blob: 69eb903fb79fab06569bd3110d2f529811420cc0 [file] [log] [blame]
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00001/* Interfaces for libdw.
2 Copyright (C) 2002, 2004, 2005 Red Hat, Inc.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
4
5 This program is Open Source software; you can redistribute it and/or
6 modify it under the terms of the Open Software License version 1.0 as
7 published by the Open Source Initiative.
8
9 You should have received a copy of the Open Software License along
10 with this program; if not, you may obtain a copy of the Open Software
11 License version 1.0 from http://www.opensource.org/licenses/osl.php or
12 by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
13 3001 King Ranch Road, Ukiah, CA 95482. */
14
15#ifndef _LIBDW_H
16#define _LIBDW_H 1
17
18#include <gelf.h>
19#include <stdbool.h>
20#include <stddef.h>
21
22
23#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
24# define __nonnull_attribute__(...) __attribute__ ((__nonnull__ (__VA_ARGS__)))
25#else
26# define __nonnull_attribute__(args...)
27#endif
28
29
30/* Mode for the session. */
31typedef enum
32 {
33 DWARF_C_READ, /* Read .. */
34 DWARF_C_RDWR, /* Read and write .. */
35 DWARF_C_WRITE, /* Write .. */
36 }
37Dwarf_Cmd;
38
39
40/* Callback results. */
41enum
42{
43 DWARF_CB_OK = 0,
44 DWARF_CB_ABORT
45};
46
47
48/* Error values. */
49enum
50 {
51 DW_TAG_invalid = 0
52#define DW_TAG_invalid DW_TAG_invalid
53 };
54
55
56/* Type for offset in DWARF file. */
57typedef GElf_Off Dwarf_Off;
58
59/* Type for address in DWARF file. */
60typedef GElf_Addr Dwarf_Addr;
61
62/* Integer types. Big enough to hold any numeric value. */
63typedef GElf_Xword Dwarf_Word;
64typedef GElf_Sxword Dwarf_Sword;
65/* For the times we know we do not need that much. */
66typedef GElf_Half Dwarf_Half;
67
68
69/* DWARF abbreviation record. */
70typedef struct Dwarf_Abbrev Dwarf_Abbrev;
71
72/* Returned to show the last DIE has be returned. */
73#define DWARF_END_ABBREV ((Dwarf_Abbrev *) -1l)
74
75/* Source code line information for CU. */
76typedef struct Dwarf_Lines_s Dwarf_Lines;
77
78/* One source code line information. */
79typedef struct Dwarf_Line_s Dwarf_Line;
80
81/* Source file information. */
82typedef struct Dwarf_Files_s Dwarf_Files;
83
84/* One address range record. */
85typedef struct Dwarf_Arange_s Dwarf_Arange;
86
87/* Address ranges of a file. */
88typedef struct Dwarf_Aranges_s Dwarf_Aranges;
89
90/* CU representation. */
91struct Dwarf_CU;
92
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000093/* Macro information. */
94typedef struct Dwarf_Macro_s Dwarf_Macro;
95
96/* Attribute representation. */
97typedef struct
98{
99 unsigned int code;
100 unsigned int form;
101 unsigned char *valp;
102 struct Dwarf_CU *cu;
103} Dwarf_Attribute;
104
105
106/* Data block representation. */
107typedef struct
108{
109 Dwarf_Word length;
110 unsigned char *data;
111} Dwarf_Block;
112
113
114/* DIE information. */
115typedef struct
116{
117 /* The offset can be computed from the address. */
118 void *addr;
119 struct Dwarf_CU *cu;
120 Dwarf_Abbrev *abbrev;
121 // XXX We'll see what other information will be needed.
122 long int padding__;
123} Dwarf_Die;
124
125/* Returned to show the last DIE has be returned. */
126#define DWARF_END_DIE ((Dwarf_Die *) -1l)
127
128
129/* Global symbol information. */
130typedef struct
131{
132 Dwarf_Off cu_offset;
133 Dwarf_Off die_offset;
134 const char *name;
135} Dwarf_Global;
136
137
Roland McGrath6724c902005-10-28 07:07:19 +0000138/* One operation in a DWARF location expression.
139 A location expression is an array of these. */
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000140typedef struct
141{
142 uint8_t atom; /* Operation */
143 Dwarf_Word number; /* Operand */
144 Dwarf_Word number2; /* Possible second operand */
145 Dwarf_Word offset; /* Offset in location expression */
Roland McGrath6724c902005-10-28 07:07:19 +0000146} Dwarf_Op;
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000147
148
149/* Handle for debug sessions. */
150typedef struct Dwarf Dwarf;
151
152
153/* Out-Of-Memory handler. */
154#if __GNUC__ < 4
155typedef void (*Dwarf_OOM) (void);
156#else
157typedef void (*__attribute__ ((noreturn)) Dwarf_OOM) (void);
158#endif
159
160
161/* Create a handle for a new debug session. */
162extern Dwarf *dwarf_begin (int fildes, Dwarf_Cmd cmd);
163
164/* Create a handle for a new debug session for an ELF file. */
165extern Dwarf *dwarf_begin_elf (Elf *elf, Dwarf_Cmd cmd, Elf_Scn *scngrp);
166
167/* Retrieve ELF descriptor used for DWARF access. */
168extern Elf *dwarf_getelf (Dwarf *dwarf);
169
170/* Release debugging handling context. */
171extern int dwarf_end (Dwarf *dwarf);
172
173
174/* Get the data block for the .debug_info section. */
175extern Elf_Data *dwarf_getscn_info (Dwarf *dwarf);
176
177/* Read the header for the DWARF CU header. */
178extern int dwarf_nextcu (Dwarf *dwarf, Dwarf_Off off, Dwarf_Off *next_off,
179 size_t *header_sizep, Dwarf_Off *abbrev_offsetp,
180 uint8_t *address_sizep, uint8_t *offset_sizep)
181 __nonnull_attribute__ (3);
182
183
184/* Return DIE at given offset. */
185extern Dwarf_Die *dwarf_offdie (Dwarf *dbg, Dwarf_Off offset,
186 Dwarf_Die *result) __nonnull_attribute__ (3);
187
188/* Return offset of DIE. */
189extern Dwarf_Off dwarf_dieoffset (Dwarf_Die *die);
190
191/* Return offset of DIE in CU. */
192extern Dwarf_Off dwarf_cuoffset (Dwarf_Die *die);
193
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000194/* Return CU DIE containing given DIE. */
195extern Dwarf_Die *dwarf_diecu (Dwarf_Die *die, Dwarf_Die *result,
196 uint8_t *address_sizep, uint8_t *offset_sizep);
197
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000198/* Return CU DIE containing given address. */
199extern Dwarf_Die *dwarf_addrdie (Dwarf *dbg, Dwarf_Addr addr,
200 Dwarf_Die *result) __nonnull_attribute__ (3);
201
202/* Return child of current DIE. */
203extern int dwarf_child (Dwarf_Die *die, Dwarf_Die *result)
204 __nonnull_attribute__ (2);
205
206/* Return sibling of given DIE. */
207extern int dwarf_siblingof (Dwarf_Die *die, Dwarf_Die *result)
208 __nonnull_attribute__ (2);
209
210/* Check whether the DIE has children. */
211extern int dwarf_haschildren (Dwarf_Die *die);
212
213/* Get attributes of the DIE. */
214extern ptrdiff_t dwarf_getattrs (Dwarf_Die *die,
215 int (*callback) (Dwarf_Attribute *, void *),
216 void *arg, ptrdiff_t offset);
217
218/* Return tag of given DIE. */
219extern int dwarf_tag (Dwarf_Die *die);
220
221
222/* Return specific attribute of DIE. */
223extern Dwarf_Attribute *dwarf_attr (Dwarf_Die *die, unsigned int search_name,
224 Dwarf_Attribute *result)
225 __nonnull_attribute__ (3);
226
227/* Check whether given DIE has specific attribute. */
228extern int dwarf_hasattr (Dwarf_Die *die, unsigned int search_name);
229
230/* These are the same as dwarf_attr and dwarf_hasattr, respectively,
231 but they resolve an indirect attribute through DW_AT_abstract_origin. */
232extern Dwarf_Attribute *dwarf_attr_integrate (Dwarf_Die *die,
233 unsigned int search_name,
234 Dwarf_Attribute *result)
235 __nonnull_attribute__ (3);
236extern int dwarf_hasattr_integrate (Dwarf_Die *die, unsigned int search_name);
237
238
239
240
241/* Check whether given attribute has specific form. */
242extern int dwarf_hasform (Dwarf_Attribute *attr, unsigned int search_form);
243
244/* Return attribute code of given attribute. */
245extern unsigned int dwarf_whatattr (Dwarf_Attribute *attr);
246
247/* Return form code of given attribute. */
248extern unsigned int dwarf_whatform (Dwarf_Attribute *attr);
249
250
251/* Return string associated with given attribute. */
252extern const char *dwarf_formstring (Dwarf_Attribute *attrp);
253
254/* Return unsigned constant represented by attribute. */
255extern int dwarf_formudata (Dwarf_Attribute *attr, Dwarf_Word *return_uval)
256 __nonnull_attribute__ (2);
257
258/* Return signed constant represented by attribute. */
259extern int dwarf_formsdata (Dwarf_Attribute *attr, Dwarf_Sword *return_uval)
260 __nonnull_attribute__ (2);
261
262/* Return address represented by attribute. */
263extern int dwarf_formaddr (Dwarf_Attribute *attr, Dwarf_Addr *return_addr)
264 __nonnull_attribute__ (2);
265
266/* Return reference offset represented by attribute. */
267extern int dwarf_formref (Dwarf_Attribute *attr, Dwarf_Off *return_offset)
268 __nonnull_attribute__ (2);
269
270/* Look up the DIE in a reference-form attribute. */
271extern Dwarf_Die *dwarf_formref_die (Dwarf_Attribute *attr, Dwarf_Die *die_mem)
272 __nonnull_attribute__ (2);
273
274/* Return block represented by attribute. */
275extern int dwarf_formblock (Dwarf_Attribute *attr, Dwarf_Block *return_block)
276 __nonnull_attribute__ (2);
277
278/* Return flag represented by attribute. */
279extern int dwarf_formflag (Dwarf_Attribute *attr, bool *return_bool)
280 __nonnull_attribute__ (2);
281
282
283/* Simplified attribute value access functions. */
284
285/* Return string in name attribute of DIE. */
286extern const char *dwarf_diename (Dwarf_Die *die);
287
288/* Return high PC attribute of DIE. */
289extern int dwarf_highpc (Dwarf_Die *die, Dwarf_Addr *return_addr)
290 __nonnull_attribute__ (2);
291
292/* Return low PC attribute of DIE. */
293extern int dwarf_lowpc (Dwarf_Die *die, Dwarf_Addr *return_addr)
294 __nonnull_attribute__ (2);
295
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000296/* Return entry_pc or low_pc attribute of DIE. */
297extern int dwarf_entrypc (Dwarf_Die *die, Dwarf_Addr *return_addr)
298 __nonnull_attribute__ (2);
299
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000300/* Return 1 if DIE's lowpc/highpc or ranges attributes match the PC address,
301 0 if not, or -1 for errors. */
302extern int dwarf_haspc (Dwarf_Die *die, Dwarf_Addr pc);
303
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000304/* Enumerate the PC address ranges covered by this DIE, covering all
305 addresses where dwarf_haspc returns true. In the first call OFFSET
306 should be zero and *BASEP need not be initialized. Returns -1 for
307 errors, zero when there are no more address ranges to report, or a
308 nonzero OFFSET value to pass to the next call. Each subsequent call
309 must preserve *BASEP from the prior call. Successful calls fill in
310 *STARTP and *ENDP with a contiguous address range. */
311extern ptrdiff_t dwarf_ranges (Dwarf_Die *die,
312 ptrdiff_t offset, Dwarf_Addr *basep,
313 Dwarf_Addr *startp, Dwarf_Addr *endp);
314
315
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000316/* Return byte size attribute of DIE. */
317extern int dwarf_bytesize (Dwarf_Die *die);
318
319/* Return bit size attribute of DIE. */
320extern int dwarf_bitsize (Dwarf_Die *die);
321
322/* Return bit offset attribute of DIE. */
323extern int dwarf_bitoffset (Dwarf_Die *die);
324
325/* Return array order attribute of DIE. */
326extern int dwarf_arrayorder (Dwarf_Die *die);
327
328/* Return source language attribute of DIE. */
329extern int dwarf_srclang (Dwarf_Die *die);
330
331
332/* Get abbreviation at given offset for given DIE. */
333extern Dwarf_Abbrev *dwarf_getabbrev (Dwarf_Die *die, Dwarf_Off offset,
334 size_t *lengthp);
335
336/* Get abbreviation at given offset in .debug_abbrev section. */
337extern int dwarf_offabbrev (Dwarf *dbg, Dwarf_Off offset, size_t *lengthp,
338 Dwarf_Abbrev *abbrevp)
339 __nonnull_attribute__ (4);
340
341/* Get abbreviation code. */
342extern unsigned int dwarf_getabbrevcode (Dwarf_Abbrev *abbrev);
343
344/* Get abbreviation tag. */
345extern unsigned int dwarf_getabbrevtag (Dwarf_Abbrev *abbrev);
346
347/* Return true if abbreviation is children flag set. */
348extern int dwarf_abbrevhaschildren (Dwarf_Abbrev *abbrev);
349
350/* Get number of attributes of abbreviation. */
351extern int dwarf_getattrcnt (Dwarf_Abbrev *abbrev, size_t *attrcntp)
352 __nonnull_attribute__ (2);
353
354/* Get specific attribute of abbreviation. */
355extern int dwarf_getabbrevattr (Dwarf_Abbrev *abbrev, size_t idx,
356 unsigned int *namep, unsigned int *formp,
357 Dwarf_Off *offset);
358
359
360/* Get string from-debug_str section. */
361extern const char *dwarf_getstring (Dwarf *dbg, Dwarf_Off offset,
362 size_t *lenp);
363
364
365/* Get public symbol information. */
366extern ptrdiff_t dwarf_getpubnames (Dwarf *dbg,
367 int (*callback) (Dwarf *, Dwarf_Global *,
368 void *),
369 void *arg, ptrdiff_t offset)
370 __nonnull_attribute__ (2);
371
372
373/* Get source file information for CU. */
374extern int dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines,
375 size_t *nlines) __nonnull_attribute__ (2, 3);
376
377/* Return one of the source lines of the CU. */
378extern Dwarf_Line *dwarf_onesrcline (Dwarf_Lines *lines, size_t idx);
379
380/* Get the file source files used in the CU. */
381extern int dwarf_getsrcfiles (Dwarf_Die *cudie, Dwarf_Files **files,
382 size_t *nfiles)
383 __nonnull_attribute__ (2);
384
385
386/* Get source for address in CU. */
387extern Dwarf_Line *dwarf_getsrc_die (Dwarf_Die *cudie, Dwarf_Addr addr);
388
389/* Get source for file and line number. */
390extern int dwarf_getsrc_file (Dwarf *dbg, const char *fname, int line, int col,
391 Dwarf_Line ***srcsp, size_t *nsrcs)
392 __nonnull_attribute__ (2, 5, 6);
393
394
395/* Return line address. */
396extern int dwarf_lineaddr (Dwarf_Line *line, Dwarf_Addr *addrp);
397
398/* Return line number. */
399extern int dwarf_lineno (Dwarf_Line *line, int *linep)
400 __nonnull_attribute__ (2);
401
402/* Return column in line. */
403extern int dwarf_linecol (Dwarf_Line *line, int *colp)
404 __nonnull_attribute__ (2);
405
406/* Return true if record is for beginning of a statement. */
407extern int dwarf_linebeginstatement (Dwarf_Line *line, bool *flagp)
408 __nonnull_attribute__ (2);
409
410/* Return true if record is for end of sequence. */
411extern int dwarf_lineendsequence (Dwarf_Line *line, bool *flagp)
412 __nonnull_attribute__ (2);
413
414/* Return true if record is for beginning of a basic block. */
415extern int dwarf_lineblock (Dwarf_Line *line, bool *flagp)
416 __nonnull_attribute__ (2);
417
418/* Return true if record is for end of prologue. */
419extern int dwarf_lineprologueend (Dwarf_Line *line, bool *flagp)
420 __nonnull_attribute__ (2);
421
422/* Return true if record is for beginning of epilogue. */
423extern int dwarf_lineepiloguebegin (Dwarf_Line *line, bool *flagp)
424 __nonnull_attribute__ (2);
425
426
427/* Find line information for address. */
428extern const char *dwarf_linesrc (Dwarf_Line *line,
429 Dwarf_Word *mtime, Dwarf_Word *length);
430
431/* Return file information. */
432extern const char *dwarf_filesrc (Dwarf_Files *file, size_t idx,
433 Dwarf_Word *mtime, Dwarf_Word *length);
434
435
Roland McGrath6724c902005-10-28 07:07:19 +0000436/* Return location expression, decoded as a list of operations. */
437extern int dwarf_getlocation (Dwarf_Attribute *attr, Dwarf_Op **expr,
438 size_t *exprlen) __nonnull_attribute__ (2, 3);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000439
Roland McGrath6724c902005-10-28 07:07:19 +0000440/* Return location expressions. If the attribute uses a location list,
441 ADDRESS selects the relevant location expressions from the list.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000442 There can be multiple matches, resulting in multiple expressions to
Roland McGrath6724c902005-10-28 07:07:19 +0000443 return. EXPRS and EXPRLENS are parallel arrays of NLOCS slots to
444 fill in. Returns the number of locations filled in, or -1 for
445 errors. If EXPRS is a null pointer, stores nothing and returns the
446 total number of locations. A return value of zero means that the
447 location list indicated no value is accessible. */
448extern int dwarf_getlocation_addr (Dwarf_Attribute *attr, Dwarf_Addr address,
449 Dwarf_Op **exprs, size_t *exprlens,
450 size_t nlocs);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000451
452
453/* Return scope DIEs containing PC address.
454 Sets *SCOPES to a malloc'd array of Dwarf_Die structures,
455 and returns the number of elements in the array.
456 (*SCOPES)[0] is the DIE for the innermost scope containing PC,
457 (*SCOPES)[1] is the DIE for the scope containing that scope, and so on.
458 Returns -1 for errors or 0 if no scopes match PC. */
459extern int dwarf_getscopes (Dwarf_Die *cudie, Dwarf_Addr pc,
460 Dwarf_Die **scopes);
461
Roland McGrath71e15a02005-08-27 10:33:26 +0000462/* Return scope DIEs containing the given DIE.
463 Sets *SCOPES to a malloc'd array of Dwarf_Die structures,
464 and returns the number of elements in the array.
465 (*SCOPES)[0] is a copy of DIE.
466 (*SCOPES)[1] is the DIE for the scope containing that scope, and so on.
467 Returns -1 for errors or 0 if DIE is not found in any scope entry. */
468extern int dwarf_getscopes_die (Dwarf_Die *die, Dwarf_Die **scopes);
469
470
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000471/* Search SCOPES[0..NSCOPES-1] for a variable called NAME.
472 Ignore the first SKIP_SHADOWS scopes that match the name.
473 If MATCH_FILE is not null, accept only declaration in that source file;
474 if MATCH_LINENO or MATCH_LINECOL are also nonzero, accept only declaration
475 at that line and column.
476
477 If successful, fill in *RESULT with the DIE of the variable found,
478 and return N where SCOPES[N] is the scope defining the variable.
479 Return -1 for errors or -2 for no matching variable found. */
480extern int dwarf_getscopevar (Dwarf_Die *scopes, int nscopes,
481 const char *name, int skip_shadows,
482 const char *match_file,
483 int match_lineno, int match_linecol,
484 Dwarf_Die *result);
485
486
487
488/* Return list address ranges. */
489extern int dwarf_getaranges (Dwarf *dbg, Dwarf_Aranges **aranges,
490 size_t *naranges)
491 __nonnull_attribute__ (2);
492
493/* Return one of the address range entries. */
494extern Dwarf_Arange *dwarf_onearange (Dwarf_Aranges *aranges, size_t idx);
495
496/* Return information in address range record. */
497extern int dwarf_getarangeinfo (Dwarf_Arange *arange, Dwarf_Addr *addrp,
498 Dwarf_Word *lengthp, Dwarf_Off *offsetp);
499
500/* Get address range which includes given address. */
501extern Dwarf_Arange *dwarf_getarange_addr (Dwarf_Aranges *aranges,
502 Dwarf_Addr addr);
503
504
505
506/* Get functions in CUDIE. */
507extern ptrdiff_t dwarf_getfuncs (Dwarf_Die *cudie,
Roland McGrath6724c902005-10-28 07:07:19 +0000508 int (*callback) (Dwarf_Die *, void *),
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000509 void *arg, ptrdiff_t offset);
510
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000511
Roland McGrath6724c902005-10-28 07:07:19 +0000512/* Return file name containing definition of the given declaration. */
513extern const char *dwarf_decl_file (Dwarf_Die *decl);
514
515/* Get line number of beginning of given declaration. */
516extern int dwarf_decl_line (Dwarf_Die *decl, int *linep)
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000517 __nonnull_attribute__ (2);
518
Roland McGrath6724c902005-10-28 07:07:19 +0000519/* Get column number of beginning of given declaration. */
520extern int dwarf_decl_column (Dwarf_Die *decl, int *colp)
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000521 __nonnull_attribute__ (2);
522
Roland McGrath1ecb6062005-08-15 09:53:04 +0000523
524/* Return nonzero if given function is an abstract inline definition. */
Roland McGrath6724c902005-10-28 07:07:19 +0000525extern int dwarf_func_inline (Dwarf_Die *func);
Roland McGrath1ecb6062005-08-15 09:53:04 +0000526
527/* Find each concrete inlined instance of the abstract inline definition. */
Roland McGrath6724c902005-10-28 07:07:19 +0000528extern int dwarf_func_inline_instances (Dwarf_Die *func,
Roland McGrath1ecb6062005-08-15 09:53:04 +0000529 int (*callback) (Dwarf_Die *, void *),
530 void *arg);
531
532
Roland McGrath07d4f2f2005-10-28 06:56:24 +0000533/* Find the appropriate PC location or locations for function entry
534 breakpoints for the given DW_TAG_subprogram DIE. Returns -1 for errors.
535 On success, returns the number of breakpoint locations (never zero)
536 and sets *BKPTS to a malloc'd vector of addresses. */
537extern int dwarf_entry_breakpoints (Dwarf_Die *die, Dwarf_Addr **bkpts);
538
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000539
540/* Call callback function for each of the macro information entry for
541 the CU. */
542extern ptrdiff_t dwarf_getmacros (Dwarf_Die *cudie,
543 int (*callback) (Dwarf_Macro *, void *),
544 void *arg, ptrdiff_t offset)
545 __nonnull_attribute__ (2);
546
547/* Return macro opcode. */
548extern int dwarf_macro_opcode (Dwarf_Macro *macro, unsigned int *opcodep)
549 __nonnull_attribute__ (2);
550
551/* Return first macro parameter. */
552extern int dwarf_macro_param1 (Dwarf_Macro *macro, Dwarf_Word *paramp)
553 __nonnull_attribute__ (2);
554
555/* Return second macro parameter. */
556extern int dwarf_macro_param2 (Dwarf_Macro *macro, Dwarf_Word *paramp,
557 const char **strp);
558
559
560/* Return error code of last failing function call. This value is kept
561 separately for each thread. */
562extern int dwarf_errno (void);
563
564/* Return error string for ERROR. If ERROR is zero, return error string
565 for most recent error or NULL is none occurred. If ERROR is -1 the
566 behaviour is similar to the last case except that not NULL but a legal
567 string is returned. */
568extern const char *dwarf_errmsg (int err);
569
570
571/* Register new Out-Of-Memory handler. The old handler is returned. */
572extern Dwarf_OOM dwarf_new_oom_handler (Dwarf *dbg, Dwarf_OOM handler);
573
574
575/* Inline optimizations. */
576#ifdef __OPTIMIZE__
577/* Return attribute code of given attribute. */
578extern inline unsigned int
579dwarf_whatattr (Dwarf_Attribute *attr)
580{
581 return attr == NULL ? 0 : attr->code;
582}
583
584/* Return attribute code of given attribute. */
585extern inline unsigned int
586dwarf_whatform (Dwarf_Attribute *attr)
587{
588 return attr == NULL ? 0 : attr->form;
589}
590#endif /* Optimize. */
591
592#endif /* libdw.h */