1b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Interfaces for libdw.
2209f149fdcdb5ecad8d5660429128b771d9b44cdMark Wielaard   Copyright (C) 2002-2010, 2013, 2014 Red Hat, Inc.
3de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   This file is part of elfutils.
4b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
5de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   This file is free software; you can redistribute it and/or modify
6de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   it under the terms of either
7b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
8de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard     * the GNU Lesser General Public License as published by the Free
9de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       Software Foundation; either version 3 of the License, or (at
10de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       your option) any later version
11de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
12de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   or
13de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
14de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard     * the GNU General Public License as published by the Free
15de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       Software Foundation; either version 2 of the License, or (at
16de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       your option) any later version
17de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
18de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   or both in parallel, as here.
19de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
20de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   elfutils is distributed in the hope that it will be useful, but
21361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper   WITHOUT ANY WARRANTY; without even the implied warranty of
22361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper   General Public License for more details.
24361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper
25de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   You should have received copies of the GNU General Public License and
26de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   the GNU Lesser General Public License along with this program.  If
27de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   not, see <http://www.gnu.org/licenses/>.  */
28b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
29b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#ifndef _LIBDW_H
30b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#define _LIBDW_H	1
31b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
32b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#include <gelf.h>
33b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#include <stdbool.h>
34b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#include <stddef.h>
35edb079a596b25379828836e501d003f20afdb879Petr Machata#include <stdint.h>
36b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
37b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
38b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
39b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper# define __nonnull_attribute__(...) __attribute__ ((__nonnull__ (__VA_ARGS__)))
40e4c22ea004c02a58f5db5eb53794275344c17958Roland McGrath# define __deprecated_attribute__ __attribute__ ((__deprecated__))
41b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#else
42b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper# define __nonnull_attribute__(args...)
43e4c22ea004c02a58f5db5eb53794275344c17958Roland McGrath# define __deprecated_attribute__
44b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#endif
45b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
46e4c22ea004c02a58f5db5eb53794275344c17958Roland McGrath
4787d4780beb37f265fa89ffd909e77513ef516180Roland McGrath#ifdef __GNUC_STDC_INLINE__
48b597dfad924980dede10d7c19d87900b6172e599Ulrich Drepper# define __libdw_extern_inline extern __inline __attribute__ ((__gnu_inline__))
4987d4780beb37f265fa89ffd909e77513ef516180Roland McGrath#else
50b597dfad924980dede10d7c19d87900b6172e599Ulrich Drepper# define __libdw_extern_inline extern __inline
5187d4780beb37f265fa89ffd909e77513ef516180Roland McGrath#endif
5287d4780beb37f265fa89ffd909e77513ef516180Roland McGrath
53b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
54b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Mode for the session.  */
55b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef enum
56b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  {
57b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    DWARF_C_READ,		/* Read .. */
58b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    DWARF_C_RDWR,		/* Read and write .. */
59b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    DWARF_C_WRITE,		/* Write .. */
60b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  }
61b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperDwarf_Cmd;
62b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
63b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
64b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Callback results.  */
65b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperenum
66b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper{
67b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_CB_OK = 0,
68b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_CB_ABORT
69b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper};
70b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
71b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
72b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Error values.  */
73b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperenum
74b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  {
75b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    DW_TAG_invalid = 0
76b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#define DW_TAG_invalid	DW_TAG_invalid
77b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  };
78b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
79b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
80b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Type for offset in DWARF file.  */
81b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef GElf_Off Dwarf_Off;
82b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
83b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Type for address in DWARF file.  */
84b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef GElf_Addr Dwarf_Addr;
85b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
86b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Integer types.  Big enough to hold any numeric value.  */
87b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef GElf_Xword Dwarf_Word;
88b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef GElf_Sxword Dwarf_Sword;
89b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* For the times we know we do not need that much.  */
90b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef GElf_Half Dwarf_Half;
91b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
92b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
93b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* DWARF abbreviation record.  */
94b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef struct Dwarf_Abbrev Dwarf_Abbrev;
95b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
96b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Returned to show the last DIE has be returned.  */
97b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#define DWARF_END_ABBREV ((Dwarf_Abbrev *) -1l)
98b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
99b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Source code line information for CU.  */
100b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef struct Dwarf_Lines_s Dwarf_Lines;
101b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
102b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* One source code line information.  */
103b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef struct Dwarf_Line_s Dwarf_Line;
104b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
105b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Source file information.  */
106b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef struct Dwarf_Files_s Dwarf_Files;
107b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
108b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* One address range record.  */
109b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef struct Dwarf_Arange_s Dwarf_Arange;
110b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
111b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Address ranges of a file.  */
112b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef struct Dwarf_Aranges_s Dwarf_Aranges;
113b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
114b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* CU representation.  */
115b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperstruct Dwarf_CU;
116209f149fdcdb5ecad8d5660429128b771d9b44cdMark Wielaardtypedef struct Dwarf_CU Dwarf_CU;
117b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
118b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Macro information.  */
119b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef struct Dwarf_Macro_s Dwarf_Macro;
120b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
121b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Attribute representation.  */
122b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef struct
123b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper{
124b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  unsigned int code;
125b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  unsigned int form;
126b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  unsigned char *valp;
127b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  struct Dwarf_CU *cu;
128b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper} Dwarf_Attribute;
129b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
130b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
131b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Data block representation.  */
132b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef struct
133b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper{
134b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Dwarf_Word length;
135b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  unsigned char *data;
136b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper} Dwarf_Block;
137b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
138b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
139b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* DIE information.  */
140b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef struct
141b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper{
142b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  /* The offset can be computed from the address.  */
143b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  void *addr;
144b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  struct Dwarf_CU *cu;
145b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Dwarf_Abbrev *abbrev;
146b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  // XXX We'll see what other information will be needed.
147b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  long int padding__;
148b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper} Dwarf_Die;
149b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
150b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Returned to show the last DIE has be returned.  */
151b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#define DWARF_END_DIE ((Dwarf_Die *) -1l)
152b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
153b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
154b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Global symbol information.  */
155b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef struct
156b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper{
157b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Dwarf_Off cu_offset;
158b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Dwarf_Off die_offset;
159b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  const char *name;
160b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper} Dwarf_Global;
161b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
162b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
1636724c90d02659f7466b67b357563042e403d154eRoland McGrath/* One operation in a DWARF location expression.
1646724c90d02659f7466b67b357563042e403d154eRoland McGrath   A location expression is an array of these.  */
165b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef struct
166b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper{
167b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  uint8_t atom;			/* Operation */
168b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Dwarf_Word number;		/* Operand */
169b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Dwarf_Word number2;		/* Possible second operand */
170b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Dwarf_Word offset;		/* Offset in location expression */
1716724c90d02659f7466b67b357563042e403d154eRoland McGrath} Dwarf_Op;
172b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
173b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
1743c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath/* This describes one Common Information Entry read from a CFI section.
1753c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   Pointers here point into the DATA->d_buf block passed to dwarf_next_cfi.  */
1763c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrathtypedef struct
1773c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath{
1783c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  Dwarf_Off CIE_id;	 /* Always DW_CIE_ID_64 in Dwarf_CIE structures.  */
1793c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
1803c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  /* Instruction stream describing initial state used by FDEs.  If
1813c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath     we did not understand the whole augmentation string and it did
1823c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath     not use 'z', then there might be more augmentation data here
1833c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath     (and in FDEs) before the actual instructions.  */
1843c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  const uint8_t *initial_instructions;
1853c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  const uint8_t *initial_instructions_end;
1863c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
1873c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  Dwarf_Word code_alignment_factor;
1883c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  Dwarf_Sword data_alignment_factor;
1893c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  Dwarf_Word return_address_register;
1903c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
1913c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  const char *augmentation;	/* Augmentation string.  */
1923c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
1933c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  /* Augmentation data, might be NULL.  The size is correct only if
1943c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath     we understood the augmentation string sufficiently.  */
1953c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  const uint8_t *augmentation_data;
1963c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  size_t augmentation_data_size;
1973c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  size_t fde_augmentation_data_size;
1983c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath} Dwarf_CIE;
1993c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
2003c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath/* This describes one Frame Description Entry read from a CFI section.
2013c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   Pointers here point into the DATA->d_buf block passed to dwarf_next_cfi.  */
2023c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrathtypedef struct
2033c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath{
2043c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  /* Section offset of CIE this FDE refers to.  This will never be
2053c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath     DW_CIE_ID_64 in an FDE.  If this value is DW_CIE_ID_64, this is
2063c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath     actually a Dwarf_CIE structure.  */
2073c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  Dwarf_Off CIE_pointer;
2083c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
2093c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  /* We can't really decode anything further without looking up the CIE
2103c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath     and checking its augmentation string.  Here follows the encoded
2113c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath     initial_location and address_range, then any augmentation data,
2123c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath     then the instruction stream.  This FDE describes PC locations in
2133c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath     the byte range [initial_location, initial_location+address_range).
2143c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath     When the CIE augmentation string uses 'z', the augmentation data is
2153c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath     a DW_FORM_block (self-sized).  Otherwise, when we understand the
2163c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath     augmentation string completely, fde_augmentation_data_size gives
2173c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath     the number of bytes of augmentation data before the instructions.  */
2183c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  const uint8_t *start;
2193c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  const uint8_t *end;
2203c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath} Dwarf_FDE;
2213c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
2223c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath/* Each entry in a CFI section is either a CIE described by Dwarf_CIE or
2233c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   an FDE described by Dward_FDE.  Check CIE_id to see which you have.  */
2243c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrathtypedef union
2253c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath{
2263c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  Dwarf_Off CIE_id;	 /* Always DW_CIE_ID_64 in Dwarf_CIE structures.  */
2273c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  Dwarf_CIE cie;
2283c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  Dwarf_FDE fde;
2293c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath} Dwarf_CFI_Entry;
2303c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
23108e71dbedcd97273432d55ab0e4c476c287a5aa6Mark Wielaard#define dwarf_cfi_cie_p(entry)	((entry)->cie.CIE_id == DW_CIE_ID_64)
23208e71dbedcd97273432d55ab0e4c476c287a5aa6Mark Wielaard
2333c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath/* Opaque type representing a frame state described by CFI.  */
2343c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrathtypedef struct Dwarf_Frame_s Dwarf_Frame;
2353c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
2363c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath/* Opaque type representing a CFI section found in a DWARF or ELF file.  */
2373c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrathtypedef struct Dwarf_CFI_s Dwarf_CFI;
2383c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
2393c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
240b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Handle for debug sessions.  */
241b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef struct Dwarf Dwarf;
242b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
243b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
244b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Out-Of-Memory handler.  */
245b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#if __GNUC__ < 4
246b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef void (*Dwarf_OOM) (void);
247b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#else
248b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef void (*__attribute__ ((noreturn)) Dwarf_OOM) (void);
249b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#endif
250b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
251b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
2523be744790cfa3d8614fe81b1e398c505a7025915Ulrich Drepper#ifdef __cplusplus
2533be744790cfa3d8614fe81b1e398c505a7025915Ulrich Drepperextern "C" {
2543be744790cfa3d8614fe81b1e398c505a7025915Ulrich Drepper#endif
2553be744790cfa3d8614fe81b1e398c505a7025915Ulrich Drepper
256b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Create a handle for a new debug session.  */
257b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern Dwarf *dwarf_begin (int fildes, Dwarf_Cmd cmd);
258b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
259b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Create a handle for a new debug session for an ELF file.  */
260b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern Dwarf *dwarf_begin_elf (Elf *elf, Dwarf_Cmd cmd, Elf_Scn *scngrp);
261b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
262b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Retrieve ELF descriptor used for DWARF access.  */
263b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern Elf *dwarf_getelf (Dwarf *dwarf);
264b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
265209f149fdcdb5ecad8d5660429128b771d9b44cdMark Wielaard/* Retieve DWARF descriptor used for a Dwarf_Die or Dwarf_Attribute.
266209f149fdcdb5ecad8d5660429128b771d9b44cdMark Wielaard   A Dwarf_Die or a Dwarf_Attribute is associated with a particular
267209f149fdcdb5ecad8d5660429128b771d9b44cdMark Wielaard   Dwarf_CU handle.  This function returns the DWARF descriptor for
268209f149fdcdb5ecad8d5660429128b771d9b44cdMark Wielaard   that Dwarf_CU.  */
269209f149fdcdb5ecad8d5660429128b771d9b44cdMark Wielaardextern Dwarf *dwarf_cu_getdwarf (Dwarf_CU *cu);
270209f149fdcdb5ecad8d5660429128b771d9b44cdMark Wielaard
27135e2a765c002374f1b88dc81ce154bed42f9b1d8Florian Weimer/* Retrieves the DWARF descriptor for debugaltlink data.  Returns NULL
27235e2a765c002374f1b88dc81ce154bed42f9b1d8Florian Weimer   if no alternate debug data has been supplied.  */
27335e2a765c002374f1b88dc81ce154bed42f9b1d8Florian Weimerextern Dwarf *dwarf_getalt (Dwarf *main);
27435e2a765c002374f1b88dc81ce154bed42f9b1d8Florian Weimer
27535e2a765c002374f1b88dc81ce154bed42f9b1d8Florian Weimer/* Provides the data referenced by the .gnu_debugaltlink section.  The
27635e2a765c002374f1b88dc81ce154bed42f9b1d8Florian Weimer   caller should check that MAIN and ALT match (i.e., they have the
27735e2a765c002374f1b88dc81ce154bed42f9b1d8Florian Weimer   same build ID).  It is the responsibility of the caller to ensure
27835e2a765c002374f1b88dc81ce154bed42f9b1d8Florian Weimer   that the data referenced by ALT stays valid while it is used by
27935e2a765c002374f1b88dc81ce154bed42f9b1d8Florian Weimer   MAIN, until dwarf_setalt is called on MAIN with a different
28035e2a765c002374f1b88dc81ce154bed42f9b1d8Florian Weimer   descriptor, or dwarf_end.  */
28135e2a765c002374f1b88dc81ce154bed42f9b1d8Florian Weimerextern void dwarf_setalt (Dwarf *main, Dwarf *alt);
28235e2a765c002374f1b88dc81ce154bed42f9b1d8Florian Weimer
283b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Release debugging handling context.  */
284b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_end (Dwarf *dwarf);
285b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
286b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
287b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Get the data block for the .debug_info section.  */
288b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern Elf_Data *dwarf_getscn_info (Dwarf *dwarf);
289b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
2903e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath/* Read the header for the DWARF CU.  */
291b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_nextcu (Dwarf *dwarf, Dwarf_Off off, Dwarf_Off *next_off,
292b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper			 size_t *header_sizep, Dwarf_Off *abbrev_offsetp,
293b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper			 uint8_t *address_sizep, uint8_t *offset_sizep)
294b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (3);
295b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
2963e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath/* Read the header of a DWARF CU or type unit.  If TYPE_SIGNATUREP is not
2973e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath   null, this reads a type unit from the .debug_types section; otherwise
2983e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath   this reads a CU from the .debug_info section.  */
2993e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrathextern int dwarf_next_unit (Dwarf *dwarf, Dwarf_Off off, Dwarf_Off *next_off,
3002b1f09548b66c2c75d5be6f13cd9374adc95f8d8Roland McGrath			    size_t *header_sizep, Dwarf_Half *versionp,
3013e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath			    Dwarf_Off *abbrev_offsetp,
3023e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath			    uint8_t *address_sizep, uint8_t *offset_sizep,
3033e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath			    uint64_t *type_signaturep, Dwarf_Off *type_offsetp)
3043e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath     __nonnull_attribute__ (3);
3053e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath
306b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
3073c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath/* Decode one DWARF CFI entry (CIE or FDE) from the raw section data.
3083c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   The E_IDENT from the originating ELF file indicates the address
3093c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   size and byte order used in the CFI section contained in DATA;
3103c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   EH_FRAME_P should be true for .eh_frame format and false for
3113c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   .debug_frame format.  OFFSET is the byte position in the section
3123c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   to start at; on return *NEXT_OFFSET is filled in with the byte
3133c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   position immediately after this entry.
3143c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
3153c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   On success, returns 0 and fills in *ENTRY; use dwarf_cfi_cie_p to
3163c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   see whether ENTRY->cie or ENTRY->fde is valid.
3173c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
3183c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   On errors, returns -1.  Some format errors will permit safely
3193c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   skipping to the next CFI entry though the current one is unusable.
3203c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   In that case, *NEXT_OFF will be updated before a -1 return.
3213c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
3223c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   If there are no more CFI entries left in the section,
3233c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   returns 1 and sets *NEXT_OFFSET to (Dwarf_Off) -1.  */
3243c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrathextern int dwarf_next_cfi (const unsigned char e_ident[],
3253c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath			   Elf_Data *data, bool eh_frame_p,
3263c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath			   Dwarf_Off offset, Dwarf_Off *next_offset,
3273c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath			   Dwarf_CFI_Entry *entry)
3283c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  __nonnull_attribute__ (1, 2, 5, 6);
3293c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
3303c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath/* Use the CFI in the DWARF .debug_frame section.
3313c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   Returns NULL if there is no such section (not an error).
3323c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   The pointer returned can be used until dwarf_end is called on DWARF,
3333c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   and must not be passed to dwarf_cfi_end.
3343c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   Calling this more than once returns the same pointer.  */
3353c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrathextern Dwarf_CFI *dwarf_getcfi (Dwarf *dwarf);
3363c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
3373c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath/* Use the CFI in the ELF file's exception-handling data.
3383c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   Returns NULL if there is no such data.
3393c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   The pointer returned can be used until elf_end is called on ELF,
3403c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   and must be passed to dwarf_cfi_end before then.
3413c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   Calling this more than once allocates independent data structures.  */
3423c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrathextern Dwarf_CFI *dwarf_getcfi_elf (Elf *elf);
3433c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
3443c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath/* Release resources allocated by dwarf_getcfi_elf.  */
3453c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrathextern int dwarf_cfi_end (Dwarf_CFI *cache);
3463c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
3473c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
3480b72b650b173fdf5467b337ff26e97e69daed869Mark Wielaard/* Return DIE at given offset in .debug_info section.  */
349b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern Dwarf_Die *dwarf_offdie (Dwarf *dbg, Dwarf_Off offset,
350b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper				Dwarf_Die *result) __nonnull_attribute__ (3);
351b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
3522b1f09548b66c2c75d5be6f13cd9374adc95f8d8Roland McGrath/* Return DIE at given offset in .debug_types section.  */
3532b1f09548b66c2c75d5be6f13cd9374adc95f8d8Roland McGrathextern Dwarf_Die *dwarf_offdie_types (Dwarf *dbg, Dwarf_Off offset,
3542b1f09548b66c2c75d5be6f13cd9374adc95f8d8Roland McGrath				      Dwarf_Die *result)
3552b1f09548b66c2c75d5be6f13cd9374adc95f8d8Roland McGrath     __nonnull_attribute__ (3);
3562b1f09548b66c2c75d5be6f13cd9374adc95f8d8Roland McGrath
357b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return offset of DIE.  */
358b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern Dwarf_Off dwarf_dieoffset (Dwarf_Die *die);
359b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
360b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return offset of DIE in CU.  */
361b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern Dwarf_Off dwarf_cuoffset (Dwarf_Die *die);
362b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
36307d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath/* Return CU DIE containing given DIE.  */
36407d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrathextern Dwarf_Die *dwarf_diecu (Dwarf_Die *die, Dwarf_Die *result,
365c373d850ec9ca342f4c71d5e287c8d8bf0723cd6Roland McGrath			       uint8_t *address_sizep, uint8_t *offset_sizep)
366c373d850ec9ca342f4c71d5e287c8d8bf0723cd6Roland McGrath     __nonnull_attribute__ (2);
36707d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
368f18f233615cdae0a3633506238348a1dee9d3ea0Mark Wielaard/* Return the CU DIE and the header info associated with a Dwarf_Die
369f18f233615cdae0a3633506238348a1dee9d3ea0Mark Wielaard   or Dwarf_Attribute.  A Dwarf_Die or a Dwarf_Attribute is associated
370f18f233615cdae0a3633506238348a1dee9d3ea0Mark Wielaard   with a particular Dwarf_CU handle.  This function returns the CU or
371f18f233615cdae0a3633506238348a1dee9d3ea0Mark Wielaard   type unit DIE and header information for that Dwarf_CU.  The
372f18f233615cdae0a3633506238348a1dee9d3ea0Mark Wielaard   returned DIE is either a compile_unit, partial_unit or type_unit.
373f18f233615cdae0a3633506238348a1dee9d3ea0Mark Wielaard   If it is a type_unit, then the type signature and type offset are
374f18f233615cdae0a3633506238348a1dee9d3ea0Mark Wielaard   also provided, otherwise type_offset will be set to zero.  See also
375f18f233615cdae0a3633506238348a1dee9d3ea0Mark Wielaard   dwarf_diecu and dwarf_next_unit.  */
376f18f233615cdae0a3633506238348a1dee9d3ea0Mark Wielaardextern Dwarf_Die *dwarf_cu_die (Dwarf_CU *cu, Dwarf_Die *result,
377f18f233615cdae0a3633506238348a1dee9d3ea0Mark Wielaard				Dwarf_Half *versionp,
378f18f233615cdae0a3633506238348a1dee9d3ea0Mark Wielaard				Dwarf_Off *abbrev_offsetp,
379f18f233615cdae0a3633506238348a1dee9d3ea0Mark Wielaard				uint8_t *address_sizep,
380f18f233615cdae0a3633506238348a1dee9d3ea0Mark Wielaard				uint8_t *offset_sizep,
381f18f233615cdae0a3633506238348a1dee9d3ea0Mark Wielaard				uint64_t *type_signaturep,
382f18f233615cdae0a3633506238348a1dee9d3ea0Mark Wielaard				Dwarf_Off *type_offsetp)
383f18f233615cdae0a3633506238348a1dee9d3ea0Mark Wielaard     __nonnull_attribute__ (2);
384f18f233615cdae0a3633506238348a1dee9d3ea0Mark Wielaard
385b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return CU DIE containing given address.  */
386b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern Dwarf_Die *dwarf_addrdie (Dwarf *dbg, Dwarf_Addr addr,
387b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper				 Dwarf_Die *result) __nonnull_attribute__ (3);
388b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
389b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return child of current DIE.  */
390b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_child (Dwarf_Die *die, Dwarf_Die *result)
391c373d850ec9ca342f4c71d5e287c8d8bf0723cd6Roland McGrath     __nonnull_attribute__ (2);
392b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
39335f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper/* Locates the first sibling of DIE and places it in RESULT.
39435f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper   Returns 0 if a sibling was found, -1 if something went wrong.
39535f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper   Returns 1 if no sibling could be found and, if RESULT is not
39635f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper   the same as DIE, it sets RESULT->addr to the address of the
39735f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper   (non-sibling) DIE that follows this one, or NULL if this DIE
398ebc5c885e696cdc4961916113c50e1396d8d3d48Roland McGrath   was the last one in the compilation unit.  */
399b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_siblingof (Dwarf_Die *die, Dwarf_Die *result)
400b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
401b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
4023a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard/* For type aliases and qualifier type DIEs follow the DW_AT_type
4033a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard   attribute (recursively) and return the underlying type Dwarf_Die.
4043a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard   Returns 0 when RESULT contains a Dwarf_Die (possibly equal to the
4053a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard   given DIE) that isn't a type alias or qualifier type.  Returns 1
4063a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard   when RESULT contains a type alias or qualifier Dwarf_Die that
4073a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard   couldn't be peeled further (it doesn't have a DW_TAG_type
4083a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard   attribute).  Returns -1 when an error occured.
4093a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard
4103a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard   The current DWARF specification defines one type alias tag
4113a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard   (DW_TAG_typedef) and three qualifier type tags (DW_TAG_const_type,
4127fb8031aed51ee7c5eb5e5e9c0e072a1367ff7cbMark Wielaard   DW_TAG_volatile_type, DW_TAG_restrict_type).  DWARF5 defines one
4137fb8031aed51ee7c5eb5e5e9c0e072a1367ff7cbMark Wielaard   other qualifier type tag (DW_TAG_atomic_type).  A future version of
4143a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard   this function might peel other alias or qualifier type tags if a
4153a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard   future DWARF version or GNU extension defines other type aliases or
4163a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard   qualifier type tags that don't modify or change the structural
4173a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard   layout of the underlying type.  */
4183a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaardextern int dwarf_peel_type (Dwarf_Die *die, Dwarf_Die *result)
4193a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard    __nonnull_attribute__ (2);
4203a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard
421b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Check whether the DIE has children.  */
4224f3d2a2aff351b2c202c8d6e7854a9e3a05153f2Ulrich Drepperextern int dwarf_haschildren (Dwarf_Die *die) __nonnull_attribute__ (1);
423b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
42435f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper/* Walks the attributes of DIE, starting at the one OFFSET bytes in,
42535f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper   calling the CALLBACK function for each one.  Stops if the callback
42635f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper   function ever returns a value other than DWARF_CB_OK and returns the
42735f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper   offset of the offending attribute.  If the end of the attributes
42835f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper   is reached 1 is returned.  If something goes wrong -1 is returned and
42935f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper   the dwarf error number is set.  */
430b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern ptrdiff_t dwarf_getattrs (Dwarf_Die *die,
431b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper				 int (*callback) (Dwarf_Attribute *, void *),
4324f3d2a2aff351b2c202c8d6e7854a9e3a05153f2Ulrich Drepper				 void *arg, ptrdiff_t offset)
4334f3d2a2aff351b2c202c8d6e7854a9e3a05153f2Ulrich Drepper     __nonnull_attribute__ (2);
434b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
435b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return tag of given DIE.  */
4364f3d2a2aff351b2c202c8d6e7854a9e3a05153f2Ulrich Drepperextern int dwarf_tag (Dwarf_Die *die) __nonnull_attribute__ (1);
437b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
438b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
439b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return specific attribute of DIE.  */
440b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern Dwarf_Attribute *dwarf_attr (Dwarf_Die *die, unsigned int search_name,
441b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper				    Dwarf_Attribute *result)
442b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (3);
443b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
444b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Check whether given DIE has specific attribute.  */
445b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_hasattr (Dwarf_Die *die, unsigned int search_name);
446b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
447b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* These are the same as dwarf_attr and dwarf_hasattr, respectively,
448b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   but they resolve an indirect attribute through DW_AT_abstract_origin.  */
449b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern Dwarf_Attribute *dwarf_attr_integrate (Dwarf_Die *die,
450b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper					      unsigned int search_name,
451b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper					      Dwarf_Attribute *result)
452b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (3);
453b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_hasattr_integrate (Dwarf_Die *die, unsigned int search_name);
454b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
455b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
456b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
457b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
458b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Check whether given attribute has specific form.  */
459b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_hasform (Dwarf_Attribute *attr, unsigned int search_form);
460b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
461b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return attribute code of given attribute.  */
462b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern unsigned int dwarf_whatattr (Dwarf_Attribute *attr);
463b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
464b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return form code of given attribute.  */
465b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern unsigned int dwarf_whatform (Dwarf_Attribute *attr);
466b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
467b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
468b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return string associated with given attribute.  */
469b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern const char *dwarf_formstring (Dwarf_Attribute *attrp);
470b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
471b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return unsigned constant represented by attribute.  */
472b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_formudata (Dwarf_Attribute *attr, Dwarf_Word *return_uval)
473b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
474b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
475b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return signed constant represented by attribute.  */
476b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_formsdata (Dwarf_Attribute *attr, Dwarf_Sword *return_uval)
477b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
478b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
479b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return address represented by attribute.  */
480b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_formaddr (Dwarf_Attribute *attr, Dwarf_Addr *return_addr)
481b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
482b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
483e4c22ea004c02a58f5db5eb53794275344c17958Roland McGrath/* This function is deprecated.  Always use dwarf_formref_die instead.
484e4c22ea004c02a58f5db5eb53794275344c17958Roland McGrath   Return reference offset represented by attribute.  */
485b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_formref (Dwarf_Attribute *attr, Dwarf_Off *return_offset)
486e4c22ea004c02a58f5db5eb53794275344c17958Roland McGrath     __nonnull_attribute__ (2) __deprecated_attribute__;
487b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
488b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Look up the DIE in a reference-form attribute.  */
489b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern Dwarf_Die *dwarf_formref_die (Dwarf_Attribute *attr, Dwarf_Die *die_mem)
490b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
491b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
492b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return block represented by attribute.  */
493b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_formblock (Dwarf_Attribute *attr, Dwarf_Block *return_block)
494b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
495b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
496b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return flag represented by attribute.  */
497b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_formflag (Dwarf_Attribute *attr, bool *return_bool)
498b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
499b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
500b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
501b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Simplified attribute value access functions.  */
502b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
503b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return string in name attribute of DIE.  */
504b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern const char *dwarf_diename (Dwarf_Die *die);
505b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
506b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return high PC attribute of DIE.  */
507b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_highpc (Dwarf_Die *die, Dwarf_Addr *return_addr)
508b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
509b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
510b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return low PC attribute of DIE.  */
511b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_lowpc (Dwarf_Die *die, Dwarf_Addr *return_addr)
512b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
513b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
51407d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath/* Return entry_pc or low_pc attribute of DIE.  */
51507d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrathextern int dwarf_entrypc (Dwarf_Die *die, Dwarf_Addr *return_addr)
51607d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath     __nonnull_attribute__ (2);
51707d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
518b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return 1 if DIE's lowpc/highpc or ranges attributes match the PC address,
519b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   0 if not, or -1 for errors.  */
520b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_haspc (Dwarf_Die *die, Dwarf_Addr pc);
521b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
52207d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath/* Enumerate the PC address ranges covered by this DIE, covering all
52307d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath   addresses where dwarf_haspc returns true.  In the first call OFFSET
52407d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath   should be zero and *BASEP need not be initialized.  Returns -1 for
52507d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath   errors, zero when there are no more address ranges to report, or a
52607d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath   nonzero OFFSET value to pass to the next call.  Each subsequent call
52707d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath   must preserve *BASEP from the prior call.  Successful calls fill in
52807d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath   *STARTP and *ENDP with a contiguous address range.  */
52907d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrathextern ptrdiff_t dwarf_ranges (Dwarf_Die *die,
53007d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath			       ptrdiff_t offset, Dwarf_Addr *basep,
53107d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath			       Dwarf_Addr *startp, Dwarf_Addr *endp);
53207d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
53307d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
534b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return byte size attribute of DIE.  */
535b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_bytesize (Dwarf_Die *die);
536b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
537b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return bit size attribute of DIE.  */
538b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_bitsize (Dwarf_Die *die);
539b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
540b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return bit offset attribute of DIE.  */
541b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_bitoffset (Dwarf_Die *die);
542b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
543b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return array order attribute of DIE.  */
544b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_arrayorder (Dwarf_Die *die);
545b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
546b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return source language attribute of DIE.  */
547b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_srclang (Dwarf_Die *die);
548b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
549b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
550b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Get abbreviation at given offset for given DIE.  */
551b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern Dwarf_Abbrev *dwarf_getabbrev (Dwarf_Die *die, Dwarf_Off offset,
552b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper				      size_t *lengthp);
553b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
554b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Get abbreviation at given offset in .debug_abbrev section.  */
555b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_offabbrev (Dwarf *dbg, Dwarf_Off offset, size_t *lengthp,
556b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper			    Dwarf_Abbrev *abbrevp)
557b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (4);
558b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
559b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Get abbreviation code.  */
560b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern unsigned int dwarf_getabbrevcode (Dwarf_Abbrev *abbrev);
561b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
562b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Get abbreviation tag.  */
563b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern unsigned int dwarf_getabbrevtag (Dwarf_Abbrev *abbrev);
564b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
565b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return true if abbreviation is children flag set.  */
566b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_abbrevhaschildren (Dwarf_Abbrev *abbrev);
567b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
568b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Get number of attributes of abbreviation.  */
569b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_getattrcnt (Dwarf_Abbrev *abbrev, size_t *attrcntp)
570b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
571b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
572b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Get specific attribute of abbreviation.  */
573b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_getabbrevattr (Dwarf_Abbrev *abbrev, size_t idx,
574b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper				unsigned int *namep, unsigned int *formp,
575b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper				Dwarf_Off *offset);
576b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
577b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
578b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Get string from-debug_str section.  */
579b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern const char *dwarf_getstring (Dwarf *dbg, Dwarf_Off offset,
580b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper				    size_t *lenp);
581b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
582b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
583b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Get public symbol information.  */
584b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern ptrdiff_t dwarf_getpubnames (Dwarf *dbg,
585b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper				    int (*callback) (Dwarf *, Dwarf_Global *,
586b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper						     void *),
587b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper				    void *arg, ptrdiff_t offset)
588b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
589b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
590b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
591b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Get source file information for CU.  */
592b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines,
593b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper			      size_t *nlines) __nonnull_attribute__ (2, 3);
594b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
595b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return one of the source lines of the CU.  */
596b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern Dwarf_Line *dwarf_onesrcline (Dwarf_Lines *lines, size_t idx);
597b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
598b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Get the file source files used in the CU.  */
599b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_getsrcfiles (Dwarf_Die *cudie, Dwarf_Files **files,
600b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper			      size_t *nfiles)
601b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
602b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
603b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
604b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Get source for address in CU.  */
605b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern Dwarf_Line *dwarf_getsrc_die (Dwarf_Die *cudie, Dwarf_Addr addr);
606b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
607b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Get source for file and line number.  */
608b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_getsrc_file (Dwarf *dbg, const char *fname, int line, int col,
609b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper			      Dwarf_Line ***srcsp, size_t *nsrcs)
610b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2, 5, 6);
611b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
612b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
613b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return line address.  */
614b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_lineaddr (Dwarf_Line *line, Dwarf_Addr *addrp);
615b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
616c70cf4e5e5a463b64673c4e80bcf60c938b437b4Roland McGrath/* Return line VLIW operation index.  */
617c70cf4e5e5a463b64673c4e80bcf60c938b437b4Roland McGrathextern int dwarf_lineop_index (Dwarf_Line *line, unsigned int *op_indexp);
618c70cf4e5e5a463b64673c4e80bcf60c938b437b4Roland McGrath
619b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return line number.  */
620b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_lineno (Dwarf_Line *line, int *linep)
621b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
622b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
623b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return column in line.  */
624b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_linecol (Dwarf_Line *line, int *colp)
625b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
626b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
627b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return true if record is for beginning of a statement.  */
628b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_linebeginstatement (Dwarf_Line *line, bool *flagp)
629b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
630b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
631b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return true if record is for end of sequence.  */
632b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_lineendsequence (Dwarf_Line *line, bool *flagp)
633b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
634b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
635b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return true if record is for beginning of a basic block.  */
636b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_lineblock (Dwarf_Line *line, bool *flagp)
637b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
638b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
639b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return true if record is for end of prologue.  */
640b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_lineprologueend (Dwarf_Line *line, bool *flagp)
641b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
642b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
643b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return true if record is for beginning of epilogue.  */
644b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_lineepiloguebegin (Dwarf_Line *line, bool *flagp)
645b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
646b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
647c70cf4e5e5a463b64673c4e80bcf60c938b437b4Roland McGrath/* Return instruction-set architecture in this record.  */
648c70cf4e5e5a463b64673c4e80bcf60c938b437b4Roland McGrathextern int dwarf_lineisa (Dwarf_Line *line, unsigned int *isap)
649c70cf4e5e5a463b64673c4e80bcf60c938b437b4Roland McGrath     __nonnull_attribute__ (2);
650c70cf4e5e5a463b64673c4e80bcf60c938b437b4Roland McGrath
651c70cf4e5e5a463b64673c4e80bcf60c938b437b4Roland McGrath/* Return code path discriminator in this record.  */
652c70cf4e5e5a463b64673c4e80bcf60c938b437b4Roland McGrathextern int dwarf_linediscriminator (Dwarf_Line *line, unsigned int *discp)
653c70cf4e5e5a463b64673c4e80bcf60c938b437b4Roland McGrath     __nonnull_attribute__ (2);
654c70cf4e5e5a463b64673c4e80bcf60c938b437b4Roland McGrath
655b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
656b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Find line information for address.  */
657b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern const char *dwarf_linesrc (Dwarf_Line *line,
658b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper				  Dwarf_Word *mtime, Dwarf_Word *length);
659b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
660b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return file information.  */
661b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern const char *dwarf_filesrc (Dwarf_Files *file, size_t idx,
662b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper				  Dwarf_Word *mtime, Dwarf_Word *length);
663b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
66443da9895c6d828ceae65a47f2337e8ef24eb97c1Roland McGrath/* Return the directory list used in the file information extracted.
66543da9895c6d828ceae65a47f2337e8ef24eb97c1Roland McGrath   (*RESULT)[0] is the CU's DW_AT_comp_dir value, and may be null.
66643da9895c6d828ceae65a47f2337e8ef24eb97c1Roland McGrath   (*RESULT)[0..*NDIRS-1] are the compile-time include directory path
66743da9895c6d828ceae65a47f2337e8ef24eb97c1Roland McGrath   encoded by the compiler.  */
66843da9895c6d828ceae65a47f2337e8ef24eb97c1Roland McGrathextern int dwarf_getsrcdirs (Dwarf_Files *files,
66943da9895c6d828ceae65a47f2337e8ef24eb97c1Roland McGrath			     const char *const **result, size_t *ndirs)
67043da9895c6d828ceae65a47f2337e8ef24eb97c1Roland McGrath  __nonnull_attribute__ (2, 3);
67143da9895c6d828ceae65a47f2337e8ef24eb97c1Roland McGrath
672b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
6736724c90d02659f7466b67b357563042e403d154eRoland McGrath/* Return location expression, decoded as a list of operations.  */
6746724c90d02659f7466b67b357563042e403d154eRoland McGrathextern int dwarf_getlocation (Dwarf_Attribute *attr, Dwarf_Op **expr,
6756724c90d02659f7466b67b357563042e403d154eRoland McGrath			      size_t *exprlen) __nonnull_attribute__ (2, 3);
676b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
6776724c90d02659f7466b67b357563042e403d154eRoland McGrath/* Return location expressions.  If the attribute uses a location list,
6786724c90d02659f7466b67b357563042e403d154eRoland McGrath   ADDRESS selects the relevant location expressions from the list.
679b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   There can be multiple matches, resulting in multiple expressions to
6806724c90d02659f7466b67b357563042e403d154eRoland McGrath   return.  EXPRS and EXPRLENS are parallel arrays of NLOCS slots to
6816724c90d02659f7466b67b357563042e403d154eRoland McGrath   fill in.  Returns the number of locations filled in, or -1 for
6826724c90d02659f7466b67b357563042e403d154eRoland McGrath   errors.  If EXPRS is a null pointer, stores nothing and returns the
6836724c90d02659f7466b67b357563042e403d154eRoland McGrath   total number of locations.  A return value of zero means that the
6846724c90d02659f7466b67b357563042e403d154eRoland McGrath   location list indicated no value is accessible.  */
6856724c90d02659f7466b67b357563042e403d154eRoland McGrathextern int dwarf_getlocation_addr (Dwarf_Attribute *attr, Dwarf_Addr address,
6866724c90d02659f7466b67b357563042e403d154eRoland McGrath				   Dwarf_Op **exprs, size_t *exprlens,
6876724c90d02659f7466b67b357563042e403d154eRoland McGrath				   size_t nlocs);
688b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
68966eaae9bcc1608efad65e3aa0204afbb3cb1a83dMark Wielaard/* Enumerate the locations ranges and descriptions covered by the
69066eaae9bcc1608efad65e3aa0204afbb3cb1a83dMark Wielaard   given attribute.  In the first call OFFSET should be zero and
69166eaae9bcc1608efad65e3aa0204afbb3cb1a83dMark Wielaard   *BASEP need not be initialized.  Returns -1 for errors, zero when
69266eaae9bcc1608efad65e3aa0204afbb3cb1a83dMark Wielaard   there are no more locations to report, or a nonzero OFFSET
69366eaae9bcc1608efad65e3aa0204afbb3cb1a83dMark Wielaard   value to pass to the next call.  Each subsequent call must preserve
69466eaae9bcc1608efad65e3aa0204afbb3cb1a83dMark Wielaard   *BASEP from the prior call.  Successful calls fill in *STARTP and
69566eaae9bcc1608efad65e3aa0204afbb3cb1a83dMark Wielaard   *ENDP with a contiguous address range and *EXPR with a pointer to
69666eaae9bcc1608efad65e3aa0204afbb3cb1a83dMark Wielaard   an array of operations with length *EXPRLEN.  If the attribute
69766eaae9bcc1608efad65e3aa0204afbb3cb1a83dMark Wielaard   describes a single location description and not a location list the
69866eaae9bcc1608efad65e3aa0204afbb3cb1a83dMark Wielaard   first call (with OFFSET zero) will return the location description
69966eaae9bcc1608efad65e3aa0204afbb3cb1a83dMark Wielaard   in *EXPR with *STARTP set to zero and *ENDP set to minus one.  */
70066eaae9bcc1608efad65e3aa0204afbb3cb1a83dMark Wielaardextern ptrdiff_t dwarf_getlocations (Dwarf_Attribute *attr,
70166eaae9bcc1608efad65e3aa0204afbb3cb1a83dMark Wielaard				     ptrdiff_t offset, Dwarf_Addr *basep,
70266eaae9bcc1608efad65e3aa0204afbb3cb1a83dMark Wielaard				     Dwarf_Addr *startp, Dwarf_Addr *endp,
70366eaae9bcc1608efad65e3aa0204afbb3cb1a83dMark Wielaard				     Dwarf_Op **expr, size_t *exprlen);
70466eaae9bcc1608efad65e3aa0204afbb3cb1a83dMark Wielaard
705f0371041995308d197447019eb2ac9285c96477bRoland McGrath/* Return the block associated with a DW_OP_implicit_value operation.
706f0371041995308d197447019eb2ac9285c96477bRoland McGrath   The OP pointer must point into an expression that dwarf_getlocation
707f0371041995308d197447019eb2ac9285c96477bRoland McGrath   or dwarf_getlocation_addr has returned given the same ATTR.  */
708f0371041995308d197447019eb2ac9285c96477bRoland McGrathextern int dwarf_getlocation_implicit_value (Dwarf_Attribute *attr,
7097e0aecdad525d8b290e2b9b999f6960a42bee33dRoland McGrath					     const Dwarf_Op *op,
710f0371041995308d197447019eb2ac9285c96477bRoland McGrath					     Dwarf_Block *return_block)
711f0371041995308d197447019eb2ac9285c96477bRoland McGrath  __nonnull_attribute__ (2, 3);
712f0371041995308d197447019eb2ac9285c96477bRoland McGrath
713932585d2385c9d4e5686e4ddc9ba30c68172d7f3Roland McGrath/* Return the attribute indicated by a DW_OP_GNU_implicit_pointer operation.
714932585d2385c9d4e5686e4ddc9ba30c68172d7f3Roland McGrath   The OP pointer must point into an expression that dwarf_getlocation
715932585d2385c9d4e5686e4ddc9ba30c68172d7f3Roland McGrath   or dwarf_getlocation_addr has returned given the same ATTR.
716932585d2385c9d4e5686e4ddc9ba30c68172d7f3Roland McGrath   The result is the DW_AT_location or DW_AT_const_value attribute
717932585d2385c9d4e5686e4ddc9ba30c68172d7f3Roland McGrath   of the OP->number DIE.  */
718932585d2385c9d4e5686e4ddc9ba30c68172d7f3Roland McGrathextern int dwarf_getlocation_implicit_pointer (Dwarf_Attribute *attr,
719932585d2385c9d4e5686e4ddc9ba30c68172d7f3Roland McGrath					       const Dwarf_Op *op,
720932585d2385c9d4e5686e4ddc9ba30c68172d7f3Roland McGrath					       Dwarf_Attribute *result)
721932585d2385c9d4e5686e4ddc9ba30c68172d7f3Roland McGrath  __nonnull_attribute__ (2, 3);
722932585d2385c9d4e5686e4ddc9ba30c68172d7f3Roland McGrath
723b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard/* Return the DIE associated with an operation such as
724b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard   DW_OP_GNU_implicit_pointer, DW_OP_GNU_parameter_ref, DW_OP_GNU_convert,
725b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard   DW_OP_GNU_reinterpret, DW_OP_GNU_const_type, DW_OP_GNU_regval_type or
726b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard   DW_OP_GNU_deref_type.  The OP pointer must point into an expression that
727b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard   dwarf_getlocation or dwarf_getlocation_addr has returned given the same
728b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard   ATTR.  The RESULT is a DIE that expresses a type or value needed by the
729b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard   given OP.  */
730b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaardextern int dwarf_getlocation_die (Dwarf_Attribute *attr,
731b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard				  const Dwarf_Op *op,
732b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard				  Dwarf_Die *result)
733b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard  __nonnull_attribute__ (2, 3);
734b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard
735b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard/* Return the attribute expressing a value associated with an operation such
736b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard   as DW_OP_implicit_value, DW_OP_GNU_entry_value or DW_OP_GNU_const_type.
737b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard   The OP pointer must point into an expression that dwarf_getlocation
738b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard   or dwarf_getlocation_addr has returned given the same ATTR.
739b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard   The RESULT is a value expressed by an attribute such as DW_AT_location
740b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard   or DW_AT_const_value.  */
741b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaardextern int dwarf_getlocation_attr (Dwarf_Attribute *attr,
742b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard				   const Dwarf_Op *op,
743b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard				   Dwarf_Attribute *result)
744b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard  __nonnull_attribute__ (2, 3);
745b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark Wielaard
746f0371041995308d197447019eb2ac9285c96477bRoland McGrath
747ebc5c885e696cdc4961916113c50e1396d8d3d48Roland McGrath/* Compute the byte-size of a type DIE according to DWARF rules.
748ebc5c885e696cdc4961916113c50e1396d8d3d48Roland McGrath   For most types, this is just DW_AT_byte_size.
749ebc5c885e696cdc4961916113c50e1396d8d3d48Roland McGrath   For DW_TAG_array_type it can apply much more complex rules.  */
750ebc5c885e696cdc4961916113c50e1396d8d3d48Roland McGrathextern int dwarf_aggregate_size (Dwarf_Die *die, Dwarf_Word *size);
751ebc5c885e696cdc4961916113c50e1396d8d3d48Roland McGrath
752b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
753b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return scope DIEs containing PC address.
754b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   Sets *SCOPES to a malloc'd array of Dwarf_Die structures,
755b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   and returns the number of elements in the array.
756b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   (*SCOPES)[0] is the DIE for the innermost scope containing PC,
757b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   (*SCOPES)[1] is the DIE for the scope containing that scope, and so on.
758b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   Returns -1 for errors or 0 if no scopes match PC.  */
759b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_getscopes (Dwarf_Die *cudie, Dwarf_Addr pc,
760b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper			    Dwarf_Die **scopes);
761b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
76271e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath/* Return scope DIEs containing the given DIE.
76371e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath   Sets *SCOPES to a malloc'd array of Dwarf_Die structures,
76471e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath   and returns the number of elements in the array.
76571e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath   (*SCOPES)[0] is a copy of DIE.
76671e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath   (*SCOPES)[1] is the DIE for the scope containing that scope, and so on.
76771e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath   Returns -1 for errors or 0 if DIE is not found in any scope entry.  */
76871e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrathextern int dwarf_getscopes_die (Dwarf_Die *die, Dwarf_Die **scopes);
76971e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath
77071e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath
771b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Search SCOPES[0..NSCOPES-1] for a variable called NAME.
772b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   Ignore the first SKIP_SHADOWS scopes that match the name.
773b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   If MATCH_FILE is not null, accept only declaration in that source file;
774b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   if MATCH_LINENO or MATCH_LINECOL are also nonzero, accept only declaration
775b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   at that line and column.
776b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
777b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   If successful, fill in *RESULT with the DIE of the variable found,
778b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   and return N where SCOPES[N] is the scope defining the variable.
779b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   Return -1 for errors or -2 for no matching variable found.  */
780b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_getscopevar (Dwarf_Die *scopes, int nscopes,
781b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper			      const char *name, int skip_shadows,
782b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper			      const char *match_file,
783b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper			      int match_lineno, int match_linecol,
784b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper			      Dwarf_Die *result);
785b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
786b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
787b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
788b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return list address ranges.  */
789b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_getaranges (Dwarf *dbg, Dwarf_Aranges **aranges,
790b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper			     size_t *naranges)
791b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
792b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
793b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return one of the address range entries.  */
794b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern Dwarf_Arange *dwarf_onearange (Dwarf_Aranges *aranges, size_t idx);
795b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
796b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return information in address range record.  */
797b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_getarangeinfo (Dwarf_Arange *arange, Dwarf_Addr *addrp,
798b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper				Dwarf_Word *lengthp, Dwarf_Off *offsetp);
799b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
800b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Get address range which includes given address.  */
801b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern Dwarf_Arange *dwarf_getarange_addr (Dwarf_Aranges *aranges,
802b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper					   Dwarf_Addr addr);
803b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
804b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
805b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
8061b734df17fca9f89a887b85ffe74616a87388f51Mark Wielaard/* Get functions in CUDIE.  The given callback will be called for all
8071b734df17fca9f89a887b85ffe74616a87388f51Mark Wielaard   defining DW_TAG_subprograms in the CU DIE tree.  If the callback
8081b734df17fca9f89a887b85ffe74616a87388f51Mark Wielaard   returns DWARF_CB_ABORT the return value can be used as offset argument
8091b734df17fca9f89a887b85ffe74616a87388f51Mark Wielaard   to resume the function to find all remaining functions (this is not
8101b734df17fca9f89a887b85ffe74616a87388f51Mark Wielaard   really recommended, since it needs to rewalk the CU DIE tree first till
8111b734df17fca9f89a887b85ffe74616a87388f51Mark Wielaard   that offset is found again).  If the callback returns DWARF_CB_OK
8121b734df17fca9f89a887b85ffe74616a87388f51Mark Wielaard   dwarf_getfuncs will not return but keep calling the callback for each
8131b734df17fca9f89a887b85ffe74616a87388f51Mark Wielaard   function DIE it finds.  Pass zero for offset on the first call to walk
8141b734df17fca9f89a887b85ffe74616a87388f51Mark Wielaard   the full CU DIE tree.  If no more functions can be found and the callback
8151b734df17fca9f89a887b85ffe74616a87388f51Mark Wielaard   returned DWARF_CB_OK then the function returns zero.  */
816b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern ptrdiff_t dwarf_getfuncs (Dwarf_Die *cudie,
8176724c90d02659f7466b67b357563042e403d154eRoland McGrath				 int (*callback) (Dwarf_Die *, void *),
818b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper				 void *arg, ptrdiff_t offset);
819b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
820b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
8216724c90d02659f7466b67b357563042e403d154eRoland McGrath/* Return file name containing definition of the given declaration.  */
8226724c90d02659f7466b67b357563042e403d154eRoland McGrathextern const char *dwarf_decl_file (Dwarf_Die *decl);
823b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
8246724c90d02659f7466b67b357563042e403d154eRoland McGrath/* Get line number of beginning of given declaration.  */
8256724c90d02659f7466b67b357563042e403d154eRoland McGrathextern int dwarf_decl_line (Dwarf_Die *decl, int *linep)
826b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
827b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
8286724c90d02659f7466b67b357563042e403d154eRoland McGrath/* Get column number of beginning of given declaration.  */
8296724c90d02659f7466b67b357563042e403d154eRoland McGrathextern int dwarf_decl_column (Dwarf_Die *decl, int *colp)
830b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
831b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
8321ecb606f5af22838bf42b50dcc581d2b0f9191feRoland McGrath
8331ecb606f5af22838bf42b50dcc581d2b0f9191feRoland McGrath/* Return nonzero if given function is an abstract inline definition.  */
8346724c90d02659f7466b67b357563042e403d154eRoland McGrathextern int dwarf_func_inline (Dwarf_Die *func);
8351ecb606f5af22838bf42b50dcc581d2b0f9191feRoland McGrath
8361ecb606f5af22838bf42b50dcc581d2b0f9191feRoland McGrath/* Find each concrete inlined instance of the abstract inline definition.  */
8376724c90d02659f7466b67b357563042e403d154eRoland McGrathextern int dwarf_func_inline_instances (Dwarf_Die *func,
8381ecb606f5af22838bf42b50dcc581d2b0f9191feRoland McGrath					int (*callback) (Dwarf_Die *, void *),
8391ecb606f5af22838bf42b50dcc581d2b0f9191feRoland McGrath					void *arg);
8401ecb606f5af22838bf42b50dcc581d2b0f9191feRoland McGrath
8411ecb606f5af22838bf42b50dcc581d2b0f9191feRoland McGrath
84207d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath/* Find the appropriate PC location or locations for function entry
84307d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath   breakpoints for the given DW_TAG_subprogram DIE.  Returns -1 for errors.
84407d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath   On success, returns the number of breakpoint locations (never zero)
84507d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath   and sets *BKPTS to a malloc'd vector of addresses.  */
84607d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrathextern int dwarf_entry_breakpoints (Dwarf_Die *die, Dwarf_Addr **bkpts);
84707d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
848b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
849fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata/* Iterate through the macro unit referenced by CUDIE and call
850edb079a596b25379828836e501d003f20afdb879Petr Machata   CALLBACK for each macro information entry.  To start the iteration,
851edb079a596b25379828836e501d003f20afdb879Petr Machata   one would pass DWARF_GETMACROS_START for TOKEN.
852edb079a596b25379828836e501d003f20afdb879Petr Machata
853edb079a596b25379828836e501d003f20afdb879Petr Machata   The iteration continues while CALLBACK returns DWARF_CB_OK.  If the
854edb079a596b25379828836e501d003f20afdb879Petr Machata   callback returns DWARF_CB_ABORT, the iteration stops and a
855edb079a596b25379828836e501d003f20afdb879Petr Machata   continuation token is returned, which can be used to restart the
856edb079a596b25379828836e501d003f20afdb879Petr Machata   iteration at the point where it ended.  Returns -1 for errors or 0
857edb079a596b25379828836e501d003f20afdb879Petr Machata   if there are no more macro entries.
858fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata
859fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   Note that the Dwarf_Macro pointer passed to the callback is only
860fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   valid for the duration of the callback invocation.
861fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata
862edb079a596b25379828836e501d003f20afdb879Petr Machata   For backward compatibility, a token of 0 is accepted for starting
863edb079a596b25379828836e501d003f20afdb879Petr Machata   the iteration as well, but in that case this interface will refuse
864edb079a596b25379828836e501d003f20afdb879Petr Machata   to serve opcode 0xff from .debug_macro sections.  Such opcode would
865edb079a596b25379828836e501d003f20afdb879Petr Machata   be considered invalid and would cause dwarf_getmacros to return
866edb079a596b25379828836e501d003f20afdb879Petr Machata   with error.  */
867edb079a596b25379828836e501d003f20afdb879Petr Machata#define DWARF_GETMACROS_START PTRDIFF_MIN
868b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern ptrdiff_t dwarf_getmacros (Dwarf_Die *cudie,
869b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper				  int (*callback) (Dwarf_Macro *, void *),
870fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata				  void *arg, ptrdiff_t token)
871fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata     __nonnull_attribute__ (2);
872fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata
873fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata/* This is similar in operation to dwarf_getmacros, but selects the
874fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   unit to iterate through by offset instead of by CU, and always
875fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   iterates .debug_macro.  This can be used for handling
876fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   DW_MACRO_GNU_transparent_include's or similar opcodes.
877fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata
878edb079a596b25379828836e501d003f20afdb879Petr Machata   TOKEN value of DWARF_GETMACROS_START can be used to start the
879edb079a596b25379828836e501d003f20afdb879Petr Machata   iteration.
880edb079a596b25379828836e501d003f20afdb879Petr Machata
881fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   It is not appropriate to obtain macro unit offset by hand from a CU
882fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   DIE and then request iteration through this interface.  The reason
883fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   for this is that if a dwarf_macro_getsrcfiles is later called,
884fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   there would be no way to figure out what DW_AT_comp_dir was present
885fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   on the CU DIE, and file names referenced in either the macro unit
886fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   itself, or the .debug_line unit that it references, might be wrong.
887edb079a596b25379828836e501d003f20afdb879Petr Machata   Use dwarf_getmacros.  */
888fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machataextern ptrdiff_t dwarf_getmacros_off (Dwarf *dbg, Dwarf_Off macoff,
889fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata				      int (*callback) (Dwarf_Macro *, void *),
890fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata				      void *arg, ptrdiff_t token)
891fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata  __nonnull_attribute__ (3);
892b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
893fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata/* Get the source files used by the macro entry.  You shouldn't assume
894fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   that Dwarf_Files references will remain valid after MACRO becomes
895fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   invalid.  (Which is to say it's only valid within the
896fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   dwarf_getmacros* callback.)  Returns 0 for success or a negative
897fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   value in case of an error.  */
898fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machataextern int dwarf_macro_getsrcfiles (Dwarf *dbg, Dwarf_Macro *macro,
899fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata				    Dwarf_Files **files, size_t *nfiles)
900fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata  __nonnull_attribute__ (2, 3, 4);
901fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata
902fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata/* Return macro opcode.  That's a constant that can be either from
903fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   DW_MACINFO_* domain or DW_MACRO_GNU_* domain.  The two domains have
904fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   compatible values, so it's OK to use either of them for
905edb079a596b25379828836e501d003f20afdb879Petr Machata   comparisons.  The only differences is 0xff, which could be either
906edb079a596b25379828836e501d003f20afdb879Petr Machata   DW_MACINFO_vendor_ext or a vendor-defined DW_MACRO_* constant.  One
907edb079a596b25379828836e501d003f20afdb879Petr Machata   would need to look if the CU DIE which the iteration was requested
908edb079a596b25379828836e501d003f20afdb879Petr Machata   for has attribute DW_AT_macro_info, or either of DW_AT_GNU_macros
909edb079a596b25379828836e501d003f20afdb879Petr Machata   or DW_AT_macros to differentiate the two interpretations.  */
910b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_macro_opcode (Dwarf_Macro *macro, unsigned int *opcodep)
911b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
912b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
913fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata/* Get number of parameters of MACRO and store it to *PARAMCNTP.  */
914fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machataextern int dwarf_macro_getparamcnt (Dwarf_Macro *macro, size_t *paramcntp);
915fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata
916fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata/* Get IDX-th parameter of MACRO (numbered from zero), and stores it
917fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   to *ATTRIBUTE.  Returns 0 on success or -1 for errors.
918fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata
919fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   After a successful call, you can query ATTRIBUTE by dwarf_whatform
920fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   to determine which of the dwarf_formX calls to make to get actual
921fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   value out of ATTRIBUTE.  Note that calling dwarf_whatattr is not
922fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   meaningful for pseudo-attributes formed this way.  */
923fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machataextern int dwarf_macro_param (Dwarf_Macro *macro, size_t idx,
924fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata			      Dwarf_Attribute *attribute);
925fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata
926fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata/* Return macro parameter with index 0.  This will return -1 if the
927fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   parameter is not an integral value.  Use dwarf_macro_param for more
928fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   general access.  */
929b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_macro_param1 (Dwarf_Macro *macro, Dwarf_Word *paramp)
930b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (2);
931b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
932fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata/* Return macro parameter with index 1.  This will return -1 if the
933fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   parameter is not an integral or string value.  Use
934fb90bf3f84b5683bbc1f234ee05008ff26250e5cPetr Machata   dwarf_macro_param for more general access.  */
935b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_macro_param2 (Dwarf_Macro *macro, Dwarf_Word *paramp,
936b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper			       const char **strp);
937b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
9383c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath/* Compute what's known about a call frame when the PC is at ADDRESS.
9393c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   Returns 0 for success or -1 for errors.
9403c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   On success, *FRAME is a malloc'd pointer.  */
9413c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrathextern int dwarf_cfi_addrframe (Dwarf_CFI *cache,
9423c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath				Dwarf_Addr address, Dwarf_Frame **frame)
9433c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  __nonnull_attribute__ (3);
9443c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
9453c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath/* Return the DWARF register number used in FRAME to denote
9463c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   the return address in FRAME's caller frame.  The remaining
9473c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   arguments can be non-null to fill in more information.
9483c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
9493c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   Fill [*START, *END) with the PC range to which FRAME's information applies.
9503c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   Fill in *SIGNALP to indicate whether this is a signal-handling frame.
9513c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   If true, this is the implicit call frame that calls a signal handler.
9523c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   This frame's "caller" is actually the interrupted state, not a call;
9533c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   its return address is an exact PC, not a PC after a call instruction.  */
9543c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrathextern int dwarf_frame_info (Dwarf_Frame *frame,
9553c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath			     Dwarf_Addr *start, Dwarf_Addr *end, bool *signalp);
9563c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
957af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrath/* Return a DWARF expression that yields the Canonical Frame Address at
958af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrath   this frame state.  Returns -1 for errors, or zero for success, with
959af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrath   *NOPS set to the number of operations stored at *OPS.  That pointer
960af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrath   can be used only as long as FRAME is alive and unchanged.  *NOPS is
961af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrath   zero if the CFA cannot be determined here.  Note that if nonempty,
962af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrath   *OPS is a DWARF expression, not a location description--append
963af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrath   DW_OP_stack_value to a get a location description for the CFA.  */
964af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrathextern int dwarf_frame_cfa (Dwarf_Frame *frame, Dwarf_Op **ops, size_t *nops)
9653c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  __nonnull_attribute__ (2);
9663c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
967af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrath/* Deliver a DWARF location description that yields the location or
968af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrath   value of DWARF register number REGNO in the state described by FRAME.
9693c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
970af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrath   Returns -1 for errors or zero for success, setting *NOPS to the
971af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrath   number of operations in the array stored at *OPS.  Note the last
972af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrath   operation is DW_OP_stack_value if there is no mutable location but
973af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrath   only a computable value.
9743c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
975af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrath   *NOPS zero with *OPS set to OPS_MEM means CFI says the caller's
976af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrath   REGNO is "undefined", i.e. it's call-clobbered and cannot be recovered.
9773c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
978af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrath   *NOPS zero with *OPS set to a null pointer means CFI says the
979af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrath   caller's REGNO is "same_value", i.e. this frame did not change it;
980af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrath   ask the caller frame where to find it.
9813c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
9823c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   For common simple expressions *OPS is OPS_MEM.  For arbitrary DWARF
9833c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   expressions in the CFI, *OPS is an internal pointer that can be used as
9843c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   long as the Dwarf_CFI used to create FRAME remains alive.  */
9853c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrathextern int dwarf_frame_register (Dwarf_Frame *frame, int regno,
986af80014e49796185298dfb261ddf1e51d98f25c0Roland McGrath				 Dwarf_Op ops_mem[3],
9873c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath				 Dwarf_Op **ops, size_t *nops)
9883c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  __nonnull_attribute__ (3, 4, 5);
9893c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
9903c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
991b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return error code of last failing function call.  This value is kept
992b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   separately for each thread.  */
993b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int dwarf_errno (void);
994b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
995b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return error string for ERROR.  If ERROR is zero, return error string
996b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   for most recent error or NULL is none occurred.  If ERROR is -1 the
997b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   behaviour is similar to the last case except that not NULL but a legal
998b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   string is returned.  */
999b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern const char *dwarf_errmsg (int err);
1000b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
1001b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
1002b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Register new Out-Of-Memory handler.  The old handler is returned.  */
1003b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern Dwarf_OOM dwarf_new_oom_handler (Dwarf *dbg, Dwarf_OOM handler);
1004b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
1005b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
1006b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Inline optimizations.  */
1007b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#ifdef __OPTIMIZE__
1008b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return attribute code of given attribute.  */
1009b597dfad924980dede10d7c19d87900b6172e599Ulrich Drepper__libdw_extern_inline unsigned int
1010b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperdwarf_whatattr (Dwarf_Attribute *attr)
1011b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper{
1012b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  return attr == NULL ? 0 : attr->code;
1013b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper}
1014b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
1015b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return attribute code of given attribute.  */
1016b597dfad924980dede10d7c19d87900b6172e599Ulrich Drepper__libdw_extern_inline unsigned int
1017b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperdwarf_whatform (Dwarf_Attribute *attr)
1018b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper{
1019b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  return attr == NULL ? 0 : attr->form;
1020b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper}
1021b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#endif	/* Optimize.  */
1022b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
10233be744790cfa3d8614fe81b1e398c505a7025915Ulrich Drepper#ifdef __cplusplus
10243be744790cfa3d8614fe81b1e398c505a7025915Ulrich Drepper}
10253be744790cfa3d8614fe81b1e398c505a7025915Ulrich Drepper#endif
10263be744790cfa3d8614fe81b1e398c505a7025915Ulrich Drepper
1027b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#endif	/* libdw.h */
1028