gdbserver: include aarch32/aarch64 header file in corresponding source file
[deliverable/binutils-gdb.git] / gdb / dwarf2-frame.h
CommitLineData
cfc14b3a
MK
1/* Frame unwinder for frames with DWARF Call Frame Information.
2
b811d2c2 3 Copyright (C) 2003-2020 Free Software Foundation, Inc.
cfc14b3a
MK
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
a9762ec7 11 the Free Software Foundation; either version 3 of the License, or
cfc14b3a
MK
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
a9762ec7 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
cfc14b3a
MK
21
22#ifndef DWARF2_FRAME_H
23#define DWARF2_FRAME_H 1
24
ecc9ac84 25struct gdbarch;
cfc14b3a 26struct objfile;
e6e5e94c 27struct frame_info;
9f6f94ff
TT
28struct dwarf2_per_cu_data;
29struct agent_expr;
30struct axs_value;
cfc14b3a 31
05cbe71a
MK
32/* Register rule. */
33
34enum 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
30baf67b 44 code is modeling; it indicates that the register's value is
05cbe71a
MK
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
46ea248b
AO
55 /* These are defined in Dwarf3. */
56 DWARF2_FRAME_REG_SAVED_VAL_OFFSET,
57 DWARF2_FRAME_REG_SAVED_VAL_EXP,
58
05cbe71a
MK
59 /* These aren't defined by the DWARF2 CFI specification, but are
60 used internally by GDB. */
b39cc962 61 DWARF2_FRAME_REG_FN, /* Call a registered function. */
05cbe71a 62 DWARF2_FRAME_REG_RA, /* Return Address. */
8d5a9abc 63 DWARF2_FRAME_REG_RA_OFFSET, /* Return Address with offset. */
ea7963f0
FR
64 DWARF2_FRAME_REG_CFA, /* Call Frame Address. */
65 DWARF2_FRAME_REG_CFA_OFFSET /* Call Frame Address with offset. */
05cbe71a
MK
66};
67
68/* Register state. */
69
70struct 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;
b348037f
YQ
77 struct
78 {
79 const gdb_byte *start;
80 ULONGEST len;
81 } exp;
b39cc962
DJ
82 struct value *(*fn) (struct frame_info *this_frame, void **this_cache,
83 int regnum);
05cbe71a 84 } loc;
05cbe71a
MK
85 enum dwarf2_frame_reg_rule how;
86};
87
b41c5a85
JW
88enum cfa_how_kind
89{
90 CFA_UNSET,
91 CFA_REG_OFFSET,
92 CFA_EXP
93};
94
95struct dwarf2_frame_state_reg_info
96{
1c90d9f0
YQ
97 dwarf2_frame_state_reg_info () = default;
98 ~dwarf2_frame_state_reg_info ()
99 {
100 delete prev;
1c90d9f0
YQ
101 }
102
103 /* Copy constructor. */
104 dwarf2_frame_state_reg_info (const dwarf2_frame_state_reg_info &src)
780942fc 105 : reg (src.reg), cfa_offset (src.cfa_offset),
1c90d9f0
YQ
106 cfa_reg (src.cfa_reg), cfa_how (src.cfa_how), cfa_exp (src.cfa_exp),
107 prev (src.prev)
108 {
1c90d9f0
YQ
109 }
110
111 /* Assignment operator for both move-assignment and copy-assignment. */
112 dwarf2_frame_state_reg_info&
113 operator= (dwarf2_frame_state_reg_info rhs)
114 {
115 swap (*this, rhs);
116 return *this;
117 }
118
119 /* Move constructor. */
120 dwarf2_frame_state_reg_info (dwarf2_frame_state_reg_info &&rhs) noexcept
780942fc 121 : reg (std::move (rhs.reg)), cfa_offset (rhs.cfa_offset),
1c90d9f0
YQ
122 cfa_reg (rhs.cfa_reg), cfa_how (rhs.cfa_how), cfa_exp (rhs.cfa_exp),
123 prev (rhs.prev)
124 {
125 rhs.prev = nullptr;
1c90d9f0 126 }
b41c5a85 127
780942fc
TT
128 /* If necessary, enlarge the register set to hold NUM_REGS_REQUESTED
129 registers. */
1c90d9f0
YQ
130 void alloc_regs (int num_regs_requested)
131 {
780942fc 132 gdb_assert (num_regs_requested > 0);
1c90d9f0 133
780942fc
TT
134 if (num_regs_requested <= reg.size ())
135 return;
1c90d9f0 136
780942fc 137 reg.resize (num_regs_requested);
1c90d9f0
YQ
138 }
139
780942fc 140 std::vector<struct dwarf2_frame_state_reg> reg;
1c90d9f0
YQ
141
142 LONGEST cfa_offset = 0;
143 ULONGEST cfa_reg = 0;
144 enum cfa_how_kind cfa_how = CFA_UNSET;
145 const gdb_byte *cfa_exp = NULL;
b41c5a85
JW
146
147 /* Used to implement DW_CFA_remember_state. */
1c90d9f0
YQ
148 struct dwarf2_frame_state_reg_info *prev = NULL;
149
150private:
151 friend void swap (dwarf2_frame_state_reg_info& lhs,
152 dwarf2_frame_state_reg_info& rhs)
153 {
154 using std::swap;
155
156 swap (lhs.reg, rhs.reg);
1c90d9f0
YQ
157 swap (lhs.cfa_offset, rhs.cfa_offset);
158 swap (lhs.cfa_reg, rhs.cfa_reg);
159 swap (lhs.cfa_how, rhs.cfa_how);
160 swap (lhs.cfa_exp, rhs.cfa_exp);
161 swap (lhs.prev, rhs.prev);
162 }
b41c5a85
JW
163};
164
afe37d6b
YQ
165struct dwarf2_cie;
166
b41c5a85
JW
167/* Structure describing a frame state. */
168
169struct dwarf2_frame_state
170{
afe37d6b 171 dwarf2_frame_state (CORE_ADDR pc, struct dwarf2_cie *cie);
afe37d6b 172
b41c5a85
JW
173 /* Each register save state can be described in terms of a CFA slot,
174 another register, or a location expression. */
afe37d6b 175 struct dwarf2_frame_state_reg_info regs {};
b41c5a85
JW
176
177 /* The PC described by the current frame state. */
178 CORE_ADDR pc;
179
180 /* Initial register set from the CIE.
181 Used to implement DW_CFA_restore. */
afe37d6b 182 struct dwarf2_frame_state_reg_info initial {};
b41c5a85
JW
183
184 /* The information we care about from the CIE. */
afe37d6b
YQ
185 const LONGEST data_align;
186 const ULONGEST code_align;
187 const ULONGEST retaddr_column;
b41c5a85
JW
188
189 /* Flags for known producer quirks. */
190
191 /* The ARM compilers, in DWARF2 mode, assume that DW_CFA_def_cfa
192 and DW_CFA_def_cfa_offset takes a factored offset. */
afe37d6b 193 bool armcc_cfa_offsets_sf = false;
b41c5a85
JW
194
195 /* The ARM compilers, in DWARF2 or DWARF3 mode, may assume that
196 the CFA is defined as REG - OFFSET rather than REG + OFFSET. */
afe37d6b 197 bool armcc_cfa_offsets_reversed = false;
b41c5a85
JW
198};
199
3c3bb058
AB
200/* When this is true the DWARF frame unwinders can be used if they are
201 registered with the gdbarch. Not all architectures can or do use the
202 DWARF unwinders. Setting this to true on a target that does not
203 otherwise support the DWARF unwinders has no effect. */
491144b5 204extern bool dwarf2_frame_unwinders_enabled_p;
3c3bb058 205
8f22cb90
MK
206/* Set the architecture-specific register state initialization
207 function for GDBARCH to INIT_REG. */
208
209extern void dwarf2_frame_set_init_reg (struct gdbarch *gdbarch,
210 void (*init_reg) (struct gdbarch *, int,
aff37fc1
DM
211 struct dwarf2_frame_state_reg *,
212 struct frame_info *));
8f22cb90 213
3ed09a32
DJ
214/* Set the architecture-specific signal trampoline recognition
215 function for GDBARCH to SIGNAL_FRAME_P. */
216
217extern void
218 dwarf2_frame_set_signal_frame_p (struct gdbarch *gdbarch,
219 int (*signal_frame_p) (struct gdbarch *,
220 struct frame_info *));
221
4fc771b8
DJ
222/* Set the architecture-specific adjustment of .eh_frame and .debug_frame
223 register numbers. */
4bf8967c
AS
224
225extern void
4fc771b8
DJ
226 dwarf2_frame_set_adjust_regnum (struct gdbarch *gdbarch,
227 int (*adjust_regnum) (struct gdbarch *,
228 int, int));
4bf8967c 229
4a4e5149 230/* Append the DWARF-2 frame unwinders to GDBARCH's list. */
cfc14b3a 231
4a4e5149 232void dwarf2_append_unwinders (struct gdbarch *gdbarch);
cfc14b3a
MK
233
234/* Return the frame base methods for the function that contains PC, or
235 NULL if it can't be handled by the DWARF CFI frame unwinder. */
236
05cbe71a 237extern const struct frame_base *
4a4e5149 238 dwarf2_frame_base_sniffer (struct frame_info *this_frame);
cfc14b3a 239
e7802207
TT
240/* Compute the DWARF CFA for a frame. */
241
242CORE_ADDR dwarf2_frame_cfa (struct frame_info *this_frame);
243
a8fd5589
TT
244/* Find the CFA information for PC.
245
246 Return 1 if a register is used for the CFA, or 0 if another
247 expression is used. Throw an exception on error.
248
249 GDBARCH is the architecture to use.
250 DATA is the per-CU data.
251
252 REGNUM_OUT is an out parameter that is set to the register number.
253 OFFSET_OUT is the offset to use from this register.
254 These are only filled in when 1 is returned.
255
256 TEXT_OFFSET_OUT, CFA_START_OUT, and CFA_END_OUT describe the CFA
257 in other cases. These are only used when 0 is returned. */
258
259extern int dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc,
260 struct dwarf2_per_cu_data *data,
261 int *regnum_out, LONGEST *offset_out,
262 CORE_ADDR *text_offset_out,
263 const gdb_byte **cfa_start_out,
264 const gdb_byte **cfa_end_out);
9f6f94ff 265
cfc14b3a 266#endif /* dwarf2-frame.h */
This page took 1.152464 seconds and 4 git commands to generate.