blob: 351aef26ec6b868accbee7b6ef524d20631aac0f [file] [log] [blame]
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00001/* Interfaces for libdw.
2 Copyright (C) 2002, 2004, 2005 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
197/* Create a handle for a new debug session. */
198extern Dwarf *dwarf_begin (int fildes, Dwarf_Cmd cmd);
199
200/* Create a handle for a new debug session for an ELF file. */
201extern Dwarf *dwarf_begin_elf (Elf *elf, Dwarf_Cmd cmd, Elf_Scn *scngrp);
202
203/* Retrieve ELF descriptor used for DWARF access. */
204extern Elf *dwarf_getelf (Dwarf *dwarf);
205
206/* Release debugging handling context. */
207extern int dwarf_end (Dwarf *dwarf);
208
209
210/* Get the data block for the .debug_info section. */
211extern Elf_Data *dwarf_getscn_info (Dwarf *dwarf);
212
213/* Read the header for the DWARF CU header. */
214extern int dwarf_nextcu (Dwarf *dwarf, Dwarf_Off off, Dwarf_Off *next_off,
215 size_t *header_sizep, Dwarf_Off *abbrev_offsetp,
216 uint8_t *address_sizep, uint8_t *offset_sizep)
217 __nonnull_attribute__ (3);
218
219
220/* Return DIE at given offset. */
221extern Dwarf_Die *dwarf_offdie (Dwarf *dbg, Dwarf_Off offset,
222 Dwarf_Die *result) __nonnull_attribute__ (3);
223
224/* Return offset of DIE. */
225extern Dwarf_Off dwarf_dieoffset (Dwarf_Die *die);
226
227/* Return offset of DIE in CU. */
228extern Dwarf_Off dwarf_cuoffset (Dwarf_Die *die);
229
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000230/* Return CU DIE containing given DIE. */
231extern Dwarf_Die *dwarf_diecu (Dwarf_Die *die, Dwarf_Die *result,
232 uint8_t *address_sizep, uint8_t *offset_sizep);
233
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000234/* Return CU DIE containing given address. */
235extern Dwarf_Die *dwarf_addrdie (Dwarf *dbg, Dwarf_Addr addr,
236 Dwarf_Die *result) __nonnull_attribute__ (3);
237
238/* Return child of current DIE. */
239extern int dwarf_child (Dwarf_Die *die, Dwarf_Die *result)
Ulrich Drepper4f3d2a22006-05-22 01:30:56 +0000240 __nonnull_attribute__ (1, 2);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000241
242/* Return sibling of given DIE. */
243extern int dwarf_siblingof (Dwarf_Die *die, Dwarf_Die *result)
244 __nonnull_attribute__ (2);
245
246/* Check whether the DIE has children. */
Ulrich Drepper4f3d2a22006-05-22 01:30:56 +0000247extern int dwarf_haschildren (Dwarf_Die *die) __nonnull_attribute__ (1);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000248
249/* Get attributes of the DIE. */
250extern ptrdiff_t dwarf_getattrs (Dwarf_Die *die,
251 int (*callback) (Dwarf_Attribute *, void *),
Ulrich Drepper4f3d2a22006-05-22 01:30:56 +0000252 void *arg, ptrdiff_t offset)
253 __nonnull_attribute__ (2);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000254
255/* Return tag of given DIE. */
Ulrich Drepper4f3d2a22006-05-22 01:30:56 +0000256extern int dwarf_tag (Dwarf_Die *die) __nonnull_attribute__ (1);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000257
258
259/* Return specific attribute of DIE. */
260extern Dwarf_Attribute *dwarf_attr (Dwarf_Die *die, unsigned int search_name,
261 Dwarf_Attribute *result)
262 __nonnull_attribute__ (3);
263
264/* Check whether given DIE has specific attribute. */
265extern int dwarf_hasattr (Dwarf_Die *die, unsigned int search_name);
266
267/* These are the same as dwarf_attr and dwarf_hasattr, respectively,
268 but they resolve an indirect attribute through DW_AT_abstract_origin. */
269extern Dwarf_Attribute *dwarf_attr_integrate (Dwarf_Die *die,
270 unsigned int search_name,
271 Dwarf_Attribute *result)
272 __nonnull_attribute__ (3);
273extern int dwarf_hasattr_integrate (Dwarf_Die *die, unsigned int search_name);
274
275
276
277
278/* Check whether given attribute has specific form. */
279extern int dwarf_hasform (Dwarf_Attribute *attr, unsigned int search_form);
280
281/* Return attribute code of given attribute. */
282extern unsigned int dwarf_whatattr (Dwarf_Attribute *attr);
283
284/* Return form code of given attribute. */
285extern unsigned int dwarf_whatform (Dwarf_Attribute *attr);
286
287
288/* Return string associated with given attribute. */
289extern const char *dwarf_formstring (Dwarf_Attribute *attrp);
290
291/* Return unsigned constant represented by attribute. */
292extern int dwarf_formudata (Dwarf_Attribute *attr, Dwarf_Word *return_uval)
293 __nonnull_attribute__ (2);
294
295/* Return signed constant represented by attribute. */
296extern int dwarf_formsdata (Dwarf_Attribute *attr, Dwarf_Sword *return_uval)
297 __nonnull_attribute__ (2);
298
299/* Return address represented by attribute. */
300extern int dwarf_formaddr (Dwarf_Attribute *attr, Dwarf_Addr *return_addr)
301 __nonnull_attribute__ (2);
302
303/* Return reference offset represented by attribute. */
304extern int dwarf_formref (Dwarf_Attribute *attr, Dwarf_Off *return_offset)
305 __nonnull_attribute__ (2);
306
307/* Look up the DIE in a reference-form attribute. */
308extern Dwarf_Die *dwarf_formref_die (Dwarf_Attribute *attr, Dwarf_Die *die_mem)
309 __nonnull_attribute__ (2);
310
311/* Return block represented by attribute. */
312extern int dwarf_formblock (Dwarf_Attribute *attr, Dwarf_Block *return_block)
313 __nonnull_attribute__ (2);
314
315/* Return flag represented by attribute. */
316extern int dwarf_formflag (Dwarf_Attribute *attr, bool *return_bool)
317 __nonnull_attribute__ (2);
318
319
320/* Simplified attribute value access functions. */
321
322/* Return string in name attribute of DIE. */
323extern const char *dwarf_diename (Dwarf_Die *die);
324
325/* Return high PC attribute of DIE. */
326extern int dwarf_highpc (Dwarf_Die *die, Dwarf_Addr *return_addr)
327 __nonnull_attribute__ (2);
328
329/* Return low PC attribute of DIE. */
330extern int dwarf_lowpc (Dwarf_Die *die, Dwarf_Addr *return_addr)
331 __nonnull_attribute__ (2);
332
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000333/* Return entry_pc or low_pc attribute of DIE. */
334extern int dwarf_entrypc (Dwarf_Die *die, Dwarf_Addr *return_addr)
335 __nonnull_attribute__ (2);
336
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000337/* Return 1 if DIE's lowpc/highpc or ranges attributes match the PC address,
338 0 if not, or -1 for errors. */
339extern int dwarf_haspc (Dwarf_Die *die, Dwarf_Addr pc);
340
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000341/* Enumerate the PC address ranges covered by this DIE, covering all
342 addresses where dwarf_haspc returns true. In the first call OFFSET
343 should be zero and *BASEP need not be initialized. Returns -1 for
344 errors, zero when there are no more address ranges to report, or a
345 nonzero OFFSET value to pass to the next call. Each subsequent call
346 must preserve *BASEP from the prior call. Successful calls fill in
347 *STARTP and *ENDP with a contiguous address range. */
348extern ptrdiff_t dwarf_ranges (Dwarf_Die *die,
349 ptrdiff_t offset, Dwarf_Addr *basep,
350 Dwarf_Addr *startp, Dwarf_Addr *endp);
351
352
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000353/* Return byte size attribute of DIE. */
354extern int dwarf_bytesize (Dwarf_Die *die);
355
356/* Return bit size attribute of DIE. */
357extern int dwarf_bitsize (Dwarf_Die *die);
358
359/* Return bit offset attribute of DIE. */
360extern int dwarf_bitoffset (Dwarf_Die *die);
361
362/* Return array order attribute of DIE. */
363extern int dwarf_arrayorder (Dwarf_Die *die);
364
365/* Return source language attribute of DIE. */
366extern int dwarf_srclang (Dwarf_Die *die);
367
368
369/* Get abbreviation at given offset for given DIE. */
370extern Dwarf_Abbrev *dwarf_getabbrev (Dwarf_Die *die, Dwarf_Off offset,
371 size_t *lengthp);
372
373/* Get abbreviation at given offset in .debug_abbrev section. */
374extern int dwarf_offabbrev (Dwarf *dbg, Dwarf_Off offset, size_t *lengthp,
375 Dwarf_Abbrev *abbrevp)
376 __nonnull_attribute__ (4);
377
378/* Get abbreviation code. */
379extern unsigned int dwarf_getabbrevcode (Dwarf_Abbrev *abbrev);
380
381/* Get abbreviation tag. */
382extern unsigned int dwarf_getabbrevtag (Dwarf_Abbrev *abbrev);
383
384/* Return true if abbreviation is children flag set. */
385extern int dwarf_abbrevhaschildren (Dwarf_Abbrev *abbrev);
386
387/* Get number of attributes of abbreviation. */
388extern int dwarf_getattrcnt (Dwarf_Abbrev *abbrev, size_t *attrcntp)
389 __nonnull_attribute__ (2);
390
391/* Get specific attribute of abbreviation. */
392extern int dwarf_getabbrevattr (Dwarf_Abbrev *abbrev, size_t idx,
393 unsigned int *namep, unsigned int *formp,
394 Dwarf_Off *offset);
395
396
397/* Get string from-debug_str section. */
398extern const char *dwarf_getstring (Dwarf *dbg, Dwarf_Off offset,
399 size_t *lenp);
400
401
402/* Get public symbol information. */
403extern ptrdiff_t dwarf_getpubnames (Dwarf *dbg,
404 int (*callback) (Dwarf *, Dwarf_Global *,
405 void *),
406 void *arg, ptrdiff_t offset)
407 __nonnull_attribute__ (2);
408
409
410/* Get source file information for CU. */
411extern int dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines,
412 size_t *nlines) __nonnull_attribute__ (2, 3);
413
414/* Return one of the source lines of the CU. */
415extern Dwarf_Line *dwarf_onesrcline (Dwarf_Lines *lines, size_t idx);
416
417/* Get the file source files used in the CU. */
418extern int dwarf_getsrcfiles (Dwarf_Die *cudie, Dwarf_Files **files,
419 size_t *nfiles)
420 __nonnull_attribute__ (2);
421
422
423/* Get source for address in CU. */
424extern Dwarf_Line *dwarf_getsrc_die (Dwarf_Die *cudie, Dwarf_Addr addr);
425
426/* Get source for file and line number. */
427extern int dwarf_getsrc_file (Dwarf *dbg, const char *fname, int line, int col,
428 Dwarf_Line ***srcsp, size_t *nsrcs)
429 __nonnull_attribute__ (2, 5, 6);
430
431
432/* Return line address. */
433extern int dwarf_lineaddr (Dwarf_Line *line, Dwarf_Addr *addrp);
434
435/* Return line number. */
436extern int dwarf_lineno (Dwarf_Line *line, int *linep)
437 __nonnull_attribute__ (2);
438
439/* Return column in line. */
440extern int dwarf_linecol (Dwarf_Line *line, int *colp)
441 __nonnull_attribute__ (2);
442
443/* Return true if record is for beginning of a statement. */
444extern int dwarf_linebeginstatement (Dwarf_Line *line, bool *flagp)
445 __nonnull_attribute__ (2);
446
447/* Return true if record is for end of sequence. */
448extern int dwarf_lineendsequence (Dwarf_Line *line, bool *flagp)
449 __nonnull_attribute__ (2);
450
451/* Return true if record is for beginning of a basic block. */
452extern int dwarf_lineblock (Dwarf_Line *line, bool *flagp)
453 __nonnull_attribute__ (2);
454
455/* Return true if record is for end of prologue. */
456extern int dwarf_lineprologueend (Dwarf_Line *line, bool *flagp)
457 __nonnull_attribute__ (2);
458
459/* Return true if record is for beginning of epilogue. */
460extern int dwarf_lineepiloguebegin (Dwarf_Line *line, bool *flagp)
461 __nonnull_attribute__ (2);
462
463
464/* Find line information for address. */
465extern const char *dwarf_linesrc (Dwarf_Line *line,
466 Dwarf_Word *mtime, Dwarf_Word *length);
467
468/* Return file information. */
469extern const char *dwarf_filesrc (Dwarf_Files *file, size_t idx,
470 Dwarf_Word *mtime, Dwarf_Word *length);
471
472
Roland McGrath6724c902005-10-28 07:07:19 +0000473/* Return location expression, decoded as a list of operations. */
474extern int dwarf_getlocation (Dwarf_Attribute *attr, Dwarf_Op **expr,
475 size_t *exprlen) __nonnull_attribute__ (2, 3);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000476
Roland McGrath6724c902005-10-28 07:07:19 +0000477/* Return location expressions. If the attribute uses a location list,
478 ADDRESS selects the relevant location expressions from the list.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000479 There can be multiple matches, resulting in multiple expressions to
Roland McGrath6724c902005-10-28 07:07:19 +0000480 return. EXPRS and EXPRLENS are parallel arrays of NLOCS slots to
481 fill in. Returns the number of locations filled in, or -1 for
482 errors. If EXPRS is a null pointer, stores nothing and returns the
483 total number of locations. A return value of zero means that the
484 location list indicated no value is accessible. */
485extern int dwarf_getlocation_addr (Dwarf_Attribute *attr, Dwarf_Addr address,
486 Dwarf_Op **exprs, size_t *exprlens,
487 size_t nlocs);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000488
489
490/* Return scope DIEs containing PC address.
491 Sets *SCOPES to a malloc'd array of Dwarf_Die structures,
492 and returns the number of elements in the array.
493 (*SCOPES)[0] is the DIE for the innermost scope containing PC,
494 (*SCOPES)[1] is the DIE for the scope containing that scope, and so on.
495 Returns -1 for errors or 0 if no scopes match PC. */
496extern int dwarf_getscopes (Dwarf_Die *cudie, Dwarf_Addr pc,
497 Dwarf_Die **scopes);
498
Roland McGrath71e15a02005-08-27 10:33:26 +0000499/* Return scope DIEs containing the given DIE.
500 Sets *SCOPES to a malloc'd array of Dwarf_Die structures,
501 and returns the number of elements in the array.
502 (*SCOPES)[0] is a copy of DIE.
503 (*SCOPES)[1] is the DIE for the scope containing that scope, and so on.
504 Returns -1 for errors or 0 if DIE is not found in any scope entry. */
505extern int dwarf_getscopes_die (Dwarf_Die *die, Dwarf_Die **scopes);
506
507
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000508/* Search SCOPES[0..NSCOPES-1] for a variable called NAME.
509 Ignore the first SKIP_SHADOWS scopes that match the name.
510 If MATCH_FILE is not null, accept only declaration in that source file;
511 if MATCH_LINENO or MATCH_LINECOL are also nonzero, accept only declaration
512 at that line and column.
513
514 If successful, fill in *RESULT with the DIE of the variable found,
515 and return N where SCOPES[N] is the scope defining the variable.
516 Return -1 for errors or -2 for no matching variable found. */
517extern int dwarf_getscopevar (Dwarf_Die *scopes, int nscopes,
518 const char *name, int skip_shadows,
519 const char *match_file,
520 int match_lineno, int match_linecol,
521 Dwarf_Die *result);
522
523
524
525/* Return list address ranges. */
526extern int dwarf_getaranges (Dwarf *dbg, Dwarf_Aranges **aranges,
527 size_t *naranges)
528 __nonnull_attribute__ (2);
529
530/* Return one of the address range entries. */
531extern Dwarf_Arange *dwarf_onearange (Dwarf_Aranges *aranges, size_t idx);
532
533/* Return information in address range record. */
534extern int dwarf_getarangeinfo (Dwarf_Arange *arange, Dwarf_Addr *addrp,
535 Dwarf_Word *lengthp, Dwarf_Off *offsetp);
536
537/* Get address range which includes given address. */
538extern Dwarf_Arange *dwarf_getarange_addr (Dwarf_Aranges *aranges,
539 Dwarf_Addr addr);
540
541
542
543/* Get functions in CUDIE. */
544extern ptrdiff_t dwarf_getfuncs (Dwarf_Die *cudie,
Roland McGrath6724c902005-10-28 07:07:19 +0000545 int (*callback) (Dwarf_Die *, void *),
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000546 void *arg, ptrdiff_t offset);
547
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000548
Roland McGrath6724c902005-10-28 07:07:19 +0000549/* Return file name containing definition of the given declaration. */
550extern const char *dwarf_decl_file (Dwarf_Die *decl);
551
552/* Get line number of beginning of given declaration. */
553extern int dwarf_decl_line (Dwarf_Die *decl, int *linep)
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000554 __nonnull_attribute__ (2);
555
Roland McGrath6724c902005-10-28 07:07:19 +0000556/* Get column number of beginning of given declaration. */
557extern int dwarf_decl_column (Dwarf_Die *decl, int *colp)
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000558 __nonnull_attribute__ (2);
559
Roland McGrath1ecb6062005-08-15 09:53:04 +0000560
561/* Return nonzero if given function is an abstract inline definition. */
Roland McGrath6724c902005-10-28 07:07:19 +0000562extern int dwarf_func_inline (Dwarf_Die *func);
Roland McGrath1ecb6062005-08-15 09:53:04 +0000563
564/* Find each concrete inlined instance of the abstract inline definition. */
Roland McGrath6724c902005-10-28 07:07:19 +0000565extern int dwarf_func_inline_instances (Dwarf_Die *func,
Roland McGrath1ecb6062005-08-15 09:53:04 +0000566 int (*callback) (Dwarf_Die *, void *),
567 void *arg);
568
569
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000570/* Find the appropriate PC location or locations for function entry
571 breakpoints for the given DW_TAG_subprogram DIE. Returns -1 for errors.
572 On success, returns the number of breakpoint locations (never zero)
573 and sets *BKPTS to a malloc'd vector of addresses. */
574extern int dwarf_entry_breakpoints (Dwarf_Die *die, Dwarf_Addr **bkpts);
575
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000576
577/* Call callback function for each of the macro information entry for
578 the CU. */
579extern ptrdiff_t dwarf_getmacros (Dwarf_Die *cudie,
580 int (*callback) (Dwarf_Macro *, void *),
581 void *arg, ptrdiff_t offset)
582 __nonnull_attribute__ (2);
583
584/* Return macro opcode. */
585extern int dwarf_macro_opcode (Dwarf_Macro *macro, unsigned int *opcodep)
586 __nonnull_attribute__ (2);
587
588/* Return first macro parameter. */
589extern int dwarf_macro_param1 (Dwarf_Macro *macro, Dwarf_Word *paramp)
590 __nonnull_attribute__ (2);
591
592/* Return second macro parameter. */
593extern int dwarf_macro_param2 (Dwarf_Macro *macro, Dwarf_Word *paramp,
594 const char **strp);
595
596
597/* Return error code of last failing function call. This value is kept
598 separately for each thread. */
599extern int dwarf_errno (void);
600
601/* Return error string for ERROR. If ERROR is zero, return error string
602 for most recent error or NULL is none occurred. If ERROR is -1 the
603 behaviour is similar to the last case except that not NULL but a legal
604 string is returned. */
605extern const char *dwarf_errmsg (int err);
606
607
608/* Register new Out-Of-Memory handler. The old handler is returned. */
609extern Dwarf_OOM dwarf_new_oom_handler (Dwarf *dbg, Dwarf_OOM handler);
610
611
612/* Inline optimizations. */
613#ifdef __OPTIMIZE__
614/* Return attribute code of given attribute. */
615extern inline unsigned int
616dwarf_whatattr (Dwarf_Attribute *attr)
617{
618 return attr == NULL ? 0 : attr->code;
619}
620
621/* Return attribute code of given attribute. */
622extern inline unsigned int
623dwarf_whatform (Dwarf_Attribute *attr)
624{
625 return attr == NULL ? 0 : attr->form;
626}
627#endif /* Optimize. */
628
629#endif /* libdw.h */