Blame libdw/libdw.h

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