1*7304104dSAndroid Build Coastguard Worker /* Internal definitions for libdwfl.
2*7304104dSAndroid Build Coastguard Worker Copyright (C) 2005-2015, 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 _LIBDWFLP_H
30*7304104dSAndroid Build Coastguard Worker #define _LIBDWFLP_H 1
31*7304104dSAndroid Build Coastguard Worker
32*7304104dSAndroid Build Coastguard Worker #include <libdwfl.h>
33*7304104dSAndroid Build Coastguard Worker #include <libebl.h>
34*7304104dSAndroid Build Coastguard Worker #include <assert.h>
35*7304104dSAndroid Build Coastguard Worker #include <dirent.h>
36*7304104dSAndroid Build Coastguard Worker #include <errno.h>
37*7304104dSAndroid Build Coastguard Worker #include <stdbool.h>
38*7304104dSAndroid Build Coastguard Worker #include <stdlib.h>
39*7304104dSAndroid Build Coastguard Worker #include <string.h>
40*7304104dSAndroid Build Coastguard Worker
41*7304104dSAndroid Build Coastguard Worker #include "libdwP.h" /* We need its INTDECLs. */
42*7304104dSAndroid Build Coastguard Worker #include "libdwelfP.h"
43*7304104dSAndroid Build Coastguard Worker
44*7304104dSAndroid Build Coastguard Worker typedef struct Dwfl_Process Dwfl_Process;
45*7304104dSAndroid Build Coastguard Worker
46*7304104dSAndroid Build Coastguard Worker #define DWFL_ERRORS \
47*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (NOERROR, N_("no error")) \
48*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (UNKNOWN_ERROR, N_("unknown error")) \
49*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (NOMEM, N_("out of memory")) \
50*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (ERRNO, N_("See errno")) \
51*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (LIBELF, N_("See elf_errno")) \
52*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (LIBDW, N_("See dwarf_errno")) \
53*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (LIBEBL, N_("See ebl_errno (XXX missing)")) \
54*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (ZLIB, N_("gzip decompression failed")) \
55*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (BZLIB, N_("bzip2 decompression failed")) \
56*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (LZMA, N_("LZMA decompression failed")) \
57*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (ZSTD, N_("zstd decompression failed")) \
58*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (UNKNOWN_MACHINE, N_("no support library found for machine")) \
59*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (NOREL, N_("Callbacks missing for ET_REL file")) \
60*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (BADRELTYPE, N_("Unsupported relocation type")) \
61*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (BADRELOFF, N_("r_offset is bogus")) \
62*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (BADSTROFF, N_("offset out of range")) \
63*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (RELUNDEF, N_("relocation refers to undefined symbol")) \
64*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (CB, N_("Callback returned failure")) \
65*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (NO_DWARF, N_("No DWARF information found")) \
66*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (NO_SYMTAB, N_("No symbol table found")) \
67*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (NO_PHDR, N_("No ELF program headers")) \
68*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (OVERLAP, N_("address range overlaps an existing module")) \
69*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (ADDR_OUTOFRANGE, N_("address out of range")) \
70*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (NO_MATCH, N_("no matching address range")) \
71*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (TRUNCATED, N_("image truncated")) \
72*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (ALREADY_ELF, N_("ELF file opened")) \
73*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (BADELF, N_("not a valid ELF file")) \
74*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (WEIRD_TYPE, N_("cannot handle DWARF type description")) \
75*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (WRONG_ID_ELF, N_("ELF file does not match build ID")) \
76*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (BAD_PRELINK, N_("corrupt .gnu.prelink_undo section data")) \
77*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (LIBEBL_BAD, N_("Internal error due to ebl")) \
78*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (CORE_MISSING, N_("Missing data in core file")) \
79*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (INVALID_REGISTER, N_("Invalid register")) \
80*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (REGISTER_VAL_UNKNOWN, N_("Unknown register value")) \
81*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (PROCESS_MEMORY_READ, N_("Error reading process memory")) \
82*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (PROCESS_NO_ARCH, N_("Couldn't find architecture of any ELF")) \
83*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (PARSE_PROC, N_("Error parsing /proc filesystem")) \
84*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (INVALID_DWARF, N_("Invalid DWARF")) \
85*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (UNSUPPORTED_DWARF, N_("Unsupported DWARF")) \
86*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (NEXT_THREAD_FAIL, N_("Unable to find more threads")) \
87*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (ATTACH_STATE_CONFLICT, N_("Dwfl already has attached state")) \
88*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (NO_ATTACH_STATE, N_("Dwfl has no attached state")) \
89*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (NO_UNWIND, N_("Unwinding not supported for this architecture")) \
90*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (INVALID_ARGUMENT, N_("Invalid argument")) \
91*7304104dSAndroid Build Coastguard Worker DWFL_ERROR (NO_CORE_FILE, N_("Not an ET_CORE ELF file"))
92*7304104dSAndroid Build Coastguard Worker
93*7304104dSAndroid Build Coastguard Worker #define DWFL_ERROR(name, text) DWFL_E_##name,
94*7304104dSAndroid Build Coastguard Worker typedef enum { DWFL_ERRORS DWFL_E_NUM } Dwfl_Error;
95*7304104dSAndroid Build Coastguard Worker #undef DWFL_ERROR
96*7304104dSAndroid Build Coastguard Worker
97*7304104dSAndroid Build Coastguard Worker #define OTHER_ERROR(name) ((unsigned int) DWFL_E_##name << 16)
98*7304104dSAndroid Build Coastguard Worker #define DWFL_E(name, errno) (OTHER_ERROR (name) | (errno))
99*7304104dSAndroid Build Coastguard Worker
100*7304104dSAndroid Build Coastguard Worker extern int __libdwfl_canon_error (Dwfl_Error) internal_function;
101*7304104dSAndroid Build Coastguard Worker extern void __libdwfl_seterrno (Dwfl_Error) internal_function;
102*7304104dSAndroid Build Coastguard Worker
103*7304104dSAndroid Build Coastguard Worker /* Resources we might keep for the user about the core file that the
104*7304104dSAndroid Build Coastguard Worker Dwfl might have been created from. Can currently only be set
105*7304104dSAndroid Build Coastguard Worker through std-argp. */
106*7304104dSAndroid Build Coastguard Worker struct Dwfl_User_Core
107*7304104dSAndroid Build Coastguard Worker {
108*7304104dSAndroid Build Coastguard Worker char *executable_for_core; /* --executable if --core was specified. */
109*7304104dSAndroid Build Coastguard Worker Elf *core; /* non-NULL if we need to free it. */
110*7304104dSAndroid Build Coastguard Worker int fd; /* close if >= 0. */
111*7304104dSAndroid Build Coastguard Worker };
112*7304104dSAndroid Build Coastguard Worker
113*7304104dSAndroid Build Coastguard Worker struct Dwfl
114*7304104dSAndroid Build Coastguard Worker {
115*7304104dSAndroid Build Coastguard Worker const Dwfl_Callbacks *callbacks;
116*7304104dSAndroid Build Coastguard Worker #ifdef ENABLE_LIBDEBUGINFOD
117*7304104dSAndroid Build Coastguard Worker debuginfod_client *debuginfod;
118*7304104dSAndroid Build Coastguard Worker #endif
119*7304104dSAndroid Build Coastguard Worker Dwfl_Module *modulelist; /* List in order used by full traversals. */
120*7304104dSAndroid Build Coastguard Worker
121*7304104dSAndroid Build Coastguard Worker Dwfl_Process *process;
122*7304104dSAndroid Build Coastguard Worker Dwfl_Error attacherr; /* Previous error attaching process. */
123*7304104dSAndroid Build Coastguard Worker
124*7304104dSAndroid Build Coastguard Worker GElf_Addr offline_next_address;
125*7304104dSAndroid Build Coastguard Worker
126*7304104dSAndroid Build Coastguard Worker GElf_Addr segment_align; /* Smallest granularity of segments. */
127*7304104dSAndroid Build Coastguard Worker
128*7304104dSAndroid Build Coastguard Worker /* Binary search table in three parallel malloc'd arrays. */
129*7304104dSAndroid Build Coastguard Worker size_t lookup_elts; /* Elements in use. */
130*7304104dSAndroid Build Coastguard Worker size_t lookup_alloc; /* Elements allococated. */
131*7304104dSAndroid Build Coastguard Worker GElf_Addr *lookup_addr; /* Start address of segment. */
132*7304104dSAndroid Build Coastguard Worker Dwfl_Module **lookup_module; /* Module associated with segment, or null. */
133*7304104dSAndroid Build Coastguard Worker int *lookup_segndx; /* User segment index, or -1. */
134*7304104dSAndroid Build Coastguard Worker int next_segndx;
135*7304104dSAndroid Build Coastguard Worker
136*7304104dSAndroid Build Coastguard Worker struct Dwfl_User_Core *user_core;
137*7304104dSAndroid Build Coastguard Worker };
138*7304104dSAndroid Build Coastguard Worker
139*7304104dSAndroid Build Coastguard Worker #define OFFLINE_REDZONE 0x10000
140*7304104dSAndroid Build Coastguard Worker
141*7304104dSAndroid Build Coastguard Worker struct dwfl_file
142*7304104dSAndroid Build Coastguard Worker {
143*7304104dSAndroid Build Coastguard Worker char *name;
144*7304104dSAndroid Build Coastguard Worker int fd;
145*7304104dSAndroid Build Coastguard Worker bool valid; /* The build ID note has been matched. */
146*7304104dSAndroid Build Coastguard Worker bool relocated; /* Partial relocation of all sections done. */
147*7304104dSAndroid Build Coastguard Worker
148*7304104dSAndroid Build Coastguard Worker Elf *elf;
149*7304104dSAndroid Build Coastguard Worker
150*7304104dSAndroid Build Coastguard Worker /* This is the lowest p_vaddr in this ELF file, aligned to p_align.
151*7304104dSAndroid Build Coastguard Worker For a file without phdrs, this is zero. */
152*7304104dSAndroid Build Coastguard Worker GElf_Addr vaddr;
153*7304104dSAndroid Build Coastguard Worker
154*7304104dSAndroid Build Coastguard Worker /* This is an address chosen for synchronization between the main file
155*7304104dSAndroid Build Coastguard Worker and the debug file. See dwfl_module_getdwarf.c for how it's chosen. */
156*7304104dSAndroid Build Coastguard Worker GElf_Addr address_sync;
157*7304104dSAndroid Build Coastguard Worker };
158*7304104dSAndroid Build Coastguard Worker
159*7304104dSAndroid Build Coastguard Worker struct Dwfl_Module
160*7304104dSAndroid Build Coastguard Worker {
161*7304104dSAndroid Build Coastguard Worker Dwfl *dwfl;
162*7304104dSAndroid Build Coastguard Worker struct Dwfl_Module *next; /* Link on Dwfl.modulelist. */
163*7304104dSAndroid Build Coastguard Worker
164*7304104dSAndroid Build Coastguard Worker void *userdata;
165*7304104dSAndroid Build Coastguard Worker
166*7304104dSAndroid Build Coastguard Worker char *name; /* Iterator name for this module. */
167*7304104dSAndroid Build Coastguard Worker GElf_Addr low_addr, high_addr;
168*7304104dSAndroid Build Coastguard Worker
169*7304104dSAndroid Build Coastguard Worker struct dwfl_file main, debug, aux_sym;
170*7304104dSAndroid Build Coastguard Worker GElf_Addr main_bias;
171*7304104dSAndroid Build Coastguard Worker Ebl *ebl;
172*7304104dSAndroid Build Coastguard Worker GElf_Half e_type; /* GElf_Ehdr.e_type cache. */
173*7304104dSAndroid Build Coastguard Worker Dwfl_Error elferr; /* Previous failure to open main file. */
174*7304104dSAndroid Build Coastguard Worker
175*7304104dSAndroid Build Coastguard Worker struct dwfl_relocation *reloc_info; /* Relocatable sections. */
176*7304104dSAndroid Build Coastguard Worker
177*7304104dSAndroid Build Coastguard Worker struct dwfl_file *symfile; /* Either main or debug. */
178*7304104dSAndroid Build Coastguard Worker Elf_Data *symdata; /* Data in the ELF symbol table section. */
179*7304104dSAndroid Build Coastguard Worker Elf_Data *aux_symdata; /* Data in the auxiliary ELF symbol table. */
180*7304104dSAndroid Build Coastguard Worker size_t syments; /* sh_size / sh_entsize of that section. */
181*7304104dSAndroid Build Coastguard Worker size_t aux_syments; /* sh_size / sh_entsize of aux_sym section. */
182*7304104dSAndroid Build Coastguard Worker int first_global; /* Index of first global symbol of table. */
183*7304104dSAndroid Build Coastguard Worker int aux_first_global; /* Index of first global of aux_sym table. */
184*7304104dSAndroid Build Coastguard Worker Elf_Data *symstrdata; /* Data for its string table. */
185*7304104dSAndroid Build Coastguard Worker Elf_Data *aux_symstrdata; /* Data for aux_sym string table. */
186*7304104dSAndroid Build Coastguard Worker Elf_Data *symxndxdata; /* Data in the extended section index table. */
187*7304104dSAndroid Build Coastguard Worker Elf_Data *aux_symxndxdata; /* Data in the extended auxiliary table. */
188*7304104dSAndroid Build Coastguard Worker
189*7304104dSAndroid Build Coastguard Worker char *elfpath; /* The path where we found the main Elf. */
190*7304104dSAndroid Build Coastguard Worker
191*7304104dSAndroid Build Coastguard Worker Dwarf *dw; /* libdw handle for its debugging info. */
192*7304104dSAndroid Build Coastguard Worker Dwarf *alt; /* Dwarf used for dwarf_setalt, or NULL. */
193*7304104dSAndroid Build Coastguard Worker int alt_fd; /* descriptor, only valid when alt != NULL. */
194*7304104dSAndroid Build Coastguard Worker Elf *alt_elf; /* Elf for alt Dwarf. */
195*7304104dSAndroid Build Coastguard Worker
196*7304104dSAndroid Build Coastguard Worker Dwfl_Error symerr; /* Previous failure to load symbols. */
197*7304104dSAndroid Build Coastguard Worker Dwfl_Error dwerr; /* Previous failure to load DWARF. */
198*7304104dSAndroid Build Coastguard Worker
199*7304104dSAndroid Build Coastguard Worker /* Known CU's in this module. */
200*7304104dSAndroid Build Coastguard Worker struct dwfl_cu *first_cu, **cu;
201*7304104dSAndroid Build Coastguard Worker
202*7304104dSAndroid Build Coastguard Worker void *lazy_cu_root; /* Table indexed by Dwarf_Off of CU. */
203*7304104dSAndroid Build Coastguard Worker
204*7304104dSAndroid Build Coastguard Worker struct dwfl_arange *aranges; /* Mapping of addresses in module to CUs. */
205*7304104dSAndroid Build Coastguard Worker
206*7304104dSAndroid Build Coastguard Worker void *build_id_bits; /* malloc'd copy of build ID bits. */
207*7304104dSAndroid Build Coastguard Worker GElf_Addr build_id_vaddr; /* Address where they reside, 0 if unknown. */
208*7304104dSAndroid Build Coastguard Worker int build_id_len; /* -1 for prior failure, 0 if unset. */
209*7304104dSAndroid Build Coastguard Worker
210*7304104dSAndroid Build Coastguard Worker unsigned int ncu;
211*7304104dSAndroid Build Coastguard Worker unsigned int lazycu; /* Possible users, deleted when none left. */
212*7304104dSAndroid Build Coastguard Worker unsigned int naranges;
213*7304104dSAndroid Build Coastguard Worker
214*7304104dSAndroid Build Coastguard Worker Dwarf_CFI *dwarf_cfi; /* Cached DWARF CFI for this module. */
215*7304104dSAndroid Build Coastguard Worker Dwarf_CFI *eh_cfi; /* Cached EH CFI for this module. */
216*7304104dSAndroid Build Coastguard Worker
217*7304104dSAndroid Build Coastguard Worker int segment; /* Index of first segment table entry. */
218*7304104dSAndroid Build Coastguard Worker bool gc; /* Mark/sweep flag. */
219*7304104dSAndroid Build Coastguard Worker bool is_executable; /* Use Dwfl::executable_for_core? */
220*7304104dSAndroid Build Coastguard Worker };
221*7304104dSAndroid Build Coastguard Worker
222*7304104dSAndroid Build Coastguard Worker /* This holds information common for all the threads/tasks/TIDs of one process
223*7304104dSAndroid Build Coastguard Worker for backtraces. */
224*7304104dSAndroid Build Coastguard Worker
225*7304104dSAndroid Build Coastguard Worker struct Dwfl_Process
226*7304104dSAndroid Build Coastguard Worker {
227*7304104dSAndroid Build Coastguard Worker struct Dwfl *dwfl;
228*7304104dSAndroid Build Coastguard Worker pid_t pid;
229*7304104dSAndroid Build Coastguard Worker const Dwfl_Thread_Callbacks *callbacks;
230*7304104dSAndroid Build Coastguard Worker void *callbacks_arg;
231*7304104dSAndroid Build Coastguard Worker struct ebl *ebl;
232*7304104dSAndroid Build Coastguard Worker bool ebl_close:1;
233*7304104dSAndroid Build Coastguard Worker };
234*7304104dSAndroid Build Coastguard Worker
235*7304104dSAndroid Build Coastguard Worker /* See its typedef in libdwfl.h. */
236*7304104dSAndroid Build Coastguard Worker
237*7304104dSAndroid Build Coastguard Worker struct Dwfl_Thread
238*7304104dSAndroid Build Coastguard Worker {
239*7304104dSAndroid Build Coastguard Worker Dwfl_Process *process;
240*7304104dSAndroid Build Coastguard Worker pid_t tid;
241*7304104dSAndroid Build Coastguard Worker /* Bottom (innermost) frame while we're initializing, NULL afterwards. */
242*7304104dSAndroid Build Coastguard Worker Dwfl_Frame *unwound;
243*7304104dSAndroid Build Coastguard Worker void *callbacks_arg;
244*7304104dSAndroid Build Coastguard Worker };
245*7304104dSAndroid Build Coastguard Worker
246*7304104dSAndroid Build Coastguard Worker /* See its typedef in libdwfl.h. */
247*7304104dSAndroid Build Coastguard Worker
248*7304104dSAndroid Build Coastguard Worker struct Dwfl_Frame
249*7304104dSAndroid Build Coastguard Worker {
250*7304104dSAndroid Build Coastguard Worker Dwfl_Thread *thread;
251*7304104dSAndroid Build Coastguard Worker /* Previous (outer) frame. */
252*7304104dSAndroid Build Coastguard Worker Dwfl_Frame *unwound;
253*7304104dSAndroid Build Coastguard Worker bool signal_frame : 1;
254*7304104dSAndroid Build Coastguard Worker bool initial_frame : 1;
255*7304104dSAndroid Build Coastguard Worker enum
256*7304104dSAndroid Build Coastguard Worker {
257*7304104dSAndroid Build Coastguard Worker /* This structure is still being initialized or there was an error
258*7304104dSAndroid Build Coastguard Worker initializing it. */
259*7304104dSAndroid Build Coastguard Worker DWFL_FRAME_STATE_ERROR,
260*7304104dSAndroid Build Coastguard Worker /* PC field is valid. */
261*7304104dSAndroid Build Coastguard Worker DWFL_FRAME_STATE_PC_SET,
262*7304104dSAndroid Build Coastguard Worker /* PC field is undefined, this means the next (inner) frame was the
263*7304104dSAndroid Build Coastguard Worker outermost frame. */
264*7304104dSAndroid Build Coastguard Worker DWFL_FRAME_STATE_PC_UNDEFINED
265*7304104dSAndroid Build Coastguard Worker } pc_state;
266*7304104dSAndroid Build Coastguard Worker /* Either initialized from appropriate REGS element or on some archs
267*7304104dSAndroid Build Coastguard Worker initialized separately as the return address has no DWARF register. */
268*7304104dSAndroid Build Coastguard Worker Dwarf_Addr pc;
269*7304104dSAndroid Build Coastguard Worker /* (1 << X) bitmask where 0 <= X < ebl_frame_nregs. */
270*7304104dSAndroid Build Coastguard Worker uint64_t regs_set[3];
271*7304104dSAndroid Build Coastguard Worker /* REGS array size is ebl_frame_nregs.
272*7304104dSAndroid Build Coastguard Worker REGS_SET tells which of the REGS are valid. */
273*7304104dSAndroid Build Coastguard Worker Dwarf_Addr regs[];
274*7304104dSAndroid Build Coastguard Worker };
275*7304104dSAndroid Build Coastguard Worker
276*7304104dSAndroid Build Coastguard Worker /* Fetch value from Dwfl_Frame->regs indexed by DWARF REGNO. The
277*7304104dSAndroid Build Coastguard Worker function returns 0 on success, -1 on error (invalid DWARF register
278*7304104dSAndroid Build Coastguard Worker number), 1 if the value of the register in the frame is unknown.
279*7304104dSAndroid Build Coastguard Worker Even on error, no error code is set. */
280*7304104dSAndroid Build Coastguard Worker int __libdwfl_frame_reg_get (Dwfl_Frame *state, unsigned regno,
281*7304104dSAndroid Build Coastguard Worker Dwarf_Addr *val)
282*7304104dSAndroid Build Coastguard Worker internal_function;
283*7304104dSAndroid Build Coastguard Worker
284*7304104dSAndroid Build Coastguard Worker /* Store value to Dwfl_Frame->regs indexed by DWARF REGNO.
285*7304104dSAndroid Build Coastguard Worker No error code is set if the function returns FALSE. */
286*7304104dSAndroid Build Coastguard Worker bool __libdwfl_frame_reg_set (Dwfl_Frame *state, unsigned regno,
287*7304104dSAndroid Build Coastguard Worker Dwarf_Addr val)
288*7304104dSAndroid Build Coastguard Worker internal_function;
289*7304104dSAndroid Build Coastguard Worker
290*7304104dSAndroid Build Coastguard Worker /* Information cached about each CU in Dwfl_Module.dw. */
291*7304104dSAndroid Build Coastguard Worker struct dwfl_cu
292*7304104dSAndroid Build Coastguard Worker {
293*7304104dSAndroid Build Coastguard Worker /* This caches libdw information about the CU. It's also the
294*7304104dSAndroid Build Coastguard Worker address passed back to users, so we take advantage of the
295*7304104dSAndroid Build Coastguard Worker fact that it's placed first to cast back. */
296*7304104dSAndroid Build Coastguard Worker Dwarf_Die die;
297*7304104dSAndroid Build Coastguard Worker
298*7304104dSAndroid Build Coastguard Worker Dwfl_Module *mod; /* Pointer back to containing module. */
299*7304104dSAndroid Build Coastguard Worker
300*7304104dSAndroid Build Coastguard Worker struct dwfl_cu *next; /* CU immediately following in the file. */
301*7304104dSAndroid Build Coastguard Worker
302*7304104dSAndroid Build Coastguard Worker struct Dwfl_Lines *lines;
303*7304104dSAndroid Build Coastguard Worker };
304*7304104dSAndroid Build Coastguard Worker
305*7304104dSAndroid Build Coastguard Worker struct Dwfl_Lines
306*7304104dSAndroid Build Coastguard Worker {
307*7304104dSAndroid Build Coastguard Worker struct dwfl_cu *cu;
308*7304104dSAndroid Build Coastguard Worker
309*7304104dSAndroid Build Coastguard Worker /* This is what the opaque Dwfl_Line * pointers we pass to users are.
310*7304104dSAndroid Build Coastguard Worker We need to recover pointers to our struct dwfl_cu and a record in
311*7304104dSAndroid Build Coastguard Worker libdw's Dwarf_Line table. To minimize the memory used in addition
312*7304104dSAndroid Build Coastguard Worker to libdw's Dwarf_Lines buffer, we just point to our own index in
313*7304104dSAndroid Build Coastguard Worker this table, and have one pointer back to the CU. The indices here
314*7304104dSAndroid Build Coastguard Worker match those in libdw's Dwarf_CU.lines->info table. */
315*7304104dSAndroid Build Coastguard Worker struct Dwfl_Line
316*7304104dSAndroid Build Coastguard Worker {
317*7304104dSAndroid Build Coastguard Worker unsigned int idx; /* My index in the dwfl_cu.lines table. */
318*7304104dSAndroid Build Coastguard Worker } idx[0];
319*7304104dSAndroid Build Coastguard Worker };
320*7304104dSAndroid Build Coastguard Worker
321*7304104dSAndroid Build Coastguard Worker static inline struct dwfl_cu *
dwfl_linecu_inline(const Dwfl_Line * line)322*7304104dSAndroid Build Coastguard Worker dwfl_linecu_inline (const Dwfl_Line *line)
323*7304104dSAndroid Build Coastguard Worker {
324*7304104dSAndroid Build Coastguard Worker const struct Dwfl_Lines *lines = ((const void *) line
325*7304104dSAndroid Build Coastguard Worker - offsetof (struct Dwfl_Lines,
326*7304104dSAndroid Build Coastguard Worker idx[line->idx]));
327*7304104dSAndroid Build Coastguard Worker return lines->cu;
328*7304104dSAndroid Build Coastguard Worker }
329*7304104dSAndroid Build Coastguard Worker #define dwfl_linecu dwfl_linecu_inline
330*7304104dSAndroid Build Coastguard Worker
331*7304104dSAndroid Build Coastguard Worker static inline GElf_Addr
dwfl_adjusted_address(Dwfl_Module * mod,GElf_Addr addr)332*7304104dSAndroid Build Coastguard Worker dwfl_adjusted_address (Dwfl_Module *mod, GElf_Addr addr)
333*7304104dSAndroid Build Coastguard Worker {
334*7304104dSAndroid Build Coastguard Worker return addr + mod->main_bias;
335*7304104dSAndroid Build Coastguard Worker }
336*7304104dSAndroid Build Coastguard Worker
337*7304104dSAndroid Build Coastguard Worker static inline GElf_Addr
dwfl_deadjust_address(Dwfl_Module * mod,GElf_Addr addr)338*7304104dSAndroid Build Coastguard Worker dwfl_deadjust_address (Dwfl_Module *mod, GElf_Addr addr)
339*7304104dSAndroid Build Coastguard Worker {
340*7304104dSAndroid Build Coastguard Worker return addr - mod->main_bias;
341*7304104dSAndroid Build Coastguard Worker }
342*7304104dSAndroid Build Coastguard Worker
343*7304104dSAndroid Build Coastguard Worker static inline Dwarf_Addr
dwfl_adjusted_dwarf_addr(Dwfl_Module * mod,Dwarf_Addr addr)344*7304104dSAndroid Build Coastguard Worker dwfl_adjusted_dwarf_addr (Dwfl_Module *mod, Dwarf_Addr addr)
345*7304104dSAndroid Build Coastguard Worker {
346*7304104dSAndroid Build Coastguard Worker return dwfl_adjusted_address (mod, (addr
347*7304104dSAndroid Build Coastguard Worker - mod->debug.address_sync
348*7304104dSAndroid Build Coastguard Worker + mod->main.address_sync));
349*7304104dSAndroid Build Coastguard Worker }
350*7304104dSAndroid Build Coastguard Worker
351*7304104dSAndroid Build Coastguard Worker static inline Dwarf_Addr
dwfl_deadjust_dwarf_addr(Dwfl_Module * mod,Dwarf_Addr addr)352*7304104dSAndroid Build Coastguard Worker dwfl_deadjust_dwarf_addr (Dwfl_Module *mod, Dwarf_Addr addr)
353*7304104dSAndroid Build Coastguard Worker {
354*7304104dSAndroid Build Coastguard Worker return (dwfl_deadjust_address (mod, addr)
355*7304104dSAndroid Build Coastguard Worker - mod->main.address_sync
356*7304104dSAndroid Build Coastguard Worker + mod->debug.address_sync);
357*7304104dSAndroid Build Coastguard Worker }
358*7304104dSAndroid Build Coastguard Worker
359*7304104dSAndroid Build Coastguard Worker static inline Dwarf_Addr
dwfl_adjusted_aux_sym_addr(Dwfl_Module * mod,Dwarf_Addr addr)360*7304104dSAndroid Build Coastguard Worker dwfl_adjusted_aux_sym_addr (Dwfl_Module *mod, Dwarf_Addr addr)
361*7304104dSAndroid Build Coastguard Worker {
362*7304104dSAndroid Build Coastguard Worker return dwfl_adjusted_address (mod, (addr
363*7304104dSAndroid Build Coastguard Worker - mod->aux_sym.address_sync
364*7304104dSAndroid Build Coastguard Worker + mod->main.address_sync));
365*7304104dSAndroid Build Coastguard Worker }
366*7304104dSAndroid Build Coastguard Worker
367*7304104dSAndroid Build Coastguard Worker static inline Dwarf_Addr
dwfl_deadjust_aux_sym_addr(Dwfl_Module * mod,Dwarf_Addr addr)368*7304104dSAndroid Build Coastguard Worker dwfl_deadjust_aux_sym_addr (Dwfl_Module *mod, Dwarf_Addr addr)
369*7304104dSAndroid Build Coastguard Worker {
370*7304104dSAndroid Build Coastguard Worker return (dwfl_deadjust_address (mod, addr)
371*7304104dSAndroid Build Coastguard Worker - mod->main.address_sync
372*7304104dSAndroid Build Coastguard Worker + mod->aux_sym.address_sync);
373*7304104dSAndroid Build Coastguard Worker }
374*7304104dSAndroid Build Coastguard Worker
375*7304104dSAndroid Build Coastguard Worker static inline GElf_Addr
dwfl_adjusted_st_value(Dwfl_Module * mod,Elf * symelf,GElf_Addr addr)376*7304104dSAndroid Build Coastguard Worker dwfl_adjusted_st_value (Dwfl_Module *mod, Elf *symelf, GElf_Addr addr)
377*7304104dSAndroid Build Coastguard Worker {
378*7304104dSAndroid Build Coastguard Worker if (symelf == mod->main.elf)
379*7304104dSAndroid Build Coastguard Worker return dwfl_adjusted_address (mod, addr);
380*7304104dSAndroid Build Coastguard Worker if (symelf == mod->debug.elf)
381*7304104dSAndroid Build Coastguard Worker return dwfl_adjusted_dwarf_addr (mod, addr);
382*7304104dSAndroid Build Coastguard Worker return dwfl_adjusted_aux_sym_addr (mod, addr);
383*7304104dSAndroid Build Coastguard Worker }
384*7304104dSAndroid Build Coastguard Worker
385*7304104dSAndroid Build Coastguard Worker static inline GElf_Addr
dwfl_deadjust_st_value(Dwfl_Module * mod,Elf * symelf,GElf_Addr addr)386*7304104dSAndroid Build Coastguard Worker dwfl_deadjust_st_value (Dwfl_Module *mod, Elf *symelf, GElf_Addr addr)
387*7304104dSAndroid Build Coastguard Worker {
388*7304104dSAndroid Build Coastguard Worker if (symelf == mod->main.elf)
389*7304104dSAndroid Build Coastguard Worker return dwfl_deadjust_address (mod, addr);
390*7304104dSAndroid Build Coastguard Worker if (symelf == mod->debug.elf)
391*7304104dSAndroid Build Coastguard Worker return dwfl_deadjust_dwarf_addr (mod, addr);
392*7304104dSAndroid Build Coastguard Worker return dwfl_deadjust_aux_sym_addr (mod, addr);
393*7304104dSAndroid Build Coastguard Worker }
394*7304104dSAndroid Build Coastguard Worker
395*7304104dSAndroid Build Coastguard Worker /* This describes a contiguous address range that lies in a single CU.
396*7304104dSAndroid Build Coastguard Worker We condense runs of Dwarf_Arange entries for the same CU into this. */
397*7304104dSAndroid Build Coastguard Worker struct dwfl_arange
398*7304104dSAndroid Build Coastguard Worker {
399*7304104dSAndroid Build Coastguard Worker struct dwfl_cu *cu;
400*7304104dSAndroid Build Coastguard Worker size_t arange; /* Index in Dwarf_Aranges. */
401*7304104dSAndroid Build Coastguard Worker };
402*7304104dSAndroid Build Coastguard Worker
403*7304104dSAndroid Build Coastguard Worker #define __LIBDWFL_REMOTE_MEM_CACHE_SIZE 4096
404*7304104dSAndroid Build Coastguard Worker /* Structure for caching remote memory reads as used by __libdwfl_pid_arg. */
405*7304104dSAndroid Build Coastguard Worker struct __libdwfl_remote_mem_cache
406*7304104dSAndroid Build Coastguard Worker {
407*7304104dSAndroid Build Coastguard Worker Dwarf_Addr addr; /* Remote address. */
408*7304104dSAndroid Build Coastguard Worker Dwarf_Off len; /* Zero if cleared, otherwise likely 4K. */
409*7304104dSAndroid Build Coastguard Worker unsigned char buf[__LIBDWFL_REMOTE_MEM_CACHE_SIZE]; /* The actual cache. */
410*7304104dSAndroid Build Coastguard Worker };
411*7304104dSAndroid Build Coastguard Worker
412*7304104dSAndroid Build Coastguard Worker /* Structure used for keeping track of ptrace attaching a thread.
413*7304104dSAndroid Build Coastguard Worker Shared by linux-pid-attach and linux-proc-maps. If it has been setup
414*7304104dSAndroid Build Coastguard Worker then get the instance through __libdwfl_get_pid_arg. */
415*7304104dSAndroid Build Coastguard Worker struct __libdwfl_pid_arg
416*7304104dSAndroid Build Coastguard Worker {
417*7304104dSAndroid Build Coastguard Worker /* /proc/PID/task/. */
418*7304104dSAndroid Build Coastguard Worker DIR *dir;
419*7304104dSAndroid Build Coastguard Worker /* Elf for /proc/PID/exe. Set to NULL if it couldn't be opened. */
420*7304104dSAndroid Build Coastguard Worker Elf *elf;
421*7304104dSAndroid Build Coastguard Worker /* Remote memory cache, NULL if there is no memory cached.
422*7304104dSAndroid Build Coastguard Worker Should be cleared on detachment (because that makes the thread
423*7304104dSAndroid Build Coastguard Worker runnable and the cache invalid). */
424*7304104dSAndroid Build Coastguard Worker struct __libdwfl_remote_mem_cache *mem_cache;
425*7304104dSAndroid Build Coastguard Worker /* fd for /proc/PID/exe. Set to -1 if it couldn't be opened. */
426*7304104dSAndroid Build Coastguard Worker int elf_fd;
427*7304104dSAndroid Build Coastguard Worker /* It is 0 if not used. */
428*7304104dSAndroid Build Coastguard Worker pid_t tid_attached;
429*7304104dSAndroid Build Coastguard Worker /* Valid only if TID_ATTACHED is not zero. */
430*7304104dSAndroid Build Coastguard Worker bool tid_was_stopped;
431*7304104dSAndroid Build Coastguard Worker /* True if threads are ptrace stopped by caller. */
432*7304104dSAndroid Build Coastguard Worker bool assume_ptrace_stopped;
433*7304104dSAndroid Build Coastguard Worker };
434*7304104dSAndroid Build Coastguard Worker
435*7304104dSAndroid Build Coastguard Worker /* If DWfl is not NULL and a Dwfl_Process has been setup that has
436*7304104dSAndroid Build Coastguard Worker Dwfl_Thread_Callbacks set to pid_thread_callbacks, then return the
437*7304104dSAndroid Build Coastguard Worker callbacks_arg, which will be a struct __libdwfl_pid_arg. Otherwise
438*7304104dSAndroid Build Coastguard Worker returns NULL. */
439*7304104dSAndroid Build Coastguard Worker extern struct __libdwfl_pid_arg *__libdwfl_get_pid_arg (Dwfl *dwfl)
440*7304104dSAndroid Build Coastguard Worker internal_function;
441*7304104dSAndroid Build Coastguard Worker
442*7304104dSAndroid Build Coastguard Worker /* Makes sure the given tid is attached. On success returns true and
443*7304104dSAndroid Build Coastguard Worker sets tid_was_stopped. */
444*7304104dSAndroid Build Coastguard Worker extern bool __libdwfl_ptrace_attach (pid_t tid, bool *tid_was_stoppedp)
445*7304104dSAndroid Build Coastguard Worker internal_function;
446*7304104dSAndroid Build Coastguard Worker
447*7304104dSAndroid Build Coastguard Worker /* Detaches a tid that was attached through
448*7304104dSAndroid Build Coastguard Worker __libdwfl_ptrace_attach. Must be given the tid_was_stopped as set
449*7304104dSAndroid Build Coastguard Worker by __libdwfl_ptrace_attach. */
450*7304104dSAndroid Build Coastguard Worker extern void __libdwfl_ptrace_detach (pid_t tid, bool tid_was_stopped)
451*7304104dSAndroid Build Coastguard Worker internal_function;
452*7304104dSAndroid Build Coastguard Worker
453*7304104dSAndroid Build Coastguard Worker
454*7304104dSAndroid Build Coastguard Worker /* Internal wrapper for old dwfl_module_getsym and new dwfl_module_getsym_info.
455*7304104dSAndroid Build Coastguard Worker adjust_st_value set to true returns adjusted SYM st_value, set to false
456*7304104dSAndroid Build Coastguard Worker it will not adjust SYM at all, but does match against resolved *ADDR. */
457*7304104dSAndroid Build Coastguard Worker extern const char *__libdwfl_getsym (Dwfl_Module *mod, int ndx, GElf_Sym *sym,
458*7304104dSAndroid Build Coastguard Worker GElf_Addr *addr, GElf_Word *shndxp,
459*7304104dSAndroid Build Coastguard Worker Elf **elfp, Dwarf_Addr *biasp,
460*7304104dSAndroid Build Coastguard Worker bool *resolved, bool adjust_st_value)
461*7304104dSAndroid Build Coastguard Worker internal_function;
462*7304104dSAndroid Build Coastguard Worker
463*7304104dSAndroid Build Coastguard Worker extern void __libdwfl_module_free (Dwfl_Module *mod) internal_function;
464*7304104dSAndroid Build Coastguard Worker
465*7304104dSAndroid Build Coastguard Worker /* Find the main ELF file, update MOD->elferr and/or MOD->main.elf. */
466*7304104dSAndroid Build Coastguard Worker extern void __libdwfl_getelf (Dwfl_Module *mod) internal_function;
467*7304104dSAndroid Build Coastguard Worker
468*7304104dSAndroid Build Coastguard Worker /* Process relocations in debugging sections in an ET_REL file.
469*7304104dSAndroid Build Coastguard Worker FILE must be opened with ELF_C_READ_MMAP_PRIVATE or ELF_C_READ,
470*7304104dSAndroid Build Coastguard Worker to make it possible to relocate the data in place (or ELF_C_RDWR or
471*7304104dSAndroid Build Coastguard Worker ELF_C_RDWR_MMAP if you intend to modify the Elf file on disk). After
472*7304104dSAndroid Build Coastguard Worker this, dwarf_begin_elf on FILE will read the relocated data.
473*7304104dSAndroid Build Coastguard Worker
474*7304104dSAndroid Build Coastguard Worker When DEBUG is false, apply partial relocation to all sections. */
475*7304104dSAndroid Build Coastguard Worker extern Dwfl_Error __libdwfl_relocate (Dwfl_Module *mod, Elf *file, bool debug)
476*7304104dSAndroid Build Coastguard Worker internal_function;
477*7304104dSAndroid Build Coastguard Worker
478*7304104dSAndroid Build Coastguard Worker /* Find the section index in mod->main.elf that contains the given
479*7304104dSAndroid Build Coastguard Worker *ADDR. Adjusts *ADDR to be section relative on success, returns
480*7304104dSAndroid Build Coastguard Worker SHN_UNDEF on failure. */
481*7304104dSAndroid Build Coastguard Worker extern size_t __libdwfl_find_section_ndx (Dwfl_Module *mod, Dwarf_Addr *addr)
482*7304104dSAndroid Build Coastguard Worker internal_function;
483*7304104dSAndroid Build Coastguard Worker
484*7304104dSAndroid Build Coastguard Worker /* Process (simple) relocations in arbitrary section TSCN of an ET_REL file.
485*7304104dSAndroid Build Coastguard Worker RELOCSCN is SHT_REL or SHT_RELA and TSCN is its sh_info target section. */
486*7304104dSAndroid Build Coastguard Worker extern Dwfl_Error __libdwfl_relocate_section (Dwfl_Module *mod, Elf *relocated,
487*7304104dSAndroid Build Coastguard Worker Elf_Scn *relocscn, Elf_Scn *tscn,
488*7304104dSAndroid Build Coastguard Worker bool partial)
489*7304104dSAndroid Build Coastguard Worker internal_function;
490*7304104dSAndroid Build Coastguard Worker
491*7304104dSAndroid Build Coastguard Worker /* Adjust *VALUE from section-relative to absolute.
492*7304104dSAndroid Build Coastguard Worker MOD->dwfl->callbacks->section_address is called to determine the actual
493*7304104dSAndroid Build Coastguard Worker address of a loaded section. */
494*7304104dSAndroid Build Coastguard Worker extern Dwfl_Error __libdwfl_relocate_value (Dwfl_Module *mod, Elf *elf,
495*7304104dSAndroid Build Coastguard Worker size_t *shstrndx_cache,
496*7304104dSAndroid Build Coastguard Worker Elf32_Word shndx,
497*7304104dSAndroid Build Coastguard Worker GElf_Addr *value)
498*7304104dSAndroid Build Coastguard Worker internal_function;
499*7304104dSAndroid Build Coastguard Worker
500*7304104dSAndroid Build Coastguard Worker /* Ensure that MOD->ebl is set up. */
501*7304104dSAndroid Build Coastguard Worker extern Dwfl_Error __libdwfl_module_getebl (Dwfl_Module *mod) internal_function;
502*7304104dSAndroid Build Coastguard Worker
503*7304104dSAndroid Build Coastguard Worker /* Install a new Dwarf_CFI in *SLOT (MOD->eh_cfi or MOD->dwarf_cfi). */
504*7304104dSAndroid Build Coastguard Worker extern Dwarf_CFI *__libdwfl_set_cfi (Dwfl_Module *mod, Dwarf_CFI **slot,
505*7304104dSAndroid Build Coastguard Worker Dwarf_CFI *cfi)
506*7304104dSAndroid Build Coastguard Worker internal_function;
507*7304104dSAndroid Build Coastguard Worker
508*7304104dSAndroid Build Coastguard Worker /* Iterate through all the CU's in the module. Start by passing a null
509*7304104dSAndroid Build Coastguard Worker LASTCU, and then pass the last *CU returned. Success return with null
510*7304104dSAndroid Build Coastguard Worker *CU no more CUs. */
511*7304104dSAndroid Build Coastguard Worker extern Dwfl_Error __libdwfl_nextcu (Dwfl_Module *mod, struct dwfl_cu *lastcu,
512*7304104dSAndroid Build Coastguard Worker struct dwfl_cu **cu) internal_function;
513*7304104dSAndroid Build Coastguard Worker
514*7304104dSAndroid Build Coastguard Worker /* Find the CU by address. */
515*7304104dSAndroid Build Coastguard Worker extern Dwfl_Error __libdwfl_addrcu (Dwfl_Module *mod, Dwarf_Addr addr,
516*7304104dSAndroid Build Coastguard Worker struct dwfl_cu **cu) internal_function;
517*7304104dSAndroid Build Coastguard Worker
518*7304104dSAndroid Build Coastguard Worker /* Ensure that CU->lines (and CU->cu->lines) is set up. */
519*7304104dSAndroid Build Coastguard Worker extern Dwfl_Error __libdwfl_cu_getsrclines (struct dwfl_cu *cu)
520*7304104dSAndroid Build Coastguard Worker internal_function;
521*7304104dSAndroid Build Coastguard Worker
522*7304104dSAndroid Build Coastguard Worker /* Look in ELF for an NT_GNU_BUILD_ID note. Store it to BUILD_ID_BITS,
523*7304104dSAndroid Build Coastguard Worker its vaddr in ELF to BUILD_ID_VADDR (it is unrelocated, even if MOD is not
524*7304104dSAndroid Build Coastguard Worker NULL) and store length to BUILD_ID_LEN. Returns -1 for errors, 1 if it was
525*7304104dSAndroid Build Coastguard Worker stored and 0 if no note is found. MOD may be NULL, MOD must be non-NULL
526*7304104dSAndroid Build Coastguard Worker only if ELF is ET_REL. */
527*7304104dSAndroid Build Coastguard Worker extern int __libdwfl_find_elf_build_id (Dwfl_Module *mod, Elf *elf,
528*7304104dSAndroid Build Coastguard Worker const void **build_id_bits,
529*7304104dSAndroid Build Coastguard Worker GElf_Addr *build_id_elfaddr,
530*7304104dSAndroid Build Coastguard Worker int *build_id_len)
531*7304104dSAndroid Build Coastguard Worker internal_function;
532*7304104dSAndroid Build Coastguard Worker
533*7304104dSAndroid Build Coastguard Worker /* Look in ELF for an NT_GNU_BUILD_ID note. If SET is true, store it
534*7304104dSAndroid Build Coastguard Worker in MOD and return its length. If SET is false, instead compare it
535*7304104dSAndroid Build Coastguard Worker to that stored in MOD and return 2 if they match, 1 if they do not.
536*7304104dSAndroid Build Coastguard Worker Returns -1 for errors, 0 if no note is found. */
537*7304104dSAndroid Build Coastguard Worker extern int __libdwfl_find_build_id (Dwfl_Module *mod, bool set, Elf *elf)
538*7304104dSAndroid Build Coastguard Worker internal_function;
539*7304104dSAndroid Build Coastguard Worker
540*7304104dSAndroid Build Coastguard Worker /* Open a main or debuginfo file by its build ID, returns the fd. */
541*7304104dSAndroid Build Coastguard Worker extern int __libdwfl_open_mod_by_build_id (Dwfl_Module *mod, bool debug,
542*7304104dSAndroid Build Coastguard Worker char **file_name) internal_function;
543*7304104dSAndroid Build Coastguard Worker
544*7304104dSAndroid Build Coastguard Worker /* Same, but takes an explicit build_id, can also be used for alt debug. */
545*7304104dSAndroid Build Coastguard Worker extern int __libdwfl_open_by_build_id (Dwfl_Module *mod, bool debug,
546*7304104dSAndroid Build Coastguard Worker char **file_name, const size_t id_len,
547*7304104dSAndroid Build Coastguard Worker const uint8_t *id) internal_function;
548*7304104dSAndroid Build Coastguard Worker
549*7304104dSAndroid Build Coastguard Worker extern uint32_t __libdwfl_crc32 (uint32_t crc, unsigned char *buf, size_t len)
550*7304104dSAndroid Build Coastguard Worker attribute_hidden;
551*7304104dSAndroid Build Coastguard Worker extern int __libdwfl_crc32_file (int fd, uint32_t *resp) attribute_hidden;
552*7304104dSAndroid Build Coastguard Worker
553*7304104dSAndroid Build Coastguard Worker
554*7304104dSAndroid Build Coastguard Worker /* Given ELF and some parameters return TRUE if the *P return value parameters
555*7304104dSAndroid Build Coastguard Worker have been successfully filled in. Any of the *P parameters can be NULL. */
556*7304104dSAndroid Build Coastguard Worker extern bool __libdwfl_elf_address_range (Elf *elf, GElf_Addr base,
557*7304104dSAndroid Build Coastguard Worker bool add_p_vaddr, bool sanity,
558*7304104dSAndroid Build Coastguard Worker GElf_Addr *vaddrp,
559*7304104dSAndroid Build Coastguard Worker GElf_Addr *address_syncp,
560*7304104dSAndroid Build Coastguard Worker GElf_Addr *startp, GElf_Addr *endp,
561*7304104dSAndroid Build Coastguard Worker GElf_Addr *biasp, GElf_Half *e_typep)
562*7304104dSAndroid Build Coastguard Worker internal_function;
563*7304104dSAndroid Build Coastguard Worker
564*7304104dSAndroid Build Coastguard Worker /* Meat of dwfl_report_elf, given elf_begin just called.
565*7304104dSAndroid Build Coastguard Worker Consumes ELF on success, not on failure. */
566*7304104dSAndroid Build Coastguard Worker extern Dwfl_Module *__libdwfl_report_elf (Dwfl *dwfl, const char *name,
567*7304104dSAndroid Build Coastguard Worker const char *file_name, int fd,
568*7304104dSAndroid Build Coastguard Worker Elf *elf, GElf_Addr base,
569*7304104dSAndroid Build Coastguard Worker bool add_p_vaddr, bool sanity)
570*7304104dSAndroid Build Coastguard Worker internal_function;
571*7304104dSAndroid Build Coastguard Worker
572*7304104dSAndroid Build Coastguard Worker /* Meat of dwfl_report_offline. */
573*7304104dSAndroid Build Coastguard Worker extern Dwfl_Module *__libdwfl_report_offline (Dwfl *dwfl, const char *name,
574*7304104dSAndroid Build Coastguard Worker const char *file_name,
575*7304104dSAndroid Build Coastguard Worker int fd, bool closefd,
576*7304104dSAndroid Build Coastguard Worker int (*predicate) (const char *,
577*7304104dSAndroid Build Coastguard Worker const char *))
578*7304104dSAndroid Build Coastguard Worker internal_function;
579*7304104dSAndroid Build Coastguard Worker
580*7304104dSAndroid Build Coastguard Worker /* Free PROCESS. Unlink and free also any structures it references. */
581*7304104dSAndroid Build Coastguard Worker extern void __libdwfl_process_free (Dwfl_Process *process)
582*7304104dSAndroid Build Coastguard Worker internal_function;
583*7304104dSAndroid Build Coastguard Worker
584*7304104dSAndroid Build Coastguard Worker /* Update STATE->unwound for the unwound frame.
585*7304104dSAndroid Build Coastguard Worker On error STATE->unwound == NULL
586*7304104dSAndroid Build Coastguard Worker or STATE->unwound->pc_state == DWFL_FRAME_STATE_ERROR;
587*7304104dSAndroid Build Coastguard Worker in such case dwfl_errno () is set.
588*7304104dSAndroid Build Coastguard Worker If STATE->unwound->pc_state == DWFL_FRAME_STATE_PC_UNDEFINED
589*7304104dSAndroid Build Coastguard Worker then STATE was the last valid frame. */
590*7304104dSAndroid Build Coastguard Worker extern void __libdwfl_frame_unwind (Dwfl_Frame *state)
591*7304104dSAndroid Build Coastguard Worker internal_function;
592*7304104dSAndroid Build Coastguard Worker
593*7304104dSAndroid Build Coastguard Worker /* Align segment START downwards or END upwards addresses according to DWFL. */
594*7304104dSAndroid Build Coastguard Worker extern GElf_Addr __libdwfl_segment_start (Dwfl *dwfl, GElf_Addr start)
595*7304104dSAndroid Build Coastguard Worker internal_function;
596*7304104dSAndroid Build Coastguard Worker extern GElf_Addr __libdwfl_segment_end (Dwfl *dwfl, GElf_Addr end)
597*7304104dSAndroid Build Coastguard Worker internal_function;
598*7304104dSAndroid Build Coastguard Worker
599*7304104dSAndroid Build Coastguard Worker /* Decompression wrappers: decompress whole file into memory. */
600*7304104dSAndroid Build Coastguard Worker extern Dwfl_Error __libdw_gunzip (int fd, off_t start_offset,
601*7304104dSAndroid Build Coastguard Worker void *mapped, size_t mapped_size,
602*7304104dSAndroid Build Coastguard Worker void **whole, size_t *whole_size)
603*7304104dSAndroid Build Coastguard Worker internal_function;
604*7304104dSAndroid Build Coastguard Worker extern Dwfl_Error __libdw_bunzip2 (int fd, off_t start_offset,
605*7304104dSAndroid Build Coastguard Worker void *mapped, size_t mapped_size,
606*7304104dSAndroid Build Coastguard Worker void **whole, size_t *whole_size)
607*7304104dSAndroid Build Coastguard Worker internal_function;
608*7304104dSAndroid Build Coastguard Worker extern Dwfl_Error __libdw_unlzma (int fd, off_t start_offset,
609*7304104dSAndroid Build Coastguard Worker void *mapped, size_t mapped_size,
610*7304104dSAndroid Build Coastguard Worker void **whole, size_t *whole_size)
611*7304104dSAndroid Build Coastguard Worker internal_function;
612*7304104dSAndroid Build Coastguard Worker extern Dwfl_Error __libdw_unzstd (int fd, off_t start_offset,
613*7304104dSAndroid Build Coastguard Worker void *mapped, size_t mapped_size,
614*7304104dSAndroid Build Coastguard Worker void **whole, size_t *whole_size)
615*7304104dSAndroid Build Coastguard Worker internal_function;
616*7304104dSAndroid Build Coastguard Worker
617*7304104dSAndroid Build Coastguard Worker /* Skip the image header before a file image: updates *START_OFFSET. */
618*7304104dSAndroid Build Coastguard Worker extern Dwfl_Error __libdw_image_header (int fd, off_t *start_offset,
619*7304104dSAndroid Build Coastguard Worker void *mapped, size_t mapped_size)
620*7304104dSAndroid Build Coastguard Worker internal_function;
621*7304104dSAndroid Build Coastguard Worker
622*7304104dSAndroid Build Coastguard Worker /* Open Elf handle on *FDP. This handles decompression and checks
623*7304104dSAndroid Build Coastguard Worker elf_kind. Succeed only for ELF_K_ELF, or also ELF_K_AR if ARCHIVE_OK.
624*7304104dSAndroid Build Coastguard Worker Returns DWFL_E_NOERROR and sets *ELFP on success, resets *FDP to -1 if
625*7304104dSAndroid Build Coastguard Worker it's no longer used. Resets *FDP on failure too iff CLOSE_ON_FAIL. */
626*7304104dSAndroid Build Coastguard Worker extern Dwfl_Error __libdw_open_file (int *fdp, Elf **elfp,
627*7304104dSAndroid Build Coastguard Worker bool close_on_fail, bool archive_ok)
628*7304104dSAndroid Build Coastguard Worker internal_function;
629*7304104dSAndroid Build Coastguard Worker
630*7304104dSAndroid Build Coastguard Worker /* Same as __libdw_open_file, but opens Elf handle from memory region. */
631*7304104dSAndroid Build Coastguard Worker extern Dwfl_Error __libdw_open_elf_memory (char *data, size_t size, Elf **elfp,
632*7304104dSAndroid Build Coastguard Worker bool archive_ok)
633*7304104dSAndroid Build Coastguard Worker internal_function;
634*7304104dSAndroid Build Coastguard Worker
635*7304104dSAndroid Build Coastguard Worker /* Same as __libdw_open_file, but never closes the given file
636*7304104dSAndroid Build Coastguard Worker descriptor and ELF_K_AR is always an acceptable type. */
637*7304104dSAndroid Build Coastguard Worker extern Dwfl_Error __libdw_open_elf (int fd, Elf **elfp) internal_function;
638*7304104dSAndroid Build Coastguard Worker
639*7304104dSAndroid Build Coastguard Worker /* Fetch PT_DYNAMIC P_VADDR from ELF and store it to *VADDRP. Return success.
640*7304104dSAndroid Build Coastguard Worker *VADDRP is not modified if the function fails. */
641*7304104dSAndroid Build Coastguard Worker extern bool __libdwfl_dynamic_vaddr_get (Elf *elf, GElf_Addr *vaddrp)
642*7304104dSAndroid Build Coastguard Worker internal_function;
643*7304104dSAndroid Build Coastguard Worker
644*7304104dSAndroid Build Coastguard Worker #ifdef ENABLE_LIBDEBUGINFOD
645*7304104dSAndroid Build Coastguard Worker /* Internal interface to libdebuginfod (if installed). */
646*7304104dSAndroid Build Coastguard Worker int
647*7304104dSAndroid Build Coastguard Worker __libdwfl_debuginfod_find_executable (Dwfl *dwfl,
648*7304104dSAndroid Build Coastguard Worker const unsigned char *build_id_bits,
649*7304104dSAndroid Build Coastguard Worker size_t build_id_len);
650*7304104dSAndroid Build Coastguard Worker int
651*7304104dSAndroid Build Coastguard Worker __libdwfl_debuginfod_find_debuginfo (Dwfl *dwfl,
652*7304104dSAndroid Build Coastguard Worker const unsigned char *build_id_bits,
653*7304104dSAndroid Build Coastguard Worker size_t build_id_len);
654*7304104dSAndroid Build Coastguard Worker void
655*7304104dSAndroid Build Coastguard Worker __libdwfl_debuginfod_end (debuginfod_client *c);
656*7304104dSAndroid Build Coastguard Worker #endif
657*7304104dSAndroid Build Coastguard Worker
658*7304104dSAndroid Build Coastguard Worker
659*7304104dSAndroid Build Coastguard Worker /* These are working nicely for --core, but are not ready to be
660*7304104dSAndroid Build Coastguard Worker exported interfaces quite yet. */
661*7304104dSAndroid Build Coastguard Worker
662*7304104dSAndroid Build Coastguard Worker /* Type of callback function ...
663*7304104dSAndroid Build Coastguard Worker */
664*7304104dSAndroid Build Coastguard Worker typedef bool Dwfl_Memory_Callback (Dwfl *dwfl, int segndx,
665*7304104dSAndroid Build Coastguard Worker void **buffer, size_t *buffer_available,
666*7304104dSAndroid Build Coastguard Worker GElf_Addr vaddr, size_t minread, void *arg);
667*7304104dSAndroid Build Coastguard Worker
668*7304104dSAndroid Build Coastguard Worker /* Type of callback function ...
669*7304104dSAndroid Build Coastguard Worker */
670*7304104dSAndroid Build Coastguard Worker typedef bool Dwfl_Module_Callback (Dwfl_Module *mod, void **userdata,
671*7304104dSAndroid Build Coastguard Worker const char *name, Dwarf_Addr base,
672*7304104dSAndroid Build Coastguard Worker void **buffer, size_t *buffer_available,
673*7304104dSAndroid Build Coastguard Worker GElf_Off cost, GElf_Off worthwhile,
674*7304104dSAndroid Build Coastguard Worker GElf_Off whole, GElf_Off contiguous,
675*7304104dSAndroid Build Coastguard Worker void *arg, Elf **elfp);
676*7304104dSAndroid Build Coastguard Worker
677*7304104dSAndroid Build Coastguard Worker /* One shared library (or executable) info from DT_DEBUG link map. */
678*7304104dSAndroid Build Coastguard Worker struct r_debug_info_module
679*7304104dSAndroid Build Coastguard Worker {
680*7304104dSAndroid Build Coastguard Worker struct r_debug_info_module *next;
681*7304104dSAndroid Build Coastguard Worker /* FD is -1 iff ELF is NULL. */
682*7304104dSAndroid Build Coastguard Worker int fd;
683*7304104dSAndroid Build Coastguard Worker Elf *elf;
684*7304104dSAndroid Build Coastguard Worker GElf_Addr l_ld;
685*7304104dSAndroid Build Coastguard Worker /* START and END are both zero if not valid. */
686*7304104dSAndroid Build Coastguard Worker GElf_Addr start, end;
687*7304104dSAndroid Build Coastguard Worker bool disk_file_has_build_id;
688*7304104dSAndroid Build Coastguard Worker char name[0];
689*7304104dSAndroid Build Coastguard Worker };
690*7304104dSAndroid Build Coastguard Worker
691*7304104dSAndroid Build Coastguard Worker /* Information gathered from DT_DEBUG by dwfl_link_map_report hinted to
692*7304104dSAndroid Build Coastguard Worker dwfl_segment_report_module. */
693*7304104dSAndroid Build Coastguard Worker struct r_debug_info
694*7304104dSAndroid Build Coastguard Worker {
695*7304104dSAndroid Build Coastguard Worker struct r_debug_info_module *module;
696*7304104dSAndroid Build Coastguard Worker };
697*7304104dSAndroid Build Coastguard Worker
698*7304104dSAndroid Build Coastguard Worker /* ...
699*7304104dSAndroid Build Coastguard Worker */
700*7304104dSAndroid Build Coastguard Worker extern int dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
701*7304104dSAndroid Build Coastguard Worker Dwfl_Memory_Callback *memory_callback,
702*7304104dSAndroid Build Coastguard Worker void *memory_callback_arg,
703*7304104dSAndroid Build Coastguard Worker Dwfl_Module_Callback *read_eagerly,
704*7304104dSAndroid Build Coastguard Worker void *read_eagerly_arg,
705*7304104dSAndroid Build Coastguard Worker size_t maxread,
706*7304104dSAndroid Build Coastguard Worker const void *note_file,
707*7304104dSAndroid Build Coastguard Worker size_t note_file_size,
708*7304104dSAndroid Build Coastguard Worker const struct r_debug_info *r_debug_info);
709*7304104dSAndroid Build Coastguard Worker
710*7304104dSAndroid Build Coastguard Worker /* Report a module for entry in the dynamic linker's struct link_map list.
711*7304104dSAndroid Build Coastguard Worker For each link_map entry, if an existing module resides at its address,
712*7304104dSAndroid Build Coastguard Worker this just modifies that module's name and suggested file name. If
713*7304104dSAndroid Build Coastguard Worker no such module exists, this calls dwfl_report_elf on the l_name string.
714*7304104dSAndroid Build Coastguard Worker
715*7304104dSAndroid Build Coastguard Worker If AUXV is not null, it points to AUXV_SIZE bytes of auxiliary vector
716*7304104dSAndroid Build Coastguard Worker data as contained in an NT_AUXV note or read from a /proc/pid/auxv
717*7304104dSAndroid Build Coastguard Worker file. When this is available, it guides the search. If AUXV is null
718*7304104dSAndroid Build Coastguard Worker or the memory it points to is not accessible, then this search can
719*7304104dSAndroid Build Coastguard Worker only find where to begin if the correct executable file was
720*7304104dSAndroid Build Coastguard Worker previously reported and preloaded as with dwfl_report_elf.
721*7304104dSAndroid Build Coastguard Worker
722*7304104dSAndroid Build Coastguard Worker Fill in R_DEBUG_INFO if it is not NULL. It should be cleared by the
723*7304104dSAndroid Build Coastguard Worker caller, this function does not touch fields it does not need to modify.
724*7304104dSAndroid Build Coastguard Worker If R_DEBUG_INFO is not NULL then no modules get added to DWFL, caller
725*7304104dSAndroid Build Coastguard Worker has to add them from filled in R_DEBUG_INFO.
726*7304104dSAndroid Build Coastguard Worker
727*7304104dSAndroid Build Coastguard Worker Returns the number of modules found, or -1 for errors. */
728*7304104dSAndroid Build Coastguard Worker extern int dwfl_link_map_report (Dwfl *dwfl, const void *auxv, size_t auxv_size,
729*7304104dSAndroid Build Coastguard Worker Dwfl_Memory_Callback *memory_callback,
730*7304104dSAndroid Build Coastguard Worker void *memory_callback_arg,
731*7304104dSAndroid Build Coastguard Worker struct r_debug_info *r_debug_info);
732*7304104dSAndroid Build Coastguard Worker
733*7304104dSAndroid Build Coastguard Worker
734*7304104dSAndroid Build Coastguard Worker /* Avoid PLT entries. */
735*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_begin)
736*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_errmsg)
737*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_errno)
738*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_addrmodule)
739*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_addrsegment)
740*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_addrdwarf)
741*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_addrdie)
742*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_core_file_attach)
743*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_core_file_report)
744*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_getmodules)
745*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_module_addrdie)
746*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_module_address_section)
747*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_module_addrinfo)
748*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_module_addrsym)
749*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_module_build_id)
750*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_module_getdwarf)
751*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_module_getelf)
752*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_module_getsym)
753*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_module_getsym_info)
754*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_module_getsymtab)
755*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_module_getsymtab_first_global)
756*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_module_getsrc)
757*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_module_report_build_id)
758*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_report_elf)
759*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_report_begin)
760*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_report_begin_add)
761*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_report_module)
762*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_report_segment)
763*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_report_offline)
764*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_report_offline_memory)
765*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_report_end)
766*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_build_id_find_elf)
767*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_build_id_find_debuginfo)
768*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_standard_find_debuginfo)
769*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_link_map_report)
770*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_linux_kernel_find_elf)
771*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_linux_kernel_module_section_address)
772*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_linux_proc_attach)
773*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_linux_proc_report)
774*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_linux_proc_maps_report)
775*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_linux_proc_find_elf)
776*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_linux_kernel_report_kernel)
777*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_linux_kernel_report_modules)
778*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_linux_kernel_report_offline)
779*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_offline_section_address)
780*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_module_relocate_address)
781*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_module_dwarf_cfi)
782*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_module_eh_cfi)
783*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_attach_state)
784*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_pid)
785*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_thread_dwfl)
786*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_thread_tid)
787*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_frame_thread)
788*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_thread_state_registers)
789*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_thread_state_register_pc)
790*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_getthread_frames)
791*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_getthreads)
792*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_thread_getframes)
793*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_frame_pc)
794*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_frame_reg)
795*7304104dSAndroid Build Coastguard Worker INTDECL (dwfl_get_debuginfod_client)
796*7304104dSAndroid Build Coastguard Worker
797*7304104dSAndroid Build Coastguard Worker /* Leading arguments standard to callbacks passed a Dwfl_Module. */
798*7304104dSAndroid Build Coastguard Worker #define MODCB_ARGS(mod) (mod), &(mod)->userdata, (mod)->name, (mod)->low_addr
799*7304104dSAndroid Build Coastguard Worker #define CBFAIL (errno ? DWFL_E (ERRNO, errno) : DWFL_E_CB);
800*7304104dSAndroid Build Coastguard Worker
801*7304104dSAndroid Build Coastguard Worker
802*7304104dSAndroid Build Coastguard Worker /* The default used by dwfl_standard_find_debuginfo. */
803*7304104dSAndroid Build Coastguard Worker #define DEFAULT_DEBUGINFO_PATH ":.debug:/usr/lib/debug"
804*7304104dSAndroid Build Coastguard Worker
805*7304104dSAndroid Build Coastguard Worker
806*7304104dSAndroid Build Coastguard Worker #endif /* libdwflP.h */
807