blob: 5385312752f5c18298fb011032c52a6118112167 [file] [log] [blame]
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00001/* Interfaces for libdw.
Roland McGrath43da9892007-04-16 23:13:37 +00002 Copyright (C) 2002, 2004, 2005, 2006, 2007 Red Hat, Inc.
Ulrich Drepper361df7d2006-04-04 21:38:57 +00003 This file is part of Red Hat elfutils.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00004
Ulrich Drepper361df7d2006-04-04 21:38:57 +00005 Red Hat elfutils is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by the
7 Free Software Foundation; version 2 of the License.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00008
Ulrich Drepper361df7d2006-04-04 21:38:57 +00009 Red Hat elfutils is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with Red Hat elfutils; if not, write to the Free Software Foundation,
Ulrich Drepper1e9ef502006-04-04 22:29:06 +000016 Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
Ulrich Drepper361df7d2006-04-04 21:38:57 +000017
18 In addition, as a special exception, Red Hat, Inc. gives You the
19 additional right to link the code of Red Hat elfutils with code licensed
20 under any Open Source Initiative certified open source license
21 (http://www.opensource.org/licenses/index.php) which requires the
22 distribution of source code with any binary distribution and to
23 distribute linked combinations of the two. Non-GPL Code permitted under
24 this exception must only link to the code of Red Hat elfutils through
25 those well defined interfaces identified in the file named EXCEPTION
26 found in the source code files (the "Approved Interfaces"). The files
27 of Non-GPL Code may instantiate templates or use macros or inline
28 functions from the Approved Interfaces without causing the resulting
29 work to be covered by the GNU General Public License. Only Red Hat,
30 Inc. may make changes or additions to the list of Approved Interfaces.
31 Red Hat's grant of this exception is conditioned upon your not adding
32 any new exceptions. If you wish to add a new Approved Interface or
33 exception, please contact Red Hat. You must obey the GNU General Public
34 License in all respects for all of the Red Hat elfutils code and other
35 code used in conjunction with Red Hat elfutils except the Non-GPL Code
36 covered by this exception. If you modify this file, you may extend this
37 exception to your version of the file, but you are not obligated to do
38 so. If you do not wish to provide this exception without modification,
39 you must delete this exception statement from your version and license
40 this file solely under the GPL without exception.
41
42 Red Hat elfutils is an included package of the Open Invention Network.
43 An included package of the Open Invention Network is a package for which
44 Open Invention Network licensees cross-license their patents. No patent
45 license is granted, either expressly or impliedly, by designation as an
46 included package. Should you wish to participate in the Open Invention
47 Network licensing program, please visit www.openinventionnetwork.com
48 <http://www.openinventionnetwork.com>. */
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000049
50#ifndef _LIBDW_H
51#define _LIBDW_H 1
52
53#include <gelf.h>
54#include <stdbool.h>
55#include <stddef.h>
56
57
58#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
59# define __nonnull_attribute__(...) __attribute__ ((__nonnull__ (__VA_ARGS__)))
60#else
61# define __nonnull_attribute__(args...)
62#endif
63
Roland McGrath87d47802007-07-16 22:23:37 +000064#ifdef __GNUC_STDC_INLINE__
65# define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
66#else
67# define __extern_inline extern __inline
68#endif
69
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000070
71/* Mode for the session. */
72typedef enum
73 {
74 DWARF_C_READ, /* Read .. */
75 DWARF_C_RDWR, /* Read and write .. */
76 DWARF_C_WRITE, /* Write .. */
77 }
78Dwarf_Cmd;
79
80
81/* Callback results. */
82enum
83{
84 DWARF_CB_OK = 0,
85 DWARF_CB_ABORT
86};
87
88
89/* Error values. */
90enum
91 {
92 DW_TAG_invalid = 0
93#define DW_TAG_invalid DW_TAG_invalid
94 };
95
96
97/* Type for offset in DWARF file. */
98typedef GElf_Off Dwarf_Off;
99
100/* Type for address in DWARF file. */
101typedef GElf_Addr Dwarf_Addr;
102
103/* Integer types. Big enough to hold any numeric value. */
104typedef GElf_Xword Dwarf_Word;
105typedef GElf_Sxword Dwarf_Sword;
106/* For the times we know we do not need that much. */
107typedef GElf_Half Dwarf_Half;
108
109
110/* DWARF abbreviation record. */
111typedef struct Dwarf_Abbrev Dwarf_Abbrev;
112
113/* Returned to show the last DIE has be returned. */
114#define DWARF_END_ABBREV ((Dwarf_Abbrev *) -1l)
115
116/* Source code line information for CU. */
117typedef struct Dwarf_Lines_s Dwarf_Lines;
118
119/* One source code line information. */
120typedef struct Dwarf_Line_s Dwarf_Line;
121
122/* Source file information. */
123typedef struct Dwarf_Files_s Dwarf_Files;
124
125/* One address range record. */
126typedef struct Dwarf_Arange_s Dwarf_Arange;
127
128/* Address ranges of a file. */
129typedef struct Dwarf_Aranges_s Dwarf_Aranges;
130
131/* CU representation. */
132struct Dwarf_CU;
133
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000134/* Macro information. */
135typedef struct Dwarf_Macro_s Dwarf_Macro;
136
137/* Attribute representation. */
138typedef struct
139{
140 unsigned int code;
141 unsigned int form;
142 unsigned char *valp;
143 struct Dwarf_CU *cu;
144} Dwarf_Attribute;
145
146
147/* Data block representation. */
148typedef struct
149{
150 Dwarf_Word length;
151 unsigned char *data;
152} Dwarf_Block;
153
154
155/* DIE information. */
156typedef struct
157{
158 /* The offset can be computed from the address. */
159 void *addr;
160 struct Dwarf_CU *cu;
161 Dwarf_Abbrev *abbrev;
162 // XXX We'll see what other information will be needed.
163 long int padding__;
164} Dwarf_Die;
165
166/* Returned to show the last DIE has be returned. */
167#define DWARF_END_DIE ((Dwarf_Die *) -1l)
168
169
170/* Global symbol information. */
171typedef struct
172{
173 Dwarf_Off cu_offset;
174 Dwarf_Off die_offset;
175 const char *name;
176} Dwarf_Global;
177
178
Roland McGrath6724c902005-10-28 07:07:19 +0000179/* One operation in a DWARF location expression.
180 A location expression is an array of these. */
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000181typedef struct
182{
183 uint8_t atom; /* Operation */
184 Dwarf_Word number; /* Operand */
185 Dwarf_Word number2; /* Possible second operand */
186 Dwarf_Word offset; /* Offset in location expression */
Roland McGrath6724c902005-10-28 07:07:19 +0000187} Dwarf_Op;
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000188
189
190/* Handle for debug sessions. */
191typedef struct Dwarf Dwarf;
192
193
194/* Out-Of-Memory handler. */
195#if __GNUC__ < 4
196typedef void (*Dwarf_OOM) (void);
197#else
198typedef void (*__attribute__ ((noreturn)) Dwarf_OOM) (void);
199#endif
200
201
Ulrich Drepper3be74472006-05-27 18:15:40 +0000202#ifdef __cplusplus
203extern "C" {
204#endif
205
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000206/* Create a handle for a new debug session. */
207extern Dwarf *dwarf_begin (int fildes, Dwarf_Cmd cmd);
208
209/* Create a handle for a new debug session for an ELF file. */
210extern Dwarf *dwarf_begin_elf (Elf *elf, Dwarf_Cmd cmd, Elf_Scn *scngrp);
211
212/* Retrieve ELF descriptor used for DWARF access. */
213extern Elf *dwarf_getelf (Dwarf *dwarf);
214
215/* Release debugging handling context. */
216extern int dwarf_end (Dwarf *dwarf);
217
218
219/* Get the data block for the .debug_info section. */
220extern Elf_Data *dwarf_getscn_info (Dwarf *dwarf);
221
222/* Read the header for the DWARF CU header. */
223extern int dwarf_nextcu (Dwarf *dwarf, Dwarf_Off off, Dwarf_Off *next_off,
224 size_t *header_sizep, Dwarf_Off *abbrev_offsetp,
225 uint8_t *address_sizep, uint8_t *offset_sizep)
226 __nonnull_attribute__ (3);
227
228
229/* Return DIE at given offset. */
230extern Dwarf_Die *dwarf_offdie (Dwarf *dbg, Dwarf_Off offset,
231 Dwarf_Die *result) __nonnull_attribute__ (3);
232
233/* Return offset of DIE. */
234extern Dwarf_Off dwarf_dieoffset (Dwarf_Die *die);
235
236/* Return offset of DIE in CU. */
237extern Dwarf_Off dwarf_cuoffset (Dwarf_Die *die);
238
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000239/* Return CU DIE containing given DIE. */
240extern Dwarf_Die *dwarf_diecu (Dwarf_Die *die, Dwarf_Die *result,
Roland McGrathc373d852006-10-10 00:25:21 +0000241 uint8_t *address_sizep, uint8_t *offset_sizep)
242 __nonnull_attribute__ (2);
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000243
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000244/* Return CU DIE containing given address. */
245extern Dwarf_Die *dwarf_addrdie (Dwarf *dbg, Dwarf_Addr addr,
246 Dwarf_Die *result) __nonnull_attribute__ (3);
247
248/* Return child of current DIE. */
249extern int dwarf_child (Dwarf_Die *die, Dwarf_Die *result)
Roland McGrathc373d852006-10-10 00:25:21 +0000250 __nonnull_attribute__ (2);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000251
252/* Return sibling of given DIE. */
253extern int dwarf_siblingof (Dwarf_Die *die, Dwarf_Die *result)
254 __nonnull_attribute__ (2);
255
256/* Check whether the DIE has children. */
Ulrich Drepper4f3d2a22006-05-22 01:30:56 +0000257extern int dwarf_haschildren (Dwarf_Die *die) __nonnull_attribute__ (1);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000258
259/* Get attributes of the DIE. */
260extern ptrdiff_t dwarf_getattrs (Dwarf_Die *die,
261 int (*callback) (Dwarf_Attribute *, void *),
Ulrich Drepper4f3d2a22006-05-22 01:30:56 +0000262 void *arg, ptrdiff_t offset)
263 __nonnull_attribute__ (2);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000264
265/* Return tag of given DIE. */
Ulrich Drepper4f3d2a22006-05-22 01:30:56 +0000266extern int dwarf_tag (Dwarf_Die *die) __nonnull_attribute__ (1);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000267
268
269/* Return specific attribute of DIE. */
270extern Dwarf_Attribute *dwarf_attr (Dwarf_Die *die, unsigned int search_name,
271 Dwarf_Attribute *result)
272 __nonnull_attribute__ (3);
273
274/* Check whether given DIE has specific attribute. */
275extern int dwarf_hasattr (Dwarf_Die *die, unsigned int search_name);
276
277/* These are the same as dwarf_attr and dwarf_hasattr, respectively,
278 but they resolve an indirect attribute through DW_AT_abstract_origin. */
279extern Dwarf_Attribute *dwarf_attr_integrate (Dwarf_Die *die,
280 unsigned int search_name,
281 Dwarf_Attribute *result)
282 __nonnull_attribute__ (3);
283extern int dwarf_hasattr_integrate (Dwarf_Die *die, unsigned int search_name);
284
285
286
287
288/* Check whether given attribute has specific form. */
289extern int dwarf_hasform (Dwarf_Attribute *attr, unsigned int search_form);
290
291/* Return attribute code of given attribute. */
292extern unsigned int dwarf_whatattr (Dwarf_Attribute *attr);
293
294/* Return form code of given attribute. */
295extern unsigned int dwarf_whatform (Dwarf_Attribute *attr);
296
297
298/* Return string associated with given attribute. */
299extern const char *dwarf_formstring (Dwarf_Attribute *attrp);
300
301/* Return unsigned constant represented by attribute. */
302extern int dwarf_formudata (Dwarf_Attribute *attr, Dwarf_Word *return_uval)
303 __nonnull_attribute__ (2);
304
305/* Return signed constant represented by attribute. */
306extern int dwarf_formsdata (Dwarf_Attribute *attr, Dwarf_Sword *return_uval)
307 __nonnull_attribute__ (2);
308
309/* Return address represented by attribute. */
310extern int dwarf_formaddr (Dwarf_Attribute *attr, Dwarf_Addr *return_addr)
311 __nonnull_attribute__ (2);
312
313/* Return reference offset represented by attribute. */
314extern int dwarf_formref (Dwarf_Attribute *attr, Dwarf_Off *return_offset)
315 __nonnull_attribute__ (2);
316
317/* Look up the DIE in a reference-form attribute. */
318extern Dwarf_Die *dwarf_formref_die (Dwarf_Attribute *attr, Dwarf_Die *die_mem)
319 __nonnull_attribute__ (2);
320
321/* Return block represented by attribute. */
322extern int dwarf_formblock (Dwarf_Attribute *attr, Dwarf_Block *return_block)
323 __nonnull_attribute__ (2);
324
325/* Return flag represented by attribute. */
326extern int dwarf_formflag (Dwarf_Attribute *attr, bool *return_bool)
327 __nonnull_attribute__ (2);
328
329
330/* Simplified attribute value access functions. */
331
332/* Return string in name attribute of DIE. */
333extern const char *dwarf_diename (Dwarf_Die *die);
334
335/* Return high PC attribute of DIE. */
336extern int dwarf_highpc (Dwarf_Die *die, Dwarf_Addr *return_addr)
337 __nonnull_attribute__ (2);
338
339/* Return low PC attribute of DIE. */
340extern int dwarf_lowpc (Dwarf_Die *die, Dwarf_Addr *return_addr)
341 __nonnull_attribute__ (2);
342
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000343/* Return entry_pc or low_pc attribute of DIE. */
344extern int dwarf_entrypc (Dwarf_Die *die, Dwarf_Addr *return_addr)
345 __nonnull_attribute__ (2);
346
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000347/* Return 1 if DIE's lowpc/highpc or ranges attributes match the PC address,
348 0 if not, or -1 for errors. */
349extern int dwarf_haspc (Dwarf_Die *die, Dwarf_Addr pc);
350
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000351/* Enumerate the PC address ranges covered by this DIE, covering all
352 addresses where dwarf_haspc returns true. In the first call OFFSET
353 should be zero and *BASEP need not be initialized. Returns -1 for
354 errors, zero when there are no more address ranges to report, or a
355 nonzero OFFSET value to pass to the next call. Each subsequent call
356 must preserve *BASEP from the prior call. Successful calls fill in
357 *STARTP and *ENDP with a contiguous address range. */
358extern ptrdiff_t dwarf_ranges (Dwarf_Die *die,
359 ptrdiff_t offset, Dwarf_Addr *basep,
360 Dwarf_Addr *startp, Dwarf_Addr *endp);
361
362
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000363/* Return byte size attribute of DIE. */
364extern int dwarf_bytesize (Dwarf_Die *die);
365
366/* Return bit size attribute of DIE. */
367extern int dwarf_bitsize (Dwarf_Die *die);
368
369/* Return bit offset attribute of DIE. */
370extern int dwarf_bitoffset (Dwarf_Die *die);
371
372/* Return array order attribute of DIE. */
373extern int dwarf_arrayorder (Dwarf_Die *die);
374
375/* Return source language attribute of DIE. */
376extern int dwarf_srclang (Dwarf_Die *die);
377
378
379/* Get abbreviation at given offset for given DIE. */
380extern Dwarf_Abbrev *dwarf_getabbrev (Dwarf_Die *die, Dwarf_Off offset,
381 size_t *lengthp);
382
383/* Get abbreviation at given offset in .debug_abbrev section. */
384extern int dwarf_offabbrev (Dwarf *dbg, Dwarf_Off offset, size_t *lengthp,
385 Dwarf_Abbrev *abbrevp)
386 __nonnull_attribute__ (4);
387
388/* Get abbreviation code. */
389extern unsigned int dwarf_getabbrevcode (Dwarf_Abbrev *abbrev);
390
391/* Get abbreviation tag. */
392extern unsigned int dwarf_getabbrevtag (Dwarf_Abbrev *abbrev);
393
394/* Return true if abbreviation is children flag set. */
395extern int dwarf_abbrevhaschildren (Dwarf_Abbrev *abbrev);
396
397/* Get number of attributes of abbreviation. */
398extern int dwarf_getattrcnt (Dwarf_Abbrev *abbrev, size_t *attrcntp)
399 __nonnull_attribute__ (2);
400
401/* Get specific attribute of abbreviation. */
402extern int dwarf_getabbrevattr (Dwarf_Abbrev *abbrev, size_t idx,
403 unsigned int *namep, unsigned int *formp,
404 Dwarf_Off *offset);
405
406
407/* Get string from-debug_str section. */
408extern const char *dwarf_getstring (Dwarf *dbg, Dwarf_Off offset,
409 size_t *lenp);
410
411
412/* Get public symbol information. */
413extern ptrdiff_t dwarf_getpubnames (Dwarf *dbg,
414 int (*callback) (Dwarf *, Dwarf_Global *,
415 void *),
416 void *arg, ptrdiff_t offset)
417 __nonnull_attribute__ (2);
418
419
420/* Get source file information for CU. */
421extern int dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines,
422 size_t *nlines) __nonnull_attribute__ (2, 3);
423
424/* Return one of the source lines of the CU. */
425extern Dwarf_Line *dwarf_onesrcline (Dwarf_Lines *lines, size_t idx);
426
427/* Get the file source files used in the CU. */
428extern int dwarf_getsrcfiles (Dwarf_Die *cudie, Dwarf_Files **files,
429 size_t *nfiles)
430 __nonnull_attribute__ (2);
431
432
433/* Get source for address in CU. */
434extern Dwarf_Line *dwarf_getsrc_die (Dwarf_Die *cudie, Dwarf_Addr addr);
435
436/* Get source for file and line number. */
437extern int dwarf_getsrc_file (Dwarf *dbg, const char *fname, int line, int col,
438 Dwarf_Line ***srcsp, size_t *nsrcs)
439 __nonnull_attribute__ (2, 5, 6);
440
441
442/* Return line address. */
443extern int dwarf_lineaddr (Dwarf_Line *line, Dwarf_Addr *addrp);
444
445/* Return line number. */
446extern int dwarf_lineno (Dwarf_Line *line, int *linep)
447 __nonnull_attribute__ (2);
448
449/* Return column in line. */
450extern int dwarf_linecol (Dwarf_Line *line, int *colp)
451 __nonnull_attribute__ (2);
452
453/* Return true if record is for beginning of a statement. */
454extern int dwarf_linebeginstatement (Dwarf_Line *line, bool *flagp)
455 __nonnull_attribute__ (2);
456
457/* Return true if record is for end of sequence. */
458extern int dwarf_lineendsequence (Dwarf_Line *line, bool *flagp)
459 __nonnull_attribute__ (2);
460
461/* Return true if record is for beginning of a basic block. */
462extern int dwarf_lineblock (Dwarf_Line *line, bool *flagp)
463 __nonnull_attribute__ (2);
464
465/* Return true if record is for end of prologue. */
466extern int dwarf_lineprologueend (Dwarf_Line *line, bool *flagp)
467 __nonnull_attribute__ (2);
468
469/* Return true if record is for beginning of epilogue. */
470extern int dwarf_lineepiloguebegin (Dwarf_Line *line, bool *flagp)
471 __nonnull_attribute__ (2);
472
473
474/* Find line information for address. */
475extern const char *dwarf_linesrc (Dwarf_Line *line,
476 Dwarf_Word *mtime, Dwarf_Word *length);
477
478/* Return file information. */
479extern const char *dwarf_filesrc (Dwarf_Files *file, size_t idx,
480 Dwarf_Word *mtime, Dwarf_Word *length);
481
Roland McGrath43da9892007-04-16 23:13:37 +0000482/* Return the directory list used in the file information extracted.
483 (*RESULT)[0] is the CU's DW_AT_comp_dir value, and may be null.
484 (*RESULT)[0..*NDIRS-1] are the compile-time include directory path
485 encoded by the compiler. */
486extern int dwarf_getsrcdirs (Dwarf_Files *files,
487 const char *const **result, size_t *ndirs)
488 __nonnull_attribute__ (2, 3);
489
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000490
Roland McGrath6724c902005-10-28 07:07:19 +0000491/* Return location expression, decoded as a list of operations. */
492extern int dwarf_getlocation (Dwarf_Attribute *attr, Dwarf_Op **expr,
493 size_t *exprlen) __nonnull_attribute__ (2, 3);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000494
Roland McGrath6724c902005-10-28 07:07:19 +0000495/* Return location expressions. If the attribute uses a location list,
496 ADDRESS selects the relevant location expressions from the list.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000497 There can be multiple matches, resulting in multiple expressions to
Roland McGrath6724c902005-10-28 07:07:19 +0000498 return. EXPRS and EXPRLENS are parallel arrays of NLOCS slots to
499 fill in. Returns the number of locations filled in, or -1 for
500 errors. If EXPRS is a null pointer, stores nothing and returns the
501 total number of locations. A return value of zero means that the
502 location list indicated no value is accessible. */
503extern int dwarf_getlocation_addr (Dwarf_Attribute *attr, Dwarf_Addr address,
504 Dwarf_Op **exprs, size_t *exprlens,
505 size_t nlocs);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000506
507
508/* Return scope DIEs containing PC address.
509 Sets *SCOPES to a malloc'd array of Dwarf_Die structures,
510 and returns the number of elements in the array.
511 (*SCOPES)[0] is the DIE for the innermost scope containing PC,
512 (*SCOPES)[1] is the DIE for the scope containing that scope, and so on.
513 Returns -1 for errors or 0 if no scopes match PC. */
514extern int dwarf_getscopes (Dwarf_Die *cudie, Dwarf_Addr pc,
515 Dwarf_Die **scopes);
516
Roland McGrath71e15a02005-08-27 10:33:26 +0000517/* Return scope DIEs containing the given DIE.
518 Sets *SCOPES to a malloc'd array of Dwarf_Die structures,
519 and returns the number of elements in the array.
520 (*SCOPES)[0] is a copy of DIE.
521 (*SCOPES)[1] is the DIE for the scope containing that scope, and so on.
522 Returns -1 for errors or 0 if DIE is not found in any scope entry. */
523extern int dwarf_getscopes_die (Dwarf_Die *die, Dwarf_Die **scopes);
524
525
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000526/* Search SCOPES[0..NSCOPES-1] for a variable called NAME.
527 Ignore the first SKIP_SHADOWS scopes that match the name.
528 If MATCH_FILE is not null, accept only declaration in that source file;
529 if MATCH_LINENO or MATCH_LINECOL are also nonzero, accept only declaration
530 at that line and column.
531
532 If successful, fill in *RESULT with the DIE of the variable found,
533 and return N where SCOPES[N] is the scope defining the variable.
534 Return -1 for errors or -2 for no matching variable found. */
535extern int dwarf_getscopevar (Dwarf_Die *scopes, int nscopes,
536 const char *name, int skip_shadows,
537 const char *match_file,
538 int match_lineno, int match_linecol,
539 Dwarf_Die *result);
540
541
542
543/* Return list address ranges. */
544extern int dwarf_getaranges (Dwarf *dbg, Dwarf_Aranges **aranges,
545 size_t *naranges)
546 __nonnull_attribute__ (2);
547
548/* Return one of the address range entries. */
549extern Dwarf_Arange *dwarf_onearange (Dwarf_Aranges *aranges, size_t idx);
550
551/* Return information in address range record. */
552extern int dwarf_getarangeinfo (Dwarf_Arange *arange, Dwarf_Addr *addrp,
553 Dwarf_Word *lengthp, Dwarf_Off *offsetp);
554
555/* Get address range which includes given address. */
556extern Dwarf_Arange *dwarf_getarange_addr (Dwarf_Aranges *aranges,
557 Dwarf_Addr addr);
558
559
560
561/* Get functions in CUDIE. */
562extern ptrdiff_t dwarf_getfuncs (Dwarf_Die *cudie,
Roland McGrath6724c902005-10-28 07:07:19 +0000563 int (*callback) (Dwarf_Die *, void *),
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000564 void *arg, ptrdiff_t offset);
565
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000566
Roland McGrath6724c902005-10-28 07:07:19 +0000567/* Return file name containing definition of the given declaration. */
568extern const char *dwarf_decl_file (Dwarf_Die *decl);
569
570/* Get line number of beginning of given declaration. */
571extern int dwarf_decl_line (Dwarf_Die *decl, int *linep)
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000572 __nonnull_attribute__ (2);
573
Roland McGrath6724c902005-10-28 07:07:19 +0000574/* Get column number of beginning of given declaration. */
575extern int dwarf_decl_column (Dwarf_Die *decl, int *colp)
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000576 __nonnull_attribute__ (2);
577
Roland McGrath1ecb6062005-08-15 09:53:04 +0000578
579/* Return nonzero if given function is an abstract inline definition. */
Roland McGrath6724c902005-10-28 07:07:19 +0000580extern int dwarf_func_inline (Dwarf_Die *func);
Roland McGrath1ecb6062005-08-15 09:53:04 +0000581
582/* Find each concrete inlined instance of the abstract inline definition. */
Roland McGrath6724c902005-10-28 07:07:19 +0000583extern int dwarf_func_inline_instances (Dwarf_Die *func,
Roland McGrath1ecb6062005-08-15 09:53:04 +0000584 int (*callback) (Dwarf_Die *, void *),
585 void *arg);
586
587
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000588/* Find the appropriate PC location or locations for function entry
589 breakpoints for the given DW_TAG_subprogram DIE. Returns -1 for errors.
590 On success, returns the number of breakpoint locations (never zero)
591 and sets *BKPTS to a malloc'd vector of addresses. */
592extern int dwarf_entry_breakpoints (Dwarf_Die *die, Dwarf_Addr **bkpts);
593
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000594
595/* Call callback function for each of the macro information entry for
596 the CU. */
597extern ptrdiff_t dwarf_getmacros (Dwarf_Die *cudie,
598 int (*callback) (Dwarf_Macro *, void *),
599 void *arg, ptrdiff_t offset)
600 __nonnull_attribute__ (2);
601
602/* Return macro opcode. */
603extern int dwarf_macro_opcode (Dwarf_Macro *macro, unsigned int *opcodep)
604 __nonnull_attribute__ (2);
605
606/* Return first macro parameter. */
607extern int dwarf_macro_param1 (Dwarf_Macro *macro, Dwarf_Word *paramp)
608 __nonnull_attribute__ (2);
609
610/* Return second macro parameter. */
611extern int dwarf_macro_param2 (Dwarf_Macro *macro, Dwarf_Word *paramp,
612 const char **strp);
613
614
615/* Return error code of last failing function call. This value is kept
616 separately for each thread. */
617extern int dwarf_errno (void);
618
619/* Return error string for ERROR. If ERROR is zero, return error string
620 for most recent error or NULL is none occurred. If ERROR is -1 the
621 behaviour is similar to the last case except that not NULL but a legal
622 string is returned. */
623extern const char *dwarf_errmsg (int err);
624
625
626/* Register new Out-Of-Memory handler. The old handler is returned. */
627extern Dwarf_OOM dwarf_new_oom_handler (Dwarf *dbg, Dwarf_OOM handler);
628
629
630/* Inline optimizations. */
631#ifdef __OPTIMIZE__
632/* Return attribute code of given attribute. */
Roland McGrath87d47802007-07-16 22:23:37 +0000633__extern_inline unsigned int
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000634dwarf_whatattr (Dwarf_Attribute *attr)
635{
636 return attr == NULL ? 0 : attr->code;
637}
638
639/* Return attribute code of given attribute. */
Roland McGrath87d47802007-07-16 22:23:37 +0000640__extern_inline unsigned int
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000641dwarf_whatform (Dwarf_Attribute *attr)
642{
643 return attr == NULL ? 0 : attr->form;
644}
645#endif /* Optimize. */
646
Ulrich Drepper3be74472006-05-27 18:15:40 +0000647#ifdef __cplusplus
648}
649#endif
650
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000651#endif /* libdw.h */