blob: 968e73a2d9d9493bf461573af279e6f791803928 [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
64
65/* Mode for the session. */
66typedef enum
67 {
68 DWARF_C_READ, /* Read .. */
69 DWARF_C_RDWR, /* Read and write .. */
70 DWARF_C_WRITE, /* Write .. */
71 }
72Dwarf_Cmd;
73
74
75/* Callback results. */
76enum
77{
78 DWARF_CB_OK = 0,
79 DWARF_CB_ABORT
80};
81
82
83/* Error values. */
84enum
85 {
86 DW_TAG_invalid = 0
87#define DW_TAG_invalid DW_TAG_invalid
88 };
89
90
91/* Type for offset in DWARF file. */
92typedef GElf_Off Dwarf_Off;
93
94/* Type for address in DWARF file. */
95typedef GElf_Addr Dwarf_Addr;
96
97/* Integer types. Big enough to hold any numeric value. */
98typedef GElf_Xword Dwarf_Word;
99typedef GElf_Sxword Dwarf_Sword;
100/* For the times we know we do not need that much. */
101typedef GElf_Half Dwarf_Half;
102
103
104/* DWARF abbreviation record. */
105typedef struct Dwarf_Abbrev Dwarf_Abbrev;
106
107/* Returned to show the last DIE has be returned. */
108#define DWARF_END_ABBREV ((Dwarf_Abbrev *) -1l)
109
110/* Source code line information for CU. */
111typedef struct Dwarf_Lines_s Dwarf_Lines;
112
113/* One source code line information. */
114typedef struct Dwarf_Line_s Dwarf_Line;
115
116/* Source file information. */
117typedef struct Dwarf_Files_s Dwarf_Files;
118
119/* One address range record. */
120typedef struct Dwarf_Arange_s Dwarf_Arange;
121
122/* Address ranges of a file. */
123typedef struct Dwarf_Aranges_s Dwarf_Aranges;
124
125/* CU representation. */
126struct Dwarf_CU;
127
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000128/* Macro information. */
129typedef struct Dwarf_Macro_s Dwarf_Macro;
130
131/* Attribute representation. */
132typedef struct
133{
134 unsigned int code;
135 unsigned int form;
136 unsigned char *valp;
137 struct Dwarf_CU *cu;
138} Dwarf_Attribute;
139
140
141/* Data block representation. */
142typedef struct
143{
144 Dwarf_Word length;
145 unsigned char *data;
146} Dwarf_Block;
147
148
149/* DIE information. */
150typedef struct
151{
152 /* The offset can be computed from the address. */
153 void *addr;
154 struct Dwarf_CU *cu;
155 Dwarf_Abbrev *abbrev;
156 // XXX We'll see what other information will be needed.
157 long int padding__;
158} Dwarf_Die;
159
160/* Returned to show the last DIE has be returned. */
161#define DWARF_END_DIE ((Dwarf_Die *) -1l)
162
163
164/* Global symbol information. */
165typedef struct
166{
167 Dwarf_Off cu_offset;
168 Dwarf_Off die_offset;
169 const char *name;
170} Dwarf_Global;
171
172
Roland McGrath6724c902005-10-28 07:07:19 +0000173/* One operation in a DWARF location expression.
174 A location expression is an array of these. */
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000175typedef struct
176{
177 uint8_t atom; /* Operation */
178 Dwarf_Word number; /* Operand */
179 Dwarf_Word number2; /* Possible second operand */
180 Dwarf_Word offset; /* Offset in location expression */
Roland McGrath6724c902005-10-28 07:07:19 +0000181} Dwarf_Op;
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000182
183
184/* Handle for debug sessions. */
185typedef struct Dwarf Dwarf;
186
187
188/* Out-Of-Memory handler. */
189#if __GNUC__ < 4
190typedef void (*Dwarf_OOM) (void);
191#else
192typedef void (*__attribute__ ((noreturn)) Dwarf_OOM) (void);
193#endif
194
195
Ulrich Drepper3be74472006-05-27 18:15:40 +0000196#ifdef __cplusplus
197extern "C" {
198#endif
199
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000200/* Create a handle for a new debug session. */
201extern Dwarf *dwarf_begin (int fildes, Dwarf_Cmd cmd);
202
203/* Create a handle for a new debug session for an ELF file. */
204extern Dwarf *dwarf_begin_elf (Elf *elf, Dwarf_Cmd cmd, Elf_Scn *scngrp);
205
206/* Retrieve ELF descriptor used for DWARF access. */
207extern Elf *dwarf_getelf (Dwarf *dwarf);
208
209/* Release debugging handling context. */
210extern int dwarf_end (Dwarf *dwarf);
211
212
213/* Get the data block for the .debug_info section. */
214extern Elf_Data *dwarf_getscn_info (Dwarf *dwarf);
215
216/* Read the header for the DWARF CU header. */
217extern int dwarf_nextcu (Dwarf *dwarf, Dwarf_Off off, Dwarf_Off *next_off,
218 size_t *header_sizep, Dwarf_Off *abbrev_offsetp,
219 uint8_t *address_sizep, uint8_t *offset_sizep)
220 __nonnull_attribute__ (3);
221
222
223/* Return DIE at given offset. */
224extern Dwarf_Die *dwarf_offdie (Dwarf *dbg, Dwarf_Off offset,
225 Dwarf_Die *result) __nonnull_attribute__ (3);
226
227/* Return offset of DIE. */
228extern Dwarf_Off dwarf_dieoffset (Dwarf_Die *die);
229
230/* Return offset of DIE in CU. */
231extern Dwarf_Off dwarf_cuoffset (Dwarf_Die *die);
232
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000233/* Return CU DIE containing given DIE. */
234extern Dwarf_Die *dwarf_diecu (Dwarf_Die *die, Dwarf_Die *result,
Roland McGrathc373d852006-10-10 00:25:21 +0000235 uint8_t *address_sizep, uint8_t *offset_sizep)
236 __nonnull_attribute__ (2);
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000237
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000238/* Return CU DIE containing given address. */
239extern Dwarf_Die *dwarf_addrdie (Dwarf *dbg, Dwarf_Addr addr,
240 Dwarf_Die *result) __nonnull_attribute__ (3);
241
242/* Return child of current DIE. */
243extern int dwarf_child (Dwarf_Die *die, Dwarf_Die *result)
Roland McGrathc373d852006-10-10 00:25:21 +0000244 __nonnull_attribute__ (2);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000245
246/* Return sibling of given DIE. */
247extern int dwarf_siblingof (Dwarf_Die *die, Dwarf_Die *result)
248 __nonnull_attribute__ (2);
249
250/* Check whether the DIE has children. */
Ulrich Drepper4f3d2a22006-05-22 01:30:56 +0000251extern int dwarf_haschildren (Dwarf_Die *die) __nonnull_attribute__ (1);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000252
253/* Get attributes of the DIE. */
254extern ptrdiff_t dwarf_getattrs (Dwarf_Die *die,
255 int (*callback) (Dwarf_Attribute *, void *),
Ulrich Drepper4f3d2a22006-05-22 01:30:56 +0000256 void *arg, ptrdiff_t offset)
257 __nonnull_attribute__ (2);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000258
259/* Return tag of given DIE. */
Ulrich Drepper4f3d2a22006-05-22 01:30:56 +0000260extern int dwarf_tag (Dwarf_Die *die) __nonnull_attribute__ (1);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000261
262
263/* Return specific attribute of DIE. */
264extern Dwarf_Attribute *dwarf_attr (Dwarf_Die *die, unsigned int search_name,
265 Dwarf_Attribute *result)
266 __nonnull_attribute__ (3);
267
268/* Check whether given DIE has specific attribute. */
269extern int dwarf_hasattr (Dwarf_Die *die, unsigned int search_name);
270
271/* These are the same as dwarf_attr and dwarf_hasattr, respectively,
272 but they resolve an indirect attribute through DW_AT_abstract_origin. */
273extern Dwarf_Attribute *dwarf_attr_integrate (Dwarf_Die *die,
274 unsigned int search_name,
275 Dwarf_Attribute *result)
276 __nonnull_attribute__ (3);
277extern int dwarf_hasattr_integrate (Dwarf_Die *die, unsigned int search_name);
278
279
280
281
282/* Check whether given attribute has specific form. */
283extern int dwarf_hasform (Dwarf_Attribute *attr, unsigned int search_form);
284
285/* Return attribute code of given attribute. */
286extern unsigned int dwarf_whatattr (Dwarf_Attribute *attr);
287
288/* Return form code of given attribute. */
289extern unsigned int dwarf_whatform (Dwarf_Attribute *attr);
290
291
292/* Return string associated with given attribute. */
293extern const char *dwarf_formstring (Dwarf_Attribute *attrp);
294
295/* Return unsigned constant represented by attribute. */
296extern int dwarf_formudata (Dwarf_Attribute *attr, Dwarf_Word *return_uval)
297 __nonnull_attribute__ (2);
298
299/* Return signed constant represented by attribute. */
300extern int dwarf_formsdata (Dwarf_Attribute *attr, Dwarf_Sword *return_uval)
301 __nonnull_attribute__ (2);
302
303/* Return address represented by attribute. */
304extern int dwarf_formaddr (Dwarf_Attribute *attr, Dwarf_Addr *return_addr)
305 __nonnull_attribute__ (2);
306
307/* Return reference offset represented by attribute. */
308extern int dwarf_formref (Dwarf_Attribute *attr, Dwarf_Off *return_offset)
309 __nonnull_attribute__ (2);
310
311/* Look up the DIE in a reference-form attribute. */
312extern Dwarf_Die *dwarf_formref_die (Dwarf_Attribute *attr, Dwarf_Die *die_mem)
313 __nonnull_attribute__ (2);
314
315/* Return block represented by attribute. */
316extern int dwarf_formblock (Dwarf_Attribute *attr, Dwarf_Block *return_block)
317 __nonnull_attribute__ (2);
318
319/* Return flag represented by attribute. */
320extern int dwarf_formflag (Dwarf_Attribute *attr, bool *return_bool)
321 __nonnull_attribute__ (2);
322
323
324/* Simplified attribute value access functions. */
325
326/* Return string in name attribute of DIE. */
327extern const char *dwarf_diename (Dwarf_Die *die);
328
329/* Return high PC attribute of DIE. */
330extern int dwarf_highpc (Dwarf_Die *die, Dwarf_Addr *return_addr)
331 __nonnull_attribute__ (2);
332
333/* Return low PC attribute of DIE. */
334extern int dwarf_lowpc (Dwarf_Die *die, Dwarf_Addr *return_addr)
335 __nonnull_attribute__ (2);
336
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000337/* Return entry_pc or low_pc attribute of DIE. */
338extern int dwarf_entrypc (Dwarf_Die *die, Dwarf_Addr *return_addr)
339 __nonnull_attribute__ (2);
340
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000341/* Return 1 if DIE's lowpc/highpc or ranges attributes match the PC address,
342 0 if not, or -1 for errors. */
343extern int dwarf_haspc (Dwarf_Die *die, Dwarf_Addr pc);
344
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000345/* Enumerate the PC address ranges covered by this DIE, covering all
346 addresses where dwarf_haspc returns true. In the first call OFFSET
347 should be zero and *BASEP need not be initialized. Returns -1 for
348 errors, zero when there are no more address ranges to report, or a
349 nonzero OFFSET value to pass to the next call. Each subsequent call
350 must preserve *BASEP from the prior call. Successful calls fill in
351 *STARTP and *ENDP with a contiguous address range. */
352extern ptrdiff_t dwarf_ranges (Dwarf_Die *die,
353 ptrdiff_t offset, Dwarf_Addr *basep,
354 Dwarf_Addr *startp, Dwarf_Addr *endp);
355
356
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000357/* Return byte size attribute of DIE. */
358extern int dwarf_bytesize (Dwarf_Die *die);
359
360/* Return bit size attribute of DIE. */
361extern int dwarf_bitsize (Dwarf_Die *die);
362
363/* Return bit offset attribute of DIE. */
364extern int dwarf_bitoffset (Dwarf_Die *die);
365
366/* Return array order attribute of DIE. */
367extern int dwarf_arrayorder (Dwarf_Die *die);
368
369/* Return source language attribute of DIE. */
370extern int dwarf_srclang (Dwarf_Die *die);
371
372
373/* Get abbreviation at given offset for given DIE. */
374extern Dwarf_Abbrev *dwarf_getabbrev (Dwarf_Die *die, Dwarf_Off offset,
375 size_t *lengthp);
376
377/* Get abbreviation at given offset in .debug_abbrev section. */
378extern int dwarf_offabbrev (Dwarf *dbg, Dwarf_Off offset, size_t *lengthp,
379 Dwarf_Abbrev *abbrevp)
380 __nonnull_attribute__ (4);
381
382/* Get abbreviation code. */
383extern unsigned int dwarf_getabbrevcode (Dwarf_Abbrev *abbrev);
384
385/* Get abbreviation tag. */
386extern unsigned int dwarf_getabbrevtag (Dwarf_Abbrev *abbrev);
387
388/* Return true if abbreviation is children flag set. */
389extern int dwarf_abbrevhaschildren (Dwarf_Abbrev *abbrev);
390
391/* Get number of attributes of abbreviation. */
392extern int dwarf_getattrcnt (Dwarf_Abbrev *abbrev, size_t *attrcntp)
393 __nonnull_attribute__ (2);
394
395/* Get specific attribute of abbreviation. */
396extern int dwarf_getabbrevattr (Dwarf_Abbrev *abbrev, size_t idx,
397 unsigned int *namep, unsigned int *formp,
398 Dwarf_Off *offset);
399
400
401/* Get string from-debug_str section. */
402extern const char *dwarf_getstring (Dwarf *dbg, Dwarf_Off offset,
403 size_t *lenp);
404
405
406/* Get public symbol information. */
407extern ptrdiff_t dwarf_getpubnames (Dwarf *dbg,
408 int (*callback) (Dwarf *, Dwarf_Global *,
409 void *),
410 void *arg, ptrdiff_t offset)
411 __nonnull_attribute__ (2);
412
413
414/* Get source file information for CU. */
415extern int dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines,
416 size_t *nlines) __nonnull_attribute__ (2, 3);
417
418/* Return one of the source lines of the CU. */
419extern Dwarf_Line *dwarf_onesrcline (Dwarf_Lines *lines, size_t idx);
420
421/* Get the file source files used in the CU. */
422extern int dwarf_getsrcfiles (Dwarf_Die *cudie, Dwarf_Files **files,
423 size_t *nfiles)
424 __nonnull_attribute__ (2);
425
426
427/* Get source for address in CU. */
428extern Dwarf_Line *dwarf_getsrc_die (Dwarf_Die *cudie, Dwarf_Addr addr);
429
430/* Get source for file and line number. */
431extern int dwarf_getsrc_file (Dwarf *dbg, const char *fname, int line, int col,
432 Dwarf_Line ***srcsp, size_t *nsrcs)
433 __nonnull_attribute__ (2, 5, 6);
434
435
436/* Return line address. */
437extern int dwarf_lineaddr (Dwarf_Line *line, Dwarf_Addr *addrp);
438
439/* Return line number. */
440extern int dwarf_lineno (Dwarf_Line *line, int *linep)
441 __nonnull_attribute__ (2);
442
443/* Return column in line. */
444extern int dwarf_linecol (Dwarf_Line *line, int *colp)
445 __nonnull_attribute__ (2);
446
447/* Return true if record is for beginning of a statement. */
448extern int dwarf_linebeginstatement (Dwarf_Line *line, bool *flagp)
449 __nonnull_attribute__ (2);
450
451/* Return true if record is for end of sequence. */
452extern int dwarf_lineendsequence (Dwarf_Line *line, bool *flagp)
453 __nonnull_attribute__ (2);
454
455/* Return true if record is for beginning of a basic block. */
456extern int dwarf_lineblock (Dwarf_Line *line, bool *flagp)
457 __nonnull_attribute__ (2);
458
459/* Return true if record is for end of prologue. */
460extern int dwarf_lineprologueend (Dwarf_Line *line, bool *flagp)
461 __nonnull_attribute__ (2);
462
463/* Return true if record is for beginning of epilogue. */
464extern int dwarf_lineepiloguebegin (Dwarf_Line *line, bool *flagp)
465 __nonnull_attribute__ (2);
466
467
468/* Find line information for address. */
469extern const char *dwarf_linesrc (Dwarf_Line *line,
470 Dwarf_Word *mtime, Dwarf_Word *length);
471
472/* Return file information. */
473extern const char *dwarf_filesrc (Dwarf_Files *file, size_t idx,
474 Dwarf_Word *mtime, Dwarf_Word *length);
475
Roland McGrath43da9892007-04-16 23:13:37 +0000476/* Return the directory list used in the file information extracted.
477 (*RESULT)[0] is the CU's DW_AT_comp_dir value, and may be null.
478 (*RESULT)[0..*NDIRS-1] are the compile-time include directory path
479 encoded by the compiler. */
480extern int dwarf_getsrcdirs (Dwarf_Files *files,
481 const char *const **result, size_t *ndirs)
482 __nonnull_attribute__ (2, 3);
483
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000484
Roland McGrath6724c902005-10-28 07:07:19 +0000485/* Return location expression, decoded as a list of operations. */
486extern int dwarf_getlocation (Dwarf_Attribute *attr, Dwarf_Op **expr,
487 size_t *exprlen) __nonnull_attribute__ (2, 3);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000488
Roland McGrath6724c902005-10-28 07:07:19 +0000489/* Return location expressions. If the attribute uses a location list,
490 ADDRESS selects the relevant location expressions from the list.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000491 There can be multiple matches, resulting in multiple expressions to
Roland McGrath6724c902005-10-28 07:07:19 +0000492 return. EXPRS and EXPRLENS are parallel arrays of NLOCS slots to
493 fill in. Returns the number of locations filled in, or -1 for
494 errors. If EXPRS is a null pointer, stores nothing and returns the
495 total number of locations. A return value of zero means that the
496 location list indicated no value is accessible. */
497extern int dwarf_getlocation_addr (Dwarf_Attribute *attr, Dwarf_Addr address,
498 Dwarf_Op **exprs, size_t *exprlens,
499 size_t nlocs);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000500
501
502/* Return scope DIEs containing PC address.
503 Sets *SCOPES to a malloc'd array of Dwarf_Die structures,
504 and returns the number of elements in the array.
505 (*SCOPES)[0] is the DIE for the innermost scope containing PC,
506 (*SCOPES)[1] is the DIE for the scope containing that scope, and so on.
507 Returns -1 for errors or 0 if no scopes match PC. */
508extern int dwarf_getscopes (Dwarf_Die *cudie, Dwarf_Addr pc,
509 Dwarf_Die **scopes);
510
Roland McGrath71e15a02005-08-27 10:33:26 +0000511/* Return scope DIEs containing the given DIE.
512 Sets *SCOPES to a malloc'd array of Dwarf_Die structures,
513 and returns the number of elements in the array.
514 (*SCOPES)[0] is a copy of DIE.
515 (*SCOPES)[1] is the DIE for the scope containing that scope, and so on.
516 Returns -1 for errors or 0 if DIE is not found in any scope entry. */
517extern int dwarf_getscopes_die (Dwarf_Die *die, Dwarf_Die **scopes);
518
519
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000520/* Search SCOPES[0..NSCOPES-1] for a variable called NAME.
521 Ignore the first SKIP_SHADOWS scopes that match the name.
522 If MATCH_FILE is not null, accept only declaration in that source file;
523 if MATCH_LINENO or MATCH_LINECOL are also nonzero, accept only declaration
524 at that line and column.
525
526 If successful, fill in *RESULT with the DIE of the variable found,
527 and return N where SCOPES[N] is the scope defining the variable.
528 Return -1 for errors or -2 for no matching variable found. */
529extern int dwarf_getscopevar (Dwarf_Die *scopes, int nscopes,
530 const char *name, int skip_shadows,
531 const char *match_file,
532 int match_lineno, int match_linecol,
533 Dwarf_Die *result);
534
535
536
537/* Return list address ranges. */
538extern int dwarf_getaranges (Dwarf *dbg, Dwarf_Aranges **aranges,
539 size_t *naranges)
540 __nonnull_attribute__ (2);
541
542/* Return one of the address range entries. */
543extern Dwarf_Arange *dwarf_onearange (Dwarf_Aranges *aranges, size_t idx);
544
545/* Return information in address range record. */
546extern int dwarf_getarangeinfo (Dwarf_Arange *arange, Dwarf_Addr *addrp,
547 Dwarf_Word *lengthp, Dwarf_Off *offsetp);
548
549/* Get address range which includes given address. */
550extern Dwarf_Arange *dwarf_getarange_addr (Dwarf_Aranges *aranges,
551 Dwarf_Addr addr);
552
553
554
555/* Get functions in CUDIE. */
556extern ptrdiff_t dwarf_getfuncs (Dwarf_Die *cudie,
Roland McGrath6724c902005-10-28 07:07:19 +0000557 int (*callback) (Dwarf_Die *, void *),
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000558 void *arg, ptrdiff_t offset);
559
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000560
Roland McGrath6724c902005-10-28 07:07:19 +0000561/* Return file name containing definition of the given declaration. */
562extern const char *dwarf_decl_file (Dwarf_Die *decl);
563
564/* Get line number of beginning of given declaration. */
565extern int dwarf_decl_line (Dwarf_Die *decl, int *linep)
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000566 __nonnull_attribute__ (2);
567
Roland McGrath6724c902005-10-28 07:07:19 +0000568/* Get column number of beginning of given declaration. */
569extern int dwarf_decl_column (Dwarf_Die *decl, int *colp)
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000570 __nonnull_attribute__ (2);
571
Roland McGrath1ecb6062005-08-15 09:53:04 +0000572
573/* Return nonzero if given function is an abstract inline definition. */
Roland McGrath6724c902005-10-28 07:07:19 +0000574extern int dwarf_func_inline (Dwarf_Die *func);
Roland McGrath1ecb6062005-08-15 09:53:04 +0000575
576/* Find each concrete inlined instance of the abstract inline definition. */
Roland McGrath6724c902005-10-28 07:07:19 +0000577extern int dwarf_func_inline_instances (Dwarf_Die *func,
Roland McGrath1ecb6062005-08-15 09:53:04 +0000578 int (*callback) (Dwarf_Die *, void *),
579 void *arg);
580
581
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000582/* Find the appropriate PC location or locations for function entry
583 breakpoints for the given DW_TAG_subprogram DIE. Returns -1 for errors.
584 On success, returns the number of breakpoint locations (never zero)
585 and sets *BKPTS to a malloc'd vector of addresses. */
586extern int dwarf_entry_breakpoints (Dwarf_Die *die, Dwarf_Addr **bkpts);
587
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000588
589/* Call callback function for each of the macro information entry for
590 the CU. */
591extern ptrdiff_t dwarf_getmacros (Dwarf_Die *cudie,
592 int (*callback) (Dwarf_Macro *, void *),
593 void *arg, ptrdiff_t offset)
594 __nonnull_attribute__ (2);
595
596/* Return macro opcode. */
597extern int dwarf_macro_opcode (Dwarf_Macro *macro, unsigned int *opcodep)
598 __nonnull_attribute__ (2);
599
600/* Return first macro parameter. */
601extern int dwarf_macro_param1 (Dwarf_Macro *macro, Dwarf_Word *paramp)
602 __nonnull_attribute__ (2);
603
604/* Return second macro parameter. */
605extern int dwarf_macro_param2 (Dwarf_Macro *macro, Dwarf_Word *paramp,
606 const char **strp);
607
608
609/* Return error code of last failing function call. This value is kept
610 separately for each thread. */
611extern int dwarf_errno (void);
612
613/* Return error string for ERROR. If ERROR is zero, return error string
614 for most recent error or NULL is none occurred. If ERROR is -1 the
615 behaviour is similar to the last case except that not NULL but a legal
616 string is returned. */
617extern const char *dwarf_errmsg (int err);
618
619
620/* Register new Out-Of-Memory handler. The old handler is returned. */
621extern Dwarf_OOM dwarf_new_oom_handler (Dwarf *dbg, Dwarf_OOM handler);
622
623
624/* Inline optimizations. */
625#ifdef __OPTIMIZE__
626/* Return attribute code of given attribute. */
627extern inline unsigned int
628dwarf_whatattr (Dwarf_Attribute *attr)
629{
630 return attr == NULL ? 0 : attr->code;
631}
632
633/* Return attribute code of given attribute. */
634extern inline unsigned int
635dwarf_whatform (Dwarf_Attribute *attr)
636{
637 return attr == NULL ? 0 : attr->form;
638}
639#endif /* Optimize. */
640
Ulrich Drepper3be74472006-05-27 18:15:40 +0000641#ifdef __cplusplus
642}
643#endif
644
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000645#endif /* libdw.h */