libdw.h revision 361df7da6dfecd817b27e62b91752ac316d7cdd4
1/* Interfaces for libdw. 2 Copyright (C) 2002, 2004, 2005 Red Hat, Inc. 3 This file is part of Red Hat elfutils. 4 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. 5 6 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. 9 10 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, 17 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 18 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>. */ 50 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 129/* 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 174/* One operation in a DWARF location expression. 175 A location expression is an array of these. */ 176typedef 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 */ 182} Dwarf_Op; 183 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 230/* 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 234/* 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) 240 __nonnull_attribute__ (2); 241 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. */ 247extern int dwarf_haschildren (Dwarf_Die *die); 248 249/* Get attributes of the DIE. */ 250extern ptrdiff_t dwarf_getattrs (Dwarf_Die *die, 251 int (*callback) (Dwarf_Attribute *, void *), 252 void *arg, ptrdiff_t offset); 253 254/* Return tag of given DIE. */ 255extern int dwarf_tag (Dwarf_Die *die); 256 257 258/* Return specific attribute of DIE. */ 259extern Dwarf_Attribute *dwarf_attr (Dwarf_Die *die, unsigned int search_name, 260 Dwarf_Attribute *result) 261 __nonnull_attribute__ (3); 262 263/* Check whether given DIE has specific attribute. */ 264extern int dwarf_hasattr (Dwarf_Die *die, unsigned int search_name); 265 266/* These are the same as dwarf_attr and dwarf_hasattr, respectively, 267 but they resolve an indirect attribute through DW_AT_abstract_origin. */ 268extern Dwarf_Attribute *dwarf_attr_integrate (Dwarf_Die *die, 269 unsigned int search_name, 270 Dwarf_Attribute *result) 271 __nonnull_attribute__ (3); 272extern int dwarf_hasattr_integrate (Dwarf_Die *die, unsigned int search_name); 273 274 275 276 277/* Check whether given attribute has specific form. */ 278extern int dwarf_hasform (Dwarf_Attribute *attr, unsigned int search_form); 279 280/* Return attribute code of given attribute. */ 281extern unsigned int dwarf_whatattr (Dwarf_Attribute *attr); 282 283/* Return form code of given attribute. */ 284extern unsigned int dwarf_whatform (Dwarf_Attribute *attr); 285 286 287/* Return string associated with given attribute. */ 288extern const char *dwarf_formstring (Dwarf_Attribute *attrp); 289 290/* Return unsigned constant represented by attribute. */ 291extern int dwarf_formudata (Dwarf_Attribute *attr, Dwarf_Word *return_uval) 292 __nonnull_attribute__ (2); 293 294/* Return signed constant represented by attribute. */ 295extern int dwarf_formsdata (Dwarf_Attribute *attr, Dwarf_Sword *return_uval) 296 __nonnull_attribute__ (2); 297 298/* Return address represented by attribute. */ 299extern int dwarf_formaddr (Dwarf_Attribute *attr, Dwarf_Addr *return_addr) 300 __nonnull_attribute__ (2); 301 302/* Return reference offset represented by attribute. */ 303extern int dwarf_formref (Dwarf_Attribute *attr, Dwarf_Off *return_offset) 304 __nonnull_attribute__ (2); 305 306/* Look up the DIE in a reference-form attribute. */ 307extern Dwarf_Die *dwarf_formref_die (Dwarf_Attribute *attr, Dwarf_Die *die_mem) 308 __nonnull_attribute__ (2); 309 310/* Return block represented by attribute. */ 311extern int dwarf_formblock (Dwarf_Attribute *attr, Dwarf_Block *return_block) 312 __nonnull_attribute__ (2); 313 314/* Return flag represented by attribute. */ 315extern int dwarf_formflag (Dwarf_Attribute *attr, bool *return_bool) 316 __nonnull_attribute__ (2); 317 318 319/* Simplified attribute value access functions. */ 320 321/* Return string in name attribute of DIE. */ 322extern const char *dwarf_diename (Dwarf_Die *die); 323 324/* Return high PC attribute of DIE. */ 325extern int dwarf_highpc (Dwarf_Die *die, Dwarf_Addr *return_addr) 326 __nonnull_attribute__ (2); 327 328/* Return low PC attribute of DIE. */ 329extern int dwarf_lowpc (Dwarf_Die *die, Dwarf_Addr *return_addr) 330 __nonnull_attribute__ (2); 331 332/* Return entry_pc or low_pc attribute of DIE. */ 333extern int dwarf_entrypc (Dwarf_Die *die, Dwarf_Addr *return_addr) 334 __nonnull_attribute__ (2); 335 336/* Return 1 if DIE's lowpc/highpc or ranges attributes match the PC address, 337 0 if not, or -1 for errors. */ 338extern int dwarf_haspc (Dwarf_Die *die, Dwarf_Addr pc); 339 340/* Enumerate the PC address ranges covered by this DIE, covering all 341 addresses where dwarf_haspc returns true. In the first call OFFSET 342 should be zero and *BASEP need not be initialized. Returns -1 for 343 errors, zero when there are no more address ranges to report, or a 344 nonzero OFFSET value to pass to the next call. Each subsequent call 345 must preserve *BASEP from the prior call. Successful calls fill in 346 *STARTP and *ENDP with a contiguous address range. */ 347extern ptrdiff_t dwarf_ranges (Dwarf_Die *die, 348 ptrdiff_t offset, Dwarf_Addr *basep, 349 Dwarf_Addr *startp, Dwarf_Addr *endp); 350 351 352/* Return byte size attribute of DIE. */ 353extern int dwarf_bytesize (Dwarf_Die *die); 354 355/* Return bit size attribute of DIE. */ 356extern int dwarf_bitsize (Dwarf_Die *die); 357 358/* Return bit offset attribute of DIE. */ 359extern int dwarf_bitoffset (Dwarf_Die *die); 360 361/* Return array order attribute of DIE. */ 362extern int dwarf_arrayorder (Dwarf_Die *die); 363 364/* Return source language attribute of DIE. */ 365extern int dwarf_srclang (Dwarf_Die *die); 366 367 368/* Get abbreviation at given offset for given DIE. */ 369extern Dwarf_Abbrev *dwarf_getabbrev (Dwarf_Die *die, Dwarf_Off offset, 370 size_t *lengthp); 371 372/* Get abbreviation at given offset in .debug_abbrev section. */ 373extern int dwarf_offabbrev (Dwarf *dbg, Dwarf_Off offset, size_t *lengthp, 374 Dwarf_Abbrev *abbrevp) 375 __nonnull_attribute__ (4); 376 377/* Get abbreviation code. */ 378extern unsigned int dwarf_getabbrevcode (Dwarf_Abbrev *abbrev); 379 380/* Get abbreviation tag. */ 381extern unsigned int dwarf_getabbrevtag (Dwarf_Abbrev *abbrev); 382 383/* Return true if abbreviation is children flag set. */ 384extern int dwarf_abbrevhaschildren (Dwarf_Abbrev *abbrev); 385 386/* Get number of attributes of abbreviation. */ 387extern int dwarf_getattrcnt (Dwarf_Abbrev *abbrev, size_t *attrcntp) 388 __nonnull_attribute__ (2); 389 390/* Get specific attribute of abbreviation. */ 391extern int dwarf_getabbrevattr (Dwarf_Abbrev *abbrev, size_t idx, 392 unsigned int *namep, unsigned int *formp, 393 Dwarf_Off *offset); 394 395 396/* Get string from-debug_str section. */ 397extern const char *dwarf_getstring (Dwarf *dbg, Dwarf_Off offset, 398 size_t *lenp); 399 400 401/* Get public symbol information. */ 402extern ptrdiff_t dwarf_getpubnames (Dwarf *dbg, 403 int (*callback) (Dwarf *, Dwarf_Global *, 404 void *), 405 void *arg, ptrdiff_t offset) 406 __nonnull_attribute__ (2); 407 408 409/* Get source file information for CU. */ 410extern int dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines, 411 size_t *nlines) __nonnull_attribute__ (2, 3); 412 413/* Return one of the source lines of the CU. */ 414extern Dwarf_Line *dwarf_onesrcline (Dwarf_Lines *lines, size_t idx); 415 416/* Get the file source files used in the CU. */ 417extern int dwarf_getsrcfiles (Dwarf_Die *cudie, Dwarf_Files **files, 418 size_t *nfiles) 419 __nonnull_attribute__ (2); 420 421 422/* Get source for address in CU. */ 423extern Dwarf_Line *dwarf_getsrc_die (Dwarf_Die *cudie, Dwarf_Addr addr); 424 425/* Get source for file and line number. */ 426extern int dwarf_getsrc_file (Dwarf *dbg, const char *fname, int line, int col, 427 Dwarf_Line ***srcsp, size_t *nsrcs) 428 __nonnull_attribute__ (2, 5, 6); 429 430 431/* Return line address. */ 432extern int dwarf_lineaddr (Dwarf_Line *line, Dwarf_Addr *addrp); 433 434/* Return line number. */ 435extern int dwarf_lineno (Dwarf_Line *line, int *linep) 436 __nonnull_attribute__ (2); 437 438/* Return column in line. */ 439extern int dwarf_linecol (Dwarf_Line *line, int *colp) 440 __nonnull_attribute__ (2); 441 442/* Return true if record is for beginning of a statement. */ 443extern int dwarf_linebeginstatement (Dwarf_Line *line, bool *flagp) 444 __nonnull_attribute__ (2); 445 446/* Return true if record is for end of sequence. */ 447extern int dwarf_lineendsequence (Dwarf_Line *line, bool *flagp) 448 __nonnull_attribute__ (2); 449 450/* Return true if record is for beginning of a basic block. */ 451extern int dwarf_lineblock (Dwarf_Line *line, bool *flagp) 452 __nonnull_attribute__ (2); 453 454/* Return true if record is for end of prologue. */ 455extern int dwarf_lineprologueend (Dwarf_Line *line, bool *flagp) 456 __nonnull_attribute__ (2); 457 458/* Return true if record is for beginning of epilogue. */ 459extern int dwarf_lineepiloguebegin (Dwarf_Line *line, bool *flagp) 460 __nonnull_attribute__ (2); 461 462 463/* Find line information for address. */ 464extern const char *dwarf_linesrc (Dwarf_Line *line, 465 Dwarf_Word *mtime, Dwarf_Word *length); 466 467/* Return file information. */ 468extern const char *dwarf_filesrc (Dwarf_Files *file, size_t idx, 469 Dwarf_Word *mtime, Dwarf_Word *length); 470 471 472/* Return location expression, decoded as a list of operations. */ 473extern int dwarf_getlocation (Dwarf_Attribute *attr, Dwarf_Op **expr, 474 size_t *exprlen) __nonnull_attribute__ (2, 3); 475 476/* Return location expressions. If the attribute uses a location list, 477 ADDRESS selects the relevant location expressions from the list. 478 There can be multiple matches, resulting in multiple expressions to 479 return. EXPRS and EXPRLENS are parallel arrays of NLOCS slots to 480 fill in. Returns the number of locations filled in, or -1 for 481 errors. If EXPRS is a null pointer, stores nothing and returns the 482 total number of locations. A return value of zero means that the 483 location list indicated no value is accessible. */ 484extern int dwarf_getlocation_addr (Dwarf_Attribute *attr, Dwarf_Addr address, 485 Dwarf_Op **exprs, size_t *exprlens, 486 size_t nlocs); 487 488 489/* Return scope DIEs containing PC address. 490 Sets *SCOPES to a malloc'd array of Dwarf_Die structures, 491 and returns the number of elements in the array. 492 (*SCOPES)[0] is the DIE for the innermost scope containing PC, 493 (*SCOPES)[1] is the DIE for the scope containing that scope, and so on. 494 Returns -1 for errors or 0 if no scopes match PC. */ 495extern int dwarf_getscopes (Dwarf_Die *cudie, Dwarf_Addr pc, 496 Dwarf_Die **scopes); 497 498/* Return scope DIEs containing the given DIE. 499 Sets *SCOPES to a malloc'd array of Dwarf_Die structures, 500 and returns the number of elements in the array. 501 (*SCOPES)[0] is a copy of DIE. 502 (*SCOPES)[1] is the DIE for the scope containing that scope, and so on. 503 Returns -1 for errors or 0 if DIE is not found in any scope entry. */ 504extern int dwarf_getscopes_die (Dwarf_Die *die, Dwarf_Die **scopes); 505 506 507/* Search SCOPES[0..NSCOPES-1] for a variable called NAME. 508 Ignore the first SKIP_SHADOWS scopes that match the name. 509 If MATCH_FILE is not null, accept only declaration in that source file; 510 if MATCH_LINENO or MATCH_LINECOL are also nonzero, accept only declaration 511 at that line and column. 512 513 If successful, fill in *RESULT with the DIE of the variable found, 514 and return N where SCOPES[N] is the scope defining the variable. 515 Return -1 for errors or -2 for no matching variable found. */ 516extern int dwarf_getscopevar (Dwarf_Die *scopes, int nscopes, 517 const char *name, int skip_shadows, 518 const char *match_file, 519 int match_lineno, int match_linecol, 520 Dwarf_Die *result); 521 522 523 524/* Return list address ranges. */ 525extern int dwarf_getaranges (Dwarf *dbg, Dwarf_Aranges **aranges, 526 size_t *naranges) 527 __nonnull_attribute__ (2); 528 529/* Return one of the address range entries. */ 530extern Dwarf_Arange *dwarf_onearange (Dwarf_Aranges *aranges, size_t idx); 531 532/* Return information in address range record. */ 533extern int dwarf_getarangeinfo (Dwarf_Arange *arange, Dwarf_Addr *addrp, 534 Dwarf_Word *lengthp, Dwarf_Off *offsetp); 535 536/* Get address range which includes given address. */ 537extern Dwarf_Arange *dwarf_getarange_addr (Dwarf_Aranges *aranges, 538 Dwarf_Addr addr); 539 540 541 542/* Get functions in CUDIE. */ 543extern ptrdiff_t dwarf_getfuncs (Dwarf_Die *cudie, 544 int (*callback) (Dwarf_Die *, void *), 545 void *arg, ptrdiff_t offset); 546 547 548/* Return file name containing definition of the given declaration. */ 549extern const char *dwarf_decl_file (Dwarf_Die *decl); 550 551/* Get line number of beginning of given declaration. */ 552extern int dwarf_decl_line (Dwarf_Die *decl, int *linep) 553 __nonnull_attribute__ (2); 554 555/* Get column number of beginning of given declaration. */ 556extern int dwarf_decl_column (Dwarf_Die *decl, int *colp) 557 __nonnull_attribute__ (2); 558 559 560/* Return nonzero if given function is an abstract inline definition. */ 561extern int dwarf_func_inline (Dwarf_Die *func); 562 563/* Find each concrete inlined instance of the abstract inline definition. */ 564extern int dwarf_func_inline_instances (Dwarf_Die *func, 565 int (*callback) (Dwarf_Die *, void *), 566 void *arg); 567 568 569/* Find the appropriate PC location or locations for function entry 570 breakpoints for the given DW_TAG_subprogram DIE. Returns -1 for errors. 571 On success, returns the number of breakpoint locations (never zero) 572 and sets *BKPTS to a malloc'd vector of addresses. */ 573extern int dwarf_entry_breakpoints (Dwarf_Die *die, Dwarf_Addr **bkpts); 574 575 576/* Call callback function for each of the macro information entry for 577 the CU. */ 578extern ptrdiff_t dwarf_getmacros (Dwarf_Die *cudie, 579 int (*callback) (Dwarf_Macro *, void *), 580 void *arg, ptrdiff_t offset) 581 __nonnull_attribute__ (2); 582 583/* Return macro opcode. */ 584extern int dwarf_macro_opcode (Dwarf_Macro *macro, unsigned int *opcodep) 585 __nonnull_attribute__ (2); 586 587/* Return first macro parameter. */ 588extern int dwarf_macro_param1 (Dwarf_Macro *macro, Dwarf_Word *paramp) 589 __nonnull_attribute__ (2); 590 591/* Return second macro parameter. */ 592extern int dwarf_macro_param2 (Dwarf_Macro *macro, Dwarf_Word *paramp, 593 const char **strp); 594 595 596/* Return error code of last failing function call. This value is kept 597 separately for each thread. */ 598extern int dwarf_errno (void); 599 600/* Return error string for ERROR. If ERROR is zero, return error string 601 for most recent error or NULL is none occurred. If ERROR is -1 the 602 behaviour is similar to the last case except that not NULL but a legal 603 string is returned. */ 604extern const char *dwarf_errmsg (int err); 605 606 607/* Register new Out-Of-Memory handler. The old handler is returned. */ 608extern Dwarf_OOM dwarf_new_oom_handler (Dwarf *dbg, Dwarf_OOM handler); 609 610 611/* Inline optimizations. */ 612#ifdef __OPTIMIZE__ 613/* Return attribute code of given attribute. */ 614extern inline unsigned int 615dwarf_whatattr (Dwarf_Attribute *attr) 616{ 617 return attr == NULL ? 0 : attr->code; 618} 619 620/* Return attribute code of given attribute. */ 621extern inline unsigned int 622dwarf_whatform (Dwarf_Attribute *attr) 623{ 624 return attr == NULL ? 0 : attr->form; 625} 626#endif /* Optimize. */ 627 628#endif /* libdw.h */ 629