Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: gdb/dwarf2read.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/dwarf2loc.c ('k') | gdb/elfread.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
None
OLDNEW
1 /* DWARF 2 debugging format support for GDB. 1 /* DWARF 2 debugging format support for GDB.
2 2
3 Copyright (C) 1994-2012 Free Software Foundation, Inc. 3 Copyright (C) 1994-2012 Free Software Foundation, Inc.
4 4
5 Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology, 5 Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
6 Inc. with support from Florida State University (under contract 6 Inc. with support from Florida State University (under contract
7 with the Ada Joint Program Office), and Silicon Graphics, Inc. 7 with the Ada Joint Program Office), and Silicon Graphics, Inc.
8 Initial contribution by Brent Benson, Harris Computer Systems, Inc., 8 Initial contribution by Brent Benson, Harris Computer Systems, Inc.,
9 based on Fred Fish's (Cygnus Support) implementation of DWARF 1 9 based on Fred Fish's (Cygnus Support) implementation of DWARF 1
10 support. 10 support.
11 11
12 This file is part of GDB. 12 This file is part of GDB.
13 13
14 This program is free software; you can redistribute it and/or modify 14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by 15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 3 of the License, or 16 the Free Software Foundation; either version 3 of the License, or
17 (at your option) any later version. 17 (at your option) any later version.
18 18
19 This program is distributed in the hope that it will be useful, 19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details. 22 GNU General Public License for more details.
23 23
24 You should have received a copy of the GNU General Public License 24 You should have received a copy of the GNU General Public License
25 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 25 along with this program. If not, see <http://www.gnu.org/licenses/>. */
26 26
27 /* FIXME: Various die-reading functions need to be more careful with
28 reading off the end of the section.
29 E.g., load_partial_dies, read_partial_die. */
30
27 #include "defs.h" 31 #include "defs.h"
28 #include "bfd.h" 32 #include "bfd.h"
29 #include "symtab.h" 33 #include "symtab.h"
30 #include "gdbtypes.h" 34 #include "gdbtypes.h"
31 #include "objfiles.h" 35 #include "objfiles.h"
32 #include "dwarf2.h" 36 #include "dwarf2.h"
33 #include "buildsym.h" 37 #include "buildsym.h"
34 #include "demangle.h" 38 #include "demangle.h"
35 #include "gdb-demangle.h" 39 #include "gdb-demangle.h"
36 #include "expression.h" 40 #include "expression.h"
(...skipping 11 matching lines...) Expand all
48 #include "block.h" 52 #include "block.h"
49 #include "addrmap.h" 53 #include "addrmap.h"
50 #include "typeprint.h" 54 #include "typeprint.h"
51 #include "jv-lang.h" 55 #include "jv-lang.h"
52 #include "psympriv.h" 56 #include "psympriv.h"
53 #include "exceptions.h" 57 #include "exceptions.h"
54 #include "gdb_stat.h" 58 #include "gdb_stat.h"
55 #include "completer.h" 59 #include "completer.h"
56 #include "vec.h" 60 #include "vec.h"
57 #include "c-lang.h" 61 #include "c-lang.h"
62 #include "go-lang.h"
58 #include "valprint.h" 63 #include "valprint.h"
64 #include "gdbcore.h" /* for gnutarget */
65 #include "gdb/gdb-index.h"
59 #include <ctype.h> 66 #include <ctype.h>
60 67
61 #include <fcntl.h> 68 #include <fcntl.h>
62 #include "gdb_string.h" 69 #include "gdb_string.h"
63 #include "gdb_assert.h" 70 #include "gdb_assert.h"
64 #include <sys/types.h> 71 #include <sys/types.h>
65 #ifdef HAVE_ZLIB_H 72 #ifdef HAVE_ZLIB_H
66 #include <zlib.h> 73 #include <zlib.h>
67 #endif 74 #endif
68 #ifdef HAVE_MMAP 75 #ifdef HAVE_MMAP
69 #include <sys/mman.h> 76 #include <sys/mman.h>
70 #ifndef MAP_FAILED 77 #ifndef MAP_FAILED
71 #define MAP_FAILED ((void *) -1) 78 #define MAP_FAILED ((void *) -1)
72 #endif 79 #endif
73 #endif 80 #endif
74 81
75 typedef struct symbol *symbolp; 82 typedef struct symbol *symbolp;
76 DEF_VEC_P (symbolp); 83 DEF_VEC_P (symbolp);
77 84
78 #if 0 85 /* When non-zero, print basic high level tracing messages.
79 /* .debug_info header for a compilation unit 86 This is in contrast to the low level DIE reading of dwarf2_die_debug. */
80 Because of alignment constraints, this structure has padding and cannot 87 static int dwarf2_read_debug = 0;
81 be mapped directly onto the beginning of the .debug_info section. */
82 typedef struct comp_unit_header
83 {
84 unsigned int length;» /* length of the .debug_info
85 » » » » contribution */
86 unsigned short version;» /* version number -- 2 for DWARF
87 » » » » version 2 */
88 unsigned int abbrev_offset;»/* offset into .debug_abbrev section */
89 unsigned char addr_size;» /* byte size of an address -- 4 */
90 }
91 _COMP_UNIT_HEADER;
92 #define _ACTUAL_COMP_UNIT_HEADER_SIZE 11
93 #endif
94
95 /* .debug_line statement program prologue
96 Because of alignment constraints, this structure has padding and cannot
97 be mapped directly onto the beginning of the .debug_info section. */
98 typedef struct statement_prologue
99 {
100 unsigned int total_length;» /* byte length of the statement
101 » » » » information */
102 unsigned short version;» /* version number -- 2 for DWARF
103 » » » » version 2 */
104 unsigned int prologue_length;» /* # bytes between prologue &
105 » » » » » stmt program */
106 unsigned char minimum_instruction_length;» /* byte size of
107 » » » » » » smallest instr */
108 unsigned char default_is_stmt;» /* initial value of is_stmt
109 » » » » » register */
110 char line_base;
111 unsigned char line_range;
112 unsigned char opcode_base;» /* number assigned to first special
113 » » » » opcode */
114 unsigned char *standard_opcode_lengths;
115 }
116 _STATEMENT_PROLOGUE;
117 88
118 /* When non-zero, dump DIEs after they are read in. */ 89 /* When non-zero, dump DIEs after they are read in. */
119 static int dwarf2_die_debug = 0; 90 static int dwarf2_die_debug = 0;
120 91
121 /* When non-zero, cross-check physname against demangler. */ 92 /* When non-zero, cross-check physname against demangler. */
122 static int check_physname = 0; 93 static int check_physname = 0;
123 94
95 /* When non-zero, do not reject deprecated .gdb_index sections. */
96 static int use_deprecated_index_sections = 0;
97
124 static int pagesize; 98 static int pagesize;
125 99
126 /* When set, the file that we're processing is known to have debugging 100 /* When set, the file that we're processing is known to have debugging
127 info for C++ namespaces. GCC 3.3.x did not produce this information, 101 info for C++ namespaces. GCC 3.3.x did not produce this information,
128 but later versions do. */ 102 but later versions do. */
129 103
130 static int processing_has_namespace_info; 104 static int processing_has_namespace_info;
131 105
132 static const struct objfile_data *dwarf2_objfile_data_key; 106 static const struct objfile_data *dwarf2_objfile_data_key;
133 107
(...skipping 12 matching lines...) Expand all
146 120
147 typedef struct dwarf2_section_info dwarf2_section_info_def; 121 typedef struct dwarf2_section_info dwarf2_section_info_def;
148 DEF_VEC_O (dwarf2_section_info_def); 122 DEF_VEC_O (dwarf2_section_info_def);
149 123
150 /* All offsets in the index are of this type. It must be 124 /* All offsets in the index are of this type. It must be
151 architecture-independent. */ 125 architecture-independent. */
152 typedef uint32_t offset_type; 126 typedef uint32_t offset_type;
153 127
154 DEF_VEC_I (offset_type); 128 DEF_VEC_I (offset_type);
155 129
130 /* Ensure only legit values are used. */
131 #define DW2_GDB_INDEX_SYMBOL_STATIC_SET_VALUE(cu_index, value) \
132 do { \
133 gdb_assert ((unsigned int) (value) <= 1); \
134 GDB_INDEX_SYMBOL_STATIC_SET_VALUE((cu_index), (value)); \
135 } while (0)
136
137 /* Ensure only legit values are used. */
138 #define DW2_GDB_INDEX_SYMBOL_KIND_SET_VALUE(cu_index, value) \
139 do { \
140 gdb_assert ((value) >= GDB_INDEX_SYMBOL_KIND_TYPE \
141 && (value) <= GDB_INDEX_SYMBOL_KIND_OTHER); \
142 GDB_INDEX_SYMBOL_KIND_SET_VALUE((cu_index), (value)); \
143 } while (0)
144
145 /* Ensure we don't use more than the alloted nuber of bits for the CU. */
146 #define DW2_GDB_INDEX_CU_SET_VALUE(cu_index, value) \
147 do { \
148 gdb_assert (((value) & ~GDB_INDEX_CU_MASK) == 0); \
149 GDB_INDEX_CU_SET_VALUE((cu_index), (value)); \
150 } while (0)
151
156 /* A description of the mapped index. The file format is described in 152 /* A description of the mapped index. The file format is described in
157 a comment by the code that writes the index. */ 153 a comment by the code that writes the index. */
158 struct mapped_index 154 struct mapped_index
159 { 155 {
160 /* Index data format version. */ 156 /* Index data format version. */
161 int version; 157 int version;
162 158
163 /* The total length of the buffer. */ 159 /* The total length of the buffer. */
164 off_t total_size; 160 off_t total_size;
165 161
166 /* A pointer to the address table data. */ 162 /* A pointer to the address table data. */
167 const gdb_byte *address_table; 163 const gdb_byte *address_table;
168 164
169 /* Size of the address table data in bytes. */ 165 /* Size of the address table data in bytes. */
170 offset_type address_table_size; 166 offset_type address_table_size;
171 167
172 /* The symbol table, implemented as a hash table. */ 168 /* The symbol table, implemented as a hash table. */
173 const offset_type *symbol_table; 169 const offset_type *symbol_table;
174 170
175 /* Size in slots, each slot is 2 offset_types. */ 171 /* Size in slots, each slot is 2 offset_types. */
176 offset_type symbol_table_slots; 172 offset_type symbol_table_slots;
177 173
178 /* A pointer to the constant pool. */ 174 /* A pointer to the constant pool. */
179 const char *constant_pool; 175 const char *constant_pool;
180 }; 176 };
181 177
178 typedef struct dwarf2_per_cu_data *dwarf2_per_cu_ptr;
179 DEF_VEC_P (dwarf2_per_cu_ptr);
180
181 /* Collection of data recorded per objfile.
182 This hangs off of dwarf2_objfile_data_key. */
183
182 struct dwarf2_per_objfile 184 struct dwarf2_per_objfile
183 { 185 {
184 struct dwarf2_section_info info; 186 struct dwarf2_section_info info;
185 struct dwarf2_section_info abbrev; 187 struct dwarf2_section_info abbrev;
186 struct dwarf2_section_info line; 188 struct dwarf2_section_info line;
187 struct dwarf2_section_info loc; 189 struct dwarf2_section_info loc;
188 struct dwarf2_section_info macinfo; 190 struct dwarf2_section_info macinfo;
189 struct dwarf2_section_info macro; 191 struct dwarf2_section_info macro;
190 struct dwarf2_section_info str; 192 struct dwarf2_section_info str;
191 struct dwarf2_section_info ranges; 193 struct dwarf2_section_info ranges;
194 struct dwarf2_section_info addr;
192 struct dwarf2_section_info frame; 195 struct dwarf2_section_info frame;
193 struct dwarf2_section_info eh_frame; 196 struct dwarf2_section_info eh_frame;
194 struct dwarf2_section_info gdb_index; 197 struct dwarf2_section_info gdb_index;
195 198
196 VEC (dwarf2_section_info_def) *types; 199 VEC (dwarf2_section_info_def) *types;
197 200
198 /* Back link. */ 201 /* Back link. */
199 struct objfile *objfile; 202 struct objfile *objfile;
200 203
201 /* A list of all the compilation units. This is used to locate 204 /* Table of all the compilation units. This is used to locate
202 the target compilation unit of a particular reference. */ 205 the target compilation unit of a particular reference. */
203 struct dwarf2_per_cu_data **all_comp_units; 206 struct dwarf2_per_cu_data **all_comp_units;
204 207
205 /* The number of compilation units in ALL_COMP_UNITS. */ 208 /* The number of compilation units in ALL_COMP_UNITS. */
206 int n_comp_units; 209 int n_comp_units;
207 210
208 /* The number of .debug_types-related CUs. */ 211 /* The number of .debug_types-related CUs. */
209 int n_type_comp_units; 212 int n_type_units;
210 213
211 /* The .debug_types-related CUs. */ 214 /* The .debug_types-related CUs (TUs). */
212 struct dwarf2_per_cu_data **type_comp_units; 215 struct signatured_type **all_type_units;
216
217 /* The number of entries in all_type_unit_groups. */
218 int n_type_unit_groups;
219
220 /* Table of type unit groups.
221 This exists to make it easy to iterate over all CUs and TU groups. */
222 struct type_unit_group **all_type_unit_groups;
223
224 /* Table of struct type_unit_group objects.
225 The hash key is the DW_AT_stmt_list value. */
226 htab_t type_unit_groups;
227
228 /* A table mapping .debug_types signatures to its signatured_type entry.
229 This is NULL if the .debug_types section hasn't been read in yet. */
230 htab_t signatured_types;
231
232 /* Type unit statistics, to see how well the scaling improvements
233 are doing. */
234 struct tu_stats
235 {
236 int nr_uniq_abbrev_tables;
237 int nr_symtabs;
238 int nr_symtab_sharers;
239 int nr_stmt_less_type_units;
240 } tu_stats;
213 241
214 /* A chain of compilation units that are currently read in, so that 242 /* A chain of compilation units that are currently read in, so that
215 they can be freed later. */ 243 they can be freed later. */
216 struct dwarf2_per_cu_data *read_in_chain; 244 struct dwarf2_per_cu_data *read_in_chain;
217 245
218 /* A table mapping .debug_types signatures to its signatured_type entry. 246 /* A table mapping DW_AT_dwo_name values to struct dwo_file objects.
219 This is NULL if the .debug_types section hasn't been read in yet. */ 247 This is NULL if the table hasn't been allocated yet. */
220 htab_t signatured_types; 248 htab_t dwo_files;
221 249
222 /* A flag indicating wether this objfile has a section loaded at a 250 /* A flag indicating wether this objfile has a section loaded at a
223 VMA of 0. */ 251 VMA of 0. */
224 int has_section_at_zero; 252 int has_section_at_zero;
225 253
226 /* True if we are using the mapped index, 254 /* True if we are using the mapped index,
227 or we are faking it for OBJF_READNOW's sake. */ 255 or we are faking it for OBJF_READNOW's sake. */
228 unsigned char using_index; 256 unsigned char using_index;
229 257
230 /* The mapped index, or NULL if .gdb_index is missing or not being used. */ 258 /* The mapped index, or NULL if .gdb_index is missing or not being used. */
231 struct mapped_index *index_table; 259 struct mapped_index *index_table;
232 260
233 /* When using index_table, this keeps track of all quick_file_names entries. 261 /* When using index_table, this keeps track of all quick_file_names entries.
234 TUs can share line table entries with CUs or other TUs, and there can be 262 TUs can share line table entries with CUs or other TUs, and there can be
235 a lot more TUs than unique line tables, so we maintain a separate table 263 a lot more TUs than unique line tables, so we maintain a separate table
236 of all line table entries to support the sharing. */ 264 of all line table entries to support the sharing. */
237 htab_t quick_file_names_table; 265 htab_t quick_file_names_table;
238 266
239 /* Set during partial symbol reading, to prevent queueing of full 267 /* Set during partial symbol reading, to prevent queueing of full
240 symbols. */ 268 symbols. */
241 int reading_partial_symbols; 269 int reading_partial_symbols;
242 270
243 /* Table mapping type .debug_info DIE offsets to types. 271 /* Table mapping type DIEs to their struct type *.
244 This is NULL if not allocated yet. 272 This is NULL if not allocated yet.
245 It (currently) makes sense to allocate debug_types_type_hash lazily. 273 The mapping is done via (CU/TU signature + DIE offset) -> type. */
246 To keep things simple we allocate both lazily. */ 274 htab_t die_type_hash;
247 htab_t debug_info_type_hash;
248 275
249 /* Table mapping type .debug_types DIE offsets to types. 276 /* The CUs we recently read. */
250 This is NULL if not allocated yet. */ 277 VEC (dwarf2_per_cu_ptr) *just_read_cus;
251 htab_t debug_types_type_hash;
252 }; 278 };
253 279
254 static struct dwarf2_per_objfile *dwarf2_per_objfile; 280 static struct dwarf2_per_objfile *dwarf2_per_objfile;
255 281
256 /* Default names of the debugging sections. */ 282 /* Default names of the debugging sections. */
257 283
258 /* Note that if the debugging section has been compressed, it might 284 /* Note that if the debugging section has been compressed, it might
259 have a name like .zdebug_info. */ 285 have a name like .zdebug_info. */
260 286
261 static const struct dwarf2_debug_sections dwarf2_elf_names = { 287 static const struct dwarf2_debug_sections dwarf2_elf_names =
288 {
262 { ".debug_info", ".zdebug_info" }, 289 { ".debug_info", ".zdebug_info" },
263 { ".debug_abbrev", ".zdebug_abbrev" }, 290 { ".debug_abbrev", ".zdebug_abbrev" },
264 { ".debug_line", ".zdebug_line" }, 291 { ".debug_line", ".zdebug_line" },
265 { ".debug_loc", ".zdebug_loc" }, 292 { ".debug_loc", ".zdebug_loc" },
266 { ".debug_macinfo", ".zdebug_macinfo" }, 293 { ".debug_macinfo", ".zdebug_macinfo" },
267 { ".debug_macro", ".zdebug_macro" }, 294 { ".debug_macro", ".zdebug_macro" },
268 { ".debug_str", ".zdebug_str" }, 295 { ".debug_str", ".zdebug_str" },
269 { ".debug_ranges", ".zdebug_ranges" }, 296 { ".debug_ranges", ".zdebug_ranges" },
270 { ".debug_types", ".zdebug_types" }, 297 { ".debug_types", ".zdebug_types" },
298 { ".debug_addr", ".zdebug_addr" },
271 { ".debug_frame", ".zdebug_frame" }, 299 { ".debug_frame", ".zdebug_frame" },
272 { ".eh_frame", NULL }, 300 { ".eh_frame", NULL },
273 { ".gdb_index", ".zgdb_index" }, 301 { ".gdb_index", ".zgdb_index" },
274 23 302 23
275 }; 303 };
276 304
305 /* List of DWO sections. */
306
307 static const struct dwo_section_names
308 {
309 struct dwarf2_section_names abbrev_dwo;
310 struct dwarf2_section_names info_dwo;
311 struct dwarf2_section_names line_dwo;
312 struct dwarf2_section_names loc_dwo;
313 struct dwarf2_section_names macinfo_dwo;
314 struct dwarf2_section_names macro_dwo;
315 struct dwarf2_section_names str_dwo;
316 struct dwarf2_section_names str_offsets_dwo;
317 struct dwarf2_section_names types_dwo;
318 }
319 dwo_section_names =
320 {
321 { ".debug_abbrev.dwo", ".zdebug_abbrev.dwo" },
322 { ".debug_info.dwo", ".zdebug_info.dwo" },
323 { ".debug_line.dwo", ".zdebug_line.dwo" },
324 { ".debug_loc.dwo", ".zdebug_loc.dwo" },
325 { ".debug_macinfo.dwo", ".zdebug_macinfo.dwo" },
326 { ".debug_macro.dwo", ".zdebug_macro.dwo" },
327 { ".debug_str.dwo", ".zdebug_str.dwo" },
328 { ".debug_str_offsets.dwo", ".zdebug_str_offsets.dwo" },
329 { ".debug_types.dwo", ".zdebug_types.dwo" },
330 };
331
277 /* local data types */ 332 /* local data types */
278 333
279 /* We hold several abbreviation tables in memory at the same time. */
280 #ifndef ABBREV_HASH_SIZE
281 #define ABBREV_HASH_SIZE 121
282 #endif
283
284 /* The data in a compilation unit header, after target2host 334 /* The data in a compilation unit header, after target2host
285 translation, looks like this. */ 335 translation, looks like this. */
286 struct comp_unit_head 336 struct comp_unit_head
287 { 337 {
288 unsigned int length; 338 unsigned int length;
289 short version; 339 short version;
290 unsigned char addr_size; 340 unsigned char addr_size;
291 unsigned char signed_addr_p; 341 unsigned char signed_addr_p;
292 unsigned int abbrev_offset; 342 sect_offset abbrev_offset;
293 343
294 /* Size of file offsets; either 4 or 8. */ 344 /* Size of file offsets; either 4 or 8. */
295 unsigned int offset_size; 345 unsigned int offset_size;
296 346
297 /* Size of the length field; either 4 or 12. */ 347 /* Size of the length field; either 4 or 12. */
298 unsigned int initial_length_size; 348 unsigned int initial_length_size;
299 349
300 /* Offset to the first byte of this compilation unit header in the 350 /* Offset to the first byte of this compilation unit header in the
301 .debug_info section, for resolving relative reference dies. */ 351 .debug_info section, for resolving relative reference dies. */
302 unsigned int offset; 352 sect_offset offset;
303 353
304 /* Offset to first die in this cu from the start of the cu. 354 /* Offset to first die in this cu from the start of the cu.
305 This will be the first byte following the compilation unit header. */ 355 This will be the first byte following the compilation unit header. */
306 unsigned int first_die_offset; 356 cu_offset first_die_offset;
307 }; 357 };
308 358
309 /* Type used for delaying computation of method physnames. 359 /* Type used for delaying computation of method physnames.
310 See comments for compute_delayed_physnames. */ 360 See comments for compute_delayed_physnames. */
311 struct delayed_method_info 361 struct delayed_method_info
312 { 362 {
313 /* The type to which the method is attached, i.e., its parent class. */ 363 /* The type to which the method is attached, i.e., its parent class. */
314 struct type *type; 364 struct type *type;
315 365
316 /* The index of the method in the type's function fieldlists. */ 366 /* The index of the method in the type's function fieldlists. */
(...skipping 20 matching lines...) Expand all
337 387
338 /* The header of the compilation unit. */ 388 /* The header of the compilation unit. */
339 struct comp_unit_head header; 389 struct comp_unit_head header;
340 390
341 /* Base address of this compilation unit. */ 391 /* Base address of this compilation unit. */
342 CORE_ADDR base_address; 392 CORE_ADDR base_address;
343 393
344 /* Non-zero if base_address has been set. */ 394 /* Non-zero if base_address has been set. */
345 int base_known; 395 int base_known;
346 396
347 struct function_range *first_fn, *last_fn, *cached_fn;
348
349 /* The language we are debugging. */ 397 /* The language we are debugging. */
350 enum language language; 398 enum language language;
351 const struct language_defn *language_defn; 399 const struct language_defn *language_defn;
352 400
353 const char *producer; 401 const char *producer;
354 402
355 /* The generic symbol table building routines have separate lists for 403 /* The generic symbol table building routines have separate lists for
356 file scope symbols and all all other scopes (local scopes). So 404 file scope symbols and all all other scopes (local scopes). So
357 we need to select the right one to pass to add_symbol_to_list(). 405 we need to select the right one to pass to add_symbol_to_list().
358 We do it by keeping a pointer to the correct list in list_in_scope. 406 We do it by keeping a pointer to the correct list in list_in_scope.
359 407
360 FIXME: The original dwarf code just treated the file scope as the 408 FIXME: The original dwarf code just treated the file scope as the
361 first local scope, and all other local scopes as nested local 409 first local scope, and all other local scopes as nested local
362 scopes, and worked fine. Check to see if we really need to 410 scopes, and worked fine. Check to see if we really need to
363 distinguish these in buildsym.c. */ 411 distinguish these in buildsym.c. */
364 struct pending **list_in_scope; 412 struct pending **list_in_scope;
365 413
366 /* DWARF abbreviation table associated with this compilation unit. */ 414 /* The abbrev table for this CU.
367 struct abbrev_info **dwarf2_abbrevs; 415 Normally this points to the abbrev table in the objfile.
416 But if DWO_UNIT is non-NULL this is the abbrev table in the DWO file. */
417 struct abbrev_table *abbrev_table;
368 418
369 /* Storage for the abbrev table. */ 419 /* Hash table holding all the loaded partial DIEs
370 struct obstack abbrev_obstack; 420 with partial_die->offset.SECT_OFF as hash. */
371
372 /* Hash table holding all the loaded partial DIEs. */
373 htab_t partial_dies; 421 htab_t partial_dies;
374 422
375 /* Storage for things with the same lifetime as this read-in compilation 423 /* Storage for things with the same lifetime as this read-in compilation
376 unit, including partial DIEs. */ 424 unit, including partial DIEs. */
377 struct obstack comp_unit_obstack; 425 struct obstack comp_unit_obstack;
378 426
379 /* When multiple dwarf2_cu structures are living in memory, this field 427 /* When multiple dwarf2_cu structures are living in memory, this field
380 chains them all together, so that they can be released efficiently. 428 chains them all together, so that they can be released efficiently.
381 We will probably also want a generation counter so that most-recently-used 429 We will probably also want a generation counter so that most-recently-used
382 compilation units are cached... */ 430 compilation units are cached... */
383 struct dwarf2_per_cu_data *read_in_chain; 431 struct dwarf2_per_cu_data *read_in_chain;
384 432
385 /* Backchain to our per_cu entry if the tree has been built. */ 433 /* Backchain to our per_cu entry if the tree has been built. */
386 struct dwarf2_per_cu_data *per_cu; 434 struct dwarf2_per_cu_data *per_cu;
387 435
388 /* How many compilation units ago was this CU last referenced? */ 436 /* How many compilation units ago was this CU last referenced? */
389 int last_used; 437 int last_used;
390 438
391 /* A hash table of die offsets for following references. */ 439 /* A hash table of DIE cu_offset for following references with
440 die_info->offset.sect_off as hash. */
392 htab_t die_hash; 441 htab_t die_hash;
393 442
394 /* Full DIEs if read in. */ 443 /* Full DIEs if read in. */
395 struct die_info *dies; 444 struct die_info *dies;
396 445
397 /* A set of pointers to dwarf2_per_cu_data objects for compilation 446 /* A set of pointers to dwarf2_per_cu_data objects for compilation
398 units referenced by this one. Only set during full symbol processing; 447 units referenced by this one. Only set during full symbol processing;
399 partial symbol tables do not have dependencies. */ 448 partial symbol tables do not have dependencies. */
400 htab_t dependencies; 449 htab_t dependencies;
401 450
402 /* Header data from the line table, during full symbol processing. */ 451 /* Header data from the line table, during full symbol processing. */
403 struct line_header *line_header; 452 struct line_header *line_header;
404 453
405 /* A list of methods which need to have physnames computed 454 /* A list of methods which need to have physnames computed
406 after all type information has been read. */ 455 after all type information has been read. */
407 VEC (delayed_method_info) *method_list; 456 VEC (delayed_method_info) *method_list;
408 457
409 /* To be copied to symtab->call_site_htab. */ 458 /* To be copied to symtab->call_site_htab. */
410 htab_t call_site_htab; 459 htab_t call_site_htab;
411 460
461 /* Non-NULL if this CU came from a DWO file.
462 There is an invariant here that is important to remember:
463 Except for attributes copied from the top level DIE in the "main"
464 (or "stub") file in preparation for reading the DWO file
465 (e.g., DW_AT_GNU_addr_base), we KISS: there is only *one* CU.
466 Either there isn't a DWO file (in which case this is NULL and the point
467 is moot), or there is and either we're not going to read it (in which
468 case this is NULL) or there is and we are reading it (in which case this
469 is non-NULL). */
470 struct dwo_unit *dwo_unit;
471
472 /* The DW_AT_addr_base attribute if present, zero otherwise
473 (zero is a valid value though).
474 Note this value comes from the stub CU/TU's DIE. */
475 ULONGEST addr_base;
476
477 /* The DW_AT_ranges_base attribute if present, zero otherwise
478 (zero is a valid value though).
479 Note this value comes from the stub CU/TU's DIE.
480 Also note that the value is zero in the non-DWO case so this value can
481 be used without needing to know whether DWO files are in use or not. */
482 ULONGEST ranges_base;
483
412 /* Mark used when releasing cached dies. */ 484 /* Mark used when releasing cached dies. */
413 unsigned int mark : 1; 485 unsigned int mark : 1;
414 486
415 /* This flag will be set if this compilation unit might include
416 inter-compilation-unit references. */
417 unsigned int has_form_ref_addr : 1;
418
419 /* This flag will be set if this compilation unit includes any
420 DW_TAG_namespace DIEs. If we know that there are explicit
421 DIEs for namespaces, we don't need to try to infer them
422 from mangled names. */
423 unsigned int has_namespace_info : 1;
424
425 /* This CU references .debug_loc. See the symtab->locations_valid field. 487 /* This CU references .debug_loc. See the symtab->locations_valid field.
426 This test is imperfect as there may exist optimized debug code not using 488 This test is imperfect as there may exist optimized debug code not using
427 any location list and still facing inlining issues if handled as 489 any location list and still facing inlining issues if handled as
428 unoptimized code. For a future better test see GCC PR other/32998. */ 490 unoptimized code. For a future better test see GCC PR other/32998. */
491 unsigned int has_loclist : 1;
429 492
430 unsigned int has_loclist : 1; 493 /* These cache the results for producer_is_gxx_lt_4_6 and producer_is_icc.
494 CHECKED_PRODUCER is set if both PRODUCER_IS_GXX_LT_4_6 and PRODUCER_IS_ICC
495 are valid. This information is cached because profiling CU expansion
496 showed excessive time spent in producer_is_gxx_lt_4_6. */
497 unsigned int checked_producer : 1;
498 unsigned int producer_is_gxx_lt_4_6 : 1;
499 unsigned int producer_is_icc : 1;
431 }; 500 };
432 501
433 /* Persistent data held for a compilation unit, even when not 502 /* Persistent data held for a compilation unit, even when not
434 processing it. We put a pointer to this structure in the 503 processing it. We put a pointer to this structure in the
435 read_symtab_private field of the psymtab. If we encounter 504 read_symtab_private field of the psymtab. */
436 inter-compilation-unit references, we also maintain a sorted
437 list of all compilation units. */
438 505
439 struct dwarf2_per_cu_data 506 struct dwarf2_per_cu_data
440 { 507 {
441 /* The start offset and length of this compilation unit. 2**29-1 508 /* The start offset and length of this compilation unit. 2**29-1
442 bytes should suffice to store the length of any compilation unit 509 bytes should suffice to store the length of any compilation unit
443 - if it doesn't, GDB will fall over anyway. 510 - if it doesn't, GDB will fall over anyway.
444 NOTE: Unlike comp_unit_head.length, this length includes 511 NOTE: Unlike comp_unit_head.length, this length includes
445 initial_length_size. */ 512 initial_length_size.
446 unsigned int offset; 513 If the DIE refers to a DWO file, this is always of the original die,
514 not the DWO file. */
515 sect_offset offset;
447 unsigned int length : 29; 516 unsigned int length : 29;
448 517
449 /* Flag indicating this compilation unit will be read in before 518 /* Flag indicating this compilation unit will be read in before
450 any of the current compilation units are processed. */ 519 any of the current compilation units are processed. */
451 unsigned int queued : 1; 520 unsigned int queued : 1;
452 521
453 /* This flag will be set if we need to load absolutely all DIEs 522 /* This flag will be set when reading partial DIEs if we need to load
454 for this compilation unit, instead of just the ones we think 523 absolutely all DIEs for this compilation unit, instead of just the ones
455 are interesting. It gets set if we look for a DIE in the 524 we think are interesting. It gets set if we look for a DIE in the
456 hash table and don't find it. */ 525 hash table and don't find it. */
457 unsigned int load_all_dies : 1; 526 unsigned int load_all_dies : 1;
458 527
459 /* Non-null if this CU is from .debug_types; in which case it points 528 /* Non-zero if this CU is from .debug_types. */
460 to the section. Otherwise it's from .debug_info. */ 529 unsigned int is_debug_types : 1;
461 struct dwarf2_section_info *debug_types_section; 530
531 /* The section this CU/TU lives in.
532 If the DIE refers to a DWO file, this is always the original die,
533 not the DWO file. */
534 struct dwarf2_section_info *info_or_types_section;
462 535
463 /* Set to non-NULL iff this CU is currently loaded. When it gets freed out 536 /* Set to non-NULL iff this CU is currently loaded. When it gets freed out
464 of the CU cache it gets reset to NULL again. */ 537 of the CU cache it gets reset to NULL again. */
465 struct dwarf2_cu *cu; 538 struct dwarf2_cu *cu;
466 539
467 /* The corresponding objfile. */ 540 /* The corresponding objfile.
541 Normally we can get the objfile from dwarf2_per_objfile.
542 However we can enter this file with just a "per_cu" handle. */
468 struct objfile *objfile; 543 struct objfile *objfile;
469 544
470 /* When using partial symbol tables, the 'psymtab' field is active. 545 /* When using partial symbol tables, the 'psymtab' field is active.
471 Otherwise the 'quick' field is active. */ 546 Otherwise the 'quick' field is active. */
472 union 547 union
473 { 548 {
474 /* The partial symbol table associated with this compilation unit, 549 /* The partial symbol table associated with this compilation unit,
475 or NULL for partial units (which do not have an associated 550 or NULL for unread partial units. */
476 symtab). */
477 struct partial_symtab *psymtab; 551 struct partial_symtab *psymtab;
478 552
479 /* Data needed by the "quick" functions. */ 553 /* Data needed by the "quick" functions. */
480 struct dwarf2_per_cu_quick_data *quick; 554 struct dwarf2_per_cu_quick_data *quick;
481 } v; 555 } v;
556
557 union
558 {
559 /* The CUs we import using DW_TAG_imported_unit. This is filled in
560 while reading psymtabs, used to compute the psymtab dependencies,
561 and then cleared. Then it is filled in again while reading full
562 symbols, and only deleted when the objfile is destroyed. */
563 VEC (dwarf2_per_cu_ptr) *imported_symtabs;
564
565 /* Type units are grouped by their DW_AT_stmt_list entry so that they
566 can share them. If this is a TU, this points to the containing
567 symtab. */
568 struct type_unit_group *type_unit_group;
569 } s;
482 }; 570 };
483 571
484 /* Entry in the signatured_types hash table. */ 572 /* Entry in the signatured_types hash table. */
485 573
486 struct signatured_type 574 struct signatured_type
487 { 575 {
576 /* The "per_cu" object of this type.
577 N.B.: This is the first member so that it's easy to convert pointers
578 between them. */
579 struct dwarf2_per_cu_data per_cu;
580
581 /* The type's signature. */
488 ULONGEST signature; 582 ULONGEST signature;
489 583
490 /* Offset in .debug_types of the type defined by this TU. */ 584 /* Offset in the TU of the type's DIE, as read from the TU header.
491 unsigned int type_offset; 585 If the definition lives in a DWO file, this value is unusable. */
492 586 cu_offset type_offset_in_tu;
493 /* The CU(/TU) of this type. */ 587
588 /* Offset in the section of the type's DIE.
589 If the definition lives in a DWO file, this is the offset in the
590 .debug_types.dwo section.
591 The value is zero until the actual value is known.
592 Zero is otherwise not a valid section offset. */
593 sect_offset type_offset_in_section;
594 };
595
596 /* A struct that can be used as a hash key for tables based on DW_AT_stmt_list.
597 This includes type_unit_group and quick_file_names. */
598
599 struct stmt_list_hash
600 {
601 /* The DWO unit this table is from or NULL if there is none. */
602 struct dwo_unit *dwo_unit;
603
604 /* Offset in .debug_line or .debug_line.dwo. */
605 sect_offset line_offset;
606 };
607
608 /* Each element of dwarf2_per_objfile->type_unit_groups is a pointer to
609 an object of this type. */
610
611 struct type_unit_group
612 {
613 /* dwarf2read.c's main "handle" on the symtab.
614 To simplify things we create an artificial CU that "includes" all the
615 type units using this stmt_list so that the rest of the code still has
616 a "per_cu" handle on the symtab.
617 This PER_CU is recognized by having no section. */
618 #define IS_TYPE_UNIT_GROUP(per_cu) ((per_cu)->info_or_types_section == NULL)
494 struct dwarf2_per_cu_data per_cu; 619 struct dwarf2_per_cu_data per_cu;
620
621 union
622 {
623 /* The TUs that share this DW_AT_stmt_list entry.
624 This is added to while parsing type units to build partial symtabs,
625 and is deleted afterwards and not used again. */
626 VEC (dwarf2_per_cu_ptr) *tus;
627
628 /* When reading the line table in "quick" functions, we need a real TU.
629 Any will do, we know they all share the same DW_AT_stmt_list entry.
630 For simplicity's sake, we pick the first one. */
631 struct dwarf2_per_cu_data *first_tu;
632 } t;
633
634 /* The primary symtab.
635 Type units in a group needn't all be defined in the same source file,
636 so we create an essentially anonymous symtab as the primary symtab. */
637 struct symtab *primary_symtab;
638
639 /* The data used to construct the hash key. */
640 struct stmt_list_hash hash;
641
642 /* The number of symtabs from the line header.
643 The value here must match line_header.num_file_names. */
644 unsigned int num_symtabs;
645
646 /* The symbol tables for this TU (obtained from the files listed in
647 DW_AT_stmt_list).
648 WARNING: The order of entries here must match the order of entries
649 in the line header. After the first TU using this type_unit_group, the
650 line header for the subsequent TUs is recreated from this. This is done
651 because we need to use the same symtabs for each TU using the same
652 DW_AT_stmt_list value. Also note that symtabs may be repeated here,
653 there's no guarantee the line header doesn't have duplicate entries. */
654 struct symtab **symtabs;
655 };
656
657 /* These sections are what may appear in a "dwo" file. */
658
659 struct dwo_sections
660 {
661 struct dwarf2_section_info abbrev;
662 struct dwarf2_section_info info;
663 struct dwarf2_section_info line;
664 struct dwarf2_section_info loc;
665 struct dwarf2_section_info macinfo;
666 struct dwarf2_section_info macro;
667 struct dwarf2_section_info str;
668 struct dwarf2_section_info str_offsets;
669 VEC (dwarf2_section_info_def) *types;
670 };
671
672 /* Common bits of DWO CUs/TUs. */
673
674 struct dwo_unit
675 {
676 /* Backlink to the containing struct dwo_file. */
677 struct dwo_file *dwo_file;
678
679 /* The "id" that distinguishes this CU/TU.
680 .debug_info calls this "dwo_id", .debug_types calls this "signature".
681 Since signatures came first, we stick with it for consistency. */
682 ULONGEST signature;
683
684 /* The section this CU/TU lives in, in the DWO file. */
685 struct dwarf2_section_info *info_or_types_section;
686
687 /* Same as dwarf2_per_cu_data:{offset,length} but for the DWO section. */
688 sect_offset offset;
689 unsigned int length;
690
691 /* For types, offset in the type's DIE of the type defined by this TU. */
692 cu_offset type_offset_in_tu;
693 };
694
695 /* Data for one DWO file. */
696
697 struct dwo_file
698 {
699 /* The DW_AT_GNU_dwo_name attribute.
700 We don't manage space for this, it's an attribute. */
701 const char *dwo_name;
702
703 /* The bfd, when the file is open. Otherwise this is NULL. */
704 bfd *dwo_bfd;
705
706 /* Section info for this file. */
707 struct dwo_sections sections;
708
709 /* Table of CUs in the file.
710 Each element is a struct dwo_unit. */
711 htab_t cus;
712
713 /* Table of TUs in the file.
714 Each element is a struct dwo_unit. */
715 htab_t tus;
495 }; 716 };
496 717
497 /* Struct used to pass misc. parameters to read_die_and_children, et 718 /* Struct used to pass misc. parameters to read_die_and_children, et
498 al. which are used for both .debug_info and .debug_types dies. 719 al. which are used for both .debug_info and .debug_types dies.
499 All parameters here are unchanging for the life of the call. This 720 All parameters here are unchanging for the life of the call. This
500 struct exists to abstract away the constant parameters of die 721 struct exists to abstract away the constant parameters of die reading. */
501 reading. */
502 722
503 struct die_reader_specs 723 struct die_reader_specs
504 { 724 {
505 /* The bfd of this objfile. */ 725 /* die_section->asection->owner. */
506 bfd* abfd; 726 bfd* abfd;
507 727
508 /* The CU of the DIE we are parsing. */ 728 /* The CU of the DIE we are parsing. */
509 struct dwarf2_cu *cu; 729 struct dwarf2_cu *cu;
510 730
511 /* Pointer to start of section buffer. 731 /* Non-NULL if reading a DWO file. */
512 This is either the start of .debug_info or .debug_types. */ 732 struct dwo_file *dwo_file;
513 const gdb_byte *buffer; 733
514 }; 734 /* The section the die comes from.
735 This is either .debug_info or .debug_types, or the .dwo variants. */
736 struct dwarf2_section_info *die_section;
737
738 /* die_section->buffer. */
739 gdb_byte *buffer;
740
741 /* The end of the buffer. */
742 const gdb_byte *buffer_end;
743 };
744
745 /* Type of function passed to init_cutu_and_read_dies, et.al. */
746 typedef void (die_reader_func_ftype) (const struct die_reader_specs *reader,
747 » » » » gdb_byte *info_ptr,
748 » » » » struct die_info *comp_unit_die,
749 » » » » int has_children,
750 » » » » void *data);
515 751
516 /* The line number information for a compilation unit (found in the 752 /* The line number information for a compilation unit (found in the
517 .debug_line section) begins with a "statement program header", 753 .debug_line section) begins with a "statement program header",
518 which contains the following information. */ 754 which contains the following information. */
519 struct line_header 755 struct line_header
520 { 756 {
521 unsigned int total_length; 757 unsigned int total_length;
522 unsigned short version; 758 unsigned short version;
523 unsigned int header_length; 759 unsigned int header_length;
524 unsigned char minimum_instruction_length; 760 unsigned char minimum_instruction_length;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 /* The start and end of the statement program following this 794 /* The start and end of the statement program following this
559 header. These point into dwarf2_per_objfile->line_buffer. */ 795 header. These point into dwarf2_per_objfile->line_buffer. */
560 gdb_byte *statement_program_start, *statement_program_end; 796 gdb_byte *statement_program_start, *statement_program_end;
561 }; 797 };
562 798
563 /* When we construct a partial symbol table entry we only 799 /* When we construct a partial symbol table entry we only
564 need this much information. */ 800 need this much information. */
565 struct partial_die_info 801 struct partial_die_info
566 { 802 {
567 /* Offset of this DIE. */ 803 /* Offset of this DIE. */
568 unsigned int offset; 804 sect_offset offset;
569 805
570 /* DWARF-2 tag for this DIE. */ 806 /* DWARF-2 tag for this DIE. */
571 ENUM_BITFIELD(dwarf_tag) tag : 16; 807 ENUM_BITFIELD(dwarf_tag) tag : 16;
572 808
573 /* Assorted flags describing the data found in this DIE. */ 809 /* Assorted flags describing the data found in this DIE. */
574 unsigned int has_children : 1; 810 unsigned int has_children : 1;
575 unsigned int is_external : 1; 811 unsigned int is_external : 1;
576 unsigned int is_declaration : 1; 812 unsigned int is_declaration : 1;
577 unsigned int has_type : 1; 813 unsigned int has_type : 1;
578 unsigned int has_specification : 1; 814 unsigned int has_specification : 1;
579 unsigned int has_pc_info : 1; 815 unsigned int has_pc_info : 1;
816 unsigned int may_be_inlined : 1;
580 817
581 /* Flag set if the SCOPE field of this structure has been 818 /* Flag set if the SCOPE field of this structure has been
582 computed. */ 819 computed. */
583 unsigned int scope_set : 1; 820 unsigned int scope_set : 1;
584 821
585 /* Flag set if the DIE has a byte_size attribute. */ 822 /* Flag set if the DIE has a byte_size attribute. */
586 unsigned int has_byte_size : 1; 823 unsigned int has_byte_size : 1;
587 824
588 /* Flag set if any of the DIE's children are template arguments. */ 825 /* Flag set if any of the DIE's children are template arguments. */
589 unsigned int has_template_arguments : 1; 826 unsigned int has_template_arguments : 1;
590 827
591 /* Flag set if fixup_partial_die has been called on this die. */ 828 /* Flag set if fixup_partial_die has been called on this die. */
592 unsigned int fixup_called : 1; 829 unsigned int fixup_called : 1;
593 830
594 /* The name of this DIE. Normally the value of DW_AT_name, but 831 /* The name of this DIE. Normally the value of DW_AT_name, but
595 sometimes a default name for unnamed DIEs. */ 832 sometimes a default name for unnamed DIEs. */
596 char *name; 833 char *name;
597 834
598 /* The linkage name, if present. */ 835 /* The linkage name, if present. */
599 const char *linkage_name; 836 const char *linkage_name;
600 837
601 /* The scope to prepend to our children. This is generally 838 /* The scope to prepend to our children. This is generally
602 allocated on the comp_unit_obstack, so will disappear 839 allocated on the comp_unit_obstack, so will disappear
603 when this compilation unit leaves the cache. */ 840 when this compilation unit leaves the cache. */
604 char *scope; 841 char *scope;
605 842
606 /* The location description associated with this DIE, if any. */ 843 /* Some data associated with the partial DIE. The tag determines
607 struct dwarf_block *locdesc; 844 which field is live. */
845 union
846 {
847 /* The location description associated with this DIE, if any. */
848 struct dwarf_block *locdesc;
849 /* The offset of an import, for DW_TAG_imported_unit. */
850 sect_offset offset;
851 } d;
608 852
609 /* If HAS_PC_INFO, the PC range associated with this DIE. */ 853 /* If HAS_PC_INFO, the PC range associated with this DIE. */
610 CORE_ADDR lowpc; 854 CORE_ADDR lowpc;
611 CORE_ADDR highpc; 855 CORE_ADDR highpc;
612 856
613 /* Pointer into the info_buffer (or types_buffer) pointing at the target of 857 /* Pointer into the info_buffer (or types_buffer) pointing at the target of
614 DW_AT_sibling, if any. */ 858 DW_AT_sibling, if any. */
615 /* NOTE: This member isn't strictly necessary, read_partial_die could 859 /* NOTE: This member isn't strictly necessary, read_partial_die could
616 return DW_AT_sibling values to its caller load_partial_dies. */ 860 return DW_AT_sibling values to its caller load_partial_dies. */
617 gdb_byte *sibling; 861 gdb_byte *sibling;
618 862
619 /* If HAS_SPECIFICATION, the offset of the DIE referred to by 863 /* If HAS_SPECIFICATION, the offset of the DIE referred to by
620 DW_AT_specification (or DW_AT_abstract_origin or 864 DW_AT_specification (or DW_AT_abstract_origin or
621 DW_AT_extension). */ 865 DW_AT_extension). */
622 unsigned int spec_offset; 866 sect_offset spec_offset;
623 867
624 /* Pointers to this DIE's parent, first child, and next sibling, 868 /* Pointers to this DIE's parent, first child, and next sibling,
625 if any. */ 869 if any. */
626 struct partial_die_info *die_parent, *die_child, *die_sibling; 870 struct partial_die_info *die_parent, *die_child, *die_sibling;
627 }; 871 };
628 872
629 /* This data structure holds the information of an abbrev. */ 873 /* This data structure holds the information of an abbrev. */
630 struct abbrev_info 874 struct abbrev_info
631 { 875 {
632 unsigned int number; /* number identifying abbrev */ 876 unsigned int number; /* number identifying abbrev */
633 enum dwarf_tag tag; /* dwarf tag */ 877 enum dwarf_tag tag; /* dwarf tag */
634 unsigned short has_children; /* boolean */ 878 unsigned short has_children; /* boolean */
635 unsigned short num_attrs; /* number of attributes */ 879 unsigned short num_attrs; /* number of attributes */
636 struct attr_abbrev *attrs; /* an array of attribute descriptions */ 880 struct attr_abbrev *attrs; /* an array of attribute descriptions */
637 struct abbrev_info *next; /* next in chain */ 881 struct abbrev_info *next; /* next in chain */
638 }; 882 };
639 883
640 struct attr_abbrev 884 struct attr_abbrev
641 { 885 {
642 ENUM_BITFIELD(dwarf_attribute) name : 16; 886 ENUM_BITFIELD(dwarf_attribute) name : 16;
643 ENUM_BITFIELD(dwarf_form) form : 16; 887 ENUM_BITFIELD(dwarf_form) form : 16;
644 }; 888 };
645 889
890 /* Size of abbrev_table.abbrev_hash_table. */
891 #define ABBREV_HASH_SIZE 121
892
893 /* Top level data structure to contain an abbreviation table. */
894
895 struct abbrev_table
896 {
897 /* Where the abbrev table came from.
898 This is used as a sanity check when the table is used. */
899 sect_offset offset;
900
901 /* Storage for the abbrev table. */
902 struct obstack abbrev_obstack;
903
904 /* Hash table of abbrevs.
905 This is an array of size ABBREV_HASH_SIZE allocated in abbrev_obstack.
906 It could be statically allocated, but the previous code didn't so we
907 don't either. */
908 struct abbrev_info **abbrevs;
909 };
910
646 /* Attributes have a name and a value. */ 911 /* Attributes have a name and a value. */
647 struct attribute 912 struct attribute
648 { 913 {
649 ENUM_BITFIELD(dwarf_attribute) name : 16; 914 ENUM_BITFIELD(dwarf_attribute) name : 16;
650 ENUM_BITFIELD(dwarf_form) form : 15; 915 ENUM_BITFIELD(dwarf_form) form : 15;
651 916
652 /* Has DW_STRING already been updated by dwarf2_canonicalize_name? This 917 /* Has DW_STRING already been updated by dwarf2_canonicalize_name? This
653 field should be in u.str (existing only for DW_STRING) but it is kept 918 field should be in u.str (existing only for DW_STRING) but it is kept
654 here for better struct attribute alignment. */ 919 here for better struct attribute alignment. */
655 unsigned int string_is_canonical : 1; 920 unsigned int string_is_canonical : 1;
(...skipping 20 matching lines...) Expand all
676 unsigned char num_attrs; 941 unsigned char num_attrs;
677 942
678 /* True if we're presently building the full type name for the 943 /* True if we're presently building the full type name for the
679 type derived from this DIE. */ 944 type derived from this DIE. */
680 unsigned char building_fullname : 1; 945 unsigned char building_fullname : 1;
681 946
682 /* Abbrev number */ 947 /* Abbrev number */
683 unsigned int abbrev; 948 unsigned int abbrev;
684 949
685 /* Offset in .debug_info or .debug_types section. */ 950 /* Offset in .debug_info or .debug_types section. */
686 unsigned int offset; 951 sect_offset offset;
687 952
688 /* The dies in a compilation unit form an n-ary tree. PARENT 953 /* The dies in a compilation unit form an n-ary tree. PARENT
689 points to this die's parent; CHILD points to the first child of 954 points to this die's parent; CHILD points to the first child of
690 this node; and all the children of a given node are chained 955 this node; and all the children of a given node are chained
691 together via their SIBLING fields. */ 956 together via their SIBLING fields. */
692 struct die_info *child; /* Its first child, if any. */ 957 struct die_info *child; /* Its first child, if any. */
693 struct die_info *sibling; /* Its next sibling, if any. */ 958 struct die_info *sibling; /* Its next sibling, if any. */
694 struct die_info *parent; /* Its parent, if any. */ 959 struct die_info *parent; /* Its parent, if any. */
695 960
696 /* An array of attributes, with NUM_ATTRS elements. There may be 961 /* An array of attributes, with NUM_ATTRS elements. There may be
697 zero, but it's not common and zero-sized arrays are not 962 zero, but it's not common and zero-sized arrays are not
698 sufficiently portable C. */ 963 sufficiently portable C. */
699 struct attribute attrs[1]; 964 struct attribute attrs[1];
700 }; 965 };
701 966
702 struct function_range
703 {
704 const char *name;
705 CORE_ADDR lowpc, highpc;
706 int seen_line;
707 struct function_range *next;
708 };
709
710 /* Get at parts of an attribute structure. */ 967 /* Get at parts of an attribute structure. */
711 968
712 #define DW_STRING(attr) ((attr)->u.str) 969 #define DW_STRING(attr) ((attr)->u.str)
713 #define DW_STRING_IS_CANONICAL(attr) ((attr)->string_is_canonical) 970 #define DW_STRING_IS_CANONICAL(attr) ((attr)->string_is_canonical)
714 #define DW_UNSND(attr) ((attr)->u.unsnd) 971 #define DW_UNSND(attr) ((attr)->u.unsnd)
715 #define DW_BLOCK(attr) ((attr)->u.blk) 972 #define DW_BLOCK(attr) ((attr)->u.blk)
716 #define DW_SND(attr) ((attr)->u.snd) 973 #define DW_SND(attr) ((attr)->u.snd)
717 #define DW_ADDR(attr) ((attr)->u.addr) 974 #define DW_ADDR(attr) ((attr)->u.addr)
718 #define DW_SIGNATURED_TYPE(attr) ((attr)->u.signatured_type) 975 #define DW_SIGNATURED_TYPE(attr) ((attr)->u.signatured_type)
719 976
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 } 1053 }
797 *typedef_field_list; 1054 *typedef_field_list;
798 unsigned typedef_field_list_count; 1055 unsigned typedef_field_list_count;
799 }; 1056 };
800 1057
801 /* One item on the queue of compilation units to read in full symbols 1058 /* One item on the queue of compilation units to read in full symbols
802 for. */ 1059 for. */
803 struct dwarf2_queue_item 1060 struct dwarf2_queue_item
804 { 1061 {
805 struct dwarf2_per_cu_data *per_cu; 1062 struct dwarf2_per_cu_data *per_cu;
1063 enum language pretend_language;
806 struct dwarf2_queue_item *next; 1064 struct dwarf2_queue_item *next;
807 }; 1065 };
808 1066
809 /* The current queue. */ 1067 /* The current queue. */
810 static struct dwarf2_queue_item *dwarf2_queue, *dwarf2_queue_tail; 1068 static struct dwarf2_queue_item *dwarf2_queue, *dwarf2_queue_tail;
811 1069
812 /* Loaded secondary compilation units are kept in memory until they 1070 /* Loaded secondary compilation units are kept in memory until they
813 have not been referenced for the processing of this many 1071 have not been referenced for the processing of this many
814 compilation units. Set this to zero to disable caching. Cache 1072 compilation units. Set this to zero to disable caching. Cache
815 sizes of up to at least twenty will improve startup time for 1073 sizes of up to at least twenty will improve startup time for
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 static void 1116 static void
859 dwarf2_const_value_length_mismatch_complaint (const char *arg1, int arg2, 1117 dwarf2_const_value_length_mismatch_complaint (const char *arg1, int arg2,
860 int arg3) 1118 int arg3)
861 { 1119 {
862 complaint (&symfile_complaints, 1120 complaint (&symfile_complaints,
863 _("const value length mismatch for '%s', got %d, expected %d"), 1121 _("const value length mismatch for '%s', got %d, expected %d"),
864 arg1, arg2, arg3); 1122 arg1, arg2, arg3);
865 } 1123 }
866 1124
867 static void 1125 static void
868 dwarf2_macros_too_long_complaint (struct dwarf2_section_info *section) 1126 dwarf2_section_buffer_overflow_complaint (struct dwarf2_section_info *section)
869 { 1127 {
870 complaint (&symfile_complaints, 1128 complaint (&symfile_complaints,
871 » _("macro info runs off end of `%s' section"), 1129 » _("debug info runs off end of %s section"
872 » section->asection->name); 1130 » " [in module %s]"),
1131 » section->asection->name,
1132 » bfd_get_filename (section->asection->owner));
873 } 1133 }
874 1134
875 static void 1135 static void
876 dwarf2_macro_malformed_definition_complaint (const char *arg1) 1136 dwarf2_macro_malformed_definition_complaint (const char *arg1)
877 { 1137 {
878 complaint (&symfile_complaints, 1138 complaint (&symfile_complaints,
879 _("macro debug info contains a " 1139 _("macro debug info contains a "
880 "malformed macro definition:\n`%s'"), 1140 "malformed macro definition:\n`%s'"),
881 arg1); 1141 arg1);
882 } 1142 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 CORE_ADDR *highpc, int need_pc, 1176 CORE_ADDR *highpc, int need_pc,
917 struct dwarf2_cu *cu); 1177 struct dwarf2_cu *cu);
918 1178
919 static void add_partial_enumeration (struct partial_die_info *enum_pdi, 1179 static void add_partial_enumeration (struct partial_die_info *enum_pdi,
920 struct dwarf2_cu *cu); 1180 struct dwarf2_cu *cu);
921 1181
922 static void add_partial_subprogram (struct partial_die_info *pdi, 1182 static void add_partial_subprogram (struct partial_die_info *pdi,
923 CORE_ADDR *lowpc, CORE_ADDR *highpc, 1183 CORE_ADDR *lowpc, CORE_ADDR *highpc,
924 int need_pc, struct dwarf2_cu *cu); 1184 int need_pc, struct dwarf2_cu *cu);
925 1185
926 static gdb_byte *locate_pdi_sibling (struct partial_die_info *orig_pdi,
927 gdb_byte *buffer, gdb_byte *info_ptr,
928 bfd *abfd, struct dwarf2_cu *cu);
929
930 static void dwarf2_psymtab_to_symtab (struct partial_symtab *); 1186 static void dwarf2_psymtab_to_symtab (struct partial_symtab *);
931 1187
932 static void psymtab_to_symtab_1 (struct partial_symtab *); 1188 static void psymtab_to_symtab_1 (struct partial_symtab *);
933 1189
934 static void dwarf2_read_abbrevs (bfd *abfd, struct dwarf2_cu *cu); 1190 static struct abbrev_info *abbrev_table_lookup_abbrev
1191 (const struct abbrev_table *, unsigned int);
1192
1193 static struct abbrev_table *abbrev_table_read_table
1194 (struct dwarf2_section_info *, sect_offset);
1195
1196 static void abbrev_table_free (struct abbrev_table *);
1197
1198 static void abbrev_table_free_cleanup (void *);
1199
1200 static void dwarf2_read_abbrevs (struct dwarf2_cu *,
1201 » » » » struct dwarf2_section_info *);
935 1202
936 static void dwarf2_free_abbrev_table (void *); 1203 static void dwarf2_free_abbrev_table (void *);
937 1204
938 static unsigned int peek_abbrev_code (bfd *, gdb_byte *); 1205 static unsigned int peek_abbrev_code (bfd *, gdb_byte *);
939 1206
940 static struct abbrev_info *peek_die_abbrev (gdb_byte *, unsigned int *, 1207 static struct partial_die_info *load_partial_dies
941 » » » » » struct dwarf2_cu *); 1208 (const struct die_reader_specs *, gdb_byte *, int);
942 1209
943 static struct abbrev_info *dwarf2_lookup_abbrev (unsigned int, 1210 static gdb_byte *read_partial_die (const struct die_reader_specs *,
944 » » » » » » struct dwarf2_cu *); 1211 » » » » struct partial_die_info *,
1212 » » » » struct abbrev_info *,
1213 » » » » unsigned int,
1214 » » » » gdb_byte *);
945 1215
946 static struct partial_die_info *load_partial_dies (bfd *, 1216 static struct partial_die_info *find_partial_die (sect_offset,
947 » » » » » » gdb_byte *, gdb_byte *,
948 » » » » » » int, struct dwarf2_cu *);
949
950 static gdb_byte *read_partial_die (struct partial_die_info *,
951 struct abbrev_info *abbrev,
952 » » » » unsigned int, bfd *,
953 » » » » gdb_byte *, gdb_byte *,
954 » » » » struct dwarf2_cu *);
955
956 static struct partial_die_info *find_partial_die (unsigned int,
957 struct dwarf2_cu *); 1217 struct dwarf2_cu *);
958 1218
959 static void fixup_partial_die (struct partial_die_info *, 1219 static void fixup_partial_die (struct partial_die_info *,
960 struct dwarf2_cu *); 1220 struct dwarf2_cu *);
961 1221
962 static gdb_byte *read_attribute (struct attribute *, struct attr_abbrev *, 1222 static gdb_byte *read_attribute (const struct die_reader_specs *,
963 bfd *, gdb_byte *, struct dwarf2_cu *); 1223 » » » » struct attribute *, struct attr_abbrev *,
964 1224 » » » » gdb_byte *);
965 static gdb_byte *read_attribute_value (struct attribute *, unsigned,
966 bfd *, gdb_byte *, struct dwarf2_cu *);
967 1225
968 static unsigned int read_1_byte (bfd *, gdb_byte *); 1226 static unsigned int read_1_byte (bfd *, gdb_byte *);
969 1227
970 static int read_1_signed_byte (bfd *, gdb_byte *); 1228 static int read_1_signed_byte (bfd *, gdb_byte *);
971 1229
972 static unsigned int read_2_bytes (bfd *, gdb_byte *); 1230 static unsigned int read_2_bytes (bfd *, gdb_byte *);
973 1231
974 static unsigned int read_4_bytes (bfd *, gdb_byte *); 1232 static unsigned int read_4_bytes (bfd *, gdb_byte *);
975 1233
976 static ULONGEST read_8_bytes (bfd *, gdb_byte *); 1234 static ULONGEST read_8_bytes (bfd *, gdb_byte *);
977 1235
978 static CORE_ADDR read_address (bfd *, gdb_byte *ptr, struct dwarf2_cu *, 1236 static CORE_ADDR read_address (bfd *, gdb_byte *ptr, struct dwarf2_cu *,
979 unsigned int *); 1237 unsigned int *);
980 1238
981 static LONGEST read_initial_length (bfd *, gdb_byte *, unsigned int *); 1239 static LONGEST read_initial_length (bfd *, gdb_byte *, unsigned int *);
982 1240
983 static LONGEST read_checked_initial_length_and_offset 1241 static LONGEST read_checked_initial_length_and_offset
984 (bfd *, gdb_byte *, const struct comp_unit_head *, 1242 (bfd *, gdb_byte *, const struct comp_unit_head *,
985 unsigned int *, unsigned int *); 1243 unsigned int *, unsigned int *);
986 1244
987 static LONGEST read_offset (bfd *, gdb_byte *, const struct comp_unit_head *, 1245 static LONGEST read_offset (bfd *, gdb_byte *, const struct comp_unit_head *,
988 unsigned int *); 1246 unsigned int *);
989 1247
990 static LONGEST read_offset_1 (bfd *, gdb_byte *, unsigned int); 1248 static LONGEST read_offset_1 (bfd *, gdb_byte *, unsigned int);
991 1249
1250 static sect_offset read_abbrev_offset (struct dwarf2_section_info *,
1251 sect_offset);
1252
992 static gdb_byte *read_n_bytes (bfd *, gdb_byte *, unsigned int); 1253 static gdb_byte *read_n_bytes (bfd *, gdb_byte *, unsigned int);
993 1254
994 static char *read_direct_string (bfd *, gdb_byte *, unsigned int *); 1255 static char *read_direct_string (bfd *, gdb_byte *, unsigned int *);
995 1256
996 static char *read_indirect_string (bfd *, gdb_byte *, 1257 static char *read_indirect_string (bfd *, gdb_byte *,
997 const struct comp_unit_head *, 1258 const struct comp_unit_head *,
998 unsigned int *); 1259 unsigned int *);
999 1260
1000 static unsigned long read_unsigned_leb128 (bfd *, gdb_byte *, unsigned int *); 1261 static ULONGEST read_unsigned_leb128 (bfd *, gdb_byte *, unsigned int *);
1001 1262
1002 static long read_signed_leb128 (bfd *, gdb_byte *, unsigned int *); 1263 static LONGEST read_signed_leb128 (bfd *, gdb_byte *, unsigned int *);
1003 1264
1004 static gdb_byte *skip_leb128 (bfd *, gdb_byte *); 1265 static CORE_ADDR read_addr_index_from_leb128 (struct dwarf2_cu *, gdb_byte *,
1266 » » » » » unsigned int *);
1267
1268 static char *read_str_index (const struct die_reader_specs *reader,
1269 » » » struct dwarf2_cu *cu, ULONGEST str_index);
1005 1270
1006 static void set_cu_language (unsigned int, struct dwarf2_cu *); 1271 static void set_cu_language (unsigned int, struct dwarf2_cu *);
1007 1272
1008 static struct attribute *dwarf2_attr (struct die_info *, unsigned int, 1273 static struct attribute *dwarf2_attr (struct die_info *, unsigned int,
1009 struct dwarf2_cu *); 1274 struct dwarf2_cu *);
1010 1275
1011 static struct attribute *dwarf2_attr_no_follow (struct die_info *, 1276 static struct attribute *dwarf2_attr_no_follow (struct die_info *,
1012 » » » » » » unsigned int, 1277 » » » » » » unsigned int);
1013 » » » » » » struct dwarf2_cu *);
1014 1278
1015 static int dwarf2_flag_true_p (struct die_info *die, unsigned name, 1279 static int dwarf2_flag_true_p (struct die_info *die, unsigned name,
1016 struct dwarf2_cu *cu); 1280 struct dwarf2_cu *cu);
1017 1281
1018 static int die_is_declaration (struct die_info *, struct dwarf2_cu *cu); 1282 static int die_is_declaration (struct die_info *, struct dwarf2_cu *cu);
1019 1283
1020 static struct die_info *die_specification (struct die_info *die, 1284 static struct die_info *die_specification (struct die_info *die,
1021 struct dwarf2_cu **); 1285 struct dwarf2_cu **);
1022 1286
1023 static void free_line_header (struct line_header *lh); 1287 static void free_line_header (struct line_header *lh);
1024 1288
1025 static void add_file_name (struct line_header *, char *, unsigned int, 1289 static void add_file_name (struct line_header *, char *, unsigned int,
1026 unsigned int, unsigned int); 1290 unsigned int, unsigned int);
1027 1291
1028 static struct line_header *(dwarf_decode_line_header 1292 static struct line_header *dwarf_decode_line_header (unsigned int offset,
1029 (unsigned int offset, 1293 » » » » » » struct dwarf2_cu *cu);
1030 bfd *abfd, struct dwarf2_cu *cu));
1031 1294
1032 static void dwarf_decode_lines (struct line_header *, const char *, 1295 static void dwarf_decode_lines (struct line_header *, const char *,
1033 struct dwarf2_cu *, struct partial_symtab *, 1296 struct dwarf2_cu *, struct partial_symtab *,
1034 int); 1297 int);
1035 1298
1036 static void dwarf2_start_subfile (char *, const char *, const char *); 1299 static void dwarf2_start_subfile (char *, const char *, const char *);
1037 1300
1301 static void dwarf2_start_symtab (struct dwarf2_cu *,
1302 char *, char *, CORE_ADDR);
1303
1038 static struct symbol *new_symbol (struct die_info *, struct type *, 1304 static struct symbol *new_symbol (struct die_info *, struct type *,
1039 struct dwarf2_cu *); 1305 struct dwarf2_cu *);
1040 1306
1041 static struct symbol *new_symbol_full (struct die_info *, struct type *, 1307 static struct symbol *new_symbol_full (struct die_info *, struct type *,
1042 struct dwarf2_cu *, struct symbol *); 1308 struct dwarf2_cu *, struct symbol *);
1043 1309
1044 static void dwarf2_const_value (struct attribute *, struct symbol *, 1310 static void dwarf2_const_value (struct attribute *, struct symbol *,
1045 struct dwarf2_cu *); 1311 struct dwarf2_cu *);
1046 1312
1047 static void dwarf2_const_value_attr (struct attribute *attr, 1313 static void dwarf2_const_value_attr (struct attribute *attr,
1048 struct type *type, 1314 struct type *type,
1049 const char *name, 1315 const char *name,
1050 struct obstack *obstack, 1316 struct obstack *obstack,
1051 » » » » struct dwarf2_cu *cu, long *value, 1317 » » » » struct dwarf2_cu *cu, LONGEST *value,
1052 gdb_byte **bytes, 1318 gdb_byte **bytes,
1053 struct dwarf2_locexpr_baton **baton); 1319 struct dwarf2_locexpr_baton **baton);
1054 1320
1055 static struct type *die_type (struct die_info *, struct dwarf2_cu *); 1321 static struct type *die_type (struct die_info *, struct dwarf2_cu *);
1056 1322
1057 static int need_gnat_info (struct dwarf2_cu *); 1323 static int need_gnat_info (struct dwarf2_cu *);
1058 1324
1059 static struct type *die_descriptive_type (struct die_info *, 1325 static struct type *die_descriptive_type (struct die_info *,
1060 struct dwarf2_cu *); 1326 struct dwarf2_cu *);
1061 1327
1062 static void set_descriptive_type (struct type *, struct die_info *, 1328 static void set_descriptive_type (struct type *, struct die_info *,
1063 struct dwarf2_cu *); 1329 struct dwarf2_cu *);
1064 1330
1065 static struct type *die_containing_type (struct die_info *, 1331 static struct type *die_containing_type (struct die_info *,
1066 struct dwarf2_cu *); 1332 struct dwarf2_cu *);
1067 1333
1068 static struct type *lookup_die_type (struct die_info *, struct attribute *, 1334 static struct type *lookup_die_type (struct die_info *, struct attribute *,
1069 struct dwarf2_cu *); 1335 struct dwarf2_cu *);
1070 1336
1071 static struct type *read_type_die (struct die_info *, struct dwarf2_cu *); 1337 static struct type *read_type_die (struct die_info *, struct dwarf2_cu *);
1072 1338
1073 static struct type *read_type_die_1 (struct die_info *, struct dwarf2_cu *); 1339 static struct type *read_type_die_1 (struct die_info *, struct dwarf2_cu *);
1074 1340
1075 static char *determine_prefix (struct die_info *die, struct dwarf2_cu *); 1341 static const char *determine_prefix (struct die_info *die, struct dwarf2_cu *);
1076 1342
1077 static char *typename_concat (struct obstack *obs, const char *prefix, 1343 static char *typename_concat (struct obstack *obs, const char *prefix,
1078 const char *suffix, int physname, 1344 const char *suffix, int physname,
1079 struct dwarf2_cu *cu); 1345 struct dwarf2_cu *cu);
1080 1346
1081 static void read_file_scope (struct die_info *, struct dwarf2_cu *); 1347 static void read_file_scope (struct die_info *, struct dwarf2_cu *);
1082 1348
1083 static void read_type_unit_scope (struct die_info *, struct dwarf2_cu *); 1349 static void read_type_unit_scope (struct die_info *, struct dwarf2_cu *);
1084 1350
1085 static void read_func_scope (struct die_info *, struct dwarf2_cu *); 1351 static void read_func_scope (struct die_info *, struct dwarf2_cu *);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 static const char *namespace_name (struct die_info *die, 1398 static const char *namespace_name (struct die_info *die,
1133 int *is_anonymous, struct dwarf2_cu *); 1399 int *is_anonymous, struct dwarf2_cu *);
1134 1400
1135 static void process_enumeration_scope (struct die_info *, struct dwarf2_cu *); 1401 static void process_enumeration_scope (struct die_info *, struct dwarf2_cu *);
1136 1402
1137 static CORE_ADDR decode_locdesc (struct dwarf_block *, struct dwarf2_cu *); 1403 static CORE_ADDR decode_locdesc (struct dwarf_block *, struct dwarf2_cu *);
1138 1404
1139 static enum dwarf_array_dim_ordering read_array_order (struct die_info *, 1405 static enum dwarf_array_dim_ordering read_array_order (struct die_info *,
1140 struct dwarf2_cu *); 1406 struct dwarf2_cu *);
1141 1407
1142 static struct die_info *read_comp_unit (gdb_byte *, struct dwarf2_cu *); 1408 static struct die_info *read_die_and_children (const struct die_reader_specs *,
1143
1144 static struct die_info *read_die_and_children_1 (const struct die_reader_specs * reader,
1145 » » » » » » gdb_byte *info_ptr,
1146 » » » » » » gdb_byte **new_info_ptr,
1147 » » » » » » struct die_info *parent);
1148
1149 static struct die_info *read_die_and_children (const struct die_reader_specs *re ader,
1150 gdb_byte *info_ptr, 1409 gdb_byte *info_ptr,
1151 gdb_byte **new_info_ptr, 1410 gdb_byte **new_info_ptr,
1152 struct die_info *parent); 1411 struct die_info *parent);
1153 1412
1154 static struct die_info *read_die_and_siblings (const struct die_reader_specs *re ader, 1413 static struct die_info *read_die_and_siblings (const struct die_reader_specs *,
1155 gdb_byte *info_ptr, 1414 gdb_byte *info_ptr,
1156 gdb_byte **new_info_ptr, 1415 gdb_byte **new_info_ptr,
1157 struct die_info *parent); 1416 struct die_info *parent);
1158 1417
1159 static gdb_byte *read_full_die (const struct die_reader_specs *reader, 1418 static gdb_byte *read_full_die_1 (const struct die_reader_specs *,
1160 » » » » struct die_info **, gdb_byte *, 1419 » » » » struct die_info **, gdb_byte *, int *, int);
1161 » » » » int *); 1420
1421 static gdb_byte *read_full_die (const struct die_reader_specs *,
1422 » » » » struct die_info **, gdb_byte *, int *);
1162 1423
1163 static void process_die (struct die_info *, struct dwarf2_cu *); 1424 static void process_die (struct die_info *, struct dwarf2_cu *);
1164 1425
1165 static char *dwarf2_canonicalize_name (char *, struct dwarf2_cu *, 1426 static char *dwarf2_canonicalize_name (char *, struct dwarf2_cu *,
1166 struct obstack *); 1427 struct obstack *);
1167 1428
1168 static char *dwarf2_name (struct die_info *die, struct dwarf2_cu *); 1429 static char *dwarf2_name (struct die_info *die, struct dwarf2_cu *);
1169 1430
1170 static const char *dwarf2_full_name (char *name, 1431 static const char *dwarf2_full_name (char *name,
1171 struct die_info *die, 1432 struct die_info *die,
1172 struct dwarf2_cu *cu); 1433 struct dwarf2_cu *cu);
1173 1434
1174 static struct die_info *dwarf2_extension (struct die_info *die, 1435 static struct die_info *dwarf2_extension (struct die_info *die,
1175 struct dwarf2_cu **); 1436 struct dwarf2_cu **);
1176 1437
1177 static char *dwarf_tag_name (unsigned int); 1438 static const char *dwarf_tag_name (unsigned int);
1178 1439
1179 static char *dwarf_attr_name (unsigned int); 1440 static const char *dwarf_attr_name (unsigned int);
1180 1441
1181 static char *dwarf_form_name (unsigned int); 1442 static const char *dwarf_form_name (unsigned int);
1182 1443
1183 static char *dwarf_bool_name (unsigned int); 1444 static char *dwarf_bool_name (unsigned int);
1184 1445
1185 static char *dwarf_type_encoding_name (unsigned int); 1446 static const char *dwarf_type_encoding_name (unsigned int);
1186
1187 #if 0
1188 static char *dwarf_cfi_name (unsigned int);
1189 #endif
1190 1447
1191 static struct die_info *sibling_die (struct die_info *); 1448 static struct die_info *sibling_die (struct die_info *);
1192 1449
1193 static void dump_die_shallow (struct ui_file *, int indent, struct die_info *); 1450 static void dump_die_shallow (struct ui_file *, int indent, struct die_info *);
1194 1451
1195 static void dump_die_for_error (struct die_info *); 1452 static void dump_die_for_error (struct die_info *);
1196 1453
1197 static void dump_die_1 (struct ui_file *, int level, int max_level, 1454 static void dump_die_1 (struct ui_file *, int level, int max_level,
1198 struct die_info *); 1455 struct die_info *);
1199 1456
1200 /*static*/ void dump_die (struct die_info *, int max_level); 1457 /*static*/ void dump_die (struct die_info *, int max_level);
1201 1458
1202 static void store_in_ref_table (struct die_info *, 1459 static void store_in_ref_table (struct die_info *,
1203 struct dwarf2_cu *); 1460 struct dwarf2_cu *);
1204 1461
1205 static int is_ref_attr (struct attribute *); 1462 static int is_ref_attr (struct attribute *);
1206 1463
1207 static unsigned int dwarf2_get_ref_die_offset (struct attribute *); 1464 static sect_offset dwarf2_get_ref_die_offset (struct attribute *);
1208 1465
1209 static LONGEST dwarf2_get_attr_constant_value (struct attribute *, int); 1466 static LONGEST dwarf2_get_attr_constant_value (struct attribute *, int);
1210 1467
1211 static struct die_info *follow_die_ref_or_sig (struct die_info *, 1468 static struct die_info *follow_die_ref_or_sig (struct die_info *,
1212 struct attribute *, 1469 struct attribute *,
1213 struct dwarf2_cu **); 1470 struct dwarf2_cu **);
1214 1471
1215 static struct die_info *follow_die_ref (struct die_info *, 1472 static struct die_info *follow_die_ref (struct die_info *,
1216 struct attribute *, 1473 struct attribute *,
1217 struct dwarf2_cu **); 1474 struct dwarf2_cu **);
1218 1475
1219 static struct die_info *follow_die_sig (struct die_info *, 1476 static struct die_info *follow_die_sig (struct die_info *,
1220 struct attribute *, 1477 struct attribute *,
1221 struct dwarf2_cu **); 1478 struct dwarf2_cu **);
1222 1479
1223 static struct signatured_type *lookup_signatured_type_at_offset 1480 static struct signatured_type *lookup_signatured_type_at_offset
1224 (struct objfile *objfile, 1481 (struct objfile *objfile,
1225 struct dwarf2_section_info *section, 1482 struct dwarf2_section_info *section, sect_offset offset);
1226 unsigned int offset);
1227 1483
1228 static void read_signatured_type_at_offset (struct objfile *objfile, 1484 static void load_full_type_unit (struct dwarf2_per_cu_data *per_cu);
1229 » » » » » struct dwarf2_section_info *sect,
1230 » » » » » unsigned int offset);
1231 1485
1232 static void read_signatured_type (struct objfile *, 1486 static void read_signatured_type (struct signatured_type *);
1233 » » » » struct signatured_type *type_sig); 1487
1488 static struct type_unit_group *get_type_unit_group
1489 (struct dwarf2_cu *, struct attribute *);
1490
1491 static void build_type_unit_groups (die_reader_func_ftype *, void *);
1234 1492
1235 /* memory allocation interface */ 1493 /* memory allocation interface */
1236 1494
1237 static struct dwarf_block *dwarf_alloc_block (struct dwarf2_cu *); 1495 static struct dwarf_block *dwarf_alloc_block (struct dwarf2_cu *);
1238 1496
1239 static struct abbrev_info *dwarf_alloc_abbrev (struct dwarf2_cu *);
1240
1241 static struct die_info *dwarf_alloc_die (struct dwarf2_cu *, int); 1497 static struct die_info *dwarf_alloc_die (struct dwarf2_cu *, int);
1242 1498
1243 static void initialize_cu_func_list (struct dwarf2_cu *); 1499 static void dwarf_decode_macros (struct dwarf2_cu *, unsigned int,
1244 1500 » » » » char *, int);
1245 static void add_to_cu_func_list (const char *, CORE_ADDR, CORE_ADDR,
1246 » » » » struct dwarf2_cu *);
1247
1248 static void dwarf_decode_macros (struct line_header *, unsigned int,
1249 char *, bfd *, struct dwarf2_cu *,
1250 » » » » struct dwarf2_section_info *,
1251 » » » » int);
1252 1501
1253 static int attr_form_is_block (struct attribute *); 1502 static int attr_form_is_block (struct attribute *);
1254 1503
1255 static int attr_form_is_section_offset (struct attribute *); 1504 static int attr_form_is_section_offset (struct attribute *);
1256 1505
1257 static int attr_form_is_constant (struct attribute *); 1506 static int attr_form_is_constant (struct attribute *);
1258 1507
1259 static void fill_in_loclist_baton (struct dwarf2_cu *cu, 1508 static void fill_in_loclist_baton (struct dwarf2_cu *cu,
1260 struct dwarf2_loclist_baton *baton, 1509 struct dwarf2_loclist_baton *baton,
1261 struct attribute *attr); 1510 struct attribute *attr);
1262 1511
1263 static void dwarf2_symbol_mark_computed (struct attribute *attr, 1512 static void dwarf2_symbol_mark_computed (struct attribute *attr,
1264 struct symbol *sym, 1513 struct symbol *sym,
1265 struct dwarf2_cu *cu); 1514 struct dwarf2_cu *cu);
1266 1515
1267 static gdb_byte *skip_one_die (gdb_byte *buffer, gdb_byte *info_ptr, 1516 static gdb_byte *skip_one_die (const struct die_reader_specs *reader,
1268 » » » struct abbrev_info *abbrev, 1517 » » » gdb_byte *info_ptr,
1269 » » » struct dwarf2_cu *cu); 1518 » » » struct abbrev_info *abbrev);
1270 1519
1271 static void free_stack_comp_unit (void *); 1520 static void free_stack_comp_unit (void *);
1272 1521
1273 static hashval_t partial_die_hash (const void *item); 1522 static hashval_t partial_die_hash (const void *item);
1274 1523
1275 static int partial_die_eq (const void *item_lhs, const void *item_rhs); 1524 static int partial_die_eq (const void *item_lhs, const void *item_rhs);
1276 1525
1277 static struct dwarf2_per_cu_data *dwarf2_find_containing_comp_unit 1526 static struct dwarf2_per_cu_data *dwarf2_find_containing_comp_unit
1278 (unsigned int offset, struct objfile *objfile); 1527 (sect_offset offset, struct objfile *objfile);
1279
1280 static struct dwarf2_per_cu_data *dwarf2_find_comp_unit
1281 (unsigned int offset, struct objfile *objfile);
1282 1528
1283 static void init_one_comp_unit (struct dwarf2_cu *cu, 1529 static void init_one_comp_unit (struct dwarf2_cu *cu,
1284 » » » » struct objfile *objfile); 1530 » » » » struct dwarf2_per_cu_data *per_cu);
1285 1531
1286 static void prepare_one_comp_unit (struct dwarf2_cu *cu, 1532 static void prepare_one_comp_unit (struct dwarf2_cu *cu,
1287 » » » » struct die_info *comp_unit_die); 1533 » » » » struct die_info *comp_unit_die,
1534 » » » » enum language pretend_language);
1288 1535
1289 static void free_one_comp_unit (void *); 1536 static void free_heap_comp_unit (void *);
1290 1537
1291 static void free_cached_comp_units (void *); 1538 static void free_cached_comp_units (void *);
1292 1539
1293 static void age_cached_comp_units (void); 1540 static void age_cached_comp_units (void);
1294 1541
1295 static void free_one_cached_comp_unit (void *); 1542 static void free_one_cached_comp_unit (struct dwarf2_per_cu_data *);
1296 1543
1297 static struct type *set_die_type (struct die_info *, struct type *, 1544 static struct type *set_die_type (struct die_info *, struct type *,
1298 struct dwarf2_cu *); 1545 struct dwarf2_cu *);
1299 1546
1300 static void create_all_comp_units (struct objfile *); 1547 static void create_all_comp_units (struct objfile *);
1301 1548
1302 static int create_debug_types_hash_table (struct objfile *objfile); 1549 static int create_all_type_units (struct objfile *);
1303 1550
1304 static void load_full_comp_unit (struct dwarf2_per_cu_data *, 1551 static void load_full_comp_unit (struct dwarf2_per_cu_data *,
1305 » » » » struct objfile *); 1552 » » » » enum language);
1306 1553
1307 static void process_full_comp_unit (struct dwarf2_per_cu_data *); 1554 static void process_full_comp_unit (struct dwarf2_per_cu_data *,
1555 » » » » enum language);
1556
1557 static void process_full_type_unit (struct dwarf2_per_cu_data *,
1558 » » » » enum language);
1308 1559
1309 static void dwarf2_add_dependence (struct dwarf2_cu *, 1560 static void dwarf2_add_dependence (struct dwarf2_cu *,
1310 struct dwarf2_per_cu_data *); 1561 struct dwarf2_per_cu_data *);
1311 1562
1312 static void dwarf2_mark (struct dwarf2_cu *); 1563 static void dwarf2_mark (struct dwarf2_cu *);
1313 1564
1314 static void dwarf2_clear_marks (struct dwarf2_per_cu_data *); 1565 static void dwarf2_clear_marks (struct dwarf2_per_cu_data *);
1315 1566
1316 static struct type *get_die_type_at_offset (unsigned int, 1567 static struct type *get_die_type_at_offset (sect_offset,
1317 struct dwarf2_per_cu_data *per_cu); 1568 struct dwarf2_per_cu_data *per_cu);
1318 1569
1319 static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu); 1570 static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu);
1320 1571
1321 static void dwarf2_release_queue (void *dummy); 1572 static void dwarf2_release_queue (void *dummy);
1322 1573
1323 static void queue_comp_unit (struct dwarf2_per_cu_data *per_cu, 1574 static void queue_comp_unit (struct dwarf2_per_cu_data *per_cu,
1324 » » » struct objfile *objfile); 1575 » » » enum language pretend_language);
1325 1576
1326 static void process_queue (struct objfile *objfile); 1577 static int maybe_queue_comp_unit (struct dwarf2_cu *this_cu,
1578 » » » » struct dwarf2_per_cu_data *per_cu,
1579 » » » » enum language pretend_language);
1580
1581 static void process_queue (void);
1327 1582
1328 static void find_file_and_directory (struct die_info *die, 1583 static void find_file_and_directory (struct die_info *die,
1329 struct dwarf2_cu *cu, 1584 struct dwarf2_cu *cu,
1330 char **name, char **comp_dir); 1585 char **name, char **comp_dir);
1331 1586
1332 static char *file_full_name (int file, struct line_header *lh, 1587 static char *file_full_name (int file, struct line_header *lh,
1333 const char *comp_dir); 1588 const char *comp_dir);
1334 1589
1335 static gdb_byte *partial_read_comp_unit_head (struct comp_unit_head *header, 1590 static void init_cutu_and_read_dies
1336 » » » » » gdb_byte *info_ptr, 1591 (struct dwarf2_per_cu_data *this_cu, struct abbrev_table *abbrev_table,
1337 » » » » » gdb_byte *buffer, 1592 int use_existing_cu, int keep,
1338 » » » » » unsigned int buffer_size, 1593 die_reader_func_ftype *die_reader_func, void *data);
1339 » » » » » bfd *abfd,
1340 » » » » » int is_debug_types_section);
1341 1594
1342 static void init_cu_die_reader (struct die_reader_specs *reader, 1595 static void init_cutu_and_read_dies_simple
1343 » » » » struct dwarf2_cu *cu); 1596 (struct dwarf2_per_cu_data *this_cu,
1597 die_reader_func_ftype *die_reader_func, void *data);
1344 1598
1345 static htab_t allocate_signatured_type_table (struct objfile *objfile); 1599 static htab_t allocate_signatured_type_table (struct objfile *objfile);
1346 1600
1601 static htab_t allocate_dwo_unit_table (struct objfile *objfile);
1602
1603 static struct dwo_unit *lookup_dwo_comp_unit
1604 (struct dwarf2_per_cu_data *, char *, const char *, ULONGEST);
1605
1606 static struct dwo_unit *lookup_dwo_type_unit
1607 (struct signatured_type *, char *, const char *);
1608
1609 static void free_dwo_file_cleanup (void *);
1610
1611 static void munmap_section_buffer (struct dwarf2_section_info *);
1612
1613 static void process_cu_includes (void);
1614
1347 #if WORDS_BIGENDIAN 1615 #if WORDS_BIGENDIAN
1348 1616
1349 /* Convert VALUE between big- and little-endian. */ 1617 /* Convert VALUE between big- and little-endian. */
1350 static offset_type 1618 static offset_type
1351 byte_swap (offset_type value) 1619 byte_swap (offset_type value)
1352 { 1620 {
1353 offset_type result; 1621 offset_type result;
1354 1622
1355 result = (value & 0xff) << 24; 1623 result = (value & 0xff) << 24;
1356 result |= (value & 0xff00) << 8; 1624 result |= (value & 0xff00) << 8;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 } 1684 }
1417 1685
1418 /* This function is mapped across the sections and remembers the 1686 /* This function is mapped across the sections and remembers the
1419 offset and size of each of the debugging sections we are interested 1687 offset and size of each of the debugging sections we are interested
1420 in. */ 1688 in. */
1421 1689
1422 static void 1690 static void
1423 dwarf2_locate_sections (bfd *abfd, asection *sectp, void *vnames) 1691 dwarf2_locate_sections (bfd *abfd, asection *sectp, void *vnames)
1424 { 1692 {
1425 const struct dwarf2_debug_sections *names; 1693 const struct dwarf2_debug_sections *names;
1694 flagword aflag = bfd_get_section_flags (abfd, sectp);
1426 1695
1427 if (vnames == NULL) 1696 if (vnames == NULL)
1428 names = &dwarf2_elf_names; 1697 names = &dwarf2_elf_names;
1429 else 1698 else
1430 names = (const struct dwarf2_debug_sections *) vnames; 1699 names = (const struct dwarf2_debug_sections *) vnames;
1431 1700
1432 if (section_is_p (sectp->name, &names->info)) 1701 if ((aflag & SEC_HAS_CONTENTS) == 0)
1702 {
1703 }
1704 else if (section_is_p (sectp->name, &names->info))
1433 { 1705 {
1434 dwarf2_per_objfile->info.asection = sectp; 1706 dwarf2_per_objfile->info.asection = sectp;
1435 dwarf2_per_objfile->info.size = bfd_get_section_size (sectp); 1707 dwarf2_per_objfile->info.size = bfd_get_section_size (sectp);
1436 } 1708 }
1437 else if (section_is_p (sectp->name, &names->abbrev)) 1709 else if (section_is_p (sectp->name, &names->abbrev))
1438 { 1710 {
1439 dwarf2_per_objfile->abbrev.asection = sectp; 1711 dwarf2_per_objfile->abbrev.asection = sectp;
1440 dwarf2_per_objfile->abbrev.size = bfd_get_section_size (sectp); 1712 dwarf2_per_objfile->abbrev.size = bfd_get_section_size (sectp);
1441 } 1713 }
1442 else if (section_is_p (sectp->name, &names->line)) 1714 else if (section_is_p (sectp->name, &names->line))
(...skipping 14 matching lines...) Expand all
1457 else if (section_is_p (sectp->name, &names->macro)) 1729 else if (section_is_p (sectp->name, &names->macro))
1458 { 1730 {
1459 dwarf2_per_objfile->macro.asection = sectp; 1731 dwarf2_per_objfile->macro.asection = sectp;
1460 dwarf2_per_objfile->macro.size = bfd_get_section_size (sectp); 1732 dwarf2_per_objfile->macro.size = bfd_get_section_size (sectp);
1461 } 1733 }
1462 else if (section_is_p (sectp->name, &names->str)) 1734 else if (section_is_p (sectp->name, &names->str))
1463 { 1735 {
1464 dwarf2_per_objfile->str.asection = sectp; 1736 dwarf2_per_objfile->str.asection = sectp;
1465 dwarf2_per_objfile->str.size = bfd_get_section_size (sectp); 1737 dwarf2_per_objfile->str.size = bfd_get_section_size (sectp);
1466 } 1738 }
1739 else if (section_is_p (sectp->name, &names->addr))
1740 {
1741 dwarf2_per_objfile->addr.asection = sectp;
1742 dwarf2_per_objfile->addr.size = bfd_get_section_size (sectp);
1743 }
1467 else if (section_is_p (sectp->name, &names->frame)) 1744 else if (section_is_p (sectp->name, &names->frame))
1468 { 1745 {
1469 dwarf2_per_objfile->frame.asection = sectp; 1746 dwarf2_per_objfile->frame.asection = sectp;
1470 dwarf2_per_objfile->frame.size = bfd_get_section_size (sectp); 1747 dwarf2_per_objfile->frame.size = bfd_get_section_size (sectp);
1471 } 1748 }
1472 else if (section_is_p (sectp->name, &names->eh_frame)) 1749 else if (section_is_p (sectp->name, &names->eh_frame))
1473 { 1750 {
1474 flagword aflag = bfd_get_section_flags (ignore_abfd, sectp); 1751 dwarf2_per_objfile->eh_frame.asection = sectp;
1475 1752 dwarf2_per_objfile->eh_frame.size = bfd_get_section_size (sectp);
1476 if (aflag & SEC_HAS_CONTENTS)
1477 {
1478 » dwarf2_per_objfile->eh_frame.asection = sectp;
1479 dwarf2_per_objfile->eh_frame.size = bfd_get_section_size (sectp);
1480 }
1481 } 1753 }
1482 else if (section_is_p (sectp->name, &names->ranges)) 1754 else if (section_is_p (sectp->name, &names->ranges))
1483 { 1755 {
1484 dwarf2_per_objfile->ranges.asection = sectp; 1756 dwarf2_per_objfile->ranges.asection = sectp;
1485 dwarf2_per_objfile->ranges.size = bfd_get_section_size (sectp); 1757 dwarf2_per_objfile->ranges.size = bfd_get_section_size (sectp);
1486 } 1758 }
1487 else if (section_is_p (sectp->name, &names->types)) 1759 else if (section_is_p (sectp->name, &names->types))
1488 { 1760 {
1489 struct dwarf2_section_info type_section; 1761 struct dwarf2_section_info type_section;
1490 1762
(...skipping 15 matching lines...) Expand all
1506 dwarf2_per_objfile->has_section_at_zero = 1; 1778 dwarf2_per_objfile->has_section_at_zero = 1;
1507 } 1779 }
1508 1780
1509 /* Decompress a section that was compressed using zlib. Store the 1781 /* Decompress a section that was compressed using zlib. Store the
1510 decompressed buffer, and its size, in OUTBUF and OUTSIZE. */ 1782 decompressed buffer, and its size, in OUTBUF and OUTSIZE. */
1511 1783
1512 static void 1784 static void
1513 zlib_decompress_section (struct objfile *objfile, asection *sectp, 1785 zlib_decompress_section (struct objfile *objfile, asection *sectp,
1514 gdb_byte **outbuf, bfd_size_type *outsize) 1786 gdb_byte **outbuf, bfd_size_type *outsize)
1515 { 1787 {
1516 bfd *abfd = objfile->obfd; 1788 bfd *abfd = sectp->owner;
1517 #ifndef HAVE_ZLIB_H 1789 #ifndef HAVE_ZLIB_H
1518 error (_("Support for zlib-compressed DWARF data (from '%s') " 1790 error (_("Support for zlib-compressed DWARF data (from '%s') "
1519 "is disabled in this copy of GDB"), 1791 "is disabled in this copy of GDB"),
1520 bfd_get_filename (abfd)); 1792 bfd_get_filename (abfd));
1521 #else 1793 #else
1522 bfd_size_type compressed_size = bfd_get_section_size (sectp); 1794 bfd_size_type compressed_size = bfd_get_section_size (sectp);
1523 gdb_byte *compressed_buffer = xmalloc (compressed_size); 1795 gdb_byte *compressed_buffer = xmalloc (compressed_size);
1524 struct cleanup *cleanup = make_cleanup (xfree, compressed_buffer); 1796 struct cleanup *cleanup = make_cleanup (xfree, compressed_buffer);
1525 bfd_size_type uncompressed_size; 1797 bfd_size_type uncompressed_size;
1526 gdb_byte *uncompressed_buffer; 1798 gdb_byte *uncompressed_buffer;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 || strm.avail_out != 0) 1850 || strm.avail_out != 0)
1579 error (_("Dwarf Error: concluding DWARF uncompression in '%s': %d"), 1851 error (_("Dwarf Error: concluding DWARF uncompression in '%s': %d"),
1580 bfd_get_filename (abfd), rc); 1852 bfd_get_filename (abfd), rc);
1581 1853
1582 do_cleanups (cleanup); 1854 do_cleanups (cleanup);
1583 *outbuf = uncompressed_buffer; 1855 *outbuf = uncompressed_buffer;
1584 *outsize = uncompressed_size; 1856 *outsize = uncompressed_size;
1585 #endif 1857 #endif
1586 } 1858 }
1587 1859
1588 /* A helper function that decides whether a section is empty. */ 1860 /* A helper function that decides whether a section is empty,
1861 or not present. */
1589 1862
1590 static int 1863 static int
1591 dwarf2_section_empty_p (struct dwarf2_section_info *info) 1864 dwarf2_section_empty_p (struct dwarf2_section_info *info)
1592 { 1865 {
1593 return info->asection == NULL || info->size == 0; 1866 return info->asection == NULL || info->size == 0;
1594 } 1867 }
1595 1868
1596 /* Read the contents of the section SECTP from object file specified by 1869 /* Read the contents of the section INFO.
1597 OBJFILE, store info about the section into INFO. 1870 OBJFILE is the main object file, but not necessarily the file where
1871 the section comes from. E.g., for DWO files INFO->asection->owner
1872 is the bfd of the DWO file.
1598 If the section is compressed, uncompress it before returning. */ 1873 If the section is compressed, uncompress it before returning. */
1599 1874
1600 static void 1875 static void
1601 dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) 1876 dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info)
1602 { 1877 {
1603 bfd *abfd = objfile->obfd;
1604 asection *sectp = info->asection; 1878 asection *sectp = info->asection;
1879 bfd *abfd;
1605 gdb_byte *buf, *retbuf; 1880 gdb_byte *buf, *retbuf;
1606 unsigned char header[4]; 1881 unsigned char header[4];
1607 1882
1608 if (info->readin) 1883 if (info->readin)
1609 return; 1884 return;
1610 info->buffer = NULL; 1885 info->buffer = NULL;
1611 info->map_addr = NULL; 1886 info->map_addr = NULL;
1612 info->readin = 1; 1887 info->readin = 1;
1613 1888
1614 if (dwarf2_section_empty_p (info)) 1889 if (dwarf2_section_empty_p (info))
1615 return; 1890 return;
1616 1891
1892 /* Note that ABFD may not be from OBJFILE, e.g. a DWO section. */
1893 abfd = sectp->owner;
1894
1617 /* Check if the file has a 4-byte header indicating compression. */ 1895 /* Check if the file has a 4-byte header indicating compression. */
1618 if (info->size > sizeof (header) 1896 if (info->size > sizeof (header)
1619 && bfd_seek (abfd, sectp->filepos, SEEK_SET) == 0 1897 && bfd_seek (abfd, sectp->filepos, SEEK_SET) == 0
1620 && bfd_bread (header, sizeof (header), abfd) == sizeof (header)) 1898 && bfd_bread (header, sizeof (header), abfd) == sizeof (header))
1621 { 1899 {
1622 /* Upon decompression, update the buffer and its size. */ 1900 /* Upon decompression, update the buffer and its size. */
1623 if (strncmp (header, "ZLIB", sizeof (header)) == 0) 1901 if (strncmp (header, "ZLIB", sizeof (header)) == 0)
1624 { 1902 {
1625 zlib_decompress_section (objfile, sectp, &info->buffer, 1903 zlib_decompress_section (objfile, sectp, &info->buffer,
1626 &info->size); 1904 &info->size);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 *sizep = info->size; 2008 *sizep = info->size;
1731 } 2009 }
1732 2010
1733 2011
1734 2012
1735 /* DWARF quick_symbols_functions support. */ 2013 /* DWARF quick_symbols_functions support. */
1736 2014
1737 /* TUs can share .debug_line entries, and there can be a lot more TUs than 2015 /* TUs can share .debug_line entries, and there can be a lot more TUs than
1738 unique line tables, so we maintain a separate table of all .debug_line 2016 unique line tables, so we maintain a separate table of all .debug_line
1739 derived entries to support the sharing. 2017 derived entries to support the sharing.

error: old chunk mismatch

OLDNEW
« no previous file with comments | « gdb/dwarf2loc.c ('k') | gdb/elfread.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698