Commit | Line | Data |
---|---|---|
19e6b90e | 1 | /* dwarf.c -- display DWARF contents of a BFD binary file |
b90efa5b | 2 | Copyright (C) 2005-2015 Free Software Foundation, Inc. |
19e6b90e L |
3 | |
4 | This file is part of GNU Binutils. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
32866df7 | 8 | the Free Software Foundation; either version 3 of the License, or |
19e6b90e L |
9 | (at your option) any later version. |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program; if not, write to the Free Software | |
18 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA | |
19 | 02110-1301, USA. */ | |
20 | ||
3db64b00 | 21 | #include "sysdep.h" |
19e6b90e | 22 | #include "libiberty.h" |
3db64b00 | 23 | #include "bfd.h" |
5bbdf3d5 | 24 | #include "bfd_stdint.h" |
3db64b00 | 25 | #include "bucomm.h" |
3284fe0c | 26 | #include "elfcomm.h" |
2dc4cec1 | 27 | #include "elf/common.h" |
fa8f86ff | 28 | #include "dwarf2.h" |
3db64b00 | 29 | #include "dwarf.h" |
8d6eee87 | 30 | #include "gdb/gdb-index.h" |
19e6b90e | 31 | |
18464d4d JK |
32 | static const char *regname (unsigned int regno, int row); |
33 | ||
19e6b90e L |
34 | static int have_frame_base; |
35 | static int need_base_address; | |
36 | ||
37 | static unsigned int last_pointer_size = 0; | |
38 | static int warned_about_missing_comp_units = FALSE; | |
39 | ||
40 | static unsigned int num_debug_info_entries = 0; | |
82b1b41b | 41 | static unsigned int alloc_num_debug_info_entries = 0; |
19e6b90e | 42 | static debug_info *debug_information = NULL; |
cc86f28f NC |
43 | /* Special value for num_debug_info_entries to indicate |
44 | that the .debug_info section could not be loaded/parsed. */ | |
45 | #define DEBUG_INFO_UNAVAILABLE (unsigned int) -1 | |
19e6b90e | 46 | |
2dc4cec1 | 47 | int eh_addr_size; |
19e6b90e L |
48 | |
49 | int do_debug_info; | |
50 | int do_debug_abbrevs; | |
51 | int do_debug_lines; | |
52 | int do_debug_pubnames; | |
f9f0e732 | 53 | int do_debug_pubtypes; |
19e6b90e L |
54 | int do_debug_aranges; |
55 | int do_debug_ranges; | |
56 | int do_debug_frames; | |
57 | int do_debug_frames_interp; | |
58 | int do_debug_macinfo; | |
59 | int do_debug_str; | |
60 | int do_debug_loc; | |
5bbdf3d5 | 61 | int do_gdb_index; |
6f875884 TG |
62 | int do_trace_info; |
63 | int do_trace_abbrevs; | |
64 | int do_trace_aranges; | |
657d0d47 CC |
65 | int do_debug_addr; |
66 | int do_debug_cu_index; | |
a262ae96 | 67 | int do_wide; |
19e6b90e | 68 | |
fd2f0033 TT |
69 | int dwarf_cutoff_level = -1; |
70 | unsigned long dwarf_start_die; | |
71 | ||
4723351a CC |
72 | int dwarf_check = 0; |
73 | ||
341f9135 CC |
74 | /* Collection of CU/TU section sets from .debug_cu_index and .debug_tu_index |
75 | sections. For version 1 package files, each set is stored in SHNDX_POOL | |
76 | as a zero-terminated list of section indexes comprising one set of debug | |
77 | sections from a .dwo file. */ | |
78 | ||
79 | static int cu_tu_indexes_read = 0; | |
80 | static unsigned int *shndx_pool = NULL; | |
81 | static unsigned int shndx_pool_size = 0; | |
82 | static unsigned int shndx_pool_used = 0; | |
83 | ||
84 | /* For version 2 package files, each set contains an array of section offsets | |
85 | and an array of section sizes, giving the offset and size of the | |
86 | contribution from a CU or TU within one of the debug sections. | |
87 | When displaying debug info from a package file, we need to use these | |
88 | tables to locate the corresponding contributions to each section. */ | |
89 | ||
90 | struct cu_tu_set | |
91 | { | |
92 | uint64_t signature; | |
93 | dwarf_vma section_offsets[DW_SECT_MAX]; | |
94 | size_t section_sizes[DW_SECT_MAX]; | |
95 | }; | |
96 | ||
97 | static int cu_count = 0; | |
98 | static int tu_count = 0; | |
99 | static struct cu_tu_set *cu_sets = NULL; | |
100 | static struct cu_tu_set *tu_sets = NULL; | |
101 | ||
102 | static void load_cu_tu_indexes (void *file); | |
103 | ||
4cb93e3b TG |
104 | /* Values for do_debug_lines. */ |
105 | #define FLAG_DEBUG_LINES_RAW 1 | |
106 | #define FLAG_DEBUG_LINES_DECODED 2 | |
107 | ||
f1c4cc75 RH |
108 | static int |
109 | size_of_encoded_value (int encoding) | |
110 | { | |
111 | switch (encoding & 0x7) | |
112 | { | |
113 | default: /* ??? */ | |
114 | case 0: return eh_addr_size; | |
115 | case 2: return 2; | |
116 | case 3: return 4; | |
117 | case 4: return 8; | |
118 | } | |
119 | } | |
120 | ||
121 | static dwarf_vma | |
041830e0 | 122 | get_encoded_value (unsigned char **pdata, |
bad62cf5 | 123 | int encoding, |
041830e0 NC |
124 | struct dwarf_section *section, |
125 | unsigned char * end) | |
f1c4cc75 | 126 | { |
041830e0 | 127 | unsigned char * data = * pdata; |
6937bb54 | 128 | unsigned int size = size_of_encoded_value (encoding); |
bad62cf5 | 129 | dwarf_vma val; |
f1c4cc75 | 130 | |
041830e0 NC |
131 | if (data + size >= end) |
132 | { | |
133 | warn (_("Encoded value extends past end of section\n")); | |
134 | * pdata = end; | |
135 | return 0; | |
136 | } | |
137 | ||
6937bb54 NC |
138 | /* PR 17512: file: 002-829853-0.004. */ |
139 | if (size > 8) | |
140 | { | |
141 | warn (_("Encoded size of %d is too large to read\n"), size); | |
142 | * pdata = end; | |
143 | return 0; | |
144 | } | |
145 | ||
0a9d414a NC |
146 | /* PR 17512: file: 1085-5603-0.004. */ |
147 | if (size == 0) | |
148 | { | |
149 | warn (_("Encoded size of 0 is too small to read\n")); | |
150 | * pdata = end; | |
151 | return 0; | |
152 | } | |
153 | ||
f1c4cc75 | 154 | if (encoding & DW_EH_PE_signed) |
bad62cf5 | 155 | val = byte_get_signed (data, size); |
f1c4cc75 | 156 | else |
bad62cf5 AM |
157 | val = byte_get (data, size); |
158 | ||
159 | if ((encoding & 0x70) == DW_EH_PE_pcrel) | |
160 | val += section->address + (data - section->start); | |
041830e0 NC |
161 | |
162 | * pdata = data + size; | |
bad62cf5 | 163 | return val; |
f1c4cc75 RH |
164 | } |
165 | ||
4c219c2e AM |
166 | #if defined HAVE_LONG_LONG && SIZEOF_LONG_LONG > SIZEOF_LONG |
167 | # ifndef __MINGW32__ | |
168 | # define DWARF_VMA_FMT "ll" | |
169 | # define DWARF_VMA_FMT_LONG "%16.16llx" | |
170 | # else | |
171 | # define DWARF_VMA_FMT "I64" | |
172 | # define DWARF_VMA_FMT_LONG "%016I64x" | |
173 | # endif | |
2e14fae2 | 174 | #else |
4c219c2e AM |
175 | # define DWARF_VMA_FMT "l" |
176 | # define DWARF_VMA_FMT_LONG "%16.16lx" | |
2d9472a2 NC |
177 | #endif |
178 | ||
bf5117e3 NC |
179 | /* Convert a dwarf vma value into a string. Returns a pointer to a static |
180 | buffer containing the converted VALUE. The value is converted according | |
181 | to the printf formating character FMTCH. If NUM_BYTES is non-zero then | |
182 | it specifies the maximum number of bytes to be displayed in the converted | |
183 | value and FMTCH is ignored - hex is always used. */ | |
467c65bc | 184 | |
47704ddf | 185 | static const char * |
bf5117e3 | 186 | dwarf_vmatoa_1 (const char *fmtch, dwarf_vma value, unsigned num_bytes) |
47704ddf KT |
187 | { |
188 | /* As dwarf_vmatoa is used more then once in a printf call | |
189 | for output, we are cycling through an fixed array of pointers | |
190 | for return address. */ | |
191 | static int buf_pos = 0; | |
467c65bc NC |
192 | static struct dwarf_vmatoa_buf |
193 | { | |
47704ddf KT |
194 | char place[64]; |
195 | } buf[16]; | |
47704ddf KT |
196 | char *ret; |
197 | ||
47704ddf | 198 | ret = buf[buf_pos++].place; |
467c65bc | 199 | buf_pos %= ARRAY_SIZE (buf); |
47704ddf | 200 | |
bf5117e3 NC |
201 | if (num_bytes) |
202 | { | |
203 | /* Printf does not have a way of specifiying a maximum field width for an | |
204 | integer value, so we print the full value into a buffer and then select | |
205 | the precision we need. */ | |
206 | snprintf (ret, sizeof (buf[0].place), DWARF_VMA_FMT_LONG, value); | |
207 | if (num_bytes > 8) | |
208 | num_bytes = 8; | |
209 | return ret + (16 - 2 * num_bytes); | |
210 | } | |
211 | else | |
212 | { | |
213 | char fmt[32]; | |
214 | ||
215 | sprintf (fmt, "%%%s%s", DWARF_VMA_FMT, fmtch); | |
216 | snprintf (ret, sizeof (buf[0].place), fmt, value); | |
217 | return ret; | |
218 | } | |
219 | } | |
47704ddf | 220 | |
bf5117e3 NC |
221 | static inline const char * |
222 | dwarf_vmatoa (const char * fmtch, dwarf_vma value) | |
223 | { | |
224 | return dwarf_vmatoa_1 (fmtch, value, 0); | |
225 | } | |
226 | ||
227 | /* Print a dwarf_vma value (typically an address, offset or length) in | |
228 | hexadecimal format, followed by a space. The length of the VALUE (and | |
229 | hence the precision displayed) is determined by the NUM_BYTES parameter. */ | |
230 | ||
231 | static void | |
232 | print_dwarf_vma (dwarf_vma value, unsigned num_bytes) | |
233 | { | |
234 | printf ("%s ", dwarf_vmatoa_1 (NULL, value, num_bytes)); | |
47704ddf KT |
235 | } |
236 | ||
74bc6052 CC |
237 | /* Format a 64-bit value, given as two 32-bit values, in hex. |
238 | For reentrancy, this uses a buffer provided by the caller. */ | |
239 | ||
240 | static const char * | |
241 | dwarf_vmatoa64 (dwarf_vma hvalue, dwarf_vma lvalue, char *buf, | |
242 | unsigned int buf_len) | |
243 | { | |
244 | int len = 0; | |
245 | ||
246 | if (hvalue == 0) | |
247 | snprintf (buf, buf_len, "%" DWARF_VMA_FMT "x", lvalue); | |
248 | else | |
249 | { | |
250 | len = snprintf (buf, buf_len, "%" DWARF_VMA_FMT "x", hvalue); | |
251 | snprintf (buf + len, buf_len - len, | |
252 | "%08" DWARF_VMA_FMT "x", lvalue); | |
253 | } | |
254 | ||
255 | return buf; | |
256 | } | |
257 | ||
f6f0e17b NC |
258 | /* Read in a LEB128 encoded value starting at address DATA. |
259 | If SIGN is true, return a signed LEB128 value. | |
260 | If LENGTH_RETURN is not NULL, return in it the number of bytes read. | |
261 | No bytes will be read at address END or beyond. */ | |
262 | ||
467c65bc | 263 | dwarf_vma |
f6f0e17b NC |
264 | read_leb128 (unsigned char *data, |
265 | unsigned int *length_return, | |
266 | bfd_boolean sign, | |
267 | const unsigned char * const end) | |
19e6b90e | 268 | { |
467c65bc | 269 | dwarf_vma result = 0; |
19e6b90e L |
270 | unsigned int num_read = 0; |
271 | unsigned int shift = 0; | |
f6f0e17b | 272 | unsigned char byte = 0; |
19e6b90e | 273 | |
f6f0e17b | 274 | while (data < end) |
19e6b90e L |
275 | { |
276 | byte = *data++; | |
277 | num_read++; | |
278 | ||
467c65bc | 279 | result |= ((dwarf_vma) (byte & 0x7f)) << shift; |
19e6b90e L |
280 | |
281 | shift += 7; | |
f6f0e17b NC |
282 | if ((byte & 0x80) == 0) |
283 | break; | |
19e6b90e | 284 | } |
19e6b90e L |
285 | |
286 | if (length_return != NULL) | |
287 | *length_return = num_read; | |
288 | ||
289 | if (sign && (shift < 8 * sizeof (result)) && (byte & 0x40)) | |
65879393 | 290 | result |= (dwarf_vma) -1 << shift; |
19e6b90e L |
291 | |
292 | return result; | |
293 | } | |
294 | ||
467c65bc | 295 | /* Create a signed version to avoid painful typecasts. */ |
f6f0e17b NC |
296 | static inline dwarf_signed_vma |
297 | read_sleb128 (unsigned char * data, | |
298 | unsigned int * length_return, | |
299 | const unsigned char * const end) | |
300 | { | |
301 | return (dwarf_signed_vma) read_leb128 (data, length_return, TRUE, end); | |
302 | } | |
303 | ||
304 | static inline dwarf_vma | |
305 | read_uleb128 (unsigned char * data, | |
306 | unsigned int * length_return, | |
307 | const unsigned char * const end) | |
467c65bc | 308 | { |
f6f0e17b | 309 | return read_leb128 (data, length_return, FALSE, end); |
467c65bc NC |
310 | } |
311 | ||
0c588247 NC |
312 | #define SAFE_BYTE_GET(VAL, PTR, AMOUNT, END) \ |
313 | do \ | |
314 | { \ | |
e39462cb | 315 | int dummy [sizeof (VAL) < (AMOUNT) ? -1 : 1] ATTRIBUTE_UNUSED ; \ |
0c588247 NC |
316 | unsigned int amount = (AMOUNT); \ |
317 | if (((PTR) + amount) >= (END)) \ | |
318 | { \ | |
319 | if ((PTR) < (END)) \ | |
320 | amount = (END) - (PTR); \ | |
321 | else \ | |
322 | amount = 0; \ | |
323 | } \ | |
6937bb54 | 324 | if (amount == 0 || amount > 8) \ |
0c588247 | 325 | VAL = 0; \ |
6937bb54 NC |
326 | else \ |
327 | VAL = byte_get ((PTR), amount); \ | |
0c588247 NC |
328 | } \ |
329 | while (0) | |
330 | ||
331 | #define SAFE_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \ | |
332 | do \ | |
333 | { \ | |
334 | SAFE_BYTE_GET (VAL, PTR, AMOUNT, END); \ | |
335 | PTR += AMOUNT; \ | |
336 | } \ | |
337 | while (0) | |
338 | ||
339 | #define SAFE_SIGNED_BYTE_GET(VAL, PTR, AMOUNT, END) \ | |
340 | do \ | |
341 | { \ | |
342 | unsigned int amount = (AMOUNT); \ | |
343 | if (((PTR) + amount) >= (END)) \ | |
344 | { \ | |
345 | if ((PTR) < (END)) \ | |
346 | amount = (END) - (PTR); \ | |
347 | else \ | |
348 | amount = 0; \ | |
349 | } \ | |
350 | if (amount) \ | |
351 | VAL = byte_get_signed ((PTR), amount); \ | |
352 | else \ | |
353 | VAL = 0; \ | |
354 | } \ | |
355 | while (0) | |
356 | ||
357 | #define SAFE_SIGNED_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \ | |
358 | do \ | |
359 | { \ | |
360 | SAFE_SIGNED_BYTE_GET (VAL, PTR, AMOUNT, END); \ | |
361 | PTR += AMOUNT; \ | |
362 | } \ | |
363 | while (0) | |
364 | ||
365 | #define SAFE_BYTE_GET64(PTR, HIGH, LOW, END) \ | |
366 | do \ | |
367 | { \ | |
87bc83b3 | 368 | if (((PTR) + 8) <= (END)) \ |
0c588247 NC |
369 | { \ |
370 | byte_get_64 ((PTR), (HIGH), (LOW)); \ | |
371 | } \ | |
372 | else \ | |
373 | { \ | |
0c588247 NC |
374 | * (LOW) = * (HIGH) = 0; \ |
375 | } \ | |
376 | } \ | |
377 | while (0) | |
378 | ||
19e6b90e L |
379 | typedef struct State_Machine_Registers |
380 | { | |
467c65bc | 381 | dwarf_vma address; |
19e6b90e L |
382 | unsigned int file; |
383 | unsigned int line; | |
384 | unsigned int column; | |
385 | int is_stmt; | |
386 | int basic_block; | |
a233b20c JJ |
387 | unsigned char op_index; |
388 | unsigned char end_sequence; | |
19e6b90e L |
389 | /* This variable hold the number of the last entry seen |
390 | in the File Table. */ | |
391 | unsigned int last_file_entry; | |
392 | } SMR; | |
393 | ||
394 | static SMR state_machine_regs; | |
395 | ||
396 | static void | |
397 | reset_state_machine (int is_stmt) | |
398 | { | |
399 | state_machine_regs.address = 0; | |
a233b20c | 400 | state_machine_regs.op_index = 0; |
19e6b90e L |
401 | state_machine_regs.file = 1; |
402 | state_machine_regs.line = 1; | |
403 | state_machine_regs.column = 0; | |
404 | state_machine_regs.is_stmt = is_stmt; | |
405 | state_machine_regs.basic_block = 0; | |
406 | state_machine_regs.end_sequence = 0; | |
407 | state_machine_regs.last_file_entry = 0; | |
408 | } | |
409 | ||
410 | /* Handled an extend line op. | |
411 | Returns the number of bytes read. */ | |
412 | ||
413 | static int | |
f6f0e17b NC |
414 | process_extended_line_op (unsigned char * data, |
415 | int is_stmt, | |
416 | unsigned char * end) | |
19e6b90e L |
417 | { |
418 | unsigned char op_code; | |
419 | unsigned int bytes_read; | |
420 | unsigned int len; | |
421 | unsigned char *name; | |
143a3db0 | 422 | unsigned char *orig_data = data; |
f6f0e17b | 423 | dwarf_vma adr; |
19e6b90e | 424 | |
f6f0e17b | 425 | len = read_uleb128 (data, & bytes_read, end); |
19e6b90e L |
426 | data += bytes_read; |
427 | ||
e44c58ce | 428 | if (len == 0 || data == end || len > (uintptr_t) (end - data)) |
19e6b90e | 429 | { |
f41e4712 | 430 | warn (_("Badly formed extended line op encountered!\n")); |
19e6b90e L |
431 | return bytes_read; |
432 | } | |
433 | ||
434 | len += bytes_read; | |
435 | op_code = *data++; | |
436 | ||
437 | printf (_(" Extended opcode %d: "), op_code); | |
438 | ||
439 | switch (op_code) | |
440 | { | |
441 | case DW_LNE_end_sequence: | |
442 | printf (_("End of Sequence\n\n")); | |
443 | reset_state_machine (is_stmt); | |
444 | break; | |
445 | ||
446 | case DW_LNE_set_address: | |
6937bb54 NC |
447 | /* PR 17512: file: 002-100480-0.004. */ |
448 | if (len - bytes_read - 1 > 8) | |
449 | warn (_("Length (%d) of DW_LNE_set_address op is too long\n"), | |
450 | len - bytes_read - 1); | |
0c588247 | 451 | SAFE_BYTE_GET (adr, data, len - bytes_read - 1, end); |
47704ddf | 452 | printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr)); |
19e6b90e | 453 | state_machine_regs.address = adr; |
a233b20c | 454 | state_machine_regs.op_index = 0; |
19e6b90e L |
455 | break; |
456 | ||
457 | case DW_LNE_define_file: | |
143a3db0 | 458 | printf (_("define new File Table entry\n")); |
19e6b90e | 459 | printf (_(" Entry\tDir\tTime\tSize\tName\n")); |
cc5914eb | 460 | printf (" %d\t", ++state_machine_regs.last_file_entry); |
f6f0e17b | 461 | |
19e6b90e | 462 | name = data; |
0c588247 | 463 | data += strnlen ((char *) data, end - data) + 1; |
f6f0e17b | 464 | printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); |
19e6b90e | 465 | data += bytes_read; |
f6f0e17b | 466 | printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); |
19e6b90e | 467 | data += bytes_read; |
f6f0e17b | 468 | printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); |
143a3db0 | 469 | data += bytes_read; |
f6f0e17b NC |
470 | printf ("%s\n\n", name); |
471 | ||
472 | if (((unsigned int) (data - orig_data) != len) || data == end) | |
473 | warn (_("DW_LNE_define_file: Bad opcode length\n")); | |
19e6b90e L |
474 | break; |
475 | ||
ed4a4bdf | 476 | case DW_LNE_set_discriminator: |
47704ddf | 477 | printf (_("set Discriminator to %s\n"), |
f6f0e17b | 478 | dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); |
ed4a4bdf CC |
479 | break; |
480 | ||
e2a0d921 NC |
481 | /* HP extensions. */ |
482 | case DW_LNE_HP_negate_is_UV_update: | |
ed4a4bdf | 483 | printf ("DW_LNE_HP_negate_is_UV_update\n"); |
e2a0d921 NC |
484 | break; |
485 | case DW_LNE_HP_push_context: | |
ed4a4bdf | 486 | printf ("DW_LNE_HP_push_context\n"); |
e2a0d921 NC |
487 | break; |
488 | case DW_LNE_HP_pop_context: | |
ed4a4bdf | 489 | printf ("DW_LNE_HP_pop_context\n"); |
e2a0d921 NC |
490 | break; |
491 | case DW_LNE_HP_set_file_line_column: | |
ed4a4bdf | 492 | printf ("DW_LNE_HP_set_file_line_column\n"); |
e2a0d921 NC |
493 | break; |
494 | case DW_LNE_HP_set_routine_name: | |
ed4a4bdf | 495 | printf ("DW_LNE_HP_set_routine_name\n"); |
e2a0d921 NC |
496 | break; |
497 | case DW_LNE_HP_set_sequence: | |
ed4a4bdf | 498 | printf ("DW_LNE_HP_set_sequence\n"); |
e2a0d921 NC |
499 | break; |
500 | case DW_LNE_HP_negate_post_semantics: | |
ed4a4bdf | 501 | printf ("DW_LNE_HP_negate_post_semantics\n"); |
e2a0d921 NC |
502 | break; |
503 | case DW_LNE_HP_negate_function_exit: | |
ed4a4bdf | 504 | printf ("DW_LNE_HP_negate_function_exit\n"); |
e2a0d921 NC |
505 | break; |
506 | case DW_LNE_HP_negate_front_end_logical: | |
ed4a4bdf | 507 | printf ("DW_LNE_HP_negate_front_end_logical\n"); |
e2a0d921 NC |
508 | break; |
509 | case DW_LNE_HP_define_proc: | |
ed4a4bdf | 510 | printf ("DW_LNE_HP_define_proc\n"); |
e2a0d921 | 511 | break; |
43294ab7 TG |
512 | case DW_LNE_HP_source_file_correlation: |
513 | { | |
514 | unsigned char *edata = data + len - bytes_read - 1; | |
515 | ||
516 | printf ("DW_LNE_HP_source_file_correlation\n"); | |
517 | ||
518 | while (data < edata) | |
519 | { | |
520 | unsigned int opc; | |
521 | ||
f6f0e17b | 522 | opc = read_uleb128 (data, & bytes_read, edata); |
43294ab7 TG |
523 | data += bytes_read; |
524 | ||
525 | switch (opc) | |
526 | { | |
527 | case DW_LNE_HP_SFC_formfeed: | |
528 | printf (" DW_LNE_HP_SFC_formfeed\n"); | |
529 | break; | |
530 | case DW_LNE_HP_SFC_set_listing_line: | |
531 | printf (" DW_LNE_HP_SFC_set_listing_line (%s)\n", | |
532 | dwarf_vmatoa ("u", | |
f6f0e17b | 533 | read_uleb128 (data, & bytes_read, edata))); |
43294ab7 TG |
534 | data += bytes_read; |
535 | break; | |
536 | case DW_LNE_HP_SFC_associate: | |
537 | printf (" DW_LNE_HP_SFC_associate "); | |
9cf03b7e | 538 | printf ("(%s", |
43294ab7 | 539 | dwarf_vmatoa ("u", |
f6f0e17b | 540 | read_uleb128 (data, & bytes_read, edata))); |
43294ab7 | 541 | data += bytes_read; |
9cf03b7e | 542 | printf (",%s", |
43294ab7 | 543 | dwarf_vmatoa ("u", |
f6f0e17b | 544 | read_uleb128 (data, & bytes_read, edata))); |
43294ab7 | 545 | data += bytes_read; |
9cf03b7e | 546 | printf (",%s)\n", |
43294ab7 | 547 | dwarf_vmatoa ("u", |
f6f0e17b | 548 | read_uleb128 (data, & bytes_read, edata))); |
43294ab7 TG |
549 | data += bytes_read; |
550 | break; | |
551 | default: | |
9cf03b7e | 552 | printf (_(" UNKNOWN DW_LNE_HP_SFC opcode (%u)\n"), opc); |
43294ab7 TG |
553 | data = edata; |
554 | break; | |
555 | } | |
556 | } | |
557 | } | |
558 | break; | |
cecf136e | 559 | |
19e6b90e | 560 | default: |
7e665af3 TG |
561 | { |
562 | unsigned int rlen = len - bytes_read - 1; | |
563 | ||
564 | if (op_code >= DW_LNE_lo_user | |
565 | /* The test against DW_LNW_hi_user is redundant due to | |
566 | the limited range of the unsigned char data type used | |
567 | for op_code. */ | |
568 | /*&& op_code <= DW_LNE_hi_user*/) | |
569 | printf (_("user defined: ")); | |
570 | else | |
571 | printf (_("UNKNOWN: ")); | |
572 | printf (_("length %d ["), rlen); | |
573 | for (; rlen; rlen--) | |
574 | printf (" %02x", *data++); | |
575 | printf ("]\n"); | |
576 | } | |
19e6b90e L |
577 | break; |
578 | } | |
579 | ||
580 | return len; | |
581 | } | |
582 | ||
0c588247 | 583 | static const unsigned char * |
467c65bc | 584 | fetch_indirect_string (dwarf_vma offset) |
19e6b90e L |
585 | { |
586 | struct dwarf_section *section = &debug_displays [str].section; | |
587 | ||
588 | if (section->start == NULL) | |
0c588247 | 589 | return (const unsigned char *) _("<no .debug_str section>"); |
19e6b90e L |
590 | |
591 | if (offset > section->size) | |
592 | { | |
467c65bc NC |
593 | warn (_("DW_FORM_strp offset too big: %s\n"), |
594 | dwarf_vmatoa ("x", offset)); | |
0c588247 | 595 | return (const unsigned char *) _("<offset is too big>"); |
19e6b90e L |
596 | } |
597 | ||
0c588247 | 598 | return (const unsigned char *) section->start + offset; |
19e6b90e L |
599 | } |
600 | ||
4723351a | 601 | static const char * |
341f9135 CC |
602 | fetch_indexed_string (dwarf_vma idx, struct cu_tu_set *this_set, |
603 | dwarf_vma offset_size, int dwo) | |
4723351a CC |
604 | { |
605 | enum dwarf_section_display_enum str_sec_idx = dwo ? str_dwo : str; | |
606 | enum dwarf_section_display_enum idx_sec_idx = dwo ? str_index_dwo : str_index; | |
607 | struct dwarf_section *index_section = &debug_displays [idx_sec_idx].section; | |
608 | struct dwarf_section *str_section = &debug_displays [str_sec_idx].section; | |
609 | dwarf_vma index_offset = idx * offset_size; | |
610 | dwarf_vma str_offset; | |
611 | ||
612 | if (index_section->start == NULL) | |
613 | return (dwo ? _("<no .debug_str_offsets.dwo section>") | |
614 | : _("<no .debug_str_offsets section>")); | |
615 | ||
341f9135 CC |
616 | if (this_set != NULL) |
617 | index_offset += this_set->section_offsets [DW_SECT_STR_OFFSETS]; | |
4723351a CC |
618 | if (index_offset > index_section->size) |
619 | { | |
620 | warn (_("DW_FORM_GNU_str_index offset too big: %s\n"), | |
621 | dwarf_vmatoa ("x", index_offset)); | |
622 | return _("<index offset is too big>"); | |
623 | } | |
624 | ||
625 | if (str_section->start == NULL) | |
626 | return (dwo ? _("<no .debug_str.dwo section>") | |
627 | : _("<no .debug_str section>")); | |
628 | ||
629 | str_offset = byte_get (index_section->start + index_offset, offset_size); | |
630 | str_offset -= str_section->address; | |
631 | if (str_offset > str_section->size) | |
632 | { | |
633 | warn (_("DW_FORM_GNU_str_index indirect offset too big: %s\n"), | |
634 | dwarf_vmatoa ("x", str_offset)); | |
635 | return _("<indirect index offset is too big>"); | |
636 | } | |
637 | ||
638 | return (const char *) str_section->start + str_offset; | |
639 | } | |
640 | ||
641 | static const char * | |
642 | fetch_indexed_value (dwarf_vma offset, dwarf_vma bytes) | |
643 | { | |
644 | struct dwarf_section *section = &debug_displays [debug_addr].section; | |
645 | ||
646 | if (section->start == NULL) | |
647 | return (_("<no .debug_addr section>")); | |
648 | ||
649 | if (offset + bytes > section->size) | |
650 | { | |
651 | warn (_("Offset into section %s too big: %s\n"), | |
652 | section->name, dwarf_vmatoa ("x", offset)); | |
653 | return "<offset too big>"; | |
654 | } | |
655 | ||
656 | return dwarf_vmatoa ("x", byte_get (section->start + offset, bytes)); | |
657 | } | |
658 | ||
659 | ||
19e6b90e L |
660 | /* FIXME: There are better and more efficient ways to handle |
661 | these structures. For now though, I just want something that | |
662 | is simple to implement. */ | |
663 | typedef struct abbrev_attr | |
664 | { | |
665 | unsigned long attribute; | |
666 | unsigned long form; | |
667 | struct abbrev_attr *next; | |
668 | } | |
669 | abbrev_attr; | |
670 | ||
671 | typedef struct abbrev_entry | |
672 | { | |
673 | unsigned long entry; | |
674 | unsigned long tag; | |
675 | int children; | |
676 | struct abbrev_attr *first_attr; | |
677 | struct abbrev_attr *last_attr; | |
678 | struct abbrev_entry *next; | |
679 | } | |
680 | abbrev_entry; | |
681 | ||
682 | static abbrev_entry *first_abbrev = NULL; | |
683 | static abbrev_entry *last_abbrev = NULL; | |
684 | ||
685 | static void | |
686 | free_abbrevs (void) | |
687 | { | |
91d6fa6a | 688 | abbrev_entry *abbrv; |
19e6b90e | 689 | |
91d6fa6a | 690 | for (abbrv = first_abbrev; abbrv;) |
19e6b90e | 691 | { |
91d6fa6a | 692 | abbrev_entry *next_abbrev = abbrv->next; |
19e6b90e L |
693 | abbrev_attr *attr; |
694 | ||
91d6fa6a | 695 | for (attr = abbrv->first_attr; attr;) |
19e6b90e | 696 | { |
91d6fa6a | 697 | abbrev_attr *next_attr = attr->next; |
19e6b90e L |
698 | |
699 | free (attr); | |
91d6fa6a | 700 | attr = next_attr; |
19e6b90e L |
701 | } |
702 | ||
91d6fa6a NC |
703 | free (abbrv); |
704 | abbrv = next_abbrev; | |
19e6b90e L |
705 | } |
706 | ||
707 | last_abbrev = first_abbrev = NULL; | |
708 | } | |
709 | ||
710 | static void | |
711 | add_abbrev (unsigned long number, unsigned long tag, int children) | |
712 | { | |
713 | abbrev_entry *entry; | |
714 | ||
3f5e193b | 715 | entry = (abbrev_entry *) malloc (sizeof (*entry)); |
19e6b90e L |
716 | if (entry == NULL) |
717 | /* ugg */ | |
718 | return; | |
719 | ||
720 | entry->entry = number; | |
721 | entry->tag = tag; | |
722 | entry->children = children; | |
723 | entry->first_attr = NULL; | |
724 | entry->last_attr = NULL; | |
725 | entry->next = NULL; | |
726 | ||
727 | if (first_abbrev == NULL) | |
728 | first_abbrev = entry; | |
729 | else | |
730 | last_abbrev->next = entry; | |
731 | ||
732 | last_abbrev = entry; | |
733 | } | |
734 | ||
735 | static void | |
736 | add_abbrev_attr (unsigned long attribute, unsigned long form) | |
737 | { | |
738 | abbrev_attr *attr; | |
739 | ||
3f5e193b | 740 | attr = (abbrev_attr *) malloc (sizeof (*attr)); |
19e6b90e L |
741 | if (attr == NULL) |
742 | /* ugg */ | |
743 | return; | |
744 | ||
745 | attr->attribute = attribute; | |
746 | attr->form = form; | |
747 | attr->next = NULL; | |
748 | ||
749 | if (last_abbrev->first_attr == NULL) | |
750 | last_abbrev->first_attr = attr; | |
751 | else | |
752 | last_abbrev->last_attr->next = attr; | |
753 | ||
754 | last_abbrev->last_attr = attr; | |
755 | } | |
756 | ||
757 | /* Processes the (partial) contents of a .debug_abbrev section. | |
758 | Returns NULL if the end of the section was encountered. | |
759 | Returns the address after the last byte read if the end of | |
760 | an abbreviation set was found. */ | |
761 | ||
762 | static unsigned char * | |
763 | process_abbrev_section (unsigned char *start, unsigned char *end) | |
764 | { | |
765 | if (first_abbrev != NULL) | |
766 | return NULL; | |
767 | ||
768 | while (start < end) | |
769 | { | |
770 | unsigned int bytes_read; | |
771 | unsigned long entry; | |
772 | unsigned long tag; | |
773 | unsigned long attribute; | |
774 | int children; | |
775 | ||
f6f0e17b | 776 | entry = read_uleb128 (start, & bytes_read, end); |
19e6b90e L |
777 | start += bytes_read; |
778 | ||
779 | /* A single zero is supposed to end the section according | |
780 | to the standard. If there's more, then signal that to | |
781 | the caller. */ | |
f6f0e17b NC |
782 | if (start == end) |
783 | return NULL; | |
19e6b90e | 784 | if (entry == 0) |
f6f0e17b | 785 | return start; |
19e6b90e | 786 | |
f6f0e17b | 787 | tag = read_uleb128 (start, & bytes_read, end); |
19e6b90e | 788 | start += bytes_read; |
f6f0e17b NC |
789 | if (start == end) |
790 | return NULL; | |
19e6b90e L |
791 | |
792 | children = *start++; | |
793 | ||
794 | add_abbrev (entry, tag, children); | |
795 | ||
796 | do | |
797 | { | |
798 | unsigned long form; | |
799 | ||
f6f0e17b | 800 | attribute = read_uleb128 (start, & bytes_read, end); |
19e6b90e | 801 | start += bytes_read; |
f6f0e17b NC |
802 | if (start == end) |
803 | break; | |
19e6b90e | 804 | |
f6f0e17b | 805 | form = read_uleb128 (start, & bytes_read, end); |
19e6b90e | 806 | start += bytes_read; |
f6f0e17b NC |
807 | if (start == end) |
808 | break; | |
19e6b90e | 809 | |
399c99f7 | 810 | add_abbrev_attr (attribute, form); |
19e6b90e L |
811 | } |
812 | while (attribute != 0); | |
813 | } | |
814 | ||
399c99f7 L |
815 | /* Report the missing single zero which ends the section. */ |
816 | error (_(".debug_abbrev section not zero terminated\n")); | |
817 | ||
19e6b90e L |
818 | return NULL; |
819 | } | |
820 | ||
a19c41a7 | 821 | static const char * |
19e6b90e L |
822 | get_TAG_name (unsigned long tag) |
823 | { | |
b9c361e0 | 824 | const char *name = get_DW_TAG_name ((unsigned int)tag); |
a19c41a7 TT |
825 | |
826 | if (name == NULL) | |
19e6b90e | 827 | { |
a19c41a7 | 828 | static char buffer[100]; |
19e6b90e | 829 | |
a19c41a7 TT |
830 | snprintf (buffer, sizeof (buffer), _("Unknown TAG value: %lx"), tag); |
831 | return buffer; | |
19e6b90e | 832 | } |
a19c41a7 TT |
833 | |
834 | return name; | |
19e6b90e L |
835 | } |
836 | ||
a19c41a7 | 837 | static const char * |
19e6b90e L |
838 | get_FORM_name (unsigned long form) |
839 | { | |
399c99f7 | 840 | const char *name; |
bf5117e3 | 841 | |
399c99f7 L |
842 | if (form == 0) |
843 | return "DW_FORM value: 0"; | |
a19c41a7 | 844 | |
399c99f7 | 845 | name = get_DW_FORM_name (form); |
a19c41a7 | 846 | if (name == NULL) |
19e6b90e | 847 | { |
a19c41a7 | 848 | static char buffer[100]; |
19e6b90e | 849 | |
a19c41a7 TT |
850 | snprintf (buffer, sizeof (buffer), _("Unknown FORM value: %lx"), form); |
851 | return buffer; | |
19e6b90e | 852 | } |
a19c41a7 TT |
853 | |
854 | return name; | |
19e6b90e L |
855 | } |
856 | ||
857 | static unsigned char * | |
0c588247 NC |
858 | display_block (unsigned char *data, |
859 | dwarf_vma length, | |
860 | const unsigned char * const end) | |
19e6b90e | 861 | { |
0c588247 NC |
862 | dwarf_vma maxlen; |
863 | ||
467c65bc | 864 | printf (_(" %s byte block: "), dwarf_vmatoa ("u", length)); |
a1165289 NC |
865 | if (data > end) |
866 | return (unsigned char *) end; | |
19e6b90e | 867 | |
0c588247 NC |
868 | maxlen = (dwarf_vma) (end - data); |
869 | length = length > maxlen ? maxlen : length; | |
870 | ||
19e6b90e L |
871 | while (length --) |
872 | printf ("%lx ", (unsigned long) byte_get (data++, 1)); | |
873 | ||
874 | return data; | |
875 | } | |
876 | ||
877 | static int | |
878 | decode_location_expression (unsigned char * data, | |
879 | unsigned int pointer_size, | |
b7807392 JJ |
880 | unsigned int offset_size, |
881 | int dwarf_version, | |
467c65bc NC |
882 | dwarf_vma length, |
883 | dwarf_vma cu_offset, | |
f1c4cc75 | 884 | struct dwarf_section * section) |
19e6b90e L |
885 | { |
886 | unsigned op; | |
887 | unsigned int bytes_read; | |
467c65bc | 888 | dwarf_vma uvalue; |
0c588247 | 889 | dwarf_signed_vma svalue; |
19e6b90e L |
890 | unsigned char *end = data + length; |
891 | int need_frame_base = 0; | |
892 | ||
893 | while (data < end) | |
894 | { | |
895 | op = *data++; | |
896 | ||
897 | switch (op) | |
898 | { | |
899 | case DW_OP_addr: | |
0c588247 NC |
900 | SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); |
901 | printf ("DW_OP_addr: %s", dwarf_vmatoa ("x", uvalue)); | |
19e6b90e L |
902 | break; |
903 | case DW_OP_deref: | |
904 | printf ("DW_OP_deref"); | |
905 | break; | |
906 | case DW_OP_const1u: | |
0c588247 NC |
907 | SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
908 | printf ("DW_OP_const1u: %lu", (unsigned long) uvalue); | |
19e6b90e L |
909 | break; |
910 | case DW_OP_const1s: | |
0c588247 NC |
911 | SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 1, end); |
912 | printf ("DW_OP_const1s: %ld", (long) svalue); | |
19e6b90e L |
913 | break; |
914 | case DW_OP_const2u: | |
87bc83b3 | 915 | SAFE_BYTE_GET_AND_INC (uvalue, data, 2, end); |
0c588247 | 916 | printf ("DW_OP_const2u: %lu", (unsigned long) uvalue); |
19e6b90e L |
917 | break; |
918 | case DW_OP_const2s: | |
0c588247 NC |
919 | SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); |
920 | printf ("DW_OP_const2s: %ld", (long) svalue); | |
19e6b90e L |
921 | break; |
922 | case DW_OP_const4u: | |
0c588247 NC |
923 | SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); |
924 | printf ("DW_OP_const4u: %lu", (unsigned long) uvalue); | |
19e6b90e L |
925 | break; |
926 | case DW_OP_const4s: | |
0c588247 NC |
927 | SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); |
928 | printf ("DW_OP_const4s: %ld", (long) svalue); | |
19e6b90e L |
929 | break; |
930 | case DW_OP_const8u: | |
0c588247 NC |
931 | SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); |
932 | printf ("DW_OP_const8u: %lu ", (unsigned long) uvalue); | |
933 | SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); | |
934 | printf ("%lu", (unsigned long) uvalue); | |
19e6b90e L |
935 | break; |
936 | case DW_OP_const8s: | |
0c588247 NC |
937 | SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); |
938 | printf ("DW_OP_const8s: %ld ", (long) svalue); | |
939 | SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); | |
940 | printf ("%ld", (long) svalue); | |
19e6b90e L |
941 | break; |
942 | case DW_OP_constu: | |
467c65bc | 943 | printf ("DW_OP_constu: %s", |
f6f0e17b | 944 | dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); |
19e6b90e L |
945 | data += bytes_read; |
946 | break; | |
947 | case DW_OP_consts: | |
467c65bc | 948 | printf ("DW_OP_consts: %s", |
f6f0e17b | 949 | dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end))); |
19e6b90e L |
950 | data += bytes_read; |
951 | break; | |
952 | case DW_OP_dup: | |
953 | printf ("DW_OP_dup"); | |
954 | break; | |
955 | case DW_OP_drop: | |
956 | printf ("DW_OP_drop"); | |
957 | break; | |
958 | case DW_OP_over: | |
959 | printf ("DW_OP_over"); | |
960 | break; | |
961 | case DW_OP_pick: | |
0c588247 NC |
962 | SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
963 | printf ("DW_OP_pick: %ld", (unsigned long) uvalue); | |
19e6b90e L |
964 | break; |
965 | case DW_OP_swap: | |
966 | printf ("DW_OP_swap"); | |
967 | break; | |
968 | case DW_OP_rot: | |
969 | printf ("DW_OP_rot"); | |
970 | break; | |
971 | case DW_OP_xderef: | |
972 | printf ("DW_OP_xderef"); | |
973 | break; | |
974 | case DW_OP_abs: | |
975 | printf ("DW_OP_abs"); | |
976 | break; | |
977 | case DW_OP_and: | |
978 | printf ("DW_OP_and"); | |
979 | break; | |
980 | case DW_OP_div: | |
981 | printf ("DW_OP_div"); | |
982 | break; | |
983 | case DW_OP_minus: | |
984 | printf ("DW_OP_minus"); | |
985 | break; | |
986 | case DW_OP_mod: | |
987 | printf ("DW_OP_mod"); | |
988 | break; | |
989 | case DW_OP_mul: | |
990 | printf ("DW_OP_mul"); | |
991 | break; | |
992 | case DW_OP_neg: | |
993 | printf ("DW_OP_neg"); | |
994 | break; | |
995 | case DW_OP_not: | |
996 | printf ("DW_OP_not"); | |
997 | break; | |
998 | case DW_OP_or: | |
999 | printf ("DW_OP_or"); | |
1000 | break; | |
1001 | case DW_OP_plus: | |
1002 | printf ("DW_OP_plus"); | |
1003 | break; | |
1004 | case DW_OP_plus_uconst: | |
467c65bc | 1005 | printf ("DW_OP_plus_uconst: %s", |
f6f0e17b | 1006 | dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); |
19e6b90e L |
1007 | data += bytes_read; |
1008 | break; | |
1009 | case DW_OP_shl: | |
1010 | printf ("DW_OP_shl"); | |
1011 | break; | |
1012 | case DW_OP_shr: | |
1013 | printf ("DW_OP_shr"); | |
1014 | break; | |
1015 | case DW_OP_shra: | |
1016 | printf ("DW_OP_shra"); | |
1017 | break; | |
1018 | case DW_OP_xor: | |
1019 | printf ("DW_OP_xor"); | |
1020 | break; | |
1021 | case DW_OP_bra: | |
0c588247 NC |
1022 | SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); |
1023 | printf ("DW_OP_bra: %ld", (long) svalue); | |
19e6b90e L |
1024 | break; |
1025 | case DW_OP_eq: | |
1026 | printf ("DW_OP_eq"); | |
1027 | break; | |
1028 | case DW_OP_ge: | |
1029 | printf ("DW_OP_ge"); | |
1030 | break; | |
1031 | case DW_OP_gt: | |
1032 | printf ("DW_OP_gt"); | |
1033 | break; | |
1034 | case DW_OP_le: | |
1035 | printf ("DW_OP_le"); | |
1036 | break; | |
1037 | case DW_OP_lt: | |
1038 | printf ("DW_OP_lt"); | |
1039 | break; | |
1040 | case DW_OP_ne: | |
1041 | printf ("DW_OP_ne"); | |
1042 | break; | |
1043 | case DW_OP_skip: | |
0c588247 NC |
1044 | SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); |
1045 | printf ("DW_OP_skip: %ld", (long) svalue); | |
19e6b90e L |
1046 | break; |
1047 | ||
1048 | case DW_OP_lit0: | |
1049 | case DW_OP_lit1: | |
1050 | case DW_OP_lit2: | |
1051 | case DW_OP_lit3: | |
1052 | case DW_OP_lit4: | |
1053 | case DW_OP_lit5: | |
1054 | case DW_OP_lit6: | |
1055 | case DW_OP_lit7: | |
1056 | case DW_OP_lit8: | |
1057 | case DW_OP_lit9: | |
1058 | case DW_OP_lit10: | |
1059 | case DW_OP_lit11: | |
1060 | case DW_OP_lit12: | |
1061 | case DW_OP_lit13: | |
1062 | case DW_OP_lit14: | |
1063 | case DW_OP_lit15: | |
1064 | case DW_OP_lit16: | |
1065 | case DW_OP_lit17: | |
1066 | case DW_OP_lit18: | |
1067 | case DW_OP_lit19: | |
1068 | case DW_OP_lit20: | |
1069 | case DW_OP_lit21: | |
1070 | case DW_OP_lit22: | |
1071 | case DW_OP_lit23: | |
1072 | case DW_OP_lit24: | |
1073 | case DW_OP_lit25: | |
1074 | case DW_OP_lit26: | |
1075 | case DW_OP_lit27: | |
1076 | case DW_OP_lit28: | |
1077 | case DW_OP_lit29: | |
1078 | case DW_OP_lit30: | |
1079 | case DW_OP_lit31: | |
1080 | printf ("DW_OP_lit%d", op - DW_OP_lit0); | |
1081 | break; | |
1082 | ||
1083 | case DW_OP_reg0: | |
1084 | case DW_OP_reg1: | |
1085 | case DW_OP_reg2: | |
1086 | case DW_OP_reg3: | |
1087 | case DW_OP_reg4: | |
1088 | case DW_OP_reg5: | |
1089 | case DW_OP_reg6: | |
1090 | case DW_OP_reg7: | |
1091 | case DW_OP_reg8: | |
1092 | case DW_OP_reg9: | |
1093 | case DW_OP_reg10: | |
1094 | case DW_OP_reg11: | |
1095 | case DW_OP_reg12: | |
1096 | case DW_OP_reg13: | |
1097 | case DW_OP_reg14: | |
1098 | case DW_OP_reg15: | |
1099 | case DW_OP_reg16: | |
1100 | case DW_OP_reg17: | |
1101 | case DW_OP_reg18: | |
1102 | case DW_OP_reg19: | |
1103 | case DW_OP_reg20: | |
1104 | case DW_OP_reg21: | |
1105 | case DW_OP_reg22: | |
1106 | case DW_OP_reg23: | |
1107 | case DW_OP_reg24: | |
1108 | case DW_OP_reg25: | |
1109 | case DW_OP_reg26: | |
1110 | case DW_OP_reg27: | |
1111 | case DW_OP_reg28: | |
1112 | case DW_OP_reg29: | |
1113 | case DW_OP_reg30: | |
1114 | case DW_OP_reg31: | |
18464d4d JK |
1115 | printf ("DW_OP_reg%d (%s)", op - DW_OP_reg0, |
1116 | regname (op - DW_OP_reg0, 1)); | |
19e6b90e L |
1117 | break; |
1118 | ||
1119 | case DW_OP_breg0: | |
1120 | case DW_OP_breg1: | |
1121 | case DW_OP_breg2: | |
1122 | case DW_OP_breg3: | |
1123 | case DW_OP_breg4: | |
1124 | case DW_OP_breg5: | |
1125 | case DW_OP_breg6: | |
1126 | case DW_OP_breg7: | |
1127 | case DW_OP_breg8: | |
1128 | case DW_OP_breg9: | |
1129 | case DW_OP_breg10: | |
1130 | case DW_OP_breg11: | |
1131 | case DW_OP_breg12: | |
1132 | case DW_OP_breg13: | |
1133 | case DW_OP_breg14: | |
1134 | case DW_OP_breg15: | |
1135 | case DW_OP_breg16: | |
1136 | case DW_OP_breg17: | |
1137 | case DW_OP_breg18: | |
1138 | case DW_OP_breg19: | |
1139 | case DW_OP_breg20: | |
1140 | case DW_OP_breg21: | |
1141 | case DW_OP_breg22: | |
1142 | case DW_OP_breg23: | |
1143 | case DW_OP_breg24: | |
1144 | case DW_OP_breg25: | |
1145 | case DW_OP_breg26: | |
1146 | case DW_OP_breg27: | |
1147 | case DW_OP_breg28: | |
1148 | case DW_OP_breg29: | |
1149 | case DW_OP_breg30: | |
1150 | case DW_OP_breg31: | |
467c65bc | 1151 | printf ("DW_OP_breg%d (%s): %s", |
47704ddf | 1152 | op - DW_OP_breg0, |
18464d4d | 1153 | regname (op - DW_OP_breg0, 1), |
f6f0e17b | 1154 | dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end))); |
19e6b90e L |
1155 | data += bytes_read; |
1156 | break; | |
1157 | ||
1158 | case DW_OP_regx: | |
f6f0e17b | 1159 | uvalue = read_uleb128 (data, &bytes_read, end); |
19e6b90e | 1160 | data += bytes_read; |
467c65bc NC |
1161 | printf ("DW_OP_regx: %s (%s)", |
1162 | dwarf_vmatoa ("u", uvalue), regname (uvalue, 1)); | |
19e6b90e L |
1163 | break; |
1164 | case DW_OP_fbreg: | |
1165 | need_frame_base = 1; | |
467c65bc | 1166 | printf ("DW_OP_fbreg: %s", |
f6f0e17b | 1167 | dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end))); |
19e6b90e L |
1168 | data += bytes_read; |
1169 | break; | |
1170 | case DW_OP_bregx: | |
f6f0e17b | 1171 | uvalue = read_uleb128 (data, &bytes_read, end); |
19e6b90e | 1172 | data += bytes_read; |
467c65bc NC |
1173 | printf ("DW_OP_bregx: %s (%s) %s", |
1174 | dwarf_vmatoa ("u", uvalue), regname (uvalue, 1), | |
f6f0e17b | 1175 | dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end))); |
19e6b90e L |
1176 | data += bytes_read; |
1177 | break; | |
1178 | case DW_OP_piece: | |
467c65bc | 1179 | printf ("DW_OP_piece: %s", |
f6f0e17b | 1180 | dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); |
19e6b90e L |
1181 | data += bytes_read; |
1182 | break; | |
1183 | case DW_OP_deref_size: | |
0c588247 NC |
1184 | SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
1185 | printf ("DW_OP_deref_size: %ld", (long) uvalue); | |
19e6b90e L |
1186 | break; |
1187 | case DW_OP_xderef_size: | |
0c588247 NC |
1188 | SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
1189 | printf ("DW_OP_xderef_size: %ld", (long) uvalue); | |
19e6b90e L |
1190 | break; |
1191 | case DW_OP_nop: | |
1192 | printf ("DW_OP_nop"); | |
1193 | break; | |
1194 | ||
1195 | /* DWARF 3 extensions. */ | |
1196 | case DW_OP_push_object_address: | |
1197 | printf ("DW_OP_push_object_address"); | |
1198 | break; | |
1199 | case DW_OP_call2: | |
1200 | /* XXX: Strictly speaking for 64-bit DWARF3 files | |
1201 | this ought to be an 8-byte wide computation. */ | |
0c588247 | 1202 | SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); |
467c65bc | 1203 | printf ("DW_OP_call2: <0x%s>", |
0c588247 | 1204 | dwarf_vmatoa ("x", svalue + cu_offset)); |
19e6b90e L |
1205 | break; |
1206 | case DW_OP_call4: | |
1207 | /* XXX: Strictly speaking for 64-bit DWARF3 files | |
1208 | this ought to be an 8-byte wide computation. */ | |
0c588247 | 1209 | SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); |
467c65bc | 1210 | printf ("DW_OP_call4: <0x%s>", |
0c588247 | 1211 | dwarf_vmatoa ("x", svalue + cu_offset)); |
19e6b90e L |
1212 | break; |
1213 | case DW_OP_call_ref: | |
e2a0d921 NC |
1214 | /* XXX: Strictly speaking for 64-bit DWARF3 files |
1215 | this ought to be an 8-byte wide computation. */ | |
b7807392 JJ |
1216 | if (dwarf_version == -1) |
1217 | { | |
1218 | printf (_("(DW_OP_call_ref in frame info)")); | |
1219 | /* No way to tell where the next op is, so just bail. */ | |
1220 | return need_frame_base; | |
1221 | } | |
1222 | if (dwarf_version == 2) | |
1223 | { | |
0c588247 | 1224 | SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); |
b7807392 JJ |
1225 | } |
1226 | else | |
1227 | { | |
0c588247 | 1228 | SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); |
b7807392 | 1229 | } |
0c588247 | 1230 | printf ("DW_OP_call_ref: <0x%s>", dwarf_vmatoa ("x", uvalue)); |
19e6b90e | 1231 | break; |
a87b0a59 NS |
1232 | case DW_OP_form_tls_address: |
1233 | printf ("DW_OP_form_tls_address"); | |
1234 | break; | |
e2a0d921 NC |
1235 | case DW_OP_call_frame_cfa: |
1236 | printf ("DW_OP_call_frame_cfa"); | |
1237 | break; | |
1238 | case DW_OP_bit_piece: | |
1239 | printf ("DW_OP_bit_piece: "); | |
9cf03b7e | 1240 | printf (_("size: %s "), |
f6f0e17b | 1241 | dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); |
e2a0d921 | 1242 | data += bytes_read; |
9cf03b7e | 1243 | printf (_("offset: %s "), |
f6f0e17b | 1244 | dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); |
e2a0d921 NC |
1245 | data += bytes_read; |
1246 | break; | |
19e6b90e | 1247 | |
3244e8f5 JJ |
1248 | /* DWARF 4 extensions. */ |
1249 | case DW_OP_stack_value: | |
1250 | printf ("DW_OP_stack_value"); | |
1251 | break; | |
1252 | ||
1253 | case DW_OP_implicit_value: | |
1254 | printf ("DW_OP_implicit_value"); | |
f6f0e17b | 1255 | uvalue = read_uleb128 (data, &bytes_read, end); |
3244e8f5 | 1256 | data += bytes_read; |
6937bb54 | 1257 | data = display_block (data, uvalue, end); |
3244e8f5 JJ |
1258 | break; |
1259 | ||
19e6b90e L |
1260 | /* GNU extensions. */ |
1261 | case DW_OP_GNU_push_tls_address: | |
9cf03b7e | 1262 | printf (_("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown")); |
e2a0d921 NC |
1263 | break; |
1264 | case DW_OP_GNU_uninit: | |
1265 | printf ("DW_OP_GNU_uninit"); | |
1266 | /* FIXME: Is there data associated with this OP ? */ | |
1267 | break; | |
f1c4cc75 RH |
1268 | case DW_OP_GNU_encoded_addr: |
1269 | { | |
6937bb54 | 1270 | int encoding = 0; |
f1c4cc75 | 1271 | dwarf_vma addr; |
467c65bc | 1272 | |
6937bb54 NC |
1273 | if (data < end) |
1274 | encoding = *data++; | |
041830e0 | 1275 | addr = get_encoded_value (&data, encoding, section, end); |
f1c4cc75 RH |
1276 | |
1277 | printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding); | |
1278 | print_dwarf_vma (addr, pointer_size); | |
1279 | } | |
1280 | break; | |
b7807392 JJ |
1281 | case DW_OP_GNU_implicit_pointer: |
1282 | /* XXX: Strictly speaking for 64-bit DWARF3 files | |
1283 | this ought to be an 8-byte wide computation. */ | |
1284 | if (dwarf_version == -1) | |
1285 | { | |
1286 | printf (_("(DW_OP_GNU_implicit_pointer in frame info)")); | |
1287 | /* No way to tell where the next op is, so just bail. */ | |
1288 | return need_frame_base; | |
1289 | } | |
1290 | if (dwarf_version == 2) | |
1291 | { | |
0c588247 | 1292 | SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); |
b7807392 JJ |
1293 | } |
1294 | else | |
1295 | { | |
0c588247 | 1296 | SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); |
b7807392 | 1297 | } |
0c588247 NC |
1298 | printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s", |
1299 | dwarf_vmatoa ("x", uvalue), | |
1300 | dwarf_vmatoa ("d", read_sleb128 (data, | |
1301 | &bytes_read, end))); | |
1302 | data += bytes_read; | |
b7807392 | 1303 | break; |
0892011d | 1304 | case DW_OP_GNU_entry_value: |
f6f0e17b | 1305 | uvalue = read_uleb128 (data, &bytes_read, end); |
0892011d | 1306 | data += bytes_read; |
058037d3 NC |
1307 | /* PR 17531: file: 0cc9cd00. */ |
1308 | if (uvalue > (dwarf_vma) (end - data)) | |
1309 | uvalue = end - data; | |
0892011d JJ |
1310 | printf ("DW_OP_GNU_entry_value: ("); |
1311 | if (decode_location_expression (data, pointer_size, offset_size, | |
1312 | dwarf_version, uvalue, | |
1313 | cu_offset, section)) | |
1314 | need_frame_base = 1; | |
1315 | putchar (')'); | |
1316 | data += uvalue; | |
6937bb54 NC |
1317 | if (data > end) |
1318 | data = end; | |
0892011d JJ |
1319 | break; |
1320 | case DW_OP_GNU_const_type: | |
f6f0e17b | 1321 | uvalue = read_uleb128 (data, &bytes_read, end); |
0892011d JJ |
1322 | data += bytes_read; |
1323 | printf ("DW_OP_GNU_const_type: <0x%s> ", | |
1324 | dwarf_vmatoa ("x", cu_offset + uvalue)); | |
0c588247 | 1325 | SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
6937bb54 | 1326 | data = display_block (data, uvalue, end); |
0892011d JJ |
1327 | break; |
1328 | case DW_OP_GNU_regval_type: | |
f6f0e17b | 1329 | uvalue = read_uleb128 (data, &bytes_read, end); |
0892011d JJ |
1330 | data += bytes_read; |
1331 | printf ("DW_OP_GNU_regval_type: %s (%s)", | |
1332 | dwarf_vmatoa ("u", uvalue), regname (uvalue, 1)); | |
f6f0e17b | 1333 | uvalue = read_uleb128 (data, &bytes_read, end); |
0892011d JJ |
1334 | data += bytes_read; |
1335 | printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue)); | |
1336 | break; | |
1337 | case DW_OP_GNU_deref_type: | |
0c588247 NC |
1338 | SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
1339 | printf ("DW_OP_GNU_deref_type: %ld", (long) uvalue); | |
f6f0e17b | 1340 | uvalue = read_uleb128 (data, &bytes_read, end); |
0892011d JJ |
1341 | data += bytes_read; |
1342 | printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue)); | |
1343 | break; | |
1344 | case DW_OP_GNU_convert: | |
f6f0e17b | 1345 | uvalue = read_uleb128 (data, &bytes_read, end); |
0892011d JJ |
1346 | data += bytes_read; |
1347 | printf ("DW_OP_GNU_convert <0x%s>", | |
f8b999f9 | 1348 | dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0)); |
0892011d JJ |
1349 | break; |
1350 | case DW_OP_GNU_reinterpret: | |
f6f0e17b | 1351 | uvalue = read_uleb128 (data, &bytes_read, end); |
0892011d JJ |
1352 | data += bytes_read; |
1353 | printf ("DW_OP_GNU_reinterpret <0x%s>", | |
f8b999f9 JJ |
1354 | dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0)); |
1355 | break; | |
1356 | case DW_OP_GNU_parameter_ref: | |
0c588247 | 1357 | SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); |
f8b999f9 | 1358 | printf ("DW_OP_GNU_parameter_ref: <0x%s>", |
0c588247 | 1359 | dwarf_vmatoa ("x", cu_offset + uvalue)); |
0892011d | 1360 | break; |
4723351a | 1361 | case DW_OP_GNU_addr_index: |
f6f0e17b | 1362 | uvalue = read_uleb128 (data, &bytes_read, end); |
4723351a CC |
1363 | data += bytes_read; |
1364 | printf ("DW_OP_GNU_addr_index <0x%s>", dwarf_vmatoa ("x", uvalue)); | |
1365 | break; | |
aae628c1 | 1366 | case DW_OP_GNU_const_index: |
f6f0e17b | 1367 | uvalue = read_uleb128 (data, &bytes_read, end); |
aae628c1 CC |
1368 | data += bytes_read; |
1369 | printf ("DW_OP_GNU_const_index <0x%s>", dwarf_vmatoa ("x", uvalue)); | |
1370 | break; | |
e2a0d921 NC |
1371 | |
1372 | /* HP extensions. */ | |
1373 | case DW_OP_HP_is_value: | |
1374 | printf ("DW_OP_HP_is_value"); | |
1375 | /* FIXME: Is there data associated with this OP ? */ | |
1376 | break; | |
1377 | case DW_OP_HP_fltconst4: | |
1378 | printf ("DW_OP_HP_fltconst4"); | |
1379 | /* FIXME: Is there data associated with this OP ? */ | |
1380 | break; | |
1381 | case DW_OP_HP_fltconst8: | |
1382 | printf ("DW_OP_HP_fltconst8"); | |
1383 | /* FIXME: Is there data associated with this OP ? */ | |
1384 | break; | |
1385 | case DW_OP_HP_mod_range: | |
1386 | printf ("DW_OP_HP_mod_range"); | |
1387 | /* FIXME: Is there data associated with this OP ? */ | |
1388 | break; | |
1389 | case DW_OP_HP_unmod_range: | |
1390 | printf ("DW_OP_HP_unmod_range"); | |
1391 | /* FIXME: Is there data associated with this OP ? */ | |
1392 | break; | |
1393 | case DW_OP_HP_tls: | |
1394 | printf ("DW_OP_HP_tls"); | |
1395 | /* FIXME: Is there data associated with this OP ? */ | |
19e6b90e L |
1396 | break; |
1397 | ||
35d60fe4 NC |
1398 | /* PGI (STMicroelectronics) extensions. */ |
1399 | case DW_OP_PGI_omp_thread_num: | |
1400 | /* Pushes the thread number for the current thread as it would be | |
1401 | returned by the standard OpenMP library function: | |
1402 | omp_get_thread_num(). The "current thread" is the thread for | |
1403 | which the expression is being evaluated. */ | |
1404 | printf ("DW_OP_PGI_omp_thread_num"); | |
1405 | break; | |
1406 | ||
19e6b90e L |
1407 | default: |
1408 | if (op >= DW_OP_lo_user | |
1409 | && op <= DW_OP_hi_user) | |
1410 | printf (_("(User defined location op)")); | |
1411 | else | |
1412 | printf (_("(Unknown location op)")); | |
1413 | /* No way to tell where the next op is, so just bail. */ | |
1414 | return need_frame_base; | |
1415 | } | |
1416 | ||
1417 | /* Separate the ops. */ | |
1418 | if (data < end) | |
1419 | printf ("; "); | |
1420 | } | |
1421 | ||
1422 | return need_frame_base; | |
1423 | } | |
1424 | ||
341f9135 CC |
1425 | /* Find the CU or TU set corresponding to the given CU_OFFSET. |
1426 | This is used for DWARF package files. */ | |
1427 | ||
1428 | static struct cu_tu_set * | |
1429 | find_cu_tu_set_v2 (dwarf_vma cu_offset, int do_types) | |
1430 | { | |
1431 | struct cu_tu_set *p; | |
1432 | unsigned int nsets; | |
1433 | unsigned int dw_sect; | |
1434 | ||
1435 | if (do_types) | |
1436 | { | |
1437 | p = tu_sets; | |
1438 | nsets = tu_count; | |
1439 | dw_sect = DW_SECT_TYPES; | |
1440 | } | |
1441 | else | |
1442 | { | |
1443 | p = cu_sets; | |
1444 | nsets = cu_count; | |
1445 | dw_sect = DW_SECT_INFO; | |
1446 | } | |
1447 | while (nsets > 0) | |
1448 | { | |
1449 | if (p->section_offsets [dw_sect] == cu_offset) | |
1450 | return p; | |
1451 | p++; | |
1452 | nsets--; | |
1453 | } | |
1454 | return NULL; | |
1455 | } | |
1456 | ||
a69c4772 NC |
1457 | /* Add INC to HIGH_BITS:LOW_BITS. */ |
1458 | static void | |
1459 | add64 (dwarf_vma * high_bits, dwarf_vma * low_bits, dwarf_vma inc) | |
1460 | { | |
1461 | dwarf_vma tmp = * low_bits; | |
1462 | ||
1463 | tmp += inc; | |
1464 | ||
1465 | /* FIXME: There is probably a better way of handling this: | |
1466 | ||
1467 | We need to cope with dwarf_vma being a 32-bit or 64-bit | |
1468 | type. Plus regardless of its size LOW_BITS is meant to | |
1469 | only hold 32-bits, so if there is overflow or wrap around | |
1470 | we must propagate into HIGH_BITS. */ | |
1471 | if (tmp < * low_bits) | |
1472 | { | |
1473 | ++ * high_bits; | |
1474 | } | |
1475 | else if (sizeof (tmp) > 8 | |
1476 | && (tmp >> 31) > 1) | |
1477 | { | |
1478 | ++ * high_bits; | |
1479 | tmp &= 0xFFFFFFFF; | |
1480 | } | |
1481 | ||
1482 | * low_bits = tmp; | |
1483 | } | |
1484 | ||
19e6b90e | 1485 | static unsigned char * |
6e3d6dc1 NC |
1486 | read_and_display_attr_value (unsigned long attribute, |
1487 | unsigned long form, | |
ec4d4525 | 1488 | unsigned char * data, |
f6f0e17b | 1489 | unsigned char * end, |
467c65bc NC |
1490 | dwarf_vma cu_offset, |
1491 | dwarf_vma pointer_size, | |
1492 | dwarf_vma offset_size, | |
6e3d6dc1 NC |
1493 | int dwarf_version, |
1494 | debug_info * debug_info_p, | |
1495 | int do_loc, | |
341f9135 CC |
1496 | struct dwarf_section * section, |
1497 | struct cu_tu_set * this_set) | |
19e6b90e | 1498 | { |
467c65bc | 1499 | dwarf_vma uvalue = 0; |
19e6b90e | 1500 | unsigned char *block_start = NULL; |
6e3d6dc1 | 1501 | unsigned char * orig_data = data; |
19e6b90e L |
1502 | unsigned int bytes_read; |
1503 | ||
f41e4712 | 1504 | if (data > end || (data == end && form != DW_FORM_flag_present)) |
0c588247 | 1505 | { |
f41e4712 | 1506 | warn (_("Corrupt attribute\n")); |
0c588247 NC |
1507 | return data; |
1508 | } | |
1509 | ||
19e6b90e L |
1510 | switch (form) |
1511 | { | |
1512 | default: | |
1513 | break; | |
1514 | ||
1515 | case DW_FORM_ref_addr: | |
1516 | if (dwarf_version == 2) | |
0c588247 | 1517 | SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); |
932fd279 | 1518 | else if (dwarf_version == 3 || dwarf_version == 4) |
0c588247 | 1519 | SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); |
19e6b90e | 1520 | else |
467c65bc NC |
1521 | error (_("Internal error: DWARF version is not 2, 3 or 4.\n")); |
1522 | ||
19e6b90e L |
1523 | break; |
1524 | ||
1525 | case DW_FORM_addr: | |
0c588247 | 1526 | SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); |
19e6b90e L |
1527 | break; |
1528 | ||
1529 | case DW_FORM_strp: | |
932fd279 | 1530 | case DW_FORM_sec_offset: |
a081f3cd JJ |
1531 | case DW_FORM_GNU_ref_alt: |
1532 | case DW_FORM_GNU_strp_alt: | |
0c588247 | 1533 | SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); |
19e6b90e L |
1534 | break; |
1535 | ||
932fd279 JJ |
1536 | case DW_FORM_flag_present: |
1537 | uvalue = 1; | |
1538 | break; | |
1539 | ||
19e6b90e L |
1540 | case DW_FORM_ref1: |
1541 | case DW_FORM_flag: | |
1542 | case DW_FORM_data1: | |
0c588247 | 1543 | SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
19e6b90e L |
1544 | break; |
1545 | ||
1546 | case DW_FORM_ref2: | |
1547 | case DW_FORM_data2: | |
0c588247 | 1548 | SAFE_BYTE_GET_AND_INC (uvalue, data, 2, end); |
19e6b90e L |
1549 | break; |
1550 | ||
1551 | case DW_FORM_ref4: | |
1552 | case DW_FORM_data4: | |
0c588247 | 1553 | SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); |
19e6b90e L |
1554 | break; |
1555 | ||
1556 | case DW_FORM_sdata: | |
f6f0e17b | 1557 | uvalue = read_sleb128 (data, & bytes_read, end); |
19e6b90e L |
1558 | data += bytes_read; |
1559 | break; | |
1560 | ||
4723351a | 1561 | case DW_FORM_GNU_str_index: |
f6f0e17b | 1562 | uvalue = read_uleb128 (data, & bytes_read, end); |
4723351a CC |
1563 | data += bytes_read; |
1564 | break; | |
1565 | ||
19e6b90e L |
1566 | case DW_FORM_ref_udata: |
1567 | case DW_FORM_udata: | |
f6f0e17b | 1568 | uvalue = read_uleb128 (data, & bytes_read, end); |
19e6b90e L |
1569 | data += bytes_read; |
1570 | break; | |
1571 | ||
1572 | case DW_FORM_indirect: | |
f6f0e17b | 1573 | form = read_uleb128 (data, & bytes_read, end); |
19e6b90e L |
1574 | data += bytes_read; |
1575 | if (!do_loc) | |
1576 | printf (" %s", get_FORM_name (form)); | |
f6f0e17b | 1577 | return read_and_display_attr_value (attribute, form, data, end, |
19e6b90e L |
1578 | cu_offset, pointer_size, |
1579 | offset_size, dwarf_version, | |
ec4d4525 | 1580 | debug_info_p, do_loc, |
341f9135 | 1581 | section, this_set); |
4723351a | 1582 | case DW_FORM_GNU_addr_index: |
f6f0e17b | 1583 | uvalue = read_uleb128 (data, & bytes_read, end); |
4723351a CC |
1584 | data += bytes_read; |
1585 | break; | |
19e6b90e L |
1586 | } |
1587 | ||
1588 | switch (form) | |
1589 | { | |
1590 | case DW_FORM_ref_addr: | |
1591 | if (!do_loc) | |
467c65bc | 1592 | printf (" <0x%s>", dwarf_vmatoa ("x",uvalue)); |
19e6b90e L |
1593 | break; |
1594 | ||
a081f3cd JJ |
1595 | case DW_FORM_GNU_ref_alt: |
1596 | if (!do_loc) | |
1597 | printf (" <alt 0x%s>", dwarf_vmatoa ("x",uvalue)); | |
1598 | break; | |
1599 | ||
19e6b90e L |
1600 | case DW_FORM_ref1: |
1601 | case DW_FORM_ref2: | |
1602 | case DW_FORM_ref4: | |
1603 | case DW_FORM_ref_udata: | |
1604 | if (!do_loc) | |
467c65bc | 1605 | printf (" <0x%s>", dwarf_vmatoa ("x", uvalue + cu_offset)); |
19e6b90e L |
1606 | break; |
1607 | ||
1608 | case DW_FORM_data4: | |
1609 | case DW_FORM_addr: | |
932fd279 | 1610 | case DW_FORM_sec_offset: |
19e6b90e | 1611 | if (!do_loc) |
467c65bc | 1612 | printf (" 0x%s", dwarf_vmatoa ("x", uvalue)); |
19e6b90e L |
1613 | break; |
1614 | ||
932fd279 | 1615 | case DW_FORM_flag_present: |
19e6b90e L |
1616 | case DW_FORM_flag: |
1617 | case DW_FORM_data1: | |
1618 | case DW_FORM_data2: | |
1619 | case DW_FORM_sdata: | |
1620 | case DW_FORM_udata: | |
1621 | if (!do_loc) | |
467c65bc | 1622 | printf (" %s", dwarf_vmatoa ("d", uvalue)); |
19e6b90e L |
1623 | break; |
1624 | ||
1625 | case DW_FORM_ref8: | |
1626 | case DW_FORM_data8: | |
2bc8690c | 1627 | if (!do_loc) |
19e6b90e | 1628 | { |
74bc6052 | 1629 | dwarf_vma high_bits; |
a69c4772 | 1630 | dwarf_vma utmp; |
74bc6052 CC |
1631 | char buf[64]; |
1632 | ||
0c588247 | 1633 | SAFE_BYTE_GET64 (data, &high_bits, &uvalue, end); |
a69c4772 NC |
1634 | utmp = uvalue; |
1635 | if (form == DW_FORM_ref8) | |
1636 | add64 (& high_bits, & utmp, cu_offset); | |
74bc6052 | 1637 | printf (" 0x%s", |
a69c4772 | 1638 | dwarf_vmatoa64 (high_bits, utmp, buf, sizeof (buf))); |
19e6b90e | 1639 | } |
0c588247 | 1640 | |
19e6b90e L |
1641 | if ((do_loc || do_debug_loc || do_debug_ranges) |
1642 | && num_debug_info_entries == 0) | |
1643 | { | |
1644 | if (sizeof (uvalue) == 8) | |
0c588247 | 1645 | SAFE_BYTE_GET (uvalue, data, 8, end); |
19e6b90e | 1646 | else |
467c65bc | 1647 | error (_("DW_FORM_data8 is unsupported when sizeof (dwarf_vma) != 8\n")); |
19e6b90e | 1648 | } |
0c588247 | 1649 | |
19e6b90e L |
1650 | data += 8; |
1651 | break; | |
1652 | ||
1653 | case DW_FORM_string: | |
1654 | if (!do_loc) | |
2bdc3eca | 1655 | printf (" %.*s", (int) (end - data), data); |
0c588247 | 1656 | data += strnlen ((char *) data, end - data) + 1; |
19e6b90e L |
1657 | break; |
1658 | ||
1659 | case DW_FORM_block: | |
932fd279 | 1660 | case DW_FORM_exprloc: |
f6f0e17b | 1661 | uvalue = read_uleb128 (data, & bytes_read, end); |
19e6b90e | 1662 | block_start = data + bytes_read; |
a1165289 NC |
1663 | if (block_start >= end) |
1664 | { | |
1665 | warn (_("Block ends prematurely\n")); | |
1666 | uvalue = 0; | |
1667 | block_start = end; | |
1668 | } | |
f41e4712 NC |
1669 | /* PR 17512: file: 008-103549-0.001:0.1. */ |
1670 | if (block_start + uvalue > end) | |
1671 | { | |
1672 | warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue); | |
1673 | uvalue = end - block_start; | |
1674 | } | |
19e6b90e L |
1675 | if (do_loc) |
1676 | data = block_start + uvalue; | |
1677 | else | |
0c588247 | 1678 | data = display_block (block_start, uvalue, end); |
19e6b90e L |
1679 | break; |
1680 | ||
1681 | case DW_FORM_block1: | |
0c588247 | 1682 | SAFE_BYTE_GET (uvalue, data, 1, end); |
19e6b90e | 1683 | block_start = data + 1; |
a1165289 NC |
1684 | if (block_start >= end) |
1685 | { | |
1686 | warn (_("Block ends prematurely\n")); | |
1687 | uvalue = 0; | |
1688 | block_start = end; | |
1689 | } | |
f41e4712 NC |
1690 | if (block_start + uvalue > end) |
1691 | { | |
1692 | warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue); | |
1693 | uvalue = end - block_start; | |
1694 | } | |
19e6b90e L |
1695 | if (do_loc) |
1696 | data = block_start + uvalue; | |
1697 | else | |
0c588247 | 1698 | data = display_block (block_start, uvalue, end); |
19e6b90e L |
1699 | break; |
1700 | ||
1701 | case DW_FORM_block2: | |
0c588247 | 1702 | SAFE_BYTE_GET (uvalue, data, 2, end); |
19e6b90e | 1703 | block_start = data + 2; |
a1165289 NC |
1704 | if (block_start >= end) |
1705 | { | |
1706 | warn (_("Block ends prematurely\n")); | |
1707 | uvalue = 0; | |
1708 | block_start = end; | |
1709 | } | |
f41e4712 NC |
1710 | if (block_start + uvalue > end) |
1711 | { | |
1712 | warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue); | |
1713 | uvalue = end - block_start; | |
1714 | } | |
19e6b90e L |
1715 | if (do_loc) |
1716 | data = block_start + uvalue; | |
1717 | else | |
0c588247 | 1718 | data = display_block (block_start, uvalue, end); |
19e6b90e L |
1719 | break; |
1720 | ||
1721 | case DW_FORM_block4: | |
0c588247 | 1722 | SAFE_BYTE_GET (uvalue, data, 4, end); |
19e6b90e | 1723 | block_start = data + 4; |
a1165289 NC |
1724 | /* PR 17512: file: 3371-3907-0.004. */ |
1725 | if (block_start >= end) | |
1726 | { | |
1727 | warn (_("Block ends prematurely\n")); | |
1728 | uvalue = 0; | |
1729 | block_start = end; | |
1730 | } | |
f41e4712 NC |
1731 | if (block_start + uvalue > end) |
1732 | { | |
1733 | warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue); | |
1734 | uvalue = end - block_start; | |
1735 | } | |
19e6b90e L |
1736 | if (do_loc) |
1737 | data = block_start + uvalue; | |
1738 | else | |
0c588247 | 1739 | data = display_block (block_start, uvalue, end); |
19e6b90e L |
1740 | break; |
1741 | ||
1742 | case DW_FORM_strp: | |
1743 | if (!do_loc) | |
47704ddf KT |
1744 | printf (_(" (indirect string, offset: 0x%s): %s"), |
1745 | dwarf_vmatoa ("x", uvalue), | |
1746 | fetch_indirect_string (uvalue)); | |
19e6b90e L |
1747 | break; |
1748 | ||
4723351a CC |
1749 | case DW_FORM_GNU_str_index: |
1750 | if (!do_loc) | |
1751 | { | |
1752 | const char *suffix = strrchr (section->name, '.'); | |
1753 | int dwo = (suffix && strcmp (suffix, ".dwo") == 0) ? 1 : 0; | |
1754 | ||
1755 | printf (_(" (indexed string: 0x%s): %s"), | |
1756 | dwarf_vmatoa ("x", uvalue), | |
341f9135 | 1757 | fetch_indexed_string (uvalue, this_set, offset_size, dwo)); |
4723351a CC |
1758 | } |
1759 | break; | |
1760 | ||
a081f3cd JJ |
1761 | case DW_FORM_GNU_strp_alt: |
1762 | if (!do_loc) | |
1763 | printf (_(" (alt indirect string, offset: 0x%s)"), | |
1764 | dwarf_vmatoa ("x", uvalue)); | |
1765 | break; | |
1766 | ||
19e6b90e L |
1767 | case DW_FORM_indirect: |
1768 | /* Handled above. */ | |
1769 | break; | |
1770 | ||
2b6f5997 CC |
1771 | case DW_FORM_ref_sig8: |
1772 | if (!do_loc) | |
1773 | { | |
74bc6052 CC |
1774 | dwarf_vma high_bits; |
1775 | char buf[64]; | |
1776 | ||
0c588247 | 1777 | SAFE_BYTE_GET64 (data, &high_bits, &uvalue, end); |
74bc6052 CC |
1778 | printf (" signature: 0x%s", |
1779 | dwarf_vmatoa64 (high_bits, uvalue, buf, sizeof (buf))); | |
2b6f5997 | 1780 | } |
74bc6052 | 1781 | data += 8; |
2b6f5997 CC |
1782 | break; |
1783 | ||
4723351a CC |
1784 | case DW_FORM_GNU_addr_index: |
1785 | if (!do_loc) | |
1786 | printf (_(" (addr_index: 0x%s): %s"), | |
1787 | dwarf_vmatoa ("x", uvalue), | |
1788 | fetch_indexed_value (uvalue * pointer_size, pointer_size)); | |
1789 | break; | |
1790 | ||
19e6b90e L |
1791 | default: |
1792 | warn (_("Unrecognized form: %lu\n"), form); | |
1793 | break; | |
1794 | } | |
1795 | ||
19e6b90e | 1796 | if ((do_loc || do_debug_loc || do_debug_ranges) |
fd2f0033 TT |
1797 | && num_debug_info_entries == 0 |
1798 | && debug_info_p != NULL) | |
19e6b90e L |
1799 | { |
1800 | switch (attribute) | |
1801 | { | |
1802 | case DW_AT_frame_base: | |
1803 | have_frame_base = 1; | |
1804 | case DW_AT_location: | |
e2a0d921 NC |
1805 | case DW_AT_string_length: |
1806 | case DW_AT_return_addr: | |
19e6b90e L |
1807 | case DW_AT_data_member_location: |
1808 | case DW_AT_vtable_elem_location: | |
e2a0d921 NC |
1809 | case DW_AT_segment: |
1810 | case DW_AT_static_link: | |
1811 | case DW_AT_use_location: | |
629e7ca8 JJ |
1812 | case DW_AT_GNU_call_site_value: |
1813 | case DW_AT_GNU_call_site_data_value: | |
1814 | case DW_AT_GNU_call_site_target: | |
1815 | case DW_AT_GNU_call_site_target_clobbered: | |
212b6063 JK |
1816 | if ((dwarf_version < 4 |
1817 | && (form == DW_FORM_data4 || form == DW_FORM_data8)) | |
932fd279 | 1818 | || form == DW_FORM_sec_offset) |
19e6b90e L |
1819 | { |
1820 | /* Process location list. */ | |
91d6fa6a | 1821 | unsigned int lmax = debug_info_p->max_loc_offsets; |
19e6b90e L |
1822 | unsigned int num = debug_info_p->num_loc_offsets; |
1823 | ||
91d6fa6a | 1824 | if (lmax == 0 || num >= lmax) |
19e6b90e | 1825 | { |
91d6fa6a | 1826 | lmax += 1024; |
467c65bc | 1827 | debug_info_p->loc_offsets = (dwarf_vma *) |
3f5e193b | 1828 | xcrealloc (debug_info_p->loc_offsets, |
91d6fa6a | 1829 | lmax, sizeof (*debug_info_p->loc_offsets)); |
3f5e193b NC |
1830 | debug_info_p->have_frame_base = (int *) |
1831 | xcrealloc (debug_info_p->have_frame_base, | |
91d6fa6a NC |
1832 | lmax, sizeof (*debug_info_p->have_frame_base)); |
1833 | debug_info_p->max_loc_offsets = lmax; | |
19e6b90e | 1834 | } |
341f9135 CC |
1835 | if (this_set != NULL) |
1836 | uvalue += this_set->section_offsets [DW_SECT_LOC]; | |
19e6b90e L |
1837 | debug_info_p->loc_offsets [num] = uvalue; |
1838 | debug_info_p->have_frame_base [num] = have_frame_base; | |
1839 | debug_info_p->num_loc_offsets++; | |
1840 | } | |
1841 | break; | |
e2a0d921 | 1842 | |
19e6b90e L |
1843 | case DW_AT_low_pc: |
1844 | if (need_base_address) | |
1845 | debug_info_p->base_address = uvalue; | |
1846 | break; | |
1847 | ||
4723351a CC |
1848 | case DW_AT_GNU_addr_base: |
1849 | debug_info_p->addr_base = uvalue; | |
1850 | break; | |
1851 | ||
1852 | case DW_AT_GNU_ranges_base: | |
1853 | debug_info_p->ranges_base = uvalue; | |
1854 | break; | |
1855 | ||
19e6b90e | 1856 | case DW_AT_ranges: |
212b6063 JK |
1857 | if ((dwarf_version < 4 |
1858 | && (form == DW_FORM_data4 || form == DW_FORM_data8)) | |
932fd279 | 1859 | || form == DW_FORM_sec_offset) |
19e6b90e L |
1860 | { |
1861 | /* Process range list. */ | |
91d6fa6a | 1862 | unsigned int lmax = debug_info_p->max_range_lists; |
19e6b90e L |
1863 | unsigned int num = debug_info_p->num_range_lists; |
1864 | ||
91d6fa6a | 1865 | if (lmax == 0 || num >= lmax) |
19e6b90e | 1866 | { |
91d6fa6a | 1867 | lmax += 1024; |
467c65bc | 1868 | debug_info_p->range_lists = (dwarf_vma *) |
3f5e193b | 1869 | xcrealloc (debug_info_p->range_lists, |
91d6fa6a NC |
1870 | lmax, sizeof (*debug_info_p->range_lists)); |
1871 | debug_info_p->max_range_lists = lmax; | |
19e6b90e L |
1872 | } |
1873 | debug_info_p->range_lists [num] = uvalue; | |
1874 | debug_info_p->num_range_lists++; | |
1875 | } | |
1876 | break; | |
1877 | ||
1878 | default: | |
1879 | break; | |
1880 | } | |
1881 | } | |
1882 | ||
4ccf1e31 | 1883 | if (do_loc || attribute == 0) |
19e6b90e L |
1884 | return data; |
1885 | ||
ec4d4525 | 1886 | /* For some attributes we can display further information. */ |
19e6b90e L |
1887 | switch (attribute) |
1888 | { | |
1889 | case DW_AT_inline: | |
2e9e81a8 | 1890 | printf ("\t"); |
19e6b90e L |
1891 | switch (uvalue) |
1892 | { | |
1893 | case DW_INL_not_inlined: | |
1894 | printf (_("(not inlined)")); | |
1895 | break; | |
1896 | case DW_INL_inlined: | |
1897 | printf (_("(inlined)")); | |
1898 | break; | |
1899 | case DW_INL_declared_not_inlined: | |
1900 | printf (_("(declared as inline but ignored)")); | |
1901 | break; | |
1902 | case DW_INL_declared_inlined: | |
1903 | printf (_("(declared as inline and inlined)")); | |
1904 | break; | |
1905 | default: | |
47704ddf KT |
1906 | printf (_(" (Unknown inline attribute value: %s)"), |
1907 | dwarf_vmatoa ("x", uvalue)); | |
19e6b90e L |
1908 | break; |
1909 | } | |
1910 | break; | |
1911 | ||
1912 | case DW_AT_language: | |
2e9e81a8 | 1913 | printf ("\t"); |
19e6b90e L |
1914 | switch (uvalue) |
1915 | { | |
4b78141a | 1916 | /* Ordered by the numeric value of these constants. */ |
19e6b90e | 1917 | case DW_LANG_C89: printf ("(ANSI C)"); break; |
4b78141a NC |
1918 | case DW_LANG_C: printf ("(non-ANSI C)"); break; |
1919 | case DW_LANG_Ada83: printf ("(Ada)"); break; | |
19e6b90e | 1920 | case DW_LANG_C_plus_plus: printf ("(C++)"); break; |
4b78141a NC |
1921 | case DW_LANG_Cobol74: printf ("(Cobol 74)"); break; |
1922 | case DW_LANG_Cobol85: printf ("(Cobol 85)"); break; | |
19e6b90e L |
1923 | case DW_LANG_Fortran77: printf ("(FORTRAN 77)"); break; |
1924 | case DW_LANG_Fortran90: printf ("(Fortran 90)"); break; | |
19e6b90e | 1925 | case DW_LANG_Pascal83: printf ("(ANSI Pascal)"); break; |
4b78141a | 1926 | case DW_LANG_Modula2: printf ("(Modula 2)"); break; |
19e6b90e | 1927 | /* DWARF 2.1 values. */ |
4b78141a | 1928 | case DW_LANG_Java: printf ("(Java)"); break; |
19e6b90e L |
1929 | case DW_LANG_C99: printf ("(ANSI C99)"); break; |
1930 | case DW_LANG_Ada95: printf ("(ADA 95)"); break; | |
1931 | case DW_LANG_Fortran95: printf ("(Fortran 95)"); break; | |
4b78141a NC |
1932 | /* DWARF 3 values. */ |
1933 | case DW_LANG_PLI: printf ("(PLI)"); break; | |
1934 | case DW_LANG_ObjC: printf ("(Objective C)"); break; | |
1935 | case DW_LANG_ObjC_plus_plus: printf ("(Objective C++)"); break; | |
1936 | case DW_LANG_UPC: printf ("(Unified Parallel C)"); break; | |
1937 | case DW_LANG_D: printf ("(D)"); break; | |
2b6f5997 CC |
1938 | /* DWARF 4 values. */ |
1939 | case DW_LANG_Python: printf ("(Python)"); break; | |
3362e0d9 ILT |
1940 | /* DWARF 5 values. */ |
1941 | case DW_LANG_Go: printf ("(Go)"); break; | |
8bc10620 | 1942 | case DW_LANG_C_plus_plus_11: printf ("(C++11)"); break; |
6ddfe5b4 | 1943 | case DW_LANG_C11: printf ("(C11)"); break; |
8bc10620 | 1944 | case DW_LANG_C_plus_plus_14: printf ("(C++14)"); break; |
19e6b90e L |
1945 | /* MIPS extension. */ |
1946 | case DW_LANG_Mips_Assembler: printf ("(MIPS assembler)"); break; | |
1947 | /* UPC extension. */ | |
1948 | case DW_LANG_Upc: printf ("(Unified Parallel C)"); break; | |
1949 | default: | |
4b78141a | 1950 | if (uvalue >= DW_LANG_lo_user && uvalue <= DW_LANG_hi_user) |
9cf03b7e | 1951 | printf (_("(implementation defined: %s)"), |
467c65bc | 1952 | dwarf_vmatoa ("x", uvalue)); |
4b78141a | 1953 | else |
9cf03b7e | 1954 | printf (_("(Unknown: %s)"), dwarf_vmatoa ("x", uvalue)); |
19e6b90e L |
1955 | break; |
1956 | } | |
1957 | break; | |
1958 | ||
1959 | case DW_AT_encoding: | |
2e9e81a8 | 1960 | printf ("\t"); |
19e6b90e L |
1961 | switch (uvalue) |
1962 | { | |
1963 | case DW_ATE_void: printf ("(void)"); break; | |
1964 | case DW_ATE_address: printf ("(machine address)"); break; | |
1965 | case DW_ATE_boolean: printf ("(boolean)"); break; | |
1966 | case DW_ATE_complex_float: printf ("(complex float)"); break; | |
1967 | case DW_ATE_float: printf ("(float)"); break; | |
1968 | case DW_ATE_signed: printf ("(signed)"); break; | |
1969 | case DW_ATE_signed_char: printf ("(signed char)"); break; | |
1970 | case DW_ATE_unsigned: printf ("(unsigned)"); break; | |
1971 | case DW_ATE_unsigned_char: printf ("(unsigned char)"); break; | |
e2a0d921 | 1972 | /* DWARF 2.1 values: */ |
19e6b90e L |
1973 | case DW_ATE_imaginary_float: printf ("(imaginary float)"); break; |
1974 | case DW_ATE_decimal_float: printf ("(decimal float)"); break; | |
e2a0d921 NC |
1975 | /* DWARF 3 values: */ |
1976 | case DW_ATE_packed_decimal: printf ("(packed_decimal)"); break; | |
1977 | case DW_ATE_numeric_string: printf ("(numeric_string)"); break; | |
1978 | case DW_ATE_edited: printf ("(edited)"); break; | |
1979 | case DW_ATE_signed_fixed: printf ("(signed_fixed)"); break; | |
1980 | case DW_ATE_unsigned_fixed: printf ("(unsigned_fixed)"); break; | |
1981 | /* HP extensions: */ | |
1982 | case DW_ATE_HP_float80: printf ("(HP_float80)"); break; | |
1983 | case DW_ATE_HP_complex_float80: printf ("(HP_complex_float80)"); break; | |
1984 | case DW_ATE_HP_float128: printf ("(HP_float128)"); break; | |
1985 | case DW_ATE_HP_complex_float128:printf ("(HP_complex_float128)"); break; | |
1986 | case DW_ATE_HP_floathpintel: printf ("(HP_floathpintel)"); break; | |
1987 | case DW_ATE_HP_imaginary_float80: printf ("(HP_imaginary_float80)"); break; | |
1988 | case DW_ATE_HP_imaginary_float128: printf ("(HP_imaginary_float128)"); break; | |
1989 | ||
19e6b90e L |
1990 | default: |
1991 | if (uvalue >= DW_ATE_lo_user | |
1992 | && uvalue <= DW_ATE_hi_user) | |
9cf03b7e | 1993 | printf (_("(user defined type)")); |
19e6b90e | 1994 | else |
9cf03b7e | 1995 | printf (_("(unknown type)")); |
19e6b90e L |
1996 | break; |
1997 | } | |
1998 | break; | |
1999 | ||
2000 | case DW_AT_accessibility: | |
2e9e81a8 | 2001 | printf ("\t"); |
19e6b90e L |
2002 | switch (uvalue) |
2003 | { | |
2004 | case DW_ACCESS_public: printf ("(public)"); break; | |
2005 | case DW_ACCESS_protected: printf ("(protected)"); break; | |
2006 | case DW_ACCESS_private: printf ("(private)"); break; | |
2007 | default: | |
9cf03b7e | 2008 | printf (_("(unknown accessibility)")); |
19e6b90e L |
2009 | break; |
2010 | } | |
2011 | break; | |
2012 | ||
2013 | case DW_AT_visibility: | |
2e9e81a8 | 2014 | printf ("\t"); |
19e6b90e L |
2015 | switch (uvalue) |
2016 | { | |
2017 | case DW_VIS_local: printf ("(local)"); break; | |
2018 | case DW_VIS_exported: printf ("(exported)"); break; | |
2019 | case DW_VIS_qualified: printf ("(qualified)"); break; | |
9cf03b7e | 2020 | default: printf (_("(unknown visibility)")); break; |
19e6b90e L |
2021 | } |
2022 | break; | |
2023 | ||
2024 | case DW_AT_virtuality: | |
2e9e81a8 | 2025 | printf ("\t"); |
19e6b90e L |
2026 | switch (uvalue) |
2027 | { | |
2028 | case DW_VIRTUALITY_none: printf ("(none)"); break; | |
2029 | case DW_VIRTUALITY_virtual: printf ("(virtual)"); break; | |
2030 | case DW_VIRTUALITY_pure_virtual:printf ("(pure_virtual)"); break; | |
9cf03b7e | 2031 | default: printf (_("(unknown virtuality)")); break; |
19e6b90e L |
2032 | } |
2033 | break; | |
2034 | ||
2035 | case DW_AT_identifier_case: | |
2e9e81a8 | 2036 | printf ("\t"); |
19e6b90e L |
2037 | switch (uvalue) |
2038 | { | |
2039 | case DW_ID_case_sensitive: printf ("(case_sensitive)"); break; | |
2040 | case DW_ID_up_case: printf ("(up_case)"); break; | |
2041 | case DW_ID_down_case: printf ("(down_case)"); break; | |
2042 | case DW_ID_case_insensitive: printf ("(case_insensitive)"); break; | |
9cf03b7e | 2043 | default: printf (_("(unknown case)")); break; |
19e6b90e L |
2044 | } |
2045 | break; | |
2046 | ||
2047 | case DW_AT_calling_convention: | |
2e9e81a8 | 2048 | printf ("\t"); |
19e6b90e L |
2049 | switch (uvalue) |
2050 | { | |
2051 | case DW_CC_normal: printf ("(normal)"); break; | |
2052 | case DW_CC_program: printf ("(program)"); break; | |
2053 | case DW_CC_nocall: printf ("(nocall)"); break; | |
2054 | default: | |
2055 | if (uvalue >= DW_CC_lo_user | |
2056 | && uvalue <= DW_CC_hi_user) | |
9cf03b7e | 2057 | printf (_("(user defined)")); |
19e6b90e | 2058 | else |
9cf03b7e | 2059 | printf (_("(unknown convention)")); |
19e6b90e L |
2060 | } |
2061 | break; | |
2062 | ||
2063 | case DW_AT_ordering: | |
2e9e81a8 | 2064 | printf ("\t"); |
19e6b90e L |
2065 | switch (uvalue) |
2066 | { | |
9cf03b7e | 2067 | case -1: printf (_("(undefined)")); break; |
19e6b90e L |
2068 | case 0: printf ("(row major)"); break; |
2069 | case 1: printf ("(column major)"); break; | |
2070 | } | |
2071 | break; | |
2072 | ||
2073 | case DW_AT_frame_base: | |
2074 | have_frame_base = 1; | |
2075 | case DW_AT_location: | |
e2a0d921 NC |
2076 | case DW_AT_string_length: |
2077 | case DW_AT_return_addr: | |
19e6b90e L |
2078 | case DW_AT_data_member_location: |
2079 | case DW_AT_vtable_elem_location: | |
e2a0d921 NC |
2080 | case DW_AT_segment: |
2081 | case DW_AT_static_link: | |
2082 | case DW_AT_use_location: | |
629e7ca8 JJ |
2083 | case DW_AT_GNU_call_site_value: |
2084 | case DW_AT_GNU_call_site_data_value: | |
2085 | case DW_AT_GNU_call_site_target: | |
2086 | case DW_AT_GNU_call_site_target_clobbered: | |
212b6063 JK |
2087 | if ((dwarf_version < 4 |
2088 | && (form == DW_FORM_data4 || form == DW_FORM_data8)) | |
932fd279 | 2089 | || form == DW_FORM_sec_offset) |
2e9e81a8 | 2090 | printf (_(" (location list)")); |
e2a0d921 | 2091 | /* Fall through. */ |
19e6b90e L |
2092 | case DW_AT_allocated: |
2093 | case DW_AT_associated: | |
2094 | case DW_AT_data_location: | |
2095 | case DW_AT_stride: | |
2096 | case DW_AT_upper_bound: | |
cecf136e | 2097 | case DW_AT_lower_bound: |
19e6b90e L |
2098 | if (block_start) |
2099 | { | |
2100 | int need_frame_base; | |
2101 | ||
2e9e81a8 | 2102 | printf ("\t("); |
19e6b90e L |
2103 | need_frame_base = decode_location_expression (block_start, |
2104 | pointer_size, | |
b7807392 JJ |
2105 | offset_size, |
2106 | dwarf_version, | |
19e6b90e | 2107 | uvalue, |
f1c4cc75 | 2108 | cu_offset, section); |
19e6b90e L |
2109 | printf (")"); |
2110 | if (need_frame_base && !have_frame_base) | |
2111 | printf (_(" [without DW_AT_frame_base]")); | |
2112 | } | |
19e6b90e L |
2113 | break; |
2114 | ||
ec4d4525 NC |
2115 | case DW_AT_import: |
2116 | { | |
a081f3cd JJ |
2117 | if (form == DW_FORM_ref_sig8 |
2118 | || form == DW_FORM_GNU_ref_alt) | |
2b6f5997 CC |
2119 | break; |
2120 | ||
ec4d4525 NC |
2121 | if (form == DW_FORM_ref1 |
2122 | || form == DW_FORM_ref2 | |
a7a0b6a5 JK |
2123 | || form == DW_FORM_ref4 |
2124 | || form == DW_FORM_ref_udata) | |
ec4d4525 NC |
2125 | uvalue += cu_offset; |
2126 | ||
6e3d6dc1 | 2127 | if (uvalue >= section->size) |
47704ddf KT |
2128 | warn (_("Offset %s used as value for DW_AT_import attribute of DIE at offset %lx is too big.\n"), |
2129 | dwarf_vmatoa ("x", uvalue), | |
2130 | (unsigned long) (orig_data - section->start)); | |
6e3d6dc1 NC |
2131 | else |
2132 | { | |
2133 | unsigned long abbrev_number; | |
2134 | abbrev_entry * entry; | |
2135 | ||
f6f0e17b | 2136 | abbrev_number = read_uleb128 (section->start + uvalue, NULL, end); |
cecf136e | 2137 | |
2e9e81a8 | 2138 | printf (_("\t[Abbrev Number: %ld"), abbrev_number); |
afd6e1ff JJ |
2139 | /* Don't look up abbrev for DW_FORM_ref_addr, as it very often will |
2140 | use different abbrev table, and we don't track .debug_info chunks | |
2141 | yet. */ | |
2142 | if (form != DW_FORM_ref_addr) | |
2143 | { | |
2144 | for (entry = first_abbrev; entry != NULL; entry = entry->next) | |
2145 | if (entry->entry == abbrev_number) | |
2146 | break; | |
2147 | if (entry != NULL) | |
2148 | printf (" (%s)", get_TAG_name (entry->tag)); | |
2149 | } | |
6e3d6dc1 NC |
2150 | printf ("]"); |
2151 | } | |
ec4d4525 NC |
2152 | } |
2153 | break; | |
2154 | ||
19e6b90e L |
2155 | default: |
2156 | break; | |
2157 | } | |
2158 | ||
2159 | return data; | |
2160 | } | |
2161 | ||
a19c41a7 | 2162 | static const char * |
19e6b90e L |
2163 | get_AT_name (unsigned long attribute) |
2164 | { | |
a19c41a7 | 2165 | const char *name; |
e2a0d921 | 2166 | |
399c99f7 L |
2167 | if (attribute == 0) |
2168 | return "DW_AT value: 0"; | |
2169 | ||
a19c41a7 TT |
2170 | /* One value is shared by the MIPS and HP extensions: */ |
2171 | if (attribute == DW_AT_MIPS_fde) | |
2172 | return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable"; | |
19e6b90e | 2173 | |
a19c41a7 TT |
2174 | name = get_DW_AT_name (attribute); |
2175 | ||
2176 | if (name == NULL) | |
2177 | { | |
2178 | static char buffer[100]; | |
2179 | ||
2180 | snprintf (buffer, sizeof (buffer), _("Unknown AT value: %lx"), | |
2181 | attribute); | |
2182 | return buffer; | |
19e6b90e | 2183 | } |
a19c41a7 TT |
2184 | |
2185 | return name; | |
19e6b90e L |
2186 | } |
2187 | ||
2188 | static unsigned char * | |
6e3d6dc1 NC |
2189 | read_and_display_attr (unsigned long attribute, |
2190 | unsigned long form, | |
ec4d4525 | 2191 | unsigned char * data, |
f6f0e17b | 2192 | unsigned char * end, |
467c65bc NC |
2193 | dwarf_vma cu_offset, |
2194 | dwarf_vma pointer_size, | |
2195 | dwarf_vma offset_size, | |
6e3d6dc1 NC |
2196 | int dwarf_version, |
2197 | debug_info * debug_info_p, | |
2198 | int do_loc, | |
341f9135 CC |
2199 | struct dwarf_section * section, |
2200 | struct cu_tu_set * this_set) | |
19e6b90e L |
2201 | { |
2202 | if (!do_loc) | |
750f03b7 | 2203 | printf (" %-18s:", get_AT_name (attribute)); |
f6f0e17b NC |
2204 | data = read_and_display_attr_value (attribute, form, data, end, |
2205 | cu_offset, pointer_size, offset_size, | |
19e6b90e | 2206 | dwarf_version, debug_info_p, |
341f9135 | 2207 | do_loc, section, this_set); |
19e6b90e L |
2208 | if (!do_loc) |
2209 | printf ("\n"); | |
2210 | return data; | |
2211 | } | |
2212 | ||
19e6b90e L |
2213 | /* Process the contents of a .debug_info section. If do_loc is non-zero |
2214 | then we are scanning for location lists and we do not want to display | |
2b6f5997 CC |
2215 | anything to the user. If do_types is non-zero, we are processing |
2216 | a .debug_types section instead of a .debug_info section. */ | |
19e6b90e L |
2217 | |
2218 | static int | |
6e3d6dc1 NC |
2219 | process_debug_info (struct dwarf_section *section, |
2220 | void *file, | |
6f875884 | 2221 | enum dwarf_section_display_enum abbrev_sec, |
2b6f5997 CC |
2222 | int do_loc, |
2223 | int do_types) | |
19e6b90e L |
2224 | { |
2225 | unsigned char *start = section->start; | |
2226 | unsigned char *end = start + section->size; | |
2227 | unsigned char *section_begin; | |
2228 | unsigned int unit; | |
2229 | unsigned int num_units = 0; | |
2230 | ||
2231 | if ((do_loc || do_debug_loc || do_debug_ranges) | |
2b6f5997 CC |
2232 | && num_debug_info_entries == 0 |
2233 | && ! do_types) | |
19e6b90e | 2234 | { |
767221a9 | 2235 | dwarf_vma length; |
19e6b90e L |
2236 | |
2237 | /* First scan the section to get the number of comp units. */ | |
2238 | for (section_begin = start, num_units = 0; section_begin < end; | |
2239 | num_units ++) | |
2240 | { | |
2241 | /* Read the first 4 bytes. For a 32-bit DWARF section, this | |
2242 | will be the length. For a 64-bit DWARF section, it'll be | |
2243 | the escape code 0xffffffff followed by an 8 byte length. */ | |
0c588247 | 2244 | SAFE_BYTE_GET (length, section_begin, 4, end); |
19e6b90e L |
2245 | |
2246 | if (length == 0xffffffff) | |
2247 | { | |
0c588247 | 2248 | SAFE_BYTE_GET (length, section_begin + 4, 8, end); |
19e6b90e L |
2249 | section_begin += length + 12; |
2250 | } | |
ec4d4525 NC |
2251 | else if (length >= 0xfffffff0 && length < 0xffffffff) |
2252 | { | |
767221a9 NC |
2253 | warn (_("Reserved length value (0x%s) found in section %s\n"), |
2254 | dwarf_vmatoa ("x", length), section->name); | |
ec4d4525 NC |
2255 | return 0; |
2256 | } | |
19e6b90e L |
2257 | else |
2258 | section_begin += length + 4; | |
aca88567 NC |
2259 | |
2260 | /* Negative values are illegal, they may even cause infinite | |
2261 | looping. This can happen if we can't accurately apply | |
2262 | relocations to an object file. */ | |
2263 | if ((signed long) length <= 0) | |
2264 | { | |
767221a9 NC |
2265 | warn (_("Corrupt unit length (0x%s) found in section %s\n"), |
2266 | dwarf_vmatoa ("x", length), section->name); | |
aca88567 NC |
2267 | return 0; |
2268 | } | |
19e6b90e L |
2269 | } |
2270 | ||
2271 | if (num_units == 0) | |
2272 | { | |
f41e4712 | 2273 | error (_("No comp units in %s section ?\n"), section->name); |
19e6b90e L |
2274 | return 0; |
2275 | } | |
2276 | ||
2277 | /* Then allocate an array to hold the information. */ | |
3f5e193b | 2278 | debug_information = (debug_info *) cmalloc (num_units, |
1306a742 | 2279 | sizeof (* debug_information)); |
19e6b90e L |
2280 | if (debug_information == NULL) |
2281 | { | |
f41e4712 | 2282 | error (_("Not enough memory for a debug info array of %u entries\n"), |
19e6b90e | 2283 | num_units); |
82b1b41b | 2284 | alloc_num_debug_info_entries = num_debug_info_entries = 0; |
19e6b90e L |
2285 | return 0; |
2286 | } | |
82b1b41b | 2287 | alloc_num_debug_info_entries = num_units; |
19e6b90e L |
2288 | } |
2289 | ||
2290 | if (!do_loc) | |
2291 | { | |
fd2f0033 TT |
2292 | if (dwarf_start_die == 0) |
2293 | printf (_("Contents of the %s section:\n\n"), section->name); | |
19e6b90e L |
2294 | |
2295 | load_debug_section (str, file); | |
4723351a CC |
2296 | load_debug_section (str_dwo, file); |
2297 | load_debug_section (str_index, file); | |
2298 | load_debug_section (str_index_dwo, file); | |
2299 | load_debug_section (debug_addr, file); | |
19e6b90e L |
2300 | } |
2301 | ||
6f875884 TG |
2302 | load_debug_section (abbrev_sec, file); |
2303 | if (debug_displays [abbrev_sec].section.start == NULL) | |
19e6b90e L |
2304 | { |
2305 | warn (_("Unable to locate %s section!\n"), | |
6f875884 | 2306 | debug_displays [abbrev_sec].section.name); |
19e6b90e L |
2307 | return 0; |
2308 | } | |
2309 | ||
2310 | for (section_begin = start, unit = 0; start < end; unit++) | |
2311 | { | |
2312 | DWARF2_Internal_CompUnit compunit; | |
2313 | unsigned char *hdrptr; | |
19e6b90e | 2314 | unsigned char *tags; |
fd2f0033 | 2315 | int level, last_level, saved_level; |
467c65bc | 2316 | dwarf_vma cu_offset; |
bf5117e3 | 2317 | unsigned int offset_size; |
19e6b90e | 2318 | int initial_length_size; |
74bc6052 CC |
2319 | dwarf_vma signature_high = 0; |
2320 | dwarf_vma signature_low = 0; | |
767221a9 | 2321 | dwarf_vma type_offset = 0; |
341f9135 CC |
2322 | struct cu_tu_set *this_set; |
2323 | dwarf_vma abbrev_base; | |
2324 | size_t abbrev_size; | |
19e6b90e L |
2325 | |
2326 | hdrptr = start; | |
2327 | ||
0c588247 | 2328 | SAFE_BYTE_GET_AND_INC (compunit.cu_length, hdrptr, 4, end); |
19e6b90e L |
2329 | |
2330 | if (compunit.cu_length == 0xffffffff) | |
2331 | { | |
0c588247 | 2332 | SAFE_BYTE_GET_AND_INC (compunit.cu_length, hdrptr, 8, end); |
19e6b90e L |
2333 | offset_size = 8; |
2334 | initial_length_size = 12; | |
2335 | } | |
2336 | else | |
2337 | { | |
2338 | offset_size = 4; | |
2339 | initial_length_size = 4; | |
2340 | } | |
2341 | ||
0c588247 | 2342 | SAFE_BYTE_GET_AND_INC (compunit.cu_version, hdrptr, 2, end); |
19e6b90e L |
2343 | |
2344 | cu_offset = start - section_begin; | |
19e6b90e | 2345 | |
341f9135 CC |
2346 | this_set = find_cu_tu_set_v2 (cu_offset, do_types); |
2347 | ||
0c588247 | 2348 | SAFE_BYTE_GET_AND_INC (compunit.cu_abbrev_offset, hdrptr, offset_size, end); |
19e6b90e | 2349 | |
341f9135 CC |
2350 | if (this_set == NULL) |
2351 | { | |
2352 | abbrev_base = 0; | |
2353 | abbrev_size = debug_displays [abbrev_sec].section.size; | |
2354 | } | |
2355 | else | |
2356 | { | |
2357 | abbrev_base = this_set->section_offsets [DW_SECT_ABBREV]; | |
2358 | abbrev_size = this_set->section_sizes [DW_SECT_ABBREV]; | |
2359 | } | |
2360 | ||
0c588247 | 2361 | SAFE_BYTE_GET_AND_INC (compunit.cu_pointer_size, hdrptr, 1, end); |
f41e4712 NC |
2362 | /* PR 17512: file: 001-108546-0.001:0.1. */ |
2363 | if (compunit.cu_pointer_size < 2 || compunit.cu_pointer_size > 8) | |
2364 | { | |
2365 | warn (_("Invalid pointer size (%d) in compunit header, using %d instead\n"), | |
2366 | compunit.cu_pointer_size, offset_size); | |
2367 | compunit.cu_pointer_size = offset_size; | |
2368 | } | |
2b6f5997 CC |
2369 | |
2370 | if (do_types) | |
2371 | { | |
0c588247 | 2372 | SAFE_BYTE_GET64 (hdrptr, &signature_high, &signature_low, end); |
f048b142 | 2373 | hdrptr += 8; |
0c588247 | 2374 | SAFE_BYTE_GET_AND_INC (type_offset, hdrptr, offset_size, end); |
2b6f5997 CC |
2375 | } |
2376 | ||
19e6b90e | 2377 | if ((do_loc || do_debug_loc || do_debug_ranges) |
2b6f5997 CC |
2378 | && num_debug_info_entries == 0 |
2379 | && ! do_types) | |
19e6b90e L |
2380 | { |
2381 | debug_information [unit].cu_offset = cu_offset; | |
2382 | debug_information [unit].pointer_size | |
2383 | = compunit.cu_pointer_size; | |
b7807392 JJ |
2384 | debug_information [unit].offset_size = offset_size; |
2385 | debug_information [unit].dwarf_version = compunit.cu_version; | |
19e6b90e | 2386 | debug_information [unit].base_address = 0; |
4723351a CC |
2387 | debug_information [unit].addr_base = DEBUG_INFO_UNAVAILABLE; |
2388 | debug_information [unit].ranges_base = DEBUG_INFO_UNAVAILABLE; | |
19e6b90e L |
2389 | debug_information [unit].loc_offsets = NULL; |
2390 | debug_information [unit].have_frame_base = NULL; | |
2391 | debug_information [unit].max_loc_offsets = 0; | |
2392 | debug_information [unit].num_loc_offsets = 0; | |
2393 | debug_information [unit].range_lists = NULL; | |
2394 | debug_information [unit].max_range_lists= 0; | |
2395 | debug_information [unit].num_range_lists = 0; | |
2396 | } | |
2397 | ||
fd2f0033 | 2398 | if (!do_loc && dwarf_start_die == 0) |
19e6b90e | 2399 | { |
47704ddf KT |
2400 | printf (_(" Compilation Unit @ offset 0x%s:\n"), |
2401 | dwarf_vmatoa ("x", cu_offset)); | |
2402 | printf (_(" Length: 0x%s (%s)\n"), | |
2403 | dwarf_vmatoa ("x", compunit.cu_length), | |
49e7b350 | 2404 | offset_size == 8 ? "64-bit" : "32-bit"); |
19e6b90e | 2405 | printf (_(" Version: %d\n"), compunit.cu_version); |
7282333f AM |
2406 | printf (_(" Abbrev Offset: 0x%s\n"), |
2407 | dwarf_vmatoa ("x", compunit.cu_abbrev_offset)); | |
19e6b90e | 2408 | printf (_(" Pointer Size: %d\n"), compunit.cu_pointer_size); |
2b6f5997 CC |
2409 | if (do_types) |
2410 | { | |
74bc6052 CC |
2411 | char buf[64]; |
2412 | ||
2413 | printf (_(" Signature: 0x%s\n"), | |
2414 | dwarf_vmatoa64 (signature_high, signature_low, | |
2415 | buf, sizeof (buf))); | |
2416 | printf (_(" Type Offset: 0x%s\n"), | |
2417 | dwarf_vmatoa ("x", type_offset)); | |
2b6f5997 | 2418 | } |
341f9135 CC |
2419 | if (this_set != NULL) |
2420 | { | |
2421 | dwarf_vma *offsets = this_set->section_offsets; | |
2422 | size_t *sizes = this_set->section_sizes; | |
2423 | ||
2424 | printf (_(" Section contributions:\n")); | |
2425 | printf (_(" .debug_abbrev.dwo: 0x%s 0x%s\n"), | |
2426 | dwarf_vmatoa ("x", offsets [DW_SECT_ABBREV]), | |
2427 | dwarf_vmatoa ("x", sizes [DW_SECT_ABBREV])); | |
2428 | printf (_(" .debug_line.dwo: 0x%s 0x%s\n"), | |
2429 | dwarf_vmatoa ("x", offsets [DW_SECT_LINE]), | |
2430 | dwarf_vmatoa ("x", sizes [DW_SECT_LINE])); | |
2431 | printf (_(" .debug_loc.dwo: 0x%s 0x%s\n"), | |
2432 | dwarf_vmatoa ("x", offsets [DW_SECT_LOC]), | |
2433 | dwarf_vmatoa ("x", sizes [DW_SECT_LOC])); | |
2434 | printf (_(" .debug_str_offsets.dwo: 0x%s 0x%s\n"), | |
2435 | dwarf_vmatoa ("x", offsets [DW_SECT_STR_OFFSETS]), | |
2436 | dwarf_vmatoa ("x", sizes [DW_SECT_STR_OFFSETS])); | |
2437 | } | |
19e6b90e L |
2438 | } |
2439 | ||
460c89ff NS |
2440 | if (cu_offset + compunit.cu_length + initial_length_size |
2441 | > section->size) | |
2442 | { | |
47704ddf KT |
2443 | warn (_("Debug info is corrupted, length of CU at %s" |
2444 | " extends beyond end of section (length = %s)\n"), | |
2445 | dwarf_vmatoa ("x", cu_offset), | |
2446 | dwarf_vmatoa ("x", compunit.cu_length)); | |
57028622 | 2447 | num_units = unit; |
460c89ff NS |
2448 | break; |
2449 | } | |
2450 | tags = hdrptr; | |
2451 | start += compunit.cu_length + initial_length_size; | |
2452 | ||
57028622 NC |
2453 | if (start > end) |
2454 | { | |
2455 | warn (_("Debug info is corrupt. CU at %s extends beyond end of section"), | |
2456 | dwarf_vmatoa ("x", cu_offset)); | |
2457 | start = end; | |
2458 | } | |
2459 | ||
932fd279 JJ |
2460 | if (compunit.cu_version != 2 |
2461 | && compunit.cu_version != 3 | |
2462 | && compunit.cu_version != 4) | |
19e6b90e | 2463 | { |
47704ddf KT |
2464 | warn (_("CU at offset %s contains corrupt or " |
2465 | "unsupported version number: %d.\n"), | |
2466 | dwarf_vmatoa ("x", cu_offset), compunit.cu_version); | |
19e6b90e L |
2467 | continue; |
2468 | } | |
2469 | ||
2470 | free_abbrevs (); | |
2471 | ||
d493b283 | 2472 | /* Process the abbrevs used by this compilation unit. */ |
341f9135 | 2473 | if (compunit.cu_abbrev_offset >= abbrev_size) |
ec4d4525 NC |
2474 | warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"), |
2475 | (unsigned long) compunit.cu_abbrev_offset, | |
341f9135 | 2476 | (unsigned long) abbrev_size); |
72c61a0d | 2477 | /* PR 17531: file:4bcd9ce9. */ |
a0a3b04c L |
2478 | else if ((abbrev_base + abbrev_size) |
2479 | > debug_displays [abbrev_sec].section.size) | |
2480 | warn (_("Debug info is corrupted, abbrev size (%lx) is larger than abbrev section size (%lx)\n"), | |
2481 | (unsigned long) abbrev_base + abbrev_size, | |
2482 | (unsigned long) debug_displays [abbrev_sec].section.size); | |
460c89ff NS |
2483 | else |
2484 | process_abbrev_section | |
341f9135 CC |
2485 | (((unsigned char *) debug_displays [abbrev_sec].section.start |
2486 | + abbrev_base + compunit.cu_abbrev_offset), | |
2487 | ((unsigned char *) debug_displays [abbrev_sec].section.start | |
2488 | + abbrev_base + abbrev_size)); | |
19e6b90e L |
2489 | |
2490 | level = 0; | |
fd2f0033 TT |
2491 | last_level = level; |
2492 | saved_level = -1; | |
19e6b90e L |
2493 | while (tags < start) |
2494 | { | |
2495 | unsigned int bytes_read; | |
2496 | unsigned long abbrev_number; | |
ec4d4525 | 2497 | unsigned long die_offset; |
19e6b90e L |
2498 | abbrev_entry *entry; |
2499 | abbrev_attr *attr; | |
fd2f0033 | 2500 | int do_printing = 1; |
19e6b90e | 2501 | |
ec4d4525 NC |
2502 | die_offset = tags - section_begin; |
2503 | ||
f6f0e17b | 2504 | abbrev_number = read_uleb128 (tags, & bytes_read, start); |
19e6b90e L |
2505 | tags += bytes_read; |
2506 | ||
eb7cc021 JK |
2507 | /* A null DIE marks the end of a list of siblings or it may also be |
2508 | a section padding. */ | |
19e6b90e L |
2509 | if (abbrev_number == 0) |
2510 | { | |
eb7cc021 JK |
2511 | /* Check if it can be a section padding for the last CU. */ |
2512 | if (level == 0 && start == end) | |
2513 | { | |
2514 | unsigned char *chk; | |
2515 | ||
2516 | for (chk = tags; chk < start; chk++) | |
2517 | if (*chk != 0) | |
2518 | break; | |
2519 | if (chk == start) | |
2520 | break; | |
2521 | } | |
2522 | ||
4337774f TT |
2523 | if (!do_loc && die_offset >= dwarf_start_die |
2524 | && (dwarf_cutoff_level == -1 | |
2525 | || level < dwarf_cutoff_level)) | |
399c99f7 L |
2526 | printf (_(" <%d><%lx>: Abbrev Number: 0\n"), |
2527 | level, die_offset); | |
2528 | ||
19e6b90e | 2529 | --level; |
ec4d4525 NC |
2530 | if (level < 0) |
2531 | { | |
2532 | static unsigned num_bogus_warns = 0; | |
2533 | ||
2534 | if (num_bogus_warns < 3) | |
2535 | { | |
4723351a CC |
2536 | warn (_("Bogus end-of-siblings marker detected at offset %lx in %s section\n"), |
2537 | die_offset, section->name); | |
ec4d4525 NC |
2538 | num_bogus_warns ++; |
2539 | if (num_bogus_warns == 3) | |
2540 | warn (_("Further warnings about bogus end-of-sibling markers suppressed\n")); | |
2541 | } | |
2542 | } | |
fd2f0033 TT |
2543 | if (dwarf_start_die != 0 && level < saved_level) |
2544 | return 1; | |
19e6b90e L |
2545 | continue; |
2546 | } | |
2547 | ||
4b78141a | 2548 | if (!do_loc) |
fd2f0033 TT |
2549 | { |
2550 | if (dwarf_start_die != 0 && die_offset < dwarf_start_die) | |
2551 | do_printing = 0; | |
2552 | else | |
2553 | { | |
2554 | if (dwarf_start_die != 0 && die_offset == dwarf_start_die) | |
2555 | saved_level = level; | |
2556 | do_printing = (dwarf_cutoff_level == -1 | |
2557 | || level < dwarf_cutoff_level); | |
2558 | if (do_printing) | |
2559 | printf (_(" <%d><%lx>: Abbrev Number: %lu"), | |
2560 | level, die_offset, abbrev_number); | |
2561 | else if (dwarf_cutoff_level == -1 | |
2562 | || last_level < dwarf_cutoff_level) | |
2563 | printf (_(" <%d><%lx>: ...\n"), level, die_offset); | |
2564 | last_level = level; | |
2565 | } | |
2566 | } | |
cecf136e | 2567 | |
19e6b90e L |
2568 | /* Scan through the abbreviation list until we reach the |
2569 | correct entry. */ | |
2570 | for (entry = first_abbrev; | |
2571 | entry && entry->entry != abbrev_number; | |
2572 | entry = entry->next) | |
2573 | continue; | |
2574 | ||
2575 | if (entry == NULL) | |
2576 | { | |
fd2f0033 | 2577 | if (!do_loc && do_printing) |
4b78141a NC |
2578 | { |
2579 | printf ("\n"); | |
2580 | fflush (stdout); | |
2581 | } | |
cc86f28f NC |
2582 | warn (_("DIE at offset %lx refers to abbreviation number %lu which does not exist\n"), |
2583 | die_offset, abbrev_number); | |
19e6b90e L |
2584 | return 0; |
2585 | } | |
2586 | ||
fd2f0033 | 2587 | if (!do_loc && do_printing) |
cc5914eb | 2588 | printf (" (%s)\n", get_TAG_name (entry->tag)); |
cecf136e | 2589 | |
19e6b90e L |
2590 | switch (entry->tag) |
2591 | { | |
2592 | default: | |
2593 | need_base_address = 0; | |
2594 | break; | |
2595 | case DW_TAG_compile_unit: | |
2596 | need_base_address = 1; | |
2597 | break; | |
2598 | case DW_TAG_entry_point: | |
19e6b90e L |
2599 | case DW_TAG_subprogram: |
2600 | need_base_address = 0; | |
2601 | /* Assuming that there is no DW_AT_frame_base. */ | |
2602 | have_frame_base = 0; | |
2603 | break; | |
2604 | } | |
2605 | ||
399c99f7 L |
2606 | for (attr = entry->first_attr; |
2607 | attr && attr->attribute; | |
2608 | attr = attr->next) | |
4b78141a | 2609 | { |
fd2f0033 TT |
2610 | debug_info *arg; |
2611 | ||
2612 | if (! do_loc && do_printing) | |
4b78141a | 2613 | /* Show the offset from where the tag was extracted. */ |
fd2f0033 TT |
2614 | printf (" <%lx>", (unsigned long)(tags - section_begin)); |
2615 | ||
82b1b41b NC |
2616 | if (debug_information && unit < alloc_num_debug_info_entries) |
2617 | arg = debug_information + unit; | |
2618 | else | |
2619 | arg = NULL; | |
2620 | ||
4b78141a NC |
2621 | tags = read_and_display_attr (attr->attribute, |
2622 | attr->form, | |
341f9135 | 2623 | tags, |
f6f0e17b | 2624 | end, |
341f9135 | 2625 | cu_offset, |
4b78141a NC |
2626 | compunit.cu_pointer_size, |
2627 | offset_size, | |
2628 | compunit.cu_version, | |
fd2f0033 | 2629 | arg, |
341f9135 CC |
2630 | do_loc || ! do_printing, |
2631 | section, | |
2632 | this_set); | |
4b78141a | 2633 | } |
cecf136e | 2634 | |
19e6b90e L |
2635 | if (entry->children) |
2636 | ++level; | |
2637 | } | |
2638 | } | |
cecf136e | 2639 | |
19e6b90e L |
2640 | /* Set num_debug_info_entries here so that it can be used to check if |
2641 | we need to process .debug_loc and .debug_ranges sections. */ | |
2642 | if ((do_loc || do_debug_loc || do_debug_ranges) | |
2b6f5997 CC |
2643 | && num_debug_info_entries == 0 |
2644 | && ! do_types) | |
82b1b41b NC |
2645 | { |
2646 | if (num_units > alloc_num_debug_info_entries) | |
2647 | num_debug_info_entries = alloc_num_debug_info_entries; | |
2648 | else | |
2649 | num_debug_info_entries = num_units; | |
2650 | } | |
cecf136e | 2651 | |
19e6b90e | 2652 | if (!do_loc) |
467c65bc | 2653 | printf ("\n"); |
cecf136e | 2654 | |
19e6b90e L |
2655 | return 1; |
2656 | } | |
2657 | ||
2658 | /* Locate and scan the .debug_info section in the file and record the pointer | |
2659 | sizes and offsets for the compilation units in it. Usually an executable | |
2660 | will have just one pointer size, but this is not guaranteed, and so we try | |
2661 | not to make any assumptions. Returns zero upon failure, or the number of | |
2662 | compilation units upon success. */ | |
2663 | ||
2664 | static unsigned int | |
2665 | load_debug_info (void * file) | |
2666 | { | |
2667 | /* Reset the last pointer size so that we can issue correct error | |
2668 | messages if we are displaying the contents of more than one section. */ | |
2669 | last_pointer_size = 0; | |
2670 | warned_about_missing_comp_units = FALSE; | |
2671 | ||
1febe64d | 2672 | /* If we have already tried and failed to load the .debug_info |
657d0d47 | 2673 | section then do not bother to repeat the task. */ |
cc86f28f | 2674 | if (num_debug_info_entries == DEBUG_INFO_UNAVAILABLE) |
1febe64d NC |
2675 | return 0; |
2676 | ||
19e6b90e L |
2677 | /* If we already have the information there is nothing else to do. */ |
2678 | if (num_debug_info_entries > 0) | |
2679 | return num_debug_info_entries; | |
2680 | ||
341f9135 CC |
2681 | /* If this is a DWARF package file, load the CU and TU indexes. */ |
2682 | load_cu_tu_indexes (file); | |
2683 | ||
19e6b90e | 2684 | if (load_debug_section (info, file) |
6f875884 | 2685 | && process_debug_info (&debug_displays [info].section, file, abbrev, 1, 0)) |
19e6b90e | 2686 | return num_debug_info_entries; |
82b1b41b NC |
2687 | |
2688 | if (load_debug_section (info_dwo, file) | |
2689 | && process_debug_info (&debug_displays [info_dwo].section, file, | |
2690 | abbrev_dwo, 1, 0)) | |
4723351a | 2691 | return num_debug_info_entries; |
1febe64d | 2692 | |
cc86f28f | 2693 | num_debug_info_entries = DEBUG_INFO_UNAVAILABLE; |
1febe64d | 2694 | return 0; |
19e6b90e L |
2695 | } |
2696 | ||
b40bf0a2 NC |
2697 | /* Read a DWARF .debug_line section header starting at DATA. |
2698 | Upon success returns an updated DATA pointer and the LINFO | |
2699 | structure and the END_OF_SEQUENCE pointer will be filled in. | |
2700 | Otherwise returns NULL. */ | |
19e6b90e | 2701 | |
b40bf0a2 NC |
2702 | static unsigned char * |
2703 | read_debug_line_header (struct dwarf_section * section, | |
2704 | unsigned char * data, | |
2705 | unsigned char * end, | |
2706 | DWARF2_Internal_LineInfo * linfo, | |
2707 | unsigned char ** end_of_sequence) | |
2708 | { | |
2709 | unsigned char *hdrptr; | |
2710 | unsigned int offset_size; | |
2711 | unsigned int initial_length_size; | |
19e6b90e | 2712 | |
b40bf0a2 NC |
2713 | /* Extract information from the Line Number Program Header. |
2714 | (section 6.2.4 in the Dwarf3 doc). */ | |
6937bb54 | 2715 | hdrptr = data; |
19e6b90e | 2716 | |
b40bf0a2 NC |
2717 | /* Get and check the length of the block. */ |
2718 | SAFE_BYTE_GET_AND_INC (linfo->li_length, hdrptr, 4, end); | |
19e6b90e | 2719 | |
b40bf0a2 | 2720 | if (linfo->li_length == 0xffffffff) |
f41e4712 NC |
2721 | { |
2722 | /* This section is 64-bit DWARF 3. */ | |
b40bf0a2 | 2723 | SAFE_BYTE_GET_AND_INC (linfo->li_length, hdrptr, 8, end); |
f41e4712 NC |
2724 | offset_size = 8; |
2725 | initial_length_size = 12; | |
2726 | } | |
2727 | else | |
2728 | { | |
2729 | offset_size = 4; | |
2730 | initial_length_size = 4; | |
2731 | } | |
19e6b90e | 2732 | |
b40bf0a2 | 2733 | if (linfo->li_length + initial_length_size > section->size) |
f41e4712 | 2734 | { |
b40bf0a2 NC |
2735 | /* If the length is just a bias against the initial_length_size then |
2736 | this means that the field has a relocation against it which has not | |
2737 | been applied. (Ie we are dealing with an object file, not a linked | |
2738 | binary). Do not complain but instead assume that the rest of the | |
2739 | section applies to this particular header. */ | |
2740 | if (linfo->li_length == - initial_length_size) | |
2741 | { | |
2742 | linfo->li_length = section->size - initial_length_size; | |
2743 | } | |
2744 | else | |
2745 | { | |
f41e4712 | 2746 | warn (_("The line info appears to be corrupt - the section is too small\n")); |
b40bf0a2 NC |
2747 | return NULL; |
2748 | } | |
f41e4712 | 2749 | } |
19e6b90e | 2750 | |
b40bf0a2 NC |
2751 | /* Get and check the version number. */ |
2752 | SAFE_BYTE_GET_AND_INC (linfo->li_version, hdrptr, 2, end); | |
2753 | ||
2754 | if (linfo->li_version != 2 | |
2755 | && linfo->li_version != 3 | |
2756 | && linfo->li_version != 4) | |
f41e4712 NC |
2757 | { |
2758 | warn (_("Only DWARF version 2, 3 and 4 line info is currently supported.\n")); | |
b40bf0a2 | 2759 | return NULL; |
f41e4712 | 2760 | } |
19e6b90e | 2761 | |
b40bf0a2 NC |
2762 | SAFE_BYTE_GET_AND_INC (linfo->li_prologue_length, hdrptr, offset_size, end); |
2763 | SAFE_BYTE_GET_AND_INC (linfo->li_min_insn_length, hdrptr, 1, end); | |
0c588247 | 2764 | |
b40bf0a2 | 2765 | if (linfo->li_version >= 4) |
f41e4712 | 2766 | { |
b40bf0a2 | 2767 | SAFE_BYTE_GET_AND_INC (linfo->li_max_ops_per_insn, hdrptr, 1, end); |
0c588247 | 2768 | |
b40bf0a2 | 2769 | if (linfo->li_max_ops_per_insn == 0) |
f41e4712 NC |
2770 | { |
2771 | warn (_("Invalid maximum operations per insn.\n")); | |
b40bf0a2 | 2772 | return NULL; |
a233b20c | 2773 | } |
f41e4712 NC |
2774 | } |
2775 | else | |
b40bf0a2 | 2776 | linfo->li_max_ops_per_insn = 1; |
0c588247 | 2777 | |
b40bf0a2 | 2778 | SAFE_BYTE_GET_AND_INC (linfo->li_default_is_stmt, hdrptr, 1, end); |
65879393 | 2779 | SAFE_SIGNED_BYTE_GET_AND_INC (linfo->li_line_base, hdrptr, 1, end); |
b40bf0a2 NC |
2780 | SAFE_BYTE_GET_AND_INC (linfo->li_line_range, hdrptr, 1, end); |
2781 | SAFE_BYTE_GET_AND_INC (linfo->li_opcode_base, hdrptr, 1, end); | |
19e6b90e | 2782 | |
b40bf0a2 | 2783 | * end_of_sequence = data + linfo->li_length + initial_length_size; |
6937bb54 NC |
2784 | /* PR 17512: file:002-117414-0.004. */ |
2785 | if (* end_of_sequence > end) | |
2786 | { | |
4c219c2e AM |
2787 | warn (_("Line length %s extends beyond end of section\n"), |
2788 | dwarf_vmatoa ("u", linfo->li_length)); | |
6937bb54 NC |
2789 | * end_of_sequence = end; |
2790 | return NULL; | |
2791 | } | |
2792 | ||
b40bf0a2 NC |
2793 | return hdrptr; |
2794 | } | |
19e6b90e | 2795 | |
b40bf0a2 NC |
2796 | static int |
2797 | display_debug_lines_raw (struct dwarf_section *section, | |
2798 | unsigned char *data, | |
2799 | unsigned char *end) | |
2800 | { | |
2801 | unsigned char *start = section->start; | |
19e6b90e | 2802 | |
b40bf0a2 NC |
2803 | printf (_("Raw dump of debug contents of section %s:\n\n"), |
2804 | section->name); | |
19e6b90e | 2805 | |
b40bf0a2 NC |
2806 | while (data < end) |
2807 | { | |
2808 | static DWARF2_Internal_LineInfo saved_linfo; | |
2809 | DWARF2_Internal_LineInfo linfo; | |
2810 | unsigned char *standard_opcodes; | |
2811 | unsigned char *end_of_sequence; | |
fe59e83d CC |
2812 | unsigned int last_dir_entry = 0; |
2813 | int i; | |
19e6b90e | 2814 | |
4925cdd7 NC |
2815 | if (const_strneq (section->name, ".debug_line.") |
2816 | /* Note: the following does not apply to .debug_line.dwo sections. | |
2817 | These are full debug_line sections. */ | |
2818 | && strcmp (section->name, ".debug_line.dwo") != 0) | |
19e6b90e | 2819 | { |
b40bf0a2 NC |
2820 | /* Sections named .debug_line.<foo> are fragments of a .debug_line |
2821 | section containing just the Line Number Statements. They are | |
2822 | created by the assembler and intended to be used alongside gcc's | |
2823 | -ffunction-sections command line option. When the linker's | |
2824 | garbage collection decides to discard a .text.<foo> section it | |
2825 | can then also discard the line number information in .debug_line.<foo>. | |
2826 | ||
4925cdd7 | 2827 | Since the section is a fragment it does not have the details |
b40bf0a2 | 2828 | needed to fill out a LineInfo structure, so instead we use the |
4925cdd7 | 2829 | details from the last full debug_line section that we processed. */ |
b40bf0a2 NC |
2830 | end_of_sequence = end; |
2831 | standard_opcodes = NULL; | |
2832 | linfo = saved_linfo; | |
058037d3 NC |
2833 | /* PR 17531: file: 0522b371. */ |
2834 | if (linfo.li_line_range == 0) | |
2835 | { | |
1306a742 | 2836 | warn (_("Partial .debug_line. section encountered without a prior full .debug_line section\n")); |
058037d3 NC |
2837 | return 0; |
2838 | } | |
b40bf0a2 | 2839 | reset_state_machine (linfo.li_default_is_stmt); |
19e6b90e | 2840 | } |
19e6b90e L |
2841 | else |
2842 | { | |
b40bf0a2 | 2843 | unsigned char * hdrptr; |
19e6b90e | 2844 | |
b40bf0a2 NC |
2845 | if ((hdrptr = read_debug_line_header (section, data, end, & linfo, |
2846 | & end_of_sequence)) == NULL) | |
2847 | return 0; | |
19e6b90e | 2848 | |
b40bf0a2 NC |
2849 | printf (_(" Offset: 0x%lx\n"), (long)(data - start)); |
2850 | printf (_(" Length: %ld\n"), (long) linfo.li_length); | |
2851 | printf (_(" DWARF Version: %d\n"), linfo.li_version); | |
2852 | printf (_(" Prologue Length: %d\n"), linfo.li_prologue_length); | |
2853 | printf (_(" Minimum Instruction Length: %d\n"), linfo.li_min_insn_length); | |
2854 | if (linfo.li_version >= 4) | |
2855 | printf (_(" Maximum Ops per Instruction: %d\n"), linfo.li_max_ops_per_insn); | |
2856 | printf (_(" Initial value of 'is_stmt': %d\n"), linfo.li_default_is_stmt); | |
2857 | printf (_(" Line Base: %d\n"), linfo.li_line_base); | |
2858 | printf (_(" Line Range: %d\n"), linfo.li_line_range); | |
2859 | printf (_(" Opcode Base: %d\n"), linfo.li_opcode_base); | |
19e6b90e | 2860 | |
0a9d414a NC |
2861 | /* PR 17512: file: 1665-6428-0.004. */ |
2862 | if (linfo.li_line_range == 0) | |
2863 | { | |
2864 | warn (_("Line range of 0 is invalid, using 1 instead\n")); | |
2865 | linfo.li_line_range = 1; | |
2866 | } | |
058037d3 | 2867 | |
b40bf0a2 | 2868 | reset_state_machine (linfo.li_default_is_stmt); |
19e6b90e | 2869 | |
b40bf0a2 NC |
2870 | /* Display the contents of the Opcodes table. */ |
2871 | standard_opcodes = hdrptr; | |
19e6b90e | 2872 | |
6937bb54 NC |
2873 | /* PR 17512: file: 002-417945-0.004. */ |
2874 | if (standard_opcodes + linfo.li_opcode_base >= end) | |
2875 | { | |
2876 | warn (_("Line Base extends beyond end of section\n")); | |
2877 | return 0; | |
2878 | } | |
2879 | ||
b40bf0a2 | 2880 | printf (_("\n Opcodes:\n")); |
19e6b90e | 2881 | |
b40bf0a2 NC |
2882 | for (i = 1; i < linfo.li_opcode_base; i++) |
2883 | printf (_(" Opcode %d has %d args\n"), i, standard_opcodes[i - 1]); | |
19e6b90e | 2884 | |
b40bf0a2 NC |
2885 | /* Display the contents of the Directory table. */ |
2886 | data = standard_opcodes + linfo.li_opcode_base - 1; | |
19e6b90e | 2887 | |
b40bf0a2 NC |
2888 | if (*data == 0) |
2889 | printf (_("\n The Directory Table is empty.\n")); | |
2890 | else | |
2891 | { | |
fe59e83d CC |
2892 | printf (_("\n The Directory Table (offset 0x%lx):\n"), |
2893 | (long)(data - start)); | |
19e6b90e | 2894 | |
6937bb54 | 2895 | while (data < end && *data != 0) |
a233b20c | 2896 | { |
6937bb54 | 2897 | printf (" %d\t%.*s\n", ++last_dir_entry, (int) (end - data), data); |
b40bf0a2 NC |
2898 | |
2899 | data += strnlen ((char *) data, end - data) + 1; | |
a233b20c | 2900 | } |
6937bb54 NC |
2901 | |
2902 | /* PR 17512: file: 002-132094-0.004. */ | |
2903 | if (data >= end - 1) | |
2904 | break; | |
b40bf0a2 | 2905 | } |
19e6b90e | 2906 | |
b40bf0a2 NC |
2907 | /* Skip the NUL at the end of the table. */ |
2908 | data++; | |
19e6b90e | 2909 | |
b40bf0a2 NC |
2910 | /* Display the contents of the File Name table. */ |
2911 | if (*data == 0) | |
2912 | printf (_("\n The File Name Table is empty.\n")); | |
2913 | else | |
2914 | { | |
fe59e83d CC |
2915 | printf (_("\n The File Name Table (offset 0x%lx):\n"), |
2916 | (long)(data - start)); | |
b40bf0a2 | 2917 | printf (_(" Entry\tDir\tTime\tSize\tName\n")); |
19e6b90e | 2918 | |
6937bb54 | 2919 | while (data < end && *data != 0) |
b40bf0a2 NC |
2920 | { |
2921 | unsigned char *name; | |
2922 | unsigned int bytes_read; | |
19e6b90e | 2923 | |
b40bf0a2 NC |
2924 | printf (" %d\t", ++state_machine_regs.last_file_entry); |
2925 | name = data; | |
2926 | data += strnlen ((char *) data, end - data) + 1; | |
19e6b90e | 2927 | |
b40bf0a2 NC |
2928 | printf ("%s\t", |
2929 | dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); | |
2930 | data += bytes_read; | |
2931 | printf ("%s\t", | |
2932 | dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); | |
2933 | data += bytes_read; | |
2934 | printf ("%s\t", | |
2935 | dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); | |
2936 | data += bytes_read; | |
6937bb54 | 2937 | printf ("%.*s\n", (int)(end - name), name); |
19e6b90e | 2938 | |
b40bf0a2 NC |
2939 | if (data == end) |
2940 | { | |
2941 | warn (_("Corrupt file name table entry\n")); | |
2942 | break; | |
2943 | } | |
a233b20c | 2944 | } |
b40bf0a2 | 2945 | } |
19e6b90e | 2946 | |
b40bf0a2 NC |
2947 | /* Skip the NUL at the end of the table. */ |
2948 | data++; | |
2949 | putchar ('\n'); | |
2950 | saved_linfo = linfo; | |
2951 | } | |
19e6b90e | 2952 | |
b40bf0a2 NC |
2953 | /* Now display the statements. */ |
2954 | if (data >= end_of_sequence) | |
2955 | printf (_(" No Line Number Statements.\n")); | |
2956 | else | |
2957 | { | |
2958 | printf (_(" Line Number Statements:\n")); | |
19e6b90e | 2959 | |
b40bf0a2 NC |
2960 | while (data < end_of_sequence) |
2961 | { | |
2962 | unsigned char op_code; | |
2963 | dwarf_signed_vma adv; | |
2964 | dwarf_vma uladv; | |
2965 | unsigned int bytes_read; | |
19e6b90e | 2966 | |
fe59e83d CC |
2967 | printf (" [0x%08lx]", (long)(data - start)); |
2968 | ||
b40bf0a2 | 2969 | op_code = *data++; |
19e6b90e | 2970 | |
b40bf0a2 | 2971 | if (op_code >= linfo.li_opcode_base) |
19e6b90e | 2972 | { |
b40bf0a2 NC |
2973 | op_code -= linfo.li_opcode_base; |
2974 | uladv = (op_code / linfo.li_line_range); | |
2975 | if (linfo.li_max_ops_per_insn == 1) | |
2976 | { | |
2977 | uladv *= linfo.li_min_insn_length; | |
2978 | state_machine_regs.address += uladv; | |
2979 | printf (_(" Special opcode %d: " | |
2980 | "advance Address by %s to 0x%s"), | |
2981 | op_code, dwarf_vmatoa ("u", uladv), | |
2982 | dwarf_vmatoa ("x", state_machine_regs.address)); | |
2983 | } | |
2984 | else | |
2985 | { | |
2986 | state_machine_regs.address | |
2987 | += ((state_machine_regs.op_index + uladv) | |
2988 | / linfo.li_max_ops_per_insn) | |
2989 | * linfo.li_min_insn_length; | |
2990 | state_machine_regs.op_index | |
2991 | = (state_machine_regs.op_index + uladv) | |
2992 | % linfo.li_max_ops_per_insn; | |
2993 | printf (_(" Special opcode %d: " | |
2994 | "advance Address by %s to 0x%s[%d]"), | |
2995 | op_code, dwarf_vmatoa ("u", uladv), | |
2996 | dwarf_vmatoa ("x", state_machine_regs.address), | |
2997 | state_machine_regs.op_index); | |
2998 | } | |
2999 | adv = (op_code % linfo.li_line_range) + linfo.li_line_base; | |
3000 | state_machine_regs.line += adv; | |
3001 | printf (_(" and Line by %s to %d\n"), | |
3002 | dwarf_vmatoa ("d", adv), state_machine_regs.line); | |
19e6b90e | 3003 | } |
b40bf0a2 NC |
3004 | else switch (op_code) |
3005 | { | |
3006 | case DW_LNS_extended_op: | |
3007 | data += process_extended_line_op (data, linfo.li_default_is_stmt, end); | |
3008 | break; | |
3009 | ||
3010 | case DW_LNS_copy: | |
3011 | printf (_(" Copy\n")); | |
3012 | break; | |
3013 | ||
3014 | case DW_LNS_advance_pc: | |
3015 | uladv = read_uleb128 (data, & bytes_read, end); | |
3016 | data += bytes_read; | |
3017 | if (linfo.li_max_ops_per_insn == 1) | |
3018 | { | |
3019 | uladv *= linfo.li_min_insn_length; | |
3020 | state_machine_regs.address += uladv; | |
3021 | printf (_(" Advance PC by %s to 0x%s\n"), | |
3022 | dwarf_vmatoa ("u", uladv), | |
3023 | dwarf_vmatoa ("x", state_machine_regs.address)); | |
3024 | } | |
3025 | else | |
3026 | { | |
3027 | state_machine_regs.address | |
3028 | += ((state_machine_regs.op_index + uladv) | |
3029 | / linfo.li_max_ops_per_insn) | |
3030 | * linfo.li_min_insn_length; | |
3031 | state_machine_regs.op_index | |
3032 | = (state_machine_regs.op_index + uladv) | |
3033 | % linfo.li_max_ops_per_insn; | |
3034 | printf (_(" Advance PC by %s to 0x%s[%d]\n"), | |
3035 | dwarf_vmatoa ("u", uladv), | |
3036 | dwarf_vmatoa ("x", state_machine_regs.address), | |
3037 | state_machine_regs.op_index); | |
3038 | } | |
3039 | break; | |
3040 | ||
3041 | case DW_LNS_advance_line: | |
3042 | adv = read_sleb128 (data, & bytes_read, end); | |
3043 | data += bytes_read; | |
3044 | state_machine_regs.line += adv; | |
3045 | printf (_(" Advance Line by %s to %d\n"), | |
3046 | dwarf_vmatoa ("d", adv), | |
3047 | state_machine_regs.line); | |
3048 | break; | |
3049 | ||
3050 | case DW_LNS_set_file: | |
3051 | adv = read_uleb128 (data, & bytes_read, end); | |
3052 | data += bytes_read; | |
3053 | printf (_(" Set File Name to entry %s in the File Name Table\n"), | |
3054 | dwarf_vmatoa ("d", adv)); | |
3055 | state_machine_regs.file = adv; | |
3056 | break; | |
3057 | ||
3058 | case DW_LNS_set_column: | |
3059 | uladv = read_uleb128 (data, & bytes_read, end); | |
3060 | data += bytes_read; | |
3061 | printf (_(" Set column to %s\n"), | |
3062 | dwarf_vmatoa ("u", uladv)); | |
3063 | state_machine_regs.column = uladv; | |
3064 | break; | |
3065 | ||
3066 | case DW_LNS_negate_stmt: | |
3067 | adv = state_machine_regs.is_stmt; | |
3068 | adv = ! adv; | |
3069 | printf (_(" Set is_stmt to %s\n"), dwarf_vmatoa ("d", adv)); | |
3070 | state_machine_regs.is_stmt = adv; | |
3071 | break; | |
3072 | ||
3073 | case DW_LNS_set_basic_block: | |
3074 | printf (_(" Set basic block\n")); | |
3075 | state_machine_regs.basic_block = 1; | |
3076 | break; | |
3077 | ||
3078 | case DW_LNS_const_add_pc: | |
3079 | uladv = ((255 - linfo.li_opcode_base) / linfo.li_line_range); | |
3080 | if (linfo.li_max_ops_per_insn) | |
3081 | { | |
3082 | uladv *= linfo.li_min_insn_length; | |
3083 | state_machine_regs.address += uladv; | |
3084 | printf (_(" Advance PC by constant %s to 0x%s\n"), | |
3085 | dwarf_vmatoa ("u", uladv), | |
3086 | dwarf_vmatoa ("x", state_machine_regs.address)); | |
3087 | } | |
3088 | else | |
3089 | { | |
3090 | state_machine_regs.address | |
3091 | += ((state_machine_regs.op_index + uladv) | |
3092 | / linfo.li_max_ops_per_insn) | |
3093 | * linfo.li_min_insn_length; | |
3094 | state_machine_regs.op_index | |
3095 | = (state_machine_regs.op_index + uladv) | |
3096 | % linfo.li_max_ops_per_insn; | |
3097 | printf (_(" Advance PC by constant %s to 0x%s[%d]\n"), | |
3098 | dwarf_vmatoa ("u", uladv), | |
3099 | dwarf_vmatoa ("x", state_machine_regs.address), | |
3100 | state_machine_regs.op_index); | |
3101 | } | |
3102 | break; | |
3103 | ||
3104 | case DW_LNS_fixed_advance_pc: | |
3105 | SAFE_BYTE_GET_AND_INC (uladv, data, 2, end); | |
3106 | state_machine_regs.address += uladv; | |
3107 | state_machine_regs.op_index = 0; | |
3108 | printf (_(" Advance PC by fixed size amount %s to 0x%s\n"), | |
3109 | dwarf_vmatoa ("u", uladv), | |
3110 | dwarf_vmatoa ("x", state_machine_regs.address)); | |
3111 | break; | |
3112 | ||
3113 | case DW_LNS_set_prologue_end: | |
3114 | printf (_(" Set prologue_end to true\n")); | |
3115 | break; | |
3116 | ||
3117 | case DW_LNS_set_epilogue_begin: | |
3118 | printf (_(" Set epilogue_begin to true\n")); | |
3119 | break; | |
3120 | ||
3121 | case DW_LNS_set_isa: | |
3122 | uladv = read_uleb128 (data, & bytes_read, end); | |
3123 | data += bytes_read; | |
3124 | printf (_(" Set ISA to %s\n"), dwarf_vmatoa ("u", uladv)); | |
3125 | break; | |
3126 | ||
3127 | default: | |
3128 | printf (_(" Unknown opcode %d with operands: "), op_code); | |
3129 | ||
3130 | if (standard_opcodes != NULL) | |
3131 | for (i = standard_opcodes[op_code - 1]; i > 0 ; --i) | |
3132 | { | |
3133 | printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data, | |
3134 | &bytes_read, end)), | |
3135 | i == 1 ? "" : ", "); | |
3136 | data += bytes_read; | |
3137 | } | |
3138 | putchar ('\n'); | |
3139 | break; | |
3140 | } | |
19e6b90e | 3141 | } |
b40bf0a2 | 3142 | putchar ('\n'); |
19e6b90e | 3143 | } |
19e6b90e L |
3144 | } |
3145 | ||
3146 | return 1; | |
3147 | } | |
3148 | ||
a262ae96 NC |
3149 | typedef struct |
3150 | { | |
467c65bc NC |
3151 | unsigned char *name; |
3152 | unsigned int directory_index; | |
3153 | unsigned int modification_date; | |
3154 | unsigned int length; | |
a262ae96 NC |
3155 | } File_Entry; |
3156 | ||
3157 | /* Output a decoded representation of the .debug_line section. */ | |
3158 | ||
3159 | static int | |
3160 | display_debug_lines_decoded (struct dwarf_section *section, | |
3161 | unsigned char *data, | |
3162 | unsigned char *end) | |
3163 | { | |
b40bf0a2 NC |
3164 | static DWARF2_Internal_LineInfo saved_linfo; |
3165 | ||
a262ae96 NC |
3166 | printf (_("Decoded dump of debug contents of section %s:\n\n"), |
3167 | section->name); | |
3168 | ||
3169 | while (data < end) | |
3170 | { | |
3171 | /* This loop amounts to one iteration per compilation unit. */ | |
91d6fa6a | 3172 | DWARF2_Internal_LineInfo linfo; |
a262ae96 NC |
3173 | unsigned char *standard_opcodes; |
3174 | unsigned char *end_of_sequence; | |
a262ae96 NC |
3175 | int i; |
3176 | File_Entry *file_table = NULL; | |
143a3db0 | 3177 | unsigned int n_files = 0; |
a262ae96 | 3178 | unsigned char **directory_table = NULL; |
143a3db0 | 3179 | unsigned int n_directories = 0; |
a262ae96 | 3180 | |
4925cdd7 NC |
3181 | if (const_strneq (section->name, ".debug_line.") |
3182 | /* Note: the following does not apply to .debug_line.dwo sections. | |
3183 | These are full debug_line sections. */ | |
3184 | && strcmp (section->name, ".debug_line.dwo") != 0) | |
a262ae96 | 3185 | { |
4925cdd7 | 3186 | /* See comment in display_debug_lines_raw(). */ |
b40bf0a2 NC |
3187 | end_of_sequence = end; |
3188 | standard_opcodes = NULL; | |
3189 | linfo = saved_linfo; | |
058037d3 NC |
3190 | /* PR 17531: file: 0522b371. */ |
3191 | if (linfo.li_line_range == 0) | |
3192 | { | |
1306a742 | 3193 | warn (_("Partial .debug_line. section encountered without a prior full .debug_line section\n")); |
058037d3 NC |
3194 | return 0; |
3195 | } | |
b40bf0a2 | 3196 | reset_state_machine (linfo.li_default_is_stmt); |
a262ae96 NC |
3197 | } |
3198 | else | |
3199 | { | |
b40bf0a2 | 3200 | unsigned char *hdrptr; |
a262ae96 | 3201 | |
b40bf0a2 NC |
3202 | if ((hdrptr = read_debug_line_header (section, data, end, & linfo, |
3203 | & end_of_sequence)) == NULL) | |
a233b20c | 3204 | return 0; |
0c588247 | 3205 | |
058037d3 NC |
3206 | /* PR 17531: file: 0522b371. */ |
3207 | if (linfo.li_line_range == 0) | |
3208 | { | |
3209 | warn (_("Line range of 0 is invalid, using 1 instead\n")); | |
3210 | linfo.li_line_range = 1; | |
3211 | } | |
b40bf0a2 | 3212 | reset_state_machine (linfo.li_default_is_stmt); |
a262ae96 | 3213 | |
b40bf0a2 NC |
3214 | /* Save a pointer to the contents of the Opcodes table. */ |
3215 | standard_opcodes = hdrptr; | |
a262ae96 | 3216 | |
b40bf0a2 NC |
3217 | /* Traverse the Directory table just to count entries. */ |
3218 | data = standard_opcodes + linfo.li_opcode_base - 1; | |
3219 | if (*data != 0) | |
3220 | { | |
3221 | unsigned char *ptr_directory_table = data; | |
a262ae96 | 3222 | |
b40bf0a2 NC |
3223 | while (*data != 0) |
3224 | { | |
3225 | data += strnlen ((char *) data, end - data) + 1; | |
3226 | n_directories++; | |
3227 | } | |
a262ae96 | 3228 | |
b40bf0a2 NC |
3229 | /* Go through the directory table again to save the directories. */ |
3230 | directory_table = (unsigned char **) | |
3231 | xmalloc (n_directories * sizeof (unsigned char *)); | |
a262ae96 | 3232 | |
b40bf0a2 NC |
3233 | i = 0; |
3234 | while (*ptr_directory_table != 0) | |
3235 | { | |
3236 | directory_table[i] = ptr_directory_table; | |
3237 | ptr_directory_table += strnlen ((char *) ptr_directory_table, | |
3238 | ptr_directory_table - end) + 1; | |
3239 | i++; | |
3240 | } | |
a262ae96 | 3241 | } |
b40bf0a2 NC |
3242 | /* Skip the NUL at the end of the table. */ |
3243 | data++; | |
a262ae96 | 3244 | |
b40bf0a2 NC |
3245 | /* Traverse the File Name table just to count the entries. */ |
3246 | if (*data != 0) | |
3247 | { | |
3248 | unsigned char *ptr_file_name_table = data; | |
a262ae96 | 3249 | |
b40bf0a2 NC |
3250 | while (*data != 0) |
3251 | { | |
3252 | unsigned int bytes_read; | |
a262ae96 | 3253 | |
b40bf0a2 NC |
3254 | /* Skip Name, directory index, last modification time and length |
3255 | of file. */ | |
3256 | data += strnlen ((char *) data, end - data) + 1; | |
3257 | read_uleb128 (data, & bytes_read, end); | |
3258 | data += bytes_read; | |
3259 | read_uleb128 (data, & bytes_read, end); | |
3260 | data += bytes_read; | |
3261 | read_uleb128 (data, & bytes_read, end); | |
3262 | data += bytes_read; | |
a262ae96 | 3263 | |
b40bf0a2 NC |
3264 | n_files++; |
3265 | } | |
a262ae96 | 3266 | |
b40bf0a2 NC |
3267 | /* Go through the file table again to save the strings. */ |
3268 | file_table = (File_Entry *) xmalloc (n_files * sizeof (File_Entry)); | |
a262ae96 | 3269 | |
b40bf0a2 NC |
3270 | i = 0; |
3271 | while (*ptr_file_name_table != 0) | |
3272 | { | |
3273 | unsigned int bytes_read; | |
3274 | ||
3275 | file_table[i].name = ptr_file_name_table; | |
3276 | ptr_file_name_table += strnlen ((char *) ptr_file_name_table, | |
3277 | end - ptr_file_name_table) + 1; | |
3278 | ||
3279 | /* We are not interested in directory, time or size. */ | |
3280 | file_table[i].directory_index = read_uleb128 (ptr_file_name_table, | |
3281 | & bytes_read, end); | |
3282 | ptr_file_name_table += bytes_read; | |
3283 | file_table[i].modification_date = read_uleb128 (ptr_file_name_table, | |
3284 | & bytes_read, end); | |
3285 | ptr_file_name_table += bytes_read; | |
3286 | file_table[i].length = read_uleb128 (ptr_file_name_table, & bytes_read, end); | |
3287 | ptr_file_name_table += bytes_read; | |
3288 | i++; | |
3289 | } | |
3290 | i = 0; | |
a262ae96 | 3291 | |
b40bf0a2 NC |
3292 | /* Print the Compilation Unit's name and a header. */ |
3293 | if (directory_table == NULL) | |
3294 | { | |
3295 | printf (_("CU: %s:\n"), file_table[0].name); | |
3296 | printf (_("File name Line number Starting address\n")); | |
3297 | } | |
3298 | else | |
3299 | { | |
3300 | unsigned int ix = file_table[0].directory_index; | |
3301 | const char *directory = ix ? (char *)directory_table[ix - 1] : "."; | |
a262ae96 | 3302 | |
b40bf0a2 NC |
3303 | if (do_wide || strlen (directory) < 76) |
3304 | printf (_("CU: %s/%s:\n"), directory, file_table[0].name); | |
3305 | else | |
3306 | printf ("%s:\n", file_table[0].name); | |
0c588247 | 3307 | |
b40bf0a2 NC |
3308 | printf (_("File name Line number Starting address\n")); |
3309 | } | |
3310 | } | |
cc5914eb | 3311 | |
b40bf0a2 NC |
3312 | /* Skip the NUL at the end of the table. */ |
3313 | data++; | |
a262ae96 | 3314 | |
b40bf0a2 NC |
3315 | saved_linfo = linfo; |
3316 | } | |
a262ae96 NC |
3317 | |
3318 | /* This loop iterates through the Dwarf Line Number Program. */ | |
3319 | while (data < end_of_sequence) | |
3320 | { | |
3321 | unsigned char op_code; | |
3322 | int adv; | |
3323 | unsigned long int uladv; | |
3324 | unsigned int bytes_read; | |
3325 | int is_special_opcode = 0; | |
3326 | ||
3327 | op_code = *data++; | |
a262ae96 | 3328 | |
91d6fa6a | 3329 | if (op_code >= linfo.li_opcode_base) |
a262ae96 | 3330 | { |
91d6fa6a | 3331 | op_code -= linfo.li_opcode_base; |
a233b20c JJ |
3332 | uladv = (op_code / linfo.li_line_range); |
3333 | if (linfo.li_max_ops_per_insn == 1) | |
3334 | { | |
3335 | uladv *= linfo.li_min_insn_length; | |
3336 | state_machine_regs.address += uladv; | |
3337 | } | |
3338 | else | |
3339 | { | |
3340 | state_machine_regs.address | |
3341 | += ((state_machine_regs.op_index + uladv) | |
3342 | / linfo.li_max_ops_per_insn) | |
b40bf0a2 | 3343 | * linfo.li_min_insn_length; |
a233b20c JJ |
3344 | state_machine_regs.op_index |
3345 | = (state_machine_regs.op_index + uladv) | |
b40bf0a2 | 3346 | % linfo.li_max_ops_per_insn; |
a233b20c | 3347 | } |
a262ae96 | 3348 | |
91d6fa6a | 3349 | adv = (op_code % linfo.li_line_range) + linfo.li_line_base; |
a262ae96 NC |
3350 | state_machine_regs.line += adv; |
3351 | is_special_opcode = 1; | |
3352 | } | |
3353 | else switch (op_code) | |
b40bf0a2 NC |
3354 | { |
3355 | case DW_LNS_extended_op: | |
3356 | { | |
3357 | unsigned int ext_op_code_len; | |
3358 | unsigned char ext_op_code; | |
3359 | unsigned char *op_code_data = data; | |
3360 | ||
3361 | ext_op_code_len = read_uleb128 (op_code_data, &bytes_read, | |
3362 | end_of_sequence); | |
3363 | op_code_data += bytes_read; | |
3364 | ||
3365 | if (ext_op_code_len == 0) | |
3366 | { | |
f41e4712 | 3367 | warn (_("Badly formed extended line op encountered!\n")); |
b40bf0a2 NC |
3368 | break; |
3369 | } | |
3370 | ext_op_code_len += bytes_read; | |
3371 | ext_op_code = *op_code_data++; | |
3372 | ||
3373 | switch (ext_op_code) | |
3374 | { | |
3375 | case DW_LNE_end_sequence: | |
3376 | reset_state_machine (linfo.li_default_is_stmt); | |
3377 | break; | |
3378 | case DW_LNE_set_address: | |
3379 | SAFE_BYTE_GET_AND_INC (state_machine_regs.address, | |
87bc83b3 CC |
3380 | op_code_data, |
3381 | ext_op_code_len - bytes_read - 1, | |
b40bf0a2 NC |
3382 | end); |
3383 | state_machine_regs.op_index = 0; | |
3384 | break; | |
3385 | case DW_LNE_define_file: | |
3386 | { | |
3387 | file_table = (File_Entry *) xrealloc | |
3388 | (file_table, (n_files + 1) * sizeof (File_Entry)); | |
3389 | ||
3390 | ++state_machine_regs.last_file_entry; | |
3391 | /* Source file name. */ | |
3392 | file_table[n_files].name = op_code_data; | |
3393 | op_code_data += strlen ((char *) op_code_data) + 1; | |
3394 | /* Directory index. */ | |
3395 | file_table[n_files].directory_index = | |
3396 | read_uleb128 (op_code_data, & bytes_read, | |
3397 | end_of_sequence); | |
3398 | op_code_data += bytes_read; | |
3399 | /* Last modification time. */ | |
3400 | file_table[n_files].modification_date = | |
3401 | read_uleb128 (op_code_data, & bytes_read, | |
3402 | end_of_sequence); | |
3403 | op_code_data += bytes_read; | |
3404 | /* File length. */ | |
3405 | file_table[n_files].length = | |
3406 | read_uleb128 (op_code_data, & bytes_read, | |
3407 | end_of_sequence); | |
3408 | ||
3409 | n_files++; | |
3410 | break; | |
3411 | } | |
3412 | case DW_LNE_set_discriminator: | |
3413 | case DW_LNE_HP_set_sequence: | |
3414 | /* Simply ignored. */ | |
3415 | break; | |
3416 | ||
3417 | default: | |
3418 | printf (_("UNKNOWN (%u): length %d\n"), | |
3419 | ext_op_code, ext_op_code_len - bytes_read); | |
3420 | break; | |
3421 | } | |
3422 | data += ext_op_code_len; | |
3423 | break; | |
3424 | } | |
3425 | case DW_LNS_copy: | |
3426 | break; | |
3427 | ||
3428 | case DW_LNS_advance_pc: | |
3429 | uladv = read_uleb128 (data, & bytes_read, end); | |
3430 | data += bytes_read; | |
3431 | if (linfo.li_max_ops_per_insn == 1) | |
3432 | { | |
3433 | uladv *= linfo.li_min_insn_length; | |
3434 | state_machine_regs.address += uladv; | |
3435 | } | |
3436 | else | |
3437 | { | |
3438 | state_machine_regs.address | |
3439 | += ((state_machine_regs.op_index + uladv) | |
3440 | / linfo.li_max_ops_per_insn) | |
3441 | * linfo.li_min_insn_length; | |
3442 | state_machine_regs.op_index | |
3443 | = (state_machine_regs.op_index + uladv) | |
3444 | % linfo.li_max_ops_per_insn; | |
3445 | } | |
3446 | break; | |
3447 | ||
3448 | case DW_LNS_advance_line: | |
3449 | adv = read_sleb128 (data, & bytes_read, end); | |
3450 | data += bytes_read; | |
3451 | state_machine_regs.line += adv; | |
3452 | break; | |
3453 | ||
3454 | case DW_LNS_set_file: | |
3455 | adv = read_uleb128 (data, & bytes_read, end); | |
3456 | data += bytes_read; | |
3457 | state_machine_regs.file = adv; | |
3458 | ||
3459 | if (file_table == NULL) | |
3460 | printf (_("\n [Use file table entry %d]\n"), state_machine_regs.file - 1); | |
3461 | else if (file_table[state_machine_regs.file - 1].directory_index == 0) | |
3462 | /* If directory index is 0, that means current directory. */ | |
3463 | printf ("\n./%s:[++]\n", | |
3464 | file_table[state_machine_regs.file - 1].name); | |
3465 | else if (directory_table == NULL) | |
3466 | printf (_("\n [Use directory table entry %d]\n"), | |
3467 | file_table[state_machine_regs.file - 1].directory_index - 1); | |
3468 | else | |
3469 | /* The directory index starts counting at 1. */ | |
3470 | printf ("\n%s/%s:\n", | |
3471 | directory_table[file_table[state_machine_regs.file - 1].directory_index - 1], | |
3472 | file_table[state_machine_regs.file - 1].name); | |
3473 | break; | |
3474 | ||
3475 | case DW_LNS_set_column: | |
3476 | uladv = read_uleb128 (data, & bytes_read, end); | |
3477 | data += bytes_read; | |
3478 | state_machine_regs.column = uladv; | |
3479 | break; | |
3480 | ||
3481 | case DW_LNS_negate_stmt: | |
3482 | adv = state_machine_regs.is_stmt; | |
3483 | adv = ! adv; | |
3484 | state_machine_regs.is_stmt = adv; | |
3485 | break; | |
3486 | ||
3487 | case DW_LNS_set_basic_block: | |
3488 | state_machine_regs.basic_block = 1; | |
3489 | break; | |
3490 | ||
3491 | case DW_LNS_const_add_pc: | |
3492 | uladv = ((255 - linfo.li_opcode_base) / linfo.li_line_range); | |
3493 | if (linfo.li_max_ops_per_insn == 1) | |
3494 | { | |
3495 | uladv *= linfo.li_min_insn_length; | |
3496 | state_machine_regs.address += uladv; | |
3497 | } | |
3498 | else | |
3499 | { | |
3500 | state_machine_regs.address | |
3501 | += ((state_machine_regs.op_index + uladv) | |
3502 | / linfo.li_max_ops_per_insn) | |
3503 | * linfo.li_min_insn_length; | |
3504 | state_machine_regs.op_index | |
3505 | = (state_machine_regs.op_index + uladv) | |
3506 | % linfo.li_max_ops_per_insn; | |
3507 | } | |
3508 | break; | |
3509 | ||
3510 | case DW_LNS_fixed_advance_pc: | |
3511 | SAFE_BYTE_GET_AND_INC (uladv, data, 2, end); | |
3512 | state_machine_regs.address += uladv; | |
3513 | state_machine_regs.op_index = 0; | |
3514 | break; | |
3515 | ||
3516 | case DW_LNS_set_prologue_end: | |
3517 | break; | |
3518 | ||
3519 | case DW_LNS_set_epilogue_begin: | |
3520 | break; | |
3521 | ||
3522 | case DW_LNS_set_isa: | |
3523 | uladv = read_uleb128 (data, & bytes_read, end); | |
3524 | data += bytes_read; | |
3525 | printf (_(" Set ISA to %lu\n"), uladv); | |
3526 | break; | |
3527 | ||
3528 | default: | |
3529 | printf (_(" Unknown opcode %d with operands: "), op_code); | |
3530 | ||
3531 | if (standard_opcodes != NULL) | |
3532 | for (i = standard_opcodes[op_code - 1]; i > 0 ; --i) | |
3533 | { | |
3534 | printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data, | |
3535 | &bytes_read, end)), | |
3536 | i == 1 ? "" : ", "); | |
3537 | data += bytes_read; | |
3538 | } | |
3539 | putchar ('\n'); | |
3540 | break; | |
3541 | } | |
a262ae96 NC |
3542 | |
3543 | /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row | |
3544 | to the DWARF address/line matrix. */ | |
3545 | if ((is_special_opcode) || (op_code == DW_LNE_end_sequence) | |
3546 | || (op_code == DW_LNS_copy)) | |
3547 | { | |
3548 | const unsigned int MAX_FILENAME_LENGTH = 35; | |
b40bf0a2 | 3549 | char *fileName; |
a262ae96 | 3550 | char *newFileName = NULL; |
b40bf0a2 NC |
3551 | size_t fileNameLength; |
3552 | ||
3553 | if (file_table) | |
3554 | fileName = (char *) file_table[state_machine_regs.file - 1].name; | |
3555 | else | |
3556 | fileName = "<unknown>"; | |
3557 | ||
3558 | fileNameLength = strlen (fileName); | |
a262ae96 NC |
3559 | |
3560 | if ((fileNameLength > MAX_FILENAME_LENGTH) && (!do_wide)) | |
3561 | { | |
3f5e193b | 3562 | newFileName = (char *) xmalloc (MAX_FILENAME_LENGTH + 1); |
a262ae96 NC |
3563 | /* Truncate file name */ |
3564 | strncpy (newFileName, | |
3565 | fileName + fileNameLength - MAX_FILENAME_LENGTH, | |
3566 | MAX_FILENAME_LENGTH + 1); | |
3567 | } | |
3568 | else | |
3569 | { | |
3f5e193b | 3570 | newFileName = (char *) xmalloc (fileNameLength + 1); |
a262ae96 NC |
3571 | strncpy (newFileName, fileName, fileNameLength + 1); |
3572 | } | |
3573 | ||
3574 | if (!do_wide || (fileNameLength <= MAX_FILENAME_LENGTH)) | |
3575 | { | |
a233b20c | 3576 | if (linfo.li_max_ops_per_insn == 1) |
467c65bc NC |
3577 | printf ("%-35s %11d %#18" DWARF_VMA_FMT "x\n", |
3578 | newFileName, state_machine_regs.line, | |
a233b20c JJ |
3579 | state_machine_regs.address); |
3580 | else | |
467c65bc NC |
3581 | printf ("%-35s %11d %#18" DWARF_VMA_FMT "x[%d]\n", |
3582 | newFileName, state_machine_regs.line, | |
a233b20c JJ |
3583 | state_machine_regs.address, |
3584 | state_machine_regs.op_index); | |
a262ae96 NC |
3585 | } |
3586 | else | |
3587 | { | |
a233b20c | 3588 | if (linfo.li_max_ops_per_insn == 1) |
467c65bc NC |
3589 | printf ("%s %11d %#18" DWARF_VMA_FMT "x\n", |
3590 | newFileName, state_machine_regs.line, | |
a233b20c JJ |
3591 | state_machine_regs.address); |
3592 | else | |
467c65bc NC |
3593 | printf ("%s %11d %#18" DWARF_VMA_FMT "x[%d]\n", |
3594 | newFileName, state_machine_regs.line, | |
a233b20c JJ |
3595 | state_machine_regs.address, |
3596 | state_machine_regs.op_index); | |
a262ae96 NC |
3597 | } |
3598 | ||
3599 | if (op_code == DW_LNE_end_sequence) | |
3600 | printf ("\n"); | |
3601 | ||
3602 | free (newFileName); | |
3603 | } | |
3604 | } | |
b40bf0a2 NC |
3605 | |
3606 | if (file_table) | |
3607 | { | |
3608 | free (file_table); | |
3609 | file_table = NULL; | |
3610 | n_files = 0; | |
3611 | } | |
3612 | ||
3613 | if (directory_table) | |
3614 | { | |
3615 | free (directory_table); | |
3616 | directory_table = NULL; | |
3617 | n_directories = 0; | |
3618 | } | |
3619 | ||
a262ae96 NC |
3620 | putchar ('\n'); |
3621 | } | |
3622 | ||
3623 | return 1; | |
3624 | } | |
3625 | ||
3626 | static int | |
1c4cc746 | 3627 | display_debug_lines (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED) |
a262ae96 NC |
3628 | { |
3629 | unsigned char *data = section->start; | |
3630 | unsigned char *end = data + section->size; | |
4cb93e3b TG |
3631 | int retValRaw = 1; |
3632 | int retValDecoded = 1; | |
a262ae96 | 3633 | |
008f4c78 NC |
3634 | if (do_debug_lines == 0) |
3635 | do_debug_lines |= FLAG_DEBUG_LINES_RAW; | |
3636 | ||
4cb93e3b | 3637 | if (do_debug_lines & FLAG_DEBUG_LINES_RAW) |
a262ae96 NC |
3638 | retValRaw = display_debug_lines_raw (section, data, end); |
3639 | ||
4cb93e3b | 3640 | if (do_debug_lines & FLAG_DEBUG_LINES_DECODED) |
a262ae96 NC |
3641 | retValDecoded = display_debug_lines_decoded (section, data, end); |
3642 | ||
4cb93e3b | 3643 | if (!retValRaw || !retValDecoded) |
a262ae96 NC |
3644 | return 0; |
3645 | ||
3646 | return 1; | |
3647 | } | |
3648 | ||
6e3d6dc1 NC |
3649 | static debug_info * |
3650 | find_debug_info_for_offset (unsigned long offset) | |
3651 | { | |
3652 | unsigned int i; | |
3653 | ||
3654 | if (num_debug_info_entries == DEBUG_INFO_UNAVAILABLE) | |
3655 | return NULL; | |
3656 | ||
3657 | for (i = 0; i < num_debug_info_entries; i++) | |
3658 | if (debug_information[i].cu_offset == offset) | |
3659 | return debug_information + i; | |
3660 | ||
3661 | return NULL; | |
3662 | } | |
3663 | ||
459d52c8 DE |
3664 | static const char * |
3665 | get_gdb_index_symbol_kind_name (gdb_index_symbol_kind kind) | |
3666 | { | |
3667 | /* See gdb/gdb-index.h. */ | |
3668 | static const char * const kinds[] = | |
3669 | { | |
3670 | N_ ("no info"), | |
3671 | N_ ("type"), | |
3672 | N_ ("variable"), | |
3673 | N_ ("function"), | |
3674 | N_ ("other"), | |
3675 | N_ ("unused5"), | |
3676 | N_ ("unused6"), | |
3677 | N_ ("unused7") | |
3678 | }; | |
3679 | ||
3680 | return _ (kinds[kind]); | |
3681 | } | |
3682 | ||
19e6b90e | 3683 | static int |
459d52c8 DE |
3684 | display_debug_pubnames_worker (struct dwarf_section *section, |
3685 | void *file ATTRIBUTE_UNUSED, | |
3686 | int is_gnu) | |
19e6b90e | 3687 | { |
91d6fa6a | 3688 | DWARF2_Internal_PubNames names; |
19e6b90e L |
3689 | unsigned char *start = section->start; |
3690 | unsigned char *end = start + section->size; | |
3691 | ||
6e3d6dc1 NC |
3692 | /* It does not matter if this load fails, |
3693 | we test for that later on. */ | |
3694 | load_debug_info (file); | |
3695 | ||
19e6b90e L |
3696 | printf (_("Contents of the %s section:\n\n"), section->name); |
3697 | ||
3698 | while (start < end) | |
3699 | { | |
3700 | unsigned char *data; | |
3701 | unsigned long offset; | |
bf5117e3 | 3702 | unsigned int offset_size, initial_length_size; |
19e6b90e L |
3703 | |
3704 | data = start; | |
3705 | ||
0c588247 | 3706 | SAFE_BYTE_GET_AND_INC (names.pn_length, data, 4, end); |
91d6fa6a | 3707 | if (names.pn_length == 0xffffffff) |
19e6b90e | 3708 | { |
0c588247 | 3709 | SAFE_BYTE_GET_AND_INC (names.pn_length, data, 8, end); |
19e6b90e L |
3710 | offset_size = 8; |
3711 | initial_length_size = 12; | |
3712 | } | |
3713 | else | |
3714 | { | |
3715 | offset_size = 4; | |
3716 | initial_length_size = 4; | |
3717 | } | |
3718 | ||
0c588247 NC |
3719 | SAFE_BYTE_GET_AND_INC (names.pn_version, data, 2, end); |
3720 | SAFE_BYTE_GET_AND_INC (names.pn_offset, data, offset_size, end); | |
6e3d6dc1 NC |
3721 | |
3722 | if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE | |
3723 | && num_debug_info_entries > 0 | |
91d6fa6a | 3724 | && find_debug_info_for_offset (names.pn_offset) == NULL) |
6e3d6dc1 | 3725 | warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"), |
47704ddf | 3726 | (unsigned long) names.pn_offset, section->name); |
cecf136e | 3727 | |
0c588247 | 3728 | SAFE_BYTE_GET_AND_INC (names.pn_size, data, offset_size, end); |
19e6b90e | 3729 | |
058037d3 | 3730 | /* PR 17531: file: 7615b6b2. */ |
57028622 NC |
3731 | if ((dwarf_signed_vma) names.pn_length < 0 |
3732 | /* PR 17531: file: a5dbeaa7. */ | |
3733 | || start + names.pn_length + initial_length_size < start) | |
058037d3 NC |
3734 | { |
3735 | warn (_("Negative length for public name: 0x%lx\n"), (long) names.pn_length); | |
3736 | start = end; | |
3737 | } | |
3738 | else | |
3739 | start += names.pn_length + initial_length_size; | |
3740 | ||
3741 | printf (_(" Length: %ld\n"), | |
3742 | (long) names.pn_length); | |
3743 | printf (_(" Version: %d\n"), | |
3744 | names.pn_version); | |
3745 | printf (_(" Offset into .debug_info section: 0x%lx\n"), | |
3746 | (unsigned long) names.pn_offset); | |
3747 | printf (_(" Size of area in .debug_info section: %ld\n"), | |
3748 | (long) names.pn_size); | |
19e6b90e | 3749 | |
91d6fa6a | 3750 | if (names.pn_version != 2 && names.pn_version != 3) |
19e6b90e L |
3751 | { |
3752 | static int warned = 0; | |
3753 | ||
3754 | if (! warned) | |
3755 | { | |
3756 | warn (_("Only DWARF 2 and 3 pubnames are currently supported\n")); | |
3757 | warned = 1; | |
3758 | } | |
3759 | ||
3760 | continue; | |
3761 | } | |
3762 | ||
459d52c8 DE |
3763 | if (is_gnu) |
3764 | printf (_("\n Offset Kind Name\n")); | |
3765 | else | |
3766 | printf (_("\n Offset\tName\n")); | |
19e6b90e L |
3767 | |
3768 | do | |
3769 | { | |
f41e4712 NC |
3770 | bfd_size_type maxprint; |
3771 | ||
0c588247 | 3772 | SAFE_BYTE_GET (offset, data, offset_size, end); |
19e6b90e L |
3773 | |
3774 | if (offset != 0) | |
3775 | { | |
3776 | data += offset_size; | |
f41e4712 NC |
3777 | if (data >= end) |
3778 | break; | |
3779 | maxprint = (end - data) - 1; | |
3780 | ||
459d52c8 DE |
3781 | if (is_gnu) |
3782 | { | |
3783 | unsigned int kind_data; | |
3784 | gdb_index_symbol_kind kind; | |
3785 | const char *kind_name; | |
3786 | int is_static; | |
3787 | ||
3788 | SAFE_BYTE_GET (kind_data, data, 1, end); | |
3789 | data++; | |
f41e4712 | 3790 | maxprint --; |
459d52c8 DE |
3791 | /* GCC computes the kind as the upper byte in the CU index |
3792 | word, and then right shifts it by the CU index size. | |
3793 | Left shift KIND to where the gdb-index.h accessor macros | |
3794 | can use it. */ | |
3795 | kind_data <<= GDB_INDEX_CU_BITSIZE; | |
3796 | kind = GDB_INDEX_SYMBOL_KIND_VALUE (kind_data); | |
3797 | kind_name = get_gdb_index_symbol_kind_name (kind); | |
3798 | is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (kind_data); | |
f41e4712 | 3799 | printf (" %-6lx %s,%-10s %.*s\n", |
459d52c8 | 3800 | offset, is_static ? _("s") : _("g"), |
f41e4712 | 3801 | kind_name, (int) maxprint, data); |
459d52c8 DE |
3802 | } |
3803 | else | |
f41e4712 NC |
3804 | printf (" %-6lx\t%.*s\n", offset, (int) maxprint, data); |
3805 | ||
3806 | data += strnlen ((char *) data, maxprint) + 1; | |
3807 | if (data >= end) | |
3808 | break; | |
19e6b90e L |
3809 | } |
3810 | } | |
3811 | while (offset != 0); | |
3812 | } | |
3813 | ||
3814 | printf ("\n"); | |
3815 | return 1; | |
3816 | } | |
3817 | ||
459d52c8 DE |
3818 | static int |
3819 | display_debug_pubnames (struct dwarf_section *section, void *file) | |
3820 | { | |
3821 | return display_debug_pubnames_worker (section, file, 0); | |
3822 | } | |
3823 | ||
3824 | static int | |
3825 | display_debug_gnu_pubnames (struct dwarf_section *section, void *file) | |
3826 | { | |
3827 | return display_debug_pubnames_worker (section, file, 1); | |
3828 | } | |
3829 | ||
19e6b90e L |
3830 | static int |
3831 | display_debug_macinfo (struct dwarf_section *section, | |
3832 | void *file ATTRIBUTE_UNUSED) | |
3833 | { | |
3834 | unsigned char *start = section->start; | |
3835 | unsigned char *end = start + section->size; | |
3836 | unsigned char *curr = start; | |
3837 | unsigned int bytes_read; | |
3838 | enum dwarf_macinfo_record_type op; | |
3839 | ||
3840 | printf (_("Contents of the %s section:\n\n"), section->name); | |
3841 | ||
3842 | while (curr < end) | |
3843 | { | |
3844 | unsigned int lineno; | |
0c588247 | 3845 | const unsigned char *string; |
19e6b90e | 3846 | |
3f5e193b | 3847 | op = (enum dwarf_macinfo_record_type) *curr; |
19e6b90e L |
3848 | curr++; |
3849 | ||
3850 | switch (op) | |
3851 | { | |
3852 | case DW_MACINFO_start_file: | |
3853 | { | |
3854 | unsigned int filenum; | |
3855 | ||
f6f0e17b | 3856 | lineno = read_uleb128 (curr, & bytes_read, end); |
19e6b90e | 3857 | curr += bytes_read; |
f6f0e17b | 3858 | filenum = read_uleb128 (curr, & bytes_read, end); |
19e6b90e L |
3859 | curr += bytes_read; |
3860 | ||
3861 | printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"), | |
3862 | lineno, filenum); | |
3863 | } | |
3864 | break; | |
3865 | ||
3866 | case DW_MACINFO_end_file: | |
3867 | printf (_(" DW_MACINFO_end_file\n")); | |
3868 | break; | |
3869 | ||
3870 | case DW_MACINFO_define: | |
f6f0e17b | 3871 | lineno = read_uleb128 (curr, & bytes_read, end); |
19e6b90e | 3872 | curr += bytes_read; |
0c588247 NC |
3873 | string = curr; |
3874 | curr += strnlen ((char *) string, end - string) + 1; | |
19e6b90e L |
3875 | printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"), |
3876 | lineno, string); | |
3877 | break; | |
3878 | ||
3879 | case DW_MACINFO_undef: | |
f6f0e17b | 3880 | lineno = read_uleb128 (curr, & bytes_read, end); |
19e6b90e | 3881 | curr += bytes_read; |
0c588247 NC |
3882 | string = curr; |
3883 | curr += strnlen ((char *) string, end - string) + 1; | |
19e6b90e L |
3884 | printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"), |
3885 | lineno, string); | |
3886 | break; | |
3887 | ||
3888 | case DW_MACINFO_vendor_ext: | |
3889 | { | |
3890 | unsigned int constant; | |
3891 | ||
f6f0e17b | 3892 | constant = read_uleb128 (curr, & bytes_read, end); |
19e6b90e | 3893 | curr += bytes_read; |
0c588247 NC |
3894 | string = curr; |
3895 | curr += strnlen ((char *) string, end - string) + 1; | |
19e6b90e L |
3896 | printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"), |
3897 | constant, string); | |
3898 | } | |
3899 | break; | |
3900 | } | |
3901 | } | |
3902 | ||
3903 | return 1; | |
3904 | } | |
3905 | ||
4ccf1e31 JJ |
3906 | /* Given LINE_OFFSET into the .debug_line section, attempt to return |
3907 | filename and dirname corresponding to file name table entry with index | |
3908 | FILEIDX. Return NULL on failure. */ | |
3909 | ||
3910 | static unsigned char * | |
f6f0e17b NC |
3911 | get_line_filename_and_dirname (dwarf_vma line_offset, |
3912 | dwarf_vma fileidx, | |
4ccf1e31 JJ |
3913 | unsigned char **dir_name) |
3914 | { | |
3915 | struct dwarf_section *section = &debug_displays [line].section; | |
3916 | unsigned char *hdrptr, *dirtable, *file_name; | |
3917 | unsigned int offset_size, initial_length_size; | |
3918 | unsigned int version, opcode_base, bytes_read; | |
3919 | dwarf_vma length, diridx; | |
f6f0e17b | 3920 | const unsigned char * end; |
4ccf1e31 JJ |
3921 | |
3922 | *dir_name = NULL; | |
3923 | if (section->start == NULL | |
3924 | || line_offset >= section->size | |
3925 | || fileidx == 0) | |
3926 | return NULL; | |
3927 | ||
3928 | hdrptr = section->start + line_offset; | |
f6f0e17b | 3929 | end = section->start + section->size; |
0c588247 NC |
3930 | |
3931 | SAFE_BYTE_GET_AND_INC (length, hdrptr, 4, end); | |
4ccf1e31 JJ |
3932 | if (length == 0xffffffff) |
3933 | { | |
3934 | /* This section is 64-bit DWARF 3. */ | |
0c588247 | 3935 | SAFE_BYTE_GET_AND_INC (length, hdrptr, 8, end); |
4ccf1e31 JJ |
3936 | offset_size = 8; |
3937 | initial_length_size = 12; | |
3938 | } | |
3939 | else | |
3940 | { | |
3941 | offset_size = 4; | |
3942 | initial_length_size = 4; | |
3943 | } | |
3944 | if (length + initial_length_size > section->size) | |
3945 | return NULL; | |
0c588247 NC |
3946 | |
3947 | SAFE_BYTE_GET_AND_INC (version, hdrptr, 2, end); | |
4ccf1e31 JJ |
3948 | if (version != 2 && version != 3 && version != 4) |
3949 | return NULL; | |
3950 | hdrptr += offset_size + 1;/* Skip prologue_length and min_insn_length. */ | |
3951 | if (version >= 4) | |
3952 | hdrptr++; /* Skip max_ops_per_insn. */ | |
3953 | hdrptr += 3; /* Skip default_is_stmt, line_base, line_range. */ | |
0c588247 NC |
3954 | |
3955 | SAFE_BYTE_GET_AND_INC (opcode_base, hdrptr, 1, end); | |
4ccf1e31 JJ |
3956 | if (opcode_base == 0) |
3957 | return NULL; | |
0c588247 | 3958 | |
4ccf1e31 JJ |
3959 | hdrptr += opcode_base - 1; |
3960 | dirtable = hdrptr; | |
3961 | /* Skip over dirname table. */ | |
3962 | while (*hdrptr != '\0') | |
0c588247 | 3963 | hdrptr += strnlen ((char *) hdrptr, end - hdrptr) + 1; |
4ccf1e31 JJ |
3964 | hdrptr++; /* Skip the NUL at the end of the table. */ |
3965 | /* Now skip over preceding filename table entries. */ | |
3966 | for (; *hdrptr != '\0' && fileidx > 1; fileidx--) | |
3967 | { | |
0c588247 | 3968 | hdrptr += strnlen ((char *) hdrptr, end - hdrptr) + 1; |
f6f0e17b | 3969 | read_uleb128 (hdrptr, &bytes_read, end); |
4ccf1e31 | 3970 | hdrptr += bytes_read; |
f6f0e17b | 3971 | read_uleb128 (hdrptr, &bytes_read, end); |
4ccf1e31 | 3972 | hdrptr += bytes_read; |
f6f0e17b | 3973 | read_uleb128 (hdrptr, &bytes_read, end); |
4ccf1e31 JJ |
3974 | hdrptr += bytes_read; |
3975 | } | |
f6f0e17b | 3976 | if (hdrptr == end || *hdrptr == '\0') |
4ccf1e31 JJ |
3977 | return NULL; |
3978 | file_name = hdrptr; | |
0c588247 | 3979 | hdrptr += strnlen ((char *) hdrptr, end - hdrptr) + 1; |
f6f0e17b | 3980 | diridx = read_uleb128 (hdrptr, &bytes_read, end); |
4ccf1e31 JJ |
3981 | if (diridx == 0) |
3982 | return file_name; | |
3983 | for (; *dirtable != '\0' && diridx > 1; diridx--) | |
0c588247 | 3984 | dirtable += strnlen ((char *) dirtable, end - dirtable) + 1; |
4ccf1e31 JJ |
3985 | if (*dirtable == '\0') |
3986 | return NULL; | |
3987 | *dir_name = dirtable; | |
3988 | return file_name; | |
3989 | } | |
3990 | ||
3991 | static int | |
3992 | display_debug_macro (struct dwarf_section *section, | |
3993 | void *file) | |
3994 | { | |
3995 | unsigned char *start = section->start; | |
3996 | unsigned char *end = start + section->size; | |
3997 | unsigned char *curr = start; | |
3998 | unsigned char *extended_op_buf[256]; | |
3999 | unsigned int bytes_read; | |
4000 | ||
4001 | load_debug_section (str, file); | |
4002 | load_debug_section (line, file); | |
4003 | ||
4004 | printf (_("Contents of the %s section:\n\n"), section->name); | |
4005 | ||
4006 | while (curr < end) | |
4007 | { | |
4008 | unsigned int lineno, version, flags; | |
4009 | unsigned int offset_size = 4; | |
0c588247 | 4010 | const unsigned char *string; |
4ccf1e31 JJ |
4011 | dwarf_vma line_offset = 0, sec_offset = curr - start, offset; |
4012 | unsigned char **extended_ops = NULL; | |
4013 | ||
0c588247 | 4014 | SAFE_BYTE_GET_AND_INC (version, curr, 2, end); |
4ccf1e31 JJ |
4015 | if (version != 4) |
4016 | { | |
4017 | error (_("Only GNU extension to DWARF 4 of %s is currently supported.\n"), | |
4018 | section->name); | |
4019 | return 0; | |
4020 | } | |
4021 | ||
0c588247 | 4022 | SAFE_BYTE_GET_AND_INC (flags, curr, 1, end); |
4ccf1e31 JJ |
4023 | if (flags & 1) |
4024 | offset_size = 8; | |
4025 | printf (_(" Offset: 0x%lx\n"), | |
4026 | (unsigned long) sec_offset); | |
4027 | printf (_(" Version: %d\n"), version); | |
4028 | printf (_(" Offset size: %d\n"), offset_size); | |
4029 | if (flags & 2) | |
4030 | { | |
0c588247 | 4031 | SAFE_BYTE_GET_AND_INC (line_offset, curr, offset_size, end); |
4ccf1e31 JJ |
4032 | printf (_(" Offset into .debug_line: 0x%lx\n"), |
4033 | (unsigned long) line_offset); | |
4034 | } | |
4035 | if (flags & 4) | |
4036 | { | |
0c588247 | 4037 | unsigned int i, count, op; |
4ccf1e31 | 4038 | dwarf_vma nargs, n; |
0c588247 NC |
4039 | |
4040 | SAFE_BYTE_GET_AND_INC (count, curr, 1, end); | |
bf5117e3 | 4041 | |
4ccf1e31 JJ |
4042 | memset (extended_op_buf, 0, sizeof (extended_op_buf)); |
4043 | extended_ops = extended_op_buf; | |
4044 | if (count) | |
4045 | { | |
4046 | printf (_(" Extension opcode arguments:\n")); | |
4047 | for (i = 0; i < count; i++) | |
4048 | { | |
0c588247 | 4049 | SAFE_BYTE_GET_AND_INC (op, curr, 1, end); |
4ccf1e31 | 4050 | extended_ops[op] = curr; |
f6f0e17b | 4051 | nargs = read_uleb128 (curr, &bytes_read, end); |
4ccf1e31 JJ |
4052 | curr += bytes_read; |
4053 | if (nargs == 0) | |
4054 | printf (_(" DW_MACRO_GNU_%02x has no arguments\n"), op); | |
4055 | else | |
4056 | { | |
4057 | printf (_(" DW_MACRO_GNU_%02x arguments: "), op); | |
4058 | for (n = 0; n < nargs; n++) | |
4059 | { | |
0c588247 NC |
4060 | unsigned int form; |
4061 | ||
4062 | SAFE_BYTE_GET_AND_INC (form, curr, 1, end); | |
4ccf1e31 JJ |
4063 | printf ("%s%s", get_FORM_name (form), |
4064 | n == nargs - 1 ? "\n" : ", "); | |
4065 | switch (form) | |
4066 | { | |
4067 | case DW_FORM_data1: | |
4068 | case DW_FORM_data2: | |
4069 | case DW_FORM_data4: | |
4070 | case DW_FORM_data8: | |
4071 | case DW_FORM_sdata: | |
4072 | case DW_FORM_udata: | |
4073 | case DW_FORM_block: | |
4074 | case DW_FORM_block1: | |
4075 | case DW_FORM_block2: | |
4076 | case DW_FORM_block4: | |
4077 | case DW_FORM_flag: | |
4078 | case DW_FORM_string: | |
4079 | case DW_FORM_strp: | |
4080 | case DW_FORM_sec_offset: | |
4081 | break; | |
4082 | default: | |
4083 | error (_("Invalid extension opcode form %s\n"), | |
4084 | get_FORM_name (form)); | |
4085 | return 0; | |
4086 | } | |
4087 | } | |
4088 | } | |
4089 | } | |
4090 | } | |
4091 | } | |
4092 | printf ("\n"); | |
4093 | ||
4094 | while (1) | |
4095 | { | |
4096 | unsigned int op; | |
4097 | ||
4098 | if (curr >= end) | |
4099 | { | |
4100 | error (_(".debug_macro section not zero terminated\n")); | |
4101 | return 0; | |
4102 | } | |
4103 | ||
0c588247 | 4104 | SAFE_BYTE_GET_AND_INC (op, curr, 1, end); |
4ccf1e31 JJ |
4105 | if (op == 0) |
4106 | break; | |
4107 | ||
4108 | switch (op) | |
4109 | { | |
4110 | case DW_MACRO_GNU_start_file: | |
4111 | { | |
4112 | unsigned int filenum; | |
4113 | unsigned char *file_name = NULL, *dir_name = NULL; | |
4114 | ||
f6f0e17b | 4115 | lineno = read_uleb128 (curr, &bytes_read, end); |
4ccf1e31 | 4116 | curr += bytes_read; |
f6f0e17b | 4117 | filenum = read_uleb128 (curr, &bytes_read, end); |
4ccf1e31 JJ |
4118 | curr += bytes_read; |
4119 | ||
4120 | if ((flags & 2) == 0) | |
4121 | error (_("DW_MACRO_GNU_start_file used, but no .debug_line offset provided.\n")); | |
4122 | else | |
4123 | file_name | |
4124 | = get_line_filename_and_dirname (line_offset, filenum, | |
4125 | &dir_name); | |
4126 | if (file_name == NULL) | |
4127 | printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d\n"), | |
4128 | lineno, filenum); | |
4129 | else | |
4130 | printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d filename: %s%s%s\n"), | |
4131 | lineno, filenum, | |
4132 | dir_name != NULL ? (const char *) dir_name : "", | |
4133 | dir_name != NULL ? "/" : "", file_name); | |
4134 | } | |
4135 | break; | |
4136 | ||
4137 | case DW_MACRO_GNU_end_file: | |
4138 | printf (_(" DW_MACRO_GNU_end_file\n")); | |
4139 | break; | |
4140 | ||
4141 | case DW_MACRO_GNU_define: | |
f6f0e17b | 4142 | lineno = read_uleb128 (curr, &bytes_read, end); |
4ccf1e31 | 4143 | curr += bytes_read; |
0c588247 NC |
4144 | string = curr; |
4145 | curr += strnlen ((char *) string, end - string) + 1; | |
4ccf1e31 JJ |
4146 | printf (_(" DW_MACRO_GNU_define - lineno : %d macro : %s\n"), |
4147 | lineno, string); | |
4148 | break; | |
4149 | ||
4150 | case DW_MACRO_GNU_undef: | |
f6f0e17b | 4151 | lineno = read_uleb128 (curr, &bytes_read, end); |
4ccf1e31 | 4152 | curr += bytes_read; |
0c588247 NC |
4153 | string = curr; |
4154 | curr += strnlen ((char *) string, end - string) + 1; | |
4ccf1e31 JJ |
4155 | printf (_(" DW_MACRO_GNU_undef - lineno : %d macro : %s\n"), |
4156 | lineno, string); | |
4157 | break; | |
4158 | ||
4159 | case DW_MACRO_GNU_define_indirect: | |
f6f0e17b | 4160 | lineno = read_uleb128 (curr, &bytes_read, end); |
4ccf1e31 | 4161 | curr += bytes_read; |
0c588247 | 4162 | SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); |
4ccf1e31 JJ |
4163 | string = fetch_indirect_string (offset); |
4164 | printf (_(" DW_MACRO_GNU_define_indirect - lineno : %d macro : %s\n"), | |
4165 | lineno, string); | |
4166 | break; | |
4167 | ||
4168 | case DW_MACRO_GNU_undef_indirect: | |
f6f0e17b | 4169 | lineno = read_uleb128 (curr, &bytes_read, end); |
4ccf1e31 | 4170 | curr += bytes_read; |
0c588247 | 4171 | SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); |
4ccf1e31 JJ |
4172 | string = fetch_indirect_string (offset); |
4173 | printf (_(" DW_MACRO_GNU_undef_indirect - lineno : %d macro : %s\n"), | |
4174 | lineno, string); | |
4175 | break; | |
4176 | ||
4177 | case DW_MACRO_GNU_transparent_include: | |
0c588247 | 4178 | SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); |
4ccf1e31 JJ |
4179 | printf (_(" DW_MACRO_GNU_transparent_include - offset : 0x%lx\n"), |
4180 | (unsigned long) offset); | |
4181 | break; | |
4182 | ||
a081f3cd | 4183 | case DW_MACRO_GNU_define_indirect_alt: |
f6f0e17b | 4184 | lineno = read_uleb128 (curr, &bytes_read, end); |
a081f3cd | 4185 | curr += bytes_read; |
0c588247 | 4186 | SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); |
a081f3cd JJ |
4187 | printf (_(" DW_MACRO_GNU_define_indirect_alt - lineno : %d macro offset : 0x%lx\n"), |
4188 | lineno, (unsigned long) offset); | |
4189 | break; | |
4190 | ||
4191 | case DW_MACRO_GNU_undef_indirect_alt: | |
f6f0e17b | 4192 | lineno = read_uleb128 (curr, &bytes_read, end); |
a081f3cd | 4193 | curr += bytes_read; |
0c588247 | 4194 | SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); |
a081f3cd JJ |
4195 | printf (_(" DW_MACRO_GNU_undef_indirect_alt - lineno : %d macro offset : 0x%lx\n"), |
4196 | lineno, (unsigned long) offset); | |
4197 | break; | |
4198 | ||
4199 | case DW_MACRO_GNU_transparent_include_alt: | |
0c588247 | 4200 | SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); |
a081f3cd JJ |
4201 | printf (_(" DW_MACRO_GNU_transparent_include_alt - offset : 0x%lx\n"), |
4202 | (unsigned long) offset); | |
4203 | break; | |
4204 | ||
4ccf1e31 JJ |
4205 | default: |
4206 | if (extended_ops == NULL || extended_ops[op] == NULL) | |
4207 | { | |
4208 | error (_(" Unknown macro opcode %02x seen\n"), op); | |
4209 | return 0; | |
4210 | } | |
4211 | else | |
4212 | { | |
4213 | /* Skip over unhandled opcodes. */ | |
4214 | dwarf_vma nargs, n; | |
4215 | unsigned char *desc = extended_ops[op]; | |
f6f0e17b | 4216 | nargs = read_uleb128 (desc, &bytes_read, end); |
4ccf1e31 JJ |
4217 | desc += bytes_read; |
4218 | if (nargs == 0) | |
4219 | { | |
4220 | printf (_(" DW_MACRO_GNU_%02x\n"), op); | |
4221 | break; | |
4222 | } | |
4223 | printf (_(" DW_MACRO_GNU_%02x -"), op); | |
4224 | for (n = 0; n < nargs; n++) | |
4225 | { | |
0c588247 NC |
4226 | int val; |
4227 | ||
4228 | SAFE_BYTE_GET_AND_INC (val, desc, 1, end); | |
4ccf1e31 | 4229 | curr |
0c588247 | 4230 | = read_and_display_attr_value (0, val, |
f6f0e17b | 4231 | curr, end, 0, 0, offset_size, |
341f9135 CC |
4232 | version, NULL, 0, NULL, |
4233 | NULL); | |
4ccf1e31 JJ |
4234 | if (n != nargs - 1) |
4235 | printf (","); | |
4236 | } | |
4237 | printf ("\n"); | |
4238 | } | |
4239 | break; | |
4240 | } | |
4241 | } | |
4242 | ||
4243 | printf ("\n"); | |
4244 | } | |
4245 | ||
4246 | return 1; | |
4247 | } | |
4248 | ||
19e6b90e L |
4249 | static int |
4250 | display_debug_abbrev (struct dwarf_section *section, | |
4251 | void *file ATTRIBUTE_UNUSED) | |
4252 | { | |
4253 | abbrev_entry *entry; | |
4254 | unsigned char *start = section->start; | |
4255 | unsigned char *end = start + section->size; | |
4256 | ||
4257 | printf (_("Contents of the %s section:\n\n"), section->name); | |
4258 | ||
4259 | do | |
4260 | { | |
7282333f AM |
4261 | unsigned char *last; |
4262 | ||
19e6b90e L |
4263 | free_abbrevs (); |
4264 | ||
7282333f | 4265 | last = start; |
19e6b90e L |
4266 | start = process_abbrev_section (start, end); |
4267 | ||
4268 | if (first_abbrev == NULL) | |
4269 | continue; | |
4270 | ||
7282333f | 4271 | printf (_(" Number TAG (0x%lx)\n"), (long) (last - section->start)); |
19e6b90e L |
4272 | |
4273 | for (entry = first_abbrev; entry; entry = entry->next) | |
4274 | { | |
4275 | abbrev_attr *attr; | |
4276 | ||
cc5914eb | 4277 | printf (" %ld %s [%s]\n", |
19e6b90e L |
4278 | entry->entry, |
4279 | get_TAG_name (entry->tag), | |
4280 | entry->children ? _("has children") : _("no children")); | |
4281 | ||
4282 | for (attr = entry->first_attr; attr; attr = attr->next) | |
cc5914eb | 4283 | printf (" %-18s %s\n", |
19e6b90e L |
4284 | get_AT_name (attr->attribute), |
4285 | get_FORM_name (attr->form)); | |
4286 | } | |
4287 | } | |
4288 | while (start); | |
4289 | ||
4290 | printf ("\n"); | |
4291 | ||
4292 | return 1; | |
4293 | } | |
4294 | ||
4723351a CC |
4295 | /* Display a location list from a normal (ie, non-dwo) .debug_loc section. */ |
4296 | ||
4297 | static void | |
4298 | display_loc_list (struct dwarf_section *section, | |
4299 | unsigned char **start_ptr, | |
82b1b41b | 4300 | unsigned int debug_info_entry, |
4723351a CC |
4301 | unsigned long offset, |
4302 | unsigned long base_address, | |
4303 | int has_frame_base) | |
4304 | { | |
4305 | unsigned char *start = *start_ptr; | |
4306 | unsigned char *section_end = section->start + section->size; | |
82b1b41b NC |
4307 | unsigned long cu_offset; |
4308 | unsigned int pointer_size; | |
4309 | unsigned int offset_size; | |
4310 | int dwarf_version; | |
4723351a CC |
4311 | |
4312 | dwarf_vma begin; | |
4313 | dwarf_vma end; | |
4314 | unsigned short length; | |
4315 | int need_frame_base; | |
4316 | ||
82b1b41b NC |
4317 | if (debug_info_entry >= num_debug_info_entries) |
4318 | { | |
4319 | warn (_("No debug information available for loc lists of entry: %u\n"), | |
4320 | debug_info_entry); | |
4321 | return; | |
4322 | } | |
4323 | ||
4324 | cu_offset = debug_information [debug_info_entry].cu_offset; | |
4325 | pointer_size = debug_information [debug_info_entry].pointer_size; | |
4326 | offset_size = debug_information [debug_info_entry].offset_size; | |
4327 | dwarf_version = debug_information [debug_info_entry].dwarf_version; | |
4328 | ||
f41e4712 NC |
4329 | if (pointer_size < 2 || pointer_size > 8) |
4330 | { | |
4331 | warn (_("Invalid pointer size (%d) in debug info for entry %d\n"), | |
4332 | pointer_size, debug_info_entry); | |
4333 | return; | |
4334 | } | |
4335 | ||
4723351a CC |
4336 | while (1) |
4337 | { | |
4338 | if (start + 2 * pointer_size > section_end) | |
4339 | { | |
4340 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), | |
4341 | offset); | |
4342 | break; | |
4343 | } | |
4344 | ||
fab128ef CC |
4345 | printf (" %8.8lx ", offset + (start - *start_ptr)); |
4346 | ||
4723351a CC |
4347 | /* Note: we use sign extension here in order to be sure that we can detect |
4348 | the -1 escape value. Sign extension into the top 32 bits of a 32-bit | |
4349 | address will not affect the values that we display since we always show | |
4350 | hex values, and always the bottom 32-bits. */ | |
0c588247 NC |
4351 | SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, section_end); |
4352 | SAFE_BYTE_GET_AND_INC (end, start, pointer_size, section_end); | |
4723351a | 4353 | |
4723351a CC |
4354 | if (begin == 0 && end == 0) |
4355 | { | |
4356 | printf (_("<End of list>\n")); | |
4357 | break; | |
4358 | } | |
4359 | ||
4360 | /* Check base address specifiers. */ | |
4361 | if (begin == (dwarf_vma) -1 && end != (dwarf_vma) -1) | |
4362 | { | |
4363 | base_address = end; | |
4364 | print_dwarf_vma (begin, pointer_size); | |
4365 | print_dwarf_vma (end, pointer_size); | |
4366 | printf (_("(base address)\n")); | |
4367 | continue; | |
4368 | } | |
4369 | ||
4370 | if (start + 2 > section_end) | |
4371 | { | |
4372 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), | |
4373 | offset); | |
4374 | break; | |
4375 | } | |
4376 | ||
0c588247 | 4377 | SAFE_BYTE_GET_AND_INC (length, start, 2, section_end); |
4723351a CC |
4378 | |
4379 | if (start + length > section_end) | |
4380 | { | |
4381 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), | |
4382 | offset); | |
4383 | break; | |
4384 | } | |
4385 | ||
4386 | print_dwarf_vma (begin + base_address, pointer_size); | |
4387 | print_dwarf_vma (end + base_address, pointer_size); | |
4388 | ||
4389 | putchar ('('); | |
4390 | need_frame_base = decode_location_expression (start, | |
4391 | pointer_size, | |
4392 | offset_size, | |
4393 | dwarf_version, | |
4394 | length, | |
4395 | cu_offset, section); | |
4396 | putchar (')'); | |
4397 | ||
4398 | if (need_frame_base && !has_frame_base) | |
4399 | printf (_(" [without DW_AT_frame_base]")); | |
4400 | ||
4401 | if (begin == end) | |
4402 | fputs (_(" (start == end)"), stdout); | |
4403 | else if (begin > end) | |
4404 | fputs (_(" (start > end)"), stdout); | |
4405 | ||
4406 | putchar ('\n'); | |
4407 | ||
4408 | start += length; | |
4409 | } | |
4410 | ||
4411 | *start_ptr = start; | |
4412 | } | |
4413 | ||
fab128ef CC |
4414 | /* Print a .debug_addr table index in decimal, surrounded by square brackets, |
4415 | right-adjusted in a field of length LEN, and followed by a space. */ | |
4416 | ||
4417 | static void | |
4418 | print_addr_index (unsigned int idx, unsigned int len) | |
4419 | { | |
4420 | static char buf[15]; | |
4421 | snprintf (buf, sizeof (buf), "[%d]", idx); | |
341f9135 | 4422 | printf ("%*s ", len, buf); |
fab128ef CC |
4423 | } |
4424 | ||
4723351a CC |
4425 | /* Display a location list from a .dwo section. It uses address indexes rather |
4426 | than embedded addresses. This code closely follows display_loc_list, but the | |
4427 | two are sufficiently different that combining things is very ugly. */ | |
4428 | ||
4429 | static void | |
4430 | display_loc_list_dwo (struct dwarf_section *section, | |
4431 | unsigned char **start_ptr, | |
82b1b41b | 4432 | unsigned int debug_info_entry, |
4723351a CC |
4433 | unsigned long offset, |
4434 | int has_frame_base) | |
4435 | { | |
4436 | unsigned char *start = *start_ptr; | |
4437 | unsigned char *section_end = section->start + section->size; | |
82b1b41b NC |
4438 | unsigned long cu_offset; |
4439 | unsigned int pointer_size; | |
4440 | unsigned int offset_size; | |
4441 | int dwarf_version; | |
4723351a CC |
4442 | int entry_type; |
4443 | unsigned short length; | |
4444 | int need_frame_base; | |
fab128ef | 4445 | unsigned int idx; |
4723351a CC |
4446 | unsigned int bytes_read; |
4447 | ||
82b1b41b NC |
4448 | if (debug_info_entry >= num_debug_info_entries) |
4449 | { | |
4450 | warn (_("No debug information for loc lists of entry: %u\n"), | |
4451 | debug_info_entry); | |
4452 | return; | |
4453 | } | |
4454 | ||
4455 | cu_offset = debug_information [debug_info_entry].cu_offset; | |
4456 | pointer_size = debug_information [debug_info_entry].pointer_size; | |
4457 | offset_size = debug_information [debug_info_entry].offset_size; | |
4458 | dwarf_version = debug_information [debug_info_entry].dwarf_version; | |
4459 | ||
f41e4712 NC |
4460 | if (pointer_size < 2 || pointer_size > 8) |
4461 | { | |
4462 | warn (_("Invalid pointer size (%d) in debug info for entry %d\n"), | |
4463 | pointer_size, debug_info_entry); | |
4464 | return; | |
4465 | } | |
4466 | ||
4723351a CC |
4467 | while (1) |
4468 | { | |
fab128ef | 4469 | printf (" %8.8lx ", offset + (start - *start_ptr)); |
4723351a | 4470 | |
fab128ef | 4471 | if (start >= section_end) |
4723351a CC |
4472 | { |
4473 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), | |
4474 | offset); | |
4475 | break; | |
4476 | } | |
4477 | ||
0c588247 | 4478 | SAFE_BYTE_GET_AND_INC (entry_type, start, 1, section_end); |
4723351a CC |
4479 | switch (entry_type) |
4480 | { | |
4481 | case 0: /* A terminating entry. */ | |
4723351a | 4482 | *start_ptr = start; |
fab128ef | 4483 | printf (_("<End of list>\n")); |
4723351a CC |
4484 | return; |
4485 | case 1: /* A base-address entry. */ | |
f6f0e17b | 4486 | idx = read_uleb128 (start, &bytes_read, section_end); |
4723351a | 4487 | start += bytes_read; |
fab128ef CC |
4488 | print_addr_index (idx, 8); |
4489 | printf (" "); | |
4490 | printf (_("(base address selection entry)\n")); | |
4723351a | 4491 | continue; |
fab128ef | 4492 | case 2: /* A start/end entry. */ |
f6f0e17b | 4493 | idx = read_uleb128 (start, &bytes_read, section_end); |
fab128ef CC |
4494 | start += bytes_read; |
4495 | print_addr_index (idx, 8); | |
f6f0e17b | 4496 | idx = read_uleb128 (start, &bytes_read, section_end); |
4723351a | 4497 | start += bytes_read; |
fab128ef CC |
4498 | print_addr_index (idx, 8); |
4499 | break; | |
4500 | case 3: /* A start/length entry. */ | |
f6f0e17b | 4501 | idx = read_uleb128 (start, &bytes_read, section_end); |
4723351a | 4502 | start += bytes_read; |
fab128ef | 4503 | print_addr_index (idx, 8); |
0c588247 | 4504 | SAFE_BYTE_GET_AND_INC (idx, start, 4, section_end); |
fab128ef CC |
4505 | printf ("%08x ", idx); |
4506 | break; | |
4507 | case 4: /* An offset pair entry. */ | |
0c588247 | 4508 | SAFE_BYTE_GET_AND_INC (idx, start, 4, section_end); |
fab128ef | 4509 | printf ("%08x ", idx); |
0c588247 | 4510 | SAFE_BYTE_GET_AND_INC (idx, start, 4, section_end); |
fab128ef | 4511 | printf ("%08x ", idx); |
4723351a CC |
4512 | break; |
4513 | default: | |
fab128ef | 4514 | warn (_("Unknown location list entry type 0x%x.\n"), entry_type); |
4723351a CC |
4515 | *start_ptr = start; |
4516 | return; | |
4517 | } | |
4518 | ||
4519 | if (start + 2 > section_end) | |
4520 | { | |
4521 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), | |
4522 | offset); | |
4523 | break; | |
4524 | } | |
4525 | ||
0c588247 | 4526 | SAFE_BYTE_GET_AND_INC (length, start, 2, section_end); |
4723351a CC |
4527 | if (start + length > section_end) |
4528 | { | |
4529 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), | |
4530 | offset); | |
4531 | break; | |
4532 | } | |
4533 | ||
4534 | putchar ('('); | |
4535 | need_frame_base = decode_location_expression (start, | |
4536 | pointer_size, | |
4537 | offset_size, | |
4538 | dwarf_version, | |
4539 | length, | |
4540 | cu_offset, section); | |
4541 | putchar (')'); | |
4542 | ||
4543 | if (need_frame_base && !has_frame_base) | |
4544 | printf (_(" [without DW_AT_frame_base]")); | |
4545 | ||
4546 | putchar ('\n'); | |
4547 | ||
4548 | start += length; | |
4549 | } | |
4550 | ||
4551 | *start_ptr = start; | |
4552 | } | |
4553 | ||
51d0d03f JJ |
4554 | /* Sort array of indexes in ascending order of loc_offsets[idx]. */ |
4555 | ||
4556 | static dwarf_vma *loc_offsets; | |
4557 | ||
4558 | static int | |
4559 | loc_offsets_compar (const void *ap, const void *bp) | |
4560 | { | |
4561 | dwarf_vma a = loc_offsets[*(const unsigned int *) ap]; | |
4562 | dwarf_vma b = loc_offsets[*(const unsigned int *) bp]; | |
4563 | ||
4564 | return (a > b) - (b > a); | |
4565 | } | |
4566 | ||
19e6b90e L |
4567 | static int |
4568 | display_debug_loc (struct dwarf_section *section, void *file) | |
4569 | { | |
4570 | unsigned char *start = section->start; | |
19e6b90e L |
4571 | unsigned long bytes; |
4572 | unsigned char *section_begin = start; | |
4573 | unsigned int num_loc_list = 0; | |
4574 | unsigned long last_offset = 0; | |
4575 | unsigned int first = 0; | |
4576 | unsigned int i; | |
4577 | unsigned int j; | |
51d0d03f | 4578 | unsigned int k; |
19e6b90e | 4579 | int seen_first_offset = 0; |
51d0d03f | 4580 | int locs_sorted = 1; |
19e6b90e | 4581 | unsigned char *next; |
51d0d03f | 4582 | unsigned int *array = NULL; |
4723351a CC |
4583 | const char *suffix = strrchr (section->name, '.'); |
4584 | int is_dwo = 0; | |
4585 | ||
4586 | if (suffix && strcmp (suffix, ".dwo") == 0) | |
4587 | is_dwo = 1; | |
19e6b90e L |
4588 | |
4589 | bytes = section->size; | |
19e6b90e L |
4590 | |
4591 | if (bytes == 0) | |
4592 | { | |
4593 | printf (_("\nThe %s section is empty.\n"), section->name); | |
4594 | return 0; | |
4595 | } | |
4596 | ||
1febe64d NC |
4597 | if (load_debug_info (file) == 0) |
4598 | { | |
4599 | warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"), | |
4600 | section->name); | |
4601 | return 0; | |
4602 | } | |
19e6b90e L |
4603 | |
4604 | /* Check the order of location list in .debug_info section. If | |
4605 | offsets of location lists are in the ascending order, we can | |
4606 | use `debug_information' directly. */ | |
4607 | for (i = 0; i < num_debug_info_entries; i++) | |
4608 | { | |
4609 | unsigned int num; | |
4610 | ||
4611 | num = debug_information [i].num_loc_offsets; | |
51d0d03f JJ |
4612 | if (num > num_loc_list) |
4613 | num_loc_list = num; | |
19e6b90e L |
4614 | |
4615 | /* Check if we can use `debug_information' directly. */ | |
51d0d03f | 4616 | if (locs_sorted && num != 0) |
19e6b90e L |
4617 | { |
4618 | if (!seen_first_offset) | |
4619 | { | |
4620 | /* This is the first location list. */ | |
4621 | last_offset = debug_information [i].loc_offsets [0]; | |
4622 | first = i; | |
4623 | seen_first_offset = 1; | |
4624 | j = 1; | |
4625 | } | |
4626 | else | |
4627 | j = 0; | |
4628 | ||
4629 | for (; j < num; j++) | |
4630 | { | |
4631 | if (last_offset > | |
4632 | debug_information [i].loc_offsets [j]) | |
4633 | { | |
51d0d03f | 4634 | locs_sorted = 0; |
19e6b90e L |
4635 | break; |
4636 | } | |
4637 | last_offset = debug_information [i].loc_offsets [j]; | |
4638 | } | |
4639 | } | |
4640 | } | |
4641 | ||
19e6b90e L |
4642 | if (!seen_first_offset) |
4643 | error (_("No location lists in .debug_info section!\n")); | |
4644 | ||
d4bfc77b | 4645 | if (debug_information [first].num_loc_offsets > 0 |
d493b283 | 4646 | && debug_information [first].loc_offsets [0] != 0) |
47704ddf KT |
4647 | warn (_("Location lists in %s section start at 0x%s\n"), |
4648 | section->name, | |
4649 | dwarf_vmatoa ("x", debug_information [first].loc_offsets [0])); | |
19e6b90e | 4650 | |
51d0d03f JJ |
4651 | if (!locs_sorted) |
4652 | array = (unsigned int *) xcmalloc (num_loc_list, sizeof (unsigned int)); | |
19e6b90e | 4653 | printf (_("Contents of the %s section:\n\n"), section->name); |
fab128ef | 4654 | printf (_(" Offset Begin End Expression\n")); |
19e6b90e L |
4655 | |
4656 | seen_first_offset = 0; | |
4657 | for (i = first; i < num_debug_info_entries; i++) | |
4658 | { | |
19e6b90e | 4659 | unsigned long offset; |
19e6b90e | 4660 | unsigned long base_address; |
19e6b90e L |
4661 | int has_frame_base; |
4662 | ||
51d0d03f JJ |
4663 | if (!locs_sorted) |
4664 | { | |
4665 | for (k = 0; k < debug_information [i].num_loc_offsets; k++) | |
4666 | array[k] = k; | |
4667 | loc_offsets = debug_information [i].loc_offsets; | |
4668 | qsort (array, debug_information [i].num_loc_offsets, | |
4669 | sizeof (*array), loc_offsets_compar); | |
4670 | } | |
19e6b90e | 4671 | |
51d0d03f | 4672 | for (k = 0; k < debug_information [i].num_loc_offsets; k++) |
19e6b90e | 4673 | { |
51d0d03f JJ |
4674 | j = locs_sorted ? k : array[k]; |
4675 | if (k | |
4676 | && debug_information [i].loc_offsets [locs_sorted | |
4677 | ? k - 1 : array [k - 1]] | |
4678 | == debug_information [i].loc_offsets [j]) | |
4679 | continue; | |
19e6b90e | 4680 | has_frame_base = debug_information [i].have_frame_base [j]; |
d493b283 | 4681 | offset = debug_information [i].loc_offsets [j]; |
19e6b90e L |
4682 | next = section_begin + offset; |
4683 | base_address = debug_information [i].base_address; | |
4684 | ||
4685 | if (!seen_first_offset) | |
4686 | seen_first_offset = 1; | |
4687 | else | |
4688 | { | |
4689 | if (start < next) | |
4690 | warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"), | |
0af1713e AM |
4691 | (unsigned long) (start - section_begin), |
4692 | (unsigned long) (next - section_begin)); | |
19e6b90e L |
4693 | else if (start > next) |
4694 | warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"), | |
0af1713e AM |
4695 | (unsigned long) (start - section_begin), |
4696 | (unsigned long) (next - section_begin)); | |
19e6b90e L |
4697 | } |
4698 | start = next; | |
4699 | ||
4700 | if (offset >= bytes) | |
4701 | { | |
4702 | warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"), | |
4703 | offset); | |
4704 | continue; | |
4705 | } | |
4706 | ||
4723351a CC |
4707 | if (is_dwo) |
4708 | display_loc_list_dwo (section, &start, i, offset, has_frame_base); | |
4709 | else | |
4710 | display_loc_list (section, &start, i, offset, base_address, | |
4711 | has_frame_base); | |
19e6b90e L |
4712 | } |
4713 | } | |
031cd65f | 4714 | |
4723351a | 4715 | if (start < section->start + section->size) |
031cd65f | 4716 | warn (_("There are %ld unused bytes at the end of section %s\n"), |
4723351a | 4717 | (long) (section->start + section->size - start), section->name); |
98fb390a | 4718 | putchar ('\n'); |
51d0d03f | 4719 | free (array); |
19e6b90e L |
4720 | return 1; |
4721 | } | |
4722 | ||
4723 | static int | |
4724 | display_debug_str (struct dwarf_section *section, | |
4725 | void *file ATTRIBUTE_UNUSED) | |
4726 | { | |
4727 | unsigned char *start = section->start; | |
4728 | unsigned long bytes = section->size; | |
4729 | dwarf_vma addr = section->address; | |
4730 | ||
4731 | if (bytes == 0) | |
4732 | { | |
4733 | printf (_("\nThe %s section is empty.\n"), section->name); | |
4734 | return 0; | |
4735 | } | |
4736 | ||
4737 | printf (_("Contents of the %s section:\n\n"), section->name); | |
4738 | ||
4739 | while (bytes) | |
4740 | { | |
4741 | int j; | |
4742 | int k; | |
4743 | int lbytes; | |
4744 | ||
4745 | lbytes = (bytes > 16 ? 16 : bytes); | |
4746 | ||
4747 | printf (" 0x%8.8lx ", (unsigned long) addr); | |
4748 | ||
4749 | for (j = 0; j < 16; j++) | |
4750 | { | |
4751 | if (j < lbytes) | |
4752 | printf ("%2.2x", start[j]); | |
4753 | else | |
4754 | printf (" "); | |
4755 | ||
4756 | if ((j & 3) == 3) | |
4757 | printf (" "); | |
4758 | } | |
4759 | ||
4760 | for (j = 0; j < lbytes; j++) | |
4761 | { | |
4762 | k = start[j]; | |
4763 | if (k >= ' ' && k < 0x80) | |
4764 | printf ("%c", k); | |
4765 | else | |
4766 | printf ("."); | |
4767 | } | |
4768 | ||
4769 | putchar ('\n'); | |
4770 | ||
4771 | start += lbytes; | |
4772 | addr += lbytes; | |
4773 | bytes -= lbytes; | |
4774 | } | |
4775 | ||
4776 | putchar ('\n'); | |
4777 | ||
4778 | return 1; | |
4779 | } | |
4780 | ||
19e6b90e L |
4781 | static int |
4782 | display_debug_info (struct dwarf_section *section, void *file) | |
4783 | { | |
4723351a | 4784 | return process_debug_info (section, file, section->abbrev_sec, 0, 0); |
19e6b90e L |
4785 | } |
4786 | ||
2b6f5997 CC |
4787 | static int |
4788 | display_debug_types (struct dwarf_section *section, void *file) | |
4789 | { | |
4723351a | 4790 | return process_debug_info (section, file, section->abbrev_sec, 0, 1); |
6f875884 TG |
4791 | } |
4792 | ||
4793 | static int | |
4794 | display_trace_info (struct dwarf_section *section, void *file) | |
4795 | { | |
4723351a | 4796 | return process_debug_info (section, file, section->abbrev_sec, 0, 0); |
2b6f5997 | 4797 | } |
19e6b90e L |
4798 | |
4799 | static int | |
4800 | display_debug_aranges (struct dwarf_section *section, | |
4801 | void *file ATTRIBUTE_UNUSED) | |
4802 | { | |
4803 | unsigned char *start = section->start; | |
4804 | unsigned char *end = start + section->size; | |
4805 | ||
80c35038 | 4806 | printf (_("Contents of the %s section:\n\n"), section->name); |
19e6b90e | 4807 | |
6e3d6dc1 NC |
4808 | /* It does not matter if this load fails, |
4809 | we test for that later on. */ | |
4810 | load_debug_info (file); | |
4811 | ||
19e6b90e L |
4812 | while (start < end) |
4813 | { | |
4814 | unsigned char *hdrptr; | |
4815 | DWARF2_Internal_ARange arange; | |
91d6fa6a | 4816 | unsigned char *addr_ranges; |
2d9472a2 NC |
4817 | dwarf_vma length; |
4818 | dwarf_vma address; | |
53b8873b | 4819 | unsigned char address_size; |
19e6b90e | 4820 | int excess; |
bf5117e3 NC |
4821 | unsigned int offset_size; |
4822 | unsigned int initial_length_size; | |
19e6b90e L |
4823 | |
4824 | hdrptr = start; | |
4825 | ||
0c588247 | 4826 | SAFE_BYTE_GET_AND_INC (arange.ar_length, hdrptr, 4, end); |
19e6b90e L |
4827 | if (arange.ar_length == 0xffffffff) |
4828 | { | |
0c588247 | 4829 | SAFE_BYTE_GET_AND_INC (arange.ar_length, hdrptr, 8, end); |
19e6b90e L |
4830 | offset_size = 8; |
4831 | initial_length_size = 12; | |
4832 | } | |
4833 | else | |
4834 | { | |
4835 | offset_size = 4; | |
4836 | initial_length_size = 4; | |
4837 | } | |
4838 | ||
0c588247 NC |
4839 | SAFE_BYTE_GET_AND_INC (arange.ar_version, hdrptr, 2, end); |
4840 | SAFE_BYTE_GET_AND_INC (arange.ar_info_offset, hdrptr, offset_size, end); | |
19e6b90e | 4841 | |
6e3d6dc1 NC |
4842 | if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE |
4843 | && num_debug_info_entries > 0 | |
4844 | && find_debug_info_for_offset (arange.ar_info_offset) == NULL) | |
4845 | warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"), | |
47704ddf | 4846 | (unsigned long) arange.ar_info_offset, section->name); |
6e3d6dc1 | 4847 | |
0c588247 NC |
4848 | SAFE_BYTE_GET_AND_INC (arange.ar_pointer_size, hdrptr, 1, end); |
4849 | SAFE_BYTE_GET_AND_INC (arange.ar_segment_size, hdrptr, 1, end); | |
19e6b90e L |
4850 | |
4851 | if (arange.ar_version != 2 && arange.ar_version != 3) | |
4852 | { | |
4853 | warn (_("Only DWARF 2 and 3 aranges are currently supported.\n")); | |
4854 | break; | |
4855 | } | |
4856 | ||
47704ddf KT |
4857 | printf (_(" Length: %ld\n"), |
4858 | (long) arange.ar_length); | |
19e6b90e | 4859 | printf (_(" Version: %d\n"), arange.ar_version); |
47704ddf KT |
4860 | printf (_(" Offset into .debug_info: 0x%lx\n"), |
4861 | (unsigned long) arange.ar_info_offset); | |
19e6b90e L |
4862 | printf (_(" Pointer Size: %d\n"), arange.ar_pointer_size); |
4863 | printf (_(" Segment Size: %d\n"), arange.ar_segment_size); | |
4864 | ||
53b8873b NC |
4865 | address_size = arange.ar_pointer_size + arange.ar_segment_size; |
4866 | ||
f41e4712 NC |
4867 | /* PR 17512: file: 001-108546-0.001:0.1. */ |
4868 | if (address_size == 0 || address_size > 8) | |
b3681d67 L |
4869 | { |
4870 | error (_("Invalid address size in %s section!\n"), | |
4871 | section->name); | |
4872 | break; | |
4873 | } | |
4874 | ||
53b8873b NC |
4875 | /* The DWARF spec does not require that the address size be a power |
4876 | of two, but we do. This will have to change if we ever encounter | |
4877 | an uneven architecture. */ | |
4878 | if ((address_size & (address_size - 1)) != 0) | |
4879 | { | |
4880 | warn (_("Pointer size + Segment size is not a power of two.\n")); | |
4881 | break; | |
4882 | } | |
cecf136e | 4883 | |
209c9a13 NC |
4884 | if (address_size > 4) |
4885 | printf (_("\n Address Length\n")); | |
4886 | else | |
4887 | printf (_("\n Address Length\n")); | |
19e6b90e | 4888 | |
91d6fa6a | 4889 | addr_ranges = hdrptr; |
19e6b90e | 4890 | |
53b8873b NC |
4891 | /* Must pad to an alignment boundary that is twice the address size. */ |
4892 | excess = (hdrptr - start) % (2 * address_size); | |
19e6b90e | 4893 | if (excess) |
91d6fa6a | 4894 | addr_ranges += (2 * address_size) - excess; |
19e6b90e | 4895 | |
1617e571 AM |
4896 | start += arange.ar_length + initial_length_size; |
4897 | ||
91d6fa6a | 4898 | while (addr_ranges + 2 * address_size <= start) |
19e6b90e | 4899 | { |
0c588247 NC |
4900 | SAFE_BYTE_GET_AND_INC (address, addr_ranges, address_size, end); |
4901 | SAFE_BYTE_GET_AND_INC (length, addr_ranges, address_size, end); | |
19e6b90e | 4902 | |
80c35038 | 4903 | printf (" "); |
2d9472a2 NC |
4904 | print_dwarf_vma (address, address_size); |
4905 | print_dwarf_vma (length, address_size); | |
4906 | putchar ('\n'); | |
19e6b90e | 4907 | } |
19e6b90e L |
4908 | } |
4909 | ||
4910 | printf ("\n"); | |
4911 | ||
4912 | return 1; | |
4913 | } | |
4914 | ||
4723351a CC |
4915 | /* Comparison function for qsort. */ |
4916 | static int | |
4917 | comp_addr_base (const void * v0, const void * v1) | |
4918 | { | |
4919 | debug_info * info0 = (debug_info *) v0; | |
4920 | debug_info * info1 = (debug_info *) v1; | |
4921 | return info0->addr_base - info1->addr_base; | |
4922 | } | |
4923 | ||
4924 | /* Display the debug_addr section. */ | |
4925 | static int | |
4926 | display_debug_addr (struct dwarf_section *section, | |
4927 | void *file) | |
4928 | { | |
4929 | debug_info **debug_addr_info; | |
4930 | unsigned char *entry; | |
4931 | unsigned char *end; | |
4932 | unsigned int i; | |
4933 | unsigned int count; | |
4934 | ||
4935 | if (section->size == 0) | |
4936 | { | |
4937 | printf (_("\nThe %s section is empty.\n"), section->name); | |
4938 | return 0; | |
4939 | } | |
4940 | ||
4941 | if (load_debug_info (file) == 0) | |
4942 | { | |
4943 | warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"), | |
4944 | section->name); | |
4945 | return 0; | |
4946 | } | |
4947 | ||
4948 | printf (_("Contents of the %s section:\n\n"), section->name); | |
4949 | ||
1306a742 NC |
4950 | /* PR 17531: file: cf38d01b. |
4951 | We use xcalloc because a corrupt file may not have initialised all of the | |
4952 | fields in the debug_info structure, which means that the sort below might | |
4953 | try to move uninitialised data. */ | |
4954 | debug_addr_info = (debug_info **) xcalloc ((num_debug_info_entries + 1), | |
4955 | sizeof (debug_info *)); | |
4723351a CC |
4956 | |
4957 | count = 0; | |
4958 | for (i = 0; i < num_debug_info_entries; i++) | |
82b1b41b | 4959 | if (debug_information [i].addr_base != DEBUG_INFO_UNAVAILABLE) |
1306a742 NC |
4960 | { |
4961 | /* PR 17531: file: cf38d01b. */ | |
4962 | if (debug_information[i].addr_base >= section->size) | |
4963 | warn (_("Corrupt address base (%lx) found in debug section %u\n"), | |
4964 | (unsigned long) debug_information[i].addr_base, i); | |
4965 | else | |
4966 | debug_addr_info [count++] = debug_information + i; | |
4967 | } | |
4723351a CC |
4968 | |
4969 | /* Add a sentinel to make iteration convenient. */ | |
4970 | debug_addr_info [count] = (debug_info *) xmalloc (sizeof (debug_info)); | |
4971 | debug_addr_info [count]->addr_base = section->size; | |
4723351a | 4972 | qsort (debug_addr_info, count, sizeof (debug_info *), comp_addr_base); |
1306a742 | 4973 | |
4723351a CC |
4974 | for (i = 0; i < count; i++) |
4975 | { | |
4976 | unsigned int idx; | |
fab128ef | 4977 | unsigned int address_size = debug_addr_info [i]->pointer_size; |
4723351a CC |
4978 | |
4979 | printf (_(" For compilation unit at offset 0x%s:\n"), | |
4980 | dwarf_vmatoa ("x", debug_addr_info [i]->cu_offset)); | |
4981 | ||
fab128ef | 4982 | printf (_("\tIndex\tAddress\n")); |
4723351a CC |
4983 | entry = section->start + debug_addr_info [i]->addr_base; |
4984 | end = section->start + debug_addr_info [i + 1]->addr_base; | |
4985 | idx = 0; | |
4986 | while (entry < end) | |
4987 | { | |
fab128ef CC |
4988 | dwarf_vma base = byte_get (entry, address_size); |
4989 | printf (_("\t%d:\t"), idx); | |
4990 | print_dwarf_vma (base, address_size); | |
4991 | printf ("\n"); | |
4992 | entry += address_size; | |
4723351a CC |
4993 | idx++; |
4994 | } | |
4995 | } | |
4996 | printf ("\n"); | |
4997 | ||
4998 | free (debug_addr_info); | |
4999 | return 1; | |
5000 | } | |
5001 | ||
5002 | /* Display the .debug_str_offsets and .debug_str_offsets.dwo sections. */ | |
5003 | static int | |
5004 | display_debug_str_offsets (struct dwarf_section *section, | |
5005 | void *file ATTRIBUTE_UNUSED) | |
5006 | { | |
5007 | if (section->size == 0) | |
5008 | { | |
5009 | printf (_("\nThe %s section is empty.\n"), section->name); | |
5010 | return 0; | |
5011 | } | |
5012 | /* TODO: Dump the contents. This is made somewhat difficult by not knowing | |
5013 | what the offset size is for this section. */ | |
5014 | return 1; | |
5015 | } | |
5016 | ||
01a8f077 JK |
5017 | /* Each debug_information[x].range_lists[y] gets this representation for |
5018 | sorting purposes. */ | |
5019 | ||
5020 | struct range_entry | |
467c65bc NC |
5021 | { |
5022 | /* The debug_information[x].range_lists[y] value. */ | |
5023 | unsigned long ranges_offset; | |
01a8f077 | 5024 | |
467c65bc NC |
5025 | /* Original debug_information to find parameters of the data. */ |
5026 | debug_info *debug_info_p; | |
5027 | }; | |
01a8f077 JK |
5028 | |
5029 | /* Sort struct range_entry in ascending order of its RANGES_OFFSET. */ | |
5030 | ||
5031 | static int | |
5032 | range_entry_compar (const void *ap, const void *bp) | |
5033 | { | |
3f5e193b NC |
5034 | const struct range_entry *a_re = (const struct range_entry *) ap; |
5035 | const struct range_entry *b_re = (const struct range_entry *) bp; | |
01a8f077 JK |
5036 | const unsigned long a = a_re->ranges_offset; |
5037 | const unsigned long b = b_re->ranges_offset; | |
5038 | ||
5039 | return (a > b) - (b > a); | |
5040 | } | |
5041 | ||
19e6b90e L |
5042 | static int |
5043 | display_debug_ranges (struct dwarf_section *section, | |
5044 | void *file ATTRIBUTE_UNUSED) | |
5045 | { | |
5046 | unsigned char *start = section->start; | |
a2ff7a4b | 5047 | unsigned char *last_start = start; |
f6f0e17b | 5048 | unsigned long bytes = section->size; |
19e6b90e | 5049 | unsigned char *section_begin = start; |
f6f0e17b | 5050 | unsigned char *finish = start + bytes; |
01a8f077 JK |
5051 | unsigned int num_range_list, i; |
5052 | struct range_entry *range_entries, *range_entry_fill; | |
19e6b90e | 5053 | |
19e6b90e L |
5054 | if (bytes == 0) |
5055 | { | |
5056 | printf (_("\nThe %s section is empty.\n"), section->name); | |
5057 | return 0; | |
5058 | } | |
5059 | ||
1febe64d NC |
5060 | if (load_debug_info (file) == 0) |
5061 | { | |
5062 | warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"), | |
5063 | section->name); | |
5064 | return 0; | |
5065 | } | |
19e6b90e | 5066 | |
01a8f077 | 5067 | num_range_list = 0; |
19e6b90e | 5068 | for (i = 0; i < num_debug_info_entries; i++) |
01a8f077 | 5069 | num_range_list += debug_information [i].num_range_lists; |
19e6b90e | 5070 | |
01a8f077 | 5071 | if (num_range_list == 0) |
4723351a CC |
5072 | { |
5073 | /* This can happen when the file was compiled with -gsplit-debug | |
5074 | which removes references to range lists from the primary .o file. */ | |
5075 | printf (_("No range lists in .debug_info section.\n")); | |
5076 | return 1; | |
5077 | } | |
19e6b90e | 5078 | |
3f5e193b NC |
5079 | range_entries = (struct range_entry *) |
5080 | xmalloc (sizeof (*range_entries) * num_range_list); | |
01a8f077 | 5081 | range_entry_fill = range_entries; |
19e6b90e | 5082 | |
01a8f077 JK |
5083 | for (i = 0; i < num_debug_info_entries; i++) |
5084 | { | |
5085 | debug_info *debug_info_p = &debug_information[i]; | |
5086 | unsigned int j; | |
5087 | ||
5088 | for (j = 0; j < debug_info_p->num_range_lists; j++) | |
5089 | { | |
5090 | range_entry_fill->ranges_offset = debug_info_p->range_lists[j]; | |
5091 | range_entry_fill->debug_info_p = debug_info_p; | |
5092 | range_entry_fill++; | |
19e6b90e L |
5093 | } |
5094 | } | |
5095 | ||
01a8f077 JK |
5096 | qsort (range_entries, num_range_list, sizeof (*range_entries), |
5097 | range_entry_compar); | |
19e6b90e | 5098 | |
d493b283 | 5099 | if (dwarf_check != 0 && range_entries[0].ranges_offset != 0) |
19e6b90e | 5100 | warn (_("Range lists in %s section start at 0x%lx\n"), |
01a8f077 | 5101 | section->name, range_entries[0].ranges_offset); |
19e6b90e L |
5102 | |
5103 | printf (_("Contents of the %s section:\n\n"), section->name); | |
5104 | printf (_(" Offset Begin End\n")); | |
5105 | ||
01a8f077 | 5106 | for (i = 0; i < num_range_list; i++) |
19e6b90e | 5107 | { |
01a8f077 JK |
5108 | struct range_entry *range_entry = &range_entries[i]; |
5109 | debug_info *debug_info_p = range_entry->debug_info_p; | |
19e6b90e | 5110 | unsigned int pointer_size; |
01a8f077 JK |
5111 | unsigned long offset; |
5112 | unsigned char *next; | |
19e6b90e L |
5113 | unsigned long base_address; |
5114 | ||
01a8f077 | 5115 | pointer_size = debug_info_p->pointer_size; |
d493b283 | 5116 | offset = range_entry->ranges_offset; |
01a8f077 JK |
5117 | next = section_begin + offset; |
5118 | base_address = debug_info_p->base_address; | |
cecf136e | 5119 | |
f41e4712 NC |
5120 | /* PR 17512: file: 001-101485-0.001:0.1. */ |
5121 | if (pointer_size < 2 || pointer_size > 8) | |
5122 | { | |
5123 | warn (_("Corrupt pointer size (%d) in debug entry at offset %8.8lx\n"), | |
5124 | pointer_size, offset); | |
5125 | continue; | |
5126 | } | |
5127 | ||
4723351a | 5128 | if (dwarf_check != 0 && i > 0) |
19e6b90e | 5129 | { |
01a8f077 JK |
5130 | if (start < next) |
5131 | warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"), | |
5132 | (unsigned long) (start - section_begin), | |
5133 | (unsigned long) (next - section_begin), section->name); | |
5134 | else if (start > next) | |
a2ff7a4b AM |
5135 | { |
5136 | if (next == last_start) | |
5137 | continue; | |
5138 | warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"), | |
5139 | (unsigned long) (start - section_begin), | |
5140 | (unsigned long) (next - section_begin), section->name); | |
5141 | } | |
01a8f077 JK |
5142 | } |
5143 | start = next; | |
a2ff7a4b | 5144 | last_start = next; |
19e6b90e | 5145 | |
f6f0e17b | 5146 | while (start < finish) |
01a8f077 JK |
5147 | { |
5148 | dwarf_vma begin; | |
5149 | dwarf_vma end; | |
5150 | ||
5151 | /* Note: we use sign extension here in order to be sure that | |
5152 | we can detect the -1 escape value. Sign extension into the | |
5153 | top 32 bits of a 32-bit address will not affect the values | |
5154 | that we display since we always show hex values, and always | |
5155 | the bottom 32-bits. */ | |
0c588247 | 5156 | SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish); |
f6f0e17b NC |
5157 | if (start >= finish) |
5158 | break; | |
0c588247 | 5159 | SAFE_SIGNED_BYTE_GET_AND_INC (end, start, pointer_size, finish); |
01a8f077 JK |
5160 | |
5161 | printf (" %8.8lx ", offset); | |
5162 | ||
5163 | if (begin == 0 && end == 0) | |
19e6b90e | 5164 | { |
01a8f077 JK |
5165 | printf (_("<End of list>\n")); |
5166 | break; | |
19e6b90e | 5167 | } |
19e6b90e | 5168 | |
01a8f077 JK |
5169 | /* Check base address specifiers. */ |
5170 | if (begin == (dwarf_vma) -1 && end != (dwarf_vma) -1) | |
19e6b90e | 5171 | { |
01a8f077 JK |
5172 | base_address = end; |
5173 | print_dwarf_vma (begin, pointer_size); | |
5174 | print_dwarf_vma (end, pointer_size); | |
5175 | printf ("(base address)\n"); | |
5176 | continue; | |
5177 | } | |
19e6b90e | 5178 | |
01a8f077 JK |
5179 | print_dwarf_vma (begin + base_address, pointer_size); |
5180 | print_dwarf_vma (end + base_address, pointer_size); | |
4a149252 | 5181 | |
01a8f077 JK |
5182 | if (begin == end) |
5183 | fputs (_("(start == end)"), stdout); | |
5184 | else if (begin > end) | |
5185 | fputs (_("(start > end)"), stdout); | |
19e6b90e | 5186 | |
01a8f077 | 5187 | putchar ('\n'); |
19e6b90e L |
5188 | } |
5189 | } | |
5190 | putchar ('\n'); | |
01a8f077 JK |
5191 | |
5192 | free (range_entries); | |
5193 | ||
19e6b90e L |
5194 | return 1; |
5195 | } | |
5196 | ||
5197 | typedef struct Frame_Chunk | |
5198 | { | |
5199 | struct Frame_Chunk *next; | |
5200 | unsigned char *chunk_start; | |
a1165289 | 5201 | unsigned int ncols; |
19e6b90e L |
5202 | /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */ |
5203 | short int *col_type; | |
5204 | int *col_offset; | |
5205 | char *augmentation; | |
5206 | unsigned int code_factor; | |
5207 | int data_factor; | |
bf5117e3 NC |
5208 | dwarf_vma pc_begin; |
5209 | dwarf_vma pc_range; | |
19e6b90e L |
5210 | int cfa_reg; |
5211 | int cfa_offset; | |
a1165289 | 5212 | unsigned int ra; |
19e6b90e L |
5213 | unsigned char fde_encoding; |
5214 | unsigned char cfa_exp; | |
604282a7 JJ |
5215 | unsigned char ptr_size; |
5216 | unsigned char segment_size; | |
19e6b90e L |
5217 | } |
5218 | Frame_Chunk; | |
5219 | ||
665ce1f6 L |
5220 | static const char *const *dwarf_regnames; |
5221 | static unsigned int dwarf_regnames_count; | |
5222 | ||
19e6b90e L |
5223 | /* A marker for a col_type that means this column was never referenced |
5224 | in the frame info. */ | |
5225 | #define DW_CFA_unreferenced (-1) | |
5226 | ||
a1165289 | 5227 | /* Return 0 if no more space is needed, 1 if more space is needed, |
665ce1f6 L |
5228 | -1 for invalid reg. */ |
5229 | ||
5230 | static int | |
5231 | frame_need_space (Frame_Chunk *fc, unsigned int reg) | |
19e6b90e | 5232 | { |
a1165289 | 5233 | unsigned int prev = fc->ncols; |
19e6b90e | 5234 | |
665ce1f6 L |
5235 | if (reg < (unsigned int) fc->ncols) |
5236 | return 0; | |
5237 | ||
5238 | if (dwarf_regnames_count | |
5239 | && reg > dwarf_regnames_count) | |
5240 | return -1; | |
19e6b90e L |
5241 | |
5242 | fc->ncols = reg + 1; | |
a1165289 NC |
5243 | /* PR 17512: file: 10450-2643-0.004. |
5244 | If reg == -1 then this can happen... */ | |
5245 | if (fc->ncols == 0) | |
5246 | return -1; | |
5247 | ||
06614111 NC |
5248 | /* PR 17512: file: 2844a11d. */ |
5249 | if (fc->ncols > 1024) | |
5250 | { | |
5251 | error (_("Unfeasibly large register number: %u\n"), reg); | |
5252 | fc->ncols = 0; | |
5253 | /* FIXME: 1024 is an arbitrary limit. Increase it if | |
5254 | we ever encounter a valid binary that exceeds it. */ | |
5255 | return -1; | |
5256 | } | |
5257 | ||
3f5e193b NC |
5258 | fc->col_type = (short int *) xcrealloc (fc->col_type, fc->ncols, |
5259 | sizeof (short int)); | |
5260 | fc->col_offset = (int *) xcrealloc (fc->col_offset, fc->ncols, sizeof (int)); | |
041830e0 NC |
5261 | /* PR 17512: file:002-10025-0.005. */ |
5262 | if (fc->col_type == NULL || fc->col_offset == NULL) | |
5263 | { | |
5264 | error (_("Out of memory allocating %u columns in dwarf frame arrays\n"), | |
5265 | fc->ncols); | |
5266 | fc->ncols = 0; | |
5267 | return -1; | |
5268 | } | |
19e6b90e L |
5269 | |
5270 | while (prev < fc->ncols) | |
5271 | { | |
5272 | fc->col_type[prev] = DW_CFA_unreferenced; | |
5273 | fc->col_offset[prev] = 0; | |
5274 | prev++; | |
5275 | } | |
665ce1f6 | 5276 | return 1; |
19e6b90e L |
5277 | } |
5278 | ||
2dc4cec1 L |
5279 | static const char *const dwarf_regnames_i386[] = |
5280 | { | |
43234a1e L |
5281 | "eax", "ecx", "edx", "ebx", /* 0 - 3 */ |
5282 | "esp", "ebp", "esi", "edi", /* 4 - 7 */ | |
5283 | "eip", "eflags", NULL, /* 8 - 10 */ | |
5284 | "st0", "st1", "st2", "st3", /* 11 - 14 */ | |
5285 | "st4", "st5", "st6", "st7", /* 15 - 18 */ | |
5286 | NULL, NULL, /* 19 - 20 */ | |
5287 | "xmm0", "xmm1", "xmm2", "xmm3", /* 21 - 24 */ | |
5288 | "xmm4", "xmm5", "xmm6", "xmm7", /* 25 - 28 */ | |
5289 | "mm0", "mm1", "mm2", "mm3", /* 29 - 32 */ | |
5290 | "mm4", "mm5", "mm6", "mm7", /* 33 - 36 */ | |
5291 | "fcw", "fsw", "mxcsr", /* 37 - 39 */ | |
5292 | "es", "cs", "ss", "ds", "fs", "gs", NULL, NULL, /* 40 - 47 */ | |
5293 | "tr", "ldtr", /* 48 - 49 */ | |
5294 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 50 - 57 */ | |
5295 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 58 - 65 */ | |
5296 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 66 - 73 */ | |
5297 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 74 - 81 */ | |
5298 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 82 - 89 */ | |
5299 | NULL, NULL, NULL, /* 90 - 92 */ | |
5300 | "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7" /* 93 - 100 */ | |
2dc4cec1 L |
5301 | }; |
5302 | ||
b129eb0e RH |
5303 | void |
5304 | init_dwarf_regnames_i386 (void) | |
5305 | { | |
5306 | dwarf_regnames = dwarf_regnames_i386; | |
5307 | dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_i386); | |
5308 | } | |
5309 | ||
2dc4cec1 L |
5310 | static const char *const dwarf_regnames_x86_64[] = |
5311 | { | |
5312 | "rax", "rdx", "rcx", "rbx", | |
5313 | "rsi", "rdi", "rbp", "rsp", | |
5314 | "r8", "r9", "r10", "r11", | |
5315 | "r12", "r13", "r14", "r15", | |
5316 | "rip", | |
5317 | "xmm0", "xmm1", "xmm2", "xmm3", | |
5318 | "xmm4", "xmm5", "xmm6", "xmm7", | |
5319 | "xmm8", "xmm9", "xmm10", "xmm11", | |
5320 | "xmm12", "xmm13", "xmm14", "xmm15", | |
5321 | "st0", "st1", "st2", "st3", | |
5322 | "st4", "st5", "st6", "st7", | |
5323 | "mm0", "mm1", "mm2", "mm3", | |
5324 | "mm4", "mm5", "mm6", "mm7", | |
5325 | "rflags", | |
5326 | "es", "cs", "ss", "ds", "fs", "gs", NULL, NULL, | |
5327 | "fs.base", "gs.base", NULL, NULL, | |
5328 | "tr", "ldtr", | |
43234a1e L |
5329 | "mxcsr", "fcw", "fsw", |
5330 | "xmm16", "xmm17", "xmm18", "xmm19", | |
5331 | "xmm20", "xmm21", "xmm22", "xmm23", | |
5332 | "xmm24", "xmm25", "xmm26", "xmm27", | |
5333 | "xmm28", "xmm29", "xmm30", "xmm31", | |
5334 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 83 - 90 */ | |
5335 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 91 - 98 */ | |
5336 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 99 - 106 */ | |
5337 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 107 - 114 */ | |
5338 | NULL, NULL, NULL, /* 115 - 117 */ | |
5339 | "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7" | |
2dc4cec1 L |
5340 | }; |
5341 | ||
b129eb0e RH |
5342 | void |
5343 | init_dwarf_regnames_x86_64 (void) | |
5344 | { | |
5345 | dwarf_regnames = dwarf_regnames_x86_64; | |
5346 | dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_x86_64); | |
5347 | } | |
5348 | ||
4ee22035 RH |
5349 | static const char *const dwarf_regnames_aarch64[] = |
5350 | { | |
5351 | "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", | |
5352 | "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15", | |
5353 | "x16", "x17", "x18", "x19", "x20", "x21", "x22", "x23", | |
5354 | "x24", "x25", "x26", "x27", "x28", "x29", "x30", "sp", | |
5355 | NULL, "elr", NULL, NULL, NULL, NULL, NULL, NULL, | |
5356 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | |
5357 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | |
5358 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | |
5359 | "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", | |
5360 | "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15", | |
5361 | "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", | |
5362 | "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31", | |
5363 | }; | |
5364 | ||
5365 | void | |
5366 | init_dwarf_regnames_aarch64 (void) | |
5367 | { | |
5368 | dwarf_regnames = dwarf_regnames_aarch64; | |
5369 | dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_aarch64); | |
5370 | } | |
5371 | ||
2dc4cec1 L |
5372 | void |
5373 | init_dwarf_regnames (unsigned int e_machine) | |
5374 | { | |
5375 | switch (e_machine) | |
5376 | { | |
5377 | case EM_386: | |
5378 | case EM_486: | |
b129eb0e | 5379 | init_dwarf_regnames_i386 (); |
2dc4cec1 L |
5380 | break; |
5381 | ||
5382 | case EM_X86_64: | |
7f502d6c | 5383 | case EM_L1OM: |
7a9068fe | 5384 | case EM_K1OM: |
b129eb0e | 5385 | init_dwarf_regnames_x86_64 (); |
2dc4cec1 L |
5386 | break; |
5387 | ||
4ee22035 RH |
5388 | case EM_AARCH64: |
5389 | init_dwarf_regnames_aarch64 (); | |
5390 | break; | |
5391 | ||
2dc4cec1 L |
5392 | default: |
5393 | break; | |
5394 | } | |
5395 | } | |
5396 | ||
5397 | static const char * | |
5398 | regname (unsigned int regno, int row) | |
5399 | { | |
5400 | static char reg[64]; | |
5401 | if (dwarf_regnames | |
5402 | && regno < dwarf_regnames_count | |
5403 | && dwarf_regnames [regno] != NULL) | |
5404 | { | |
5405 | if (row) | |
5406 | return dwarf_regnames [regno]; | |
5407 | snprintf (reg, sizeof (reg), "r%d (%s)", regno, | |
5408 | dwarf_regnames [regno]); | |
5409 | } | |
5410 | else | |
5411 | snprintf (reg, sizeof (reg), "r%d", regno); | |
5412 | return reg; | |
5413 | } | |
5414 | ||
19e6b90e | 5415 | static void |
a1165289 | 5416 | frame_display_row (Frame_Chunk *fc, int *need_col_headers, unsigned int *max_regs) |
19e6b90e | 5417 | { |
a1165289 | 5418 | unsigned int r; |
19e6b90e L |
5419 | char tmp[100]; |
5420 | ||
5421 | if (*max_regs < fc->ncols) | |
5422 | *max_regs = fc->ncols; | |
5423 | ||
5424 | if (*need_col_headers) | |
5425 | { | |
91d6fa6a | 5426 | static const char *sloc = " LOC"; |
2dc4cec1 | 5427 | |
19e6b90e L |
5428 | *need_col_headers = 0; |
5429 | ||
91d6fa6a | 5430 | printf ("%-*s CFA ", eh_addr_size * 2, sloc); |
19e6b90e L |
5431 | |
5432 | for (r = 0; r < *max_regs; r++) | |
5433 | if (fc->col_type[r] != DW_CFA_unreferenced) | |
5434 | { | |
5435 | if (r == fc->ra) | |
2dc4cec1 | 5436 | printf ("ra "); |
19e6b90e | 5437 | else |
2dc4cec1 | 5438 | printf ("%-5s ", regname (r, 1)); |
19e6b90e L |
5439 | } |
5440 | ||
5441 | printf ("\n"); | |
5442 | } | |
5443 | ||
bf5117e3 | 5444 | print_dwarf_vma (fc->pc_begin, eh_addr_size); |
19e6b90e L |
5445 | if (fc->cfa_exp) |
5446 | strcpy (tmp, "exp"); | |
5447 | else | |
2dc4cec1 | 5448 | sprintf (tmp, "%s%+d", regname (fc->cfa_reg, 1), fc->cfa_offset); |
19e6b90e L |
5449 | printf ("%-8s ", tmp); |
5450 | ||
5451 | for (r = 0; r < fc->ncols; r++) | |
5452 | { | |
5453 | if (fc->col_type[r] != DW_CFA_unreferenced) | |
5454 | { | |
5455 | switch (fc->col_type[r]) | |
5456 | { | |
5457 | case DW_CFA_undefined: | |
5458 | strcpy (tmp, "u"); | |
5459 | break; | |
5460 | case DW_CFA_same_value: | |
5461 | strcpy (tmp, "s"); | |
5462 | break; | |
5463 | case DW_CFA_offset: | |
5464 | sprintf (tmp, "c%+d", fc->col_offset[r]); | |
5465 | break; | |
12eae2d3 JJ |
5466 | case DW_CFA_val_offset: |
5467 | sprintf (tmp, "v%+d", fc->col_offset[r]); | |
5468 | break; | |
19e6b90e | 5469 | case DW_CFA_register: |
2dc4cec1 | 5470 | sprintf (tmp, "%s", regname (fc->col_offset[r], 0)); |
19e6b90e L |
5471 | break; |
5472 | case DW_CFA_expression: | |
5473 | strcpy (tmp, "exp"); | |
5474 | break; | |
12eae2d3 JJ |
5475 | case DW_CFA_val_expression: |
5476 | strcpy (tmp, "vexp"); | |
5477 | break; | |
19e6b90e L |
5478 | default: |
5479 | strcpy (tmp, "n/a"); | |
5480 | break; | |
5481 | } | |
2dc4cec1 | 5482 | printf ("%-5s ", tmp); |
19e6b90e L |
5483 | } |
5484 | } | |
5485 | printf ("\n"); | |
5486 | } | |
5487 | ||
49727e46 | 5488 | #define GET(VAR, N) SAFE_BYTE_GET_AND_INC (VAR, start, N, end) |
f6f0e17b NC |
5489 | #define LEB() read_uleb128 (start, & length_return, end); start += length_return |
5490 | #define SLEB() read_sleb128 (start, & length_return, end); start += length_return | |
19e6b90e | 5491 | |
49727e46 AM |
5492 | static unsigned char * |
5493 | read_cie (unsigned char *start, unsigned char *end, | |
5494 | Frame_Chunk **p_cie, int *p_version, | |
5495 | unsigned long *p_aug_len, unsigned char **p_aug) | |
5496 | { | |
5497 | int version; | |
5498 | Frame_Chunk *fc; | |
5499 | unsigned int length_return; | |
5500 | unsigned char *augmentation_data = NULL; | |
5501 | unsigned long augmentation_data_len = 0; | |
5502 | ||
041830e0 | 5503 | * p_cie = NULL; |
f41e4712 NC |
5504 | /* PR 17512: file: 001-228113-0.004. */ |
5505 | if (start >= end) | |
5506 | return end; | |
5507 | ||
49727e46 AM |
5508 | fc = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk)); |
5509 | memset (fc, 0, sizeof (Frame_Chunk)); | |
5510 | ||
5511 | fc->col_type = (short int *) xmalloc (sizeof (short int)); | |
5512 | fc->col_offset = (int *) xmalloc (sizeof (int)); | |
5513 | ||
5514 | version = *start++; | |
5515 | ||
5516 | fc->augmentation = (char *) start; | |
f41e4712 NC |
5517 | /* PR 17512: file: 001-228113-0.004. |
5518 | Skip past augmentation name, but avoid running off the end of the data. */ | |
5519 | while (start < end) | |
5520 | if (* start ++ == '\0') | |
5521 | break; | |
5522 | if (start == end) | |
5523 | { | |
5524 | warn (_("No terminator for augmentation name\n")); | |
5525 | return start; | |
5526 | } | |
49727e46 AM |
5527 | |
5528 | if (strcmp (fc->augmentation, "eh") == 0) | |
5529 | start += eh_addr_size; | |
5530 | ||
5531 | if (version >= 4) | |
5532 | { | |
5533 | GET (fc->ptr_size, 1); | |
5534 | GET (fc->segment_size, 1); | |
5535 | eh_addr_size = fc->ptr_size; | |
5536 | } | |
5537 | else | |
5538 | { | |
5539 | fc->ptr_size = eh_addr_size; | |
5540 | fc->segment_size = 0; | |
5541 | } | |
5542 | fc->code_factor = LEB (); | |
5543 | fc->data_factor = SLEB (); | |
5544 | if (version == 1) | |
5545 | { | |
5546 | GET (fc->ra, 1); | |
5547 | } | |
5548 | else | |
5549 | { | |
5550 | fc->ra = LEB (); | |
5551 | } | |
5552 | ||
5553 | if (fc->augmentation[0] == 'z') | |
5554 | { | |
5555 | augmentation_data_len = LEB (); | |
5556 | augmentation_data = start; | |
5557 | start += augmentation_data_len; | |
a1165289 NC |
5558 | /* PR 17512: file: 11042-2589-0.004. */ |
5559 | if (start > end) | |
5560 | { | |
1306a742 | 5561 | warn (_("Augmentation data too long: 0x%lx\n"), augmentation_data_len); |
a1165289 NC |
5562 | return end; |
5563 | } | |
49727e46 AM |
5564 | } |
5565 | ||
5566 | if (augmentation_data_len) | |
5567 | { | |
058037d3 NC |
5568 | unsigned char *p; |
5569 | unsigned char *q; | |
5570 | unsigned char *qend; | |
5571 | ||
49727e46 AM |
5572 | p = (unsigned char *) fc->augmentation + 1; |
5573 | q = augmentation_data; | |
058037d3 NC |
5574 | qend = q + augmentation_data_len; |
5575 | ||
5576 | /* PR 17531: file: 015adfaa. */ | |
5577 | if (qend < q) | |
5578 | { | |
5579 | warn (_("Negative augmentation data length: 0x%lx"), augmentation_data_len); | |
5580 | augmentation_data_len = 0; | |
5581 | } | |
49727e46 | 5582 | |
a1165289 | 5583 | while (p < end && q < augmentation_data + augmentation_data_len) |
49727e46 AM |
5584 | { |
5585 | if (*p == 'L') | |
5586 | q++; | |
5587 | else if (*p == 'P') | |
5588 | q += 1 + size_of_encoded_value (*q); | |
5589 | else if (*p == 'R') | |
5590 | fc->fde_encoding = *q++; | |
5591 | else if (*p == 'S') | |
5592 | ; | |
5593 | else | |
5594 | break; | |
5595 | p++; | |
5596 | } | |
c361b9ac NC |
5597 | /* Note - it is OK if this loop terminates with q < qend. |
5598 | Padding may have been inserted to align the end of the CIE. */ | |
49727e46 AM |
5599 | } |
5600 | ||
5601 | *p_cie = fc; | |
5602 | if (p_version) | |
5603 | *p_version = version; | |
5604 | if (p_aug_len) | |
5605 | { | |
5606 | *p_aug_len = augmentation_data_len; | |
5607 | *p_aug = augmentation_data; | |
5608 | } | |
5609 | return start; | |
5610 | } | |
5611 | ||
19e6b90e L |
5612 | static int |
5613 | display_debug_frames (struct dwarf_section *section, | |
5614 | void *file ATTRIBUTE_UNUSED) | |
5615 | { | |
5616 | unsigned char *start = section->start; | |
5617 | unsigned char *end = start + section->size; | |
5618 | unsigned char *section_start = start; | |
49727e46 | 5619 | Frame_Chunk *chunks = 0, *forward_refs = 0; |
19e6b90e L |
5620 | Frame_Chunk *remembered_state = 0; |
5621 | Frame_Chunk *rs; | |
5622 | int is_eh = strcmp (section->name, ".eh_frame") == 0; | |
5623 | unsigned int length_return; | |
a1165289 | 5624 | unsigned int max_regs = 0; |
665ce1f6 | 5625 | const char *bad_reg = _("bad register: "); |
604282a7 | 5626 | int saved_eh_addr_size = eh_addr_size; |
19e6b90e | 5627 | |
80c35038 | 5628 | printf (_("Contents of the %s section:\n"), section->name); |
19e6b90e L |
5629 | |
5630 | while (start < end) | |
5631 | { | |
5632 | unsigned char *saved_start; | |
5633 | unsigned char *block_end; | |
bf5117e3 NC |
5634 | dwarf_vma length; |
5635 | dwarf_vma cie_id; | |
19e6b90e L |
5636 | Frame_Chunk *fc; |
5637 | Frame_Chunk *cie; | |
5638 | int need_col_headers = 1; | |
5639 | unsigned char *augmentation_data = NULL; | |
5640 | unsigned long augmentation_data_len = 0; | |
bf5117e3 NC |
5641 | unsigned int encoded_ptr_size = saved_eh_addr_size; |
5642 | unsigned int offset_size; | |
5643 | unsigned int initial_length_size; | |
19e6b90e L |
5644 | |
5645 | saved_start = start; | |
19e6b90e | 5646 | |
0c588247 | 5647 | SAFE_BYTE_GET_AND_INC (length, start, 4, end); |
041830e0 | 5648 | |
19e6b90e L |
5649 | if (length == 0) |
5650 | { | |
5651 | printf ("\n%08lx ZERO terminator\n\n", | |
5652 | (unsigned long)(saved_start - section_start)); | |
6937bb54 NC |
5653 | /* Skip any zero terminators that directly follow. |
5654 | A corrupt section size could have loaded a whole | |
5655 | slew of zero filled memory bytes. eg | |
5656 | PR 17512: file: 070-19381-0.004. */ | |
5657 | while (start < end && * start == 0) | |
5658 | ++ start; | |
b758e50f | 5659 | continue; |
19e6b90e L |
5660 | } |
5661 | ||
5662 | if (length == 0xffffffff) | |
5663 | { | |
0c588247 | 5664 | SAFE_BYTE_GET_AND_INC (length, start, 8, end); |
19e6b90e L |
5665 | offset_size = 8; |
5666 | initial_length_size = 12; | |
5667 | } | |
5668 | else | |
5669 | { | |
5670 | offset_size = 4; | |
5671 | initial_length_size = 4; | |
5672 | } | |
5673 | ||
5674 | block_end = saved_start + length + initial_length_size; | |
041830e0 | 5675 | if (block_end > end || block_end < start) |
53b8873b | 5676 | { |
bf5117e3 NC |
5677 | warn ("Invalid length 0x%s in FDE at %#08lx\n", |
5678 | dwarf_vmatoa_1 (NULL, length, offset_size), | |
5679 | (unsigned long) (saved_start - section_start)); | |
53b8873b NC |
5680 | block_end = end; |
5681 | } | |
0c588247 NC |
5682 | |
5683 | SAFE_BYTE_GET_AND_INC (cie_id, start, offset_size, end); | |
19e6b90e | 5684 | |
846a11e4 NC |
5685 | if (is_eh ? (cie_id == 0) : ((offset_size == 4 && cie_id == DW_CIE_ID) |
5686 | || (offset_size == 8 && cie_id == DW64_CIE_ID))) | |
19e6b90e L |
5687 | { |
5688 | int version; | |
a1165289 | 5689 | unsigned int mreg; |
19e6b90e | 5690 | |
49727e46 AM |
5691 | start = read_cie (start, end, &cie, &version, |
5692 | &augmentation_data_len, &augmentation_data); | |
041830e0 NC |
5693 | /* PR 17512: file: 027-135133-0.005. */ |
5694 | if (cie == NULL) | |
5695 | break; | |
a1165289 | 5696 | |
49727e46 | 5697 | fc = cie; |
19e6b90e L |
5698 | fc->next = chunks; |
5699 | chunks = fc; | |
5700 | fc->chunk_start = saved_start; | |
a1165289 | 5701 | mreg = max_regs > 0 ? max_regs - 1 : 0; |
49727e46 AM |
5702 | if (mreg < fc->ra) |
5703 | mreg = fc->ra; | |
06614111 NC |
5704 | if (frame_need_space (fc, mreg) < 0) |
5705 | break; | |
49727e46 AM |
5706 | if (fc->fde_encoding) |
5707 | encoded_ptr_size = size_of_encoded_value (fc->fde_encoding); | |
19e6b90e | 5708 | |
bf5117e3 NC |
5709 | printf ("\n%08lx ", (unsigned long) (saved_start - section_start)); |
5710 | print_dwarf_vma (length, fc->ptr_size); | |
9c41109d | 5711 | print_dwarf_vma (cie_id, offset_size); |
bf5117e3 | 5712 | |
19e6b90e | 5713 | if (do_debug_frames_interp) |
bf5117e3 NC |
5714 | { |
5715 | printf ("CIE \"%s\" cf=%d df=%d ra=%d\n", fc->augmentation, | |
5716 | fc->code_factor, fc->data_factor, fc->ra); | |
5717 | } | |
19e6b90e L |
5718 | else |
5719 | { | |
bf5117e3 | 5720 | printf ("CIE\n"); |
19e6b90e L |
5721 | printf (" Version: %d\n", version); |
5722 | printf (" Augmentation: \"%s\"\n", fc->augmentation); | |
604282a7 JJ |
5723 | if (version >= 4) |
5724 | { | |
5725 | printf (" Pointer Size: %u\n", fc->ptr_size); | |
5726 | printf (" Segment Size: %u\n", fc->segment_size); | |
5727 | } | |
19e6b90e L |
5728 | printf (" Code alignment factor: %u\n", fc->code_factor); |
5729 | printf (" Data alignment factor: %d\n", fc->data_factor); | |
5730 | printf (" Return address column: %d\n", fc->ra); | |
5731 | ||
5732 | if (augmentation_data_len) | |
5733 | { | |
5734 | unsigned long i; | |
a1165289 | 5735 | |
19e6b90e L |
5736 | printf (" Augmentation data: "); |
5737 | for (i = 0; i < augmentation_data_len; ++i) | |
a1165289 NC |
5738 | /* FIXME: If do_wide is FALSE, then we should |
5739 | add carriage returns at 80 columns... */ | |
19e6b90e L |
5740 | printf (" %02x", augmentation_data[i]); |
5741 | putchar ('\n'); | |
5742 | } | |
5743 | putchar ('\n'); | |
5744 | } | |
19e6b90e L |
5745 | } |
5746 | else | |
5747 | { | |
5748 | unsigned char *look_for; | |
5749 | static Frame_Chunk fde_fc; | |
604282a7 | 5750 | unsigned long segment_selector; |
19e6b90e | 5751 | |
49727e46 AM |
5752 | if (is_eh) |
5753 | { | |
5754 | dwarf_vma sign = (dwarf_vma) 1 << (offset_size * 8 - 1); | |
5755 | look_for = start - 4 - ((cie_id ^ sign) - sign); | |
5756 | } | |
5757 | else | |
5758 | look_for = section_start + cie_id; | |
19e6b90e | 5759 | |
49727e46 AM |
5760 | if (look_for <= saved_start) |
5761 | { | |
5762 | for (cie = chunks; cie ; cie = cie->next) | |
5763 | if (cie->chunk_start == look_for) | |
5764 | break; | |
5765 | } | |
5766 | else | |
5767 | { | |
5768 | for (cie = forward_refs; cie ; cie = cie->next) | |
5769 | if (cie->chunk_start == look_for) | |
5770 | break; | |
5771 | if (!cie) | |
5772 | { | |
5773 | unsigned int off_size; | |
5774 | unsigned char *cie_scan; | |
19e6b90e | 5775 | |
49727e46 AM |
5776 | cie_scan = look_for; |
5777 | off_size = 4; | |
5778 | SAFE_BYTE_GET_AND_INC (length, cie_scan, 4, end); | |
5779 | if (length == 0xffffffff) | |
5780 | { | |
5781 | SAFE_BYTE_GET_AND_INC (length, cie_scan, 8, end); | |
5782 | off_size = 8; | |
5783 | } | |
5784 | if (length != 0) | |
5785 | { | |
5786 | dwarf_vma c_id; | |
5787 | ||
5788 | SAFE_BYTE_GET_AND_INC (c_id, cie_scan, off_size, end); | |
5789 | if (is_eh | |
5790 | ? c_id == 0 | |
5791 | : ((off_size == 4 && c_id == DW_CIE_ID) | |
5792 | || (off_size == 8 && c_id == DW64_CIE_ID))) | |
5793 | { | |
5794 | int version; | |
a1165289 | 5795 | unsigned int mreg; |
49727e46 AM |
5796 | |
5797 | read_cie (cie_scan, end, &cie, &version, | |
5798 | &augmentation_data_len, &augmentation_data); | |
a1165289 NC |
5799 | /* PR 17512: file: 3450-2098-0.004. */ |
5800 | if (cie == NULL) | |
5801 | { | |
5802 | warn (_("Failed to read CIE information\n")); | |
5803 | break; | |
5804 | } | |
49727e46 AM |
5805 | cie->next = forward_refs; |
5806 | forward_refs = cie; | |
5807 | cie->chunk_start = look_for; | |
a1165289 | 5808 | mreg = max_regs > 0 ? max_regs - 1 : 0; |
49727e46 AM |
5809 | if (mreg < cie->ra) |
5810 | mreg = cie->ra; | |
06614111 NC |
5811 | if (frame_need_space (cie, mreg) < 0) |
5812 | { | |
5813 | warn (_("Invalid max register\n")); | |
5814 | break; | |
5815 | } | |
49727e46 AM |
5816 | if (cie->fde_encoding) |
5817 | encoded_ptr_size | |
5818 | = size_of_encoded_value (cie->fde_encoding); | |
5819 | } | |
5820 | } | |
5821 | } | |
5822 | } | |
5823 | ||
5824 | fc = &fde_fc; | |
5825 | memset (fc, 0, sizeof (Frame_Chunk)); | |
19e6b90e L |
5826 | |
5827 | if (!cie) | |
5828 | { | |
bf5117e3 NC |
5829 | warn ("Invalid CIE pointer 0x%s in FDE at %#08lx\n", |
5830 | dwarf_vmatoa_1 (NULL, cie_id, offset_size), | |
5831 | (unsigned long) (saved_start - section_start)); | |
19e6b90e | 5832 | fc->ncols = 0; |
3f5e193b NC |
5833 | fc->col_type = (short int *) xmalloc (sizeof (short int)); |
5834 | fc->col_offset = (int *) xmalloc (sizeof (int)); | |
06614111 NC |
5835 | if (frame_need_space (fc, max_regs > 0 ? max_regs - 1 : 0) < 0) |
5836 | { | |
5837 | warn (_("Invalid max register\n")); | |
5838 | break; | |
5839 | } | |
19e6b90e L |
5840 | cie = fc; |
5841 | fc->augmentation = ""; | |
5842 | fc->fde_encoding = 0; | |
604282a7 JJ |
5843 | fc->ptr_size = eh_addr_size; |
5844 | fc->segment_size = 0; | |
19e6b90e L |
5845 | } |
5846 | else | |
5847 | { | |
5848 | fc->ncols = cie->ncols; | |
3f5e193b NC |
5849 | fc->col_type = (short int *) xcmalloc (fc->ncols, sizeof (short int)); |
5850 | fc->col_offset = (int *) xcmalloc (fc->ncols, sizeof (int)); | |
19e6b90e L |
5851 | memcpy (fc->col_type, cie->col_type, fc->ncols * sizeof (short int)); |
5852 | memcpy (fc->col_offset, cie->col_offset, fc->ncols * sizeof (int)); | |
5853 | fc->augmentation = cie->augmentation; | |
604282a7 JJ |
5854 | fc->ptr_size = cie->ptr_size; |
5855 | eh_addr_size = cie->ptr_size; | |
5856 | fc->segment_size = cie->segment_size; | |
19e6b90e L |
5857 | fc->code_factor = cie->code_factor; |
5858 | fc->data_factor = cie->data_factor; | |
5859 | fc->cfa_reg = cie->cfa_reg; | |
5860 | fc->cfa_offset = cie->cfa_offset; | |
5861 | fc->ra = cie->ra; | |
06614111 NC |
5862 | if (frame_need_space (fc, max_regs > 0 ? max_regs - 1: 0) < 0) |
5863 | { | |
5864 | warn (_("Invalid max register\n")); | |
5865 | break; | |
5866 | } | |
19e6b90e L |
5867 | fc->fde_encoding = cie->fde_encoding; |
5868 | } | |
5869 | ||
5870 | if (fc->fde_encoding) | |
5871 | encoded_ptr_size = size_of_encoded_value (fc->fde_encoding); | |
5872 | ||
604282a7 JJ |
5873 | segment_selector = 0; |
5874 | if (fc->segment_size) | |
041830e0 NC |
5875 | SAFE_BYTE_GET_AND_INC (segment_selector, start, fc->segment_size, end); |
5876 | ||
5877 | fc->pc_begin = get_encoded_value (&start, fc->fde_encoding, section, end); | |
19e6b90e | 5878 | |
0c588247 NC |
5879 | /* FIXME: It appears that sometimes the final pc_range value is |
5880 | encoded in less than encoded_ptr_size bytes. See the x86_64 | |
5881 | run of the "objcopy on compressed debug sections" test for an | |
5882 | example of this. */ | |
5883 | SAFE_BYTE_GET_AND_INC (fc->pc_range, start, encoded_ptr_size, end); | |
bf5117e3 | 5884 | |
19e6b90e L |
5885 | if (cie->augmentation[0] == 'z') |
5886 | { | |
5887 | augmentation_data_len = LEB (); | |
5888 | augmentation_data = start; | |
5889 | start += augmentation_data_len; | |
0a9d414a | 5890 | /* PR 17512: file: 722-8446-0.004. */ |
53774b7e | 5891 | if (start >= end || ((signed long) augmentation_data_len) < 0) |
0a9d414a NC |
5892 | { |
5893 | warn (_("Corrupt augmentation data length: %lx\n"), | |
5894 | augmentation_data_len); | |
5895 | start = end; | |
5896 | augmentation_data = NULL; | |
5897 | augmentation_data_len = 0; | |
5898 | } | |
19e6b90e L |
5899 | } |
5900 | ||
bf5117e3 NC |
5901 | printf ("\n%08lx %s %s FDE cie=%08lx pc=", |
5902 | (unsigned long)(saved_start - section_start), | |
5903 | dwarf_vmatoa_1 (NULL, length, fc->ptr_size), | |
9c41109d | 5904 | dwarf_vmatoa_1 (NULL, cie_id, offset_size), |
604282a7 | 5905 | (unsigned long)(cie->chunk_start - section_start)); |
bf5117e3 | 5906 | |
604282a7 JJ |
5907 | if (fc->segment_size) |
5908 | printf ("%04lx:", segment_selector); | |
bf5117e3 NC |
5909 | |
5910 | printf ("%s..%s\n", | |
5911 | dwarf_vmatoa_1 (NULL, fc->pc_begin, fc->ptr_size), | |
5912 | dwarf_vmatoa_1 (NULL, fc->pc_begin + fc->pc_range, fc->ptr_size)); | |
5913 | ||
19e6b90e L |
5914 | if (! do_debug_frames_interp && augmentation_data_len) |
5915 | { | |
5916 | unsigned long i; | |
5917 | ||
5918 | printf (" Augmentation data: "); | |
5919 | for (i = 0; i < augmentation_data_len; ++i) | |
5920 | printf (" %02x", augmentation_data[i]); | |
5921 | putchar ('\n'); | |
5922 | putchar ('\n'); | |
5923 | } | |
5924 | } | |
5925 | ||
5926 | /* At this point, fc is the current chunk, cie (if any) is set, and | |
5927 | we're about to interpret instructions for the chunk. */ | |
5928 | /* ??? At present we need to do this always, since this sizes the | |
5929 | fc->col_type and fc->col_offset arrays, which we write into always. | |
5930 | We should probably split the interpreted and non-interpreted bits | |
5931 | into two different routines, since there's so much that doesn't | |
5932 | really overlap between them. */ | |
5933 | if (1 || do_debug_frames_interp) | |
5934 | { | |
5935 | /* Start by making a pass over the chunk, allocating storage | |
5936 | and taking note of what registers are used. */ | |
5937 | unsigned char *tmp = start; | |
5938 | ||
5939 | while (start < block_end) | |
5940 | { | |
041830e0 NC |
5941 | unsigned int reg, op, opa; |
5942 | unsigned long temp; | |
19e6b90e L |
5943 | |
5944 | op = *start++; | |
5945 | opa = op & 0x3f; | |
5946 | if (op & 0xc0) | |
5947 | op &= 0xc0; | |
5948 | ||
5949 | /* Warning: if you add any more cases to this switch, be | |
5950 | sure to add them to the corresponding switch below. */ | |
5951 | switch (op) | |
5952 | { | |
5953 | case DW_CFA_advance_loc: | |
5954 | break; | |
5955 | case DW_CFA_offset: | |
5956 | LEB (); | |
665ce1f6 L |
5957 | if (frame_need_space (fc, opa) >= 0) |
5958 | fc->col_type[opa] = DW_CFA_undefined; | |
19e6b90e L |
5959 | break; |
5960 | case DW_CFA_restore: | |
665ce1f6 L |
5961 | if (frame_need_space (fc, opa) >= 0) |
5962 | fc->col_type[opa] = DW_CFA_undefined; | |
19e6b90e L |
5963 | break; |
5964 | case DW_CFA_set_loc: | |
5965 | start += encoded_ptr_size; | |
5966 | break; | |
5967 | case DW_CFA_advance_loc1: | |
5968 | start += 1; | |
5969 | break; | |
5970 | case DW_CFA_advance_loc2: | |
5971 | start += 2; | |
5972 | break; | |
5973 | case DW_CFA_advance_loc4: | |
5974 | start += 4; | |
5975 | break; | |
5976 | case DW_CFA_offset_extended: | |
12eae2d3 | 5977 | case DW_CFA_val_offset: |
19e6b90e | 5978 | reg = LEB (); LEB (); |
665ce1f6 L |
5979 | if (frame_need_space (fc, reg) >= 0) |
5980 | fc->col_type[reg] = DW_CFA_undefined; | |
19e6b90e L |
5981 | break; |
5982 | case DW_CFA_restore_extended: | |
5983 | reg = LEB (); | |
665ce1f6 L |
5984 | if (frame_need_space (fc, reg) >= 0) |
5985 | fc->col_type[reg] = DW_CFA_undefined; | |
19e6b90e L |
5986 | break; |
5987 | case DW_CFA_undefined: | |
5988 | reg = LEB (); | |
665ce1f6 L |
5989 | if (frame_need_space (fc, reg) >= 0) |
5990 | fc->col_type[reg] = DW_CFA_undefined; | |
19e6b90e L |
5991 | break; |
5992 | case DW_CFA_same_value: | |
5993 | reg = LEB (); | |
665ce1f6 L |
5994 | if (frame_need_space (fc, reg) >= 0) |
5995 | fc->col_type[reg] = DW_CFA_undefined; | |
19e6b90e L |
5996 | break; |
5997 | case DW_CFA_register: | |
5998 | reg = LEB (); LEB (); | |
665ce1f6 L |
5999 | if (frame_need_space (fc, reg) >= 0) |
6000 | fc->col_type[reg] = DW_CFA_undefined; | |
19e6b90e L |
6001 | break; |
6002 | case DW_CFA_def_cfa: | |
6003 | LEB (); LEB (); | |
6004 | break; | |
6005 | case DW_CFA_def_cfa_register: | |
6006 | LEB (); | |
6007 | break; | |
6008 | case DW_CFA_def_cfa_offset: | |
6009 | LEB (); | |
6010 | break; | |
6011 | case DW_CFA_def_cfa_expression: | |
91d6fa6a | 6012 | temp = LEB (); |
041830e0 NC |
6013 | if (start + temp < start) |
6014 | { | |
6015 | warn (_("Corrupt CFA_def expression value: %lu\n"), temp); | |
6016 | start = block_end; | |
6017 | } | |
6018 | else | |
6019 | start += temp; | |
19e6b90e L |
6020 | break; |
6021 | case DW_CFA_expression: | |
12eae2d3 | 6022 | case DW_CFA_val_expression: |
19e6b90e | 6023 | reg = LEB (); |
91d6fa6a | 6024 | temp = LEB (); |
041830e0 NC |
6025 | if (start + temp < start) |
6026 | { | |
6027 | /* PR 17512: file:306-192417-0.005. */ | |
6028 | warn (_("Corrupt CFA expression value: %lu\n"), temp); | |
6029 | start = block_end; | |
6030 | } | |
6031 | else | |
6032 | start += temp; | |
665ce1f6 L |
6033 | if (frame_need_space (fc, reg) >= 0) |
6034 | fc->col_type[reg] = DW_CFA_undefined; | |
19e6b90e L |
6035 | break; |
6036 | case DW_CFA_offset_extended_sf: | |
12eae2d3 | 6037 | case DW_CFA_val_offset_sf: |
19e6b90e | 6038 | reg = LEB (); SLEB (); |
665ce1f6 L |
6039 | if (frame_need_space (fc, reg) >= 0) |
6040 | fc->col_type[reg] = DW_CFA_undefined; | |
19e6b90e L |
6041 | break; |
6042 | case DW_CFA_def_cfa_sf: | |
6043 | LEB (); SLEB (); | |
6044 | break; | |
6045 | case DW_CFA_def_cfa_offset_sf: | |
6046 | SLEB (); | |
6047 | break; | |
6048 | case DW_CFA_MIPS_advance_loc8: | |
6049 | start += 8; | |
6050 | break; | |
6051 | case DW_CFA_GNU_args_size: | |
6052 | LEB (); | |
6053 | break; | |
6054 | case DW_CFA_GNU_negative_offset_extended: | |
6055 | reg = LEB (); LEB (); | |
665ce1f6 L |
6056 | if (frame_need_space (fc, reg) >= 0) |
6057 | fc->col_type[reg] = DW_CFA_undefined; | |
6058 | break; | |
19e6b90e L |
6059 | default: |
6060 | break; | |
6061 | } | |
6062 | } | |
6063 | start = tmp; | |
6064 | } | |
6065 | ||
6066 | /* Now we know what registers are used, make a second pass over | |
6067 | the chunk, this time actually printing out the info. */ | |
6068 | ||
6069 | while (start < block_end) | |
6070 | { | |
6071 | unsigned op, opa; | |
6072 | unsigned long ul, reg, roffs; | |
bf5117e3 NC |
6073 | long l; |
6074 | dwarf_vma ofs; | |
19e6b90e | 6075 | dwarf_vma vma; |
665ce1f6 | 6076 | const char *reg_prefix = ""; |
19e6b90e L |
6077 | |
6078 | op = *start++; | |
6079 | opa = op & 0x3f; | |
6080 | if (op & 0xc0) | |
6081 | op &= 0xc0; | |
6082 | ||
6083 | /* Warning: if you add any more cases to this switch, be | |
6084 | sure to add them to the corresponding switch above. */ | |
6085 | switch (op) | |
6086 | { | |
6087 | case DW_CFA_advance_loc: | |
6088 | if (do_debug_frames_interp) | |
6089 | frame_display_row (fc, &need_col_headers, &max_regs); | |
6090 | else | |
bf5117e3 | 6091 | printf (" DW_CFA_advance_loc: %d to %s\n", |
19e6b90e | 6092 | opa * fc->code_factor, |
bf5117e3 NC |
6093 | dwarf_vmatoa_1 (NULL, |
6094 | fc->pc_begin + opa * fc->code_factor, | |
6095 | fc->ptr_size)); | |
19e6b90e L |
6096 | fc->pc_begin += opa * fc->code_factor; |
6097 | break; | |
6098 | ||
6099 | case DW_CFA_offset: | |
6100 | roffs = LEB (); | |
665ce1f6 L |
6101 | if (opa >= (unsigned int) fc->ncols) |
6102 | reg_prefix = bad_reg; | |
6103 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
6104 | printf (" DW_CFA_offset: %s%s at cfa%+ld\n", | |
6105 | reg_prefix, regname (opa, 0), | |
6106 | roffs * fc->data_factor); | |
6107 | if (*reg_prefix == '\0') | |
6108 | { | |
6109 | fc->col_type[opa] = DW_CFA_offset; | |
6110 | fc->col_offset[opa] = roffs * fc->data_factor; | |
6111 | } | |
19e6b90e L |
6112 | break; |
6113 | ||
6114 | case DW_CFA_restore: | |
665ce1f6 L |
6115 | if (opa >= (unsigned int) cie->ncols |
6116 | || opa >= (unsigned int) fc->ncols) | |
6117 | reg_prefix = bad_reg; | |
6118 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
6119 | printf (" DW_CFA_restore: %s%s\n", | |
6120 | reg_prefix, regname (opa, 0)); | |
6121 | if (*reg_prefix == '\0') | |
6122 | { | |
6123 | fc->col_type[opa] = cie->col_type[opa]; | |
6124 | fc->col_offset[opa] = cie->col_offset[opa]; | |
b3f5b73b ILT |
6125 | if (do_debug_frames_interp |
6126 | && fc->col_type[opa] == DW_CFA_unreferenced) | |
6127 | fc->col_type[opa] = DW_CFA_undefined; | |
665ce1f6 | 6128 | } |
19e6b90e L |
6129 | break; |
6130 | ||
6131 | case DW_CFA_set_loc: | |
6937bb54 | 6132 | vma = get_encoded_value (&start, fc->fde_encoding, section, block_end); |
19e6b90e L |
6133 | if (do_debug_frames_interp) |
6134 | frame_display_row (fc, &need_col_headers, &max_regs); | |
6135 | else | |
bf5117e3 NC |
6136 | printf (" DW_CFA_set_loc: %s\n", |
6137 | dwarf_vmatoa_1 (NULL, vma, fc->ptr_size)); | |
19e6b90e L |
6138 | fc->pc_begin = vma; |
6139 | break; | |
6140 | ||
6141 | case DW_CFA_advance_loc1: | |
0c588247 | 6142 | SAFE_BYTE_GET_AND_INC (ofs, start, 1, end); |
19e6b90e L |
6143 | if (do_debug_frames_interp) |
6144 | frame_display_row (fc, &need_col_headers, &max_regs); | |
6145 | else | |
bf5117e3 NC |
6146 | printf (" DW_CFA_advance_loc1: %ld to %s\n", |
6147 | (unsigned long) (ofs * fc->code_factor), | |
6148 | dwarf_vmatoa_1 (NULL, | |
6149 | fc->pc_begin + ofs * fc->code_factor, | |
6150 | fc->ptr_size)); | |
19e6b90e L |
6151 | fc->pc_begin += ofs * fc->code_factor; |
6152 | break; | |
6153 | ||
6154 | case DW_CFA_advance_loc2: | |
6937bb54 | 6155 | SAFE_BYTE_GET_AND_INC (ofs, start, 2, block_end); |
19e6b90e L |
6156 | if (do_debug_frames_interp) |
6157 | frame_display_row (fc, &need_col_headers, &max_regs); | |
6158 | else | |
bf5117e3 NC |
6159 | printf (" DW_CFA_advance_loc2: %ld to %s\n", |
6160 | (unsigned long) (ofs * fc->code_factor), | |
6161 | dwarf_vmatoa_1 (NULL, | |
6162 | fc->pc_begin + ofs * fc->code_factor, | |
6163 | fc->ptr_size)); | |
19e6b90e L |
6164 | fc->pc_begin += ofs * fc->code_factor; |
6165 | break; | |
6166 | ||
6167 | case DW_CFA_advance_loc4: | |
6937bb54 | 6168 | SAFE_BYTE_GET_AND_INC (ofs, start, 4, block_end); |
19e6b90e L |
6169 | if (do_debug_frames_interp) |
6170 | frame_display_row (fc, &need_col_headers, &max_regs); | |
6171 | else | |
bf5117e3 NC |
6172 | printf (" DW_CFA_advance_loc4: %ld to %s\n", |
6173 | (unsigned long) (ofs * fc->code_factor), | |
6174 | dwarf_vmatoa_1 (NULL, | |
6175 | fc->pc_begin + ofs * fc->code_factor, | |
6176 | fc->ptr_size)); | |
19e6b90e L |
6177 | fc->pc_begin += ofs * fc->code_factor; |
6178 | break; | |
6179 | ||
6180 | case DW_CFA_offset_extended: | |
6181 | reg = LEB (); | |
6182 | roffs = LEB (); | |
665ce1f6 L |
6183 | if (reg >= (unsigned int) fc->ncols) |
6184 | reg_prefix = bad_reg; | |
6185 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
6186 | printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n", | |
6187 | reg_prefix, regname (reg, 0), | |
6188 | roffs * fc->data_factor); | |
6189 | if (*reg_prefix == '\0') | |
6190 | { | |
6191 | fc->col_type[reg] = DW_CFA_offset; | |
6192 | fc->col_offset[reg] = roffs * fc->data_factor; | |
6193 | } | |
19e6b90e L |
6194 | break; |
6195 | ||
12eae2d3 JJ |
6196 | case DW_CFA_val_offset: |
6197 | reg = LEB (); | |
6198 | roffs = LEB (); | |
665ce1f6 L |
6199 | if (reg >= (unsigned int) fc->ncols) |
6200 | reg_prefix = bad_reg; | |
6201 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
6202 | printf (" DW_CFA_val_offset: %s%s at cfa%+ld\n", | |
6203 | reg_prefix, regname (reg, 0), | |
6204 | roffs * fc->data_factor); | |
6205 | if (*reg_prefix == '\0') | |
6206 | { | |
6207 | fc->col_type[reg] = DW_CFA_val_offset; | |
6208 | fc->col_offset[reg] = roffs * fc->data_factor; | |
6209 | } | |
12eae2d3 JJ |
6210 | break; |
6211 | ||
19e6b90e L |
6212 | case DW_CFA_restore_extended: |
6213 | reg = LEB (); | |
665ce1f6 L |
6214 | if (reg >= (unsigned int) cie->ncols |
6215 | || reg >= (unsigned int) fc->ncols) | |
6216 | reg_prefix = bad_reg; | |
6217 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
6218 | printf (" DW_CFA_restore_extended: %s%s\n", | |
6219 | reg_prefix, regname (reg, 0)); | |
6220 | if (*reg_prefix == '\0') | |
6221 | { | |
6222 | fc->col_type[reg] = cie->col_type[reg]; | |
6223 | fc->col_offset[reg] = cie->col_offset[reg]; | |
6224 | } | |
19e6b90e L |
6225 | break; |
6226 | ||
6227 | case DW_CFA_undefined: | |
6228 | reg = LEB (); | |
665ce1f6 L |
6229 | if (reg >= (unsigned int) fc->ncols) |
6230 | reg_prefix = bad_reg; | |
6231 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
6232 | printf (" DW_CFA_undefined: %s%s\n", | |
6233 | reg_prefix, regname (reg, 0)); | |
6234 | if (*reg_prefix == '\0') | |
6235 | { | |
6236 | fc->col_type[reg] = DW_CFA_undefined; | |
6237 | fc->col_offset[reg] = 0; | |
6238 | } | |
19e6b90e L |
6239 | break; |
6240 | ||
6241 | case DW_CFA_same_value: | |
6242 | reg = LEB (); | |
665ce1f6 L |
6243 | if (reg >= (unsigned int) fc->ncols) |
6244 | reg_prefix = bad_reg; | |
6245 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
6246 | printf (" DW_CFA_same_value: %s%s\n", | |
6247 | reg_prefix, regname (reg, 0)); | |
6248 | if (*reg_prefix == '\0') | |
6249 | { | |
6250 | fc->col_type[reg] = DW_CFA_same_value; | |
6251 | fc->col_offset[reg] = 0; | |
6252 | } | |
19e6b90e L |
6253 | break; |
6254 | ||
6255 | case DW_CFA_register: | |
6256 | reg = LEB (); | |
6257 | roffs = LEB (); | |
665ce1f6 L |
6258 | if (reg >= (unsigned int) fc->ncols) |
6259 | reg_prefix = bad_reg; | |
6260 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
2dc4cec1 | 6261 | { |
665ce1f6 L |
6262 | printf (" DW_CFA_register: %s%s in ", |
6263 | reg_prefix, regname (reg, 0)); | |
2dc4cec1 L |
6264 | puts (regname (roffs, 0)); |
6265 | } | |
665ce1f6 L |
6266 | if (*reg_prefix == '\0') |
6267 | { | |
6268 | fc->col_type[reg] = DW_CFA_register; | |
6269 | fc->col_offset[reg] = roffs; | |
6270 | } | |
19e6b90e L |
6271 | break; |
6272 | ||
6273 | case DW_CFA_remember_state: | |
6274 | if (! do_debug_frames_interp) | |
6275 | printf (" DW_CFA_remember_state\n"); | |
3f5e193b | 6276 | rs = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk)); |
d71ad7fc RC |
6277 | rs->cfa_offset = fc->cfa_offset; |
6278 | rs->cfa_reg = fc->cfa_reg; | |
6279 | rs->ra = fc->ra; | |
6280 | rs->cfa_exp = fc->cfa_exp; | |
19e6b90e | 6281 | rs->ncols = fc->ncols; |
3f5e193b | 6282 | rs->col_type = (short int *) xcmalloc (rs->ncols, |
d71ad7fc RC |
6283 | sizeof (* rs->col_type)); |
6284 | rs->col_offset = (int *) xcmalloc (rs->ncols, sizeof (* rs->col_offset)); | |
6285 | memcpy (rs->col_type, fc->col_type, rs->ncols * sizeof (* fc->col_type)); | |
6286 | memcpy (rs->col_offset, fc->col_offset, rs->ncols * sizeof (* fc->col_offset)); | |
19e6b90e L |
6287 | rs->next = remembered_state; |
6288 | remembered_state = rs; | |
6289 | break; | |
6290 | ||
6291 | case DW_CFA_restore_state: | |
6292 | if (! do_debug_frames_interp) | |
6293 | printf (" DW_CFA_restore_state\n"); | |
6294 | rs = remembered_state; | |
6295 | if (rs) | |
6296 | { | |
6297 | remembered_state = rs->next; | |
d71ad7fc RC |
6298 | fc->cfa_offset = rs->cfa_offset; |
6299 | fc->cfa_reg = rs->cfa_reg; | |
6300 | fc->ra = rs->ra; | |
6301 | fc->cfa_exp = rs->cfa_exp; | |
06614111 NC |
6302 | if (frame_need_space (fc, rs->ncols - 1) < 0) |
6303 | { | |
1306a742 | 6304 | warn (_("Invalid column number in saved frame state\n")); |
06614111 NC |
6305 | fc->ncols = 0; |
6306 | break; | |
6307 | } | |
d71ad7fc | 6308 | memcpy (fc->col_type, rs->col_type, rs->ncols * sizeof (* rs->col_type)); |
19e6b90e | 6309 | memcpy (fc->col_offset, rs->col_offset, |
d71ad7fc | 6310 | rs->ncols * sizeof (* rs->col_offset)); |
19e6b90e L |
6311 | free (rs->col_type); |
6312 | free (rs->col_offset); | |
6313 | free (rs); | |
6314 | } | |
6315 | else if (do_debug_frames_interp) | |
6316 | printf ("Mismatched DW_CFA_restore_state\n"); | |
6317 | break; | |
6318 | ||
6319 | case DW_CFA_def_cfa: | |
6320 | fc->cfa_reg = LEB (); | |
6321 | fc->cfa_offset = LEB (); | |
6322 | fc->cfa_exp = 0; | |
6323 | if (! do_debug_frames_interp) | |
2dc4cec1 L |
6324 | printf (" DW_CFA_def_cfa: %s ofs %d\n", |
6325 | regname (fc->cfa_reg, 0), fc->cfa_offset); | |
19e6b90e L |
6326 | break; |
6327 | ||
6328 | case DW_CFA_def_cfa_register: | |
6329 | fc->cfa_reg = LEB (); | |
6330 | fc->cfa_exp = 0; | |
6331 | if (! do_debug_frames_interp) | |
2dc4cec1 L |
6332 | printf (" DW_CFA_def_cfa_register: %s\n", |
6333 | regname (fc->cfa_reg, 0)); | |
19e6b90e L |
6334 | break; |
6335 | ||
6336 | case DW_CFA_def_cfa_offset: | |
6337 | fc->cfa_offset = LEB (); | |
6338 | if (! do_debug_frames_interp) | |
6339 | printf (" DW_CFA_def_cfa_offset: %d\n", fc->cfa_offset); | |
6340 | break; | |
6341 | ||
6342 | case DW_CFA_nop: | |
6343 | if (! do_debug_frames_interp) | |
6344 | printf (" DW_CFA_nop\n"); | |
6345 | break; | |
6346 | ||
6347 | case DW_CFA_def_cfa_expression: | |
6348 | ul = LEB (); | |
06614111 | 6349 | if (start >= block_end || start + ul > block_end || start + ul < start) |
6937bb54 | 6350 | { |
a1165289 | 6351 | printf (_(" DW_CFA_def_cfa_expression: <corrupt len %lu>\n"), ul); |
6937bb54 NC |
6352 | break; |
6353 | } | |
19e6b90e L |
6354 | if (! do_debug_frames_interp) |
6355 | { | |
6356 | printf (" DW_CFA_def_cfa_expression ("); | |
b7807392 JJ |
6357 | decode_location_expression (start, eh_addr_size, 0, -1, |
6358 | ul, 0, section); | |
19e6b90e L |
6359 | printf (")\n"); |
6360 | } | |
6361 | fc->cfa_exp = 1; | |
6362 | start += ul; | |
6363 | break; | |
6364 | ||
6365 | case DW_CFA_expression: | |
6366 | reg = LEB (); | |
6367 | ul = LEB (); | |
665ce1f6 L |
6368 | if (reg >= (unsigned int) fc->ncols) |
6369 | reg_prefix = bad_reg; | |
6937bb54 | 6370 | /* PR 17512: file: 069-133014-0.006. */ |
06614111 NC |
6371 | /* PR 17512: file: 98c02eb4. */ |
6372 | if (start >= block_end || start + ul > block_end || start + ul < start) | |
6937bb54 | 6373 | { |
a1165289 | 6374 | printf (_(" DW_CFA_expression: <corrupt len %lu>\n"), ul); |
6937bb54 NC |
6375 | break; |
6376 | } | |
665ce1f6 | 6377 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
19e6b90e | 6378 | { |
665ce1f6 L |
6379 | printf (" DW_CFA_expression: %s%s (", |
6380 | reg_prefix, regname (reg, 0)); | |
b7807392 | 6381 | decode_location_expression (start, eh_addr_size, 0, -1, |
f1c4cc75 | 6382 | ul, 0, section); |
19e6b90e L |
6383 | printf (")\n"); |
6384 | } | |
665ce1f6 L |
6385 | if (*reg_prefix == '\0') |
6386 | fc->col_type[reg] = DW_CFA_expression; | |
19e6b90e L |
6387 | start += ul; |
6388 | break; | |
6389 | ||
12eae2d3 JJ |
6390 | case DW_CFA_val_expression: |
6391 | reg = LEB (); | |
6392 | ul = LEB (); | |
665ce1f6 L |
6393 | if (reg >= (unsigned int) fc->ncols) |
6394 | reg_prefix = bad_reg; | |
06614111 | 6395 | if (start >= block_end || start + ul > block_end || start + ul < start) |
6937bb54 | 6396 | { |
a1165289 | 6397 | printf (" DW_CFA_val_expression: <corrupt len %lu>\n", ul); |
6937bb54 NC |
6398 | break; |
6399 | } | |
665ce1f6 | 6400 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
12eae2d3 | 6401 | { |
665ce1f6 L |
6402 | printf (" DW_CFA_val_expression: %s%s (", |
6403 | reg_prefix, regname (reg, 0)); | |
b7807392 JJ |
6404 | decode_location_expression (start, eh_addr_size, 0, -1, |
6405 | ul, 0, section); | |
12eae2d3 JJ |
6406 | printf (")\n"); |
6407 | } | |
665ce1f6 L |
6408 | if (*reg_prefix == '\0') |
6409 | fc->col_type[reg] = DW_CFA_val_expression; | |
12eae2d3 JJ |
6410 | start += ul; |
6411 | break; | |
6412 | ||
19e6b90e L |
6413 | case DW_CFA_offset_extended_sf: |
6414 | reg = LEB (); | |
6415 | l = SLEB (); | |
665ce1f6 L |
6416 | if (frame_need_space (fc, reg) < 0) |
6417 | reg_prefix = bad_reg; | |
6418 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
6419 | printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n", | |
6420 | reg_prefix, regname (reg, 0), | |
6421 | l * fc->data_factor); | |
6422 | if (*reg_prefix == '\0') | |
6423 | { | |
6424 | fc->col_type[reg] = DW_CFA_offset; | |
6425 | fc->col_offset[reg] = l * fc->data_factor; | |
6426 | } | |
19e6b90e L |
6427 | break; |
6428 | ||
12eae2d3 JJ |
6429 | case DW_CFA_val_offset_sf: |
6430 | reg = LEB (); | |
6431 | l = SLEB (); | |
665ce1f6 L |
6432 | if (frame_need_space (fc, reg) < 0) |
6433 | reg_prefix = bad_reg; | |
6434 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
6435 | printf (" DW_CFA_val_offset_sf: %s%s at cfa%+ld\n", | |
6436 | reg_prefix, regname (reg, 0), | |
6437 | l * fc->data_factor); | |
6438 | if (*reg_prefix == '\0') | |
6439 | { | |
6440 | fc->col_type[reg] = DW_CFA_val_offset; | |
6441 | fc->col_offset[reg] = l * fc->data_factor; | |
6442 | } | |
12eae2d3 JJ |
6443 | break; |
6444 | ||
19e6b90e L |
6445 | case DW_CFA_def_cfa_sf: |
6446 | fc->cfa_reg = LEB (); | |
6447 | fc->cfa_offset = SLEB (); | |
6448 | fc->cfa_offset = fc->cfa_offset * fc->data_factor; | |
6449 | fc->cfa_exp = 0; | |
6450 | if (! do_debug_frames_interp) | |
2dc4cec1 L |
6451 | printf (" DW_CFA_def_cfa_sf: %s ofs %d\n", |
6452 | regname (fc->cfa_reg, 0), fc->cfa_offset); | |
19e6b90e L |
6453 | break; |
6454 | ||
6455 | case DW_CFA_def_cfa_offset_sf: | |
6456 | fc->cfa_offset = SLEB (); | |
6457 | fc->cfa_offset = fc->cfa_offset * fc->data_factor; | |
6458 | if (! do_debug_frames_interp) | |
6459 | printf (" DW_CFA_def_cfa_offset_sf: %d\n", fc->cfa_offset); | |
6460 | break; | |
6461 | ||
6462 | case DW_CFA_MIPS_advance_loc8: | |
6937bb54 | 6463 | SAFE_BYTE_GET_AND_INC (ofs, start, 8, block_end); |
19e6b90e L |
6464 | if (do_debug_frames_interp) |
6465 | frame_display_row (fc, &need_col_headers, &max_regs); | |
6466 | else | |
bf5117e3 NC |
6467 | printf (" DW_CFA_MIPS_advance_loc8: %ld to %s\n", |
6468 | (unsigned long) (ofs * fc->code_factor), | |
6469 | dwarf_vmatoa_1 (NULL, | |
6470 | fc->pc_begin + ofs * fc->code_factor, | |
6471 | fc->ptr_size)); | |
19e6b90e L |
6472 | fc->pc_begin += ofs * fc->code_factor; |
6473 | break; | |
6474 | ||
6475 | case DW_CFA_GNU_window_save: | |
6476 | if (! do_debug_frames_interp) | |
6477 | printf (" DW_CFA_GNU_window_save\n"); | |
6478 | break; | |
6479 | ||
6480 | case DW_CFA_GNU_args_size: | |
6481 | ul = LEB (); | |
6482 | if (! do_debug_frames_interp) | |
6483 | printf (" DW_CFA_GNU_args_size: %ld\n", ul); | |
6484 | break; | |
6485 | ||
6486 | case DW_CFA_GNU_negative_offset_extended: | |
6487 | reg = LEB (); | |
6488 | l = - LEB (); | |
665ce1f6 L |
6489 | if (frame_need_space (fc, reg) < 0) |
6490 | reg_prefix = bad_reg; | |
6491 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
6492 | printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n", | |
6493 | reg_prefix, regname (reg, 0), | |
6494 | l * fc->data_factor); | |
6495 | if (*reg_prefix == '\0') | |
6496 | { | |
6497 | fc->col_type[reg] = DW_CFA_offset; | |
6498 | fc->col_offset[reg] = l * fc->data_factor; | |
6499 | } | |
19e6b90e L |
6500 | break; |
6501 | ||
6502 | default: | |
53b8873b NC |
6503 | if (op >= DW_CFA_lo_user && op <= DW_CFA_hi_user) |
6504 | printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op); | |
6505 | else | |
f41e4712 | 6506 | warn (_("Unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op); |
19e6b90e L |
6507 | start = block_end; |
6508 | } | |
6509 | } | |
6510 | ||
6511 | if (do_debug_frames_interp) | |
6512 | frame_display_row (fc, &need_col_headers, &max_regs); | |
6513 | ||
6514 | start = block_end; | |
604282a7 | 6515 | eh_addr_size = saved_eh_addr_size; |
19e6b90e L |
6516 | } |
6517 | ||
6518 | printf ("\n"); | |
6519 | ||
6520 | return 1; | |
6521 | } | |
6522 | ||
6523 | #undef GET | |
6524 | #undef LEB | |
6525 | #undef SLEB | |
6526 | ||
5bbdf3d5 DE |
6527 | static int |
6528 | display_gdb_index (struct dwarf_section *section, | |
6529 | void *file ATTRIBUTE_UNUSED) | |
6530 | { | |
6531 | unsigned char *start = section->start; | |
6532 | uint32_t version; | |
6533 | uint32_t cu_list_offset, tu_list_offset; | |
6534 | uint32_t address_table_offset, symbol_table_offset, constant_pool_offset; | |
6535 | unsigned int cu_list_elements, tu_list_elements; | |
6536 | unsigned int address_table_size, symbol_table_slots; | |
6537 | unsigned char *cu_list, *tu_list; | |
6538 | unsigned char *address_table, *symbol_table, *constant_pool; | |
6539 | unsigned int i; | |
6540 | ||
6541 | /* The documentation for the format of this file is in gdb/dwarf2read.c. */ | |
6542 | ||
6543 | printf (_("Contents of the %s section:\n"), section->name); | |
6544 | ||
6545 | if (section->size < 6 * sizeof (uint32_t)) | |
6546 | { | |
6547 | warn (_("Truncated header in the %s section.\n"), section->name); | |
6548 | return 0; | |
6549 | } | |
6550 | ||
6551 | version = byte_get_little_endian (start, 4); | |
da88a764 | 6552 | printf (_("Version %ld\n"), (long) version); |
5bbdf3d5 DE |
6553 | |
6554 | /* Prior versions are obsolete, and future versions may not be | |
6555 | backwards compatible. */ | |
aa170720 | 6556 | if (version < 3 || version > 8) |
5bbdf3d5 | 6557 | { |
da88a764 | 6558 | warn (_("Unsupported version %lu.\n"), (unsigned long) version); |
5bbdf3d5 DE |
6559 | return 0; |
6560 | } | |
8d6eee87 TT |
6561 | if (version < 4) |
6562 | warn (_("The address table data in version 3 may be wrong.\n")); | |
6563 | if (version < 5) | |
6564 | warn (_("Version 4 does not support case insensitive lookups.\n")); | |
6565 | if (version < 6) | |
6566 | warn (_("Version 5 does not include inlined functions.\n")); | |
6567 | if (version < 7) | |
6568 | warn (_("Version 6 does not include symbol attributes.\n")); | |
aa170720 DE |
6569 | /* Version 7 indices generated by Gold have bad type unit references, |
6570 | PR binutils/15021. But we don't know if the index was generated by | |
6571 | Gold or not, so to avoid worrying users with gdb-generated indices | |
6572 | we say nothing for version 7 here. */ | |
5bbdf3d5 DE |
6573 | |
6574 | cu_list_offset = byte_get_little_endian (start + 4, 4); | |
6575 | tu_list_offset = byte_get_little_endian (start + 8, 4); | |
6576 | address_table_offset = byte_get_little_endian (start + 12, 4); | |
6577 | symbol_table_offset = byte_get_little_endian (start + 16, 4); | |
6578 | constant_pool_offset = byte_get_little_endian (start + 20, 4); | |
6579 | ||
6580 | if (cu_list_offset > section->size | |
6581 | || tu_list_offset > section->size | |
6582 | || address_table_offset > section->size | |
6583 | || symbol_table_offset > section->size | |
6584 | || constant_pool_offset > section->size) | |
6585 | { | |
6586 | warn (_("Corrupt header in the %s section.\n"), section->name); | |
6587 | return 0; | |
6588 | } | |
6589 | ||
53774b7e NC |
6590 | /* PR 17531: file: 418d0a8a. */ |
6591 | if (tu_list_offset < cu_list_offset) | |
6592 | { | |
6593 | warn (_("TU offset (%x) is less than CU offset (%x)\n"), | |
6594 | tu_list_offset, cu_list_offset); | |
6595 | return 0; | |
6596 | } | |
6597 | ||
5bbdf3d5 | 6598 | cu_list_elements = (tu_list_offset - cu_list_offset) / 8; |
53774b7e NC |
6599 | |
6600 | if (address_table_offset < tu_list_offset) | |
6601 | { | |
6602 | warn (_("Address table offset (%x) is less than TU offset (%x)\n"), | |
6603 | address_table_offset, tu_list_offset); | |
6604 | return 0; | |
6605 | } | |
6606 | ||
5bbdf3d5 | 6607 | tu_list_elements = (address_table_offset - tu_list_offset) / 8; |
53774b7e NC |
6608 | |
6609 | /* PR 17531: file: 18a47d3d. */ | |
6610 | if (symbol_table_offset < address_table_offset) | |
6611 | { | |
acff9664 | 6612 | warn (_("Symbol table offset (%xl) is less then Address table offset (%x)\n"), |
53774b7e NC |
6613 | symbol_table_offset, address_table_offset); |
6614 | return 0; | |
6615 | } | |
6616 | ||
5bbdf3d5 | 6617 | address_table_size = symbol_table_offset - address_table_offset; |
53774b7e NC |
6618 | |
6619 | if (constant_pool_offset < symbol_table_offset) | |
6620 | { | |
6621 | warn (_("Constant pool offset (%x) is less than symbol table offset (%x)\n"), | |
6622 | constant_pool_offset, symbol_table_offset); | |
6623 | return 0; | |
6624 | } | |
6625 | ||
5bbdf3d5 DE |
6626 | symbol_table_slots = (constant_pool_offset - symbol_table_offset) / 8; |
6627 | ||
6628 | cu_list = start + cu_list_offset; | |
6629 | tu_list = start + tu_list_offset; | |
6630 | address_table = start + address_table_offset; | |
6631 | symbol_table = start + symbol_table_offset; | |
6632 | constant_pool = start + constant_pool_offset; | |
6633 | ||
acff9664 NC |
6634 | if (address_table + address_table_size * (2 + 8 + 4) > section->start + section->size) |
6635 | { | |
1306a742 | 6636 | warn (_("Address table extends beyond end of section.\n")); |
acff9664 NC |
6637 | return 0; |
6638 | } | |
6639 | ||
5bbdf3d5 DE |
6640 | printf (_("\nCU table:\n")); |
6641 | for (i = 0; i < cu_list_elements; i += 2) | |
6642 | { | |
6643 | uint64_t cu_offset = byte_get_little_endian (cu_list + i * 8, 8); | |
6644 | uint64_t cu_length = byte_get_little_endian (cu_list + i * 8 + 8, 8); | |
6645 | ||
6646 | printf (_("[%3u] 0x%lx - 0x%lx\n"), i / 2, | |
6647 | (unsigned long) cu_offset, | |
6648 | (unsigned long) (cu_offset + cu_length - 1)); | |
6649 | } | |
6650 | ||
6651 | printf (_("\nTU table:\n")); | |
6652 | for (i = 0; i < tu_list_elements; i += 3) | |
6653 | { | |
6654 | uint64_t tu_offset = byte_get_little_endian (tu_list + i * 8, 8); | |
6655 | uint64_t type_offset = byte_get_little_endian (tu_list + i * 8 + 8, 8); | |
6656 | uint64_t signature = byte_get_little_endian (tu_list + i * 8 + 16, 8); | |
6657 | ||
6658 | printf (_("[%3u] 0x%lx 0x%lx "), i / 3, | |
6659 | (unsigned long) tu_offset, | |
6660 | (unsigned long) type_offset); | |
6661 | print_dwarf_vma (signature, 8); | |
6662 | printf ("\n"); | |
6663 | } | |
6664 | ||
6665 | printf (_("\nAddress table:\n")); | |
acff9664 NC |
6666 | for (i = 0; i < address_table_size && i <= address_table_size - (2 * 8 + 4); |
6667 | i += 2 * 8 + 4) | |
5bbdf3d5 DE |
6668 | { |
6669 | uint64_t low = byte_get_little_endian (address_table + i, 8); | |
6670 | uint64_t high = byte_get_little_endian (address_table + i + 8, 8); | |
6671 | uint32_t cu_index = byte_get_little_endian (address_table + i + 16, 4); | |
6672 | ||
6673 | print_dwarf_vma (low, 8); | |
6674 | print_dwarf_vma (high, 8); | |
da88a764 | 6675 | printf (_("%lu\n"), (unsigned long) cu_index); |
5bbdf3d5 DE |
6676 | } |
6677 | ||
6678 | printf (_("\nSymbol table:\n")); | |
6679 | for (i = 0; i < symbol_table_slots; ++i) | |
6680 | { | |
6681 | uint32_t name_offset = byte_get_little_endian (symbol_table + i * 8, 4); | |
6682 | uint32_t cu_vector_offset = byte_get_little_endian (symbol_table + i * 8 + 4, 4); | |
6683 | uint32_t num_cus, cu; | |
6684 | ||
6685 | if (name_offset != 0 | |
6686 | || cu_vector_offset != 0) | |
6687 | { | |
6688 | unsigned int j; | |
6689 | ||
53774b7e NC |
6690 | /* PR 17531: file: 5b7b07ad. */ |
6691 | if (constant_pool + name_offset < constant_pool | |
6692 | || constant_pool + name_offset >= section->start + section->size) | |
6693 | { | |
6694 | printf (_("[%3u] <corrupt offset: %x>"), i, name_offset); | |
6695 | warn (_("Corrupt name offset of 0x%x found for symbol table slot %d\n"), | |
6696 | name_offset, i); | |
6697 | } | |
6698 | else | |
acff9664 NC |
6699 | printf ("[%3u] %.*s:", i, |
6700 | (int) (section->size - (constant_pool_offset + name_offset)), | |
6701 | constant_pool + name_offset); | |
53774b7e NC |
6702 | |
6703 | if (constant_pool + cu_vector_offset < constant_pool | |
57028622 | 6704 | || constant_pool + cu_vector_offset >= section->start + section->size - 3) |
53774b7e NC |
6705 | { |
6706 | printf (_("<invalid CU vector offset: %x>\n"), cu_vector_offset); | |
6707 | warn (_("Corrupt CU vector offset of 0x%x found for symbol table slot %d\n"), | |
6708 | cu_vector_offset, i); | |
6709 | continue; | |
6710 | } | |
57028622 NC |
6711 | |
6712 | num_cus = byte_get_little_endian (constant_pool + cu_vector_offset, 4); | |
53774b7e | 6713 | |
acff9664 | 6714 | if (num_cus * 4 < num_cus |
57028622 NC |
6715 | || constant_pool + cu_vector_offset + 4 + num_cus * 4 |
6716 | >= section->start + section->size) | |
53774b7e NC |
6717 | { |
6718 | printf ("<invalid number of CUs: %d>\n", num_cus); | |
acff9664 | 6719 | warn (_("Invalid number of CUs (0x%x) for symbol table slot %d\n"), |
53774b7e NC |
6720 | num_cus, i); |
6721 | continue; | |
6722 | } | |
6723 | ||
8d6eee87 TT |
6724 | if (num_cus > 1) |
6725 | printf ("\n"); | |
5bbdf3d5 DE |
6726 | for (j = 0; j < num_cus; ++j) |
6727 | { | |
7c1cef97 | 6728 | int is_static; |
8d6eee87 TT |
6729 | gdb_index_symbol_kind kind; |
6730 | ||
5bbdf3d5 | 6731 | cu = byte_get_little_endian (constant_pool + cu_vector_offset + 4 + j * 4, 4); |
7c1cef97 | 6732 | is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu); |
8d6eee87 TT |
6733 | kind = GDB_INDEX_SYMBOL_KIND_VALUE (cu); |
6734 | cu = GDB_INDEX_CU_VALUE (cu); | |
5bbdf3d5 | 6735 | /* Convert to TU number if it's for a type unit. */ |
ad6b52dd | 6736 | if (cu >= cu_list_elements / 2) |
8d6eee87 TT |
6737 | printf ("%cT%lu", num_cus > 1 ? '\t' : ' ', |
6738 | (unsigned long) (cu - cu_list_elements / 2)); | |
5bbdf3d5 | 6739 | else |
8d6eee87 TT |
6740 | printf ("%c%lu", num_cus > 1 ? '\t' : ' ', (unsigned long) cu); |
6741 | ||
459d52c8 DE |
6742 | printf (" [%s, %s]", |
6743 | is_static ? _("static") : _("global"), | |
6744 | get_gdb_index_symbol_kind_name (kind)); | |
8d6eee87 TT |
6745 | if (num_cus > 1) |
6746 | printf ("\n"); | |
5bbdf3d5 | 6747 | } |
8d6eee87 TT |
6748 | if (num_cus <= 1) |
6749 | printf ("\n"); | |
5bbdf3d5 DE |
6750 | } |
6751 | } | |
6752 | ||
6753 | return 1; | |
6754 | } | |
6755 | ||
657d0d47 CC |
6756 | /* Pre-allocate enough space for the CU/TU sets needed. */ |
6757 | ||
6758 | static void | |
6759 | prealloc_cu_tu_list (unsigned int nshndx) | |
6760 | { | |
6761 | if (shndx_pool == NULL) | |
6762 | { | |
6763 | shndx_pool_size = nshndx; | |
6764 | shndx_pool_used = 0; | |
6765 | shndx_pool = (unsigned int *) xcmalloc (shndx_pool_size, | |
6766 | sizeof (unsigned int)); | |
6767 | } | |
6768 | else | |
6769 | { | |
6770 | shndx_pool_size = shndx_pool_used + nshndx; | |
6771 | shndx_pool = (unsigned int *) xcrealloc (shndx_pool, shndx_pool_size, | |
6772 | sizeof (unsigned int)); | |
6773 | } | |
6774 | } | |
6775 | ||
6776 | static void | |
6777 | add_shndx_to_cu_tu_entry (unsigned int shndx) | |
6778 | { | |
6779 | if (shndx_pool_used >= shndx_pool_size) | |
6780 | { | |
6781 | error (_("Internal error: out of space in the shndx pool.\n")); | |
6782 | return; | |
6783 | } | |
6784 | shndx_pool [shndx_pool_used++] = shndx; | |
6785 | } | |
6786 | ||
6787 | static void | |
6788 | end_cu_tu_entry (void) | |
6789 | { | |
6790 | if (shndx_pool_used >= shndx_pool_size) | |
6791 | { | |
6792 | error (_("Internal error: out of space in the shndx pool.\n")); | |
6793 | return; | |
6794 | } | |
6795 | shndx_pool [shndx_pool_used++] = 0; | |
6796 | } | |
6797 | ||
341f9135 CC |
6798 | /* Return the short name of a DWARF section given by a DW_SECT enumerator. */ |
6799 | ||
6800 | static const char * | |
6801 | get_DW_SECT_short_name (unsigned int dw_sect) | |
6802 | { | |
6803 | static char buf[16]; | |
6804 | ||
6805 | switch (dw_sect) | |
6806 | { | |
6807 | case DW_SECT_INFO: | |
6808 | return "info"; | |
6809 | case DW_SECT_TYPES: | |
6810 | return "types"; | |
6811 | case DW_SECT_ABBREV: | |
6812 | return "abbrev"; | |
6813 | case DW_SECT_LINE: | |
6814 | return "line"; | |
6815 | case DW_SECT_LOC: | |
6816 | return "loc"; | |
6817 | case DW_SECT_STR_OFFSETS: | |
6818 | return "str_off"; | |
6819 | case DW_SECT_MACINFO: | |
6820 | return "macinfo"; | |
6821 | case DW_SECT_MACRO: | |
6822 | return "macro"; | |
6823 | default: | |
6824 | break; | |
6825 | } | |
6826 | ||
6827 | snprintf (buf, sizeof (buf), "%d", dw_sect); | |
6828 | return buf; | |
6829 | } | |
6830 | ||
6831 | /* Process a CU or TU index. If DO_DISPLAY is true, print the contents. | |
6832 | These sections are extensions for Fission. | |
6833 | See http://gcc.gnu.org/wiki/DebugFissionDWP. */ | |
657d0d47 CC |
6834 | |
6835 | static int | |
6836 | process_cu_tu_index (struct dwarf_section *section, int do_display) | |
6837 | { | |
6838 | unsigned char *phdr = section->start; | |
6839 | unsigned char *limit = phdr + section->size; | |
6840 | unsigned char *phash; | |
6841 | unsigned char *pindex; | |
6842 | unsigned char *ppool; | |
6843 | unsigned int version; | |
341f9135 | 6844 | unsigned int ncols = 0; |
657d0d47 CC |
6845 | unsigned int nused; |
6846 | unsigned int nslots; | |
6847 | unsigned int i; | |
341f9135 CC |
6848 | unsigned int j; |
6849 | dwarf_vma signature_high; | |
6850 | dwarf_vma signature_low; | |
6851 | char buf[64]; | |
657d0d47 | 6852 | |
6937bb54 NC |
6853 | /* PR 17512: file: 002-168123-0.004. */ |
6854 | if (phdr == NULL) | |
6855 | { | |
6856 | warn (_("Section %s is empty\n"), section->name); | |
6857 | return 0; | |
6858 | } | |
6859 | /* PR 17512: file: 002-376-0.004. */ | |
6860 | if (section->size < 24) | |
6861 | { | |
72c61a0d | 6862 | warn (_("Section %s is too small to contain a CU/TU header\n"), |
6937bb54 NC |
6863 | section->name); |
6864 | return 0; | |
6865 | } | |
6866 | ||
6867 | SAFE_BYTE_GET (version, phdr, 4, limit); | |
341f9135 | 6868 | if (version >= 2) |
6937bb54 NC |
6869 | SAFE_BYTE_GET (ncols, phdr + 4, 4, limit); |
6870 | SAFE_BYTE_GET (nused, phdr + 8, 4, limit); | |
6871 | SAFE_BYTE_GET (nslots, phdr + 12, 4, limit); | |
6872 | ||
657d0d47 CC |
6873 | phash = phdr + 16; |
6874 | pindex = phash + nslots * 8; | |
6875 | ppool = pindex + nslots * 4; | |
6876 | ||
57028622 NC |
6877 | /* PR 17531: file: 45d69832. */ |
6878 | if (pindex < phash || ppool < phdr) | |
6879 | { | |
6880 | warn (_("Section %s is too small for %d slots\n"), | |
6881 | section->name, nslots); | |
6882 | return 0; | |
6883 | } | |
6884 | ||
657d0d47 CC |
6885 | if (do_display) |
6886 | { | |
6887 | printf (_("Contents of the %s section:\n\n"), section->name); | |
6888 | printf (_(" Version: %d\n"), version); | |
341f9135 CC |
6889 | if (version >= 2) |
6890 | printf (_(" Number of columns: %d\n"), ncols); | |
657d0d47 CC |
6891 | printf (_(" Number of used entries: %d\n"), nused); |
6892 | printf (_(" Number of slots: %d\n\n"), nslots); | |
6893 | } | |
6894 | ||
6895 | if (ppool > limit) | |
6896 | { | |
6897 | warn (_("Section %s too small for %d hash table entries\n"), | |
6898 | section->name, nslots); | |
6899 | return 0; | |
6900 | } | |
6901 | ||
341f9135 | 6902 | if (version == 1) |
657d0d47 | 6903 | { |
341f9135 CC |
6904 | if (!do_display) |
6905 | prealloc_cu_tu_list ((limit - ppool) / 4); | |
6906 | for (i = 0; i < nslots; i++) | |
657d0d47 | 6907 | { |
341f9135 CC |
6908 | unsigned char *shndx_list; |
6909 | unsigned int shndx; | |
6910 | ||
6937bb54 | 6911 | SAFE_BYTE_GET64 (phash, &signature_high, &signature_low, limit); |
341f9135 | 6912 | if (signature_high != 0 || signature_low != 0) |
657d0d47 | 6913 | { |
6937bb54 | 6914 | SAFE_BYTE_GET (j, pindex, 4, limit); |
341f9135 CC |
6915 | shndx_list = ppool + j * 4; |
6916 | if (do_display) | |
6917 | printf (_(" [%3d] Signature: 0x%s Sections: "), | |
6918 | i, dwarf_vmatoa64 (signature_high, signature_low, | |
6919 | buf, sizeof (buf))); | |
6920 | for (;;) | |
657d0d47 | 6921 | { |
341f9135 CC |
6922 | if (shndx_list >= limit) |
6923 | { | |
6924 | warn (_("Section %s too small for shndx pool\n"), | |
6925 | section->name); | |
6926 | return 0; | |
6927 | } | |
6937bb54 | 6928 | SAFE_BYTE_GET (shndx, shndx_list, 4, limit); |
341f9135 CC |
6929 | if (shndx == 0) |
6930 | break; | |
6931 | if (do_display) | |
6932 | printf (" %d", shndx); | |
6933 | else | |
6934 | add_shndx_to_cu_tu_entry (shndx); | |
6935 | shndx_list += 4; | |
657d0d47 | 6936 | } |
657d0d47 | 6937 | if (do_display) |
341f9135 | 6938 | printf ("\n"); |
657d0d47 | 6939 | else |
341f9135 CC |
6940 | end_cu_tu_entry (); |
6941 | } | |
6942 | phash += 8; | |
6943 | pindex += 4; | |
6944 | } | |
6945 | } | |
6946 | else if (version == 2) | |
6947 | { | |
6948 | unsigned int val; | |
6949 | unsigned int dw_sect; | |
6950 | unsigned char *ph = phash; | |
6951 | unsigned char *pi = pindex; | |
6952 | unsigned char *poffsets = ppool + ncols * 4; | |
6953 | unsigned char *psizes = poffsets + nused * ncols * 4; | |
6954 | unsigned char *pend = psizes + nused * ncols * 4; | |
6955 | bfd_boolean is_tu_index; | |
6956 | struct cu_tu_set *this_set = NULL; | |
6957 | unsigned int row; | |
6958 | unsigned char *prow; | |
6959 | ||
6960 | is_tu_index = strcmp (section->name, ".debug_tu_index") == 0; | |
6961 | ||
6962 | if (pend > limit) | |
6963 | { | |
6964 | warn (_("Section %s too small for offset and size tables\n"), | |
6965 | section->name); | |
6966 | return 0; | |
6967 | } | |
6968 | ||
6969 | if (do_display) | |
6970 | { | |
6971 | printf (_(" Offset table\n")); | |
6972 | printf (" slot %-16s ", | |
6973 | is_tu_index ? _("signature") : _("dwo_id")); | |
6974 | } | |
6975 | else | |
6976 | { | |
6977 | if (is_tu_index) | |
6978 | { | |
6979 | tu_count = nused; | |
72c61a0d | 6980 | tu_sets = xcalloc2 (nused, sizeof (struct cu_tu_set)); |
341f9135 | 6981 | this_set = tu_sets; |
657d0d47 | 6982 | } |
657d0d47 | 6983 | else |
341f9135 CC |
6984 | { |
6985 | cu_count = nused; | |
72c61a0d | 6986 | cu_sets = xcalloc2 (nused, sizeof (struct cu_tu_set)); |
341f9135 CC |
6987 | this_set = cu_sets; |
6988 | } | |
6989 | } | |
6937bb54 | 6990 | |
341f9135 CC |
6991 | if (do_display) |
6992 | { | |
6993 | for (j = 0; j < ncols; j++) | |
6994 | { | |
6937bb54 | 6995 | SAFE_BYTE_GET (dw_sect, ppool + j * 4, 4, limit); |
341f9135 CC |
6996 | printf (" %8s", get_DW_SECT_short_name (dw_sect)); |
6997 | } | |
6998 | printf ("\n"); | |
6999 | } | |
6937bb54 | 7000 | |
341f9135 CC |
7001 | for (i = 0; i < nslots; i++) |
7002 | { | |
6937bb54 NC |
7003 | SAFE_BYTE_GET64 (ph, &signature_high, &signature_low, limit); |
7004 | ||
7005 | SAFE_BYTE_GET (row, pi, 4, limit); | |
341f9135 CC |
7006 | if (row != 0) |
7007 | { | |
591f7597 | 7008 | /* PR 17531: file: a05f6ab3. */ |
ef77750e | 7009 | if (row > nused) |
591f7597 NC |
7010 | { |
7011 | warn (_("Row index (%u) is larger than number of used entries (%u)\n"), | |
7012 | row, nused); | |
7013 | return 0; | |
7014 | } | |
7015 | ||
341f9135 CC |
7016 | if (!do_display) |
7017 | memcpy (&this_set[row - 1].signature, ph, sizeof (uint64_t)); | |
6937bb54 | 7018 | |
341f9135 | 7019 | prow = poffsets + (row - 1) * ncols * 4; |
6937bb54 | 7020 | |
341f9135 CC |
7021 | if (do_display) |
7022 | printf (_(" [%3d] 0x%s"), | |
7023 | i, dwarf_vmatoa64 (signature_high, signature_low, | |
7024 | buf, sizeof (buf))); | |
7025 | for (j = 0; j < ncols; j++) | |
7026 | { | |
6937bb54 | 7027 | SAFE_BYTE_GET (val, prow + j * 4, 4, limit); |
341f9135 CC |
7028 | if (do_display) |
7029 | printf (" %8d", val); | |
7030 | else | |
7031 | { | |
6937bb54 | 7032 | SAFE_BYTE_GET (dw_sect, ppool + j * 4, 4, limit); |
82b1b41b NC |
7033 | |
7034 | /* PR 17531: file: 10796eb3. */ | |
7035 | if (dw_sect >= DW_SECT_MAX) | |
7036 | warn (_("Overlarge Dwarf section index detected: %u\n"), dw_sect); | |
7037 | else | |
7038 | this_set [row - 1].section_offsets [dw_sect] = val; | |
341f9135 CC |
7039 | } |
7040 | } | |
6937bb54 | 7041 | |
341f9135 CC |
7042 | if (do_display) |
7043 | printf ("\n"); | |
7044 | } | |
7045 | ph += 8; | |
7046 | pi += 4; | |
7047 | } | |
7048 | ||
7049 | ph = phash; | |
7050 | pi = pindex; | |
7051 | if (do_display) | |
7052 | { | |
7053 | printf ("\n"); | |
7054 | printf (_(" Size table\n")); | |
7055 | printf (" slot %-16s ", | |
7056 | is_tu_index ? _("signature") : _("dwo_id")); | |
7057 | } | |
6937bb54 | 7058 | |
341f9135 CC |
7059 | for (j = 0; j < ncols; j++) |
7060 | { | |
6937bb54 | 7061 | SAFE_BYTE_GET (val, ppool + j * 4, 4, limit); |
341f9135 CC |
7062 | if (do_display) |
7063 | printf (" %8s", get_DW_SECT_short_name (val)); | |
7064 | } | |
6937bb54 | 7065 | |
341f9135 CC |
7066 | if (do_display) |
7067 | printf ("\n"); | |
6937bb54 | 7068 | |
341f9135 CC |
7069 | for (i = 0; i < nslots; i++) |
7070 | { | |
6937bb54 NC |
7071 | SAFE_BYTE_GET64 (ph, &signature_high, &signature_low, limit); |
7072 | ||
7073 | SAFE_BYTE_GET (row, pi, 4, limit); | |
341f9135 CC |
7074 | if (row != 0) |
7075 | { | |
7076 | prow = psizes + (row - 1) * ncols * 4; | |
6937bb54 | 7077 | |
341f9135 CC |
7078 | if (do_display) |
7079 | printf (_(" [%3d] 0x%s"), | |
7080 | i, dwarf_vmatoa64 (signature_high, signature_low, | |
7081 | buf, sizeof (buf))); | |
6937bb54 | 7082 | |
341f9135 CC |
7083 | for (j = 0; j < ncols; j++) |
7084 | { | |
6937bb54 | 7085 | SAFE_BYTE_GET (val, prow + j * 4, 4, limit); |
341f9135 CC |
7086 | if (do_display) |
7087 | printf (" %8d", val); | |
7088 | else | |
7089 | { | |
6937bb54 | 7090 | SAFE_BYTE_GET (dw_sect, ppool + j * 4, 4, limit); |
82b1b41b NC |
7091 | if (dw_sect >= DW_SECT_MAX) |
7092 | warn (_("Overlarge Dwarf section index detected: %u\n"), dw_sect); | |
7093 | else | |
341f9135 CC |
7094 | this_set [row - 1].section_sizes [dw_sect] = val; |
7095 | } | |
7096 | } | |
6937bb54 | 7097 | |
341f9135 CC |
7098 | if (do_display) |
7099 | printf ("\n"); | |
7100 | } | |
6937bb54 | 7101 | |
341f9135 CC |
7102 | ph += 8; |
7103 | pi += 4; | |
657d0d47 | 7104 | } |
657d0d47 | 7105 | } |
341f9135 | 7106 | else if (do_display) |
6937bb54 | 7107 | printf (_(" Unsupported version (%d)\n"), version); |
657d0d47 CC |
7108 | |
7109 | if (do_display) | |
7110 | printf ("\n"); | |
7111 | ||
7112 | return 1; | |
7113 | } | |
7114 | ||
7115 | /* Load the CU and TU indexes if present. This will build a list of | |
7116 | section sets that we can use to associate a .debug_info.dwo section | |
7117 | with its associated .debug_abbrev.dwo section in a .dwp file. */ | |
7118 | ||
7119 | static void | |
7120 | load_cu_tu_indexes (void *file) | |
7121 | { | |
7122 | /* If we have already loaded (or tried to load) the CU and TU indexes | |
7123 | then do not bother to repeat the task. */ | |
7124 | if (cu_tu_indexes_read) | |
7125 | return; | |
7126 | ||
7127 | if (load_debug_section (dwp_cu_index, file)) | |
7128 | process_cu_tu_index (&debug_displays [dwp_cu_index].section, 0); | |
7129 | ||
7130 | if (load_debug_section (dwp_tu_index, file)) | |
7131 | process_cu_tu_index (&debug_displays [dwp_tu_index].section, 0); | |
7132 | ||
7133 | cu_tu_indexes_read = 1; | |
7134 | } | |
7135 | ||
7136 | /* Find the set of sections that includes section SHNDX. */ | |
7137 | ||
7138 | unsigned int * | |
7139 | find_cu_tu_set (void *file, unsigned int shndx) | |
7140 | { | |
7141 | unsigned int i; | |
7142 | ||
7143 | load_cu_tu_indexes (file); | |
7144 | ||
7145 | /* Find SHNDX in the shndx pool. */ | |
7146 | for (i = 0; i < shndx_pool_used; i++) | |
7147 | if (shndx_pool [i] == shndx) | |
7148 | break; | |
7149 | ||
7150 | if (i >= shndx_pool_used) | |
7151 | return NULL; | |
7152 | ||
7153 | /* Now backup to find the first entry in the set. */ | |
7154 | while (i > 0 && shndx_pool [i - 1] != 0) | |
7155 | i--; | |
7156 | ||
7157 | return shndx_pool + i; | |
7158 | } | |
7159 | ||
7160 | /* Display a .debug_cu_index or .debug_tu_index section. */ | |
7161 | ||
7162 | static int | |
7163 | display_cu_index (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED) | |
7164 | { | |
7165 | return process_cu_tu_index (section, 1); | |
7166 | } | |
7167 | ||
19e6b90e L |
7168 | static int |
7169 | display_debug_not_supported (struct dwarf_section *section, | |
7170 | void *file ATTRIBUTE_UNUSED) | |
7171 | { | |
7172 | printf (_("Displaying the debug contents of section %s is not yet supported.\n"), | |
7173 | section->name); | |
7174 | ||
7175 | return 1; | |
7176 | } | |
7177 | ||
1306a742 NC |
7178 | /* Like malloc, but takes two parameters like calloc. |
7179 | Verifies that the first parameter is not too large. | |
82b1b41b | 7180 | Note: does *not* initialise the allocated memory to zero. */ |
19e6b90e L |
7181 | void * |
7182 | cmalloc (size_t nmemb, size_t size) | |
7183 | { | |
7184 | /* Check for overflow. */ | |
7185 | if (nmemb >= ~(size_t) 0 / size) | |
7186 | return NULL; | |
82b1b41b NC |
7187 | |
7188 | return xmalloc (nmemb * size); | |
19e6b90e L |
7189 | } |
7190 | ||
1306a742 NC |
7191 | /* Like xmalloc, but takes two parameters like calloc. |
7192 | Verifies that the first parameter is not too large. | |
7193 | Note: does *not* initialise the allocated memory to zero. */ | |
72c61a0d | 7194 | void * |
1306a742 | 7195 | xcmalloc (size_t nmemb, size_t size) |
72c61a0d NC |
7196 | { |
7197 | /* Check for overflow. */ | |
7198 | if (nmemb >= ~(size_t) 0 / size) | |
7199 | return NULL; | |
7200 | ||
1306a742 | 7201 | return xmalloc (nmemb * size); |
72c61a0d NC |
7202 | } |
7203 | ||
1306a742 NC |
7204 | /* Like xrealloc, but takes three parameters. |
7205 | Verifies that the second parameter is not too large. | |
7206 | Note: does *not* initialise any new memory to zero. */ | |
19e6b90e | 7207 | void * |
1306a742 | 7208 | xcrealloc (void *ptr, size_t nmemb, size_t size) |
19e6b90e L |
7209 | { |
7210 | /* Check for overflow. */ | |
7211 | if (nmemb >= ~(size_t) 0 / size) | |
7212 | return NULL; | |
82b1b41b | 7213 | |
1306a742 | 7214 | return xrealloc (ptr, nmemb * size); |
19e6b90e L |
7215 | } |
7216 | ||
1306a742 | 7217 | /* Like xcalloc, but verifies that the first parameter is not too large. */ |
19e6b90e | 7218 | void * |
1306a742 | 7219 | xcalloc2 (size_t nmemb, size_t size) |
19e6b90e L |
7220 | { |
7221 | /* Check for overflow. */ | |
7222 | if (nmemb >= ~(size_t) 0 / size) | |
7223 | return NULL; | |
82b1b41b | 7224 | |
1306a742 | 7225 | return xcalloc (nmemb, size); |
19e6b90e L |
7226 | } |
7227 | ||
19e6b90e L |
7228 | void |
7229 | free_debug_memory (void) | |
7230 | { | |
3f5e193b | 7231 | unsigned int i; |
19e6b90e L |
7232 | |
7233 | free_abbrevs (); | |
7234 | ||
7235 | for (i = 0; i < max; i++) | |
3f5e193b | 7236 | free_debug_section ((enum dwarf_section_display_enum) i); |
19e6b90e | 7237 | |
cc86f28f | 7238 | if (debug_information != NULL) |
19e6b90e | 7239 | { |
cc86f28f | 7240 | if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE) |
19e6b90e | 7241 | { |
cc86f28f | 7242 | for (i = 0; i < num_debug_info_entries; i++) |
19e6b90e | 7243 | { |
cc86f28f NC |
7244 | if (!debug_information [i].max_loc_offsets) |
7245 | { | |
7246 | free (debug_information [i].loc_offsets); | |
7247 | free (debug_information [i].have_frame_base); | |
7248 | } | |
7249 | if (!debug_information [i].max_range_lists) | |
7250 | free (debug_information [i].range_lists); | |
19e6b90e | 7251 | } |
19e6b90e L |
7252 | } |
7253 | free (debug_information); | |
7254 | debug_information = NULL; | |
82b1b41b | 7255 | alloc_num_debug_info_entries = num_debug_info_entries = 0; |
19e6b90e | 7256 | } |
19e6b90e L |
7257 | } |
7258 | ||
4cb93e3b TG |
7259 | void |
7260 | dwarf_select_sections_by_names (const char *names) | |
7261 | { | |
7262 | typedef struct | |
7263 | { | |
7264 | const char * option; | |
7265 | int * variable; | |
f9f0e732 | 7266 | int val; |
4cb93e3b TG |
7267 | } |
7268 | debug_dump_long_opts; | |
7269 | ||
7270 | static const debug_dump_long_opts opts_table [] = | |
7271 | { | |
7272 | /* Please keep this table alpha- sorted. */ | |
7273 | { "Ranges", & do_debug_ranges, 1 }, | |
7274 | { "abbrev", & do_debug_abbrevs, 1 }, | |
657d0d47 | 7275 | { "addr", & do_debug_addr, 1 }, |
4cb93e3b | 7276 | { "aranges", & do_debug_aranges, 1 }, |
657d0d47 CC |
7277 | { "cu_index", & do_debug_cu_index, 1 }, |
7278 | { "decodedline", & do_debug_lines, FLAG_DEBUG_LINES_DECODED }, | |
4cb93e3b TG |
7279 | { "frames", & do_debug_frames, 1 }, |
7280 | { "frames-interp", & do_debug_frames_interp, 1 }, | |
657d0d47 CC |
7281 | /* The special .gdb_index section. */ |
7282 | { "gdb_index", & do_gdb_index, 1 }, | |
4cb93e3b TG |
7283 | { "info", & do_debug_info, 1 }, |
7284 | { "line", & do_debug_lines, FLAG_DEBUG_LINES_RAW }, /* For backwards compatibility. */ | |
4cb93e3b TG |
7285 | { "loc", & do_debug_loc, 1 }, |
7286 | { "macro", & do_debug_macinfo, 1 }, | |
7287 | { "pubnames", & do_debug_pubnames, 1 }, | |
357da287 | 7288 | { "pubtypes", & do_debug_pubtypes, 1 }, |
4cb93e3b TG |
7289 | /* This entry is for compatability |
7290 | with earlier versions of readelf. */ | |
7291 | { "ranges", & do_debug_aranges, 1 }, | |
657d0d47 | 7292 | { "rawline", & do_debug_lines, FLAG_DEBUG_LINES_RAW }, |
4cb93e3b | 7293 | { "str", & do_debug_str, 1 }, |
6f875884 TG |
7294 | /* These trace_* sections are used by Itanium VMS. */ |
7295 | { "trace_abbrev", & do_trace_abbrevs, 1 }, | |
7296 | { "trace_aranges", & do_trace_aranges, 1 }, | |
7297 | { "trace_info", & do_trace_info, 1 }, | |
4cb93e3b TG |
7298 | { NULL, NULL, 0 } |
7299 | }; | |
7300 | ||
7301 | const char *p; | |
467c65bc | 7302 | |
4cb93e3b TG |
7303 | p = names; |
7304 | while (*p) | |
7305 | { | |
7306 | const debug_dump_long_opts * entry; | |
467c65bc | 7307 | |
4cb93e3b TG |
7308 | for (entry = opts_table; entry->option; entry++) |
7309 | { | |
7310 | size_t len = strlen (entry->option); | |
467c65bc | 7311 | |
4cb93e3b TG |
7312 | if (strncmp (p, entry->option, len) == 0 |
7313 | && (p[len] == ',' || p[len] == '\0')) | |
7314 | { | |
7315 | * entry->variable |= entry->val; | |
467c65bc | 7316 | |
4cb93e3b TG |
7317 | /* The --debug-dump=frames-interp option also |
7318 | enables the --debug-dump=frames option. */ | |
7319 | if (do_debug_frames_interp) | |
7320 | do_debug_frames = 1; | |
7321 | ||
7322 | p += len; | |
7323 | break; | |
7324 | } | |
7325 | } | |
467c65bc | 7326 | |
4cb93e3b TG |
7327 | if (entry->option == NULL) |
7328 | { | |
7329 | warn (_("Unrecognized debug option '%s'\n"), p); | |
7330 | p = strchr (p, ','); | |
7331 | if (p == NULL) | |
7332 | break; | |
7333 | } | |
467c65bc | 7334 | |
4cb93e3b TG |
7335 | if (*p == ',') |
7336 | p++; | |
7337 | } | |
7338 | } | |
7339 | ||
7340 | void | |
7341 | dwarf_select_sections_by_letters (const char *letters) | |
7342 | { | |
91d6fa6a | 7343 | unsigned int lindex = 0; |
4cb93e3b | 7344 | |
91d6fa6a NC |
7345 | while (letters[lindex]) |
7346 | switch (letters[lindex++]) | |
4cb93e3b TG |
7347 | { |
7348 | case 'i': | |
7349 | do_debug_info = 1; | |
7350 | break; | |
467c65bc | 7351 | |
4cb93e3b TG |
7352 | case 'a': |
7353 | do_debug_abbrevs = 1; | |
7354 | break; | |
467c65bc | 7355 | |
4cb93e3b TG |
7356 | case 'l': |
7357 | do_debug_lines |= FLAG_DEBUG_LINES_RAW; | |
7358 | break; | |
467c65bc | 7359 | |
4cb93e3b TG |
7360 | case 'L': |
7361 | do_debug_lines |= FLAG_DEBUG_LINES_DECODED; | |
7362 | break; | |
467c65bc | 7363 | |
4cb93e3b TG |
7364 | case 'p': |
7365 | do_debug_pubnames = 1; | |
7366 | break; | |
467c65bc | 7367 | |
f9f0e732 NC |
7368 | case 't': |
7369 | do_debug_pubtypes = 1; | |
7370 | break; | |
467c65bc | 7371 | |
4cb93e3b TG |
7372 | case 'r': |
7373 | do_debug_aranges = 1; | |
7374 | break; | |
467c65bc | 7375 | |
4cb93e3b TG |
7376 | case 'R': |
7377 | do_debug_ranges = 1; | |
7378 | break; | |
467c65bc | 7379 | |
4cb93e3b TG |
7380 | case 'F': |
7381 | do_debug_frames_interp = 1; | |
7382 | case 'f': | |
7383 | do_debug_frames = 1; | |
7384 | break; | |
467c65bc | 7385 | |
4cb93e3b TG |
7386 | case 'm': |
7387 | do_debug_macinfo = 1; | |
7388 | break; | |
467c65bc | 7389 | |
4cb93e3b TG |
7390 | case 's': |
7391 | do_debug_str = 1; | |
7392 | break; | |
467c65bc | 7393 | |
4cb93e3b TG |
7394 | case 'o': |
7395 | do_debug_loc = 1; | |
7396 | break; | |
467c65bc | 7397 | |
4cb93e3b TG |
7398 | default: |
7399 | warn (_("Unrecognized debug option '%s'\n"), optarg); | |
7400 | break; | |
7401 | } | |
7402 | } | |
7403 | ||
7404 | void | |
7405 | dwarf_select_sections_all (void) | |
7406 | { | |
7407 | do_debug_info = 1; | |
7408 | do_debug_abbrevs = 1; | |
7409 | do_debug_lines = FLAG_DEBUG_LINES_RAW; | |
7410 | do_debug_pubnames = 1; | |
f9f0e732 | 7411 | do_debug_pubtypes = 1; |
4cb93e3b TG |
7412 | do_debug_aranges = 1; |
7413 | do_debug_ranges = 1; | |
7414 | do_debug_frames = 1; | |
7415 | do_debug_macinfo = 1; | |
7416 | do_debug_str = 1; | |
7417 | do_debug_loc = 1; | |
5bbdf3d5 | 7418 | do_gdb_index = 1; |
6f875884 TG |
7419 | do_trace_info = 1; |
7420 | do_trace_abbrevs = 1; | |
7421 | do_trace_aranges = 1; | |
657d0d47 CC |
7422 | do_debug_addr = 1; |
7423 | do_debug_cu_index = 1; | |
4cb93e3b TG |
7424 | } |
7425 | ||
19e6b90e L |
7426 | struct dwarf_section_display debug_displays[] = |
7427 | { | |
06614111 | 7428 | { { ".debug_abbrev", ".zdebug_abbrev", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7429 | display_debug_abbrev, &do_debug_abbrevs, 0 }, |
06614111 | 7430 | { { ".debug_aranges", ".zdebug_aranges", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7431 | display_debug_aranges, &do_debug_aranges, 1 }, |
06614111 | 7432 | { { ".debug_frame", ".zdebug_frame", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7433 | display_debug_frames, &do_debug_frames, 1 }, |
06614111 | 7434 | { { ".debug_info", ".zdebug_info", NULL, NULL, 0, 0, abbrev, NULL }, |
4723351a | 7435 | display_debug_info, &do_debug_info, 1 }, |
06614111 | 7436 | { { ".debug_line", ".zdebug_line", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7437 | display_debug_lines, &do_debug_lines, 1 }, |
06614111 | 7438 | { { ".debug_pubnames", ".zdebug_pubnames", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7439 | display_debug_pubnames, &do_debug_pubnames, 0 }, |
06614111 | 7440 | { { ".debug_gnu_pubnames", ".zdebug_gnu_pubnames", NULL, NULL, 0, 0, 0, NULL }, |
459d52c8 | 7441 | display_debug_gnu_pubnames, &do_debug_pubnames, 0 }, |
06614111 | 7442 | { { ".eh_frame", "", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7443 | display_debug_frames, &do_debug_frames, 1 }, |
06614111 | 7444 | { { ".debug_macinfo", ".zdebug_macinfo", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7445 | display_debug_macinfo, &do_debug_macinfo, 0 }, |
06614111 | 7446 | { { ".debug_macro", ".zdebug_macro", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7447 | display_debug_macro, &do_debug_macinfo, 1 }, |
06614111 | 7448 | { { ".debug_str", ".zdebug_str", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7449 | display_debug_str, &do_debug_str, 0 }, |
06614111 | 7450 | { { ".debug_loc", ".zdebug_loc", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7451 | display_debug_loc, &do_debug_loc, 1 }, |
06614111 | 7452 | { { ".debug_pubtypes", ".zdebug_pubtypes", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7453 | display_debug_pubnames, &do_debug_pubtypes, 0 }, |
06614111 | 7454 | { { ".debug_gnu_pubtypes", ".zdebug_gnu_pubtypes", NULL, NULL, 0, 0, 0, NULL }, |
459d52c8 | 7455 | display_debug_gnu_pubnames, &do_debug_pubtypes, 0 }, |
06614111 | 7456 | { { ".debug_ranges", ".zdebug_ranges", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7457 | display_debug_ranges, &do_debug_ranges, 1 }, |
06614111 | 7458 | { { ".debug_static_func", ".zdebug_static_func", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7459 | display_debug_not_supported, NULL, 0 }, |
06614111 | 7460 | { { ".debug_static_vars", ".zdebug_static_vars", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7461 | display_debug_not_supported, NULL, 0 }, |
06614111 | 7462 | { { ".debug_types", ".zdebug_types", NULL, NULL, 0, 0, abbrev, NULL }, |
4723351a | 7463 | display_debug_types, &do_debug_info, 1 }, |
06614111 | 7464 | { { ".debug_weaknames", ".zdebug_weaknames", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7465 | display_debug_not_supported, NULL, 0 }, |
06614111 | 7466 | { { ".gdb_index", "", NULL, NULL, 0, 0, 0, NULL }, |
657d0d47 | 7467 | display_gdb_index, &do_gdb_index, 0 }, |
06614111 | 7468 | { { ".trace_info", "", NULL, NULL, 0, 0, trace_abbrev, NULL }, |
657d0d47 | 7469 | display_trace_info, &do_trace_info, 1 }, |
06614111 | 7470 | { { ".trace_abbrev", "", NULL, NULL, 0, 0, 0, NULL }, |
657d0d47 | 7471 | display_debug_abbrev, &do_trace_abbrevs, 0 }, |
06614111 | 7472 | { { ".trace_aranges", "", NULL, NULL, 0, 0, 0, NULL }, |
657d0d47 | 7473 | display_debug_aranges, &do_trace_aranges, 0 }, |
06614111 | 7474 | { { ".debug_info.dwo", ".zdebug_info.dwo", NULL, NULL, 0, 0, abbrev_dwo, NULL }, |
657d0d47 | 7475 | display_debug_info, &do_debug_info, 1 }, |
06614111 | 7476 | { { ".debug_abbrev.dwo", ".zdebug_abbrev.dwo", NULL, NULL, 0, 0, 0, NULL }, |
657d0d47 | 7477 | display_debug_abbrev, &do_debug_abbrevs, 0 }, |
06614111 | 7478 | { { ".debug_types.dwo", ".zdebug_types.dwo", NULL, NULL, 0, 0, abbrev_dwo, NULL }, |
657d0d47 | 7479 | display_debug_types, &do_debug_info, 1 }, |
06614111 | 7480 | { { ".debug_line.dwo", ".zdebug_line.dwo", NULL, NULL, 0, 0, 0, NULL }, |
657d0d47 | 7481 | display_debug_lines, &do_debug_lines, 1 }, |
06614111 | 7482 | { { ".debug_loc.dwo", ".zdebug_loc.dwo", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7483 | display_debug_loc, &do_debug_loc, 1 }, |
06614111 | 7484 | { { ".debug_macro.dwo", ".zdebug_macro.dwo", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7485 | display_debug_macro, &do_debug_macinfo, 1 }, |
06614111 | 7486 | { { ".debug_macinfo.dwo", ".zdebug_macinfo.dwo", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7487 | display_debug_macinfo, &do_debug_macinfo, 0 }, |
06614111 | 7488 | { { ".debug_str.dwo", ".zdebug_str.dwo", NULL, NULL, 0, 0, 0, NULL }, |
657d0d47 | 7489 | display_debug_str, &do_debug_str, 1 }, |
06614111 | 7490 | { { ".debug_str_offsets", ".zdebug_str_offsets", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7491 | display_debug_str_offsets, NULL, 0 }, |
06614111 | 7492 | { { ".debug_str_offsets.dwo", ".zdebug_str_offsets.dwo", NULL, NULL, 0, 0, 0, NULL }, |
4723351a | 7493 | display_debug_str_offsets, NULL, 0 }, |
06614111 | 7494 | { { ".debug_addr", ".zdebug_addr", NULL, NULL, 0, 0, 0, NULL }, |
657d0d47 | 7495 | display_debug_addr, &do_debug_addr, 1 }, |
06614111 | 7496 | { { ".debug_cu_index", "", NULL, NULL, 0, 0, 0, NULL }, |
657d0d47 | 7497 | display_cu_index, &do_debug_cu_index, 0 }, |
06614111 | 7498 | { { ".debug_tu_index", "", NULL, NULL, 0, 0, 0, NULL }, |
657d0d47 | 7499 | display_cu_index, &do_debug_cu_index, 0 }, |
19e6b90e | 7500 | }; |