LCOV - code coverage report
Current view: top level - libdw - libdw.h (source / functions) Hit Total Coverage
Test: elfutils-0.172 Lines: 2 2 100.0 %
Date: 2018-06-11 22:52:14 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* Interfaces for libdw.
       2             :    Copyright (C) 2002-2010, 2013, 2014, 2016, 2018 Red Hat, Inc.
       3             :    This file is part of elfutils.
       4             : 
       5             :    This file is free software; you can redistribute it and/or modify
       6             :    it under the terms of either
       7             : 
       8             :      * the GNU Lesser General Public License as published by the Free
       9             :        Software Foundation; either version 3 of the License, or (at
      10             :        your option) any later version
      11             : 
      12             :    or
      13             : 
      14             :      * the GNU General Public License as published by the Free
      15             :        Software Foundation; either version 2 of the License, or (at
      16             :        your option) any later version
      17             : 
      18             :    or both in parallel, as here.
      19             : 
      20             :    elfutils is distributed in the hope that it will be useful, but
      21             :    WITHOUT ANY WARRANTY; without even the implied warranty of
      22             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      23             :    General Public License for more details.
      24             : 
      25             :    You should have received copies of the GNU General Public License and
      26             :    the GNU Lesser General Public License along with this program.  If
      27             :    not, see <http://www.gnu.org/licenses/>.  */
      28             : 
      29             : #ifndef _LIBDW_H
      30             : #define _LIBDW_H        1
      31             : 
      32             : #include <gelf.h>
      33             : #include <stdbool.h>
      34             : #include <stddef.h>
      35             : #include <stdint.h>
      36             : 
      37             : /* Mode for the session.  */
      38             : typedef enum
      39             :   {
      40             :     DWARF_C_READ,               /* Read .. */
      41             :     DWARF_C_RDWR,               /* Read and write .. */
      42             :     DWARF_C_WRITE,              /* Write .. */
      43             :   }
      44             : Dwarf_Cmd;
      45             : 
      46             : 
      47             : /* Callback results.  */
      48             : enum
      49             : {
      50             :   DWARF_CB_OK = 0,
      51             :   DWARF_CB_ABORT
      52             : };
      53             : 
      54             : 
      55             : /* Error values.  */
      56             : enum
      57             :   {
      58             :     DW_TAG_invalid = 0
      59             : #define DW_TAG_invalid  DW_TAG_invalid
      60             :   };
      61             : 
      62             : 
      63             : /* Type for offset in DWARF file.  */
      64             : typedef GElf_Off Dwarf_Off;
      65             : 
      66             : /* Type for address in DWARF file.  */
      67             : typedef GElf_Addr Dwarf_Addr;
      68             : 
      69             : /* Integer types.  Big enough to hold any numeric value.  */
      70             : typedef GElf_Xword Dwarf_Word;
      71             : typedef GElf_Sxword Dwarf_Sword;
      72             : /* For the times we know we do not need that much.  */
      73             : typedef GElf_Half Dwarf_Half;
      74             : 
      75             : 
      76             : /* DWARF abbreviation record.  */
      77             : typedef struct Dwarf_Abbrev Dwarf_Abbrev;
      78             : 
      79             : /* Returned to show the last DIE has be returned.  */
      80             : #define DWARF_END_ABBREV ((Dwarf_Abbrev *) -1l)
      81             : 
      82             : /* Source code line information for CU.  */
      83             : typedef struct Dwarf_Lines_s Dwarf_Lines;
      84             : 
      85             : /* One source code line information.  */
      86             : typedef struct Dwarf_Line_s Dwarf_Line;
      87             : 
      88             : /* Source file information.  */
      89             : typedef struct Dwarf_Files_s Dwarf_Files;
      90             : 
      91             : /* One address range record.  */
      92             : typedef struct Dwarf_Arange_s Dwarf_Arange;
      93             : 
      94             : /* Address ranges of a file.  */
      95             : typedef struct Dwarf_Aranges_s Dwarf_Aranges;
      96             : 
      97             : /* CU representation.  */
      98             : struct Dwarf_CU;
      99             : typedef struct Dwarf_CU Dwarf_CU;
     100             : 
     101             : /* Macro information.  */
     102             : typedef struct Dwarf_Macro_s Dwarf_Macro;
     103             : 
     104             : /* Attribute representation.  */
     105             : typedef struct
     106             : {
     107             :   unsigned int code;
     108             :   unsigned int form;
     109             :   unsigned char *valp;
     110             :   struct Dwarf_CU *cu;
     111             : } Dwarf_Attribute;
     112             : 
     113             : 
     114             : /* Data block representation.  */
     115             : typedef struct
     116             : {
     117             :   Dwarf_Word length;
     118             :   unsigned char *data;
     119             : } Dwarf_Block;
     120             : 
     121             : 
     122             : /* DIE information.  */
     123             : typedef struct
     124             : {
     125             :   /* The offset can be computed from the address.  */
     126             :   void *addr;
     127             :   struct Dwarf_CU *cu;
     128             :   Dwarf_Abbrev *abbrev;
     129             :   // XXX We'll see what other information will be needed.
     130             :   long int padding__;
     131             : } Dwarf_Die;
     132             : 
     133             : /* Returned to show the last DIE has be returned.  */
     134             : #define DWARF_END_DIE ((Dwarf_Die *) -1l)
     135             : 
     136             : 
     137             : /* Global symbol information.  */
     138             : typedef struct
     139             : {
     140             :   Dwarf_Off cu_offset;
     141             :   Dwarf_Off die_offset;
     142             :   const char *name;
     143             : } Dwarf_Global;
     144             : 
     145             : 
     146             : /* One operation in a DWARF location expression.
     147             :    A location expression is an array of these.  */
     148             : typedef struct
     149             : {
     150             :   uint8_t atom;                 /* Operation */
     151             :   Dwarf_Word number;            /* Operand */
     152             :   Dwarf_Word number2;           /* Possible second operand */
     153             :   Dwarf_Word offset;            /* Offset in location expression */
     154             : } Dwarf_Op;
     155             : 
     156             : 
     157             : /* This describes one Common Information Entry read from a CFI section.
     158             :    Pointers here point into the DATA->d_buf block passed to dwarf_next_cfi.  */
     159             : typedef struct
     160             : {
     161             :   Dwarf_Off CIE_id;      /* Always DW_CIE_ID_64 in Dwarf_CIE structures.  */
     162             : 
     163             :   /* Instruction stream describing initial state used by FDEs.  If
     164             :      we did not understand the whole augmentation string and it did
     165             :      not use 'z', then there might be more augmentation data here
     166             :      (and in FDEs) before the actual instructions.  */
     167             :   const uint8_t *initial_instructions;
     168             :   const uint8_t *initial_instructions_end;
     169             : 
     170             :   Dwarf_Word code_alignment_factor;
     171             :   Dwarf_Sword data_alignment_factor;
     172             :   Dwarf_Word return_address_register;
     173             : 
     174             :   const char *augmentation;     /* Augmentation string.  */
     175             : 
     176             :   /* Augmentation data, might be NULL.  The size is correct only if
     177             :      we understood the augmentation string sufficiently.  */
     178             :   const uint8_t *augmentation_data;
     179             :   size_t augmentation_data_size;
     180             :   size_t fde_augmentation_data_size;
     181             : } Dwarf_CIE;
     182             : 
     183             : /* This describes one Frame Description Entry read from a CFI section.
     184             :    Pointers here point into the DATA->d_buf block passed to dwarf_next_cfi.  */
     185             : typedef struct
     186             : {
     187             :   /* Section offset of CIE this FDE refers to.  This will never be
     188             :      DW_CIE_ID_64 in an FDE.  If this value is DW_CIE_ID_64, this is
     189             :      actually a Dwarf_CIE structure.  */
     190             :   Dwarf_Off CIE_pointer;
     191             : 
     192             :   /* We can't really decode anything further without looking up the CIE
     193             :      and checking its augmentation string.  Here follows the encoded
     194             :      initial_location and address_range, then any augmentation data,
     195             :      then the instruction stream.  This FDE describes PC locations in
     196             :      the byte range [initial_location, initial_location+address_range).
     197             :      When the CIE augmentation string uses 'z', the augmentation data is
     198             :      a DW_FORM_block (self-sized).  Otherwise, when we understand the
     199             :      augmentation string completely, fde_augmentation_data_size gives
     200             :      the number of bytes of augmentation data before the instructions.  */
     201             :   const uint8_t *start;
     202             :   const uint8_t *end;
     203             : } Dwarf_FDE;
     204             : 
     205             : /* Each entry in a CFI section is either a CIE described by Dwarf_CIE or
     206             :    an FDE described by Dward_FDE.  Check CIE_id to see which you have.  */
     207             : typedef union
     208             : {
     209             :   Dwarf_Off CIE_id;      /* Always DW_CIE_ID_64 in Dwarf_CIE structures.  */
     210             :   Dwarf_CIE cie;
     211             :   Dwarf_FDE fde;
     212             : } Dwarf_CFI_Entry;
     213             : 
     214             : /* Same as DW_CIE_ID_64 from dwarf.h to keep libdw.h independent.  */
     215             : #define LIBDW_CIE_ID 0xffffffffffffffffULL
     216             : #define dwarf_cfi_cie_p(entry)  ((entry)->cie.CIE_id == LIBDW_CIE_ID)
     217             : 
     218             : /* Opaque type representing a frame state described by CFI.  */
     219             : typedef struct Dwarf_Frame_s Dwarf_Frame;
     220             : 
     221             : /* Opaque type representing a CFI section found in a DWARF or ELF file.  */
     222             : typedef struct Dwarf_CFI_s Dwarf_CFI;
     223             : 
     224             : 
     225             : /* Handle for debug sessions.  */
     226             : typedef struct Dwarf Dwarf;
     227             : 
     228             : 
     229             : /* Out-Of-Memory handler.  */
     230             : typedef void (*__noreturn_attribute__ Dwarf_OOM) (void);
     231             : 
     232             : 
     233             : #ifdef __cplusplus
     234             : extern "C" {
     235             : #endif
     236             : 
     237             : /* Create a handle for a new debug session.  */
     238             : extern Dwarf *dwarf_begin (int fildes, Dwarf_Cmd cmd);
     239             : 
     240             : /* Create a handle for a new debug session for an ELF file.  */
     241             : extern Dwarf *dwarf_begin_elf (Elf *elf, Dwarf_Cmd cmd, Elf_Scn *scngrp);
     242             : 
     243             : /* Retrieve ELF descriptor used for DWARF access.  */
     244             : extern Elf *dwarf_getelf (Dwarf *dwarf);
     245             : 
     246             : /* Retieve DWARF descriptor used for a Dwarf_Die or Dwarf_Attribute.
     247             :    A Dwarf_Die or a Dwarf_Attribute is associated with a particular
     248             :    Dwarf_CU handle.  This function returns the DWARF descriptor for
     249             :    that Dwarf_CU.  */
     250             : extern Dwarf *dwarf_cu_getdwarf (Dwarf_CU *cu);
     251             : 
     252             : /* Retrieves the DWARF descriptor for debugaltlink data.  Returns NULL
     253             :    if no alternate debug data has been supplied yet.  libdw will try
     254             :    to set the alt file on first use of an alt FORM if not yet explicitly
     255             :    provided by dwarf_setalt.  */
     256             : extern Dwarf *dwarf_getalt (Dwarf *main);
     257             : 
     258             : /* Provides the data referenced by the .gnu_debugaltlink section.  The
     259             :    caller should check that MAIN and ALT match (i.e., they have the
     260             :    same build ID).  It is the responsibility of the caller to ensure
     261             :    that the data referenced by ALT stays valid while it is used by
     262             :    MAIN, until dwarf_setalt is called on MAIN with a different
     263             :    descriptor, or dwarf_end.  Must be called before inspecting DIEs
     264             :    that might have alt FORMs.  Otherwise libdw will try to set the
     265             :    alt file itself on first use.  */
     266             : extern void dwarf_setalt (Dwarf *main, Dwarf *alt);
     267             : 
     268             : /* Release debugging handling context.  */
     269             : extern int dwarf_end (Dwarf *dwarf);
     270             : 
     271             : 
     272             : /* Get the data block for the .debug_info section.  */
     273             : extern Elf_Data *dwarf_getscn_info (Dwarf *dwarf);
     274             : 
     275             : /* Read the header for the DWARF CU.  */
     276             : extern int dwarf_nextcu (Dwarf *dwarf, Dwarf_Off off, Dwarf_Off *next_off,
     277             :                          size_t *header_sizep, Dwarf_Off *abbrev_offsetp,
     278             :                          uint8_t *address_sizep, uint8_t *offset_sizep)
     279             :      __nonnull_attribute__ (3);
     280             : 
     281             : /* Read the header of a DWARF CU or type unit.  If TYPE_SIGNATUREP is not
     282             :    null, this reads a type unit from the .debug_types section; otherwise
     283             :    this reads a CU from the .debug_info section.  */
     284             : extern int dwarf_next_unit (Dwarf *dwarf, Dwarf_Off off, Dwarf_Off *next_off,
     285             :                             size_t *header_sizep, Dwarf_Half *versionp,
     286             :                             Dwarf_Off *abbrev_offsetp,
     287             :                             uint8_t *address_sizep, uint8_t *offset_sizep,
     288             :                             uint64_t *type_signaturep, Dwarf_Off *type_offsetp)
     289             :      __nonnull_attribute__ (3);
     290             : 
     291             : 
     292             : /* Gets the next Dwarf_CU (unit), version, unit type and if available
     293             :    the CU DIE and sub (type) DIE of the unit.  Returns 0 on success,
     294             :    -1 on error or 1 if there are no more units.  To start iterating
     295             :    provide NULL for CU.  If version < 5 the unit type is set from the
     296             :    CU DIE if available (DW_UT_compile for DW_TAG_compile_unit,
     297             :    DW_UT_type for DW_TAG_type_unit or DW_UT_partial for
     298             :    DW_TAG_partial_unit), otherwise it is set to zero.  If unavailable
     299             :    (the version or unit type is unknown) the CU DIE is cleared.
     300             :    Likewise if the sub DIE isn't isn't available (the unit type is not
     301             :    DW_UT_type or DW_UT_split_type) the sub DIE tag is cleared.  */
     302             : extern int dwarf_get_units (Dwarf *dwarf, Dwarf_CU *cu, Dwarf_CU **next_cu,
     303             :                             Dwarf_Half *version, uint8_t *unit_type,
     304             :                             Dwarf_Die *cudie, Dwarf_Die *subdie)
     305             :      __nonnull_attribute__ (3);
     306             : 
     307             : /* Provides information and DIEs associated with the given Dwarf_CU
     308             :    unit.  Returns -1 on error, zero on success. Arguments not needed
     309             :    may be NULL.  If they are NULL and aren't known yet, they won't be
     310             :    looked up.  If the subdie doesn't exist for this unit_type it will
     311             :    be cleared.  If there is no unit_id for this unit type it will be
     312             :    set to zero.  */
     313             : extern int dwarf_cu_info (Dwarf_CU *cu,
     314             :                           Dwarf_Half *version, uint8_t *unit_type,
     315             :                           Dwarf_Die *cudie, Dwarf_Die *subdie,
     316             :                           uint64_t *unit_id,
     317             :                           uint8_t *address_size, uint8_t *offset_size);
     318             : 
     319             : /* Decode one DWARF CFI entry (CIE or FDE) from the raw section data.
     320             :    The E_IDENT from the originating ELF file indicates the address
     321             :    size and byte order used in the CFI section contained in DATA;
     322             :    EH_FRAME_P should be true for .eh_frame format and false for
     323             :    .debug_frame format.  OFFSET is the byte position in the section
     324             :    to start at; on return *NEXT_OFFSET is filled in with the byte
     325             :    position immediately after this entry.
     326             : 
     327             :    On success, returns 0 and fills in *ENTRY; use dwarf_cfi_cie_p to
     328             :    see whether ENTRY->cie or ENTRY->fde is valid.
     329             : 
     330             :    On errors, returns -1.  Some format errors will permit safely
     331             :    skipping to the next CFI entry though the current one is unusable.
     332             :    In that case, *NEXT_OFF will be updated before a -1 return.
     333             : 
     334             :    If there are no more CFI entries left in the section,
     335             :    returns 1 and sets *NEXT_OFFSET to (Dwarf_Off) -1.  */
     336             : extern int dwarf_next_cfi (const unsigned char e_ident[],
     337             :                            Elf_Data *data, bool eh_frame_p,
     338             :                            Dwarf_Off offset, Dwarf_Off *next_offset,
     339             :                            Dwarf_CFI_Entry *entry)
     340             :   __nonnull_attribute__ (1, 2, 5, 6);
     341             : 
     342             : /* Use the CFI in the DWARF .debug_frame section.
     343             :    Returns NULL if there is no such section (not an error).
     344             :    The pointer returned can be used until dwarf_end is called on DWARF,
     345             :    and must not be passed to dwarf_cfi_end.
     346             :    Calling this more than once returns the same pointer.  */
     347             : extern Dwarf_CFI *dwarf_getcfi (Dwarf *dwarf);
     348             : 
     349             : /* Use the CFI in the ELF file's exception-handling data.
     350             :    Returns NULL if there is no such data.
     351             :    The pointer returned can be used until elf_end is called on ELF,
     352             :    and must be passed to dwarf_cfi_end before then.
     353             :    Calling this more than once allocates independent data structures.  */
     354             : extern Dwarf_CFI *dwarf_getcfi_elf (Elf *elf);
     355             : 
     356             : /* Release resources allocated by dwarf_getcfi_elf.  */
     357             : extern int dwarf_cfi_end (Dwarf_CFI *cache);
     358             : 
     359             : 
     360             : /* Return DIE at given offset in .debug_info section.  */
     361             : extern Dwarf_Die *dwarf_offdie (Dwarf *dbg, Dwarf_Off offset,
     362             :                                 Dwarf_Die *result) __nonnull_attribute__ (3);
     363             : 
     364             : /* Return DIE at given offset in .debug_types section.  */
     365             : extern Dwarf_Die *dwarf_offdie_types (Dwarf *dbg, Dwarf_Off offset,
     366             :                                       Dwarf_Die *result)
     367             :      __nonnull_attribute__ (3);
     368             : 
     369             : /* Return offset of DIE.  */
     370             : extern Dwarf_Off dwarf_dieoffset (Dwarf_Die *die);
     371             : 
     372             : /* Return offset of DIE in CU.  */
     373             : extern Dwarf_Off dwarf_cuoffset (Dwarf_Die *die);
     374             : 
     375             : /* Return CU DIE containing given DIE.  */
     376             : extern Dwarf_Die *dwarf_diecu (Dwarf_Die *die, Dwarf_Die *result,
     377             :                                uint8_t *address_sizep, uint8_t *offset_sizep)
     378             :      __nonnull_attribute__ (2);
     379             : 
     380             : /* Given a Dwarf_Die addr returns a (reconstructed) Dwarf_Die, or NULL
     381             :    if the given addr didn't come from a valid Dwarf_Die.  In particular
     382             :    it will make sure that the correct Dwarf_CU pointer is set for the
     383             :    Dwarf_Die, the Dwarf_Abbrev pointer will not be set up yet (it will
     384             :    only be once the Dwarf_Die is used to read attributes, children or
     385             :    siblings).  This functions can be used to keep a reference to a
     386             :    Dwarf_Die which you want to refer to later.  The addr, and the result
     387             :    of this function, is only valid while the associated Dwarf is valid.  */
     388             : extern Dwarf_Die *dwarf_die_addr_die (Dwarf *dbg, void *addr,
     389             :                                       Dwarf_Die *result)
     390             :      __nonnull_attribute__ (3);
     391             : 
     392             : /* Return the CU DIE and the header info associated with a Dwarf_Die
     393             :    or Dwarf_Attribute.  A Dwarf_Die or a Dwarf_Attribute is associated
     394             :    with a particular Dwarf_CU handle.  This function returns the CU or
     395             :    type unit DIE and header information for that Dwarf_CU.  The
     396             :    returned DIE is either a compile_unit, partial_unit or type_unit.
     397             :    If it is a type_unit, then the type signature and type offset are
     398             :    also provided, otherwise type_offset will be set to zero.  See also
     399             :    dwarf_diecu and dwarf_next_unit.  */
     400             : extern Dwarf_Die *dwarf_cu_die (Dwarf_CU *cu, Dwarf_Die *result,
     401             :                                 Dwarf_Half *versionp,
     402             :                                 Dwarf_Off *abbrev_offsetp,
     403             :                                 uint8_t *address_sizep,
     404             :                                 uint8_t *offset_sizep,
     405             :                                 uint64_t *type_signaturep,
     406             :                                 Dwarf_Off *type_offsetp)
     407             :      __nonnull_attribute__ (2);
     408             : 
     409             : /* Return CU DIE containing given address.  */
     410             : extern Dwarf_Die *dwarf_addrdie (Dwarf *dbg, Dwarf_Addr addr,
     411             :                                  Dwarf_Die *result) __nonnull_attribute__ (3);
     412             : 
     413             : /* Return child of current DIE.  */
     414             : extern int dwarf_child (Dwarf_Die *die, Dwarf_Die *result)
     415             :      __nonnull_attribute__ (2);
     416             : 
     417             : /* Locates the first sibling of DIE and places it in RESULT.
     418             :    Returns 0 if a sibling was found, -1 if something went wrong.
     419             :    Returns 1 if no sibling could be found and, if RESULT is not
     420             :    the same as DIE, it sets RESULT->addr to the address of the
     421             :    (non-sibling) DIE that follows this one, or NULL if this DIE
     422             :    was the last one in the compilation unit.  */
     423             : extern int dwarf_siblingof (Dwarf_Die *die, Dwarf_Die *result)
     424             :      __nonnull_attribute__ (2);
     425             : 
     426             : /* For type aliases and qualifier type DIEs, which don't modify or
     427             :    change the structural layout of the underlying type, follow the
     428             :    DW_AT_type attribute (recursively) and return the underlying type
     429             :    Dwarf_Die.
     430             : 
     431             :    Returns 0 when RESULT contains a Dwarf_Die (possibly equal to the
     432             :    given DIE) that isn't a type alias or qualifier type.  Returns 1
     433             :    when RESULT contains a type alias or qualifier Dwarf_Die that
     434             :    couldn't be peeled further (it doesn't have a DW_TAG_type
     435             :    attribute).  Returns -1 when an error occured.
     436             : 
     437             :    The current DWARF specification defines one type alias tag
     438             :    (DW_TAG_typedef) and seven modifier/qualifier type tags
     439             :    (DW_TAG_const_type, DW_TAG_volatile_type, DW_TAG_restrict_type,
     440             :    DW_TAG_atomic_type, DW_TAG_immutable_type, DW_TAG_packed_type and
     441             :    DW_TAG_shared_type).  This function won't peel modifier type
     442             :    tags that change the way the underlying type is accessed such
     443             :    as the pointer or reference type tags (DW_TAG_pointer_type,
     444             :    DW_TAG_reference_type or DW_TAG_rvalue_reference_type).
     445             : 
     446             :    A future version of this function might peel other alias or
     447             :    qualifier type tags if a future DWARF version or GNU extension
     448             :    defines other type aliases or qualifier type tags that don't modify,
     449             :    change the structural layout or the way to access the underlying type.  */
     450             : extern int dwarf_peel_type (Dwarf_Die *die, Dwarf_Die *result)
     451             :     __nonnull_attribute__ (2);
     452             : 
     453             : /* Check whether the DIE has children.  */
     454             : extern int dwarf_haschildren (Dwarf_Die *die) __nonnull_attribute__ (1);
     455             : 
     456             : /* Walks the attributes of DIE, starting at the one OFFSET bytes in,
     457             :    calling the CALLBACK function for each one.  Stops if the callback
     458             :    function ever returns a value other than DWARF_CB_OK and returns the
     459             :    offset of the offending attribute.  If the end of the attributes
     460             :    is reached 1 is returned.  If something goes wrong -1 is returned and
     461             :    the dwarf error number is set.  */
     462             : extern ptrdiff_t dwarf_getattrs (Dwarf_Die *die,
     463             :                                  int (*callback) (Dwarf_Attribute *, void *),
     464             :                                  void *arg, ptrdiff_t offset)
     465             :      __nonnull_attribute__ (2);
     466             : 
     467             : /* Return tag of given DIE.  */
     468             : extern int dwarf_tag (Dwarf_Die *die) __nonnull_attribute__ (1);
     469             : 
     470             : 
     471             : /* Return specific attribute of DIE.  */
     472             : extern Dwarf_Attribute *dwarf_attr (Dwarf_Die *die, unsigned int search_name,
     473             :                                     Dwarf_Attribute *result)
     474             :      __nonnull_attribute__ (3);
     475             : 
     476             : /* Check whether given DIE has specific attribute.  */
     477             : extern int dwarf_hasattr (Dwarf_Die *die, unsigned int search_name);
     478             : 
     479             : /* These are the same as dwarf_attr and dwarf_hasattr, respectively,
     480             :    but they resolve an indirect attribute through DW_AT_abstract_origin.  */
     481             : extern Dwarf_Attribute *dwarf_attr_integrate (Dwarf_Die *die,
     482             :                                               unsigned int search_name,
     483             :                                               Dwarf_Attribute *result)
     484             :      __nonnull_attribute__ (3);
     485             : extern int dwarf_hasattr_integrate (Dwarf_Die *die, unsigned int search_name);
     486             : 
     487             : 
     488             : 
     489             : 
     490             : /* Check whether given attribute has specific form.  */
     491             : extern int dwarf_hasform (Dwarf_Attribute *attr, unsigned int search_form);
     492             : 
     493             : /* Return attribute code of given attribute.  */
     494             : extern unsigned int dwarf_whatattr (Dwarf_Attribute *attr);
     495             : 
     496             : /* Return form code of given attribute.  */
     497             : extern unsigned int dwarf_whatform (Dwarf_Attribute *attr);
     498             : 
     499             : 
     500             : /* Return string associated with given attribute.  */
     501             : extern const char *dwarf_formstring (Dwarf_Attribute *attrp);
     502             : 
     503             : /* Return unsigned constant represented by attribute.  */
     504             : extern int dwarf_formudata (Dwarf_Attribute *attr, Dwarf_Word *return_uval)
     505             :      __nonnull_attribute__ (2);
     506             : 
     507             : /* Return signed constant represented by attribute.  */
     508             : extern int dwarf_formsdata (Dwarf_Attribute *attr, Dwarf_Sword *return_uval)
     509             :      __nonnull_attribute__ (2);
     510             : 
     511             : /* Return address represented by attribute.  */
     512             : extern int dwarf_formaddr (Dwarf_Attribute *attr, Dwarf_Addr *return_addr)
     513             :      __nonnull_attribute__ (2);
     514             : 
     515             : /* This function is deprecated.  Always use dwarf_formref_die instead.
     516             :    Return reference offset represented by attribute.  */
     517             : extern int dwarf_formref (Dwarf_Attribute *attr, Dwarf_Off *return_offset)
     518             :      __nonnull_attribute__ (2) __deprecated_attribute__;
     519             : 
     520             : /* Look up the DIE in a reference-form attribute.  */
     521             : extern Dwarf_Die *dwarf_formref_die (Dwarf_Attribute *attr, Dwarf_Die *die_mem)
     522             :      __nonnull_attribute__ (2);
     523             : 
     524             : /* Return block represented by attribute.  */
     525             : extern int dwarf_formblock (Dwarf_Attribute *attr, Dwarf_Block *return_block)
     526             :      __nonnull_attribute__ (2);
     527             : 
     528             : /* Return flag represented by attribute.  */
     529             : extern int dwarf_formflag (Dwarf_Attribute *attr, bool *return_bool)
     530             :      __nonnull_attribute__ (2);
     531             : 
     532             : 
     533             : /* Simplified attribute value access functions.  */
     534             : 
     535             : /* Return string in name attribute of DIE.  */
     536             : extern const char *dwarf_diename (Dwarf_Die *die);
     537             : 
     538             : /* Return high PC attribute of DIE.  */
     539             : extern int dwarf_highpc (Dwarf_Die *die, Dwarf_Addr *return_addr)
     540             :      __nonnull_attribute__ (2);
     541             : 
     542             : /* Return low PC attribute of DIE.  */
     543             : extern int dwarf_lowpc (Dwarf_Die *die, Dwarf_Addr *return_addr)
     544             :      __nonnull_attribute__ (2);
     545             : 
     546             : /* Return entry_pc or low_pc attribute of DIE.  */
     547             : extern int dwarf_entrypc (Dwarf_Die *die, Dwarf_Addr *return_addr)
     548             :      __nonnull_attribute__ (2);
     549             : 
     550             : /* Return 1 if DIE's lowpc/highpc or ranges attributes match the PC address,
     551             :    0 if not, or -1 for errors.  */
     552             : extern int dwarf_haspc (Dwarf_Die *die, Dwarf_Addr pc);
     553             : 
     554             : /* Enumerate the PC address ranges covered by this DIE, covering all
     555             :    addresses where dwarf_haspc returns true.  In the first call OFFSET
     556             :    should be zero and *BASEP need not be initialized.  Returns -1 for
     557             :    errors, zero when there are no more address ranges to report, or a
     558             :    nonzero OFFSET value to pass to the next call.  Each subsequent call
     559             :    must preserve *BASEP from the prior call.  Successful calls fill in
     560             :    *STARTP and *ENDP with a contiguous address range.  */
     561             : extern ptrdiff_t dwarf_ranges (Dwarf_Die *die,
     562             :                                ptrdiff_t offset, Dwarf_Addr *basep,
     563             :                                Dwarf_Addr *startp, Dwarf_Addr *endp);
     564             : 
     565             : 
     566             : /* Return byte size attribute of DIE.  */
     567             : extern int dwarf_bytesize (Dwarf_Die *die);
     568             : 
     569             : /* Return bit size attribute of DIE.  */
     570             : extern int dwarf_bitsize (Dwarf_Die *die);
     571             : 
     572             : /* Return bit offset attribute of DIE.  */
     573             : extern int dwarf_bitoffset (Dwarf_Die *die);
     574             : 
     575             : /* Return array order attribute of DIE.  */
     576             : extern int dwarf_arrayorder (Dwarf_Die *die);
     577             : 
     578             : /* Return source language attribute of DIE.  */
     579             : extern int dwarf_srclang (Dwarf_Die *die);
     580             : 
     581             : 
     582             : /* Get abbreviation at given offset for given DIE.  */
     583             : extern Dwarf_Abbrev *dwarf_getabbrev (Dwarf_Die *die, Dwarf_Off offset,
     584             :                                       size_t *lengthp);
     585             : 
     586             : /* Get abbreviation at given offset in .debug_abbrev section.  */
     587             : extern int dwarf_offabbrev (Dwarf *dbg, Dwarf_Off offset, size_t *lengthp,
     588             :                             Dwarf_Abbrev *abbrevp)
     589             :      __nonnull_attribute__ (4);
     590             : 
     591             : /* Get abbreviation code.  */
     592             : extern unsigned int dwarf_getabbrevcode (Dwarf_Abbrev *abbrev);
     593             : 
     594             : /* Get abbreviation tag.  */
     595             : extern unsigned int dwarf_getabbrevtag (Dwarf_Abbrev *abbrev);
     596             : 
     597             : /* Return true if abbreviation is children flag set.  */
     598             : extern int dwarf_abbrevhaschildren (Dwarf_Abbrev *abbrev);
     599             : 
     600             : /* Get number of attributes of abbreviation.  */
     601             : extern int dwarf_getattrcnt (Dwarf_Abbrev *abbrev, size_t *attrcntp)
     602             :      __nonnull_attribute__ (2);
     603             : 
     604             : /* Get specific attribute of abbreviation.  */
     605             : extern int dwarf_getabbrevattr (Dwarf_Abbrev *abbrev, size_t idx,
     606             :                                 unsigned int *namep, unsigned int *formp,
     607             :                                 Dwarf_Off *offset);
     608             : 
     609             : /* Get specific attribute of abbreviation and any data encoded with it.
     610             :    Specifically for DW_FORM_implicit_const data will be set to the
     611             :    constant value associated.  */
     612             : extern int dwarf_getabbrevattr_data (Dwarf_Abbrev *abbrev, size_t idx,
     613             :                                      unsigned int *namep, unsigned int *formp,
     614             :                                      Dwarf_Sword *datap, Dwarf_Off *offset);
     615             : 
     616             : /* Get string from-debug_str section.  */
     617             : extern const char *dwarf_getstring (Dwarf *dbg, Dwarf_Off offset,
     618             :                                     size_t *lenp);
     619             : 
     620             : 
     621             : /* Get public symbol information.  */
     622             : extern ptrdiff_t dwarf_getpubnames (Dwarf *dbg,
     623             :                                     int (*callback) (Dwarf *, Dwarf_Global *,
     624             :                                                      void *),
     625             :                                     void *arg, ptrdiff_t offset)
     626             :      __nonnull_attribute__ (2);
     627             : 
     628             : 
     629             : /* Get source file information for CU.  */
     630             : extern int dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines,
     631             :                               size_t *nlines) __nonnull_attribute__ (2, 3);
     632             : 
     633             : /* Return one of the source lines of the CU.  */
     634             : extern Dwarf_Line *dwarf_onesrcline (Dwarf_Lines *lines, size_t idx);
     635             : 
     636             : /* Get the file source files used in the CU.  */
     637             : extern int dwarf_getsrcfiles (Dwarf_Die *cudie, Dwarf_Files **files,
     638             :                               size_t *nfiles)
     639             :      __nonnull_attribute__ (2);
     640             : 
     641             : 
     642             : /* Get source for address in CU.  */
     643             : extern Dwarf_Line *dwarf_getsrc_die (Dwarf_Die *cudie, Dwarf_Addr addr);
     644             : 
     645             : /* Get source for file and line number.  */
     646             : extern int dwarf_getsrc_file (Dwarf *dbg, const char *fname, int line, int col,
     647             :                               Dwarf_Line ***srcsp, size_t *nsrcs)
     648             :      __nonnull_attribute__ (2, 5, 6);
     649             : 
     650             : 
     651             : /* Return line address.  */
     652             : extern int dwarf_lineaddr (Dwarf_Line *line, Dwarf_Addr *addrp);
     653             : 
     654             : /* Return line VLIW operation index.  */
     655             : extern int dwarf_lineop_index (Dwarf_Line *line, unsigned int *op_indexp);
     656             : 
     657             : /* Return line number.  */
     658             : extern int dwarf_lineno (Dwarf_Line *line, int *linep)
     659             :      __nonnull_attribute__ (2);
     660             : 
     661             : /* Return column in line.  */
     662             : extern int dwarf_linecol (Dwarf_Line *line, int *colp)
     663             :      __nonnull_attribute__ (2);
     664             : 
     665             : /* Return true if record is for beginning of a statement.  */
     666             : extern int dwarf_linebeginstatement (Dwarf_Line *line, bool *flagp)
     667             :      __nonnull_attribute__ (2);
     668             : 
     669             : /* Return true if record is for end of sequence.  */
     670             : extern int dwarf_lineendsequence (Dwarf_Line *line, bool *flagp)
     671             :      __nonnull_attribute__ (2);
     672             : 
     673             : /* Return true if record is for beginning of a basic block.  */
     674             : extern int dwarf_lineblock (Dwarf_Line *line, bool *flagp)
     675             :      __nonnull_attribute__ (2);
     676             : 
     677             : /* Return true if record is for end of prologue.  */
     678             : extern int dwarf_lineprologueend (Dwarf_Line *line, bool *flagp)
     679             :      __nonnull_attribute__ (2);
     680             : 
     681             : /* Return true if record is for beginning of epilogue.  */
     682             : extern int dwarf_lineepiloguebegin (Dwarf_Line *line, bool *flagp)
     683             :      __nonnull_attribute__ (2);
     684             : 
     685             : /* Return instruction-set architecture in this record.  */
     686             : extern int dwarf_lineisa (Dwarf_Line *line, unsigned int *isap)
     687             :      __nonnull_attribute__ (2);
     688             : 
     689             : /* Return code path discriminator in this record.  */
     690             : extern int dwarf_linediscriminator (Dwarf_Line *line, unsigned int *discp)
     691             :      __nonnull_attribute__ (2);
     692             : 
     693             : 
     694             : /* Find line information for address.  The returned string is NULL when
     695             :    an error occured, or the file path.  The file path is either absolute
     696             :    or relative to the compilation directory.  See dwarf_decl_file.  */
     697             : extern const char *dwarf_linesrc (Dwarf_Line *line,
     698             :                                   Dwarf_Word *mtime, Dwarf_Word *length);
     699             : 
     700             : /* Return file information.  The returned string is NULL when
     701             :    an error occured, or the file path.  The file path is either absolute
     702             :    or relative to the compilation directory.  See dwarf_decl_file.  */
     703             : extern const char *dwarf_filesrc (Dwarf_Files *file, size_t idx,
     704             :                                   Dwarf_Word *mtime, Dwarf_Word *length);
     705             : 
     706             : /* Return the Dwarf_Files and index associated with the given Dwarf_Line.  */
     707             : extern int dwarf_line_file (Dwarf_Line *line,
     708             :                             Dwarf_Files **files, size_t *idx)
     709             :     __nonnull_attribute__ (2, 3);
     710             : 
     711             : /* Return the directory list used in the file information extracted.
     712             :    (*RESULT)[0] is the CU's DW_AT_comp_dir value, and may be null.
     713             :    (*RESULT)[0..*NDIRS-1] are the compile-time include directory path
     714             :    encoded by the compiler.  */
     715             : extern int dwarf_getsrcdirs (Dwarf_Files *files,
     716             :                              const char *const **result, size_t *ndirs)
     717             :   __nonnull_attribute__ (2, 3);
     718             : 
     719             : 
     720             : /* Return location expression, decoded as a list of operations.  */
     721             : extern int dwarf_getlocation (Dwarf_Attribute *attr, Dwarf_Op **expr,
     722             :                               size_t *exprlen) __nonnull_attribute__ (2, 3);
     723             : 
     724             : /* Return location expressions.  If the attribute uses a location list,
     725             :    ADDRESS selects the relevant location expressions from the list.
     726             :    There can be multiple matches, resulting in multiple expressions to
     727             :    return.  EXPRS and EXPRLENS are parallel arrays of NLOCS slots to
     728             :    fill in.  Returns the number of locations filled in, or -1 for
     729             :    errors.  If EXPRS is a null pointer, stores nothing and returns the
     730             :    total number of locations.  A return value of zero means that the
     731             :    location list indicated no value is accessible.  */
     732             : extern int dwarf_getlocation_addr (Dwarf_Attribute *attr, Dwarf_Addr address,
     733             :                                    Dwarf_Op **exprs, size_t *exprlens,
     734             :                                    size_t nlocs);
     735             : 
     736             : /* Enumerate the locations ranges and descriptions covered by the
     737             :    given attribute.  In the first call OFFSET should be zero and
     738             :    *BASEP need not be initialized.  Returns -1 for errors, zero when
     739             :    there are no more locations to report, or a nonzero OFFSET
     740             :    value to pass to the next call.  Each subsequent call must preserve
     741             :    *BASEP from the prior call.  Successful calls fill in *STARTP and
     742             :    *ENDP with a contiguous address range and *EXPR with a pointer to
     743             :    an array of operations with length *EXPRLEN.  If the attribute
     744             :    describes a single location description and not a location list the
     745             :    first call (with OFFSET zero) will return the location description
     746             :    in *EXPR with *STARTP set to zero and *ENDP set to minus one.  */
     747             : extern ptrdiff_t dwarf_getlocations (Dwarf_Attribute *attr,
     748             :                                      ptrdiff_t offset, Dwarf_Addr *basep,
     749             :                                      Dwarf_Addr *startp, Dwarf_Addr *endp,
     750             :                                      Dwarf_Op **expr, size_t *exprlen);
     751             : 
     752             : /* Return the block associated with a DW_OP_implicit_value operation.
     753             :    The OP pointer must point into an expression that dwarf_getlocation
     754             :    or dwarf_getlocation_addr has returned given the same ATTR.  */
     755             : extern int dwarf_getlocation_implicit_value (Dwarf_Attribute *attr,
     756             :                                              const Dwarf_Op *op,
     757             :                                              Dwarf_Block *return_block)
     758             :   __nonnull_attribute__ (2, 3);
     759             : 
     760             : /* Return the attribute indicated by a DW_OP_GNU_implicit_pointer operation.
     761             :    The OP pointer must point into an expression that dwarf_getlocation
     762             :    or dwarf_getlocation_addr has returned given the same ATTR.
     763             :    The result is the DW_AT_location or DW_AT_const_value attribute
     764             :    of the OP->number DIE.  */
     765             : extern int dwarf_getlocation_implicit_pointer (Dwarf_Attribute *attr,
     766             :                                                const Dwarf_Op *op,
     767             :                                                Dwarf_Attribute *result)
     768             :   __nonnull_attribute__ (2, 3);
     769             : 
     770             : /* Return the DIE associated with an operation such as
     771             :    DW_OP_GNU_implicit_pointer, DW_OP_GNU_parameter_ref, DW_OP_GNU_convert,
     772             :    DW_OP_GNU_reinterpret, DW_OP_GNU_const_type, DW_OP_GNU_regval_type or
     773             :    DW_OP_GNU_deref_type.  The OP pointer must point into an expression that
     774             :    dwarf_getlocation or dwarf_getlocation_addr has returned given the same
     775             :    ATTR.  The RESULT is a DIE that expresses a type or value needed by the
     776             :    given OP.  */
     777             : extern int dwarf_getlocation_die (Dwarf_Attribute *attr,
     778             :                                   const Dwarf_Op *op,
     779             :                                   Dwarf_Die *result)
     780             :   __nonnull_attribute__ (2, 3);
     781             : 
     782             : /* Return the attribute expressing a value associated with an operation such
     783             :    as DW_OP_implicit_value, DW_OP_GNU_entry_value or DW_OP_GNU_const_type.
     784             :    The OP pointer must point into an expression that dwarf_getlocation
     785             :    or dwarf_getlocation_addr has returned given the same ATTR.
     786             :    The RESULT is a value expressed by an attribute such as DW_AT_location
     787             :    or DW_AT_const_value.  */
     788             : extern int dwarf_getlocation_attr (Dwarf_Attribute *attr,
     789             :                                    const Dwarf_Op *op,
     790             :                                    Dwarf_Attribute *result)
     791             :   __nonnull_attribute__ (2, 3);
     792             : 
     793             : 
     794             : /* Compute the byte-size of a type DIE according to DWARF rules.
     795             :    For most types, this is just DW_AT_byte_size.
     796             :    For DW_TAG_array_type it can apply much more complex rules.  */
     797             : extern int dwarf_aggregate_size (Dwarf_Die *die, Dwarf_Word *size);
     798             : 
     799             : /* Given a language code, as returned by dwarf_srclan, get the default
     800             :    lower bound for a subrange type without a lower bound attribute.
     801             :    Returns zero on success or -1 on failure when the given language
     802             :    wasn't recognized.  */
     803             : extern int dwarf_default_lower_bound (int lang, Dwarf_Sword *result)
     804             :   __nonnull_attribute__ (2);
     805             : 
     806             : /* Return scope DIEs containing PC address.
     807             :    Sets *SCOPES to a malloc'd array of Dwarf_Die structures,
     808             :    and returns the number of elements in the array.
     809             :    (*SCOPES)[0] is the DIE for the innermost scope containing PC,
     810             :    (*SCOPES)[1] is the DIE for the scope containing that scope, and so on.
     811             :    Returns -1 for errors or 0 if no scopes match PC.  */
     812             : extern int dwarf_getscopes (Dwarf_Die *cudie, Dwarf_Addr pc,
     813             :                             Dwarf_Die **scopes);
     814             : 
     815             : /* Return scope DIEs containing the given DIE.
     816             :    Sets *SCOPES to a malloc'd array of Dwarf_Die structures,
     817             :    and returns the number of elements in the array.
     818             :    (*SCOPES)[0] is a copy of DIE.
     819             :    (*SCOPES)[1] is the DIE for the scope containing that scope, and so on.
     820             :    Returns -1 for errors or 0 if DIE is not found in any scope entry.  */
     821             : extern int dwarf_getscopes_die (Dwarf_Die *die, Dwarf_Die **scopes);
     822             : 
     823             : 
     824             : /* Search SCOPES[0..NSCOPES-1] for a variable called NAME.
     825             :    Ignore the first SKIP_SHADOWS scopes that match the name.
     826             :    If MATCH_FILE is not null, accept only declaration in that source file;
     827             :    if MATCH_LINENO or MATCH_LINECOL are also nonzero, accept only declaration
     828             :    at that line and column.
     829             : 
     830             :    If successful, fill in *RESULT with the DIE of the variable found,
     831             :    and return N where SCOPES[N] is the scope defining the variable.
     832             :    Return -1 for errors or -2 for no matching variable found.  */
     833             : extern int dwarf_getscopevar (Dwarf_Die *scopes, int nscopes,
     834             :                               const char *name, int skip_shadows,
     835             :                               const char *match_file,
     836             :                               int match_lineno, int match_linecol,
     837             :                               Dwarf_Die *result);
     838             : 
     839             : 
     840             : 
     841             : /* Return list address ranges.  */
     842             : extern int dwarf_getaranges (Dwarf *dbg, Dwarf_Aranges **aranges,
     843             :                              size_t *naranges)
     844             :      __nonnull_attribute__ (2);
     845             : 
     846             : /* Return one of the address range entries.  */
     847             : extern Dwarf_Arange *dwarf_onearange (Dwarf_Aranges *aranges, size_t idx);
     848             : 
     849             : /* Return information in address range record.  */
     850             : extern int dwarf_getarangeinfo (Dwarf_Arange *arange, Dwarf_Addr *addrp,
     851             :                                 Dwarf_Word *lengthp, Dwarf_Off *offsetp);
     852             : 
     853             : /* Get address range which includes given address.  */
     854             : extern Dwarf_Arange *dwarf_getarange_addr (Dwarf_Aranges *aranges,
     855             :                                            Dwarf_Addr addr);
     856             : 
     857             : 
     858             : 
     859             : /* Get functions in CUDIE.  The given callback will be called for all
     860             :    defining DW_TAG_subprograms in the CU DIE tree.  If the callback
     861             :    returns DWARF_CB_ABORT the return value can be used as offset argument
     862             :    to resume the function to find all remaining functions (this is not
     863             :    really recommended, since it needs to rewalk the CU DIE tree first till
     864             :    that offset is found again).  If the callback returns DWARF_CB_OK
     865             :    dwarf_getfuncs will not return but keep calling the callback for each
     866             :    function DIE it finds.  Pass zero for offset on the first call to walk
     867             :    the full CU DIE tree.  If no more functions can be found and the callback
     868             :    returned DWARF_CB_OK then the function returns zero.  */
     869             : extern ptrdiff_t dwarf_getfuncs (Dwarf_Die *cudie,
     870             :                                  int (*callback) (Dwarf_Die *, void *),
     871             :                                  void *arg, ptrdiff_t offset);
     872             : 
     873             : 
     874             : /* Return file name containing definition of the given declaration.
     875             :    Of the DECL has an (indirect, see dwarf_attr_integrate) decl_file
     876             :    attribute.  The returned file path is either absolute, or relative
     877             :    to the compilation directory.  Given the decl DIE, the compilation
     878             :    directory can be retrieved through:
     879             :    dwarf_formstring (dwarf_attr (dwarf_diecu (decl, &cudie, NULL, NULL),
     880             :                                  DW_AT_comp_dir, &attr));
     881             :    Returns NULL if no decl_file could be found or an error occured.  */
     882             : extern const char *dwarf_decl_file (Dwarf_Die *decl);
     883             : 
     884             : /* Get line number of beginning of given declaration.  */
     885             : extern int dwarf_decl_line (Dwarf_Die *decl, int *linep)
     886             :      __nonnull_attribute__ (2);
     887             : 
     888             : /* Get column number of beginning of given declaration.  */
     889             : extern int dwarf_decl_column (Dwarf_Die *decl, int *colp)
     890             :      __nonnull_attribute__ (2);
     891             : 
     892             : 
     893             : /* Return nonzero if given function is an abstract inline definition.  */
     894             : extern int dwarf_func_inline (Dwarf_Die *func);
     895             : 
     896             : /* Find each concrete inlined instance of the abstract inline definition.  */
     897             : extern int dwarf_func_inline_instances (Dwarf_Die *func,
     898             :                                         int (*callback) (Dwarf_Die *, void *),
     899             :                                         void *arg);
     900             : 
     901             : 
     902             : /* Find the appropriate PC location or locations for function entry
     903             :    breakpoints for the given DW_TAG_subprogram DIE.  Returns -1 for errors.
     904             :    On success, returns the number of breakpoint locations (never zero)
     905             :    and sets *BKPTS to a malloc'd vector of addresses.  */
     906             : extern int dwarf_entry_breakpoints (Dwarf_Die *die, Dwarf_Addr **bkpts);
     907             : 
     908             : 
     909             : /* Iterate through the macro unit referenced by CUDIE and call
     910             :    CALLBACK for each macro information entry.  To start the iteration,
     911             :    one would pass DWARF_GETMACROS_START for TOKEN.
     912             : 
     913             :    The iteration continues while CALLBACK returns DWARF_CB_OK.  If the
     914             :    callback returns DWARF_CB_ABORT, the iteration stops and a
     915             :    continuation token is returned, which can be used to restart the
     916             :    iteration at the point where it ended.  Returns -1 for errors or 0
     917             :    if there are no more macro entries.
     918             : 
     919             :    Note that the Dwarf_Macro pointer passed to the callback is only
     920             :    valid for the duration of the callback invocation.
     921             : 
     922             :    For backward compatibility, a token of 0 is accepted for starting
     923             :    the iteration as well, but in that case this interface will refuse
     924             :    to serve opcode 0xff from .debug_macro sections.  Such opcode would
     925             :    be considered invalid and would cause dwarf_getmacros to return
     926             :    with error.  */
     927             : #define DWARF_GETMACROS_START PTRDIFF_MIN
     928             : extern ptrdiff_t dwarf_getmacros (Dwarf_Die *cudie,
     929             :                                   int (*callback) (Dwarf_Macro *, void *),
     930             :                                   void *arg, ptrdiff_t token)
     931             :      __nonnull_attribute__ (2);
     932             : 
     933             : /* This is similar in operation to dwarf_getmacros, but selects the
     934             :    unit to iterate through by offset instead of by CU, and always
     935             :    iterates .debug_macro.  This can be used for handling
     936             :    DW_MACRO_GNU_transparent_include's or similar opcodes.
     937             : 
     938             :    TOKEN value of DWARF_GETMACROS_START can be used to start the
     939             :    iteration.
     940             : 
     941             :    It is not appropriate to obtain macro unit offset by hand from a CU
     942             :    DIE and then request iteration through this interface.  The reason
     943             :    for this is that if a dwarf_macro_getsrcfiles is later called,
     944             :    there would be no way to figure out what DW_AT_comp_dir was present
     945             :    on the CU DIE, and file names referenced in either the macro unit
     946             :    itself, or the .debug_line unit that it references, might be wrong.
     947             :    Use dwarf_getmacros.  */
     948             : extern ptrdiff_t dwarf_getmacros_off (Dwarf *dbg, Dwarf_Off macoff,
     949             :                                       int (*callback) (Dwarf_Macro *, void *),
     950             :                                       void *arg, ptrdiff_t token)
     951             :   __nonnull_attribute__ (3);
     952             : 
     953             : /* Get the source files used by the macro entry.  You shouldn't assume
     954             :    that Dwarf_Files references will remain valid after MACRO becomes
     955             :    invalid.  (Which is to say it's only valid within the
     956             :    dwarf_getmacros* callback.)  Returns 0 for success or a negative
     957             :    value in case of an error.  */
     958             : extern int dwarf_macro_getsrcfiles (Dwarf *dbg, Dwarf_Macro *macro,
     959             :                                     Dwarf_Files **files, size_t *nfiles)
     960             :   __nonnull_attribute__ (2, 3, 4);
     961             : 
     962             : /* Return macro opcode.  That's a constant that can be either from
     963             :    DW_MACINFO_* domain or DW_MACRO_GNU_* domain.  The two domains have
     964             :    compatible values, so it's OK to use either of them for
     965             :    comparisons.  The only differences is 0xff, which could be either
     966             :    DW_MACINFO_vendor_ext or a vendor-defined DW_MACRO_* constant.  One
     967             :    would need to look if the CU DIE which the iteration was requested
     968             :    for has attribute DW_AT_macro_info, or either of DW_AT_GNU_macros
     969             :    or DW_AT_macros to differentiate the two interpretations.  */
     970             : extern int dwarf_macro_opcode (Dwarf_Macro *macro, unsigned int *opcodep)
     971             :      __nonnull_attribute__ (2);
     972             : 
     973             : /* Get number of parameters of MACRO and store it to *PARAMCNTP.  */
     974             : extern int dwarf_macro_getparamcnt (Dwarf_Macro *macro, size_t *paramcntp);
     975             : 
     976             : /* Get IDX-th parameter of MACRO (numbered from zero), and stores it
     977             :    to *ATTRIBUTE.  Returns 0 on success or -1 for errors.
     978             : 
     979             :    After a successful call, you can query ATTRIBUTE by dwarf_whatform
     980             :    to determine which of the dwarf_formX calls to make to get actual
     981             :    value out of ATTRIBUTE.  Note that calling dwarf_whatattr is not
     982             :    meaningful for pseudo-attributes formed this way.  */
     983             : extern int dwarf_macro_param (Dwarf_Macro *macro, size_t idx,
     984             :                               Dwarf_Attribute *attribute);
     985             : 
     986             : /* Return macro parameter with index 0.  This will return -1 if the
     987             :    parameter is not an integral value.  Use dwarf_macro_param for more
     988             :    general access.  */
     989             : extern int dwarf_macro_param1 (Dwarf_Macro *macro, Dwarf_Word *paramp)
     990             :      __nonnull_attribute__ (2);
     991             : 
     992             : /* Return macro parameter with index 1.  This will return -1 if the
     993             :    parameter is not an integral or string value.  Use
     994             :    dwarf_macro_param for more general access.  */
     995             : extern int dwarf_macro_param2 (Dwarf_Macro *macro, Dwarf_Word *paramp,
     996             :                                const char **strp);
     997             : 
     998             : /* Compute what's known about a call frame when the PC is at ADDRESS.
     999             :    Returns 0 for success or -1 for errors.
    1000             :    On success, *FRAME is a malloc'd pointer.  */
    1001             : extern int dwarf_cfi_addrframe (Dwarf_CFI *cache,
    1002             :                                 Dwarf_Addr address, Dwarf_Frame **frame)
    1003             :   __nonnull_attribute__ (3);
    1004             : 
    1005             : /* Return the DWARF register number used in FRAME to denote
    1006             :    the return address in FRAME's caller frame.  The remaining
    1007             :    arguments can be non-null to fill in more information.
    1008             : 
    1009             :    Fill [*START, *END) with the PC range to which FRAME's information applies.
    1010             :    Fill in *SIGNALP to indicate whether this is a signal-handling frame.
    1011             :    If true, this is the implicit call frame that calls a signal handler.
    1012             :    This frame's "caller" is actually the interrupted state, not a call;
    1013             :    its return address is an exact PC, not a PC after a call instruction.  */
    1014             : extern int dwarf_frame_info (Dwarf_Frame *frame,
    1015             :                              Dwarf_Addr *start, Dwarf_Addr *end, bool *signalp);
    1016             : 
    1017             : /* Return a DWARF expression that yields the Canonical Frame Address at
    1018             :    this frame state.  Returns -1 for errors, or zero for success, with
    1019             :    *NOPS set to the number of operations stored at *OPS.  That pointer
    1020             :    can be used only as long as FRAME is alive and unchanged.  *NOPS is
    1021             :    zero if the CFA cannot be determined here.  Note that if nonempty,
    1022             :    *OPS is a DWARF expression, not a location description--append
    1023             :    DW_OP_stack_value to a get a location description for the CFA.  */
    1024             : extern int dwarf_frame_cfa (Dwarf_Frame *frame, Dwarf_Op **ops, size_t *nops)
    1025             :   __nonnull_attribute__ (2);
    1026             : 
    1027             : /* Deliver a DWARF location description that yields the location or
    1028             :    value of DWARF register number REGNO in the state described by FRAME.
    1029             : 
    1030             :    Returns -1 for errors or zero for success, setting *NOPS to the
    1031             :    number of operations in the array stored at *OPS.  Note the last
    1032             :    operation is DW_OP_stack_value if there is no mutable location but
    1033             :    only a computable value.
    1034             : 
    1035             :    *NOPS zero with *OPS set to OPS_MEM means CFI says the caller's
    1036             :    REGNO is "undefined", i.e. it's call-clobbered and cannot be recovered.
    1037             : 
    1038             :    *NOPS zero with *OPS set to a null pointer means CFI says the
    1039             :    caller's REGNO is "same_value", i.e. this frame did not change it;
    1040             :    ask the caller frame where to find it.
    1041             : 
    1042             :    For common simple expressions *OPS is OPS_MEM.  For arbitrary DWARF
    1043             :    expressions in the CFI, *OPS is an internal pointer that can be used as
    1044             :    long as the Dwarf_CFI used to create FRAME remains alive.  */
    1045             : extern int dwarf_frame_register (Dwarf_Frame *frame, int regno,
    1046             :                                  Dwarf_Op ops_mem[3],
    1047             :                                  Dwarf_Op **ops, size_t *nops)
    1048             :   __nonnull_attribute__ (3, 4, 5);
    1049             : 
    1050             : 
    1051             : /* Return error code of last failing function call.  This value is kept
    1052             :    separately for each thread.  */
    1053             : extern int dwarf_errno (void);
    1054             : 
    1055             : /* Return error string for ERROR.  If ERROR is zero, return error string
    1056             :    for most recent error or NULL is none occurred.  If ERROR is -1 the
    1057             :    behaviour is similar to the last case except that not NULL but a legal
    1058             :    string is returned.  */
    1059             : extern const char *dwarf_errmsg (int err);
    1060             : 
    1061             : 
    1062             : /* Register new Out-Of-Memory handler.  The old handler is returned.  */
    1063             : extern Dwarf_OOM dwarf_new_oom_handler (Dwarf *dbg, Dwarf_OOM handler);
    1064             : 
    1065             : 
    1066             : /* Inline optimizations.  */
    1067             : #ifdef __OPTIMIZE__
    1068             : /* Return attribute code of given attribute.  */
    1069             : __libdw_extern_inline unsigned int
    1070             : dwarf_whatattr (Dwarf_Attribute *attr)
    1071             : {
    1072     2451568 :   return attr == NULL ? 0 : attr->code;
    1073             : }
    1074             : 
    1075             : /* Return attribute code of given attribute.  */
    1076             : __libdw_extern_inline unsigned int
    1077             : dwarf_whatform (Dwarf_Attribute *attr)
    1078             : {
    1079     6441169 :   return attr == NULL ? 0 : attr->form;
    1080             : }
    1081             : #endif  /* Optimize.  */
    1082             : 
    1083             : #ifdef __cplusplus
    1084             : }
    1085             : #endif
    1086             : 
    1087             : #endif  /* libdw.h */

Generated by: LCOV version 1.13