Move dwarf2_frame_state_reg.exp_len to union .loc
[deliverable/binutils-gdb.git] / gdb / dwarf2-frame.h
1 /* Frame unwinder for frames with DWARF Call Frame Information.
2
3 Copyright (C) 2003-2017 Free Software Foundation, Inc.
4
5 Contributed by Mark Kettenis.
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22 #ifndef DWARF2_FRAME_H
23 #define DWARF2_FRAME_H 1
24
25 struct gdbarch;
26 struct objfile;
27 struct frame_info;
28 struct dwarf2_per_cu_data;
29 struct agent_expr;
30 struct axs_value;
31
32 /* Register rule. */
33
34 enum dwarf2_frame_reg_rule
35 {
36 /* Make certain that 0 maps onto the correct enum value; the
37 corresponding structure is being initialized using memset zero.
38 This indicates that CFI didn't provide any information at all
39 about a register, leaving how to obtain its value totally
40 unspecified. */
41 DWARF2_FRAME_REG_UNSPECIFIED = 0,
42
43 /* The term "undefined" comes from the DWARF2 CFI spec which this
44 code is moddeling; it indicates that the register's value is
45 "undefined". GCC uses the less formal term "unsaved". Its
46 definition is a combination of REG_UNDEFINED and REG_UNSPECIFIED.
47 The failure to differentiate the two helps explain a few problems
48 with the CFI generated by GCC. */
49 DWARF2_FRAME_REG_UNDEFINED,
50 DWARF2_FRAME_REG_SAVED_OFFSET,
51 DWARF2_FRAME_REG_SAVED_REG,
52 DWARF2_FRAME_REG_SAVED_EXP,
53 DWARF2_FRAME_REG_SAME_VALUE,
54
55 /* These are defined in Dwarf3. */
56 DWARF2_FRAME_REG_SAVED_VAL_OFFSET,
57 DWARF2_FRAME_REG_SAVED_VAL_EXP,
58
59 /* These aren't defined by the DWARF2 CFI specification, but are
60 used internally by GDB. */
61 DWARF2_FRAME_REG_FN, /* Call a registered function. */
62 DWARF2_FRAME_REG_RA, /* Return Address. */
63 DWARF2_FRAME_REG_RA_OFFSET, /* Return Address with offset. */
64 DWARF2_FRAME_REG_CFA, /* Call Frame Address. */
65 DWARF2_FRAME_REG_CFA_OFFSET /* Call Frame Address with offset. */
66 };
67
68 /* Register state. */
69
70 struct dwarf2_frame_state_reg
71 {
72 /* Each register save state can be described in terms of a CFA slot,
73 another register, or a location expression. */
74 union {
75 LONGEST offset;
76 ULONGEST reg;
77 struct
78 {
79 const gdb_byte *start;
80 ULONGEST len;
81 } exp;
82 struct value *(*fn) (struct frame_info *this_frame, void **this_cache,
83 int regnum);
84 } loc;
85 enum dwarf2_frame_reg_rule how;
86 };
87
88 enum cfa_how_kind
89 {
90 CFA_UNSET,
91 CFA_REG_OFFSET,
92 CFA_EXP
93 };
94
95 struct dwarf2_frame_state_reg_info
96 {
97 struct dwarf2_frame_state_reg *reg;
98 int num_regs;
99
100 LONGEST cfa_offset;
101 ULONGEST cfa_reg;
102 enum cfa_how_kind cfa_how;
103 const gdb_byte *cfa_exp;
104
105 /* Used to implement DW_CFA_remember_state. */
106 struct dwarf2_frame_state_reg_info *prev;
107 };
108
109 /* Structure describing a frame state. */
110
111 struct dwarf2_frame_state
112 {
113 /* Each register save state can be described in terms of a CFA slot,
114 another register, or a location expression. */
115 struct dwarf2_frame_state_reg_info regs;
116
117 /* The PC described by the current frame state. */
118 CORE_ADDR pc;
119
120 /* Initial register set from the CIE.
121 Used to implement DW_CFA_restore. */
122 struct dwarf2_frame_state_reg_info initial;
123
124 /* The information we care about from the CIE. */
125 LONGEST data_align;
126 ULONGEST code_align;
127 ULONGEST retaddr_column;
128
129 /* Flags for known producer quirks. */
130
131 /* The ARM compilers, in DWARF2 mode, assume that DW_CFA_def_cfa
132 and DW_CFA_def_cfa_offset takes a factored offset. */
133 int armcc_cfa_offsets_sf;
134
135 /* The ARM compilers, in DWARF2 or DWARF3 mode, may assume that
136 the CFA is defined as REG - OFFSET rather than REG + OFFSET. */
137 int armcc_cfa_offsets_reversed;
138 };
139
140 /* Set the architecture-specific register state initialization
141 function for GDBARCH to INIT_REG. */
142
143 extern void dwarf2_frame_set_init_reg (struct gdbarch *gdbarch,
144 void (*init_reg) (struct gdbarch *, int,
145 struct dwarf2_frame_state_reg *,
146 struct frame_info *));
147
148 /* Set the architecture-specific signal trampoline recognition
149 function for GDBARCH to SIGNAL_FRAME_P. */
150
151 extern void
152 dwarf2_frame_set_signal_frame_p (struct gdbarch *gdbarch,
153 int (*signal_frame_p) (struct gdbarch *,
154 struct frame_info *));
155
156 /* Set the architecture-specific adjustment of .eh_frame and .debug_frame
157 register numbers. */
158
159 extern void
160 dwarf2_frame_set_adjust_regnum (struct gdbarch *gdbarch,
161 int (*adjust_regnum) (struct gdbarch *,
162 int, int));
163
164 /* Append the DWARF-2 frame unwinders to GDBARCH's list. */
165
166 void dwarf2_append_unwinders (struct gdbarch *gdbarch);
167
168 /* Return the frame base methods for the function that contains PC, or
169 NULL if it can't be handled by the DWARF CFI frame unwinder. */
170
171 extern const struct frame_base *
172 dwarf2_frame_base_sniffer (struct frame_info *this_frame);
173
174 /* Compute the DWARF CFA for a frame. */
175
176 CORE_ADDR dwarf2_frame_cfa (struct frame_info *this_frame);
177
178 /* Assert that the register set RS is large enough to store gdbarch_num_regs
179 columns. If necessary, enlarge the register set. */
180
181 void dwarf2_frame_state_alloc_regs (struct dwarf2_frame_state_reg_info *rs,
182 int num_regs);
183
184 /* Find the CFA information for PC.
185
186 Return 1 if a register is used for the CFA, or 0 if another
187 expression is used. Throw an exception on error.
188
189 GDBARCH is the architecture to use.
190 DATA is the per-CU data.
191
192 REGNUM_OUT is an out parameter that is set to the register number.
193 OFFSET_OUT is the offset to use from this register.
194 These are only filled in when 1 is returned.
195
196 TEXT_OFFSET_OUT, CFA_START_OUT, and CFA_END_OUT describe the CFA
197 in other cases. These are only used when 0 is returned. */
198
199 extern int dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc,
200 struct dwarf2_per_cu_data *data,
201 int *regnum_out, LONGEST *offset_out,
202 CORE_ADDR *text_offset_out,
203 const gdb_byte **cfa_start_out,
204 const gdb_byte **cfa_end_out);
205
206 #endif /* dwarf2-frame.h */
This page took 0.049028 seconds and 4 git commands to generate.