blob: 424c354e12dee227d873a4e9fde08b4b42f978d5 [file] [log] [blame]
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00001/* Interfaces for libdw.
Ulrich Drepper3be74472006-05-27 18:15:40 +00002 Copyright (C) 2002, 2004, 2005, 2006 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 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
5
Ulrich Drepper361df7d2006-04-04 21:38:57 +00006 Red Hat elfutils is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by the
8 Free Software Foundation; version 2 of the License.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00009
Ulrich Drepper361df7d2006-04-04 21:38:57 +000010 Red Hat elfutils is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with Red Hat elfutils; if not, write to the Free Software Foundation,
Ulrich Drepper1e9ef502006-04-04 22:29:06 +000017 Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
Ulrich Drepper361df7d2006-04-04 21:38:57 +000018
19 In addition, as a special exception, Red Hat, Inc. gives You the
20 additional right to link the code of Red Hat elfutils with code licensed
21 under any Open Source Initiative certified open source license
22 (http://www.opensource.org/licenses/index.php) which requires the
23 distribution of source code with any binary distribution and to
24 distribute linked combinations of the two. Non-GPL Code permitted under
25 this exception must only link to the code of Red Hat elfutils through
26 those well defined interfaces identified in the file named EXCEPTION
27 found in the source code files (the "Approved Interfaces"). The files
28 of Non-GPL Code may instantiate templates or use macros or inline
29 functions from the Approved Interfaces without causing the resulting
30 work to be covered by the GNU General Public License. Only Red Hat,
31 Inc. may make changes or additions to the list of Approved Interfaces.
32 Red Hat's grant of this exception is conditioned upon your not adding
33 any new exceptions. If you wish to add a new Approved Interface or
34 exception, please contact Red Hat. You must obey the GNU General Public
35 License in all respects for all of the Red Hat elfutils code and other
36 code used in conjunction with Red Hat elfutils except the Non-GPL Code
37 covered by this exception. If you modify this file, you may extend this
38 exception to your version of the file, but you are not obligated to do
39 so. If you do not wish to provide this exception without modification,
40 you must delete this exception statement from your version and license
41 this file solely under the GPL without exception.
42
43 Red Hat elfutils is an included package of the Open Invention Network.
44 An included package of the Open Invention Network is a package for which
45 Open Invention Network licensees cross-license their patents. No patent
46 license is granted, either expressly or impliedly, by designation as an
47 included package. Should you wish to participate in the Open Invention
48 Network licensing program, please visit www.openinventionnetwork.com
49 <http://www.openinventionnetwork.com>. */
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000050
51#ifndef _LIBDW_H
52#define _LIBDW_H 1
53
54#include <gelf.h>
55#include <stdbool.h>
56#include <stddef.h>
57
58
59#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
60# define __nonnull_attribute__(...) __attribute__ ((__nonnull__ (__VA_ARGS__)))
61#else
62# define __nonnull_attribute__(args...)
63#endif
64
65
66/* Mode for the session. */
67typedef enum
68 {
69 DWARF_C_READ, /* Read .. */
70 DWARF_C_RDWR, /* Read and write .. */
71 DWARF_C_WRITE, /* Write .. */
72 }
73Dwarf_Cmd;
74
75
76/* Callback results. */
77enum
78{
79 DWARF_CB_OK = 0,
80 DWARF_CB_ABORT
81};
82
83
84/* Error values. */
85enum
86 {
87 DW_TAG_invalid = 0
88#define DW_TAG_invalid DW_TAG_invalid
89 };
90
91
92/* Type for offset in DWARF file. */
93typedef GElf_Off Dwarf_Off;
94
95/* Type for address in DWARF file. */
96typedef GElf_Addr Dwarf_Addr;
97
98/* Integer types. Big enough to hold any numeric value. */
99typedef GElf_Xword Dwarf_Word;
100typedef GElf_Sxword Dwarf_Sword;
101/* For the times we know we do not need that much. */
102typedef GElf_Half Dwarf_Half;
103
104
105/* DWARF abbreviation record. */
106typedef struct Dwarf_Abbrev Dwarf_Abbrev;
107
108/* Returned to show the last DIE has be returned. */
109#define DWARF_END_ABBREV ((Dwarf_Abbrev *) -1l)
110
111/* Source code line information for CU. */
112typedef struct Dwarf_Lines_s Dwarf_Lines;
113
114/* One source code line information. */
115typedef struct Dwarf_Line_s Dwarf_Line;
116
117/* Source file information. */
118typedef struct Dwarf_Files_s Dwarf_Files;
119
120/* One address range record. */
121typedef struct Dwarf_Arange_s Dwarf_Arange;
122
123/* Address ranges of a file. */
124typedef struct Dwarf_Aranges_s Dwarf_Aranges;
125
126/* CU representation. */
127struct Dwarf_CU;
128
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000129/* Macro information. */
130typedef struct Dwarf_Macro_s Dwarf_Macro;
131
132/* Attribute representation. */
133typedef struct
134{
135 unsigned int code;
136 unsigned int form;
137 unsigned char *valp;
138 struct Dwarf_CU *cu;
139} Dwarf_Attribute;
140
141
142/* Data block representation. */
143typedef struct
144{
145 Dwarf_Word length;
146 unsigned char *data;
147} Dwarf_Block;
148
149
150/* DIE information. */
151typedef struct
152{
153 /* The offset can be computed from the address. */
154 void *addr;
155 struct Dwarf_CU *cu;
156 Dwarf_Abbrev *abbrev;
157 // XXX We'll see what other information will be needed.
158 long int padding__;
159} Dwarf_Die;
160
161/* Returned to show the last DIE has be returned. */
162#define DWARF_END_DIE ((Dwarf_Die *) -1l)
163
164
165/* Global symbol information. */
166typedef struct
167{
168 Dwarf_Off cu_offset;
169 Dwarf_Off die_offset;
170 const char *name;
171} Dwarf_Global;
172
173
Roland McGrath6724c902005-10-28 07:07:19 +0000174/* One operation in a DWARF location expression.
175 A location expression is an array of these. */
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000176typedef struct
177{
178 uint8_t atom; /* Operation */
179 Dwarf_Word number; /* Operand */
180 Dwarf_Word number2; /* Possible second operand */
181 Dwarf_Word offset; /* Offset in location expression */
Roland McGrath6724c902005-10-28 07:07:19 +0000182} Dwarf_Op;
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000183
184
185/* Handle for debug sessions. */
186typedef struct Dwarf Dwarf;
187
188
189/* Out-Of-Memory handler. */
190#if __GNUC__ < 4
191typedef void (*Dwarf_OOM) (void);
192#else
193typedef void (*__attribute__ ((noreturn)) Dwarf_OOM) (void);
194#endif
195
196
Ulrich Drepper3be74472006-05-27 18:15:40 +0000197#ifdef __cplusplus
198extern "C" {
199#endif
200
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000201/* Create a handle for a new debug session. */
202extern Dwarf *dwarf_begin (int fildes, Dwarf_Cmd cmd);
203
204/* Create a handle for a new debug session for an ELF file. */
205extern Dwarf *dwarf_begin_elf (Elf *elf, Dwarf_Cmd cmd, Elf_Scn *scngrp);
206
207/* Retrieve ELF descriptor used for DWARF access. */
208extern Elf *dwarf_getelf (Dwarf *dwarf);
209
210/* Release debugging handling context. */
211extern int dwarf_end (Dwarf *dwarf);
212
213
214/* Get the data block for the .debug_info section. */
215extern Elf_Data *dwarf_getscn_info (Dwarf *dwarf);
216
217/* Read the header for the DWARF CU header. */
218extern int dwarf_nextcu (Dwarf *dwarf, Dwarf_Off off, Dwarf_Off *next_off,
219 size_t *header_sizep, Dwarf_Off *abbrev_offsetp,
220 uint8_t *address_sizep, uint8_t *offset_sizep)
221 __nonnull_attribute__ (3);
222
223
224/* Return DIE at given offset. */
225extern Dwarf_Die *dwarf_offdie (Dwarf *dbg, Dwarf_Off offset,
226 Dwarf_Die *result) __nonnull_attribute__ (3);
227
228/* Return offset of DIE. */
229extern Dwarf_Off dwarf_dieoffset (Dwarf_Die *die);
230
231/* Return offset of DIE in CU. */
232extern Dwarf_Off dwarf_cuoffset (Dwarf_Die *die);
233
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000234/* Return CU DIE containing given DIE. */
235extern Dwarf_Die *dwarf_diecu (Dwarf_Die *die, Dwarf_Die *result,
236 uint8_t *address_sizep, uint8_t *offset_sizep);
237
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)
Ulrich Drepper4f3d2a22006-05-22 01:30:56 +0000244 __nonnull_attribute__ (1, 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
476
Roland McGrath6724c902005-10-28 07:07:19 +0000477/* Return location expression, decoded as a list of operations. */
478extern int dwarf_getlocation (Dwarf_Attribute *attr, Dwarf_Op **expr,
479 size_t *exprlen) __nonnull_attribute__ (2, 3);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000480
Roland McGrath6724c902005-10-28 07:07:19 +0000481/* Return location expressions. If the attribute uses a location list,
482 ADDRESS selects the relevant location expressions from the list.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000483 There can be multiple matches, resulting in multiple expressions to
Roland McGrath6724c902005-10-28 07:07:19 +0000484 return. EXPRS and EXPRLENS are parallel arrays of NLOCS slots to
485 fill in. Returns the number of locations filled in, or -1 for
486 errors. If EXPRS is a null pointer, stores nothing and returns the
487 total number of locations. A return value of zero means that the
488 location list indicated no value is accessible. */
489extern int dwarf_getlocation_addr (Dwarf_Attribute *attr, Dwarf_Addr address,
490 Dwarf_Op **exprs, size_t *exprlens,
491 size_t nlocs);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000492
493
494/* Return scope DIEs containing PC address.
495 Sets *SCOPES to a malloc'd array of Dwarf_Die structures,
496 and returns the number of elements in the array.
497 (*SCOPES)[0] is the DIE for the innermost scope containing PC,
498 (*SCOPES)[1] is the DIE for the scope containing that scope, and so on.
499 Returns -1 for errors or 0 if no scopes match PC. */
500extern int dwarf_getscopes (Dwarf_Die *cudie, Dwarf_Addr pc,
501 Dwarf_Die **scopes);
502
Roland McGrath71e15a02005-08-27 10:33:26 +0000503/* Return scope DIEs containing the given DIE.
504 Sets *SCOPES to a malloc'd array of Dwarf_Die structures,
505 and returns the number of elements in the array.
506 (*SCOPES)[0] is a copy of DIE.
507 (*SCOPES)[1] is the DIE for the scope containing that scope, and so on.
508 Returns -1 for errors or 0 if DIE is not found in any scope entry. */
509extern int dwarf_getscopes_die (Dwarf_Die *die, Dwarf_Die **scopes);
510
511
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000512/* Search SCOPES[0..NSCOPES-1] for a variable called NAME.
513 Ignore the first SKIP_SHADOWS scopes that match the name.
514 If MATCH_FILE is not null, accept only declaration in that source file;
515 if MATCH_LINENO or MATCH_LINECOL are also nonzero, accept only declaration
516 at that line and column.
517
518 If successful, fill in *RESULT with the DIE of the variable found,
519 and return N where SCOPES[N] is the scope defining the variable.
520 Return -1 for errors or -2 for no matching variable found. */
521extern int dwarf_getscopevar (Dwarf_Die *scopes, int nscopes,
522 const char *name, int skip_shadows,
523 const char *match_file,
524 int match_lineno, int match_linecol,
525 Dwarf_Die *result);
526
527
528
529/* Return list address ranges. */
530extern int dwarf_getaranges (Dwarf *dbg, Dwarf_Aranges **aranges,
531 size_t *naranges)
532 __nonnull_attribute__ (2);
533
534/* Return one of the address range entries. */
535extern Dwarf_Arange *dwarf_onearange (Dwarf_Aranges *aranges, size_t idx);
536
537/* Return information in address range record. */
538extern int dwarf_getarangeinfo (Dwarf_Arange *arange, Dwarf_Addr *addrp,
539 Dwarf_Word *lengthp, Dwarf_Off *offsetp);
540
541/* Get address range which includes given address. */
542extern Dwarf_Arange *dwarf_getarange_addr (Dwarf_Aranges *aranges,
543 Dwarf_Addr addr);
544
545
546
547/* Get functions in CUDIE. */
548extern ptrdiff_t dwarf_getfuncs (Dwarf_Die *cudie,
Roland McGrath6724c902005-10-28 07:07:19 +0000549 int (*callback) (Dwarf_Die *, void *),
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000550 void *arg, ptrdiff_t offset);
551
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000552
Roland McGrath6724c902005-10-28 07:07:19 +0000553/* Return file name containing definition of the given declaration. */
554extern const char *dwarf_decl_file (Dwarf_Die *decl);
555
556/* Get line number of beginning of given declaration. */
557extern int dwarf_decl_line (Dwarf_Die *decl, int *linep)
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000558 __nonnull_attribute__ (2);
559
Roland McGrath6724c902005-10-28 07:07:19 +0000560/* Get column number of beginning of given declaration. */
561extern int dwarf_decl_column (Dwarf_Die *decl, int *colp)
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000562 __nonnull_attribute__ (2);
563
Roland McGrath1ecb6062005-08-15 09:53:04 +0000564
565/* Return nonzero if given function is an abstract inline definition. */
Roland McGrath6724c902005-10-28 07:07:19 +0000566extern int dwarf_func_inline (Dwarf_Die *func);
Roland McGrath1ecb6062005-08-15 09:53:04 +0000567
568/* Find each concrete inlined instance of the abstract inline definition. */
Roland McGrath6724c902005-10-28 07:07:19 +0000569extern int dwarf_func_inline_instances (Dwarf_Die *func,
Roland McGrath1ecb6062005-08-15 09:53:04 +0000570 int (*callback) (Dwarf_Die *, void *),
571 void *arg);
572
573
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000574/* Find the appropriate PC location or locations for function entry
575 breakpoints for the given DW_TAG_subprogram DIE. Returns -1 for errors.
576 On success, returns the number of breakpoint locations (never zero)
577 and sets *BKPTS to a malloc'd vector of addresses. */
578extern int dwarf_entry_breakpoints (Dwarf_Die *die, Dwarf_Addr **bkpts);
579
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000580
581/* Call callback function for each of the macro information entry for
582 the CU. */
583extern ptrdiff_t dwarf_getmacros (Dwarf_Die *cudie,
584 int (*callback) (Dwarf_Macro *, void *),
585 void *arg, ptrdiff_t offset)
586 __nonnull_attribute__ (2);
587
588/* Return macro opcode. */
589extern int dwarf_macro_opcode (Dwarf_Macro *macro, unsigned int *opcodep)
590 __nonnull_attribute__ (2);
591
592/* Return first macro parameter. */
593extern int dwarf_macro_param1 (Dwarf_Macro *macro, Dwarf_Word *paramp)
594 __nonnull_attribute__ (2);
595
596/* Return second macro parameter. */
597extern int dwarf_macro_param2 (Dwarf_Macro *macro, Dwarf_Word *paramp,
598 const char **strp);
599
600
601/* Return error code of last failing function call. This value is kept
602 separately for each thread. */
603extern int dwarf_errno (void);
604
605/* Return error string for ERROR. If ERROR is zero, return error string
606 for most recent error or NULL is none occurred. If ERROR is -1 the
607 behaviour is similar to the last case except that not NULL but a legal
608 string is returned. */
609extern const char *dwarf_errmsg (int err);
610
611
612/* Register new Out-Of-Memory handler. The old handler is returned. */
613extern Dwarf_OOM dwarf_new_oom_handler (Dwarf *dbg, Dwarf_OOM handler);
614
615
616/* Inline optimizations. */
617#ifdef __OPTIMIZE__
618/* Return attribute code of given attribute. */
619extern inline unsigned int
620dwarf_whatattr (Dwarf_Attribute *attr)
621{
622 return attr == NULL ? 0 : attr->code;
623}
624
625/* Return attribute code of given attribute. */
626extern inline unsigned int
627dwarf_whatform (Dwarf_Attribute *attr)
628{
629 return attr == NULL ? 0 : attr->form;
630}
631#endif /* Optimize. */
632
Ulrich Drepper3be74472006-05-27 18:15:40 +0000633#ifdef __cplusplus
634}
635#endif
636
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000637#endif /* libdw.h */