Blame libdw/libdw.h

Packit 032894
/* Interfaces for libdw.
Packit 032894
   Copyright (C) 2002-2010, 2013, 2014, 2016, 2018 Red Hat, Inc.
Packit 032894
   This file is part of elfutils.
Packit 032894
Packit 032894
   This file is free software; you can redistribute it and/or modify
Packit 032894
   it under the terms of either
Packit 032894
Packit 032894
     * the GNU Lesser General Public License as published by the Free
Packit 032894
       Software Foundation; either version 3 of the License, or (at
Packit 032894
       your option) any later version
Packit 032894
Packit 032894
   or
Packit 032894
Packit 032894
     * the GNU General Public License as published by the Free
Packit 032894
       Software Foundation; either version 2 of the License, or (at
Packit 032894
       your option) any later version
Packit 032894
Packit 032894
   or both in parallel, as here.
Packit 032894
Packit 032894
   elfutils is distributed in the hope that it will be useful, but
Packit 032894
   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 032894
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 032894
   General Public License for more details.
Packit 032894
Packit 032894
   You should have received copies of the GNU General Public License and
Packit 032894
   the GNU Lesser General Public License along with this program.  If
Packit 032894
   not, see <http://www.gnu.org/licenses/>.  */
Packit 032894
Packit 032894
#ifndef _LIBDW_H
Packit 032894
#define _LIBDW_H	1
Packit 032894
Packit 032894
#include <gelf.h>
Packit 032894
#include <stdbool.h>
Packit 032894
#include <stddef.h>
Packit 032894
#include <stdint.h>
Packit 032894
Packit 032894
/* Mode for the session.  */
Packit 032894
typedef enum
Packit 032894
  {
Packit 032894
    DWARF_C_READ,		/* Read .. */
Packit 032894
    DWARF_C_RDWR,		/* Read and write .. */
Packit 032894
    DWARF_C_WRITE,		/* Write .. */
Packit 032894
  }
Packit 032894
Dwarf_Cmd;
Packit 032894
Packit 032894
Packit 032894
/* Callback results.  */
Packit 032894
enum
Packit 032894
{
Packit 032894
  DWARF_CB_OK = 0,
Packit 032894
  DWARF_CB_ABORT
Packit 032894
};
Packit 032894
Packit 032894
Packit 032894
/* Error values.  */
Packit 032894
enum
Packit 032894
  {
Packit 032894
    DW_TAG_invalid = 0
Packit 032894
#define DW_TAG_invalid	DW_TAG_invalid
Packit 032894
  };
Packit 032894
Packit 032894
Packit 032894
/* Type for offset in DWARF file.  */
Packit 032894
typedef GElf_Off Dwarf_Off;
Packit 032894
Packit 032894
/* Type for address in DWARF file.  */
Packit 032894
typedef GElf_Addr Dwarf_Addr;
Packit 032894
Packit 032894
/* Integer types.  Big enough to hold any numeric value.  */
Packit 032894
typedef GElf_Xword Dwarf_Word;
Packit 032894
typedef GElf_Sxword Dwarf_Sword;
Packit 032894
/* For the times we know we do not need that much.  */
Packit 032894
typedef GElf_Half Dwarf_Half;
Packit 032894
Packit 032894
Packit 032894
/* DWARF abbreviation record.  */
Packit 032894
typedef struct Dwarf_Abbrev Dwarf_Abbrev;
Packit 032894
Packit 032894
/* Returned to show the last DIE has be returned.  */
Packit 032894
#define DWARF_END_ABBREV ((Dwarf_Abbrev *) -1l)
Packit 032894
Packit 032894
/* Source code line information for CU.  */
Packit 032894
typedef struct Dwarf_Lines_s Dwarf_Lines;
Packit 032894
Packit 032894
/* One source code line information.  */
Packit 032894
typedef struct Dwarf_Line_s Dwarf_Line;
Packit 032894
Packit 032894
/* Source file information.  */
Packit 032894
typedef struct Dwarf_Files_s Dwarf_Files;
Packit 032894
Packit 032894
/* One address range record.  */
Packit 032894
typedef struct Dwarf_Arange_s Dwarf_Arange;
Packit 032894
Packit 032894
/* Address ranges of a file.  */
Packit 032894
typedef struct Dwarf_Aranges_s Dwarf_Aranges;
Packit 032894
Packit 032894
/* CU representation.  */
Packit 032894
struct Dwarf_CU;
Packit 032894
typedef struct Dwarf_CU Dwarf_CU;
Packit 032894
Packit 032894
/* Macro information.  */
Packit 032894
typedef struct Dwarf_Macro_s Dwarf_Macro;
Packit 032894
Packit 032894
/* Attribute representation.  */
Packit 032894
typedef struct
Packit 032894
{
Packit 032894
  unsigned int code;
Packit 032894
  unsigned int form;
Packit 032894
  unsigned char *valp;
Packit 032894
  struct Dwarf_CU *cu;
Packit 032894
} Dwarf_Attribute;
Packit 032894
Packit 032894
Packit 032894
/* Data block representation.  */
Packit 032894
typedef struct
Packit 032894
{
Packit 032894
  Dwarf_Word length;
Packit 032894
  unsigned char *data;
Packit 032894
} Dwarf_Block;
Packit 032894
Packit 032894
Packit 032894
/* DIE information.  */
Packit 032894
typedef struct
Packit 032894
{
Packit 032894
  /* The offset can be computed from the address.  */
Packit 032894
  void *addr;
Packit 032894
  struct Dwarf_CU *cu;
Packit 032894
  Dwarf_Abbrev *abbrev;
Packit 032894
  // XXX We'll see what other information will be needed.
Packit 032894
  long int padding__;
Packit 032894
} Dwarf_Die;
Packit 032894
Packit 032894
/* Returned to show the last DIE has be returned.  */
Packit 032894
#define DWARF_END_DIE ((Dwarf_Die *) -1l)
Packit 032894
Packit 032894
Packit 032894
/* Global symbol information.  */
Packit 032894
typedef struct
Packit 032894
{
Packit 032894
  Dwarf_Off cu_offset;
Packit 032894
  Dwarf_Off die_offset;
Packit 032894
  const char *name;
Packit 032894
} Dwarf_Global;
Packit 032894
Packit 032894
Packit 032894
/* One operation in a DWARF location expression.
Packit 032894
   A location expression is an array of these.  */
Packit 032894
typedef struct
Packit 032894
{
Packit 032894
  uint8_t atom;			/* Operation */
Packit 032894
  Dwarf_Word number;		/* Operand */
Packit 032894
  Dwarf_Word number2;		/* Possible second operand */
Packit 032894
  Dwarf_Word offset;		/* Offset in location expression */
Packit 032894
} Dwarf_Op;
Packit 032894
Packit 032894
Packit 032894
/* This describes one Common Information Entry read from a CFI section.
Packit 032894
   Pointers here point into the DATA->d_buf block passed to dwarf_next_cfi.  */
Packit 032894
typedef struct
Packit 032894
{
Packit 032894
  Dwarf_Off CIE_id;	 /* Always DW_CIE_ID_64 in Dwarf_CIE structures.  */
Packit 032894
Packit 032894
  /* Instruction stream describing initial state used by FDEs.  If
Packit 032894
     we did not understand the whole augmentation string and it did
Packit 032894
     not use 'z', then there might be more augmentation data here
Packit 032894
     (and in FDEs) before the actual instructions.  */
Packit 032894
  const uint8_t *initial_instructions;
Packit 032894
  const uint8_t *initial_instructions_end;
Packit 032894
Packit 032894
  Dwarf_Word code_alignment_factor;
Packit 032894
  Dwarf_Sword data_alignment_factor;
Packit 032894
  Dwarf_Word return_address_register;
Packit 032894
Packit 032894
  const char *augmentation;	/* Augmentation string.  */
Packit 032894
Packit 032894
  /* Augmentation data, might be NULL.  The size is correct only if
Packit 032894
     we understood the augmentation string sufficiently.  */
Packit 032894
  const uint8_t *augmentation_data;
Packit 032894
  size_t augmentation_data_size;
Packit 032894
  size_t fde_augmentation_data_size;
Packit 032894
} Dwarf_CIE;
Packit 032894
Packit 032894
/* This describes one Frame Description Entry read from a CFI section.
Packit 032894
   Pointers here point into the DATA->d_buf block passed to dwarf_next_cfi.  */
Packit 032894
typedef struct
Packit 032894
{
Packit 032894
  /* Section offset of CIE this FDE refers to.  This will never be
Packit 032894
     DW_CIE_ID_64 in an FDE.  If this value is DW_CIE_ID_64, this is
Packit 032894
     actually a Dwarf_CIE structure.  */
Packit 032894
  Dwarf_Off CIE_pointer;
Packit 032894
Packit 032894
  /* We can't really decode anything further without looking up the CIE
Packit 032894
     and checking its augmentation string.  Here follows the encoded
Packit 032894
     initial_location and address_range, then any augmentation data,
Packit 032894
     then the instruction stream.  This FDE describes PC locations in
Packit 032894
     the byte range [initial_location, initial_location+address_range).
Packit 032894
     When the CIE augmentation string uses 'z', the augmentation data is
Packit 032894
     a DW_FORM_block (self-sized).  Otherwise, when we understand the
Packit 032894
     augmentation string completely, fde_augmentation_data_size gives
Packit 032894
     the number of bytes of augmentation data before the instructions.  */
Packit 032894
  const uint8_t *start;
Packit 032894
  const uint8_t *end;
Packit 032894
} Dwarf_FDE;
Packit 032894
Packit 032894
/* Each entry in a CFI section is either a CIE described by Dwarf_CIE or
Packit 032894
   an FDE described by Dward_FDE.  Check CIE_id to see which you have.  */
Packit 032894
typedef union
Packit 032894
{
Packit 032894
  Dwarf_Off CIE_id;	 /* Always DW_CIE_ID_64 in Dwarf_CIE structures.  */
Packit 032894
  Dwarf_CIE cie;
Packit 032894
  Dwarf_FDE fde;
Packit 032894
} Dwarf_CFI_Entry;
Packit 032894
Packit 032894
/* Same as DW_CIE_ID_64 from dwarf.h to keep libdw.h independent.  */
Packit 032894
#define LIBDW_CIE_ID 0xffffffffffffffffULL
Packit 032894
#define dwarf_cfi_cie_p(entry)	((entry)->cie.CIE_id == LIBDW_CIE_ID)
Packit 032894
Packit 032894
/* Opaque type representing a frame state described by CFI.  */
Packit 032894
typedef struct Dwarf_Frame_s Dwarf_Frame;
Packit 032894
Packit 032894
/* Opaque type representing a CFI section found in a DWARF or ELF file.  */
Packit 032894
typedef struct Dwarf_CFI_s Dwarf_CFI;
Packit 032894
Packit 032894
Packit 032894
/* Handle for debug sessions.  */
Packit 032894
typedef struct Dwarf Dwarf;
Packit 032894
Packit 032894
Packit 032894
/* Out-Of-Memory handler.  */
Packit 032894
typedef void (*__noreturn_attribute__ Dwarf_OOM) (void);
Packit 032894
Packit 032894
Packit 032894
#ifdef __cplusplus
Packit 032894
extern "C" {
Packit 032894
#endif
Packit 032894
Packit 032894
/* Create a handle for a new debug session.  */
Packit 032894
extern Dwarf *dwarf_begin (int fildes, Dwarf_Cmd cmd);
Packit 032894
Packit 032894
/* Create a handle for a new debug session for an ELF file.  */
Packit 032894
extern Dwarf *dwarf_begin_elf (Elf *elf, Dwarf_Cmd cmd, Elf_Scn *scngrp);
Packit 032894
Packit 032894
/* Retrieve ELF descriptor used for DWARF access.  */
Packit 032894
extern Elf *dwarf_getelf (Dwarf *dwarf);
Packit 032894
Packit 032894
/* Retieve DWARF descriptor used for a Dwarf_Die or Dwarf_Attribute.
Packit 032894
   A Dwarf_Die or a Dwarf_Attribute is associated with a particular
Packit 032894
   Dwarf_CU handle.  This function returns the DWARF descriptor for
Packit 032894
   that Dwarf_CU.  */
Packit 032894
extern Dwarf *dwarf_cu_getdwarf (Dwarf_CU *cu);
Packit 032894
Packit 032894
/* Retrieves the DWARF descriptor for debugaltlink data.  Returns NULL
Packit 032894
   if no alternate debug data has been supplied yet.  libdw will try
Packit 032894
   to set the alt file on first use of an alt FORM if not yet explicitly
Packit 032894
   provided by dwarf_setalt.  */
Packit 032894
extern Dwarf *dwarf_getalt (Dwarf *main);
Packit 032894
Packit 032894
/* Provides the data referenced by the .gnu_debugaltlink section.  The
Packit 032894
   caller should check that MAIN and ALT match (i.e., they have the
Packit 032894
   same build ID).  It is the responsibility of the caller to ensure
Packit 032894
   that the data referenced by ALT stays valid while it is used by
Packit 032894
   MAIN, until dwarf_setalt is called on MAIN with a different
Packit 032894
   descriptor, or dwarf_end.  Must be called before inspecting DIEs
Packit 032894
   that might have alt FORMs.  Otherwise libdw will try to set the
Packit 032894
   alt file itself on first use.  */
Packit 032894
extern void dwarf_setalt (Dwarf *main, Dwarf *alt);
Packit 032894
Packit 032894
/* Release debugging handling context.  */
Packit 032894
extern int dwarf_end (Dwarf *dwarf);
Packit 032894
Packit 032894
Packit 032894
/* Read the header for the DWARF CU.  */
Packit 032894
extern int dwarf_nextcu (Dwarf *dwarf, Dwarf_Off off, Dwarf_Off *next_off,
Packit 032894
			 size_t *header_sizep, Dwarf_Off *abbrev_offsetp,
Packit 032894
			 uint8_t *address_sizep, uint8_t *offset_sizep)
Packit 032894
     __nonnull_attribute__ (3);
Packit 032894
Packit 032894
/* Read the header of a DWARF CU or type unit.  If TYPE_SIGNATUREP is not
Packit 032894
   null, this reads a type unit from the .debug_types section; otherwise
Packit 032894
   this reads a CU from the .debug_info section.  */
Packit 032894
extern int dwarf_next_unit (Dwarf *dwarf, Dwarf_Off off, Dwarf_Off *next_off,
Packit 032894
			    size_t *header_sizep, Dwarf_Half *versionp,
Packit 032894
			    Dwarf_Off *abbrev_offsetp,
Packit 032894
			    uint8_t *address_sizep, uint8_t *offset_sizep,
Packit 032894
			    uint64_t *type_signaturep, Dwarf_Off *type_offsetp)
Packit 032894
     __nonnull_attribute__ (3);
Packit 032894
Packit 032894
Packit 032894
/* Gets the next Dwarf_CU (unit), version, unit type and if available
Packit 032894
   the CU DIE and sub (type) DIE of the unit.  Returns 0 on success,
Packit 032894
   -1 on error or 1 if there are no more units.  To start iterating
Packit 032894
   provide NULL for CU.  If version < 5 the unit type is set from the
Packit 032894
   CU DIE if available (DW_UT_compile for DW_TAG_compile_unit,
Packit 032894
   DW_UT_type for DW_TAG_type_unit or DW_UT_partial for
Packit 032894
   DW_TAG_partial_unit), otherwise it is set to zero.  If unavailable
Packit 032894
   (the version or unit type is unknown) the CU DIE is cleared.
Packit 032894
   Likewise if the sub DIE isn't isn't available (the unit type is not
Packit 032894
   DW_UT_type or DW_UT_split_type) the sub DIE tag is cleared.  */
Packit 032894
extern int dwarf_get_units (Dwarf *dwarf, Dwarf_CU *cu, Dwarf_CU **next_cu,
Packit 032894
			    Dwarf_Half *version, uint8_t *unit_type,
Packit 032894
			    Dwarf_Die *cudie, Dwarf_Die *subdie)
Packit 032894
     __nonnull_attribute__ (3);
Packit 032894
Packit 032894
/* Provides information and DIEs associated with the given Dwarf_CU
Packit 032894
   unit.  Returns -1 on error, zero on success. Arguments not needed
Packit 032894
   may be NULL.  If they are NULL and aren't known yet, they won't be
Packit 032894
   looked up.  If the subdie doesn't exist for this unit_type it will
Packit 032894
   be cleared.  If there is no unit_id for this unit type it will be
Packit 032894
   set to zero.  */
Packit 032894
extern int dwarf_cu_info (Dwarf_CU *cu,
Packit 032894
			  Dwarf_Half *version, uint8_t *unit_type,
Packit 032894
			  Dwarf_Die *cudie, Dwarf_Die *subdie,
Packit 032894
			  uint64_t *unit_id,
Packit 032894
			  uint8_t *address_size, uint8_t *offset_size);
Packit 032894
Packit 032894
/* Decode one DWARF CFI entry (CIE or FDE) from the raw section data.
Packit 032894
   The E_IDENT from the originating ELF file indicates the address
Packit 032894
   size and byte order used in the CFI section contained in DATA;
Packit 032894
   EH_FRAME_P should be true for .eh_frame format and false for
Packit 032894
   .debug_frame format.  OFFSET is the byte position in the section
Packit 032894
   to start at; on return *NEXT_OFFSET is filled in with the byte
Packit 032894
   position immediately after this entry.
Packit 032894
Packit 032894
   On success, returns 0 and fills in *ENTRY; use dwarf_cfi_cie_p to
Packit 032894
   see whether ENTRY->cie or ENTRY->fde is valid.
Packit 032894
Packit 032894
   On errors, returns -1.  Some format errors will permit safely
Packit 032894
   skipping to the next CFI entry though the current one is unusable.
Packit 032894
   In that case, *NEXT_OFF will be updated before a -1 return.
Packit 032894
Packit 032894
   If there are no more CFI entries left in the section,
Packit 032894
   returns 1 and sets *NEXT_OFFSET to (Dwarf_Off) -1.  */
Packit 032894
extern int dwarf_next_cfi (const unsigned char e_ident[],
Packit 032894
			   Elf_Data *data, bool eh_frame_p,
Packit 032894
			   Dwarf_Off offset, Dwarf_Off *next_offset,
Packit 032894
			   Dwarf_CFI_Entry *entry)
Packit 032894
  __nonnull_attribute__ (1, 2, 5, 6);
Packit 032894
Packit 032894
/* Use the CFI in the DWARF .debug_frame section.
Packit 032894
   Returns NULL if there is no such section (not an error).
Packit 032894
   The pointer returned can be used until dwarf_end is called on DWARF,
Packit 032894
   and must not be passed to dwarf_cfi_end.
Packit 032894
   Calling this more than once returns the same pointer.  */
Packit 032894
extern Dwarf_CFI *dwarf_getcfi (Dwarf *dwarf);
Packit 032894
Packit 032894
/* Use the CFI in the ELF file's exception-handling data.
Packit 032894
   Returns NULL if there is no such data.
Packit 032894
   The pointer returned can be used until elf_end is called on ELF,
Packit 032894
   and must be passed to dwarf_cfi_end before then.
Packit 032894
   Calling this more than once allocates independent data structures.  */
Packit 032894
extern Dwarf_CFI *dwarf_getcfi_elf (Elf *elf);
Packit 032894
Packit 032894
/* Release resources allocated by dwarf_getcfi_elf.  */
Packit 032894
extern int dwarf_cfi_end (Dwarf_CFI *cache);
Packit 032894
Packit 032894
Packit 032894
/* Return DIE at given offset in .debug_info section.  */
Packit 032894
extern Dwarf_Die *dwarf_offdie (Dwarf *dbg, Dwarf_Off offset,
Packit 032894
				Dwarf_Die *result) __nonnull_attribute__ (3);
Packit 032894
Packit 032894
/* Return DIE at given offset in .debug_types section.  */
Packit 032894
extern Dwarf_Die *dwarf_offdie_types (Dwarf *dbg, Dwarf_Off offset,
Packit 032894
				      Dwarf_Die *result)
Packit 032894
     __nonnull_attribute__ (3);
Packit 032894
Packit 032894
/* Return offset of DIE.  */
Packit 032894
extern Dwarf_Off dwarf_dieoffset (Dwarf_Die *die);
Packit 032894
Packit 032894
/* Return offset of DIE in CU.  */
Packit 032894
extern Dwarf_Off dwarf_cuoffset (Dwarf_Die *die);
Packit 032894
Packit 032894
/* Return CU DIE containing given DIE.  */
Packit 032894
extern Dwarf_Die *dwarf_diecu (Dwarf_Die *die, Dwarf_Die *result,
Packit 032894
			       uint8_t *address_sizep, uint8_t *offset_sizep)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Given a Dwarf_Die addr returns a (reconstructed) Dwarf_Die, or NULL
Packit 032894
   if the given addr didn't come from a valid Dwarf_Die.  In particular
Packit 032894
   it will make sure that the correct Dwarf_CU pointer is set for the
Packit 032894
   Dwarf_Die, the Dwarf_Abbrev pointer will not be set up yet (it will
Packit 032894
   only be once the Dwarf_Die is used to read attributes, children or
Packit 032894
   siblings).  This functions can be used to keep a reference to a
Packit 032894
   Dwarf_Die which you want to refer to later.  The addr, and the result
Packit 032894
   of this function, is only valid while the associated Dwarf is valid.  */
Packit 032894
extern Dwarf_Die *dwarf_die_addr_die (Dwarf *dbg, void *addr,
Packit 032894
				      Dwarf_Die *result)
Packit 032894
     __nonnull_attribute__ (3);
Packit 032894
Packit 032894
/* Return the CU DIE and the header info associated with a Dwarf_Die
Packit 032894
   or Dwarf_Attribute.  A Dwarf_Die or a Dwarf_Attribute is associated
Packit 032894
   with a particular Dwarf_CU handle.  This function returns the CU or
Packit 032894
   type unit DIE and header information for that Dwarf_CU.  The
Packit 032894
   returned DIE is either a compile_unit, partial_unit or type_unit.
Packit 032894
   If it is a type_unit, then the type signature and type offset are
Packit 032894
   also provided, otherwise type_offset will be set to zero.  See also
Packit 032894
   dwarf_diecu and dwarf_next_unit.  */
Packit 032894
extern Dwarf_Die *dwarf_cu_die (Dwarf_CU *cu, Dwarf_Die *result,
Packit 032894
				Dwarf_Half *versionp,
Packit 032894
				Dwarf_Off *abbrev_offsetp,
Packit 032894
				uint8_t *address_sizep,
Packit 032894
				uint8_t *offset_sizep,
Packit 032894
				uint64_t *type_signaturep,
Packit 032894
				Dwarf_Off *type_offsetp)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return CU DIE containing given address.  */
Packit 032894
extern Dwarf_Die *dwarf_addrdie (Dwarf *dbg, Dwarf_Addr addr,
Packit 032894
				 Dwarf_Die *result) __nonnull_attribute__ (3);
Packit 032894
Packit 032894
/* Return child of current DIE.  */
Packit 032894
extern int dwarf_child (Dwarf_Die *die, Dwarf_Die *result)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Locates the first sibling of DIE and places it in RESULT.
Packit 032894
   Returns 0 if a sibling was found, -1 if something went wrong.
Packit 032894
   Returns 1 if no sibling could be found and, if RESULT is not
Packit 032894
   the same as DIE, it sets RESULT->addr to the address of the
Packit 032894
   (non-sibling) DIE that follows this one, or NULL if this DIE
Packit 032894
   was the last one in the compilation unit.  */
Packit 032894
extern int dwarf_siblingof (Dwarf_Die *die, Dwarf_Die *result)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* For type aliases and qualifier type DIEs, which don't modify or
Packit 032894
   change the structural layout of the underlying type, follow the
Packit 032894
   DW_AT_type attribute (recursively) and return the underlying type
Packit 032894
   Dwarf_Die.
Packit 032894
Packit 032894
   Returns 0 when RESULT contains a Dwarf_Die (possibly equal to the
Packit 032894
   given DIE) that isn't a type alias or qualifier type.  Returns 1
Packit 032894
   when RESULT contains a type alias or qualifier Dwarf_Die that
Packit 032894
   couldn't be peeled further (it doesn't have a DW_TAG_type
Packit 032894
   attribute).  Returns -1 when an error occured.
Packit 032894
Packit 032894
   The current DWARF specification defines one type alias tag
Packit 032894
   (DW_TAG_typedef) and seven modifier/qualifier type tags
Packit 032894
   (DW_TAG_const_type, DW_TAG_volatile_type, DW_TAG_restrict_type,
Packit 032894
   DW_TAG_atomic_type, DW_TAG_immutable_type, DW_TAG_packed_type and
Packit 032894
   DW_TAG_shared_type).  This function won't peel modifier type
Packit 032894
   tags that change the way the underlying type is accessed such
Packit 032894
   as the pointer or reference type tags (DW_TAG_pointer_type,
Packit 032894
   DW_TAG_reference_type or DW_TAG_rvalue_reference_type).
Packit 032894
Packit 032894
   A future version of this function might peel other alias or
Packit 032894
   qualifier type tags if a future DWARF version or GNU extension
Packit 032894
   defines other type aliases or qualifier type tags that don't modify,
Packit 032894
   change the structural layout or the way to access the underlying type.  */
Packit 032894
extern int dwarf_peel_type (Dwarf_Die *die, Dwarf_Die *result)
Packit 032894
    __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Check whether the DIE has children.  */
Packit 032894
extern int dwarf_haschildren (Dwarf_Die *die) __nonnull_attribute__ (1);
Packit 032894
Packit 032894
/* Walks the attributes of DIE, starting at the one OFFSET bytes in,
Packit 032894
   calling the CALLBACK function for each one.  Stops if the callback
Packit 032894
   function ever returns a value other than DWARF_CB_OK and returns the
Packit 032894
   offset of the offending attribute.  If the end of the attributes
Packit 032894
   is reached 1 is returned.  If something goes wrong -1 is returned and
Packit 032894
   the dwarf error number is set.  */
Packit 032894
extern ptrdiff_t dwarf_getattrs (Dwarf_Die *die,
Packit 032894
				 int (*callback) (Dwarf_Attribute *, void *),
Packit 032894
				 void *arg, ptrdiff_t offset)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return tag of given DIE.  */
Packit 032894
extern int dwarf_tag (Dwarf_Die *die) __nonnull_attribute__ (1);
Packit 032894
Packit 032894
Packit 032894
/* Return specific attribute of DIE.  */
Packit 032894
extern Dwarf_Attribute *dwarf_attr (Dwarf_Die *die, unsigned int search_name,
Packit 032894
				    Dwarf_Attribute *result)
Packit 032894
     __nonnull_attribute__ (3);
Packit 032894
Packit 032894
/* Check whether given DIE has specific attribute.  */
Packit 032894
extern int dwarf_hasattr (Dwarf_Die *die, unsigned int search_name);
Packit 032894
Packit 032894
/* These are the same as dwarf_attr and dwarf_hasattr, respectively,
Packit Service 35cfd5
   but they resolve an indirect attribute through
Packit Service 35cfd5
   DW_AT_abstract_origin, DW_AT_specification or, if the DIE is a
Packit Service 35cfd5
   top-level split CU, the skeleton DIE.  Note that the attribute
Packit Service 35cfd5
   might come from a DIE in a different CU (possibly from a different
Packit Service 35cfd5
   Dwarf file).  In that case all attribute information needs to be
Packit Service 35cfd5
   resolved through the CU associated with the returned
Packit Service 35cfd5
   Dwarf_Attribute.  The dwarf_form functions already do this
Packit Service 35cfd5
   automatically.  */
Packit 032894
extern Dwarf_Attribute *dwarf_attr_integrate (Dwarf_Die *die,
Packit 032894
					      unsigned int search_name,
Packit 032894
					      Dwarf_Attribute *result)
Packit 032894
     __nonnull_attribute__ (3);
Packit 032894
extern int dwarf_hasattr_integrate (Dwarf_Die *die, unsigned int search_name);
Packit 032894
Packit 032894
Packit 032894
Packit 032894
Packit 032894
/* Check whether given attribute has specific form.  */
Packit 032894
extern int dwarf_hasform (Dwarf_Attribute *attr, unsigned int search_form);
Packit 032894
Packit 032894
/* Return attribute code of given attribute.  */
Packit 032894
extern unsigned int dwarf_whatattr (Dwarf_Attribute *attr);
Packit 032894
Packit 032894
/* Return form code of given attribute.  */
Packit 032894
extern unsigned int dwarf_whatform (Dwarf_Attribute *attr);
Packit 032894
Packit 032894
Packit 032894
/* Return string associated with given attribute.  */
Packit 032894
extern const char *dwarf_formstring (Dwarf_Attribute *attrp);
Packit 032894
Packit 032894
/* Return unsigned constant represented by attribute.  */
Packit 032894
extern int dwarf_formudata (Dwarf_Attribute *attr, Dwarf_Word *return_uval)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return signed constant represented by attribute.  */
Packit 032894
extern int dwarf_formsdata (Dwarf_Attribute *attr, Dwarf_Sword *return_uval)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return address represented by attribute.  */
Packit 032894
extern int dwarf_formaddr (Dwarf_Attribute *attr, Dwarf_Addr *return_addr)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* This function is deprecated.  Always use dwarf_formref_die instead.
Packit 032894
   Return reference offset represented by attribute.  */
Packit 032894
extern int dwarf_formref (Dwarf_Attribute *attr, Dwarf_Off *return_offset)
Packit 032894
     __nonnull_attribute__ (2) __deprecated_attribute__;
Packit 032894
Packit 032894
/* Look up the DIE in a reference-form attribute.  */
Packit 032894
extern Dwarf_Die *dwarf_formref_die (Dwarf_Attribute *attr, Dwarf_Die *die_mem)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return block represented by attribute.  */
Packit 032894
extern int dwarf_formblock (Dwarf_Attribute *attr, Dwarf_Block *return_block)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return flag represented by attribute.  */
Packit 032894
extern int dwarf_formflag (Dwarf_Attribute *attr, bool *return_bool)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
Packit 032894
/* Simplified attribute value access functions.  */
Packit 032894
Packit 032894
/* Return string in name attribute of DIE.  */
Packit 032894
extern const char *dwarf_diename (Dwarf_Die *die);
Packit 032894
Packit 032894
/* Return high PC attribute of DIE.  */
Packit 032894
extern int dwarf_highpc (Dwarf_Die *die, Dwarf_Addr *return_addr)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return low PC attribute of DIE.  */
Packit 032894
extern int dwarf_lowpc (Dwarf_Die *die, Dwarf_Addr *return_addr)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return entry_pc or low_pc attribute of DIE.  */
Packit 032894
extern int dwarf_entrypc (Dwarf_Die *die, Dwarf_Addr *return_addr)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return 1 if DIE's lowpc/highpc or ranges attributes match the PC address,
Packit 032894
   0 if not, or -1 for errors.  */
Packit 032894
extern int dwarf_haspc (Dwarf_Die *die, Dwarf_Addr pc);
Packit 032894
Packit 032894
/* Enumerate the PC address ranges covered by this DIE, covering all
Packit 032894
   addresses where dwarf_haspc returns true.  In the first call OFFSET
Packit 032894
   should be zero and *BASEP need not be initialized.  Returns -1 for
Packit 032894
   errors, zero when there are no more address ranges to report, or a
Packit 032894
   nonzero OFFSET value to pass to the next call.  Each subsequent call
Packit 032894
   must preserve *BASEP from the prior call.  Successful calls fill in
Packit 032894
   *STARTP and *ENDP with a contiguous address range.  */
Packit 032894
extern ptrdiff_t dwarf_ranges (Dwarf_Die *die,
Packit 032894
			       ptrdiff_t offset, Dwarf_Addr *basep,
Packit 032894
			       Dwarf_Addr *startp, Dwarf_Addr *endp);
Packit 032894
Packit 032894
Packit 032894
/* Return byte size attribute of DIE.  */
Packit 032894
extern int dwarf_bytesize (Dwarf_Die *die);
Packit 032894
Packit 032894
/* Return bit size attribute of DIE.  */
Packit 032894
extern int dwarf_bitsize (Dwarf_Die *die);
Packit 032894
Packit 032894
/* Return bit offset attribute of DIE.  */
Packit 032894
extern int dwarf_bitoffset (Dwarf_Die *die);
Packit 032894
Packit 032894
/* Return array order attribute of DIE.  */
Packit 032894
extern int dwarf_arrayorder (Dwarf_Die *die);
Packit 032894
Packit 032894
/* Return source language attribute of DIE.  */
Packit 032894
extern int dwarf_srclang (Dwarf_Die *die);
Packit 032894
Packit 032894
Packit 032894
/* Get abbreviation at given offset for given DIE.  */
Packit 032894
extern Dwarf_Abbrev *dwarf_getabbrev (Dwarf_Die *die, Dwarf_Off offset,
Packit 032894
				      size_t *lengthp);
Packit 032894
Packit 032894
/* Get abbreviation at given offset in .debug_abbrev section.  */
Packit 032894
extern int dwarf_offabbrev (Dwarf *dbg, Dwarf_Off offset, size_t *lengthp,
Packit 032894
			    Dwarf_Abbrev *abbrevp)
Packit 032894
     __nonnull_attribute__ (4);
Packit 032894
Packit 032894
/* Get abbreviation code.  */
Packit 032894
extern unsigned int dwarf_getabbrevcode (Dwarf_Abbrev *abbrev);
Packit 032894
Packit 032894
/* Get abbreviation tag.  */
Packit 032894
extern unsigned int dwarf_getabbrevtag (Dwarf_Abbrev *abbrev);
Packit 032894
Packit 032894
/* Return true if abbreviation is children flag set.  */
Packit 032894
extern int dwarf_abbrevhaschildren (Dwarf_Abbrev *abbrev);
Packit 032894
Packit 032894
/* Get number of attributes of abbreviation.  */
Packit 032894
extern int dwarf_getattrcnt (Dwarf_Abbrev *abbrev, size_t *attrcntp)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Get specific attribute of abbreviation.  */
Packit 032894
extern int dwarf_getabbrevattr (Dwarf_Abbrev *abbrev, size_t idx,
Packit 032894
				unsigned int *namep, unsigned int *formp,
Packit 032894
				Dwarf_Off *offset);
Packit 032894
Packit 032894
/* Get specific attribute of abbreviation and any data encoded with it.
Packit 032894
   Specifically for DW_FORM_implicit_const data will be set to the
Packit 032894
   constant value associated.  */
Packit 032894
extern int dwarf_getabbrevattr_data (Dwarf_Abbrev *abbrev, size_t idx,
Packit 032894
				     unsigned int *namep, unsigned int *formp,
Packit 032894
				     Dwarf_Sword *datap, Dwarf_Off *offset);
Packit 032894
Packit 032894
/* Get string from-debug_str section.  */
Packit 032894
extern const char *dwarf_getstring (Dwarf *dbg, Dwarf_Off offset,
Packit 032894
				    size_t *lenp);
Packit 032894
Packit 032894
Packit 032894
/* Get public symbol information.  */
Packit 032894
extern ptrdiff_t dwarf_getpubnames (Dwarf *dbg,
Packit 032894
				    int (*callback) (Dwarf *, Dwarf_Global *,
Packit 032894
						     void *),
Packit 032894
				    void *arg, ptrdiff_t offset)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
Packit 032894
/* Get source file information for CU.  */
Packit 032894
extern int dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines,
Packit 032894
			      size_t *nlines) __nonnull_attribute__ (2, 3);
Packit 032894
Packit 032894
/* Return one of the source lines of the CU.  */
Packit 032894
extern Dwarf_Line *dwarf_onesrcline (Dwarf_Lines *lines, size_t idx);
Packit 032894
Packit 032894
/* Get the file source files used in the CU.  */
Packit 032894
extern int dwarf_getsrcfiles (Dwarf_Die *cudie, Dwarf_Files **files,
Packit 032894
			      size_t *nfiles)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
Packit 032894
/* Get source for address in CU.  */
Packit 032894
extern Dwarf_Line *dwarf_getsrc_die (Dwarf_Die *cudie, Dwarf_Addr addr);
Packit 032894
Packit 032894
/* Get source for file and line number.  */
Packit 032894
extern int dwarf_getsrc_file (Dwarf *dbg, const char *fname, int line, int col,
Packit 032894
			      Dwarf_Line ***srcsp, size_t *nsrcs)
Packit 032894
     __nonnull_attribute__ (2, 5, 6);
Packit 032894
Packit 032894
Packit 032894
/* Return line address.  */
Packit 032894
extern int dwarf_lineaddr (Dwarf_Line *line, Dwarf_Addr *addrp);
Packit 032894
Packit 032894
/* Return line VLIW operation index.  */
Packit 032894
extern int dwarf_lineop_index (Dwarf_Line *line, unsigned int *op_indexp);
Packit 032894
Packit 032894
/* Return line number.  */
Packit 032894
extern int dwarf_lineno (Dwarf_Line *line, int *linep)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return column in line.  */
Packit 032894
extern int dwarf_linecol (Dwarf_Line *line, int *colp)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return true if record is for beginning of a statement.  */
Packit 032894
extern int dwarf_linebeginstatement (Dwarf_Line *line, bool *flagp)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return true if record is for end of sequence.  */
Packit 032894
extern int dwarf_lineendsequence (Dwarf_Line *line, bool *flagp)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return true if record is for beginning of a basic block.  */
Packit 032894
extern int dwarf_lineblock (Dwarf_Line *line, bool *flagp)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return true if record is for end of prologue.  */
Packit 032894
extern int dwarf_lineprologueend (Dwarf_Line *line, bool *flagp)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return true if record is for beginning of epilogue.  */
Packit 032894
extern int dwarf_lineepiloguebegin (Dwarf_Line *line, bool *flagp)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return instruction-set architecture in this record.  */
Packit 032894
extern int dwarf_lineisa (Dwarf_Line *line, unsigned int *isap)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return code path discriminator in this record.  */
Packit 032894
extern int dwarf_linediscriminator (Dwarf_Line *line, unsigned int *discp)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
Packit 032894
/* Find line information for address.  The returned string is NULL when
Packit 032894
   an error occured, or the file path.  The file path is either absolute
Packit 032894
   or relative to the compilation directory.  See dwarf_decl_file.  */
Packit 032894
extern const char *dwarf_linesrc (Dwarf_Line *line,
Packit 032894
				  Dwarf_Word *mtime, Dwarf_Word *length);
Packit 032894
Packit 032894
/* Return file information.  The returned string is NULL when
Packit 032894
   an error occured, or the file path.  The file path is either absolute
Packit 032894
   or relative to the compilation directory.  See dwarf_decl_file.  */
Packit 032894
extern const char *dwarf_filesrc (Dwarf_Files *file, size_t idx,
Packit 032894
				  Dwarf_Word *mtime, Dwarf_Word *length);
Packit 032894
Packit 032894
/* Return the Dwarf_Files and index associated with the given Dwarf_Line.  */
Packit 032894
extern int dwarf_line_file (Dwarf_Line *line,
Packit 032894
			    Dwarf_Files **files, size_t *idx)
Packit 032894
    __nonnull_attribute__ (2, 3);
Packit 032894
Packit 032894
/* Return the directory list used in the file information extracted.
Packit 032894
   (*RESULT)[0] is the CU's DW_AT_comp_dir value, and may be null.
Packit 032894
   (*RESULT)[0..*NDIRS-1] are the compile-time include directory path
Packit 032894
   encoded by the compiler.  */
Packit 032894
extern int dwarf_getsrcdirs (Dwarf_Files *files,
Packit 032894
			     const char *const **result, size_t *ndirs)
Packit 032894
  __nonnull_attribute__ (2, 3);
Packit 032894
Packit 032894
/* Iterates through the debug line units.  Returns 0 on success, -1 on
Packit 032894
   error or 1 if there are no more units.  To start iterating use zero
Packit 032894
   for OFF and set *CU to NULL.  On success NEXT_OFF will be set to
Packit 032894
   the next offset to use.  The *CU will be set if this line table
Packit 032894
   needed a specific CU and needs to be given when calling
Packit 032894
   dwarf_next_lines again (to help dwarf_next_lines quickly find the
Packit 032894
   next CU).  *CU might be set to NULL when it couldn't be found (the
Packit 032894
   compilation directory entry will be the empty string in that case)
Packit 032894
   or for DWARF 5 or later tables, which are self contained.  SRCFILES
Packit 032894
   and SRCLINES may be NULL if the caller is not interested in the
Packit 032894
   actual line or file table.  On success and when not NULL, NFILES
Packit 032894
   and NLINES will be set to the number of files in the file table and
Packit 032894
   number of lines in the line table.  */
Packit 032894
extern int dwarf_next_lines (Dwarf *dwarf, Dwarf_Off off,
Packit 032894
			     Dwarf_Off *next_off, Dwarf_CU **cu,
Packit 032894
			     Dwarf_Files **srcfiles, size_t *nfiles,
Packit 032894
			     Dwarf_Lines **srclines, size_t *nlines)
Packit 032894
  __nonnull_attribute__ (3,4);
Packit 032894
Packit 032894
/* Return location expression, decoded as a list of operations.  */
Packit 032894
extern int dwarf_getlocation (Dwarf_Attribute *attr, Dwarf_Op **expr,
Packit 032894
			      size_t *exprlen) __nonnull_attribute__ (2, 3);
Packit 032894
Packit 032894
/* Return location expressions.  If the attribute uses a location list,
Packit 032894
   ADDRESS selects the relevant location expressions from the list.
Packit 032894
   There can be multiple matches, resulting in multiple expressions to
Packit 032894
   return.  EXPRS and EXPRLENS are parallel arrays of NLOCS slots to
Packit 032894
   fill in.  Returns the number of locations filled in, or -1 for
Packit 032894
   errors.  If EXPRS is a null pointer, stores nothing and returns the
Packit 032894
   total number of locations.  A return value of zero means that the
Packit 032894
   location list indicated no value is accessible.  */
Packit 032894
extern int dwarf_getlocation_addr (Dwarf_Attribute *attr, Dwarf_Addr address,
Packit 032894
				   Dwarf_Op **exprs, size_t *exprlens,
Packit 032894
				   size_t nlocs);
Packit 032894
Packit 032894
/* Enumerate the locations ranges and descriptions covered by the
Packit 032894
   given attribute.  In the first call OFFSET should be zero and
Packit 032894
   *BASEP need not be initialized.  Returns -1 for errors, zero when
Packit 032894
   there are no more locations to report, or a nonzero OFFSET
Packit 032894
   value to pass to the next call.  Each subsequent call must preserve
Packit 032894
   *BASEP from the prior call.  Successful calls fill in *STARTP and
Packit 032894
   *ENDP with a contiguous address range and *EXPR with a pointer to
Packit 032894
   an array of operations with length *EXPRLEN.  If the attribute
Packit 032894
   describes a single location description and not a location list the
Packit 032894
   first call (with OFFSET zero) will return the location description
Packit 032894
   in *EXPR with *STARTP set to zero and *ENDP set to minus one.  */
Packit 032894
extern ptrdiff_t dwarf_getlocations (Dwarf_Attribute *attr,
Packit 032894
				     ptrdiff_t offset, Dwarf_Addr *basep,
Packit 032894
				     Dwarf_Addr *startp, Dwarf_Addr *endp,
Packit 032894
				     Dwarf_Op **expr, size_t *exprlen);
Packit 032894
Packit 032894
/* Return the block associated with a DW_OP_implicit_value operation.
Packit 032894
   The OP pointer must point into an expression that dwarf_getlocation
Packit 032894
   or dwarf_getlocation_addr has returned given the same ATTR.  */
Packit 032894
extern int dwarf_getlocation_implicit_value (Dwarf_Attribute *attr,
Packit 032894
					     const Dwarf_Op *op,
Packit 032894
					     Dwarf_Block *return_block)
Packit 032894
  __nonnull_attribute__ (2, 3);
Packit 032894
Packit 032894
/* Return the attribute indicated by a DW_OP_GNU_implicit_pointer operation.
Packit 032894
   The OP pointer must point into an expression that dwarf_getlocation
Packit 032894
   or dwarf_getlocation_addr has returned given the same ATTR.
Packit 032894
   The result is the DW_AT_location or DW_AT_const_value attribute
Packit 032894
   of the OP->number DIE.  */
Packit 032894
extern int dwarf_getlocation_implicit_pointer (Dwarf_Attribute *attr,
Packit 032894
					       const Dwarf_Op *op,
Packit 032894
					       Dwarf_Attribute *result)
Packit 032894
  __nonnull_attribute__ (2, 3);
Packit 032894
Packit 032894
/* Return the DIE associated with an operation such as
Packit 032894
   DW_OP_GNU_implicit_pointer, DW_OP_GNU_parameter_ref, DW_OP_GNU_convert,
Packit 032894
   DW_OP_GNU_reinterpret, DW_OP_GNU_const_type, DW_OP_GNU_regval_type or
Packit 032894
   DW_OP_GNU_deref_type.  The OP pointer must point into an expression that
Packit 032894
   dwarf_getlocation or dwarf_getlocation_addr has returned given the same
Packit 032894
   ATTR.  The RESULT is a DIE that expresses a type or value needed by the
Packit 032894
   given OP.  */
Packit 032894
extern int dwarf_getlocation_die (Dwarf_Attribute *attr,
Packit 032894
				  const Dwarf_Op *op,
Packit 032894
				  Dwarf_Die *result)
Packit 032894
  __nonnull_attribute__ (2, 3);
Packit 032894
Packit 032894
/* Return the attribute expressing a value associated with an operation such
Packit 032894
   as DW_OP_implicit_value, DW_OP_GNU_entry_value or DW_OP_GNU_const_type.
Packit 032894
   The OP pointer must point into an expression that dwarf_getlocation
Packit 032894
   or dwarf_getlocation_addr has returned given the same ATTR.
Packit 032894
   The RESULT is a value expressed by an attribute such as DW_AT_location
Packit 032894
   or DW_AT_const_value.  */
Packit 032894
extern int dwarf_getlocation_attr (Dwarf_Attribute *attr,
Packit 032894
				   const Dwarf_Op *op,
Packit 032894
				   Dwarf_Attribute *result)
Packit 032894
  __nonnull_attribute__ (2, 3);
Packit 032894
Packit 032894
Packit 032894
/* Compute the byte-size of a type DIE according to DWARF rules.
Packit 032894
   For most types, this is just DW_AT_byte_size.
Packit 032894
   For DW_TAG_array_type it can apply much more complex rules.  */
Packit 032894
extern int dwarf_aggregate_size (Dwarf_Die *die, Dwarf_Word *size);
Packit 032894
Packit 032894
/* Given a language code, as returned by dwarf_srclan, get the default
Packit 032894
   lower bound for a subrange type without a lower bound attribute.
Packit 032894
   Returns zero on success or -1 on failure when the given language
Packit 032894
   wasn't recognized.  */
Packit 032894
extern int dwarf_default_lower_bound (int lang, Dwarf_Sword *result)
Packit 032894
  __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return scope DIEs containing PC address.
Packit 032894
   Sets *SCOPES to a malloc'd array of Dwarf_Die structures,
Packit 032894
   and returns the number of elements in the array.
Packit 032894
   (*SCOPES)[0] is the DIE for the innermost scope containing PC,
Packit 032894
   (*SCOPES)[1] is the DIE for the scope containing that scope, and so on.
Packit 032894
   Returns -1 for errors or 0 if no scopes match PC.  */
Packit 032894
extern int dwarf_getscopes (Dwarf_Die *cudie, Dwarf_Addr pc,
Packit 032894
			    Dwarf_Die **scopes);
Packit 032894
Packit 032894
/* Return scope DIEs containing the given DIE.
Packit 032894
   Sets *SCOPES to a malloc'd array of Dwarf_Die structures,
Packit 032894
   and returns the number of elements in the array.
Packit 032894
   (*SCOPES)[0] is a copy of DIE.
Packit 032894
   (*SCOPES)[1] is the DIE for the scope containing that scope, and so on.
Packit 032894
   Returns -1 for errors or 0 if DIE is not found in any scope entry.  */
Packit 032894
extern int dwarf_getscopes_die (Dwarf_Die *die, Dwarf_Die **scopes);
Packit 032894
Packit 032894
Packit 032894
/* Search SCOPES[0..NSCOPES-1] for a variable called NAME.
Packit 032894
   Ignore the first SKIP_SHADOWS scopes that match the name.
Packit 032894
   If MATCH_FILE is not null, accept only declaration in that source file;
Packit 032894
   if MATCH_LINENO or MATCH_LINECOL are also nonzero, accept only declaration
Packit 032894
   at that line and column.
Packit 032894
Packit 032894
   If successful, fill in *RESULT with the DIE of the variable found,
Packit 032894
   and return N where SCOPES[N] is the scope defining the variable.
Packit 032894
   Return -1 for errors or -2 for no matching variable found.  */
Packit 032894
extern int dwarf_getscopevar (Dwarf_Die *scopes, int nscopes,
Packit 032894
			      const char *name, int skip_shadows,
Packit 032894
			      const char *match_file,
Packit 032894
			      int match_lineno, int match_linecol,
Packit 032894
			      Dwarf_Die *result);
Packit 032894
Packit 032894
Packit 032894
Packit 032894
/* Return list address ranges.  */
Packit 032894
extern int dwarf_getaranges (Dwarf *dbg, Dwarf_Aranges **aranges,
Packit 032894
			     size_t *naranges)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return one of the address range entries.  */
Packit 032894
extern Dwarf_Arange *dwarf_onearange (Dwarf_Aranges *aranges, size_t idx);
Packit 032894
Packit 032894
/* Return information in address range record.  */
Packit 032894
extern int dwarf_getarangeinfo (Dwarf_Arange *arange, Dwarf_Addr *addrp,
Packit 032894
				Dwarf_Word *lengthp, Dwarf_Off *offsetp);
Packit 032894
Packit 032894
/* Get address range which includes given address.  */
Packit 032894
extern Dwarf_Arange *dwarf_getarange_addr (Dwarf_Aranges *aranges,
Packit 032894
					   Dwarf_Addr addr);
Packit 032894
Packit 032894
Packit 032894
Packit 032894
/* Get functions in CUDIE.  The given callback will be called for all
Packit 032894
   defining DW_TAG_subprograms in the CU DIE tree.  If the callback
Packit 032894
   returns DWARF_CB_ABORT the return value can be used as offset argument
Packit 032894
   to resume the function to find all remaining functions (this is not
Packit 032894
   really recommended, since it needs to rewalk the CU DIE tree first till
Packit 032894
   that offset is found again).  If the callback returns DWARF_CB_OK
Packit 032894
   dwarf_getfuncs will not return but keep calling the callback for each
Packit 032894
   function DIE it finds.  Pass zero for offset on the first call to walk
Packit 032894
   the full CU DIE tree.  If no more functions can be found and the callback
Packit 032894
   returned DWARF_CB_OK then the function returns zero.  */
Packit 032894
extern ptrdiff_t dwarf_getfuncs (Dwarf_Die *cudie,
Packit 032894
				 int (*callback) (Dwarf_Die *, void *),
Packit 032894
				 void *arg, ptrdiff_t offset);
Packit 032894
Packit 032894
Packit 032894
/* Return file name containing definition of the given declaration.
Packit 032894
   Of the DECL has an (indirect, see dwarf_attr_integrate) decl_file
Packit 032894
   attribute.  The returned file path is either absolute, or relative
Packit 032894
   to the compilation directory.  Given the decl DIE, the compilation
Packit 032894
   directory can be retrieved through:
Packit 032894
   dwarf_formstring (dwarf_attr (dwarf_diecu (decl, &cudie, NULL, NULL),
Packit 032894
                                 DW_AT_comp_dir, &attr));
Packit 032894
   Returns NULL if no decl_file could be found or an error occured.  */
Packit 032894
extern const char *dwarf_decl_file (Dwarf_Die *decl);
Packit 032894
Packit 032894
/* Get line number of beginning of given declaration.  */
Packit 032894
extern int dwarf_decl_line (Dwarf_Die *decl, int *linep)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Get column number of beginning of given declaration.  */
Packit 032894
extern int dwarf_decl_column (Dwarf_Die *decl, int *colp)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
Packit 032894
/* Return nonzero if given function is an abstract inline definition.  */
Packit 032894
extern int dwarf_func_inline (Dwarf_Die *func);
Packit 032894
Packit 032894
/* Find each concrete inlined instance of the abstract inline definition.  */
Packit 032894
extern int dwarf_func_inline_instances (Dwarf_Die *func,
Packit 032894
					int (*callback) (Dwarf_Die *, void *),
Packit 032894
					void *arg);
Packit 032894
Packit 032894
Packit 032894
/* Find the appropriate PC location or locations for function entry
Packit 032894
   breakpoints for the given DW_TAG_subprogram DIE.  Returns -1 for errors.
Packit 032894
   On success, returns the number of breakpoint locations (never zero)
Packit 032894
   and sets *BKPTS to a malloc'd vector of addresses.  */
Packit 032894
extern int dwarf_entry_breakpoints (Dwarf_Die *die, Dwarf_Addr **bkpts);
Packit 032894
Packit 032894
Packit 032894
/* Iterate through the macro unit referenced by CUDIE and call
Packit 032894
   CALLBACK for each macro information entry.  To start the iteration,
Packit 032894
   one would pass DWARF_GETMACROS_START for TOKEN.
Packit 032894
Packit 032894
   The iteration continues while CALLBACK returns DWARF_CB_OK.  If the
Packit 032894
   callback returns DWARF_CB_ABORT, the iteration stops and a
Packit 032894
   continuation token is returned, which can be used to restart the
Packit 032894
   iteration at the point where it ended.  Returns -1 for errors or 0
Packit 032894
   if there are no more macro entries.
Packit 032894
Packit 032894
   Note that the Dwarf_Macro pointer passed to the callback is only
Packit 032894
   valid for the duration of the callback invocation.
Packit 032894
Packit 032894
   For backward compatibility, a token of 0 is accepted for starting
Packit 032894
   the iteration as well, but in that case this interface will refuse
Packit 032894
   to serve opcode 0xff from .debug_macro sections.  Such opcode would
Packit 032894
   be considered invalid and would cause dwarf_getmacros to return
Packit 032894
   with error.  */
Packit 032894
#define DWARF_GETMACROS_START PTRDIFF_MIN
Packit 032894
extern ptrdiff_t dwarf_getmacros (Dwarf_Die *cudie,
Packit 032894
				  int (*callback) (Dwarf_Macro *, void *),
Packit 032894
				  void *arg, ptrdiff_t token)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* This is similar in operation to dwarf_getmacros, but selects the
Packit 032894
   unit to iterate through by offset instead of by CU, and always
Packit 032894
   iterates .debug_macro.  This can be used for handling
Packit 032894
   DW_MACRO_GNU_transparent_include's or similar opcodes.
Packit 032894
Packit 032894
   TOKEN value of DWARF_GETMACROS_START can be used to start the
Packit 032894
   iteration.
Packit 032894
Packit 032894
   It is not appropriate to obtain macro unit offset by hand from a CU
Packit 032894
   DIE and then request iteration through this interface.  The reason
Packit 032894
   for this is that if a dwarf_macro_getsrcfiles is later called,
Packit 032894
   there would be no way to figure out what DW_AT_comp_dir was present
Packit 032894
   on the CU DIE, and file names referenced in either the macro unit
Packit 032894
   itself, or the .debug_line unit that it references, might be wrong.
Packit 032894
   Use dwarf_getmacros.  */
Packit 032894
extern ptrdiff_t dwarf_getmacros_off (Dwarf *dbg, Dwarf_Off macoff,
Packit 032894
				      int (*callback) (Dwarf_Macro *, void *),
Packit 032894
				      void *arg, ptrdiff_t token)
Packit 032894
  __nonnull_attribute__ (3);
Packit 032894
Packit 032894
/* Get the source files used by the macro entry.  You shouldn't assume
Packit 032894
   that Dwarf_Files references will remain valid after MACRO becomes
Packit 032894
   invalid.  (Which is to say it's only valid within the
Packit 032894
   dwarf_getmacros* callback.)  Returns 0 for success or a negative
Packit 032894
   value in case of an error.  */
Packit 032894
extern int dwarf_macro_getsrcfiles (Dwarf *dbg, Dwarf_Macro *macro,
Packit 032894
				    Dwarf_Files **files, size_t *nfiles)
Packit 032894
  __nonnull_attribute__ (2, 3, 4);
Packit 032894
Packit 032894
/* Return macro opcode.  That's a constant that can be either from
Packit 032894
   DW_MACINFO_* domain or DW_MACRO_GNU_* domain.  The two domains have
Packit 032894
   compatible values, so it's OK to use either of them for
Packit 032894
   comparisons.  The only differences is 0xff, which could be either
Packit 032894
   DW_MACINFO_vendor_ext or a vendor-defined DW_MACRO_* constant.  One
Packit 032894
   would need to look if the CU DIE which the iteration was requested
Packit 032894
   for has attribute DW_AT_macro_info, or either of DW_AT_GNU_macros
Packit 032894
   or DW_AT_macros to differentiate the two interpretations.  */
Packit 032894
extern int dwarf_macro_opcode (Dwarf_Macro *macro, unsigned int *opcodep)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Get number of parameters of MACRO and store it to *PARAMCNTP.  */
Packit 032894
extern int dwarf_macro_getparamcnt (Dwarf_Macro *macro, size_t *paramcntp);
Packit 032894
Packit 032894
/* Get IDX-th parameter of MACRO (numbered from zero), and stores it
Packit 032894
   to *ATTRIBUTE.  Returns 0 on success or -1 for errors.
Packit 032894
Packit 032894
   After a successful call, you can query ATTRIBUTE by dwarf_whatform
Packit 032894
   to determine which of the dwarf_formX calls to make to get actual
Packit 032894
   value out of ATTRIBUTE.  Note that calling dwarf_whatattr is not
Packit 032894
   meaningful for pseudo-attributes formed this way.  */
Packit 032894
extern int dwarf_macro_param (Dwarf_Macro *macro, size_t idx,
Packit 032894
			      Dwarf_Attribute *attribute);
Packit 032894
Packit 032894
/* Return macro parameter with index 0.  This will return -1 if the
Packit 032894
   parameter is not an integral value.  Use dwarf_macro_param for more
Packit 032894
   general access.  */
Packit 032894
extern int dwarf_macro_param1 (Dwarf_Macro *macro, Dwarf_Word *paramp)
Packit 032894
     __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Return macro parameter with index 1.  This will return -1 if the
Packit 032894
   parameter is not an integral or string value.  Use
Packit 032894
   dwarf_macro_param for more general access.  */
Packit 032894
extern int dwarf_macro_param2 (Dwarf_Macro *macro, Dwarf_Word *paramp,
Packit 032894
			       const char **strp);
Packit 032894
Packit 032894
/* Compute what's known about a call frame when the PC is at ADDRESS.
Packit 032894
   Returns 0 for success or -1 for errors.
Packit 032894
   On success, *FRAME is a malloc'd pointer.  */
Packit 032894
extern int dwarf_cfi_addrframe (Dwarf_CFI *cache,
Packit 032894
				Dwarf_Addr address, Dwarf_Frame **frame)
Packit 032894
  __nonnull_attribute__ (3);
Packit 032894
Packit 032894
/* Return the DWARF register number used in FRAME to denote
Packit 032894
   the return address in FRAME's caller frame.  The remaining
Packit 032894
   arguments can be non-null to fill in more information.
Packit 032894
Packit 032894
   Fill [*START, *END) with the PC range to which FRAME's information applies.
Packit 032894
   Fill in *SIGNALP to indicate whether this is a signal-handling frame.
Packit 032894
   If true, this is the implicit call frame that calls a signal handler.
Packit 032894
   This frame's "caller" is actually the interrupted state, not a call;
Packit 032894
   its return address is an exact PC, not a PC after a call instruction.  */
Packit 032894
extern int dwarf_frame_info (Dwarf_Frame *frame,
Packit 032894
			     Dwarf_Addr *start, Dwarf_Addr *end, bool *signalp);
Packit 032894
Packit 032894
/* Return a DWARF expression that yields the Canonical Frame Address at
Packit 032894
   this frame state.  Returns -1 for errors, or zero for success, with
Packit 032894
   *NOPS set to the number of operations stored at *OPS.  That pointer
Packit 032894
   can be used only as long as FRAME is alive and unchanged.  *NOPS is
Packit 032894
   zero if the CFA cannot be determined here.  Note that if nonempty,
Packit 032894
   *OPS is a DWARF expression, not a location description--append
Packit 032894
   DW_OP_stack_value to a get a location description for the CFA.  */
Packit 032894
extern int dwarf_frame_cfa (Dwarf_Frame *frame, Dwarf_Op **ops, size_t *nops)
Packit 032894
  __nonnull_attribute__ (2);
Packit 032894
Packit 032894
/* Deliver a DWARF location description that yields the location or
Packit 032894
   value of DWARF register number REGNO in the state described by FRAME.
Packit 032894
Packit 032894
   Returns -1 for errors or zero for success, setting *NOPS to the
Packit 032894
   number of operations in the array stored at *OPS.  Note the last
Packit 032894
   operation is DW_OP_stack_value if there is no mutable location but
Packit 032894
   only a computable value.
Packit 032894
Packit 032894
   *NOPS zero with *OPS set to OPS_MEM means CFI says the caller's
Packit 032894
   REGNO is "undefined", i.e. it's call-clobbered and cannot be recovered.
Packit 032894
Packit 032894
   *NOPS zero with *OPS set to a null pointer means CFI says the
Packit 032894
   caller's REGNO is "same_value", i.e. this frame did not change it;
Packit 032894
   ask the caller frame where to find it.
Packit 032894
Packit 032894
   For common simple expressions *OPS is OPS_MEM.  For arbitrary DWARF
Packit 032894
   expressions in the CFI, *OPS is an internal pointer that can be used as
Packit 032894
   long as the Dwarf_CFI used to create FRAME remains alive.  */
Packit 032894
extern int dwarf_frame_register (Dwarf_Frame *frame, int regno,
Packit 032894
				 Dwarf_Op ops_mem[3],
Packit 032894
				 Dwarf_Op **ops, size_t *nops)
Packit 032894
  __nonnull_attribute__ (3, 4, 5);
Packit 032894
Packit 032894
Packit 032894
/* Return error code of last failing function call.  This value is kept
Packit 032894
   separately for each thread.  */
Packit 032894
extern int dwarf_errno (void);
Packit 032894
Packit 032894
/* Return error string for ERROR.  If ERROR is zero, return error string
Packit 032894
   for most recent error or NULL is none occurred.  If ERROR is -1 the
Packit 032894
   behaviour is similar to the last case except that not NULL but a legal
Packit 032894
   string is returned.  */
Packit 032894
extern const char *dwarf_errmsg (int err);
Packit 032894
Packit 032894
Packit 032894
/* Register new Out-Of-Memory handler.  The old handler is returned.  */
Packit 032894
extern Dwarf_OOM dwarf_new_oom_handler (Dwarf *dbg, Dwarf_OOM handler);
Packit 032894
Packit 032894
Packit 032894
/* Inline optimizations.  */
Packit 032894
#ifdef __OPTIMIZE__
Packit 032894
/* Return attribute code of given attribute.  */
Packit 032894
__libdw_extern_inline unsigned int
Packit 032894
dwarf_whatattr (Dwarf_Attribute *attr)
Packit 032894
{
Packit 032894
  return attr == NULL ? 0 : attr->code;
Packit 032894
}
Packit 032894
Packit 032894
/* Return attribute code of given attribute.  */
Packit 032894
__libdw_extern_inline unsigned int
Packit 032894
dwarf_whatform (Dwarf_Attribute *attr)
Packit 032894
{
Packit 032894
  return attr == NULL ? 0 : attr->form;
Packit 032894
}
Packit 032894
#endif	/* Optimize.  */
Packit 032894
Packit 032894
#ifdef __cplusplus
Packit 032894
}
Packit 032894
#endif
Packit 032894
Packit 032894
#endif	/* libdw.h */