dwarf_opaque.h
7.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
/*
dwarf_opaque.h
This file defines all the opaque structures for which pointers
are provided in libdwarf.h. In addition, it defines private
structures that are used internally by libdwarf.
$Revision: 1.1.1.1 $ $Date: 2002/05/02 03:29:20 $
*/
/*
Sgidefs included to define __uint32_t,
a guaranteed 4-byte quantity.
*/
#include <sgidefs.h>
#define true 1
#define false 0
/* to identify a cie */
#define DW_CIE_ID ~(0x0)
#define DW_CIE_VERSION 1
#define ABBREV_HASH_TABLE_SIZE 1000
/*
These are allocation type codes for structs that
are internal to the Libdwarf Consumer library.
*/
#define DW_DLA_ABBREV_LIST DW_DLA_ADDR + 1
#define DW_DLA_CHAIN DW_DLA_ADDR + 2
#define DW_DLA_CU_CONTEXT DW_DLA_ADDR + 3
#define DW_DLA_FRAME DW_DLA_ADDR + 4
#define DW_DLA_GLOBAL_CONTEXT DW_DLA_ADDR + 5
#define DW_DLA_FILE_ENTRY DW_DLA_ADDR + 6
#define DW_DLA_LINE_CONTEXT DW_DLA_ADDR + 7
#define DW_DLA_LOC_CHAIN DW_DLA_ADDR + 8
#define DW_DLA_HASH_TABLE DW_DLA_ADDR + 9
#define DW_DLA_FUNC_CONTEXT DW_DLA_ADDR + 10
#define DW_DLA_TYPENAME_CONTEXT DW_DLA_ADDR + 11
#define DW_DLA_VAR_CONTEXT DW_DLA_ADDR + 12
#define DW_DLA_WEAK_CONTEXT DW_DLA_ADDR + 13
/* Maximum number of allocation types for allocation routines. */
#define MAX_DW_DLA DW_DLA_WEAK_CONTEXT
typedef __uint32_t Dwarf_Word;
typedef signed char Dwarf_Sbyte;
typedef unsigned char Dwarf_Ubyte;
typedef signed short Dwarf_Shalf;
typedef __int32_t Dwarf_Sword;
typedef Dwarf_Small *Dwarf_Byte_Ptr;
typedef struct Dwarf_Abbrev_List_s *Dwarf_Abbrev_List;
typedef struct Dwarf_File_Entry_s *Dwarf_File_Entry;
typedef struct Dwarf_CU_Context_s *Dwarf_CU_Context;
typedef struct Dwarf_Hash_Table_s *Dwarf_Hash_Table;
typedef struct Dwarf_Alloc_Hdr_s *Dwarf_Alloc_Hdr;
struct Dwarf_Die_s {
/*
Points to the start of the portion corresponding
to this Die in the .debug_info section.
*/
Dwarf_Byte_Ptr di_debug_info_ptr;
Dwarf_Abbrev_List di_abbrev_list;
/* Points to cu context for this die. */
Dwarf_CU_Context di_cu_context;
};
struct Dwarf_Attribute_s {
Dwarf_Half ar_attribute; /* Attribute Value. */
Dwarf_Half ar_attribute_form; /* Attribute Form. */
Dwarf_CU_Context ar_cu_context;
Dwarf_Small *ar_debug_info_ptr;
Dwarf_Attribute ar_next;
};
/*
This structure provides the context for a compilation unit.
Thus, it contains the Dwarf_Debug, cc_dbg, that this cu
belongs to. It contains the information in the compilation
unit header, cc_length, cc_version_stamp, cc_abbrev_offset,
and cc_address_size, in the .debug_info section for that cu.
In addition, it contains the count, cc_count_cu, of the cu
number of that cu in the list of cu's in the .debug_info.
The count starts at 1, ie cc_count_cu is 1 for the first cu,
2 for the second and so on. This struct also contains a
pointer, cc_abbrev_table, to a list of pairs of abbrev code
and a pointer to the start of that abbrev
in the .debug_abbrev section.
Each die will also contain a pointer to such a struct to
record the context for that die.
**Updated by dwarf_next_cu_header in dwarf_die_deliv.c
*/
struct Dwarf_CU_Context_s {
Dwarf_Debug cc_dbg;
Dwarf_Word cc_length;
Dwarf_Half cc_version_stamp;
Dwarf_Sword cc_abbrev_offset;
Dwarf_Small cc_address_size;
Dwarf_Word cc_debug_info_offset;
Dwarf_Byte_Ptr cc_last_abbrev_ptr;
Dwarf_Hash_Table cc_abbrev_hash_table;
Dwarf_CU_Context cc_next;
};
struct Dwarf_Debug_s {
Elf *de_elf;
Dwarf_Unsigned de_access;
Dwarf_Handler de_errhand;
Dwarf_Ptr de_errarg;
/*
Context for the compilation_unit just
read by a call to dwarf_next_cu_header.
**Updated by dwarf_next_cu_header in
dwarf_die_deliv.c
*/
Dwarf_CU_Context de_cu_context;
/*
Points to linked list of CU Contexts
for the CU's already read. These are
only CU's read by dwarf_next_cu_header().
*/
Dwarf_CU_Context de_cu_context_list;
/*
Points to the last CU Context added to
the list by dwarf_next_cu_header().
*/
Dwarf_CU_Context de_cu_context_list_end;
/*
This is the list of CU contexts read for
dwarf_offdie(). These may read ahead of
dwarf_next_cu_header().
*/
Dwarf_CU_Context de_offdie_cu_context;
Dwarf_CU_Context de_offdie_cu_context_end;
/* Offset of last byte of last CU read. */
Dwarf_Word de_info_last_offset;
/*
Number of bytes in the length, address,
and offset field in various .debug_*
sections. Check that this is in agreement
with the address size in those sections.
This field is dervied from the Elf header.
*/
Dwarf_Small de_length_size;
/* set at creation of a Dwarf_Debug to say
if form_string should be checked for valid
length at every call. 0 means do the check.
non-zero means do not do the check.
*/
Dwarf_Small de_assume_string_in_bounds;
/*
Array of pointers to Dwarf_Alloc_Hdr_s structs
used to manage chunks that are malloc'ed for
each allocation type for structs. The extra
element is to take care of the fact that C
arrays start from 0, and DW_DLA_STRING is 1.
*/
Dwarf_Alloc_Hdr de_alloc_hdr[MAX_DW_DLA + 1];
/*
These fields are used to process debug_frame
section. **Updated by dwarf_get_fde_list
in dwarf_frame.h
*/
/*
Points to contiguous block of pointers
to Dwarf_Cie_s structs.
*/
Dwarf_Cie *de_cie_data;
/* Count of number of Dwarf_Cie_s structs. */
Dwarf_Signed de_cie_count;
/*
Points to contiguous block of pointers
to Dwarf_Fde_s structs.
*/
Dwarf_Fde *de_fde_data;
/* Count of number of Dwarf_Fde_s structs. */
Dwarf_Signed de_fde_count;
Dwarf_Small *de_debug_info;
Dwarf_Small *de_debug_abbrev;
Dwarf_Small *de_debug_line;
Dwarf_Small *de_debug_loc;
Dwarf_Small *de_debug_aranges;
Dwarf_Small *de_debug_macinfo;
Dwarf_Small *de_debug_pubnames;
Dwarf_Small *de_debug_str;
Dwarf_Small *de_debug_frame;
Dwarf_Small *de_debug_funcnames;
Dwarf_Small *de_debug_typenames;
Dwarf_Small *de_debug_varnames;
Dwarf_Small *de_debug_weaknames;
Dwarf_Unsigned de_debug_info_size;
Dwarf_Unsigned de_debug_abbrev_size;
Dwarf_Unsigned de_debug_line_size;
Dwarf_Unsigned de_debug_loc_size;
Dwarf_Unsigned de_debug_aranges_size;
Dwarf_Unsigned de_debug_macinfo_size;
Dwarf_Unsigned de_debug_pubnames_size;
Dwarf_Unsigned de_debug_str_size;
Dwarf_Unsigned de_debug_frame_size;
Dwarf_Unsigned de_debug_funcnames_size;
Dwarf_Unsigned de_debug_typenames_size;
Dwarf_Unsigned de_debug_varnames_size;
Dwarf_Unsigned de_debug_weaknames_size;
};
typedef struct Dwarf_Chain_s *Dwarf_Chain;
struct Dwarf_Chain_s {
void *ch_item;
Dwarf_Chain ch_next;
};
#define CURRENT_VERSION_STAMP 2
/* Size of cu header version stamp field. */
#define CU_VERSION_STAMP_SIZE sizeof(Dwarf_Half)
/* Size of cu header address size field. */
#define CU_ADDRESS_SIZE_SIZE sizeof(Dwarf_Small)