1*7304104dSAndroid Build Coastguard Worker /* Interfaces for libdw.
2*7304104dSAndroid Build Coastguard Worker Copyright (C) 2002-2010, 2013, 2014, 2016, 2018 Red Hat, Inc.
3*7304104dSAndroid Build Coastguard Worker This file is part of elfutils.
4*7304104dSAndroid Build Coastguard Worker
5*7304104dSAndroid Build Coastguard Worker This file is free software; you can redistribute it and/or modify
6*7304104dSAndroid Build Coastguard Worker it under the terms of either
7*7304104dSAndroid Build Coastguard Worker
8*7304104dSAndroid Build Coastguard Worker * the GNU Lesser General Public License as published by the Free
9*7304104dSAndroid Build Coastguard Worker Software Foundation; either version 3 of the License, or (at
10*7304104dSAndroid Build Coastguard Worker your option) any later version
11*7304104dSAndroid Build Coastguard Worker
12*7304104dSAndroid Build Coastguard Worker or
13*7304104dSAndroid Build Coastguard Worker
14*7304104dSAndroid Build Coastguard Worker * the GNU General Public License as published by the Free
15*7304104dSAndroid Build Coastguard Worker Software Foundation; either version 2 of the License, or (at
16*7304104dSAndroid Build Coastguard Worker your option) any later version
17*7304104dSAndroid Build Coastguard Worker
18*7304104dSAndroid Build Coastguard Worker or both in parallel, as here.
19*7304104dSAndroid Build Coastguard Worker
20*7304104dSAndroid Build Coastguard Worker elfutils is distributed in the hope that it will be useful, but
21*7304104dSAndroid Build Coastguard Worker WITHOUT ANY WARRANTY; without even the implied warranty of
22*7304104dSAndroid Build Coastguard Worker MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23*7304104dSAndroid Build Coastguard Worker General Public License for more details.
24*7304104dSAndroid Build Coastguard Worker
25*7304104dSAndroid Build Coastguard Worker You should have received copies of the GNU General Public License and
26*7304104dSAndroid Build Coastguard Worker the GNU Lesser General Public License along with this program. If
27*7304104dSAndroid Build Coastguard Worker not, see <http://www.gnu.org/licenses/>. */
28*7304104dSAndroid Build Coastguard Worker
29*7304104dSAndroid Build Coastguard Worker #ifndef _LIBDW_H
30*7304104dSAndroid Build Coastguard Worker #define _LIBDW_H 1
31*7304104dSAndroid Build Coastguard Worker
32*7304104dSAndroid Build Coastguard Worker #include <gelf.h>
33*7304104dSAndroid Build Coastguard Worker #include <stdbool.h>
34*7304104dSAndroid Build Coastguard Worker #include <stddef.h>
35*7304104dSAndroid Build Coastguard Worker #include <stdint.h>
36*7304104dSAndroid Build Coastguard Worker
37*7304104dSAndroid Build Coastguard Worker /* Mode for the session. */
38*7304104dSAndroid Build Coastguard Worker typedef enum
39*7304104dSAndroid Build Coastguard Worker {
40*7304104dSAndroid Build Coastguard Worker DWARF_C_READ, /* Read .. */
41*7304104dSAndroid Build Coastguard Worker DWARF_C_RDWR, /* Read and write .. */
42*7304104dSAndroid Build Coastguard Worker DWARF_C_WRITE, /* Write .. */
43*7304104dSAndroid Build Coastguard Worker }
44*7304104dSAndroid Build Coastguard Worker Dwarf_Cmd;
45*7304104dSAndroid Build Coastguard Worker
46*7304104dSAndroid Build Coastguard Worker
47*7304104dSAndroid Build Coastguard Worker /* Callback results. */
48*7304104dSAndroid Build Coastguard Worker enum
49*7304104dSAndroid Build Coastguard Worker {
50*7304104dSAndroid Build Coastguard Worker DWARF_CB_OK = 0,
51*7304104dSAndroid Build Coastguard Worker DWARF_CB_ABORT
52*7304104dSAndroid Build Coastguard Worker };
53*7304104dSAndroid Build Coastguard Worker
54*7304104dSAndroid Build Coastguard Worker
55*7304104dSAndroid Build Coastguard Worker /* Error values. */
56*7304104dSAndroid Build Coastguard Worker enum
57*7304104dSAndroid Build Coastguard Worker {
58*7304104dSAndroid Build Coastguard Worker DW_TAG_invalid = 0
59*7304104dSAndroid Build Coastguard Worker #define DW_TAG_invalid DW_TAG_invalid
60*7304104dSAndroid Build Coastguard Worker };
61*7304104dSAndroid Build Coastguard Worker
62*7304104dSAndroid Build Coastguard Worker
63*7304104dSAndroid Build Coastguard Worker /* Type for offset in DWARF file. */
64*7304104dSAndroid Build Coastguard Worker typedef GElf_Off Dwarf_Off;
65*7304104dSAndroid Build Coastguard Worker
66*7304104dSAndroid Build Coastguard Worker /* Type for address in DWARF file. */
67*7304104dSAndroid Build Coastguard Worker typedef GElf_Addr Dwarf_Addr;
68*7304104dSAndroid Build Coastguard Worker
69*7304104dSAndroid Build Coastguard Worker /* Integer types. Big enough to hold any numeric value. */
70*7304104dSAndroid Build Coastguard Worker typedef GElf_Xword Dwarf_Word;
71*7304104dSAndroid Build Coastguard Worker typedef GElf_Sxword Dwarf_Sword;
72*7304104dSAndroid Build Coastguard Worker /* For the times we know we do not need that much. */
73*7304104dSAndroid Build Coastguard Worker typedef GElf_Half Dwarf_Half;
74*7304104dSAndroid Build Coastguard Worker
75*7304104dSAndroid Build Coastguard Worker
76*7304104dSAndroid Build Coastguard Worker /* DWARF abbreviation record. */
77*7304104dSAndroid Build Coastguard Worker typedef struct Dwarf_Abbrev Dwarf_Abbrev;
78*7304104dSAndroid Build Coastguard Worker
79*7304104dSAndroid Build Coastguard Worker /* Returned to show the last DIE has be returned. */
80*7304104dSAndroid Build Coastguard Worker #define DWARF_END_ABBREV ((Dwarf_Abbrev *) -1l)
81*7304104dSAndroid Build Coastguard Worker
82*7304104dSAndroid Build Coastguard Worker /* Source code line information for CU. */
83*7304104dSAndroid Build Coastguard Worker typedef struct Dwarf_Lines_s Dwarf_Lines;
84*7304104dSAndroid Build Coastguard Worker
85*7304104dSAndroid Build Coastguard Worker /* One source code line information. */
86*7304104dSAndroid Build Coastguard Worker typedef struct Dwarf_Line_s Dwarf_Line;
87*7304104dSAndroid Build Coastguard Worker
88*7304104dSAndroid Build Coastguard Worker /* Source file information. */
89*7304104dSAndroid Build Coastguard Worker typedef struct Dwarf_Files_s Dwarf_Files;
90*7304104dSAndroid Build Coastguard Worker
91*7304104dSAndroid Build Coastguard Worker /* One address range record. */
92*7304104dSAndroid Build Coastguard Worker typedef struct Dwarf_Arange_s Dwarf_Arange;
93*7304104dSAndroid Build Coastguard Worker
94*7304104dSAndroid Build Coastguard Worker /* Address ranges of a file. */
95*7304104dSAndroid Build Coastguard Worker typedef struct Dwarf_Aranges_s Dwarf_Aranges;
96*7304104dSAndroid Build Coastguard Worker
97*7304104dSAndroid Build Coastguard Worker /* CU representation. */
98*7304104dSAndroid Build Coastguard Worker struct Dwarf_CU;
99*7304104dSAndroid Build Coastguard Worker typedef struct Dwarf_CU Dwarf_CU;
100*7304104dSAndroid Build Coastguard Worker
101*7304104dSAndroid Build Coastguard Worker /* Macro information. */
102*7304104dSAndroid Build Coastguard Worker typedef struct Dwarf_Macro_s Dwarf_Macro;
103*7304104dSAndroid Build Coastguard Worker
104*7304104dSAndroid Build Coastguard Worker /* Attribute representation. */
105*7304104dSAndroid Build Coastguard Worker typedef struct
106*7304104dSAndroid Build Coastguard Worker {
107*7304104dSAndroid Build Coastguard Worker unsigned int code;
108*7304104dSAndroid Build Coastguard Worker unsigned int form;
109*7304104dSAndroid Build Coastguard Worker unsigned char *valp;
110*7304104dSAndroid Build Coastguard Worker struct Dwarf_CU *cu;
111*7304104dSAndroid Build Coastguard Worker } Dwarf_Attribute;
112*7304104dSAndroid Build Coastguard Worker
113*7304104dSAndroid Build Coastguard Worker
114*7304104dSAndroid Build Coastguard Worker /* Data block representation. */
115*7304104dSAndroid Build Coastguard Worker typedef struct
116*7304104dSAndroid Build Coastguard Worker {
117*7304104dSAndroid Build Coastguard Worker Dwarf_Word length;
118*7304104dSAndroid Build Coastguard Worker unsigned char *data;
119*7304104dSAndroid Build Coastguard Worker } Dwarf_Block;
120*7304104dSAndroid Build Coastguard Worker
121*7304104dSAndroid Build Coastguard Worker
122*7304104dSAndroid Build Coastguard Worker /* DIE information. */
123*7304104dSAndroid Build Coastguard Worker typedef struct
124*7304104dSAndroid Build Coastguard Worker {
125*7304104dSAndroid Build Coastguard Worker /* The offset can be computed from the address. */
126*7304104dSAndroid Build Coastguard Worker void *addr;
127*7304104dSAndroid Build Coastguard Worker struct Dwarf_CU *cu;
128*7304104dSAndroid Build Coastguard Worker Dwarf_Abbrev *abbrev;
129*7304104dSAndroid Build Coastguard Worker // XXX We'll see what other information will be needed.
130*7304104dSAndroid Build Coastguard Worker long int padding__;
131*7304104dSAndroid Build Coastguard Worker } Dwarf_Die;
132*7304104dSAndroid Build Coastguard Worker
133*7304104dSAndroid Build Coastguard Worker /* Returned to show the last DIE has be returned. */
134*7304104dSAndroid Build Coastguard Worker #define DWARF_END_DIE ((Dwarf_Die *) -1l)
135*7304104dSAndroid Build Coastguard Worker
136*7304104dSAndroid Build Coastguard Worker
137*7304104dSAndroid Build Coastguard Worker /* Global symbol information. */
138*7304104dSAndroid Build Coastguard Worker typedef struct
139*7304104dSAndroid Build Coastguard Worker {
140*7304104dSAndroid Build Coastguard Worker Dwarf_Off cu_offset;
141*7304104dSAndroid Build Coastguard Worker Dwarf_Off die_offset;
142*7304104dSAndroid Build Coastguard Worker const char *name;
143*7304104dSAndroid Build Coastguard Worker } Dwarf_Global;
144*7304104dSAndroid Build Coastguard Worker
145*7304104dSAndroid Build Coastguard Worker
146*7304104dSAndroid Build Coastguard Worker /* One operation in a DWARF location expression.
147*7304104dSAndroid Build Coastguard Worker A location expression is an array of these. */
148*7304104dSAndroid Build Coastguard Worker typedef struct
149*7304104dSAndroid Build Coastguard Worker {
150*7304104dSAndroid Build Coastguard Worker uint8_t atom; /* Operation */
151*7304104dSAndroid Build Coastguard Worker Dwarf_Word number; /* Operand */
152*7304104dSAndroid Build Coastguard Worker Dwarf_Word number2; /* Possible second operand */
153*7304104dSAndroid Build Coastguard Worker Dwarf_Word offset; /* Offset in location expression */
154*7304104dSAndroid Build Coastguard Worker } Dwarf_Op;
155*7304104dSAndroid Build Coastguard Worker
156*7304104dSAndroid Build Coastguard Worker
157*7304104dSAndroid Build Coastguard Worker /* This describes one Common Information Entry read from a CFI section.
158*7304104dSAndroid Build Coastguard Worker Pointers here point into the DATA->d_buf block passed to dwarf_next_cfi. */
159*7304104dSAndroid Build Coastguard Worker typedef struct
160*7304104dSAndroid Build Coastguard Worker {
161*7304104dSAndroid Build Coastguard Worker Dwarf_Off CIE_id; /* Always DW_CIE_ID_64 in Dwarf_CIE structures. */
162*7304104dSAndroid Build Coastguard Worker
163*7304104dSAndroid Build Coastguard Worker /* Instruction stream describing initial state used by FDEs. If
164*7304104dSAndroid Build Coastguard Worker we did not understand the whole augmentation string and it did
165*7304104dSAndroid Build Coastguard Worker not use 'z', then there might be more augmentation data here
166*7304104dSAndroid Build Coastguard Worker (and in FDEs) before the actual instructions. */
167*7304104dSAndroid Build Coastguard Worker const uint8_t *initial_instructions;
168*7304104dSAndroid Build Coastguard Worker const uint8_t *initial_instructions_end;
169*7304104dSAndroid Build Coastguard Worker
170*7304104dSAndroid Build Coastguard Worker Dwarf_Word code_alignment_factor;
171*7304104dSAndroid Build Coastguard Worker Dwarf_Sword data_alignment_factor;
172*7304104dSAndroid Build Coastguard Worker Dwarf_Word return_address_register;
173*7304104dSAndroid Build Coastguard Worker
174*7304104dSAndroid Build Coastguard Worker const char *augmentation; /* Augmentation string. */
175*7304104dSAndroid Build Coastguard Worker
176*7304104dSAndroid Build Coastguard Worker /* Augmentation data, might be NULL. The size is correct only if
177*7304104dSAndroid Build Coastguard Worker we understood the augmentation string sufficiently. */
178*7304104dSAndroid Build Coastguard Worker const uint8_t *augmentation_data;
179*7304104dSAndroid Build Coastguard Worker size_t augmentation_data_size;
180*7304104dSAndroid Build Coastguard Worker size_t fde_augmentation_data_size;
181*7304104dSAndroid Build Coastguard Worker } Dwarf_CIE;
182*7304104dSAndroid Build Coastguard Worker
183*7304104dSAndroid Build Coastguard Worker /* This describes one Frame Description Entry read from a CFI section.
184*7304104dSAndroid Build Coastguard Worker Pointers here point into the DATA->d_buf block passed to dwarf_next_cfi. */
185*7304104dSAndroid Build Coastguard Worker typedef struct
186*7304104dSAndroid Build Coastguard Worker {
187*7304104dSAndroid Build Coastguard Worker /* Section offset of CIE this FDE refers to. This will never be
188*7304104dSAndroid Build Coastguard Worker DW_CIE_ID_64 in an FDE. If this value is DW_CIE_ID_64, this is
189*7304104dSAndroid Build Coastguard Worker actually a Dwarf_CIE structure. */
190*7304104dSAndroid Build Coastguard Worker Dwarf_Off CIE_pointer;
191*7304104dSAndroid Build Coastguard Worker
192*7304104dSAndroid Build Coastguard Worker /* We can't really decode anything further without looking up the CIE
193*7304104dSAndroid Build Coastguard Worker and checking its augmentation string. Here follows the encoded
194*7304104dSAndroid Build Coastguard Worker initial_location and address_range, then any augmentation data,
195*7304104dSAndroid Build Coastguard Worker then the instruction stream. This FDE describes PC locations in
196*7304104dSAndroid Build Coastguard Worker the byte range [initial_location, initial_location+address_range).
197*7304104dSAndroid Build Coastguard Worker When the CIE augmentation string uses 'z', the augmentation data is
198*7304104dSAndroid Build Coastguard Worker a DW_FORM_block (self-sized). Otherwise, when we understand the
199*7304104dSAndroid Build Coastguard Worker augmentation string completely, fde_augmentation_data_size gives
200*7304104dSAndroid Build Coastguard Worker the number of bytes of augmentation data before the instructions. */
201*7304104dSAndroid Build Coastguard Worker const uint8_t *start;
202*7304104dSAndroid Build Coastguard Worker const uint8_t *end;
203*7304104dSAndroid Build Coastguard Worker } Dwarf_FDE;
204*7304104dSAndroid Build Coastguard Worker
205*7304104dSAndroid Build Coastguard Worker /* Each entry in a CFI section is either a CIE described by Dwarf_CIE or
206*7304104dSAndroid Build Coastguard Worker an FDE described by Dward_FDE. Check CIE_id to see which you have. */
207*7304104dSAndroid Build Coastguard Worker typedef union
208*7304104dSAndroid Build Coastguard Worker {
209*7304104dSAndroid Build Coastguard Worker Dwarf_Off CIE_id; /* Always DW_CIE_ID_64 in Dwarf_CIE structures. */
210*7304104dSAndroid Build Coastguard Worker Dwarf_CIE cie;
211*7304104dSAndroid Build Coastguard Worker Dwarf_FDE fde;
212*7304104dSAndroid Build Coastguard Worker } Dwarf_CFI_Entry;
213*7304104dSAndroid Build Coastguard Worker
214*7304104dSAndroid Build Coastguard Worker /* Same as DW_CIE_ID_64 from dwarf.h to keep libdw.h independent. */
215*7304104dSAndroid Build Coastguard Worker #define LIBDW_CIE_ID 0xffffffffffffffffULL
216*7304104dSAndroid Build Coastguard Worker #define dwarf_cfi_cie_p(entry) ((entry)->cie.CIE_id == LIBDW_CIE_ID)
217*7304104dSAndroid Build Coastguard Worker
218*7304104dSAndroid Build Coastguard Worker /* Opaque type representing a frame state described by CFI. */
219*7304104dSAndroid Build Coastguard Worker typedef struct Dwarf_Frame_s Dwarf_Frame;
220*7304104dSAndroid Build Coastguard Worker
221*7304104dSAndroid Build Coastguard Worker /* Opaque type representing a CFI section found in a DWARF or ELF file. */
222*7304104dSAndroid Build Coastguard Worker typedef struct Dwarf_CFI_s Dwarf_CFI;
223*7304104dSAndroid Build Coastguard Worker
224*7304104dSAndroid Build Coastguard Worker
225*7304104dSAndroid Build Coastguard Worker /* Handle for debug sessions. */
226*7304104dSAndroid Build Coastguard Worker typedef struct Dwarf Dwarf;
227*7304104dSAndroid Build Coastguard Worker
228*7304104dSAndroid Build Coastguard Worker
229*7304104dSAndroid Build Coastguard Worker /* Out-Of-Memory handler. */
230*7304104dSAndroid Build Coastguard Worker typedef void (*__noreturn_attribute__ Dwarf_OOM) (void);
231*7304104dSAndroid Build Coastguard Worker
232*7304104dSAndroid Build Coastguard Worker
233*7304104dSAndroid Build Coastguard Worker #ifdef __cplusplus
234*7304104dSAndroid Build Coastguard Worker extern "C" {
235*7304104dSAndroid Build Coastguard Worker #endif
236*7304104dSAndroid Build Coastguard Worker
237*7304104dSAndroid Build Coastguard Worker /* Create a handle for a new debug session. */
238*7304104dSAndroid Build Coastguard Worker extern Dwarf *dwarf_begin (int fildes, Dwarf_Cmd cmd);
239*7304104dSAndroid Build Coastguard Worker
240*7304104dSAndroid Build Coastguard Worker /* Create a handle for a new debug session for an ELF file. */
241*7304104dSAndroid Build Coastguard Worker extern Dwarf *dwarf_begin_elf (Elf *elf, Dwarf_Cmd cmd, Elf_Scn *scngrp);
242*7304104dSAndroid Build Coastguard Worker
243*7304104dSAndroid Build Coastguard Worker /* Retrieve ELF descriptor used for DWARF access. */
244*7304104dSAndroid Build Coastguard Worker extern Elf *dwarf_getelf (Dwarf *dwarf);
245*7304104dSAndroid Build Coastguard Worker
246*7304104dSAndroid Build Coastguard Worker /* Retrieve DWARF descriptor used for a Dwarf_Die or Dwarf_Attribute.
247*7304104dSAndroid Build Coastguard Worker A Dwarf_Die or a Dwarf_Attribute is associated with a particular
248*7304104dSAndroid Build Coastguard Worker Dwarf_CU handle. This function returns the DWARF descriptor for
249*7304104dSAndroid Build Coastguard Worker that Dwarf_CU. */
250*7304104dSAndroid Build Coastguard Worker extern Dwarf *dwarf_cu_getdwarf (Dwarf_CU *cu);
251*7304104dSAndroid Build Coastguard Worker
252*7304104dSAndroid Build Coastguard Worker /* Retrieves the DWARF descriptor for debugaltlink data. Returns NULL
253*7304104dSAndroid Build Coastguard Worker if no alternate debug data has been supplied yet. libdw will try
254*7304104dSAndroid Build Coastguard Worker to set the alt file on first use of an alt FORM if not yet explicitly
255*7304104dSAndroid Build Coastguard Worker provided by dwarf_setalt. */
256*7304104dSAndroid Build Coastguard Worker extern Dwarf *dwarf_getalt (Dwarf *main);
257*7304104dSAndroid Build Coastguard Worker
258*7304104dSAndroid Build Coastguard Worker /* Provides the data referenced by the .gnu_debugaltlink section. The
259*7304104dSAndroid Build Coastguard Worker caller should check that MAIN and ALT match (i.e., they have the
260*7304104dSAndroid Build Coastguard Worker same build ID). It is the responsibility of the caller to ensure
261*7304104dSAndroid Build Coastguard Worker that the data referenced by ALT stays valid while it is used by
262*7304104dSAndroid Build Coastguard Worker MAIN, until dwarf_setalt is called on MAIN with a different
263*7304104dSAndroid Build Coastguard Worker descriptor, or dwarf_end. Must be called before inspecting DIEs
264*7304104dSAndroid Build Coastguard Worker that might have alt FORMs. Otherwise libdw will try to set the
265*7304104dSAndroid Build Coastguard Worker alt file itself on first use. */
266*7304104dSAndroid Build Coastguard Worker extern void dwarf_setalt (Dwarf *main, Dwarf *alt);
267*7304104dSAndroid Build Coastguard Worker
268*7304104dSAndroid Build Coastguard Worker /* Release debugging handling context. */
269*7304104dSAndroid Build Coastguard Worker extern int dwarf_end (Dwarf *dwarf);
270*7304104dSAndroid Build Coastguard Worker
271*7304104dSAndroid Build Coastguard Worker
272*7304104dSAndroid Build Coastguard Worker /* Read the header for the DWARF CU. */
273*7304104dSAndroid Build Coastguard Worker extern int dwarf_nextcu (Dwarf *dwarf, Dwarf_Off off, Dwarf_Off *next_off,
274*7304104dSAndroid Build Coastguard Worker size_t *header_sizep, Dwarf_Off *abbrev_offsetp,
275*7304104dSAndroid Build Coastguard Worker uint8_t *address_sizep, uint8_t *offset_sizep)
276*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (3);
277*7304104dSAndroid Build Coastguard Worker
278*7304104dSAndroid Build Coastguard Worker /* Read the header of a DWARF CU or type unit. If TYPE_SIGNATUREP is not
279*7304104dSAndroid Build Coastguard Worker null, this reads a type unit from the .debug_types section; otherwise
280*7304104dSAndroid Build Coastguard Worker this reads a CU from the .debug_info section. */
281*7304104dSAndroid Build Coastguard Worker extern int dwarf_next_unit (Dwarf *dwarf, Dwarf_Off off, Dwarf_Off *next_off,
282*7304104dSAndroid Build Coastguard Worker size_t *header_sizep, Dwarf_Half *versionp,
283*7304104dSAndroid Build Coastguard Worker Dwarf_Off *abbrev_offsetp,
284*7304104dSAndroid Build Coastguard Worker uint8_t *address_sizep, uint8_t *offset_sizep,
285*7304104dSAndroid Build Coastguard Worker uint64_t *type_signaturep, Dwarf_Off *type_offsetp)
286*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (3);
287*7304104dSAndroid Build Coastguard Worker
288*7304104dSAndroid Build Coastguard Worker
289*7304104dSAndroid Build Coastguard Worker /* Gets the next Dwarf_CU (unit), version, unit type and if available
290*7304104dSAndroid Build Coastguard Worker the CU DIE and sub (type) DIE of the unit. Returns 0 on success,
291*7304104dSAndroid Build Coastguard Worker -1 on error or 1 if there are no more units. To start iterating
292*7304104dSAndroid Build Coastguard Worker provide NULL for CU. If version < 5 the unit type is set from the
293*7304104dSAndroid Build Coastguard Worker CU DIE if available (DW_UT_compile for DW_TAG_compile_unit,
294*7304104dSAndroid Build Coastguard Worker DW_UT_type for DW_TAG_type_unit or DW_UT_partial for
295*7304104dSAndroid Build Coastguard Worker DW_TAG_partial_unit), otherwise it is set to zero. If unavailable
296*7304104dSAndroid Build Coastguard Worker (the version or unit type is unknown) the CU DIE is cleared.
297*7304104dSAndroid Build Coastguard Worker Likewise if the sub DIE isn't isn't available (the unit type is not
298*7304104dSAndroid Build Coastguard Worker DW_UT_type or DW_UT_split_type) the sub DIE tag is cleared. */
299*7304104dSAndroid Build Coastguard Worker extern int dwarf_get_units (Dwarf *dwarf, Dwarf_CU *cu, Dwarf_CU **next_cu,
300*7304104dSAndroid Build Coastguard Worker Dwarf_Half *version, uint8_t *unit_type,
301*7304104dSAndroid Build Coastguard Worker Dwarf_Die *cudie, Dwarf_Die *subdie)
302*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (3);
303*7304104dSAndroid Build Coastguard Worker
304*7304104dSAndroid Build Coastguard Worker /* Provides information and DIEs associated with the given Dwarf_CU
305*7304104dSAndroid Build Coastguard Worker unit. Returns -1 on error, zero on success. Arguments not needed
306*7304104dSAndroid Build Coastguard Worker may be NULL. If they are NULL and aren't known yet, they won't be
307*7304104dSAndroid Build Coastguard Worker looked up. If the subdie doesn't exist for this unit_type it will
308*7304104dSAndroid Build Coastguard Worker be cleared. If there is no unit_id for this unit type it will be
309*7304104dSAndroid Build Coastguard Worker set to zero. */
310*7304104dSAndroid Build Coastguard Worker extern int dwarf_cu_info (Dwarf_CU *cu,
311*7304104dSAndroid Build Coastguard Worker Dwarf_Half *version, uint8_t *unit_type,
312*7304104dSAndroid Build Coastguard Worker Dwarf_Die *cudie, Dwarf_Die *subdie,
313*7304104dSAndroid Build Coastguard Worker uint64_t *unit_id,
314*7304104dSAndroid Build Coastguard Worker uint8_t *address_size, uint8_t *offset_size);
315*7304104dSAndroid Build Coastguard Worker
316*7304104dSAndroid Build Coastguard Worker /* Decode one DWARF CFI entry (CIE or FDE) from the raw section data.
317*7304104dSAndroid Build Coastguard Worker The E_IDENT from the originating ELF file indicates the address
318*7304104dSAndroid Build Coastguard Worker size and byte order used in the CFI section contained in DATA;
319*7304104dSAndroid Build Coastguard Worker EH_FRAME_P should be true for .eh_frame format and false for
320*7304104dSAndroid Build Coastguard Worker .debug_frame format. OFFSET is the byte position in the section
321*7304104dSAndroid Build Coastguard Worker to start at; on return *NEXT_OFFSET is filled in with the byte
322*7304104dSAndroid Build Coastguard Worker position immediately after this entry.
323*7304104dSAndroid Build Coastguard Worker
324*7304104dSAndroid Build Coastguard Worker On success, returns 0 and fills in *ENTRY; use dwarf_cfi_cie_p to
325*7304104dSAndroid Build Coastguard Worker see whether ENTRY->cie or ENTRY->fde is valid.
326*7304104dSAndroid Build Coastguard Worker
327*7304104dSAndroid Build Coastguard Worker On errors, returns -1. Some format errors will permit safely
328*7304104dSAndroid Build Coastguard Worker skipping to the next CFI entry though the current one is unusable.
329*7304104dSAndroid Build Coastguard Worker In that case, *NEXT_OFF will be updated before a -1 return.
330*7304104dSAndroid Build Coastguard Worker
331*7304104dSAndroid Build Coastguard Worker If there are no more CFI entries left in the section,
332*7304104dSAndroid Build Coastguard Worker returns 1 and sets *NEXT_OFFSET to (Dwarf_Off) -1. */
333*7304104dSAndroid Build Coastguard Worker extern int dwarf_next_cfi (const unsigned char e_ident[],
334*7304104dSAndroid Build Coastguard Worker Elf_Data *data, bool eh_frame_p,
335*7304104dSAndroid Build Coastguard Worker Dwarf_Off offset, Dwarf_Off *next_offset,
336*7304104dSAndroid Build Coastguard Worker Dwarf_CFI_Entry *entry)
337*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (1, 2, 5, 6);
338*7304104dSAndroid Build Coastguard Worker
339*7304104dSAndroid Build Coastguard Worker /* Use the CFI in the DWARF .debug_frame section.
340*7304104dSAndroid Build Coastguard Worker Returns NULL if there is no such section (not an error).
341*7304104dSAndroid Build Coastguard Worker The pointer returned can be used until dwarf_end is called on DWARF,
342*7304104dSAndroid Build Coastguard Worker and must not be passed to dwarf_cfi_end.
343*7304104dSAndroid Build Coastguard Worker Calling this more than once returns the same pointer. */
344*7304104dSAndroid Build Coastguard Worker extern Dwarf_CFI *dwarf_getcfi (Dwarf *dwarf);
345*7304104dSAndroid Build Coastguard Worker
346*7304104dSAndroid Build Coastguard Worker /* Use the CFI in the ELF file's exception-handling data.
347*7304104dSAndroid Build Coastguard Worker Returns NULL if there is no such data.
348*7304104dSAndroid Build Coastguard Worker The pointer returned can be used until elf_end is called on ELF,
349*7304104dSAndroid Build Coastguard Worker and must be passed to dwarf_cfi_end before then.
350*7304104dSAndroid Build Coastguard Worker Calling this more than once allocates independent data structures. */
351*7304104dSAndroid Build Coastguard Worker extern Dwarf_CFI *dwarf_getcfi_elf (Elf *elf);
352*7304104dSAndroid Build Coastguard Worker
353*7304104dSAndroid Build Coastguard Worker /* Release resources allocated by dwarf_getcfi_elf. */
354*7304104dSAndroid Build Coastguard Worker extern int dwarf_cfi_end (Dwarf_CFI *cache);
355*7304104dSAndroid Build Coastguard Worker
356*7304104dSAndroid Build Coastguard Worker
357*7304104dSAndroid Build Coastguard Worker /* Return DIE at given offset in .debug_info section. */
358*7304104dSAndroid Build Coastguard Worker extern Dwarf_Die *dwarf_offdie (Dwarf *dbg, Dwarf_Off offset,
359*7304104dSAndroid Build Coastguard Worker Dwarf_Die *result) __nonnull_attribute__ (3);
360*7304104dSAndroid Build Coastguard Worker
361*7304104dSAndroid Build Coastguard Worker /* Return DIE at given offset in .debug_types section. */
362*7304104dSAndroid Build Coastguard Worker extern Dwarf_Die *dwarf_offdie_types (Dwarf *dbg, Dwarf_Off offset,
363*7304104dSAndroid Build Coastguard Worker Dwarf_Die *result)
364*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (3);
365*7304104dSAndroid Build Coastguard Worker
366*7304104dSAndroid Build Coastguard Worker /* Return offset of DIE. */
367*7304104dSAndroid Build Coastguard Worker extern Dwarf_Off dwarf_dieoffset (Dwarf_Die *die);
368*7304104dSAndroid Build Coastguard Worker
369*7304104dSAndroid Build Coastguard Worker /* Return offset of DIE in CU. */
370*7304104dSAndroid Build Coastguard Worker extern Dwarf_Off dwarf_cuoffset (Dwarf_Die *die);
371*7304104dSAndroid Build Coastguard Worker
372*7304104dSAndroid Build Coastguard Worker /* Return CU DIE containing given DIE. */
373*7304104dSAndroid Build Coastguard Worker extern Dwarf_Die *dwarf_diecu (Dwarf_Die *die, Dwarf_Die *result,
374*7304104dSAndroid Build Coastguard Worker uint8_t *address_sizep, uint8_t *offset_sizep)
375*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
376*7304104dSAndroid Build Coastguard Worker
377*7304104dSAndroid Build Coastguard Worker /* Given a Dwarf_Die addr returns a (reconstructed) Dwarf_Die, or NULL
378*7304104dSAndroid Build Coastguard Worker if the given addr didn't come from a valid Dwarf_Die. In particular
379*7304104dSAndroid Build Coastguard Worker it will make sure that the correct Dwarf_CU pointer is set for the
380*7304104dSAndroid Build Coastguard Worker Dwarf_Die, the Dwarf_Abbrev pointer will not be set up yet (it will
381*7304104dSAndroid Build Coastguard Worker only be once the Dwarf_Die is used to read attributes, children or
382*7304104dSAndroid Build Coastguard Worker siblings). This functions can be used to keep a reference to a
383*7304104dSAndroid Build Coastguard Worker Dwarf_Die which you want to refer to later. The addr, and the result
384*7304104dSAndroid Build Coastguard Worker of this function, is only valid while the associated Dwarf is valid. */
385*7304104dSAndroid Build Coastguard Worker extern Dwarf_Die *dwarf_die_addr_die (Dwarf *dbg, void *addr,
386*7304104dSAndroid Build Coastguard Worker Dwarf_Die *result)
387*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (3);
388*7304104dSAndroid Build Coastguard Worker
389*7304104dSAndroid Build Coastguard Worker /* Return the CU DIE and the header info associated with a Dwarf_Die
390*7304104dSAndroid Build Coastguard Worker or Dwarf_Attribute. A Dwarf_Die or a Dwarf_Attribute is associated
391*7304104dSAndroid Build Coastguard Worker with a particular Dwarf_CU handle. This function returns the CU or
392*7304104dSAndroid Build Coastguard Worker type unit DIE and header information for that Dwarf_CU. The
393*7304104dSAndroid Build Coastguard Worker returned DIE is either a compile_unit, partial_unit or type_unit.
394*7304104dSAndroid Build Coastguard Worker If it is a type_unit, then the type signature and type offset are
395*7304104dSAndroid Build Coastguard Worker also provided, otherwise type_offset will be set to zero. See also
396*7304104dSAndroid Build Coastguard Worker dwarf_diecu and dwarf_next_unit. */
397*7304104dSAndroid Build Coastguard Worker extern Dwarf_Die *dwarf_cu_die (Dwarf_CU *cu, Dwarf_Die *result,
398*7304104dSAndroid Build Coastguard Worker Dwarf_Half *versionp,
399*7304104dSAndroid Build Coastguard Worker Dwarf_Off *abbrev_offsetp,
400*7304104dSAndroid Build Coastguard Worker uint8_t *address_sizep,
401*7304104dSAndroid Build Coastguard Worker uint8_t *offset_sizep,
402*7304104dSAndroid Build Coastguard Worker uint64_t *type_signaturep,
403*7304104dSAndroid Build Coastguard Worker Dwarf_Off *type_offsetp)
404*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
405*7304104dSAndroid Build Coastguard Worker
406*7304104dSAndroid Build Coastguard Worker /* Return CU DIE containing given address. */
407*7304104dSAndroid Build Coastguard Worker extern Dwarf_Die *dwarf_addrdie (Dwarf *dbg, Dwarf_Addr addr,
408*7304104dSAndroid Build Coastguard Worker Dwarf_Die *result) __nonnull_attribute__ (3);
409*7304104dSAndroid Build Coastguard Worker
410*7304104dSAndroid Build Coastguard Worker /* Return child of current DIE. */
411*7304104dSAndroid Build Coastguard Worker extern int dwarf_child (Dwarf_Die *die, Dwarf_Die *result)
412*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
413*7304104dSAndroid Build Coastguard Worker
414*7304104dSAndroid Build Coastguard Worker /* Locates the first sibling of DIE and places it in RESULT.
415*7304104dSAndroid Build Coastguard Worker Returns 0 if a sibling was found, -1 if something went wrong.
416*7304104dSAndroid Build Coastguard Worker Returns 1 if no sibling could be found and, if RESULT is not
417*7304104dSAndroid Build Coastguard Worker the same as DIE, it sets RESULT->addr to the address of the
418*7304104dSAndroid Build Coastguard Worker (non-sibling) DIE that follows this one, or NULL if this DIE
419*7304104dSAndroid Build Coastguard Worker was the last one in the compilation unit. */
420*7304104dSAndroid Build Coastguard Worker extern int dwarf_siblingof (Dwarf_Die *die, Dwarf_Die *result)
421*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
422*7304104dSAndroid Build Coastguard Worker
423*7304104dSAndroid Build Coastguard Worker /* For type aliases and qualifier type DIEs, which don't modify or
424*7304104dSAndroid Build Coastguard Worker change the structural layout of the underlying type, follow the
425*7304104dSAndroid Build Coastguard Worker DW_AT_type attribute (recursively) and return the underlying type
426*7304104dSAndroid Build Coastguard Worker Dwarf_Die.
427*7304104dSAndroid Build Coastguard Worker
428*7304104dSAndroid Build Coastguard Worker Returns 0 when RESULT contains a Dwarf_Die (possibly equal to the
429*7304104dSAndroid Build Coastguard Worker given DIE) that isn't a type alias or qualifier type. Returns 1
430*7304104dSAndroid Build Coastguard Worker when RESULT contains a type alias or qualifier Dwarf_Die that
431*7304104dSAndroid Build Coastguard Worker couldn't be peeled further (it doesn't have a DW_TAG_type
432*7304104dSAndroid Build Coastguard Worker attribute). Returns -1 when an error occurred.
433*7304104dSAndroid Build Coastguard Worker
434*7304104dSAndroid Build Coastguard Worker The current DWARF specification defines one type alias tag
435*7304104dSAndroid Build Coastguard Worker (DW_TAG_typedef) and seven modifier/qualifier type tags
436*7304104dSAndroid Build Coastguard Worker (DW_TAG_const_type, DW_TAG_volatile_type, DW_TAG_restrict_type,
437*7304104dSAndroid Build Coastguard Worker DW_TAG_atomic_type, DW_TAG_immutable_type, DW_TAG_packed_type and
438*7304104dSAndroid Build Coastguard Worker DW_TAG_shared_type). This function won't peel modifier type
439*7304104dSAndroid Build Coastguard Worker tags that change the way the underlying type is accessed such
440*7304104dSAndroid Build Coastguard Worker as the pointer or reference type tags (DW_TAG_pointer_type,
441*7304104dSAndroid Build Coastguard Worker DW_TAG_reference_type or DW_TAG_rvalue_reference_type).
442*7304104dSAndroid Build Coastguard Worker
443*7304104dSAndroid Build Coastguard Worker A future version of this function might peel other alias or
444*7304104dSAndroid Build Coastguard Worker qualifier type tags if a future DWARF version or GNU extension
445*7304104dSAndroid Build Coastguard Worker defines other type aliases or qualifier type tags that don't modify,
446*7304104dSAndroid Build Coastguard Worker change the structural layout or the way to access the underlying type. */
447*7304104dSAndroid Build Coastguard Worker extern int dwarf_peel_type (Dwarf_Die *die, Dwarf_Die *result)
448*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
449*7304104dSAndroid Build Coastguard Worker
450*7304104dSAndroid Build Coastguard Worker /* Check whether the DIE has children. */
451*7304104dSAndroid Build Coastguard Worker extern int dwarf_haschildren (Dwarf_Die *die) __nonnull_attribute__ (1);
452*7304104dSAndroid Build Coastguard Worker
453*7304104dSAndroid Build Coastguard Worker /* Walks the attributes of DIE, starting at the one OFFSET bytes in,
454*7304104dSAndroid Build Coastguard Worker calling the CALLBACK function for each one. Stops if the callback
455*7304104dSAndroid Build Coastguard Worker function ever returns a value other than DWARF_CB_OK and returns the
456*7304104dSAndroid Build Coastguard Worker offset of the offending attribute. If the end of the attributes
457*7304104dSAndroid Build Coastguard Worker is reached 1 is returned. If something goes wrong -1 is returned and
458*7304104dSAndroid Build Coastguard Worker the dwarf error number is set. */
459*7304104dSAndroid Build Coastguard Worker extern ptrdiff_t dwarf_getattrs (Dwarf_Die *die,
460*7304104dSAndroid Build Coastguard Worker int (*callback) (Dwarf_Attribute *, void *),
461*7304104dSAndroid Build Coastguard Worker void *arg, ptrdiff_t offset)
462*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
463*7304104dSAndroid Build Coastguard Worker
464*7304104dSAndroid Build Coastguard Worker /* Return tag of given DIE. */
465*7304104dSAndroid Build Coastguard Worker extern int dwarf_tag (Dwarf_Die *die) __nonnull_attribute__ (1);
466*7304104dSAndroid Build Coastguard Worker
467*7304104dSAndroid Build Coastguard Worker
468*7304104dSAndroid Build Coastguard Worker /* Return specific attribute of DIE. */
469*7304104dSAndroid Build Coastguard Worker extern Dwarf_Attribute *dwarf_attr (Dwarf_Die *die, unsigned int search_name,
470*7304104dSAndroid Build Coastguard Worker Dwarf_Attribute *result)
471*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (3);
472*7304104dSAndroid Build Coastguard Worker
473*7304104dSAndroid Build Coastguard Worker /* Check whether given DIE has specific attribute. */
474*7304104dSAndroid Build Coastguard Worker extern int dwarf_hasattr (Dwarf_Die *die, unsigned int search_name);
475*7304104dSAndroid Build Coastguard Worker
476*7304104dSAndroid Build Coastguard Worker /* These are the same as dwarf_attr and dwarf_hasattr, respectively,
477*7304104dSAndroid Build Coastguard Worker but they resolve an indirect attribute through
478*7304104dSAndroid Build Coastguard Worker DW_AT_abstract_origin, DW_AT_specification or, if the DIE is a
479*7304104dSAndroid Build Coastguard Worker top-level split CU, the skeleton DIE. Note that the attribute
480*7304104dSAndroid Build Coastguard Worker might come from a DIE in a different CU (possibly from a different
481*7304104dSAndroid Build Coastguard Worker Dwarf file). In that case all attribute information needs to be
482*7304104dSAndroid Build Coastguard Worker resolved through the CU associated with the returned
483*7304104dSAndroid Build Coastguard Worker Dwarf_Attribute. The dwarf_form functions already do this
484*7304104dSAndroid Build Coastguard Worker automatically. */
485*7304104dSAndroid Build Coastguard Worker extern Dwarf_Attribute *dwarf_attr_integrate (Dwarf_Die *die,
486*7304104dSAndroid Build Coastguard Worker unsigned int search_name,
487*7304104dSAndroid Build Coastguard Worker Dwarf_Attribute *result)
488*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (3);
489*7304104dSAndroid Build Coastguard Worker extern int dwarf_hasattr_integrate (Dwarf_Die *die, unsigned int search_name);
490*7304104dSAndroid Build Coastguard Worker
491*7304104dSAndroid Build Coastguard Worker
492*7304104dSAndroid Build Coastguard Worker
493*7304104dSAndroid Build Coastguard Worker
494*7304104dSAndroid Build Coastguard Worker /* Check whether given attribute has specific form. */
495*7304104dSAndroid Build Coastguard Worker extern int dwarf_hasform (Dwarf_Attribute *attr, unsigned int search_form);
496*7304104dSAndroid Build Coastguard Worker
497*7304104dSAndroid Build Coastguard Worker /* Return attribute code of given attribute. */
498*7304104dSAndroid Build Coastguard Worker extern unsigned int dwarf_whatattr (Dwarf_Attribute *attr);
499*7304104dSAndroid Build Coastguard Worker
500*7304104dSAndroid Build Coastguard Worker /* Return form code of given attribute. */
501*7304104dSAndroid Build Coastguard Worker extern unsigned int dwarf_whatform (Dwarf_Attribute *attr);
502*7304104dSAndroid Build Coastguard Worker
503*7304104dSAndroid Build Coastguard Worker
504*7304104dSAndroid Build Coastguard Worker /* Return string associated with given attribute. */
505*7304104dSAndroid Build Coastguard Worker extern const char *dwarf_formstring (Dwarf_Attribute *attrp);
506*7304104dSAndroid Build Coastguard Worker
507*7304104dSAndroid Build Coastguard Worker /* Return unsigned constant represented by attribute. */
508*7304104dSAndroid Build Coastguard Worker extern int dwarf_formudata (Dwarf_Attribute *attr, Dwarf_Word *return_uval)
509*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
510*7304104dSAndroid Build Coastguard Worker
511*7304104dSAndroid Build Coastguard Worker /* Return signed constant represented by attribute. */
512*7304104dSAndroid Build Coastguard Worker extern int dwarf_formsdata (Dwarf_Attribute *attr, Dwarf_Sword *return_uval)
513*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
514*7304104dSAndroid Build Coastguard Worker
515*7304104dSAndroid Build Coastguard Worker /* Return address represented by attribute. */
516*7304104dSAndroid Build Coastguard Worker extern int dwarf_formaddr (Dwarf_Attribute *attr, Dwarf_Addr *return_addr)
517*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
518*7304104dSAndroid Build Coastguard Worker
519*7304104dSAndroid Build Coastguard Worker /* This function is deprecated. Always use dwarf_formref_die instead.
520*7304104dSAndroid Build Coastguard Worker Return reference offset represented by attribute. */
521*7304104dSAndroid Build Coastguard Worker extern int dwarf_formref (Dwarf_Attribute *attr, Dwarf_Off *return_offset)
522*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2) __deprecated_attribute__;
523*7304104dSAndroid Build Coastguard Worker
524*7304104dSAndroid Build Coastguard Worker /* Look up the DIE in a reference-form attribute. */
525*7304104dSAndroid Build Coastguard Worker extern Dwarf_Die *dwarf_formref_die (Dwarf_Attribute *attr, Dwarf_Die *die_mem)
526*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
527*7304104dSAndroid Build Coastguard Worker
528*7304104dSAndroid Build Coastguard Worker /* Return block represented by attribute. */
529*7304104dSAndroid Build Coastguard Worker extern int dwarf_formblock (Dwarf_Attribute *attr, Dwarf_Block *return_block)
530*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
531*7304104dSAndroid Build Coastguard Worker
532*7304104dSAndroid Build Coastguard Worker /* Return flag represented by attribute. */
533*7304104dSAndroid Build Coastguard Worker extern int dwarf_formflag (Dwarf_Attribute *attr, bool *return_bool)
534*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
535*7304104dSAndroid Build Coastguard Worker
536*7304104dSAndroid Build Coastguard Worker
537*7304104dSAndroid Build Coastguard Worker /* Simplified attribute value access functions. */
538*7304104dSAndroid Build Coastguard Worker
539*7304104dSAndroid Build Coastguard Worker /* Return string in name attribute of DIE. */
540*7304104dSAndroid Build Coastguard Worker extern const char *dwarf_diename (Dwarf_Die *die);
541*7304104dSAndroid Build Coastguard Worker
542*7304104dSAndroid Build Coastguard Worker /* Return high PC attribute of DIE. */
543*7304104dSAndroid Build Coastguard Worker extern int dwarf_highpc (Dwarf_Die *die, Dwarf_Addr *return_addr)
544*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
545*7304104dSAndroid Build Coastguard Worker
546*7304104dSAndroid Build Coastguard Worker /* Return low PC attribute of DIE. */
547*7304104dSAndroid Build Coastguard Worker extern int dwarf_lowpc (Dwarf_Die *die, Dwarf_Addr *return_addr)
548*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
549*7304104dSAndroid Build Coastguard Worker
550*7304104dSAndroid Build Coastguard Worker /* Return entry_pc or low_pc attribute of DIE. */
551*7304104dSAndroid Build Coastguard Worker extern int dwarf_entrypc (Dwarf_Die *die, Dwarf_Addr *return_addr)
552*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
553*7304104dSAndroid Build Coastguard Worker
554*7304104dSAndroid Build Coastguard Worker /* Return 1 if DIE's lowpc/highpc or ranges attributes match the PC address,
555*7304104dSAndroid Build Coastguard Worker 0 if not, or -1 for errors. */
556*7304104dSAndroid Build Coastguard Worker extern int dwarf_haspc (Dwarf_Die *die, Dwarf_Addr pc);
557*7304104dSAndroid Build Coastguard Worker
558*7304104dSAndroid Build Coastguard Worker /* Enumerate the PC address ranges covered by this DIE, covering all
559*7304104dSAndroid Build Coastguard Worker addresses where dwarf_haspc returns true. In the first call OFFSET
560*7304104dSAndroid Build Coastguard Worker should be zero and *BASEP need not be initialized. Returns -1 for
561*7304104dSAndroid Build Coastguard Worker errors, zero when there are no more address ranges to report, or a
562*7304104dSAndroid Build Coastguard Worker nonzero OFFSET value to pass to the next call. Each subsequent call
563*7304104dSAndroid Build Coastguard Worker must preserve *BASEP from the prior call. Successful calls fill in
564*7304104dSAndroid Build Coastguard Worker *STARTP and *ENDP with a contiguous address range. */
565*7304104dSAndroid Build Coastguard Worker extern ptrdiff_t dwarf_ranges (Dwarf_Die *die,
566*7304104dSAndroid Build Coastguard Worker ptrdiff_t offset, Dwarf_Addr *basep,
567*7304104dSAndroid Build Coastguard Worker Dwarf_Addr *startp, Dwarf_Addr *endp);
568*7304104dSAndroid Build Coastguard Worker
569*7304104dSAndroid Build Coastguard Worker
570*7304104dSAndroid Build Coastguard Worker /* Return byte size attribute of DIE. */
571*7304104dSAndroid Build Coastguard Worker extern int dwarf_bytesize (Dwarf_Die *die);
572*7304104dSAndroid Build Coastguard Worker
573*7304104dSAndroid Build Coastguard Worker /* Return bit size attribute of DIE. */
574*7304104dSAndroid Build Coastguard Worker extern int dwarf_bitsize (Dwarf_Die *die);
575*7304104dSAndroid Build Coastguard Worker
576*7304104dSAndroid Build Coastguard Worker /* Return bit offset attribute of DIE. */
577*7304104dSAndroid Build Coastguard Worker extern int dwarf_bitoffset (Dwarf_Die *die);
578*7304104dSAndroid Build Coastguard Worker
579*7304104dSAndroid Build Coastguard Worker /* Return array order attribute of DIE. */
580*7304104dSAndroid Build Coastguard Worker extern int dwarf_arrayorder (Dwarf_Die *die);
581*7304104dSAndroid Build Coastguard Worker
582*7304104dSAndroid Build Coastguard Worker /* Return source language attribute of DIE. */
583*7304104dSAndroid Build Coastguard Worker extern int dwarf_srclang (Dwarf_Die *die);
584*7304104dSAndroid Build Coastguard Worker
585*7304104dSAndroid Build Coastguard Worker
586*7304104dSAndroid Build Coastguard Worker /* Get abbreviation at given offset for given DIE. */
587*7304104dSAndroid Build Coastguard Worker extern Dwarf_Abbrev *dwarf_getabbrev (Dwarf_Die *die, Dwarf_Off offset,
588*7304104dSAndroid Build Coastguard Worker size_t *lengthp);
589*7304104dSAndroid Build Coastguard Worker
590*7304104dSAndroid Build Coastguard Worker /* Get abbreviation at given offset in .debug_abbrev section. */
591*7304104dSAndroid Build Coastguard Worker extern int dwarf_offabbrev (Dwarf *dbg, Dwarf_Off offset, size_t *lengthp,
592*7304104dSAndroid Build Coastguard Worker Dwarf_Abbrev *abbrevp)
593*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (4);
594*7304104dSAndroid Build Coastguard Worker
595*7304104dSAndroid Build Coastguard Worker /* Get abbreviation code. */
596*7304104dSAndroid Build Coastguard Worker extern unsigned int dwarf_getabbrevcode (Dwarf_Abbrev *abbrev);
597*7304104dSAndroid Build Coastguard Worker
598*7304104dSAndroid Build Coastguard Worker /* Get abbreviation tag. */
599*7304104dSAndroid Build Coastguard Worker extern unsigned int dwarf_getabbrevtag (Dwarf_Abbrev *abbrev);
600*7304104dSAndroid Build Coastguard Worker
601*7304104dSAndroid Build Coastguard Worker /* Return true if abbreviation is children flag set. */
602*7304104dSAndroid Build Coastguard Worker extern int dwarf_abbrevhaschildren (Dwarf_Abbrev *abbrev);
603*7304104dSAndroid Build Coastguard Worker
604*7304104dSAndroid Build Coastguard Worker /* Get number of attributes of abbreviation. */
605*7304104dSAndroid Build Coastguard Worker extern int dwarf_getattrcnt (Dwarf_Abbrev *abbrev, size_t *attrcntp)
606*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
607*7304104dSAndroid Build Coastguard Worker
608*7304104dSAndroid Build Coastguard Worker /* Get specific attribute of abbreviation. */
609*7304104dSAndroid Build Coastguard Worker extern int dwarf_getabbrevattr (Dwarf_Abbrev *abbrev, size_t idx,
610*7304104dSAndroid Build Coastguard Worker unsigned int *namep, unsigned int *formp,
611*7304104dSAndroid Build Coastguard Worker Dwarf_Off *offset);
612*7304104dSAndroid Build Coastguard Worker
613*7304104dSAndroid Build Coastguard Worker /* Get specific attribute of abbreviation and any data encoded with it.
614*7304104dSAndroid Build Coastguard Worker Specifically for DW_FORM_implicit_const data will be set to the
615*7304104dSAndroid Build Coastguard Worker constant value associated. */
616*7304104dSAndroid Build Coastguard Worker extern int dwarf_getabbrevattr_data (Dwarf_Abbrev *abbrev, size_t idx,
617*7304104dSAndroid Build Coastguard Worker unsigned int *namep, unsigned int *formp,
618*7304104dSAndroid Build Coastguard Worker Dwarf_Sword *datap, Dwarf_Off *offset);
619*7304104dSAndroid Build Coastguard Worker
620*7304104dSAndroid Build Coastguard Worker /* Get string from-debug_str section. */
621*7304104dSAndroid Build Coastguard Worker extern const char *dwarf_getstring (Dwarf *dbg, Dwarf_Off offset,
622*7304104dSAndroid Build Coastguard Worker size_t *lenp);
623*7304104dSAndroid Build Coastguard Worker
624*7304104dSAndroid Build Coastguard Worker
625*7304104dSAndroid Build Coastguard Worker /* Get public symbol information. */
626*7304104dSAndroid Build Coastguard Worker extern ptrdiff_t dwarf_getpubnames (Dwarf *dbg,
627*7304104dSAndroid Build Coastguard Worker int (*callback) (Dwarf *, Dwarf_Global *,
628*7304104dSAndroid Build Coastguard Worker void *),
629*7304104dSAndroid Build Coastguard Worker void *arg, ptrdiff_t offset)
630*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
631*7304104dSAndroid Build Coastguard Worker
632*7304104dSAndroid Build Coastguard Worker
633*7304104dSAndroid Build Coastguard Worker /* Get source file information for CU. */
634*7304104dSAndroid Build Coastguard Worker extern int dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines,
635*7304104dSAndroid Build Coastguard Worker size_t *nlines) __nonnull_attribute__ (2, 3);
636*7304104dSAndroid Build Coastguard Worker
637*7304104dSAndroid Build Coastguard Worker /* Return one of the source lines of the CU. */
638*7304104dSAndroid Build Coastguard Worker extern Dwarf_Line *dwarf_onesrcline (Dwarf_Lines *lines, size_t idx);
639*7304104dSAndroid Build Coastguard Worker
640*7304104dSAndroid Build Coastguard Worker /* Get the file source files used in the CU. */
641*7304104dSAndroid Build Coastguard Worker extern int dwarf_getsrcfiles (Dwarf_Die *cudie, Dwarf_Files **files,
642*7304104dSAndroid Build Coastguard Worker size_t *nfiles)
643*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
644*7304104dSAndroid Build Coastguard Worker
645*7304104dSAndroid Build Coastguard Worker
646*7304104dSAndroid Build Coastguard Worker /* Get source for address in CU. */
647*7304104dSAndroid Build Coastguard Worker extern Dwarf_Line *dwarf_getsrc_die (Dwarf_Die *cudie, Dwarf_Addr addr);
648*7304104dSAndroid Build Coastguard Worker
649*7304104dSAndroid Build Coastguard Worker /* Get source for file and line number. */
650*7304104dSAndroid Build Coastguard Worker extern int dwarf_getsrc_file (Dwarf *dbg, const char *fname, int line, int col,
651*7304104dSAndroid Build Coastguard Worker Dwarf_Line ***srcsp, size_t *nsrcs)
652*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2, 5, 6);
653*7304104dSAndroid Build Coastguard Worker
654*7304104dSAndroid Build Coastguard Worker
655*7304104dSAndroid Build Coastguard Worker /* Return line address. */
656*7304104dSAndroid Build Coastguard Worker extern int dwarf_lineaddr (Dwarf_Line *line, Dwarf_Addr *addrp);
657*7304104dSAndroid Build Coastguard Worker
658*7304104dSAndroid Build Coastguard Worker /* Return line VLIW operation index. */
659*7304104dSAndroid Build Coastguard Worker extern int dwarf_lineop_index (Dwarf_Line *line, unsigned int *op_indexp);
660*7304104dSAndroid Build Coastguard Worker
661*7304104dSAndroid Build Coastguard Worker /* Return line number. */
662*7304104dSAndroid Build Coastguard Worker extern int dwarf_lineno (Dwarf_Line *line, int *linep)
663*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
664*7304104dSAndroid Build Coastguard Worker
665*7304104dSAndroid Build Coastguard Worker /* Return column in line. */
666*7304104dSAndroid Build Coastguard Worker extern int dwarf_linecol (Dwarf_Line *line, int *colp)
667*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
668*7304104dSAndroid Build Coastguard Worker
669*7304104dSAndroid Build Coastguard Worker /* Return true if record is for beginning of a statement. */
670*7304104dSAndroid Build Coastguard Worker extern int dwarf_linebeginstatement (Dwarf_Line *line, bool *flagp)
671*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
672*7304104dSAndroid Build Coastguard Worker
673*7304104dSAndroid Build Coastguard Worker /* Return true if record is for end of sequence. */
674*7304104dSAndroid Build Coastguard Worker extern int dwarf_lineendsequence (Dwarf_Line *line, bool *flagp)
675*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
676*7304104dSAndroid Build Coastguard Worker
677*7304104dSAndroid Build Coastguard Worker /* Return true if record is for beginning of a basic block. */
678*7304104dSAndroid Build Coastguard Worker extern int dwarf_lineblock (Dwarf_Line *line, bool *flagp)
679*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
680*7304104dSAndroid Build Coastguard Worker
681*7304104dSAndroid Build Coastguard Worker /* Return true if record is for end of prologue. */
682*7304104dSAndroid Build Coastguard Worker extern int dwarf_lineprologueend (Dwarf_Line *line, bool *flagp)
683*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
684*7304104dSAndroid Build Coastguard Worker
685*7304104dSAndroid Build Coastguard Worker /* Return true if record is for beginning of epilogue. */
686*7304104dSAndroid Build Coastguard Worker extern int dwarf_lineepiloguebegin (Dwarf_Line *line, bool *flagp)
687*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
688*7304104dSAndroid Build Coastguard Worker
689*7304104dSAndroid Build Coastguard Worker /* Return instruction-set architecture in this record. */
690*7304104dSAndroid Build Coastguard Worker extern int dwarf_lineisa (Dwarf_Line *line, unsigned int *isap)
691*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
692*7304104dSAndroid Build Coastguard Worker
693*7304104dSAndroid Build Coastguard Worker /* Return code path discriminator in this record. */
694*7304104dSAndroid Build Coastguard Worker extern int dwarf_linediscriminator (Dwarf_Line *line, unsigned int *discp)
695*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
696*7304104dSAndroid Build Coastguard Worker
697*7304104dSAndroid Build Coastguard Worker
698*7304104dSAndroid Build Coastguard Worker /* Find line information for address. The returned string is NULL when
699*7304104dSAndroid Build Coastguard Worker an error occurred, or the file path. The file path is either absolute
700*7304104dSAndroid Build Coastguard Worker or relative to the compilation directory. See dwarf_decl_file. */
701*7304104dSAndroid Build Coastguard Worker extern const char *dwarf_linesrc (Dwarf_Line *line,
702*7304104dSAndroid Build Coastguard Worker Dwarf_Word *mtime, Dwarf_Word *length);
703*7304104dSAndroid Build Coastguard Worker
704*7304104dSAndroid Build Coastguard Worker /* Return the caller of this line if inlined. If not inlined,
705*7304104dSAndroid Build Coastguard Worker return NULL. */
706*7304104dSAndroid Build Coastguard Worker extern Dwarf_Line *dwarf_linecontext (Dwarf_Lines *lines, Dwarf_Line *line);
707*7304104dSAndroid Build Coastguard Worker
708*7304104dSAndroid Build Coastguard Worker /* Return the function name in this line record. If this line is
709*7304104dSAndroid Build Coastguard Worker inlined, this is the name of the function that was inlined. If this line
710*7304104dSAndroid Build Coastguard Worker is not inlined, return NULL. */
711*7304104dSAndroid Build Coastguard Worker extern const char *dwarf_linefunctionname (Dwarf *dbg, Dwarf_Line *line);
712*7304104dSAndroid Build Coastguard Worker
713*7304104dSAndroid Build Coastguard Worker /* Return file information. The returned string is NULL when
714*7304104dSAndroid Build Coastguard Worker an error occurred, or the file path. The file path is either absolute
715*7304104dSAndroid Build Coastguard Worker or relative to the compilation directory. See dwarf_decl_file. */
716*7304104dSAndroid Build Coastguard Worker extern const char *dwarf_filesrc (Dwarf_Files *file, size_t idx,
717*7304104dSAndroid Build Coastguard Worker Dwarf_Word *mtime, Dwarf_Word *length);
718*7304104dSAndroid Build Coastguard Worker
719*7304104dSAndroid Build Coastguard Worker /* Return the Dwarf_Files and index associated with the given Dwarf_Line. */
720*7304104dSAndroid Build Coastguard Worker extern int dwarf_line_file (Dwarf_Line *line,
721*7304104dSAndroid Build Coastguard Worker Dwarf_Files **files, size_t *idx)
722*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2, 3);
723*7304104dSAndroid Build Coastguard Worker
724*7304104dSAndroid Build Coastguard Worker /* Return the directory list used in the file information extracted.
725*7304104dSAndroid Build Coastguard Worker (*RESULT)[0] is the CU's DW_AT_comp_dir value, and may be null.
726*7304104dSAndroid Build Coastguard Worker (*RESULT)[0..*NDIRS-1] are the compile-time include directory path
727*7304104dSAndroid Build Coastguard Worker encoded by the compiler. */
728*7304104dSAndroid Build Coastguard Worker extern int dwarf_getsrcdirs (Dwarf_Files *files,
729*7304104dSAndroid Build Coastguard Worker const char *const **result, size_t *ndirs)
730*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2, 3);
731*7304104dSAndroid Build Coastguard Worker
732*7304104dSAndroid Build Coastguard Worker /* Iterates through the debug line units. Returns 0 on success, -1 on
733*7304104dSAndroid Build Coastguard Worker error or 1 if there are no more units. To start iterating use zero
734*7304104dSAndroid Build Coastguard Worker for OFF and set *CU to NULL. On success NEXT_OFF will be set to
735*7304104dSAndroid Build Coastguard Worker the next offset to use. The *CU will be set if this line table
736*7304104dSAndroid Build Coastguard Worker needed a specific CU and needs to be given when calling
737*7304104dSAndroid Build Coastguard Worker dwarf_next_lines again (to help dwarf_next_lines quickly find the
738*7304104dSAndroid Build Coastguard Worker next CU). *CU might be set to NULL when it couldn't be found (the
739*7304104dSAndroid Build Coastguard Worker compilation directory entry will be the empty string in that case)
740*7304104dSAndroid Build Coastguard Worker or for DWARF 5 or later tables, which are self contained. SRCFILES
741*7304104dSAndroid Build Coastguard Worker and SRCLINES may be NULL if the caller is not interested in the
742*7304104dSAndroid Build Coastguard Worker actual line or file table. On success and when not NULL, NFILES
743*7304104dSAndroid Build Coastguard Worker and NLINES will be set to the number of files in the file table and
744*7304104dSAndroid Build Coastguard Worker number of lines in the line table. */
745*7304104dSAndroid Build Coastguard Worker extern int dwarf_next_lines (Dwarf *dwarf, Dwarf_Off off,
746*7304104dSAndroid Build Coastguard Worker Dwarf_Off *next_off, Dwarf_CU **cu,
747*7304104dSAndroid Build Coastguard Worker Dwarf_Files **srcfiles, size_t *nfiles,
748*7304104dSAndroid Build Coastguard Worker Dwarf_Lines **srclines, size_t *nlines)
749*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (3,4);
750*7304104dSAndroid Build Coastguard Worker
751*7304104dSAndroid Build Coastguard Worker /* Return location expression, decoded as a list of operations. */
752*7304104dSAndroid Build Coastguard Worker extern int dwarf_getlocation (Dwarf_Attribute *attr, Dwarf_Op **expr,
753*7304104dSAndroid Build Coastguard Worker size_t *exprlen) __nonnull_attribute__ (2, 3);
754*7304104dSAndroid Build Coastguard Worker
755*7304104dSAndroid Build Coastguard Worker /* Return location expressions. If the attribute uses a location list,
756*7304104dSAndroid Build Coastguard Worker ADDRESS selects the relevant location expressions from the list.
757*7304104dSAndroid Build Coastguard Worker There can be multiple matches, resulting in multiple expressions to
758*7304104dSAndroid Build Coastguard Worker return. EXPRS and EXPRLENS are parallel arrays of NLOCS slots to
759*7304104dSAndroid Build Coastguard Worker fill in. Returns the number of locations filled in, or -1 for
760*7304104dSAndroid Build Coastguard Worker errors. If EXPRS is a null pointer, stores nothing and returns the
761*7304104dSAndroid Build Coastguard Worker total number of locations. A return value of zero means that the
762*7304104dSAndroid Build Coastguard Worker location list indicated no value is accessible. */
763*7304104dSAndroid Build Coastguard Worker extern int dwarf_getlocation_addr (Dwarf_Attribute *attr, Dwarf_Addr address,
764*7304104dSAndroid Build Coastguard Worker Dwarf_Op **exprs, size_t *exprlens,
765*7304104dSAndroid Build Coastguard Worker size_t nlocs);
766*7304104dSAndroid Build Coastguard Worker
767*7304104dSAndroid Build Coastguard Worker /* Enumerate the locations ranges and descriptions covered by the
768*7304104dSAndroid Build Coastguard Worker given attribute. In the first call OFFSET should be zero and
769*7304104dSAndroid Build Coastguard Worker *BASEP need not be initialized. Returns -1 for errors, zero when
770*7304104dSAndroid Build Coastguard Worker there are no more locations to report, or a nonzero OFFSET
771*7304104dSAndroid Build Coastguard Worker value to pass to the next call. Each subsequent call must preserve
772*7304104dSAndroid Build Coastguard Worker *BASEP from the prior call. Successful calls fill in *STARTP and
773*7304104dSAndroid Build Coastguard Worker *ENDP with a contiguous address range and *EXPR with a pointer to
774*7304104dSAndroid Build Coastguard Worker an array of operations with length *EXPRLEN. If the attribute
775*7304104dSAndroid Build Coastguard Worker describes a single location description and not a location list the
776*7304104dSAndroid Build Coastguard Worker first call (with OFFSET zero) will return the location description
777*7304104dSAndroid Build Coastguard Worker in *EXPR with *STARTP set to zero and *ENDP set to minus one. */
778*7304104dSAndroid Build Coastguard Worker extern ptrdiff_t dwarf_getlocations (Dwarf_Attribute *attr,
779*7304104dSAndroid Build Coastguard Worker ptrdiff_t offset, Dwarf_Addr *basep,
780*7304104dSAndroid Build Coastguard Worker Dwarf_Addr *startp, Dwarf_Addr *endp,
781*7304104dSAndroid Build Coastguard Worker Dwarf_Op **expr, size_t *exprlen);
782*7304104dSAndroid Build Coastguard Worker
783*7304104dSAndroid Build Coastguard Worker /* Return the block associated with a DW_OP_implicit_value operation.
784*7304104dSAndroid Build Coastguard Worker The OP pointer must point into an expression that dwarf_getlocation
785*7304104dSAndroid Build Coastguard Worker or dwarf_getlocation_addr has returned given the same ATTR. */
786*7304104dSAndroid Build Coastguard Worker extern int dwarf_getlocation_implicit_value (Dwarf_Attribute *attr,
787*7304104dSAndroid Build Coastguard Worker const Dwarf_Op *op,
788*7304104dSAndroid Build Coastguard Worker Dwarf_Block *return_block)
789*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2, 3);
790*7304104dSAndroid Build Coastguard Worker
791*7304104dSAndroid Build Coastguard Worker /* Return the attribute indicated by a DW_OP_GNU_implicit_pointer operation.
792*7304104dSAndroid Build Coastguard Worker The OP pointer must point into an expression that dwarf_getlocation
793*7304104dSAndroid Build Coastguard Worker or dwarf_getlocation_addr has returned given the same ATTR.
794*7304104dSAndroid Build Coastguard Worker The result is the DW_AT_location or DW_AT_const_value attribute
795*7304104dSAndroid Build Coastguard Worker of the OP->number DIE. */
796*7304104dSAndroid Build Coastguard Worker extern int dwarf_getlocation_implicit_pointer (Dwarf_Attribute *attr,
797*7304104dSAndroid Build Coastguard Worker const Dwarf_Op *op,
798*7304104dSAndroid Build Coastguard Worker Dwarf_Attribute *result)
799*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2, 3);
800*7304104dSAndroid Build Coastguard Worker
801*7304104dSAndroid Build Coastguard Worker /* Return the DIE associated with an operation such as
802*7304104dSAndroid Build Coastguard Worker DW_OP_GNU_implicit_pointer, DW_OP_GNU_parameter_ref, DW_OP_GNU_convert,
803*7304104dSAndroid Build Coastguard Worker DW_OP_GNU_reinterpret, DW_OP_GNU_const_type, DW_OP_GNU_regval_type or
804*7304104dSAndroid Build Coastguard Worker DW_OP_GNU_deref_type. The OP pointer must point into an expression that
805*7304104dSAndroid Build Coastguard Worker dwarf_getlocation or dwarf_getlocation_addr has returned given the same
806*7304104dSAndroid Build Coastguard Worker ATTR. The RESULT is a DIE that expresses a type or value needed by the
807*7304104dSAndroid Build Coastguard Worker given OP. */
808*7304104dSAndroid Build Coastguard Worker extern int dwarf_getlocation_die (Dwarf_Attribute *attr,
809*7304104dSAndroid Build Coastguard Worker const Dwarf_Op *op,
810*7304104dSAndroid Build Coastguard Worker Dwarf_Die *result)
811*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2, 3);
812*7304104dSAndroid Build Coastguard Worker
813*7304104dSAndroid Build Coastguard Worker /* Return the attribute expressing a value associated with an operation such
814*7304104dSAndroid Build Coastguard Worker as DW_OP_implicit_value, DW_OP_GNU_entry_value or DW_OP_GNU_const_type.
815*7304104dSAndroid Build Coastguard Worker The OP pointer must point into an expression that dwarf_getlocation
816*7304104dSAndroid Build Coastguard Worker or dwarf_getlocation_addr has returned given the same ATTR.
817*7304104dSAndroid Build Coastguard Worker The RESULT is a value expressed by an attribute such as DW_AT_location
818*7304104dSAndroid Build Coastguard Worker or DW_AT_const_value. */
819*7304104dSAndroid Build Coastguard Worker extern int dwarf_getlocation_attr (Dwarf_Attribute *attr,
820*7304104dSAndroid Build Coastguard Worker const Dwarf_Op *op,
821*7304104dSAndroid Build Coastguard Worker Dwarf_Attribute *result)
822*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2, 3);
823*7304104dSAndroid Build Coastguard Worker
824*7304104dSAndroid Build Coastguard Worker
825*7304104dSAndroid Build Coastguard Worker /* Compute the byte-size of a type DIE according to DWARF rules.
826*7304104dSAndroid Build Coastguard Worker For most types, this is just DW_AT_byte_size.
827*7304104dSAndroid Build Coastguard Worker For DW_TAG_array_type it can apply much more complex rules. */
828*7304104dSAndroid Build Coastguard Worker extern int dwarf_aggregate_size (Dwarf_Die *die, Dwarf_Word *size);
829*7304104dSAndroid Build Coastguard Worker
830*7304104dSAndroid Build Coastguard Worker /* Given a language code, as returned by dwarf_srclan, get the default
831*7304104dSAndroid Build Coastguard Worker lower bound for a subrange type without a lower bound attribute.
832*7304104dSAndroid Build Coastguard Worker Returns zero on success or -1 on failure when the given language
833*7304104dSAndroid Build Coastguard Worker wasn't recognized. */
834*7304104dSAndroid Build Coastguard Worker extern int dwarf_default_lower_bound (int lang, Dwarf_Sword *result)
835*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
836*7304104dSAndroid Build Coastguard Worker
837*7304104dSAndroid Build Coastguard Worker /* Return scope DIEs containing PC address.
838*7304104dSAndroid Build Coastguard Worker Sets *SCOPES to a malloc'd array of Dwarf_Die structures,
839*7304104dSAndroid Build Coastguard Worker and returns the number of elements in the array.
840*7304104dSAndroid Build Coastguard Worker (*SCOPES)[0] is the DIE for the innermost scope containing PC,
841*7304104dSAndroid Build Coastguard Worker (*SCOPES)[1] is the DIE for the scope containing that scope, and so on.
842*7304104dSAndroid Build Coastguard Worker Returns -1 for errors or 0 if no scopes match PC. */
843*7304104dSAndroid Build Coastguard Worker extern int dwarf_getscopes (Dwarf_Die *cudie, Dwarf_Addr pc,
844*7304104dSAndroid Build Coastguard Worker Dwarf_Die **scopes);
845*7304104dSAndroid Build Coastguard Worker
846*7304104dSAndroid Build Coastguard Worker /* Return scope DIEs containing the given DIE.
847*7304104dSAndroid Build Coastguard Worker Sets *SCOPES to a malloc'd array of Dwarf_Die structures,
848*7304104dSAndroid Build Coastguard Worker and returns the number of elements in the array.
849*7304104dSAndroid Build Coastguard Worker (*SCOPES)[0] is a copy of DIE.
850*7304104dSAndroid Build Coastguard Worker (*SCOPES)[1] is the DIE for the scope containing that scope, and so on.
851*7304104dSAndroid Build Coastguard Worker Returns -1 for errors or 0 if DIE is not found in any scope entry. */
852*7304104dSAndroid Build Coastguard Worker extern int dwarf_getscopes_die (Dwarf_Die *die, Dwarf_Die **scopes);
853*7304104dSAndroid Build Coastguard Worker
854*7304104dSAndroid Build Coastguard Worker
855*7304104dSAndroid Build Coastguard Worker /* Search SCOPES[0..NSCOPES-1] for a variable called NAME.
856*7304104dSAndroid Build Coastguard Worker Ignore the first SKIP_SHADOWS scopes that match the name.
857*7304104dSAndroid Build Coastguard Worker If MATCH_FILE is not null, accept only declaration in that source file;
858*7304104dSAndroid Build Coastguard Worker if MATCH_LINENO or MATCH_LINECOL are also nonzero, accept only declaration
859*7304104dSAndroid Build Coastguard Worker at that line and column.
860*7304104dSAndroid Build Coastguard Worker
861*7304104dSAndroid Build Coastguard Worker If successful, fill in *RESULT with the DIE of the variable found,
862*7304104dSAndroid Build Coastguard Worker and return N where SCOPES[N] is the scope defining the variable.
863*7304104dSAndroid Build Coastguard Worker Return -1 for errors or -2 for no matching variable found. */
864*7304104dSAndroid Build Coastguard Worker extern int dwarf_getscopevar (Dwarf_Die *scopes, int nscopes,
865*7304104dSAndroid Build Coastguard Worker const char *name, int skip_shadows,
866*7304104dSAndroid Build Coastguard Worker const char *match_file,
867*7304104dSAndroid Build Coastguard Worker int match_lineno, int match_linecol,
868*7304104dSAndroid Build Coastguard Worker Dwarf_Die *result);
869*7304104dSAndroid Build Coastguard Worker
870*7304104dSAndroid Build Coastguard Worker
871*7304104dSAndroid Build Coastguard Worker
872*7304104dSAndroid Build Coastguard Worker /* Return list address ranges. */
873*7304104dSAndroid Build Coastguard Worker extern int dwarf_getaranges (Dwarf *dbg, Dwarf_Aranges **aranges,
874*7304104dSAndroid Build Coastguard Worker size_t *naranges)
875*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
876*7304104dSAndroid Build Coastguard Worker
877*7304104dSAndroid Build Coastguard Worker /* Return one of the address range entries. */
878*7304104dSAndroid Build Coastguard Worker extern Dwarf_Arange *dwarf_onearange (Dwarf_Aranges *aranges, size_t idx);
879*7304104dSAndroid Build Coastguard Worker
880*7304104dSAndroid Build Coastguard Worker /* Return information in address range record. */
881*7304104dSAndroid Build Coastguard Worker extern int dwarf_getarangeinfo (Dwarf_Arange *arange, Dwarf_Addr *addrp,
882*7304104dSAndroid Build Coastguard Worker Dwarf_Word *lengthp, Dwarf_Off *offsetp);
883*7304104dSAndroid Build Coastguard Worker
884*7304104dSAndroid Build Coastguard Worker /* Get address range which includes given address. */
885*7304104dSAndroid Build Coastguard Worker extern Dwarf_Arange *dwarf_getarange_addr (Dwarf_Aranges *aranges,
886*7304104dSAndroid Build Coastguard Worker Dwarf_Addr addr);
887*7304104dSAndroid Build Coastguard Worker
888*7304104dSAndroid Build Coastguard Worker
889*7304104dSAndroid Build Coastguard Worker
890*7304104dSAndroid Build Coastguard Worker /* Get functions in CUDIE. The given callback will be called for all
891*7304104dSAndroid Build Coastguard Worker defining DW_TAG_subprograms in the CU DIE tree. If the callback
892*7304104dSAndroid Build Coastguard Worker returns DWARF_CB_ABORT the return value can be used as offset argument
893*7304104dSAndroid Build Coastguard Worker to resume the function to find all remaining functions (this is not
894*7304104dSAndroid Build Coastguard Worker really recommended, since it needs to rewalk the CU DIE tree first till
895*7304104dSAndroid Build Coastguard Worker that offset is found again). If the callback returns DWARF_CB_OK
896*7304104dSAndroid Build Coastguard Worker dwarf_getfuncs will not return but keep calling the callback for each
897*7304104dSAndroid Build Coastguard Worker function DIE it finds. Pass zero for offset on the first call to walk
898*7304104dSAndroid Build Coastguard Worker the full CU DIE tree. If no more functions can be found and the callback
899*7304104dSAndroid Build Coastguard Worker returned DWARF_CB_OK then the function returns zero. */
900*7304104dSAndroid Build Coastguard Worker extern ptrdiff_t dwarf_getfuncs (Dwarf_Die *cudie,
901*7304104dSAndroid Build Coastguard Worker int (*callback) (Dwarf_Die *, void *),
902*7304104dSAndroid Build Coastguard Worker void *arg, ptrdiff_t offset);
903*7304104dSAndroid Build Coastguard Worker
904*7304104dSAndroid Build Coastguard Worker
905*7304104dSAndroid Build Coastguard Worker /* Return file name containing definition of the given declaration.
906*7304104dSAndroid Build Coastguard Worker Of the DECL has an (indirect, see dwarf_attr_integrate) decl_file
907*7304104dSAndroid Build Coastguard Worker attribute. The returned file path is either absolute, or relative
908*7304104dSAndroid Build Coastguard Worker to the compilation directory. Given the decl DIE, the compilation
909*7304104dSAndroid Build Coastguard Worker directory can be retrieved through:
910*7304104dSAndroid Build Coastguard Worker dwarf_formstring (dwarf_attr (dwarf_diecu (decl, &cudie, NULL, NULL),
911*7304104dSAndroid Build Coastguard Worker DW_AT_comp_dir, &attr));
912*7304104dSAndroid Build Coastguard Worker Returns NULL if no decl_file could be found or an error occurred. */
913*7304104dSAndroid Build Coastguard Worker extern const char *dwarf_decl_file (Dwarf_Die *decl);
914*7304104dSAndroid Build Coastguard Worker
915*7304104dSAndroid Build Coastguard Worker /* Get line number of beginning of given declaration. */
916*7304104dSAndroid Build Coastguard Worker extern int dwarf_decl_line (Dwarf_Die *decl, int *linep)
917*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
918*7304104dSAndroid Build Coastguard Worker
919*7304104dSAndroid Build Coastguard Worker /* Get column number of beginning of given declaration. */
920*7304104dSAndroid Build Coastguard Worker extern int dwarf_decl_column (Dwarf_Die *decl, int *colp)
921*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
922*7304104dSAndroid Build Coastguard Worker
923*7304104dSAndroid Build Coastguard Worker
924*7304104dSAndroid Build Coastguard Worker /* Return nonzero if given function is an abstract inline definition. */
925*7304104dSAndroid Build Coastguard Worker extern int dwarf_func_inline (Dwarf_Die *func);
926*7304104dSAndroid Build Coastguard Worker
927*7304104dSAndroid Build Coastguard Worker /* Find each concrete inlined instance of the abstract inline definition. */
928*7304104dSAndroid Build Coastguard Worker extern int dwarf_func_inline_instances (Dwarf_Die *func,
929*7304104dSAndroid Build Coastguard Worker int (*callback) (Dwarf_Die *, void *),
930*7304104dSAndroid Build Coastguard Worker void *arg);
931*7304104dSAndroid Build Coastguard Worker
932*7304104dSAndroid Build Coastguard Worker
933*7304104dSAndroid Build Coastguard Worker /* Find the appropriate PC location or locations for function entry
934*7304104dSAndroid Build Coastguard Worker breakpoints for the given DW_TAG_subprogram DIE. Returns -1 for errors.
935*7304104dSAndroid Build Coastguard Worker On success, returns the number of breakpoint locations (never zero)
936*7304104dSAndroid Build Coastguard Worker and sets *BKPTS to a malloc'd vector of addresses. */
937*7304104dSAndroid Build Coastguard Worker extern int dwarf_entry_breakpoints (Dwarf_Die *die, Dwarf_Addr **bkpts);
938*7304104dSAndroid Build Coastguard Worker
939*7304104dSAndroid Build Coastguard Worker
940*7304104dSAndroid Build Coastguard Worker /* Iterate through the macro unit referenced by CUDIE and call
941*7304104dSAndroid Build Coastguard Worker CALLBACK for each macro information entry. To start the iteration,
942*7304104dSAndroid Build Coastguard Worker one would pass DWARF_GETMACROS_START for TOKEN.
943*7304104dSAndroid Build Coastguard Worker
944*7304104dSAndroid Build Coastguard Worker The iteration continues while CALLBACK returns DWARF_CB_OK. If the
945*7304104dSAndroid Build Coastguard Worker callback returns DWARF_CB_ABORT, the iteration stops and a
946*7304104dSAndroid Build Coastguard Worker continuation token is returned, which can be used to restart the
947*7304104dSAndroid Build Coastguard Worker iteration at the point where it ended. Returns -1 for errors or 0
948*7304104dSAndroid Build Coastguard Worker if there are no more macro entries.
949*7304104dSAndroid Build Coastguard Worker
950*7304104dSAndroid Build Coastguard Worker Note that the Dwarf_Macro pointer passed to the callback is only
951*7304104dSAndroid Build Coastguard Worker valid for the duration of the callback invocation.
952*7304104dSAndroid Build Coastguard Worker
953*7304104dSAndroid Build Coastguard Worker For backward compatibility, a token of 0 is accepted for starting
954*7304104dSAndroid Build Coastguard Worker the iteration as well, but in that case this interface will refuse
955*7304104dSAndroid Build Coastguard Worker to serve opcode 0xff from .debug_macro sections. Such opcode would
956*7304104dSAndroid Build Coastguard Worker be considered invalid and would cause dwarf_getmacros to return
957*7304104dSAndroid Build Coastguard Worker with error. */
958*7304104dSAndroid Build Coastguard Worker #define DWARF_GETMACROS_START PTRDIFF_MIN
959*7304104dSAndroid Build Coastguard Worker extern ptrdiff_t dwarf_getmacros (Dwarf_Die *cudie,
960*7304104dSAndroid Build Coastguard Worker int (*callback) (Dwarf_Macro *, void *),
961*7304104dSAndroid Build Coastguard Worker void *arg, ptrdiff_t token)
962*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
963*7304104dSAndroid Build Coastguard Worker
964*7304104dSAndroid Build Coastguard Worker /* This is similar in operation to dwarf_getmacros, but selects the
965*7304104dSAndroid Build Coastguard Worker unit to iterate through by offset instead of by CU, and always
966*7304104dSAndroid Build Coastguard Worker iterates .debug_macro. This can be used for handling
967*7304104dSAndroid Build Coastguard Worker DW_MACRO_GNU_transparent_include's or similar opcodes.
968*7304104dSAndroid Build Coastguard Worker
969*7304104dSAndroid Build Coastguard Worker TOKEN value of DWARF_GETMACROS_START can be used to start the
970*7304104dSAndroid Build Coastguard Worker iteration.
971*7304104dSAndroid Build Coastguard Worker
972*7304104dSAndroid Build Coastguard Worker It is not appropriate to obtain macro unit offset by hand from a CU
973*7304104dSAndroid Build Coastguard Worker DIE and then request iteration through this interface. The reason
974*7304104dSAndroid Build Coastguard Worker for this is that if a dwarf_macro_getsrcfiles is later called,
975*7304104dSAndroid Build Coastguard Worker there would be no way to figure out what DW_AT_comp_dir was present
976*7304104dSAndroid Build Coastguard Worker on the CU DIE, and file names referenced in either the macro unit
977*7304104dSAndroid Build Coastguard Worker itself, or the .debug_line unit that it references, might be wrong.
978*7304104dSAndroid Build Coastguard Worker Use dwarf_getmacros. */
979*7304104dSAndroid Build Coastguard Worker extern ptrdiff_t dwarf_getmacros_off (Dwarf *dbg, Dwarf_Off macoff,
980*7304104dSAndroid Build Coastguard Worker int (*callback) (Dwarf_Macro *, void *),
981*7304104dSAndroid Build Coastguard Worker void *arg, ptrdiff_t token)
982*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (3);
983*7304104dSAndroid Build Coastguard Worker
984*7304104dSAndroid Build Coastguard Worker /* Get the source files used by the macro entry. You shouldn't assume
985*7304104dSAndroid Build Coastguard Worker that Dwarf_Files references will remain valid after MACRO becomes
986*7304104dSAndroid Build Coastguard Worker invalid. (Which is to say it's only valid within the
987*7304104dSAndroid Build Coastguard Worker dwarf_getmacros* callback.) Returns 0 for success or a negative
988*7304104dSAndroid Build Coastguard Worker value in case of an error. */
989*7304104dSAndroid Build Coastguard Worker extern int dwarf_macro_getsrcfiles (Dwarf *dbg, Dwarf_Macro *macro,
990*7304104dSAndroid Build Coastguard Worker Dwarf_Files **files, size_t *nfiles)
991*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2, 3, 4);
992*7304104dSAndroid Build Coastguard Worker
993*7304104dSAndroid Build Coastguard Worker /* Return macro opcode. That's a constant that can be either from
994*7304104dSAndroid Build Coastguard Worker DW_MACINFO_* domain or DW_MACRO_GNU_* domain. The two domains have
995*7304104dSAndroid Build Coastguard Worker compatible values, so it's OK to use either of them for
996*7304104dSAndroid Build Coastguard Worker comparisons. The only differences is 0xff, which could be either
997*7304104dSAndroid Build Coastguard Worker DW_MACINFO_vendor_ext or a vendor-defined DW_MACRO_* constant. One
998*7304104dSAndroid Build Coastguard Worker would need to look if the CU DIE which the iteration was requested
999*7304104dSAndroid Build Coastguard Worker for has attribute DW_AT_macro_info, or either of DW_AT_GNU_macros
1000*7304104dSAndroid Build Coastguard Worker or DW_AT_macros to differentiate the two interpretations. */
1001*7304104dSAndroid Build Coastguard Worker extern int dwarf_macro_opcode (Dwarf_Macro *macro, unsigned int *opcodep)
1002*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
1003*7304104dSAndroid Build Coastguard Worker
1004*7304104dSAndroid Build Coastguard Worker /* Get number of parameters of MACRO and store it to *PARAMCNTP. */
1005*7304104dSAndroid Build Coastguard Worker extern int dwarf_macro_getparamcnt (Dwarf_Macro *macro, size_t *paramcntp);
1006*7304104dSAndroid Build Coastguard Worker
1007*7304104dSAndroid Build Coastguard Worker /* Get IDX-th parameter of MACRO (numbered from zero), and stores it
1008*7304104dSAndroid Build Coastguard Worker to *ATTRIBUTE. Returns 0 on success or -1 for errors.
1009*7304104dSAndroid Build Coastguard Worker
1010*7304104dSAndroid Build Coastguard Worker After a successful call, you can query ATTRIBUTE by dwarf_whatform
1011*7304104dSAndroid Build Coastguard Worker to determine which of the dwarf_formX calls to make to get actual
1012*7304104dSAndroid Build Coastguard Worker value out of ATTRIBUTE. Note that calling dwarf_whatattr is not
1013*7304104dSAndroid Build Coastguard Worker meaningful for pseudo-attributes formed this way. */
1014*7304104dSAndroid Build Coastguard Worker extern int dwarf_macro_param (Dwarf_Macro *macro, size_t idx,
1015*7304104dSAndroid Build Coastguard Worker Dwarf_Attribute *attribute);
1016*7304104dSAndroid Build Coastguard Worker
1017*7304104dSAndroid Build Coastguard Worker /* Return macro parameter with index 0. This will return -1 if the
1018*7304104dSAndroid Build Coastguard Worker parameter is not an integral value. Use dwarf_macro_param for more
1019*7304104dSAndroid Build Coastguard Worker general access. */
1020*7304104dSAndroid Build Coastguard Worker extern int dwarf_macro_param1 (Dwarf_Macro *macro, Dwarf_Word *paramp)
1021*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
1022*7304104dSAndroid Build Coastguard Worker
1023*7304104dSAndroid Build Coastguard Worker /* Return macro parameter with index 1. This will return -1 if the
1024*7304104dSAndroid Build Coastguard Worker parameter is not an integral or string value. Use
1025*7304104dSAndroid Build Coastguard Worker dwarf_macro_param for more general access. */
1026*7304104dSAndroid Build Coastguard Worker extern int dwarf_macro_param2 (Dwarf_Macro *macro, Dwarf_Word *paramp,
1027*7304104dSAndroid Build Coastguard Worker const char **strp);
1028*7304104dSAndroid Build Coastguard Worker
1029*7304104dSAndroid Build Coastguard Worker /* Compute what's known about a call frame when the PC is at ADDRESS.
1030*7304104dSAndroid Build Coastguard Worker Returns 0 for success or -1 for errors.
1031*7304104dSAndroid Build Coastguard Worker On success, *FRAME is a malloc'd pointer. */
1032*7304104dSAndroid Build Coastguard Worker extern int dwarf_cfi_addrframe (Dwarf_CFI *cache,
1033*7304104dSAndroid Build Coastguard Worker Dwarf_Addr address, Dwarf_Frame **frame)
1034*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (3);
1035*7304104dSAndroid Build Coastguard Worker
1036*7304104dSAndroid Build Coastguard Worker /* Return the DWARF register number used in FRAME to denote
1037*7304104dSAndroid Build Coastguard Worker the return address in FRAME's caller frame. The remaining
1038*7304104dSAndroid Build Coastguard Worker arguments can be non-null to fill in more information.
1039*7304104dSAndroid Build Coastguard Worker
1040*7304104dSAndroid Build Coastguard Worker Fill [*START, *END) with the PC range to which FRAME's information applies.
1041*7304104dSAndroid Build Coastguard Worker Fill in *SIGNALP to indicate whether this is a signal-handling frame.
1042*7304104dSAndroid Build Coastguard Worker If true, this is the implicit call frame that calls a signal handler.
1043*7304104dSAndroid Build Coastguard Worker This frame's "caller" is actually the interrupted state, not a call;
1044*7304104dSAndroid Build Coastguard Worker its return address is an exact PC, not a PC after a call instruction. */
1045*7304104dSAndroid Build Coastguard Worker extern int dwarf_frame_info (Dwarf_Frame *frame,
1046*7304104dSAndroid Build Coastguard Worker Dwarf_Addr *start, Dwarf_Addr *end, bool *signalp);
1047*7304104dSAndroid Build Coastguard Worker
1048*7304104dSAndroid Build Coastguard Worker /* Return a DWARF expression that yields the Canonical Frame Address at
1049*7304104dSAndroid Build Coastguard Worker this frame state. Returns -1 for errors, or zero for success, with
1050*7304104dSAndroid Build Coastguard Worker *NOPS set to the number of operations stored at *OPS. That pointer
1051*7304104dSAndroid Build Coastguard Worker can be used only as long as FRAME is alive and unchanged. *NOPS is
1052*7304104dSAndroid Build Coastguard Worker zero if the CFA cannot be determined here. Note that if nonempty,
1053*7304104dSAndroid Build Coastguard Worker *OPS is a DWARF expression, not a location description--append
1054*7304104dSAndroid Build Coastguard Worker DW_OP_stack_value to a get a location description for the CFA. */
1055*7304104dSAndroid Build Coastguard Worker extern int dwarf_frame_cfa (Dwarf_Frame *frame, Dwarf_Op **ops, size_t *nops)
1056*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (2);
1057*7304104dSAndroid Build Coastguard Worker
1058*7304104dSAndroid Build Coastguard Worker /* Deliver a DWARF location description that yields the location or
1059*7304104dSAndroid Build Coastguard Worker value of DWARF register number REGNO in the state described by FRAME.
1060*7304104dSAndroid Build Coastguard Worker
1061*7304104dSAndroid Build Coastguard Worker Returns -1 for errors or zero for success, setting *NOPS to the
1062*7304104dSAndroid Build Coastguard Worker number of operations in the array stored at *OPS. Note the last
1063*7304104dSAndroid Build Coastguard Worker operation is DW_OP_stack_value if there is no mutable location but
1064*7304104dSAndroid Build Coastguard Worker only a computable value.
1065*7304104dSAndroid Build Coastguard Worker
1066*7304104dSAndroid Build Coastguard Worker *NOPS zero with *OPS set to OPS_MEM means CFI says the caller's
1067*7304104dSAndroid Build Coastguard Worker REGNO is "undefined", i.e. it's call-clobbered and cannot be recovered.
1068*7304104dSAndroid Build Coastguard Worker
1069*7304104dSAndroid Build Coastguard Worker *NOPS zero with *OPS set to a null pointer means CFI says the
1070*7304104dSAndroid Build Coastguard Worker caller's REGNO is "same_value", i.e. this frame did not change it;
1071*7304104dSAndroid Build Coastguard Worker ask the caller frame where to find it.
1072*7304104dSAndroid Build Coastguard Worker
1073*7304104dSAndroid Build Coastguard Worker For common simple expressions *OPS is OPS_MEM (which is a caller
1074*7304104dSAndroid Build Coastguard Worker owned array for at least 3 Dwarf_Ops). For arbitrary DWARF
1075*7304104dSAndroid Build Coastguard Worker expressions in the CFI, *OPS is an internal pointer that can be
1076*7304104dSAndroid Build Coastguard Worker used as long as the Dwarf_CFI used to create FRAME remains
1077*7304104dSAndroid Build Coastguard Worker alive. */
1078*7304104dSAndroid Build Coastguard Worker extern int dwarf_frame_register (Dwarf_Frame *frame, int regno,
1079*7304104dSAndroid Build Coastguard Worker Dwarf_Op ops_mem[3],
1080*7304104dSAndroid Build Coastguard Worker Dwarf_Op **ops, size_t *nops)
1081*7304104dSAndroid Build Coastguard Worker __nonnull_attribute__ (3, 4, 5);
1082*7304104dSAndroid Build Coastguard Worker
1083*7304104dSAndroid Build Coastguard Worker
1084*7304104dSAndroid Build Coastguard Worker /* Return offset and/or size of CU's contribution to SECTION in a
1085*7304104dSAndroid Build Coastguard Worker DWARF package file.
1086*7304104dSAndroid Build Coastguard Worker
1087*7304104dSAndroid Build Coastguard Worker If CU is not from a DWARF package file, the file does not have
1088*7304104dSAndroid Build Coastguard Worker SECTION, or CU does not contribute to SECTION, then *OFFSETP and
1089*7304104dSAndroid Build Coastguard Worker *SIZEP are set to 0 (this is not an error and the function will
1090*7304104dSAndroid Build Coastguard Worker return 0 in that case).
1091*7304104dSAndroid Build Coastguard Worker
1092*7304104dSAndroid Build Coastguard Worker SECTION is a DW_SECT section identifier. Note that the original
1093*7304104dSAndroid Build Coastguard Worker GNU DWARF package file extension for DWARF 4 used slightly
1094*7304104dSAndroid Build Coastguard Worker different section identifiers. This function uses the standardized
1095*7304104dSAndroid Build Coastguard Worker section identifiers and maps the GNU DWARF 4 identifiers to their
1096*7304104dSAndroid Build Coastguard Worker standard DWARF 5 analogues: DW_SECT_LOCLISTS (5) refers to
1097*7304104dSAndroid Build Coastguard Worker .debug_locs.dwo for DWARF 4. DW_SECT_MACRO (7) refers to
1098*7304104dSAndroid Build Coastguard Worker .debug_macinfo.dwo for DWARF 4 or .debug_macro.dwo for the GNU
1099*7304104dSAndroid Build Coastguard Worker .debug_macro extension for DWARF 4 (section identifier 8 is
1100*7304104dSAndroid Build Coastguard Worker DW_SECT_RNGLISTS in DWARF 5, NOT DW_SECT_MACRO like in the GNU
1101*7304104dSAndroid Build Coastguard Worker extension.) .debug_types.dwo does not have a DWARF 5 equivalent,
1102*7304104dSAndroid Build Coastguard Worker so this function accepts the original DW_SECT_TYPES (2).
1103*7304104dSAndroid Build Coastguard Worker
1104*7304104dSAndroid Build Coastguard Worker Returns 0 for success or -1 for errors reading the DWARF package
1105*7304104dSAndroid Build Coastguard Worker file data or if an unknown SECTION constant is given. OFFSETP and
1106*7304104dSAndroid Build Coastguard Worker SIZEP may be NULL. */
1107*7304104dSAndroid Build Coastguard Worker extern int dwarf_cu_dwp_section_info (Dwarf_CU *cu, unsigned int section,
1108*7304104dSAndroid Build Coastguard Worker Dwarf_Off *offsetp, Dwarf_Off *sizep);
1109*7304104dSAndroid Build Coastguard Worker
1110*7304104dSAndroid Build Coastguard Worker
1111*7304104dSAndroid Build Coastguard Worker /* Return error code of last failing function call. This value is kept
1112*7304104dSAndroid Build Coastguard Worker separately for each thread. */
1113*7304104dSAndroid Build Coastguard Worker extern int dwarf_errno (void);
1114*7304104dSAndroid Build Coastguard Worker
1115*7304104dSAndroid Build Coastguard Worker /* Return error string for ERROR. If ERROR is zero, return error string
1116*7304104dSAndroid Build Coastguard Worker for most recent error or NULL is none occurred. If ERROR is -1 the
1117*7304104dSAndroid Build Coastguard Worker behaviour is similar to the last case except that not NULL but a legal
1118*7304104dSAndroid Build Coastguard Worker string is returned. */
1119*7304104dSAndroid Build Coastguard Worker extern const char *dwarf_errmsg (int err);
1120*7304104dSAndroid Build Coastguard Worker
1121*7304104dSAndroid Build Coastguard Worker
1122*7304104dSAndroid Build Coastguard Worker /* Register new Out-Of-Memory handler. The old handler is returned. */
1123*7304104dSAndroid Build Coastguard Worker extern Dwarf_OOM dwarf_new_oom_handler (Dwarf *dbg, Dwarf_OOM handler);
1124*7304104dSAndroid Build Coastguard Worker
1125*7304104dSAndroid Build Coastguard Worker
1126*7304104dSAndroid Build Coastguard Worker /* Inline optimizations. */
1127*7304104dSAndroid Build Coastguard Worker #ifdef __OPTIMIZE__
1128*7304104dSAndroid Build Coastguard Worker /* Return attribute code of given attribute. */
1129*7304104dSAndroid Build Coastguard Worker __libdw_extern_inline unsigned int
dwarf_whatattr(Dwarf_Attribute * attr)1130*7304104dSAndroid Build Coastguard Worker dwarf_whatattr (Dwarf_Attribute *attr)
1131*7304104dSAndroid Build Coastguard Worker {
1132*7304104dSAndroid Build Coastguard Worker return attr == NULL ? 0 : attr->code;
1133*7304104dSAndroid Build Coastguard Worker }
1134*7304104dSAndroid Build Coastguard Worker
1135*7304104dSAndroid Build Coastguard Worker /* Return attribute code of given attribute. */
1136*7304104dSAndroid Build Coastguard Worker __libdw_extern_inline unsigned int
dwarf_whatform(Dwarf_Attribute * attr)1137*7304104dSAndroid Build Coastguard Worker dwarf_whatform (Dwarf_Attribute *attr)
1138*7304104dSAndroid Build Coastguard Worker {
1139*7304104dSAndroid Build Coastguard Worker return attr == NULL ? 0 : attr->form;
1140*7304104dSAndroid Build Coastguard Worker }
1141*7304104dSAndroid Build Coastguard Worker #endif /* Optimize. */
1142*7304104dSAndroid Build Coastguard Worker
1143*7304104dSAndroid Build Coastguard Worker #ifdef __cplusplus
1144*7304104dSAndroid Build Coastguard Worker }
1145*7304104dSAndroid Build Coastguard Worker #endif
1146*7304104dSAndroid Build Coastguard Worker
1147*7304104dSAndroid Build Coastguard Worker #endif /* libdw.h */
1148