Commit | Line | Data |
---|---|---|
19e6b90e | 1 | /* dwarf.c -- display DWARF contents of a BFD binary file |
629e7ca8 | 2 | Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
19e6b90e L |
3 | Free Software Foundation, Inc. |
4 | ||
5 | This file is part of GNU Binutils. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
32866df7 | 9 | the Free Software Foundation; either version 3 of the License, or |
19e6b90e L |
10 | (at your option) any later version. |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA | |
20 | 02110-1301, USA. */ | |
21 | ||
3db64b00 | 22 | #include "sysdep.h" |
19e6b90e | 23 | #include "libiberty.h" |
3db64b00 | 24 | #include "bfd.h" |
5bbdf3d5 | 25 | #include "bfd_stdint.h" |
3db64b00 | 26 | #include "bucomm.h" |
3284fe0c | 27 | #include "elfcomm.h" |
2dc4cec1 | 28 | #include "elf/common.h" |
fa8f86ff | 29 | #include "dwarf2.h" |
3db64b00 | 30 | #include "dwarf.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; | |
41 | static debug_info *debug_information = NULL; | |
cc86f28f NC |
42 | /* Special value for num_debug_info_entries to indicate |
43 | that the .debug_info section could not be loaded/parsed. */ | |
44 | #define DEBUG_INFO_UNAVAILABLE (unsigned int) -1 | |
19e6b90e | 45 | |
2dc4cec1 | 46 | int eh_addr_size; |
19e6b90e L |
47 | |
48 | int do_debug_info; | |
49 | int do_debug_abbrevs; | |
50 | int do_debug_lines; | |
51 | int do_debug_pubnames; | |
f9f0e732 | 52 | int do_debug_pubtypes; |
19e6b90e L |
53 | int do_debug_aranges; |
54 | int do_debug_ranges; | |
55 | int do_debug_frames; | |
56 | int do_debug_frames_interp; | |
57 | int do_debug_macinfo; | |
58 | int do_debug_str; | |
59 | int do_debug_loc; | |
5bbdf3d5 | 60 | int do_gdb_index; |
6f875884 TG |
61 | int do_trace_info; |
62 | int do_trace_abbrevs; | |
63 | int do_trace_aranges; | |
a262ae96 | 64 | int do_wide; |
19e6b90e | 65 | |
fd2f0033 TT |
66 | int dwarf_cutoff_level = -1; |
67 | unsigned long dwarf_start_die; | |
68 | ||
4cb93e3b TG |
69 | /* Values for do_debug_lines. */ |
70 | #define FLAG_DEBUG_LINES_RAW 1 | |
71 | #define FLAG_DEBUG_LINES_DECODED 2 | |
72 | ||
f1c4cc75 RH |
73 | static int |
74 | size_of_encoded_value (int encoding) | |
75 | { | |
76 | switch (encoding & 0x7) | |
77 | { | |
78 | default: /* ??? */ | |
79 | case 0: return eh_addr_size; | |
80 | case 2: return 2; | |
81 | case 3: return 4; | |
82 | case 4: return 8; | |
83 | } | |
84 | } | |
85 | ||
86 | static dwarf_vma | |
bad62cf5 AM |
87 | get_encoded_value (unsigned char *data, |
88 | int encoding, | |
89 | struct dwarf_section *section) | |
f1c4cc75 RH |
90 | { |
91 | int size = size_of_encoded_value (encoding); | |
bad62cf5 | 92 | dwarf_vma val; |
f1c4cc75 RH |
93 | |
94 | if (encoding & DW_EH_PE_signed) | |
bad62cf5 | 95 | val = byte_get_signed (data, size); |
f1c4cc75 | 96 | else |
bad62cf5 AM |
97 | val = byte_get (data, size); |
98 | ||
99 | if ((encoding & 0x70) == DW_EH_PE_pcrel) | |
100 | val += section->address + (data - section->start); | |
101 | return val; | |
f1c4cc75 RH |
102 | } |
103 | ||
2d9472a2 NC |
104 | /* Print a dwarf_vma value (typically an address, offset or length) in |
105 | hexadecimal format, followed by a space. The length of the value (and | |
106 | hence the precision displayed) is determined by the byte_size parameter. */ | |
cecf136e | 107 | |
2d9472a2 NC |
108 | static void |
109 | print_dwarf_vma (dwarf_vma val, unsigned byte_size) | |
110 | { | |
111 | static char buff[18]; | |
467c65bc | 112 | int offset = 0; |
2d9472a2 NC |
113 | |
114 | /* Printf does not have a way of specifiying a maximum field width for an | |
115 | integer value, so we print the full value into a buffer and then select | |
116 | the precision we need. */ | |
117 | #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2) | |
467c65bc | 118 | #ifndef __MINGW32__ |
2d9472a2 | 119 | snprintf (buff, sizeof (buff), "%16.16llx ", val); |
2e14fae2 NC |
120 | #else |
121 | snprintf (buff, sizeof (buff), "%016I64x ", val); | |
122 | #endif | |
2d9472a2 NC |
123 | #else |
124 | snprintf (buff, sizeof (buff), "%16.16lx ", val); | |
125 | #endif | |
126 | ||
467c65bc NC |
127 | if (byte_size != 0) |
128 | { | |
129 | if (byte_size > 0 && byte_size <= 8) | |
130 | offset = 16 - 2 * byte_size; | |
131 | else | |
132 | error ("Wrong size in print_dwarf_vma"); | |
133 | } | |
134 | ||
135 | fputs (buff + offset, stdout); | |
2d9472a2 NC |
136 | } |
137 | ||
467c65bc NC |
138 | #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2) |
139 | #ifndef __MINGW32__ | |
140 | #define DWARF_VMA_FMT "ll" | |
141 | #else | |
142 | #define DWARF_VMA_FMT "I64" | |
143 | #endif | |
144 | #else | |
145 | #define DWARF_VMA_FMT "l" | |
146 | #endif | |
147 | ||
47704ddf | 148 | static const char * |
467c65bc | 149 | dwarf_vmatoa (const char *fmtch, dwarf_vma value) |
47704ddf KT |
150 | { |
151 | /* As dwarf_vmatoa is used more then once in a printf call | |
152 | for output, we are cycling through an fixed array of pointers | |
153 | for return address. */ | |
154 | static int buf_pos = 0; | |
467c65bc NC |
155 | static struct dwarf_vmatoa_buf |
156 | { | |
47704ddf KT |
157 | char place[64]; |
158 | } buf[16]; | |
159 | char fmt[32]; | |
160 | char *ret; | |
161 | ||
467c65bc | 162 | sprintf (fmt, "%%%s%s", DWARF_VMA_FMT, fmtch); |
47704ddf KT |
163 | |
164 | ret = buf[buf_pos++].place; | |
467c65bc | 165 | buf_pos %= ARRAY_SIZE (buf); |
47704ddf KT |
166 | |
167 | snprintf (ret, sizeof (buf[0].place), fmt, value); | |
168 | ||
169 | return ret; | |
170 | } | |
171 | ||
467c65bc | 172 | dwarf_vma |
19e6b90e L |
173 | read_leb128 (unsigned char *data, unsigned int *length_return, int sign) |
174 | { | |
467c65bc | 175 | dwarf_vma result = 0; |
19e6b90e L |
176 | unsigned int num_read = 0; |
177 | unsigned int shift = 0; | |
178 | unsigned char byte; | |
179 | ||
180 | do | |
181 | { | |
182 | byte = *data++; | |
183 | num_read++; | |
184 | ||
467c65bc | 185 | result |= ((dwarf_vma) (byte & 0x7f)) << shift; |
19e6b90e L |
186 | |
187 | shift += 7; | |
188 | ||
189 | } | |
190 | while (byte & 0x80); | |
191 | ||
192 | if (length_return != NULL) | |
193 | *length_return = num_read; | |
194 | ||
195 | if (sign && (shift < 8 * sizeof (result)) && (byte & 0x40)) | |
196 | result |= -1L << shift; | |
197 | ||
198 | return result; | |
199 | } | |
200 | ||
467c65bc NC |
201 | /* Create a signed version to avoid painful typecasts. */ |
202 | static dwarf_signed_vma | |
203 | read_sleb128 (unsigned char *data, unsigned int *length_return) | |
204 | { | |
205 | return (dwarf_signed_vma) read_leb128 (data, length_return, 1); | |
206 | } | |
207 | ||
19e6b90e L |
208 | typedef struct State_Machine_Registers |
209 | { | |
467c65bc | 210 | dwarf_vma address; |
19e6b90e L |
211 | unsigned int file; |
212 | unsigned int line; | |
213 | unsigned int column; | |
214 | int is_stmt; | |
215 | int basic_block; | |
a233b20c JJ |
216 | unsigned char op_index; |
217 | unsigned char end_sequence; | |
19e6b90e L |
218 | /* This variable hold the number of the last entry seen |
219 | in the File Table. */ | |
220 | unsigned int last_file_entry; | |
221 | } SMR; | |
222 | ||
223 | static SMR state_machine_regs; | |
224 | ||
225 | static void | |
226 | reset_state_machine (int is_stmt) | |
227 | { | |
228 | state_machine_regs.address = 0; | |
a233b20c | 229 | state_machine_regs.op_index = 0; |
19e6b90e L |
230 | state_machine_regs.file = 1; |
231 | state_machine_regs.line = 1; | |
232 | state_machine_regs.column = 0; | |
233 | state_machine_regs.is_stmt = is_stmt; | |
234 | state_machine_regs.basic_block = 0; | |
235 | state_machine_regs.end_sequence = 0; | |
236 | state_machine_regs.last_file_entry = 0; | |
237 | } | |
238 | ||
239 | /* Handled an extend line op. | |
240 | Returns the number of bytes read. */ | |
241 | ||
242 | static int | |
1617e571 | 243 | process_extended_line_op (unsigned char *data, int is_stmt) |
19e6b90e L |
244 | { |
245 | unsigned char op_code; | |
246 | unsigned int bytes_read; | |
247 | unsigned int len; | |
248 | unsigned char *name; | |
467c65bc | 249 | dwarf_vma adr; |
19e6b90e L |
250 | |
251 | len = read_leb128 (data, & bytes_read, 0); | |
252 | data += bytes_read; | |
253 | ||
254 | if (len == 0) | |
255 | { | |
256 | warn (_("badly formed extended line op encountered!\n")); | |
257 | return bytes_read; | |
258 | } | |
259 | ||
260 | len += bytes_read; | |
261 | op_code = *data++; | |
262 | ||
263 | printf (_(" Extended opcode %d: "), op_code); | |
264 | ||
265 | switch (op_code) | |
266 | { | |
267 | case DW_LNE_end_sequence: | |
268 | printf (_("End of Sequence\n\n")); | |
269 | reset_state_machine (is_stmt); | |
270 | break; | |
271 | ||
272 | case DW_LNE_set_address: | |
1617e571 | 273 | adr = byte_get (data, len - bytes_read - 1); |
47704ddf | 274 | printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr)); |
19e6b90e | 275 | state_machine_regs.address = adr; |
a233b20c | 276 | state_machine_regs.op_index = 0; |
19e6b90e L |
277 | break; |
278 | ||
279 | case DW_LNE_define_file: | |
280 | printf (_(" define new File Table entry\n")); | |
281 | printf (_(" Entry\tDir\tTime\tSize\tName\n")); | |
282 | ||
cc5914eb | 283 | printf (" %d\t", ++state_machine_regs.last_file_entry); |
19e6b90e L |
284 | name = data; |
285 | data += strlen ((char *) data) + 1; | |
467c65bc | 286 | printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); |
19e6b90e | 287 | data += bytes_read; |
467c65bc | 288 | printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); |
19e6b90e | 289 | data += bytes_read; |
467c65bc | 290 | printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); |
cc5914eb | 291 | printf ("%s\n\n", name); |
19e6b90e L |
292 | break; |
293 | ||
ed4a4bdf | 294 | case DW_LNE_set_discriminator: |
47704ddf | 295 | printf (_("set Discriminator to %s\n"), |
467c65bc | 296 | dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); |
ed4a4bdf CC |
297 | break; |
298 | ||
e2a0d921 NC |
299 | /* HP extensions. */ |
300 | case DW_LNE_HP_negate_is_UV_update: | |
ed4a4bdf | 301 | printf ("DW_LNE_HP_negate_is_UV_update\n"); |
e2a0d921 NC |
302 | break; |
303 | case DW_LNE_HP_push_context: | |
ed4a4bdf | 304 | printf ("DW_LNE_HP_push_context\n"); |
e2a0d921 NC |
305 | break; |
306 | case DW_LNE_HP_pop_context: | |
ed4a4bdf | 307 | printf ("DW_LNE_HP_pop_context\n"); |
e2a0d921 NC |
308 | break; |
309 | case DW_LNE_HP_set_file_line_column: | |
ed4a4bdf | 310 | printf ("DW_LNE_HP_set_file_line_column\n"); |
e2a0d921 NC |
311 | break; |
312 | case DW_LNE_HP_set_routine_name: | |
ed4a4bdf | 313 | printf ("DW_LNE_HP_set_routine_name\n"); |
e2a0d921 NC |
314 | break; |
315 | case DW_LNE_HP_set_sequence: | |
ed4a4bdf | 316 | printf ("DW_LNE_HP_set_sequence\n"); |
e2a0d921 NC |
317 | break; |
318 | case DW_LNE_HP_negate_post_semantics: | |
ed4a4bdf | 319 | printf ("DW_LNE_HP_negate_post_semantics\n"); |
e2a0d921 NC |
320 | break; |
321 | case DW_LNE_HP_negate_function_exit: | |
ed4a4bdf | 322 | printf ("DW_LNE_HP_negate_function_exit\n"); |
e2a0d921 NC |
323 | break; |
324 | case DW_LNE_HP_negate_front_end_logical: | |
ed4a4bdf | 325 | printf ("DW_LNE_HP_negate_front_end_logical\n"); |
e2a0d921 NC |
326 | break; |
327 | case DW_LNE_HP_define_proc: | |
ed4a4bdf | 328 | printf ("DW_LNE_HP_define_proc\n"); |
e2a0d921 | 329 | break; |
43294ab7 TG |
330 | case DW_LNE_HP_source_file_correlation: |
331 | { | |
332 | unsigned char *edata = data + len - bytes_read - 1; | |
333 | ||
334 | printf ("DW_LNE_HP_source_file_correlation\n"); | |
335 | ||
336 | while (data < edata) | |
337 | { | |
338 | unsigned int opc; | |
339 | ||
340 | opc = read_leb128 (data, & bytes_read, 0); | |
341 | data += bytes_read; | |
342 | ||
343 | switch (opc) | |
344 | { | |
345 | case DW_LNE_HP_SFC_formfeed: | |
346 | printf (" DW_LNE_HP_SFC_formfeed\n"); | |
347 | break; | |
348 | case DW_LNE_HP_SFC_set_listing_line: | |
349 | printf (" DW_LNE_HP_SFC_set_listing_line (%s)\n", | |
350 | dwarf_vmatoa ("u", | |
351 | read_leb128 (data, & bytes_read, 0))); | |
352 | data += bytes_read; | |
353 | break; | |
354 | case DW_LNE_HP_SFC_associate: | |
355 | printf (" DW_LNE_HP_SFC_associate "); | |
356 | printf (_("(%s"), | |
357 | dwarf_vmatoa ("u", | |
358 | read_leb128 (data, & bytes_read, 0))); | |
359 | data += bytes_read; | |
360 | printf (_(",%s"), | |
361 | dwarf_vmatoa ("u", | |
362 | read_leb128 (data, & bytes_read, 0))); | |
363 | data += bytes_read; | |
364 | printf (_(",%s)\n"), | |
365 | dwarf_vmatoa ("u", | |
366 | read_leb128 (data, & bytes_read, 0))); | |
367 | data += bytes_read; | |
368 | break; | |
369 | default: | |
370 | printf (" UNKNOW DW_LNE_HP_SFC opcode (%u)\n", opc); | |
371 | data = edata; | |
372 | break; | |
373 | } | |
374 | } | |
375 | } | |
376 | break; | |
cecf136e | 377 | |
19e6b90e | 378 | default: |
7e665af3 TG |
379 | { |
380 | unsigned int rlen = len - bytes_read - 1; | |
381 | ||
382 | if (op_code >= DW_LNE_lo_user | |
383 | /* The test against DW_LNW_hi_user is redundant due to | |
384 | the limited range of the unsigned char data type used | |
385 | for op_code. */ | |
386 | /*&& op_code <= DW_LNE_hi_user*/) | |
387 | printf (_("user defined: ")); | |
388 | else | |
389 | printf (_("UNKNOWN: ")); | |
390 | printf (_("length %d ["), rlen); | |
391 | for (; rlen; rlen--) | |
392 | printf (" %02x", *data++); | |
393 | printf ("]\n"); | |
394 | } | |
19e6b90e L |
395 | break; |
396 | } | |
397 | ||
398 | return len; | |
399 | } | |
400 | ||
401 | static const char * | |
467c65bc | 402 | fetch_indirect_string (dwarf_vma offset) |
19e6b90e L |
403 | { |
404 | struct dwarf_section *section = &debug_displays [str].section; | |
405 | ||
406 | if (section->start == NULL) | |
407 | return _("<no .debug_str section>"); | |
408 | ||
bfe2612a L |
409 | /* DWARF sections under Mach-O have non-zero addresses. */ |
410 | offset -= section->address; | |
19e6b90e L |
411 | if (offset > section->size) |
412 | { | |
467c65bc NC |
413 | warn (_("DW_FORM_strp offset too big: %s\n"), |
414 | dwarf_vmatoa ("x", offset)); | |
19e6b90e L |
415 | return _("<offset is too big>"); |
416 | } | |
417 | ||
418 | return (const char *) section->start + offset; | |
419 | } | |
420 | ||
421 | /* FIXME: There are better and more efficient ways to handle | |
422 | these structures. For now though, I just want something that | |
423 | is simple to implement. */ | |
424 | typedef struct abbrev_attr | |
425 | { | |
426 | unsigned long attribute; | |
427 | unsigned long form; | |
428 | struct abbrev_attr *next; | |
429 | } | |
430 | abbrev_attr; | |
431 | ||
432 | typedef struct abbrev_entry | |
433 | { | |
434 | unsigned long entry; | |
435 | unsigned long tag; | |
436 | int children; | |
437 | struct abbrev_attr *first_attr; | |
438 | struct abbrev_attr *last_attr; | |
439 | struct abbrev_entry *next; | |
440 | } | |
441 | abbrev_entry; | |
442 | ||
443 | static abbrev_entry *first_abbrev = NULL; | |
444 | static abbrev_entry *last_abbrev = NULL; | |
445 | ||
446 | static void | |
447 | free_abbrevs (void) | |
448 | { | |
91d6fa6a | 449 | abbrev_entry *abbrv; |
19e6b90e | 450 | |
91d6fa6a | 451 | for (abbrv = first_abbrev; abbrv;) |
19e6b90e | 452 | { |
91d6fa6a | 453 | abbrev_entry *next_abbrev = abbrv->next; |
19e6b90e L |
454 | abbrev_attr *attr; |
455 | ||
91d6fa6a | 456 | for (attr = abbrv->first_attr; attr;) |
19e6b90e | 457 | { |
91d6fa6a | 458 | abbrev_attr *next_attr = attr->next; |
19e6b90e L |
459 | |
460 | free (attr); | |
91d6fa6a | 461 | attr = next_attr; |
19e6b90e L |
462 | } |
463 | ||
91d6fa6a NC |
464 | free (abbrv); |
465 | abbrv = next_abbrev; | |
19e6b90e L |
466 | } |
467 | ||
468 | last_abbrev = first_abbrev = NULL; | |
469 | } | |
470 | ||
471 | static void | |
472 | add_abbrev (unsigned long number, unsigned long tag, int children) | |
473 | { | |
474 | abbrev_entry *entry; | |
475 | ||
3f5e193b | 476 | entry = (abbrev_entry *) malloc (sizeof (*entry)); |
19e6b90e L |
477 | if (entry == NULL) |
478 | /* ugg */ | |
479 | return; | |
480 | ||
481 | entry->entry = number; | |
482 | entry->tag = tag; | |
483 | entry->children = children; | |
484 | entry->first_attr = NULL; | |
485 | entry->last_attr = NULL; | |
486 | entry->next = NULL; | |
487 | ||
488 | if (first_abbrev == NULL) | |
489 | first_abbrev = entry; | |
490 | else | |
491 | last_abbrev->next = entry; | |
492 | ||
493 | last_abbrev = entry; | |
494 | } | |
495 | ||
496 | static void | |
497 | add_abbrev_attr (unsigned long attribute, unsigned long form) | |
498 | { | |
499 | abbrev_attr *attr; | |
500 | ||
3f5e193b | 501 | attr = (abbrev_attr *) malloc (sizeof (*attr)); |
19e6b90e L |
502 | if (attr == NULL) |
503 | /* ugg */ | |
504 | return; | |
505 | ||
506 | attr->attribute = attribute; | |
507 | attr->form = form; | |
508 | attr->next = NULL; | |
509 | ||
510 | if (last_abbrev->first_attr == NULL) | |
511 | last_abbrev->first_attr = attr; | |
512 | else | |
513 | last_abbrev->last_attr->next = attr; | |
514 | ||
515 | last_abbrev->last_attr = attr; | |
516 | } | |
517 | ||
518 | /* Processes the (partial) contents of a .debug_abbrev section. | |
519 | Returns NULL if the end of the section was encountered. | |
520 | Returns the address after the last byte read if the end of | |
521 | an abbreviation set was found. */ | |
522 | ||
523 | static unsigned char * | |
524 | process_abbrev_section (unsigned char *start, unsigned char *end) | |
525 | { | |
526 | if (first_abbrev != NULL) | |
527 | return NULL; | |
528 | ||
529 | while (start < end) | |
530 | { | |
531 | unsigned int bytes_read; | |
532 | unsigned long entry; | |
533 | unsigned long tag; | |
534 | unsigned long attribute; | |
535 | int children; | |
536 | ||
537 | entry = read_leb128 (start, & bytes_read, 0); | |
538 | start += bytes_read; | |
539 | ||
540 | /* A single zero is supposed to end the section according | |
541 | to the standard. If there's more, then signal that to | |
542 | the caller. */ | |
543 | if (entry == 0) | |
544 | return start == end ? NULL : start; | |
545 | ||
546 | tag = read_leb128 (start, & bytes_read, 0); | |
547 | start += bytes_read; | |
548 | ||
549 | children = *start++; | |
550 | ||
551 | add_abbrev (entry, tag, children); | |
552 | ||
553 | do | |
554 | { | |
555 | unsigned long form; | |
556 | ||
557 | attribute = read_leb128 (start, & bytes_read, 0); | |
558 | start += bytes_read; | |
559 | ||
560 | form = read_leb128 (start, & bytes_read, 0); | |
561 | start += bytes_read; | |
562 | ||
563 | if (attribute != 0) | |
564 | add_abbrev_attr (attribute, form); | |
565 | } | |
566 | while (attribute != 0); | |
567 | } | |
568 | ||
569 | return NULL; | |
570 | } | |
571 | ||
572 | static char * | |
573 | get_TAG_name (unsigned long tag) | |
574 | { | |
575 | switch (tag) | |
576 | { | |
577 | case DW_TAG_padding: return "DW_TAG_padding"; | |
578 | case DW_TAG_array_type: return "DW_TAG_array_type"; | |
579 | case DW_TAG_class_type: return "DW_TAG_class_type"; | |
580 | case DW_TAG_entry_point: return "DW_TAG_entry_point"; | |
581 | case DW_TAG_enumeration_type: return "DW_TAG_enumeration_type"; | |
582 | case DW_TAG_formal_parameter: return "DW_TAG_formal_parameter"; | |
583 | case DW_TAG_imported_declaration: return "DW_TAG_imported_declaration"; | |
584 | case DW_TAG_label: return "DW_TAG_label"; | |
585 | case DW_TAG_lexical_block: return "DW_TAG_lexical_block"; | |
586 | case DW_TAG_member: return "DW_TAG_member"; | |
587 | case DW_TAG_pointer_type: return "DW_TAG_pointer_type"; | |
588 | case DW_TAG_reference_type: return "DW_TAG_reference_type"; | |
589 | case DW_TAG_compile_unit: return "DW_TAG_compile_unit"; | |
590 | case DW_TAG_string_type: return "DW_TAG_string_type"; | |
591 | case DW_TAG_structure_type: return "DW_TAG_structure_type"; | |
592 | case DW_TAG_subroutine_type: return "DW_TAG_subroutine_type"; | |
593 | case DW_TAG_typedef: return "DW_TAG_typedef"; | |
594 | case DW_TAG_union_type: return "DW_TAG_union_type"; | |
595 | case DW_TAG_unspecified_parameters: return "DW_TAG_unspecified_parameters"; | |
596 | case DW_TAG_variant: return "DW_TAG_variant"; | |
597 | case DW_TAG_common_block: return "DW_TAG_common_block"; | |
598 | case DW_TAG_common_inclusion: return "DW_TAG_common_inclusion"; | |
599 | case DW_TAG_inheritance: return "DW_TAG_inheritance"; | |
600 | case DW_TAG_inlined_subroutine: return "DW_TAG_inlined_subroutine"; | |
601 | case DW_TAG_module: return "DW_TAG_module"; | |
602 | case DW_TAG_ptr_to_member_type: return "DW_TAG_ptr_to_member_type"; | |
603 | case DW_TAG_set_type: return "DW_TAG_set_type"; | |
604 | case DW_TAG_subrange_type: return "DW_TAG_subrange_type"; | |
605 | case DW_TAG_with_stmt: return "DW_TAG_with_stmt"; | |
606 | case DW_TAG_access_declaration: return "DW_TAG_access_declaration"; | |
607 | case DW_TAG_base_type: return "DW_TAG_base_type"; | |
608 | case DW_TAG_catch_block: return "DW_TAG_catch_block"; | |
609 | case DW_TAG_const_type: return "DW_TAG_const_type"; | |
610 | case DW_TAG_constant: return "DW_TAG_constant"; | |
611 | case DW_TAG_enumerator: return "DW_TAG_enumerator"; | |
612 | case DW_TAG_file_type: return "DW_TAG_file_type"; | |
613 | case DW_TAG_friend: return "DW_TAG_friend"; | |
614 | case DW_TAG_namelist: return "DW_TAG_namelist"; | |
615 | case DW_TAG_namelist_item: return "DW_TAG_namelist_item"; | |
616 | case DW_TAG_packed_type: return "DW_TAG_packed_type"; | |
617 | case DW_TAG_subprogram: return "DW_TAG_subprogram"; | |
618 | case DW_TAG_template_type_param: return "DW_TAG_template_type_param"; | |
619 | case DW_TAG_template_value_param: return "DW_TAG_template_value_param"; | |
620 | case DW_TAG_thrown_type: return "DW_TAG_thrown_type"; | |
621 | case DW_TAG_try_block: return "DW_TAG_try_block"; | |
622 | case DW_TAG_variant_part: return "DW_TAG_variant_part"; | |
623 | case DW_TAG_variable: return "DW_TAG_variable"; | |
624 | case DW_TAG_volatile_type: return "DW_TAG_volatile_type"; | |
625 | case DW_TAG_MIPS_loop: return "DW_TAG_MIPS_loop"; | |
626 | case DW_TAG_format_label: return "DW_TAG_format_label"; | |
627 | case DW_TAG_function_template: return "DW_TAG_function_template"; | |
628 | case DW_TAG_class_template: return "DW_TAG_class_template"; | |
629 | /* DWARF 2.1 values. */ | |
630 | case DW_TAG_dwarf_procedure: return "DW_TAG_dwarf_procedure"; | |
631 | case DW_TAG_restrict_type: return "DW_TAG_restrict_type"; | |
632 | case DW_TAG_interface_type: return "DW_TAG_interface_type"; | |
633 | case DW_TAG_namespace: return "DW_TAG_namespace"; | |
634 | case DW_TAG_imported_module: return "DW_TAG_imported_module"; | |
635 | case DW_TAG_unspecified_type: return "DW_TAG_unspecified_type"; | |
636 | case DW_TAG_partial_unit: return "DW_TAG_partial_unit"; | |
637 | case DW_TAG_imported_unit: return "DW_TAG_imported_unit"; | |
2b6f5997 CC |
638 | case DW_TAG_condition: return "DW_TAG_condition"; |
639 | case DW_TAG_shared_type: return "DW_TAG_shared_type"; | |
640 | /* DWARF 4 values. */ | |
641 | case DW_TAG_type_unit: return "DW_TAG_type_unit"; | |
642 | case DW_TAG_rvalue_reference_type: return "DW_TAG_rvalue_reference_type"; | |
643 | case DW_TAG_template_alias: return "DW_TAG_template_alias"; | |
19e6b90e L |
644 | /* UPC values. */ |
645 | case DW_TAG_upc_shared_type: return "DW_TAG_upc_shared_type"; | |
646 | case DW_TAG_upc_strict_type: return "DW_TAG_upc_strict_type"; | |
647 | case DW_TAG_upc_relaxed_type: return "DW_TAG_upc_relaxed_type"; | |
629e7ca8 JJ |
648 | /* GNU values. */ |
649 | case DW_TAG_GNU_call_site: return "DW_TAG_GNU_call_site"; | |
650 | case DW_TAG_GNU_call_site_parameter:return "DW_TAG_GNU_call_site_parameter"; | |
19e6b90e L |
651 | default: |
652 | { | |
653 | static char buffer[100]; | |
654 | ||
655 | snprintf (buffer, sizeof (buffer), _("Unknown TAG value: %lx"), tag); | |
656 | return buffer; | |
657 | } | |
658 | } | |
659 | } | |
660 | ||
661 | static char * | |
662 | get_FORM_name (unsigned long form) | |
663 | { | |
664 | switch (form) | |
665 | { | |
666 | case DW_FORM_addr: return "DW_FORM_addr"; | |
667 | case DW_FORM_block2: return "DW_FORM_block2"; | |
668 | case DW_FORM_block4: return "DW_FORM_block4"; | |
669 | case DW_FORM_data2: return "DW_FORM_data2"; | |
670 | case DW_FORM_data4: return "DW_FORM_data4"; | |
671 | case DW_FORM_data8: return "DW_FORM_data8"; | |
672 | case DW_FORM_string: return "DW_FORM_string"; | |
673 | case DW_FORM_block: return "DW_FORM_block"; | |
674 | case DW_FORM_block1: return "DW_FORM_block1"; | |
675 | case DW_FORM_data1: return "DW_FORM_data1"; | |
676 | case DW_FORM_flag: return "DW_FORM_flag"; | |
677 | case DW_FORM_sdata: return "DW_FORM_sdata"; | |
678 | case DW_FORM_strp: return "DW_FORM_strp"; | |
679 | case DW_FORM_udata: return "DW_FORM_udata"; | |
680 | case DW_FORM_ref_addr: return "DW_FORM_ref_addr"; | |
681 | case DW_FORM_ref1: return "DW_FORM_ref1"; | |
682 | case DW_FORM_ref2: return "DW_FORM_ref2"; | |
683 | case DW_FORM_ref4: return "DW_FORM_ref4"; | |
684 | case DW_FORM_ref8: return "DW_FORM_ref8"; | |
685 | case DW_FORM_ref_udata: return "DW_FORM_ref_udata"; | |
686 | case DW_FORM_indirect: return "DW_FORM_indirect"; | |
2b6f5997 CC |
687 | /* DWARF 4 values. */ |
688 | case DW_FORM_sec_offset: return "DW_FORM_sec_offset"; | |
689 | case DW_FORM_exprloc: return "DW_FORM_exprloc"; | |
690 | case DW_FORM_flag_present: return "DW_FORM_flag_present"; | |
691 | case DW_FORM_ref_sig8: return "DW_FORM_ref_sig8"; | |
19e6b90e L |
692 | default: |
693 | { | |
694 | static char buffer[100]; | |
695 | ||
696 | snprintf (buffer, sizeof (buffer), _("Unknown FORM value: %lx"), form); | |
697 | return buffer; | |
698 | } | |
699 | } | |
700 | } | |
701 | ||
702 | static unsigned char * | |
467c65bc | 703 | display_block (unsigned char *data, dwarf_vma length) |
19e6b90e | 704 | { |
467c65bc | 705 | printf (_(" %s byte block: "), dwarf_vmatoa ("u", length)); |
19e6b90e L |
706 | |
707 | while (length --) | |
708 | printf ("%lx ", (unsigned long) byte_get (data++, 1)); | |
709 | ||
710 | return data; | |
711 | } | |
712 | ||
713 | static int | |
714 | decode_location_expression (unsigned char * data, | |
715 | unsigned int pointer_size, | |
b7807392 JJ |
716 | unsigned int offset_size, |
717 | int dwarf_version, | |
467c65bc NC |
718 | dwarf_vma length, |
719 | dwarf_vma cu_offset, | |
f1c4cc75 | 720 | struct dwarf_section * section) |
19e6b90e L |
721 | { |
722 | unsigned op; | |
723 | unsigned int bytes_read; | |
467c65bc | 724 | dwarf_vma uvalue; |
19e6b90e L |
725 | unsigned char *end = data + length; |
726 | int need_frame_base = 0; | |
727 | ||
728 | while (data < end) | |
729 | { | |
730 | op = *data++; | |
731 | ||
732 | switch (op) | |
733 | { | |
734 | case DW_OP_addr: | |
767221a9 NC |
735 | printf ("DW_OP_addr: %s", |
736 | dwarf_vmatoa ("x", byte_get (data, pointer_size))); | |
19e6b90e L |
737 | data += pointer_size; |
738 | break; | |
739 | case DW_OP_deref: | |
740 | printf ("DW_OP_deref"); | |
741 | break; | |
742 | case DW_OP_const1u: | |
743 | printf ("DW_OP_const1u: %lu", (unsigned long) byte_get (data++, 1)); | |
744 | break; | |
745 | case DW_OP_const1s: | |
746 | printf ("DW_OP_const1s: %ld", (long) byte_get_signed (data++, 1)); | |
747 | break; | |
748 | case DW_OP_const2u: | |
749 | printf ("DW_OP_const2u: %lu", (unsigned long) byte_get (data, 2)); | |
750 | data += 2; | |
751 | break; | |
752 | case DW_OP_const2s: | |
753 | printf ("DW_OP_const2s: %ld", (long) byte_get_signed (data, 2)); | |
754 | data += 2; | |
755 | break; | |
756 | case DW_OP_const4u: | |
757 | printf ("DW_OP_const4u: %lu", (unsigned long) byte_get (data, 4)); | |
758 | data += 4; | |
759 | break; | |
760 | case DW_OP_const4s: | |
761 | printf ("DW_OP_const4s: %ld", (long) byte_get_signed (data, 4)); | |
762 | data += 4; | |
763 | break; | |
764 | case DW_OP_const8u: | |
765 | printf ("DW_OP_const8u: %lu %lu", (unsigned long) byte_get (data, 4), | |
766 | (unsigned long) byte_get (data + 4, 4)); | |
767 | data += 8; | |
768 | break; | |
769 | case DW_OP_const8s: | |
770 | printf ("DW_OP_const8s: %ld %ld", (long) byte_get (data, 4), | |
771 | (long) byte_get (data + 4, 4)); | |
772 | data += 8; | |
773 | break; | |
774 | case DW_OP_constu: | |
467c65bc NC |
775 | printf ("DW_OP_constu: %s", |
776 | dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0))); | |
19e6b90e L |
777 | data += bytes_read; |
778 | break; | |
779 | case DW_OP_consts: | |
467c65bc NC |
780 | printf ("DW_OP_consts: %s", |
781 | dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read))); | |
19e6b90e L |
782 | data += bytes_read; |
783 | break; | |
784 | case DW_OP_dup: | |
785 | printf ("DW_OP_dup"); | |
786 | break; | |
787 | case DW_OP_drop: | |
788 | printf ("DW_OP_drop"); | |
789 | break; | |
790 | case DW_OP_over: | |
791 | printf ("DW_OP_over"); | |
792 | break; | |
793 | case DW_OP_pick: | |
794 | printf ("DW_OP_pick: %ld", (unsigned long) byte_get (data++, 1)); | |
795 | break; | |
796 | case DW_OP_swap: | |
797 | printf ("DW_OP_swap"); | |
798 | break; | |
799 | case DW_OP_rot: | |
800 | printf ("DW_OP_rot"); | |
801 | break; | |
802 | case DW_OP_xderef: | |
803 | printf ("DW_OP_xderef"); | |
804 | break; | |
805 | case DW_OP_abs: | |
806 | printf ("DW_OP_abs"); | |
807 | break; | |
808 | case DW_OP_and: | |
809 | printf ("DW_OP_and"); | |
810 | break; | |
811 | case DW_OP_div: | |
812 | printf ("DW_OP_div"); | |
813 | break; | |
814 | case DW_OP_minus: | |
815 | printf ("DW_OP_minus"); | |
816 | break; | |
817 | case DW_OP_mod: | |
818 | printf ("DW_OP_mod"); | |
819 | break; | |
820 | case DW_OP_mul: | |
821 | printf ("DW_OP_mul"); | |
822 | break; | |
823 | case DW_OP_neg: | |
824 | printf ("DW_OP_neg"); | |
825 | break; | |
826 | case DW_OP_not: | |
827 | printf ("DW_OP_not"); | |
828 | break; | |
829 | case DW_OP_or: | |
830 | printf ("DW_OP_or"); | |
831 | break; | |
832 | case DW_OP_plus: | |
833 | printf ("DW_OP_plus"); | |
834 | break; | |
835 | case DW_OP_plus_uconst: | |
467c65bc NC |
836 | printf ("DW_OP_plus_uconst: %s", |
837 | dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0))); | |
19e6b90e L |
838 | data += bytes_read; |
839 | break; | |
840 | case DW_OP_shl: | |
841 | printf ("DW_OP_shl"); | |
842 | break; | |
843 | case DW_OP_shr: | |
844 | printf ("DW_OP_shr"); | |
845 | break; | |
846 | case DW_OP_shra: | |
847 | printf ("DW_OP_shra"); | |
848 | break; | |
849 | case DW_OP_xor: | |
850 | printf ("DW_OP_xor"); | |
851 | break; | |
852 | case DW_OP_bra: | |
853 | printf ("DW_OP_bra: %ld", (long) byte_get_signed (data, 2)); | |
854 | data += 2; | |
855 | break; | |
856 | case DW_OP_eq: | |
857 | printf ("DW_OP_eq"); | |
858 | break; | |
859 | case DW_OP_ge: | |
860 | printf ("DW_OP_ge"); | |
861 | break; | |
862 | case DW_OP_gt: | |
863 | printf ("DW_OP_gt"); | |
864 | break; | |
865 | case DW_OP_le: | |
866 | printf ("DW_OP_le"); | |
867 | break; | |
868 | case DW_OP_lt: | |
869 | printf ("DW_OP_lt"); | |
870 | break; | |
871 | case DW_OP_ne: | |
872 | printf ("DW_OP_ne"); | |
873 | break; | |
874 | case DW_OP_skip: | |
875 | printf ("DW_OP_skip: %ld", (long) byte_get_signed (data, 2)); | |
876 | data += 2; | |
877 | break; | |
878 | ||
879 | case DW_OP_lit0: | |
880 | case DW_OP_lit1: | |
881 | case DW_OP_lit2: | |
882 | case DW_OP_lit3: | |
883 | case DW_OP_lit4: | |
884 | case DW_OP_lit5: | |
885 | case DW_OP_lit6: | |
886 | case DW_OP_lit7: | |
887 | case DW_OP_lit8: | |
888 | case DW_OP_lit9: | |
889 | case DW_OP_lit10: | |
890 | case DW_OP_lit11: | |
891 | case DW_OP_lit12: | |
892 | case DW_OP_lit13: | |
893 | case DW_OP_lit14: | |
894 | case DW_OP_lit15: | |
895 | case DW_OP_lit16: | |
896 | case DW_OP_lit17: | |
897 | case DW_OP_lit18: | |
898 | case DW_OP_lit19: | |
899 | case DW_OP_lit20: | |
900 | case DW_OP_lit21: | |
901 | case DW_OP_lit22: | |
902 | case DW_OP_lit23: | |
903 | case DW_OP_lit24: | |
904 | case DW_OP_lit25: | |
905 | case DW_OP_lit26: | |
906 | case DW_OP_lit27: | |
907 | case DW_OP_lit28: | |
908 | case DW_OP_lit29: | |
909 | case DW_OP_lit30: | |
910 | case DW_OP_lit31: | |
911 | printf ("DW_OP_lit%d", op - DW_OP_lit0); | |
912 | break; | |
913 | ||
914 | case DW_OP_reg0: | |
915 | case DW_OP_reg1: | |
916 | case DW_OP_reg2: | |
917 | case DW_OP_reg3: | |
918 | case DW_OP_reg4: | |
919 | case DW_OP_reg5: | |
920 | case DW_OP_reg6: | |
921 | case DW_OP_reg7: | |
922 | case DW_OP_reg8: | |
923 | case DW_OP_reg9: | |
924 | case DW_OP_reg10: | |
925 | case DW_OP_reg11: | |
926 | case DW_OP_reg12: | |
927 | case DW_OP_reg13: | |
928 | case DW_OP_reg14: | |
929 | case DW_OP_reg15: | |
930 | case DW_OP_reg16: | |
931 | case DW_OP_reg17: | |
932 | case DW_OP_reg18: | |
933 | case DW_OP_reg19: | |
934 | case DW_OP_reg20: | |
935 | case DW_OP_reg21: | |
936 | case DW_OP_reg22: | |
937 | case DW_OP_reg23: | |
938 | case DW_OP_reg24: | |
939 | case DW_OP_reg25: | |
940 | case DW_OP_reg26: | |
941 | case DW_OP_reg27: | |
942 | case DW_OP_reg28: | |
943 | case DW_OP_reg29: | |
944 | case DW_OP_reg30: | |
945 | case DW_OP_reg31: | |
18464d4d JK |
946 | printf ("DW_OP_reg%d (%s)", op - DW_OP_reg0, |
947 | regname (op - DW_OP_reg0, 1)); | |
19e6b90e L |
948 | break; |
949 | ||
950 | case DW_OP_breg0: | |
951 | case DW_OP_breg1: | |
952 | case DW_OP_breg2: | |
953 | case DW_OP_breg3: | |
954 | case DW_OP_breg4: | |
955 | case DW_OP_breg5: | |
956 | case DW_OP_breg6: | |
957 | case DW_OP_breg7: | |
958 | case DW_OP_breg8: | |
959 | case DW_OP_breg9: | |
960 | case DW_OP_breg10: | |
961 | case DW_OP_breg11: | |
962 | case DW_OP_breg12: | |
963 | case DW_OP_breg13: | |
964 | case DW_OP_breg14: | |
965 | case DW_OP_breg15: | |
966 | case DW_OP_breg16: | |
967 | case DW_OP_breg17: | |
968 | case DW_OP_breg18: | |
969 | case DW_OP_breg19: | |
970 | case DW_OP_breg20: | |
971 | case DW_OP_breg21: | |
972 | case DW_OP_breg22: | |
973 | case DW_OP_breg23: | |
974 | case DW_OP_breg24: | |
975 | case DW_OP_breg25: | |
976 | case DW_OP_breg26: | |
977 | case DW_OP_breg27: | |
978 | case DW_OP_breg28: | |
979 | case DW_OP_breg29: | |
980 | case DW_OP_breg30: | |
981 | case DW_OP_breg31: | |
467c65bc | 982 | printf ("DW_OP_breg%d (%s): %s", |
47704ddf | 983 | op - DW_OP_breg0, |
18464d4d | 984 | regname (op - DW_OP_breg0, 1), |
467c65bc NC |
985 | dwarf_vmatoa ("d", (dwarf_signed_vma) |
986 | read_leb128 (data, &bytes_read, 1))); | |
19e6b90e L |
987 | data += bytes_read; |
988 | break; | |
989 | ||
990 | case DW_OP_regx: | |
18464d4d | 991 | uvalue = read_leb128 (data, &bytes_read, 0); |
19e6b90e | 992 | data += bytes_read; |
467c65bc NC |
993 | printf ("DW_OP_regx: %s (%s)", |
994 | dwarf_vmatoa ("u", uvalue), regname (uvalue, 1)); | |
19e6b90e L |
995 | break; |
996 | case DW_OP_fbreg: | |
997 | need_frame_base = 1; | |
467c65bc NC |
998 | printf ("DW_OP_fbreg: %s", |
999 | dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read))); | |
19e6b90e L |
1000 | data += bytes_read; |
1001 | break; | |
1002 | case DW_OP_bregx: | |
1003 | uvalue = read_leb128 (data, &bytes_read, 0); | |
1004 | data += bytes_read; | |
467c65bc NC |
1005 | printf ("DW_OP_bregx: %s (%s) %s", |
1006 | dwarf_vmatoa ("u", uvalue), regname (uvalue, 1), | |
1007 | dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read))); | |
19e6b90e L |
1008 | data += bytes_read; |
1009 | break; | |
1010 | case DW_OP_piece: | |
467c65bc NC |
1011 | printf ("DW_OP_piece: %s", |
1012 | dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0))); | |
19e6b90e L |
1013 | data += bytes_read; |
1014 | break; | |
1015 | case DW_OP_deref_size: | |
1016 | printf ("DW_OP_deref_size: %ld", (long) byte_get (data++, 1)); | |
1017 | break; | |
1018 | case DW_OP_xderef_size: | |
1019 | printf ("DW_OP_xderef_size: %ld", (long) byte_get (data++, 1)); | |
1020 | break; | |
1021 | case DW_OP_nop: | |
1022 | printf ("DW_OP_nop"); | |
1023 | break; | |
1024 | ||
1025 | /* DWARF 3 extensions. */ | |
1026 | case DW_OP_push_object_address: | |
1027 | printf ("DW_OP_push_object_address"); | |
1028 | break; | |
1029 | case DW_OP_call2: | |
1030 | /* XXX: Strictly speaking for 64-bit DWARF3 files | |
1031 | this ought to be an 8-byte wide computation. */ | |
467c65bc NC |
1032 | printf ("DW_OP_call2: <0x%s>", |
1033 | dwarf_vmatoa ("x", (dwarf_signed_vma) byte_get (data, 2) | |
1034 | + cu_offset)); | |
19e6b90e L |
1035 | data += 2; |
1036 | break; | |
1037 | case DW_OP_call4: | |
1038 | /* XXX: Strictly speaking for 64-bit DWARF3 files | |
1039 | this ought to be an 8-byte wide computation. */ | |
467c65bc NC |
1040 | printf ("DW_OP_call4: <0x%s>", |
1041 | dwarf_vmatoa ("x", (dwarf_signed_vma) byte_get (data, 4) | |
1042 | + cu_offset)); | |
19e6b90e L |
1043 | data += 4; |
1044 | break; | |
1045 | case DW_OP_call_ref: | |
e2a0d921 NC |
1046 | /* XXX: Strictly speaking for 64-bit DWARF3 files |
1047 | this ought to be an 8-byte wide computation. */ | |
b7807392 JJ |
1048 | if (dwarf_version == -1) |
1049 | { | |
1050 | printf (_("(DW_OP_call_ref in frame info)")); | |
1051 | /* No way to tell where the next op is, so just bail. */ | |
1052 | return need_frame_base; | |
1053 | } | |
1054 | if (dwarf_version == 2) | |
1055 | { | |
467c65bc NC |
1056 | printf ("DW_OP_call_ref: <0x%s>", |
1057 | dwarf_vmatoa ("x", byte_get (data, pointer_size))); | |
b7807392 JJ |
1058 | data += pointer_size; |
1059 | } | |
1060 | else | |
1061 | { | |
467c65bc NC |
1062 | printf ("DW_OP_call_ref: <0x%s>", |
1063 | dwarf_vmatoa ("x", byte_get (data, offset_size))); | |
b7807392 JJ |
1064 | data += offset_size; |
1065 | } | |
19e6b90e | 1066 | break; |
a87b0a59 NS |
1067 | case DW_OP_form_tls_address: |
1068 | printf ("DW_OP_form_tls_address"); | |
1069 | break; | |
e2a0d921 NC |
1070 | case DW_OP_call_frame_cfa: |
1071 | printf ("DW_OP_call_frame_cfa"); | |
1072 | break; | |
1073 | case DW_OP_bit_piece: | |
1074 | printf ("DW_OP_bit_piece: "); | |
467c65bc NC |
1075 | printf ("size: %s ", |
1076 | dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0))); | |
e2a0d921 | 1077 | data += bytes_read; |
467c65bc NC |
1078 | printf ("offset: %s ", |
1079 | dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0))); | |
e2a0d921 NC |
1080 | data += bytes_read; |
1081 | break; | |
19e6b90e | 1082 | |
3244e8f5 JJ |
1083 | /* DWARF 4 extensions. */ |
1084 | case DW_OP_stack_value: | |
1085 | printf ("DW_OP_stack_value"); | |
1086 | break; | |
1087 | ||
1088 | case DW_OP_implicit_value: | |
1089 | printf ("DW_OP_implicit_value"); | |
1090 | uvalue = read_leb128 (data, &bytes_read, 0); | |
1091 | data += bytes_read; | |
1092 | display_block (data, uvalue); | |
1093 | data += uvalue; | |
1094 | break; | |
1095 | ||
19e6b90e L |
1096 | /* GNU extensions. */ |
1097 | case DW_OP_GNU_push_tls_address: | |
e2a0d921 NC |
1098 | printf ("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown"); |
1099 | break; | |
1100 | case DW_OP_GNU_uninit: | |
1101 | printf ("DW_OP_GNU_uninit"); | |
1102 | /* FIXME: Is there data associated with this OP ? */ | |
1103 | break; | |
f1c4cc75 RH |
1104 | case DW_OP_GNU_encoded_addr: |
1105 | { | |
1106 | int encoding; | |
1107 | dwarf_vma addr; | |
467c65bc | 1108 | |
f1c4cc75 | 1109 | encoding = *data++; |
bad62cf5 | 1110 | addr = get_encoded_value (data, encoding, section); |
f1c4cc75 RH |
1111 | data += size_of_encoded_value (encoding); |
1112 | ||
1113 | printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding); | |
1114 | print_dwarf_vma (addr, pointer_size); | |
1115 | } | |
1116 | break; | |
b7807392 JJ |
1117 | case DW_OP_GNU_implicit_pointer: |
1118 | /* XXX: Strictly speaking for 64-bit DWARF3 files | |
1119 | this ought to be an 8-byte wide computation. */ | |
1120 | if (dwarf_version == -1) | |
1121 | { | |
1122 | printf (_("(DW_OP_GNU_implicit_pointer in frame info)")); | |
1123 | /* No way to tell where the next op is, so just bail. */ | |
1124 | return need_frame_base; | |
1125 | } | |
1126 | if (dwarf_version == 2) | |
1127 | { | |
467c65bc NC |
1128 | printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s", |
1129 | dwarf_vmatoa ("x", byte_get (data, pointer_size)), | |
1130 | dwarf_vmatoa ("d", read_sleb128 (data + pointer_size, | |
1131 | &bytes_read))); | |
b7807392 JJ |
1132 | data += pointer_size + bytes_read; |
1133 | } | |
1134 | else | |
1135 | { | |
467c65bc NC |
1136 | printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s", |
1137 | dwarf_vmatoa ("x", byte_get (data, offset_size)), | |
1138 | dwarf_vmatoa ("d", read_sleb128 (data + offset_size, | |
1139 | &bytes_read))); | |
8383c696 | 1140 | data += offset_size + bytes_read; |
b7807392 JJ |
1141 | } |
1142 | break; | |
0892011d JJ |
1143 | case DW_OP_GNU_entry_value: |
1144 | uvalue = read_leb128 (data, &bytes_read, 0); | |
1145 | data += bytes_read; | |
1146 | printf ("DW_OP_GNU_entry_value: ("); | |
1147 | if (decode_location_expression (data, pointer_size, offset_size, | |
1148 | dwarf_version, uvalue, | |
1149 | cu_offset, section)) | |
1150 | need_frame_base = 1; | |
1151 | putchar (')'); | |
1152 | data += uvalue; | |
1153 | break; | |
1154 | case DW_OP_GNU_const_type: | |
1155 | uvalue = read_leb128 (data, &bytes_read, 0); | |
1156 | data += bytes_read; | |
1157 | printf ("DW_OP_GNU_const_type: <0x%s> ", | |
1158 | dwarf_vmatoa ("x", cu_offset + uvalue)); | |
1159 | uvalue = byte_get (data++, 1); | |
1160 | display_block (data, uvalue); | |
1161 | data += uvalue; | |
1162 | break; | |
1163 | case DW_OP_GNU_regval_type: | |
1164 | uvalue = read_leb128 (data, &bytes_read, 0); | |
1165 | data += bytes_read; | |
1166 | printf ("DW_OP_GNU_regval_type: %s (%s)", | |
1167 | dwarf_vmatoa ("u", uvalue), regname (uvalue, 1)); | |
1168 | uvalue = read_leb128 (data, &bytes_read, 0); | |
1169 | data += bytes_read; | |
1170 | printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue)); | |
1171 | break; | |
1172 | case DW_OP_GNU_deref_type: | |
1173 | printf ("DW_OP_GNU_deref_type: %ld", (long) byte_get (data++, 1)); | |
1174 | uvalue = read_leb128 (data, &bytes_read, 0); | |
1175 | data += bytes_read; | |
1176 | printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue)); | |
1177 | break; | |
1178 | case DW_OP_GNU_convert: | |
1179 | uvalue = read_leb128 (data, &bytes_read, 0); | |
1180 | data += bytes_read; | |
1181 | printf ("DW_OP_GNU_convert <0x%s>", | |
f8b999f9 | 1182 | dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0)); |
0892011d JJ |
1183 | break; |
1184 | case DW_OP_GNU_reinterpret: | |
1185 | uvalue = read_leb128 (data, &bytes_read, 0); | |
1186 | data += bytes_read; | |
1187 | printf ("DW_OP_GNU_reinterpret <0x%s>", | |
f8b999f9 JJ |
1188 | dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0)); |
1189 | break; | |
1190 | case DW_OP_GNU_parameter_ref: | |
1191 | printf ("DW_OP_GNU_parameter_ref: <0x%s>", | |
1192 | dwarf_vmatoa ("x", cu_offset + byte_get (data, 4))); | |
1193 | data += 4; | |
0892011d | 1194 | break; |
e2a0d921 NC |
1195 | |
1196 | /* HP extensions. */ | |
1197 | case DW_OP_HP_is_value: | |
1198 | printf ("DW_OP_HP_is_value"); | |
1199 | /* FIXME: Is there data associated with this OP ? */ | |
1200 | break; | |
1201 | case DW_OP_HP_fltconst4: | |
1202 | printf ("DW_OP_HP_fltconst4"); | |
1203 | /* FIXME: Is there data associated with this OP ? */ | |
1204 | break; | |
1205 | case DW_OP_HP_fltconst8: | |
1206 | printf ("DW_OP_HP_fltconst8"); | |
1207 | /* FIXME: Is there data associated with this OP ? */ | |
1208 | break; | |
1209 | case DW_OP_HP_mod_range: | |
1210 | printf ("DW_OP_HP_mod_range"); | |
1211 | /* FIXME: Is there data associated with this OP ? */ | |
1212 | break; | |
1213 | case DW_OP_HP_unmod_range: | |
1214 | printf ("DW_OP_HP_unmod_range"); | |
1215 | /* FIXME: Is there data associated with this OP ? */ | |
1216 | break; | |
1217 | case DW_OP_HP_tls: | |
1218 | printf ("DW_OP_HP_tls"); | |
1219 | /* FIXME: Is there data associated with this OP ? */ | |
19e6b90e L |
1220 | break; |
1221 | ||
35d60fe4 NC |
1222 | /* PGI (STMicroelectronics) extensions. */ |
1223 | case DW_OP_PGI_omp_thread_num: | |
1224 | /* Pushes the thread number for the current thread as it would be | |
1225 | returned by the standard OpenMP library function: | |
1226 | omp_get_thread_num(). The "current thread" is the thread for | |
1227 | which the expression is being evaluated. */ | |
1228 | printf ("DW_OP_PGI_omp_thread_num"); | |
1229 | break; | |
1230 | ||
19e6b90e L |
1231 | default: |
1232 | if (op >= DW_OP_lo_user | |
1233 | && op <= DW_OP_hi_user) | |
1234 | printf (_("(User defined location op)")); | |
1235 | else | |
1236 | printf (_("(Unknown location op)")); | |
1237 | /* No way to tell where the next op is, so just bail. */ | |
1238 | return need_frame_base; | |
1239 | } | |
1240 | ||
1241 | /* Separate the ops. */ | |
1242 | if (data < end) | |
1243 | printf ("; "); | |
1244 | } | |
1245 | ||
1246 | return need_frame_base; | |
1247 | } | |
1248 | ||
1249 | static unsigned char * | |
6e3d6dc1 NC |
1250 | read_and_display_attr_value (unsigned long attribute, |
1251 | unsigned long form, | |
ec4d4525 | 1252 | unsigned char * data, |
467c65bc NC |
1253 | dwarf_vma cu_offset, |
1254 | dwarf_vma pointer_size, | |
1255 | dwarf_vma offset_size, | |
6e3d6dc1 NC |
1256 | int dwarf_version, |
1257 | debug_info * debug_info_p, | |
1258 | int do_loc, | |
1259 | struct dwarf_section * section) | |
19e6b90e | 1260 | { |
467c65bc | 1261 | dwarf_vma uvalue = 0; |
19e6b90e | 1262 | unsigned char *block_start = NULL; |
6e3d6dc1 | 1263 | unsigned char * orig_data = data; |
19e6b90e L |
1264 | unsigned int bytes_read; |
1265 | ||
1266 | switch (form) | |
1267 | { | |
1268 | default: | |
1269 | break; | |
1270 | ||
1271 | case DW_FORM_ref_addr: | |
1272 | if (dwarf_version == 2) | |
1273 | { | |
1274 | uvalue = byte_get (data, pointer_size); | |
1275 | data += pointer_size; | |
1276 | } | |
932fd279 | 1277 | else if (dwarf_version == 3 || dwarf_version == 4) |
19e6b90e L |
1278 | { |
1279 | uvalue = byte_get (data, offset_size); | |
1280 | data += offset_size; | |
1281 | } | |
1282 | else | |
467c65bc NC |
1283 | error (_("Internal error: DWARF version is not 2, 3 or 4.\n")); |
1284 | ||
19e6b90e L |
1285 | break; |
1286 | ||
1287 | case DW_FORM_addr: | |
1288 | uvalue = byte_get (data, pointer_size); | |
1289 | data += pointer_size; | |
1290 | break; | |
1291 | ||
1292 | case DW_FORM_strp: | |
932fd279 | 1293 | case DW_FORM_sec_offset: |
19e6b90e L |
1294 | uvalue = byte_get (data, offset_size); |
1295 | data += offset_size; | |
1296 | break; | |
1297 | ||
932fd279 JJ |
1298 | case DW_FORM_flag_present: |
1299 | uvalue = 1; | |
1300 | break; | |
1301 | ||
19e6b90e L |
1302 | case DW_FORM_ref1: |
1303 | case DW_FORM_flag: | |
1304 | case DW_FORM_data1: | |
1305 | uvalue = byte_get (data++, 1); | |
1306 | break; | |
1307 | ||
1308 | case DW_FORM_ref2: | |
1309 | case DW_FORM_data2: | |
1310 | uvalue = byte_get (data, 2); | |
1311 | data += 2; | |
1312 | break; | |
1313 | ||
1314 | case DW_FORM_ref4: | |
1315 | case DW_FORM_data4: | |
1316 | uvalue = byte_get (data, 4); | |
1317 | data += 4; | |
1318 | break; | |
1319 | ||
1320 | case DW_FORM_sdata: | |
1321 | uvalue = read_leb128 (data, & bytes_read, 1); | |
1322 | data += bytes_read; | |
1323 | break; | |
1324 | ||
1325 | case DW_FORM_ref_udata: | |
1326 | case DW_FORM_udata: | |
1327 | uvalue = read_leb128 (data, & bytes_read, 0); | |
1328 | data += bytes_read; | |
1329 | break; | |
1330 | ||
1331 | case DW_FORM_indirect: | |
1332 | form = read_leb128 (data, & bytes_read, 0); | |
1333 | data += bytes_read; | |
1334 | if (!do_loc) | |
1335 | printf (" %s", get_FORM_name (form)); | |
1336 | return read_and_display_attr_value (attribute, form, data, | |
1337 | cu_offset, pointer_size, | |
1338 | offset_size, dwarf_version, | |
ec4d4525 | 1339 | debug_info_p, do_loc, |
6e3d6dc1 | 1340 | section); |
19e6b90e L |
1341 | } |
1342 | ||
1343 | switch (form) | |
1344 | { | |
1345 | case DW_FORM_ref_addr: | |
1346 | if (!do_loc) | |
467c65bc | 1347 | printf (" <0x%s>", dwarf_vmatoa ("x",uvalue)); |
19e6b90e L |
1348 | break; |
1349 | ||
1350 | case DW_FORM_ref1: | |
1351 | case DW_FORM_ref2: | |
1352 | case DW_FORM_ref4: | |
1353 | case DW_FORM_ref_udata: | |
1354 | if (!do_loc) | |
467c65bc | 1355 | printf (" <0x%s>", dwarf_vmatoa ("x", uvalue + cu_offset)); |
19e6b90e L |
1356 | break; |
1357 | ||
1358 | case DW_FORM_data4: | |
1359 | case DW_FORM_addr: | |
932fd279 | 1360 | case DW_FORM_sec_offset: |
19e6b90e | 1361 | if (!do_loc) |
467c65bc | 1362 | printf (" 0x%s", dwarf_vmatoa ("x", uvalue)); |
19e6b90e L |
1363 | break; |
1364 | ||
932fd279 | 1365 | case DW_FORM_flag_present: |
19e6b90e L |
1366 | case DW_FORM_flag: |
1367 | case DW_FORM_data1: | |
1368 | case DW_FORM_data2: | |
1369 | case DW_FORM_sdata: | |
1370 | case DW_FORM_udata: | |
1371 | if (!do_loc) | |
467c65bc | 1372 | printf (" %s", dwarf_vmatoa ("d", uvalue)); |
19e6b90e L |
1373 | break; |
1374 | ||
1375 | case DW_FORM_ref8: | |
1376 | case DW_FORM_data8: | |
1377 | if (!do_loc) | |
1378 | { | |
1379 | uvalue = byte_get (data, 4); | |
467c65bc | 1380 | printf (" 0x%s", dwarf_vmatoa ("x", uvalue)); |
ec4d4525 | 1381 | printf (" 0x%lx", (unsigned long) byte_get (data + 4, 4)); |
19e6b90e L |
1382 | } |
1383 | if ((do_loc || do_debug_loc || do_debug_ranges) | |
1384 | && num_debug_info_entries == 0) | |
1385 | { | |
1386 | if (sizeof (uvalue) == 8) | |
1387 | uvalue = byte_get (data, 8); | |
1388 | else | |
467c65bc | 1389 | error (_("DW_FORM_data8 is unsupported when sizeof (dwarf_vma) != 8\n")); |
19e6b90e L |
1390 | } |
1391 | data += 8; | |
1392 | break; | |
1393 | ||
1394 | case DW_FORM_string: | |
1395 | if (!do_loc) | |
1396 | printf (" %s", data); | |
1397 | data += strlen ((char *) data) + 1; | |
1398 | break; | |
1399 | ||
1400 | case DW_FORM_block: | |
932fd279 | 1401 | case DW_FORM_exprloc: |
19e6b90e L |
1402 | uvalue = read_leb128 (data, & bytes_read, 0); |
1403 | block_start = data + bytes_read; | |
1404 | if (do_loc) | |
1405 | data = block_start + uvalue; | |
1406 | else | |
1407 | data = display_block (block_start, uvalue); | |
1408 | break; | |
1409 | ||
1410 | case DW_FORM_block1: | |
1411 | uvalue = byte_get (data, 1); | |
1412 | block_start = data + 1; | |
1413 | if (do_loc) | |
1414 | data = block_start + uvalue; | |
1415 | else | |
1416 | data = display_block (block_start, uvalue); | |
1417 | break; | |
1418 | ||
1419 | case DW_FORM_block2: | |
1420 | uvalue = byte_get (data, 2); | |
1421 | block_start = data + 2; | |
1422 | if (do_loc) | |
1423 | data = block_start + uvalue; | |
1424 | else | |
1425 | data = display_block (block_start, uvalue); | |
1426 | break; | |
1427 | ||
1428 | case DW_FORM_block4: | |
1429 | uvalue = byte_get (data, 4); | |
1430 | block_start = data + 4; | |
1431 | if (do_loc) | |
1432 | data = block_start + uvalue; | |
1433 | else | |
1434 | data = display_block (block_start, uvalue); | |
1435 | break; | |
1436 | ||
1437 | case DW_FORM_strp: | |
1438 | if (!do_loc) | |
47704ddf KT |
1439 | printf (_(" (indirect string, offset: 0x%s): %s"), |
1440 | dwarf_vmatoa ("x", uvalue), | |
1441 | fetch_indirect_string (uvalue)); | |
19e6b90e L |
1442 | break; |
1443 | ||
1444 | case DW_FORM_indirect: | |
1445 | /* Handled above. */ | |
1446 | break; | |
1447 | ||
2b6f5997 CC |
1448 | case DW_FORM_ref_sig8: |
1449 | if (!do_loc) | |
1450 | { | |
1451 | int i; | |
1452 | printf (" signature: "); | |
1453 | for (i = 0; i < 8; i++) | |
1454 | { | |
1455 | printf ("%02x", (unsigned) byte_get (data, 1)); | |
1456 | data += 1; | |
1457 | } | |
1458 | } | |
1459 | else | |
1460 | data += 8; | |
1461 | break; | |
1462 | ||
19e6b90e L |
1463 | default: |
1464 | warn (_("Unrecognized form: %lu\n"), form); | |
1465 | break; | |
1466 | } | |
1467 | ||
19e6b90e | 1468 | if ((do_loc || do_debug_loc || do_debug_ranges) |
fd2f0033 TT |
1469 | && num_debug_info_entries == 0 |
1470 | && debug_info_p != NULL) | |
19e6b90e L |
1471 | { |
1472 | switch (attribute) | |
1473 | { | |
1474 | case DW_AT_frame_base: | |
1475 | have_frame_base = 1; | |
1476 | case DW_AT_location: | |
e2a0d921 NC |
1477 | case DW_AT_string_length: |
1478 | case DW_AT_return_addr: | |
19e6b90e L |
1479 | case DW_AT_data_member_location: |
1480 | case DW_AT_vtable_elem_location: | |
e2a0d921 NC |
1481 | case DW_AT_segment: |
1482 | case DW_AT_static_link: | |
1483 | case DW_AT_use_location: | |
629e7ca8 JJ |
1484 | case DW_AT_GNU_call_site_value: |
1485 | case DW_AT_GNU_call_site_data_value: | |
1486 | case DW_AT_GNU_call_site_target: | |
1487 | case DW_AT_GNU_call_site_target_clobbered: | |
932fd279 JJ |
1488 | if (form == DW_FORM_data4 |
1489 | || form == DW_FORM_data8 | |
1490 | || form == DW_FORM_sec_offset) | |
19e6b90e L |
1491 | { |
1492 | /* Process location list. */ | |
91d6fa6a | 1493 | unsigned int lmax = debug_info_p->max_loc_offsets; |
19e6b90e L |
1494 | unsigned int num = debug_info_p->num_loc_offsets; |
1495 | ||
91d6fa6a | 1496 | if (lmax == 0 || num >= lmax) |
19e6b90e | 1497 | { |
91d6fa6a | 1498 | lmax += 1024; |
467c65bc | 1499 | debug_info_p->loc_offsets = (dwarf_vma *) |
3f5e193b | 1500 | xcrealloc (debug_info_p->loc_offsets, |
91d6fa6a | 1501 | lmax, sizeof (*debug_info_p->loc_offsets)); |
3f5e193b NC |
1502 | debug_info_p->have_frame_base = (int *) |
1503 | xcrealloc (debug_info_p->have_frame_base, | |
91d6fa6a NC |
1504 | lmax, sizeof (*debug_info_p->have_frame_base)); |
1505 | debug_info_p->max_loc_offsets = lmax; | |
19e6b90e L |
1506 | } |
1507 | debug_info_p->loc_offsets [num] = uvalue; | |
1508 | debug_info_p->have_frame_base [num] = have_frame_base; | |
1509 | debug_info_p->num_loc_offsets++; | |
1510 | } | |
1511 | break; | |
e2a0d921 | 1512 | |
19e6b90e L |
1513 | case DW_AT_low_pc: |
1514 | if (need_base_address) | |
1515 | debug_info_p->base_address = uvalue; | |
1516 | break; | |
1517 | ||
1518 | case DW_AT_ranges: | |
932fd279 JJ |
1519 | if (form == DW_FORM_data4 |
1520 | || form == DW_FORM_data8 | |
1521 | || form == DW_FORM_sec_offset) | |
19e6b90e L |
1522 | { |
1523 | /* Process range list. */ | |
91d6fa6a | 1524 | unsigned int lmax = debug_info_p->max_range_lists; |
19e6b90e L |
1525 | unsigned int num = debug_info_p->num_range_lists; |
1526 | ||
91d6fa6a | 1527 | if (lmax == 0 || num >= lmax) |
19e6b90e | 1528 | { |
91d6fa6a | 1529 | lmax += 1024; |
467c65bc | 1530 | debug_info_p->range_lists = (dwarf_vma *) |
3f5e193b | 1531 | xcrealloc (debug_info_p->range_lists, |
91d6fa6a NC |
1532 | lmax, sizeof (*debug_info_p->range_lists)); |
1533 | debug_info_p->max_range_lists = lmax; | |
19e6b90e L |
1534 | } |
1535 | debug_info_p->range_lists [num] = uvalue; | |
1536 | debug_info_p->num_range_lists++; | |
1537 | } | |
1538 | break; | |
1539 | ||
1540 | default: | |
1541 | break; | |
1542 | } | |
1543 | } | |
1544 | ||
1545 | if (do_loc) | |
1546 | return data; | |
1547 | ||
ec4d4525 | 1548 | /* For some attributes we can display further information. */ |
19e6b90e L |
1549 | printf ("\t"); |
1550 | ||
1551 | switch (attribute) | |
1552 | { | |
1553 | case DW_AT_inline: | |
1554 | switch (uvalue) | |
1555 | { | |
1556 | case DW_INL_not_inlined: | |
1557 | printf (_("(not inlined)")); | |
1558 | break; | |
1559 | case DW_INL_inlined: | |
1560 | printf (_("(inlined)")); | |
1561 | break; | |
1562 | case DW_INL_declared_not_inlined: | |
1563 | printf (_("(declared as inline but ignored)")); | |
1564 | break; | |
1565 | case DW_INL_declared_inlined: | |
1566 | printf (_("(declared as inline and inlined)")); | |
1567 | break; | |
1568 | default: | |
47704ddf KT |
1569 | printf (_(" (Unknown inline attribute value: %s)"), |
1570 | dwarf_vmatoa ("x", uvalue)); | |
19e6b90e L |
1571 | break; |
1572 | } | |
1573 | break; | |
1574 | ||
1575 | case DW_AT_language: | |
1576 | switch (uvalue) | |
1577 | { | |
4b78141a | 1578 | /* Ordered by the numeric value of these constants. */ |
19e6b90e | 1579 | case DW_LANG_C89: printf ("(ANSI C)"); break; |
4b78141a NC |
1580 | case DW_LANG_C: printf ("(non-ANSI C)"); break; |
1581 | case DW_LANG_Ada83: printf ("(Ada)"); break; | |
19e6b90e | 1582 | case DW_LANG_C_plus_plus: printf ("(C++)"); break; |
4b78141a NC |
1583 | case DW_LANG_Cobol74: printf ("(Cobol 74)"); break; |
1584 | case DW_LANG_Cobol85: printf ("(Cobol 85)"); break; | |
19e6b90e L |
1585 | case DW_LANG_Fortran77: printf ("(FORTRAN 77)"); break; |
1586 | case DW_LANG_Fortran90: printf ("(Fortran 90)"); break; | |
19e6b90e | 1587 | case DW_LANG_Pascal83: printf ("(ANSI Pascal)"); break; |
4b78141a | 1588 | case DW_LANG_Modula2: printf ("(Modula 2)"); break; |
19e6b90e | 1589 | /* DWARF 2.1 values. */ |
4b78141a | 1590 | case DW_LANG_Java: printf ("(Java)"); break; |
19e6b90e L |
1591 | case DW_LANG_C99: printf ("(ANSI C99)"); break; |
1592 | case DW_LANG_Ada95: printf ("(ADA 95)"); break; | |
1593 | case DW_LANG_Fortran95: printf ("(Fortran 95)"); break; | |
4b78141a NC |
1594 | /* DWARF 3 values. */ |
1595 | case DW_LANG_PLI: printf ("(PLI)"); break; | |
1596 | case DW_LANG_ObjC: printf ("(Objective C)"); break; | |
1597 | case DW_LANG_ObjC_plus_plus: printf ("(Objective C++)"); break; | |
1598 | case DW_LANG_UPC: printf ("(Unified Parallel C)"); break; | |
1599 | case DW_LANG_D: printf ("(D)"); break; | |
2b6f5997 CC |
1600 | /* DWARF 4 values. */ |
1601 | case DW_LANG_Python: printf ("(Python)"); break; | |
19e6b90e L |
1602 | /* MIPS extension. */ |
1603 | case DW_LANG_Mips_Assembler: printf ("(MIPS assembler)"); break; | |
1604 | /* UPC extension. */ | |
1605 | case DW_LANG_Upc: printf ("(Unified Parallel C)"); break; | |
1606 | default: | |
4b78141a | 1607 | if (uvalue >= DW_LANG_lo_user && uvalue <= DW_LANG_hi_user) |
467c65bc NC |
1608 | printf ("(implementation defined: %s)", |
1609 | dwarf_vmatoa ("x", uvalue)); | |
4b78141a | 1610 | else |
467c65bc | 1611 | printf ("(Unknown: %s)", dwarf_vmatoa ("x", uvalue)); |
19e6b90e L |
1612 | break; |
1613 | } | |
1614 | break; | |
1615 | ||
1616 | case DW_AT_encoding: | |
1617 | switch (uvalue) | |
1618 | { | |
1619 | case DW_ATE_void: printf ("(void)"); break; | |
1620 | case DW_ATE_address: printf ("(machine address)"); break; | |
1621 | case DW_ATE_boolean: printf ("(boolean)"); break; | |
1622 | case DW_ATE_complex_float: printf ("(complex float)"); break; | |
1623 | case DW_ATE_float: printf ("(float)"); break; | |
1624 | case DW_ATE_signed: printf ("(signed)"); break; | |
1625 | case DW_ATE_signed_char: printf ("(signed char)"); break; | |
1626 | case DW_ATE_unsigned: printf ("(unsigned)"); break; | |
1627 | case DW_ATE_unsigned_char: printf ("(unsigned char)"); break; | |
e2a0d921 | 1628 | /* DWARF 2.1 values: */ |
19e6b90e L |
1629 | case DW_ATE_imaginary_float: printf ("(imaginary float)"); break; |
1630 | case DW_ATE_decimal_float: printf ("(decimal float)"); break; | |
e2a0d921 NC |
1631 | /* DWARF 3 values: */ |
1632 | case DW_ATE_packed_decimal: printf ("(packed_decimal)"); break; | |
1633 | case DW_ATE_numeric_string: printf ("(numeric_string)"); break; | |
1634 | case DW_ATE_edited: printf ("(edited)"); break; | |
1635 | case DW_ATE_signed_fixed: printf ("(signed_fixed)"); break; | |
1636 | case DW_ATE_unsigned_fixed: printf ("(unsigned_fixed)"); break; | |
1637 | /* HP extensions: */ | |
1638 | case DW_ATE_HP_float80: printf ("(HP_float80)"); break; | |
1639 | case DW_ATE_HP_complex_float80: printf ("(HP_complex_float80)"); break; | |
1640 | case DW_ATE_HP_float128: printf ("(HP_float128)"); break; | |
1641 | case DW_ATE_HP_complex_float128:printf ("(HP_complex_float128)"); break; | |
1642 | case DW_ATE_HP_floathpintel: printf ("(HP_floathpintel)"); break; | |
1643 | case DW_ATE_HP_imaginary_float80: printf ("(HP_imaginary_float80)"); break; | |
1644 | case DW_ATE_HP_imaginary_float128: printf ("(HP_imaginary_float128)"); break; | |
1645 | ||
19e6b90e L |
1646 | default: |
1647 | if (uvalue >= DW_ATE_lo_user | |
1648 | && uvalue <= DW_ATE_hi_user) | |
1649 | printf ("(user defined type)"); | |
1650 | else | |
1651 | printf ("(unknown type)"); | |
1652 | break; | |
1653 | } | |
1654 | break; | |
1655 | ||
1656 | case DW_AT_accessibility: | |
1657 | switch (uvalue) | |
1658 | { | |
1659 | case DW_ACCESS_public: printf ("(public)"); break; | |
1660 | case DW_ACCESS_protected: printf ("(protected)"); break; | |
1661 | case DW_ACCESS_private: printf ("(private)"); break; | |
1662 | default: | |
1663 | printf ("(unknown accessibility)"); | |
1664 | break; | |
1665 | } | |
1666 | break; | |
1667 | ||
1668 | case DW_AT_visibility: | |
1669 | switch (uvalue) | |
1670 | { | |
1671 | case DW_VIS_local: printf ("(local)"); break; | |
1672 | case DW_VIS_exported: printf ("(exported)"); break; | |
1673 | case DW_VIS_qualified: printf ("(qualified)"); break; | |
1674 | default: printf ("(unknown visibility)"); break; | |
1675 | } | |
1676 | break; | |
1677 | ||
1678 | case DW_AT_virtuality: | |
1679 | switch (uvalue) | |
1680 | { | |
1681 | case DW_VIRTUALITY_none: printf ("(none)"); break; | |
1682 | case DW_VIRTUALITY_virtual: printf ("(virtual)"); break; | |
1683 | case DW_VIRTUALITY_pure_virtual:printf ("(pure_virtual)"); break; | |
1684 | default: printf ("(unknown virtuality)"); break; | |
1685 | } | |
1686 | break; | |
1687 | ||
1688 | case DW_AT_identifier_case: | |
1689 | switch (uvalue) | |
1690 | { | |
1691 | case DW_ID_case_sensitive: printf ("(case_sensitive)"); break; | |
1692 | case DW_ID_up_case: printf ("(up_case)"); break; | |
1693 | case DW_ID_down_case: printf ("(down_case)"); break; | |
1694 | case DW_ID_case_insensitive: printf ("(case_insensitive)"); break; | |
1695 | default: printf ("(unknown case)"); break; | |
1696 | } | |
1697 | break; | |
1698 | ||
1699 | case DW_AT_calling_convention: | |
1700 | switch (uvalue) | |
1701 | { | |
1702 | case DW_CC_normal: printf ("(normal)"); break; | |
1703 | case DW_CC_program: printf ("(program)"); break; | |
1704 | case DW_CC_nocall: printf ("(nocall)"); break; | |
1705 | default: | |
1706 | if (uvalue >= DW_CC_lo_user | |
1707 | && uvalue <= DW_CC_hi_user) | |
1708 | printf ("(user defined)"); | |
1709 | else | |
1710 | printf ("(unknown convention)"); | |
1711 | } | |
1712 | break; | |
1713 | ||
1714 | case DW_AT_ordering: | |
1715 | switch (uvalue) | |
1716 | { | |
1717 | case -1: printf ("(undefined)"); break; | |
1718 | case 0: printf ("(row major)"); break; | |
1719 | case 1: printf ("(column major)"); break; | |
1720 | } | |
1721 | break; | |
1722 | ||
1723 | case DW_AT_frame_base: | |
1724 | have_frame_base = 1; | |
1725 | case DW_AT_location: | |
e2a0d921 NC |
1726 | case DW_AT_string_length: |
1727 | case DW_AT_return_addr: | |
19e6b90e L |
1728 | case DW_AT_data_member_location: |
1729 | case DW_AT_vtable_elem_location: | |
e2a0d921 NC |
1730 | case DW_AT_segment: |
1731 | case DW_AT_static_link: | |
1732 | case DW_AT_use_location: | |
629e7ca8 JJ |
1733 | case DW_AT_GNU_call_site_value: |
1734 | case DW_AT_GNU_call_site_data_value: | |
1735 | case DW_AT_GNU_call_site_target: | |
1736 | case DW_AT_GNU_call_site_target_clobbered: | |
932fd279 JJ |
1737 | if (form == DW_FORM_data4 |
1738 | || form == DW_FORM_data8 | |
1739 | || form == DW_FORM_sec_offset) | |
e2a0d921 NC |
1740 | printf (_("(location list)")); |
1741 | /* Fall through. */ | |
19e6b90e L |
1742 | case DW_AT_allocated: |
1743 | case DW_AT_associated: | |
1744 | case DW_AT_data_location: | |
1745 | case DW_AT_stride: | |
1746 | case DW_AT_upper_bound: | |
cecf136e | 1747 | case DW_AT_lower_bound: |
19e6b90e L |
1748 | if (block_start) |
1749 | { | |
1750 | int need_frame_base; | |
1751 | ||
1752 | printf ("("); | |
1753 | need_frame_base = decode_location_expression (block_start, | |
1754 | pointer_size, | |
b7807392 JJ |
1755 | offset_size, |
1756 | dwarf_version, | |
19e6b90e | 1757 | uvalue, |
f1c4cc75 | 1758 | cu_offset, section); |
19e6b90e L |
1759 | printf (")"); |
1760 | if (need_frame_base && !have_frame_base) | |
1761 | printf (_(" [without DW_AT_frame_base]")); | |
1762 | } | |
19e6b90e L |
1763 | break; |
1764 | ||
ec4d4525 NC |
1765 | case DW_AT_import: |
1766 | { | |
2b6f5997 CC |
1767 | if (form == DW_FORM_ref_sig8) |
1768 | break; | |
1769 | ||
ec4d4525 NC |
1770 | if (form == DW_FORM_ref1 |
1771 | || form == DW_FORM_ref2 | |
1772 | || form == DW_FORM_ref4) | |
1773 | uvalue += cu_offset; | |
1774 | ||
6e3d6dc1 | 1775 | if (uvalue >= section->size) |
47704ddf KT |
1776 | warn (_("Offset %s used as value for DW_AT_import attribute of DIE at offset %lx is too big.\n"), |
1777 | dwarf_vmatoa ("x", uvalue), | |
1778 | (unsigned long) (orig_data - section->start)); | |
6e3d6dc1 NC |
1779 | else |
1780 | { | |
1781 | unsigned long abbrev_number; | |
1782 | abbrev_entry * entry; | |
1783 | ||
1784 | abbrev_number = read_leb128 (section->start + uvalue, NULL, 0); | |
cecf136e | 1785 | |
6e3d6dc1 NC |
1786 | printf ("[Abbrev Number: %ld", abbrev_number); |
1787 | for (entry = first_abbrev; entry != NULL; entry = entry->next) | |
1788 | if (entry->entry == abbrev_number) | |
1789 | break; | |
1790 | if (entry != NULL) | |
1791 | printf (" (%s)", get_TAG_name (entry->tag)); | |
1792 | printf ("]"); | |
1793 | } | |
ec4d4525 NC |
1794 | } |
1795 | break; | |
1796 | ||
19e6b90e L |
1797 | default: |
1798 | break; | |
1799 | } | |
1800 | ||
1801 | return data; | |
1802 | } | |
1803 | ||
1804 | static char * | |
1805 | get_AT_name (unsigned long attribute) | |
1806 | { | |
1807 | switch (attribute) | |
1808 | { | |
1809 | case DW_AT_sibling: return "DW_AT_sibling"; | |
1810 | case DW_AT_location: return "DW_AT_location"; | |
1811 | case DW_AT_name: return "DW_AT_name"; | |
1812 | case DW_AT_ordering: return "DW_AT_ordering"; | |
1813 | case DW_AT_subscr_data: return "DW_AT_subscr_data"; | |
1814 | case DW_AT_byte_size: return "DW_AT_byte_size"; | |
1815 | case DW_AT_bit_offset: return "DW_AT_bit_offset"; | |
1816 | case DW_AT_bit_size: return "DW_AT_bit_size"; | |
1817 | case DW_AT_element_list: return "DW_AT_element_list"; | |
1818 | case DW_AT_stmt_list: return "DW_AT_stmt_list"; | |
1819 | case DW_AT_low_pc: return "DW_AT_low_pc"; | |
1820 | case DW_AT_high_pc: return "DW_AT_high_pc"; | |
1821 | case DW_AT_language: return "DW_AT_language"; | |
1822 | case DW_AT_member: return "DW_AT_member"; | |
1823 | case DW_AT_discr: return "DW_AT_discr"; | |
1824 | case DW_AT_discr_value: return "DW_AT_discr_value"; | |
1825 | case DW_AT_visibility: return "DW_AT_visibility"; | |
1826 | case DW_AT_import: return "DW_AT_import"; | |
1827 | case DW_AT_string_length: return "DW_AT_string_length"; | |
1828 | case DW_AT_common_reference: return "DW_AT_common_reference"; | |
1829 | case DW_AT_comp_dir: return "DW_AT_comp_dir"; | |
1830 | case DW_AT_const_value: return "DW_AT_const_value"; | |
1831 | case DW_AT_containing_type: return "DW_AT_containing_type"; | |
1832 | case DW_AT_default_value: return "DW_AT_default_value"; | |
1833 | case DW_AT_inline: return "DW_AT_inline"; | |
1834 | case DW_AT_is_optional: return "DW_AT_is_optional"; | |
1835 | case DW_AT_lower_bound: return "DW_AT_lower_bound"; | |
1836 | case DW_AT_producer: return "DW_AT_producer"; | |
1837 | case DW_AT_prototyped: return "DW_AT_prototyped"; | |
1838 | case DW_AT_return_addr: return "DW_AT_return_addr"; | |
1839 | case DW_AT_start_scope: return "DW_AT_start_scope"; | |
1840 | case DW_AT_stride_size: return "DW_AT_stride_size"; | |
1841 | case DW_AT_upper_bound: return "DW_AT_upper_bound"; | |
1842 | case DW_AT_abstract_origin: return "DW_AT_abstract_origin"; | |
1843 | case DW_AT_accessibility: return "DW_AT_accessibility"; | |
1844 | case DW_AT_address_class: return "DW_AT_address_class"; | |
1845 | case DW_AT_artificial: return "DW_AT_artificial"; | |
1846 | case DW_AT_base_types: return "DW_AT_base_types"; | |
1847 | case DW_AT_calling_convention: return "DW_AT_calling_convention"; | |
1848 | case DW_AT_count: return "DW_AT_count"; | |
1849 | case DW_AT_data_member_location: return "DW_AT_data_member_location"; | |
1850 | case DW_AT_decl_column: return "DW_AT_decl_column"; | |
1851 | case DW_AT_decl_file: return "DW_AT_decl_file"; | |
1852 | case DW_AT_decl_line: return "DW_AT_decl_line"; | |
1853 | case DW_AT_declaration: return "DW_AT_declaration"; | |
1854 | case DW_AT_discr_list: return "DW_AT_discr_list"; | |
1855 | case DW_AT_encoding: return "DW_AT_encoding"; | |
1856 | case DW_AT_external: return "DW_AT_external"; | |
1857 | case DW_AT_frame_base: return "DW_AT_frame_base"; | |
1858 | case DW_AT_friend: return "DW_AT_friend"; | |
1859 | case DW_AT_identifier_case: return "DW_AT_identifier_case"; | |
1860 | case DW_AT_macro_info: return "DW_AT_macro_info"; | |
1861 | case DW_AT_namelist_items: return "DW_AT_namelist_items"; | |
1862 | case DW_AT_priority: return "DW_AT_priority"; | |
1863 | case DW_AT_segment: return "DW_AT_segment"; | |
1864 | case DW_AT_specification: return "DW_AT_specification"; | |
1865 | case DW_AT_static_link: return "DW_AT_static_link"; | |
1866 | case DW_AT_type: return "DW_AT_type"; | |
1867 | case DW_AT_use_location: return "DW_AT_use_location"; | |
1868 | case DW_AT_variable_parameter: return "DW_AT_variable_parameter"; | |
1869 | case DW_AT_virtuality: return "DW_AT_virtuality"; | |
1870 | case DW_AT_vtable_elem_location: return "DW_AT_vtable_elem_location"; | |
1871 | /* DWARF 2.1 values. */ | |
1872 | case DW_AT_allocated: return "DW_AT_allocated"; | |
1873 | case DW_AT_associated: return "DW_AT_associated"; | |
1874 | case DW_AT_data_location: return "DW_AT_data_location"; | |
1875 | case DW_AT_stride: return "DW_AT_stride"; | |
1876 | case DW_AT_entry_pc: return "DW_AT_entry_pc"; | |
1877 | case DW_AT_use_UTF8: return "DW_AT_use_UTF8"; | |
1878 | case DW_AT_extension: return "DW_AT_extension"; | |
1879 | case DW_AT_ranges: return "DW_AT_ranges"; | |
1880 | case DW_AT_trampoline: return "DW_AT_trampoline"; | |
1881 | case DW_AT_call_column: return "DW_AT_call_column"; | |
1882 | case DW_AT_call_file: return "DW_AT_call_file"; | |
1883 | case DW_AT_call_line: return "DW_AT_call_line"; | |
e2a0d921 NC |
1884 | case DW_AT_description: return "DW_AT_description"; |
1885 | case DW_AT_binary_scale: return "DW_AT_binary_scale"; | |
1886 | case DW_AT_decimal_scale: return "DW_AT_decimal_scale"; | |
1887 | case DW_AT_small: return "DW_AT_small"; | |
1888 | case DW_AT_decimal_sign: return "DW_AT_decimal_sign"; | |
1889 | case DW_AT_digit_count: return "DW_AT_digit_count"; | |
1890 | case DW_AT_picture_string: return "DW_AT_picture_string"; | |
1891 | case DW_AT_mutable: return "DW_AT_mutable"; | |
1892 | case DW_AT_threads_scaled: return "DW_AT_threads_scaled"; | |
1893 | case DW_AT_explicit: return "DW_AT_explicit"; | |
1894 | case DW_AT_object_pointer: return "DW_AT_object_pointer"; | |
1895 | case DW_AT_endianity: return "DW_AT_endianity"; | |
1896 | case DW_AT_elemental: return "DW_AT_elemental"; | |
1897 | case DW_AT_pure: return "DW_AT_pure"; | |
1898 | case DW_AT_recursive: return "DW_AT_recursive"; | |
2b6f5997 CC |
1899 | /* DWARF 4 values. */ |
1900 | case DW_AT_signature: return "DW_AT_signature"; | |
1901 | case DW_AT_main_subprogram: return "DW_AT_main_subprogram"; | |
1902 | case DW_AT_data_bit_offset: return "DW_AT_data_bit_offset"; | |
1903 | case DW_AT_const_expr: return "DW_AT_const_expr"; | |
1904 | case DW_AT_enum_class: return "DW_AT_enum_class"; | |
1905 | case DW_AT_linkage_name: return "DW_AT_linkage_name"; | |
e2a0d921 NC |
1906 | |
1907 | /* HP and SGI/MIPS extensions. */ | |
1908 | case DW_AT_MIPS_loop_begin: return "DW_AT_MIPS_loop_begin"; | |
1909 | case DW_AT_MIPS_tail_loop_begin: return "DW_AT_MIPS_tail_loop_begin"; | |
1910 | case DW_AT_MIPS_epilog_begin: return "DW_AT_MIPS_epilog_begin"; | |
1911 | case DW_AT_MIPS_loop_unroll_factor: return "DW_AT_MIPS_loop_unroll_factor"; | |
1912 | case DW_AT_MIPS_software_pipeline_depth: return "DW_AT_MIPS_software_pipeline_depth"; | |
1913 | case DW_AT_MIPS_linkage_name: return "DW_AT_MIPS_linkage_name"; | |
1914 | case DW_AT_MIPS_stride: return "DW_AT_MIPS_stride"; | |
1915 | case DW_AT_MIPS_abstract_name: return "DW_AT_MIPS_abstract_name"; | |
1916 | case DW_AT_MIPS_clone_origin: return "DW_AT_MIPS_clone_origin"; | |
1917 | case DW_AT_MIPS_has_inlines: return "DW_AT_MIPS_has_inlines"; | |
1918 | ||
1919 | /* HP Extensions. */ | |
cecf136e | 1920 | case DW_AT_HP_block_index: return "DW_AT_HP_block_index"; |
e2a0d921 NC |
1921 | case DW_AT_HP_actuals_stmt_list: return "DW_AT_HP_actuals_stmt_list"; |
1922 | case DW_AT_HP_proc_per_section: return "DW_AT_HP_proc_per_section"; | |
1923 | case DW_AT_HP_raw_data_ptr: return "DW_AT_HP_raw_data_ptr"; | |
1924 | case DW_AT_HP_pass_by_reference: return "DW_AT_HP_pass_by_reference"; | |
1925 | case DW_AT_HP_opt_level: return "DW_AT_HP_opt_level"; | |
1926 | case DW_AT_HP_prof_version_id: return "DW_AT_HP_prof_version_id"; | |
1927 | case DW_AT_HP_opt_flags: return "DW_AT_HP_opt_flags"; | |
1928 | case DW_AT_HP_cold_region_low_pc: return "DW_AT_HP_cold_region_low_pc"; | |
1929 | case DW_AT_HP_cold_region_high_pc: return "DW_AT_HP_cold_region_high_pc"; | |
1930 | case DW_AT_HP_all_variables_modifiable: return "DW_AT_HP_all_variables_modifiable"; | |
1931 | case DW_AT_HP_linkage_name: return "DW_AT_HP_linkage_name"; | |
1932 | case DW_AT_HP_prof_flags: return "DW_AT_HP_prof_flags"; | |
1933 | ||
1934 | /* One value is shared by the MIPS and HP extensions: */ | |
1935 | case DW_AT_MIPS_fde: return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable"; | |
cecf136e | 1936 | |
19e6b90e | 1937 | /* GNU extensions. */ |
2b6f5997 CC |
1938 | case DW_AT_sf_names: return "DW_AT_sf_names"; |
1939 | case DW_AT_src_info: return "DW_AT_src_info"; | |
1940 | case DW_AT_mac_info: return "DW_AT_mac_info"; | |
1941 | case DW_AT_src_coords: return "DW_AT_src_coords"; | |
1942 | case DW_AT_body_begin: return "DW_AT_body_begin"; | |
1943 | case DW_AT_body_end: return "DW_AT_body_end"; | |
1944 | case DW_AT_GNU_vector: return "DW_AT_GNU_vector"; | |
1945 | case DW_AT_GNU_guarded_by: return "DW_AT_GNU_guarded_by"; | |
1946 | case DW_AT_GNU_pt_guarded_by: return "DW_AT_GNU_pt_guarded_by"; | |
1947 | case DW_AT_GNU_guarded: return "DW_AT_GNU_guarded"; | |
1948 | case DW_AT_GNU_pt_guarded: return "DW_AT_GNU_pt_guarded"; | |
1949 | case DW_AT_GNU_locks_excluded: return "DW_AT_GNU_locks_excluded"; | |
1950 | case DW_AT_GNU_exclusive_locks_required: return "DW_AT_GNU_exclusive_locks_required"; | |
1951 | case DW_AT_GNU_shared_locks_required: return "DW_AT_GNU_shared_locks_required"; | |
1952 | case DW_AT_GNU_odr_signature: return "DW_AT_GNU_odr_signature"; | |
60a0e0e7 TG |
1953 | case DW_AT_use_GNAT_descriptive_type: return "DW_AT_use_GNAT_descriptive_type"; |
1954 | case DW_AT_GNAT_descriptive_type: return "DW_AT_GNAT_descriptive_type"; | |
629e7ca8 JJ |
1955 | case DW_AT_GNU_call_site_value: return "DW_AT_GNU_call_site_value"; |
1956 | case DW_AT_GNU_call_site_data_value: return "DW_AT_GNU_call_site_data_value"; | |
1957 | case DW_AT_GNU_call_site_target: return "DW_AT_GNU_call_site_target"; | |
1958 | case DW_AT_GNU_call_site_target_clobbered: return "DW_AT_GNU_call_site_target_clobbered"; | |
1959 | case DW_AT_GNU_tail_call: return "DW_AT_GNU_tail_call"; | |
1960 | case DW_AT_GNU_all_tail_call_sites: return "DW_AT_GNU_all_tail_call_sites"; | |
1961 | case DW_AT_GNU_all_call_sites: return "DW_AT_GNU_all_call_sites"; | |
1962 | case DW_AT_GNU_all_source_call_sites: return "DW_AT_GNU_all_source_call_sites"; | |
e2a0d921 | 1963 | |
19e6b90e L |
1964 | /* UPC extension. */ |
1965 | case DW_AT_upc_threads_scaled: return "DW_AT_upc_threads_scaled"; | |
e2a0d921 NC |
1966 | |
1967 | /* PGI (STMicroelectronics) extensions. */ | |
1968 | case DW_AT_PGI_lbase: return "DW_AT_PGI_lbase"; | |
1969 | case DW_AT_PGI_soffset: return "DW_AT_PGI_soffset"; | |
1970 | case DW_AT_PGI_lstride: return "DW_AT_PGI_lstride"; | |
1971 | ||
19e6b90e L |
1972 | default: |
1973 | { | |
1974 | static char buffer[100]; | |
1975 | ||
1976 | snprintf (buffer, sizeof (buffer), _("Unknown AT value: %lx"), | |
1977 | attribute); | |
1978 | return buffer; | |
1979 | } | |
1980 | } | |
1981 | } | |
1982 | ||
1983 | static unsigned char * | |
6e3d6dc1 NC |
1984 | read_and_display_attr (unsigned long attribute, |
1985 | unsigned long form, | |
ec4d4525 | 1986 | unsigned char * data, |
467c65bc NC |
1987 | dwarf_vma cu_offset, |
1988 | dwarf_vma pointer_size, | |
1989 | dwarf_vma offset_size, | |
6e3d6dc1 NC |
1990 | int dwarf_version, |
1991 | debug_info * debug_info_p, | |
1992 | int do_loc, | |
1993 | struct dwarf_section * section) | |
19e6b90e L |
1994 | { |
1995 | if (!do_loc) | |
750f03b7 | 1996 | printf (" %-18s:", get_AT_name (attribute)); |
19e6b90e L |
1997 | data = read_and_display_attr_value (attribute, form, data, cu_offset, |
1998 | pointer_size, offset_size, | |
1999 | dwarf_version, debug_info_p, | |
6e3d6dc1 | 2000 | do_loc, section); |
19e6b90e L |
2001 | if (!do_loc) |
2002 | printf ("\n"); | |
2003 | return data; | |
2004 | } | |
2005 | ||
2006 | ||
2007 | /* Process the contents of a .debug_info section. If do_loc is non-zero | |
2008 | then we are scanning for location lists and we do not want to display | |
2b6f5997 CC |
2009 | anything to the user. If do_types is non-zero, we are processing |
2010 | a .debug_types section instead of a .debug_info section. */ | |
19e6b90e L |
2011 | |
2012 | static int | |
6e3d6dc1 NC |
2013 | process_debug_info (struct dwarf_section *section, |
2014 | void *file, | |
6f875884 | 2015 | enum dwarf_section_display_enum abbrev_sec, |
2b6f5997 CC |
2016 | int do_loc, |
2017 | int do_types) | |
19e6b90e L |
2018 | { |
2019 | unsigned char *start = section->start; | |
2020 | unsigned char *end = start + section->size; | |
2021 | unsigned char *section_begin; | |
2022 | unsigned int unit; | |
2023 | unsigned int num_units = 0; | |
2024 | ||
2025 | if ((do_loc || do_debug_loc || do_debug_ranges) | |
2b6f5997 CC |
2026 | && num_debug_info_entries == 0 |
2027 | && ! do_types) | |
19e6b90e | 2028 | { |
767221a9 | 2029 | dwarf_vma length; |
19e6b90e L |
2030 | |
2031 | /* First scan the section to get the number of comp units. */ | |
2032 | for (section_begin = start, num_units = 0; section_begin < end; | |
2033 | num_units ++) | |
2034 | { | |
2035 | /* Read the first 4 bytes. For a 32-bit DWARF section, this | |
2036 | will be the length. For a 64-bit DWARF section, it'll be | |
2037 | the escape code 0xffffffff followed by an 8 byte length. */ | |
2038 | length = byte_get (section_begin, 4); | |
2039 | ||
2040 | if (length == 0xffffffff) | |
2041 | { | |
2042 | length = byte_get (section_begin + 4, 8); | |
2043 | section_begin += length + 12; | |
2044 | } | |
ec4d4525 NC |
2045 | else if (length >= 0xfffffff0 && length < 0xffffffff) |
2046 | { | |
767221a9 NC |
2047 | warn (_("Reserved length value (0x%s) found in section %s\n"), |
2048 | dwarf_vmatoa ("x", length), section->name); | |
ec4d4525 NC |
2049 | return 0; |
2050 | } | |
19e6b90e L |
2051 | else |
2052 | section_begin += length + 4; | |
aca88567 NC |
2053 | |
2054 | /* Negative values are illegal, they may even cause infinite | |
2055 | looping. This can happen if we can't accurately apply | |
2056 | relocations to an object file. */ | |
2057 | if ((signed long) length <= 0) | |
2058 | { | |
767221a9 NC |
2059 | warn (_("Corrupt unit length (0x%s) found in section %s\n"), |
2060 | dwarf_vmatoa ("x", length), section->name); | |
aca88567 NC |
2061 | return 0; |
2062 | } | |
19e6b90e L |
2063 | } |
2064 | ||
2065 | if (num_units == 0) | |
2066 | { | |
2067 | error (_("No comp units in %s section ?"), section->name); | |
2068 | return 0; | |
2069 | } | |
2070 | ||
2071 | /* Then allocate an array to hold the information. */ | |
3f5e193b NC |
2072 | debug_information = (debug_info *) cmalloc (num_units, |
2073 | sizeof (* debug_information)); | |
19e6b90e L |
2074 | if (debug_information == NULL) |
2075 | { | |
2076 | error (_("Not enough memory for a debug info array of %u entries"), | |
2077 | num_units); | |
2078 | return 0; | |
2079 | } | |
2080 | } | |
2081 | ||
2082 | if (!do_loc) | |
2083 | { | |
fd2f0033 TT |
2084 | if (dwarf_start_die == 0) |
2085 | printf (_("Contents of the %s section:\n\n"), section->name); | |
19e6b90e L |
2086 | |
2087 | load_debug_section (str, file); | |
2088 | } | |
2089 | ||
6f875884 TG |
2090 | load_debug_section (abbrev_sec, file); |
2091 | if (debug_displays [abbrev_sec].section.start == NULL) | |
19e6b90e L |
2092 | { |
2093 | warn (_("Unable to locate %s section!\n"), | |
6f875884 | 2094 | debug_displays [abbrev_sec].section.name); |
19e6b90e L |
2095 | return 0; |
2096 | } | |
2097 | ||
2098 | for (section_begin = start, unit = 0; start < end; unit++) | |
2099 | { | |
2100 | DWARF2_Internal_CompUnit compunit; | |
2101 | unsigned char *hdrptr; | |
19e6b90e | 2102 | unsigned char *tags; |
fd2f0033 | 2103 | int level, last_level, saved_level; |
467c65bc | 2104 | dwarf_vma cu_offset; |
19e6b90e L |
2105 | int offset_size; |
2106 | int initial_length_size; | |
1e70a64d | 2107 | unsigned char signature[8] = { 0 }; |
767221a9 | 2108 | dwarf_vma type_offset = 0; |
19e6b90e L |
2109 | |
2110 | hdrptr = start; | |
2111 | ||
2112 | compunit.cu_length = byte_get (hdrptr, 4); | |
2113 | hdrptr += 4; | |
2114 | ||
2115 | if (compunit.cu_length == 0xffffffff) | |
2116 | { | |
2117 | compunit.cu_length = byte_get (hdrptr, 8); | |
2118 | hdrptr += 8; | |
2119 | offset_size = 8; | |
2120 | initial_length_size = 12; | |
2121 | } | |
2122 | else | |
2123 | { | |
2124 | offset_size = 4; | |
2125 | initial_length_size = 4; | |
2126 | } | |
2127 | ||
2128 | compunit.cu_version = byte_get (hdrptr, 2); | |
2129 | hdrptr += 2; | |
2130 | ||
2131 | cu_offset = start - section_begin; | |
19e6b90e | 2132 | |
19e6b90e L |
2133 | compunit.cu_abbrev_offset = byte_get (hdrptr, offset_size); |
2134 | hdrptr += offset_size; | |
2135 | ||
2136 | compunit.cu_pointer_size = byte_get (hdrptr, 1); | |
2137 | hdrptr += 1; | |
2b6f5997 CC |
2138 | |
2139 | if (do_types) | |
2140 | { | |
2141 | int i; | |
2142 | ||
2143 | for (i = 0; i < 8; i++) | |
2144 | { | |
2145 | signature[i] = byte_get (hdrptr, 1); | |
2146 | hdrptr += 1; | |
2147 | } | |
2148 | ||
2149 | type_offset = byte_get (hdrptr, offset_size); | |
2150 | hdrptr += offset_size; | |
2151 | } | |
2152 | ||
19e6b90e | 2153 | if ((do_loc || do_debug_loc || do_debug_ranges) |
2b6f5997 CC |
2154 | && num_debug_info_entries == 0 |
2155 | && ! do_types) | |
19e6b90e L |
2156 | { |
2157 | debug_information [unit].cu_offset = cu_offset; | |
2158 | debug_information [unit].pointer_size | |
2159 | = compunit.cu_pointer_size; | |
b7807392 JJ |
2160 | debug_information [unit].offset_size = offset_size; |
2161 | debug_information [unit].dwarf_version = compunit.cu_version; | |
19e6b90e L |
2162 | debug_information [unit].base_address = 0; |
2163 | debug_information [unit].loc_offsets = NULL; | |
2164 | debug_information [unit].have_frame_base = NULL; | |
2165 | debug_information [unit].max_loc_offsets = 0; | |
2166 | debug_information [unit].num_loc_offsets = 0; | |
2167 | debug_information [unit].range_lists = NULL; | |
2168 | debug_information [unit].max_range_lists= 0; | |
2169 | debug_information [unit].num_range_lists = 0; | |
2170 | } | |
2171 | ||
fd2f0033 | 2172 | if (!do_loc && dwarf_start_die == 0) |
19e6b90e | 2173 | { |
47704ddf KT |
2174 | printf (_(" Compilation Unit @ offset 0x%s:\n"), |
2175 | dwarf_vmatoa ("x", cu_offset)); | |
2176 | printf (_(" Length: 0x%s (%s)\n"), | |
2177 | dwarf_vmatoa ("x", compunit.cu_length), | |
49e7b350 | 2178 | offset_size == 8 ? "64-bit" : "32-bit"); |
19e6b90e | 2179 | printf (_(" Version: %d\n"), compunit.cu_version); |
47704ddf KT |
2180 | printf (_(" Abbrev Offset: %s\n"), |
2181 | dwarf_vmatoa ("d", compunit.cu_abbrev_offset)); | |
19e6b90e | 2182 | printf (_(" Pointer Size: %d\n"), compunit.cu_pointer_size); |
2b6f5997 CC |
2183 | if (do_types) |
2184 | { | |
2185 | int i; | |
2186 | printf (_(" Signature: ")); | |
2187 | for (i = 0; i < 8; i++) | |
2188 | printf ("%02x", signature[i]); | |
2189 | printf ("\n"); | |
767221a9 NC |
2190 | printf (_(" Type Offset: 0x%s\n"), |
2191 | dwarf_vmatoa ("x", type_offset)); | |
2b6f5997 | 2192 | } |
19e6b90e L |
2193 | } |
2194 | ||
460c89ff NS |
2195 | if (cu_offset + compunit.cu_length + initial_length_size |
2196 | > section->size) | |
2197 | { | |
47704ddf KT |
2198 | warn (_("Debug info is corrupted, length of CU at %s" |
2199 | " extends beyond end of section (length = %s)\n"), | |
2200 | dwarf_vmatoa ("x", cu_offset), | |
2201 | dwarf_vmatoa ("x", compunit.cu_length)); | |
460c89ff NS |
2202 | break; |
2203 | } | |
2204 | tags = hdrptr; | |
2205 | start += compunit.cu_length + initial_length_size; | |
2206 | ||
932fd279 JJ |
2207 | if (compunit.cu_version != 2 |
2208 | && compunit.cu_version != 3 | |
2209 | && compunit.cu_version != 4) | |
19e6b90e | 2210 | { |
47704ddf KT |
2211 | warn (_("CU at offset %s contains corrupt or " |
2212 | "unsupported version number: %d.\n"), | |
2213 | dwarf_vmatoa ("x", cu_offset), compunit.cu_version); | |
19e6b90e L |
2214 | continue; |
2215 | } | |
2216 | ||
2217 | free_abbrevs (); | |
2218 | ||
bfe2612a L |
2219 | /* Process the abbrevs used by this compilation unit. DWARF |
2220 | sections under Mach-O have non-zero addresses. */ | |
6f875884 | 2221 | if (compunit.cu_abbrev_offset >= debug_displays [abbrev_sec].section.size) |
ec4d4525 NC |
2222 | warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"), |
2223 | (unsigned long) compunit.cu_abbrev_offset, | |
6f875884 | 2224 | (unsigned long) debug_displays [abbrev_sec].section.size); |
460c89ff NS |
2225 | else |
2226 | process_abbrev_section | |
6f875884 | 2227 | ((unsigned char *) debug_displays [abbrev_sec].section.start |
0ac6fba0 | 2228 | + compunit.cu_abbrev_offset, |
6f875884 TG |
2229 | (unsigned char *) debug_displays [abbrev_sec].section.start |
2230 | + debug_displays [abbrev_sec].section.size); | |
19e6b90e L |
2231 | |
2232 | level = 0; | |
fd2f0033 TT |
2233 | last_level = level; |
2234 | saved_level = -1; | |
19e6b90e L |
2235 | while (tags < start) |
2236 | { | |
2237 | unsigned int bytes_read; | |
2238 | unsigned long abbrev_number; | |
ec4d4525 | 2239 | unsigned long die_offset; |
19e6b90e L |
2240 | abbrev_entry *entry; |
2241 | abbrev_attr *attr; | |
fd2f0033 | 2242 | int do_printing = 1; |
19e6b90e | 2243 | |
ec4d4525 NC |
2244 | die_offset = tags - section_begin; |
2245 | ||
19e6b90e L |
2246 | abbrev_number = read_leb128 (tags, & bytes_read, 0); |
2247 | tags += bytes_read; | |
2248 | ||
eb7cc021 JK |
2249 | /* A null DIE marks the end of a list of siblings or it may also be |
2250 | a section padding. */ | |
19e6b90e L |
2251 | if (abbrev_number == 0) |
2252 | { | |
eb7cc021 JK |
2253 | /* Check if it can be a section padding for the last CU. */ |
2254 | if (level == 0 && start == end) | |
2255 | { | |
2256 | unsigned char *chk; | |
2257 | ||
2258 | for (chk = tags; chk < start; chk++) | |
2259 | if (*chk != 0) | |
2260 | break; | |
2261 | if (chk == start) | |
2262 | break; | |
2263 | } | |
2264 | ||
19e6b90e | 2265 | --level; |
ec4d4525 NC |
2266 | if (level < 0) |
2267 | { | |
2268 | static unsigned num_bogus_warns = 0; | |
2269 | ||
2270 | if (num_bogus_warns < 3) | |
2271 | { | |
2272 | warn (_("Bogus end-of-siblings marker detected at offset %lx in .debug_info section\n"), | |
2273 | die_offset); | |
2274 | num_bogus_warns ++; | |
2275 | if (num_bogus_warns == 3) | |
2276 | warn (_("Further warnings about bogus end-of-sibling markers suppressed\n")); | |
2277 | } | |
2278 | } | |
fd2f0033 TT |
2279 | if (dwarf_start_die != 0 && level < saved_level) |
2280 | return 1; | |
19e6b90e L |
2281 | continue; |
2282 | } | |
2283 | ||
4b78141a | 2284 | if (!do_loc) |
fd2f0033 TT |
2285 | { |
2286 | if (dwarf_start_die != 0 && die_offset < dwarf_start_die) | |
2287 | do_printing = 0; | |
2288 | else | |
2289 | { | |
2290 | if (dwarf_start_die != 0 && die_offset == dwarf_start_die) | |
2291 | saved_level = level; | |
2292 | do_printing = (dwarf_cutoff_level == -1 | |
2293 | || level < dwarf_cutoff_level); | |
2294 | if (do_printing) | |
2295 | printf (_(" <%d><%lx>: Abbrev Number: %lu"), | |
2296 | level, die_offset, abbrev_number); | |
2297 | else if (dwarf_cutoff_level == -1 | |
2298 | || last_level < dwarf_cutoff_level) | |
2299 | printf (_(" <%d><%lx>: ...\n"), level, die_offset); | |
2300 | last_level = level; | |
2301 | } | |
2302 | } | |
cecf136e | 2303 | |
19e6b90e L |
2304 | /* Scan through the abbreviation list until we reach the |
2305 | correct entry. */ | |
2306 | for (entry = first_abbrev; | |
2307 | entry && entry->entry != abbrev_number; | |
2308 | entry = entry->next) | |
2309 | continue; | |
2310 | ||
2311 | if (entry == NULL) | |
2312 | { | |
fd2f0033 | 2313 | if (!do_loc && do_printing) |
4b78141a NC |
2314 | { |
2315 | printf ("\n"); | |
2316 | fflush (stdout); | |
2317 | } | |
cc86f28f NC |
2318 | warn (_("DIE at offset %lx refers to abbreviation number %lu which does not exist\n"), |
2319 | die_offset, abbrev_number); | |
19e6b90e L |
2320 | return 0; |
2321 | } | |
2322 | ||
fd2f0033 | 2323 | if (!do_loc && do_printing) |
cc5914eb | 2324 | printf (" (%s)\n", get_TAG_name (entry->tag)); |
cecf136e | 2325 | |
19e6b90e L |
2326 | switch (entry->tag) |
2327 | { | |
2328 | default: | |
2329 | need_base_address = 0; | |
2330 | break; | |
2331 | case DW_TAG_compile_unit: | |
2332 | need_base_address = 1; | |
2333 | break; | |
2334 | case DW_TAG_entry_point: | |
19e6b90e L |
2335 | case DW_TAG_subprogram: |
2336 | need_base_address = 0; | |
2337 | /* Assuming that there is no DW_AT_frame_base. */ | |
2338 | have_frame_base = 0; | |
2339 | break; | |
2340 | } | |
2341 | ||
2342 | for (attr = entry->first_attr; attr; attr = attr->next) | |
4b78141a | 2343 | { |
fd2f0033 TT |
2344 | debug_info *arg; |
2345 | ||
2346 | if (! do_loc && do_printing) | |
4b78141a | 2347 | /* Show the offset from where the tag was extracted. */ |
fd2f0033 TT |
2348 | printf (" <%lx>", (unsigned long)(tags - section_begin)); |
2349 | ||
2350 | arg = debug_information; | |
2351 | if (debug_information) | |
2352 | arg += unit; | |
4b78141a NC |
2353 | |
2354 | tags = read_and_display_attr (attr->attribute, | |
2355 | attr->form, | |
2356 | tags, cu_offset, | |
2357 | compunit.cu_pointer_size, | |
2358 | offset_size, | |
2359 | compunit.cu_version, | |
fd2f0033 TT |
2360 | arg, |
2361 | do_loc || ! do_printing, section); | |
4b78141a | 2362 | } |
cecf136e | 2363 | |
19e6b90e L |
2364 | if (entry->children) |
2365 | ++level; | |
2366 | } | |
2367 | } | |
cecf136e | 2368 | |
19e6b90e L |
2369 | /* Set num_debug_info_entries here so that it can be used to check if |
2370 | we need to process .debug_loc and .debug_ranges sections. */ | |
2371 | if ((do_loc || do_debug_loc || do_debug_ranges) | |
2b6f5997 CC |
2372 | && num_debug_info_entries == 0 |
2373 | && ! do_types) | |
19e6b90e | 2374 | num_debug_info_entries = num_units; |
cecf136e | 2375 | |
19e6b90e | 2376 | if (!do_loc) |
467c65bc | 2377 | printf ("\n"); |
cecf136e | 2378 | |
19e6b90e L |
2379 | return 1; |
2380 | } | |
2381 | ||
2382 | /* Locate and scan the .debug_info section in the file and record the pointer | |
2383 | sizes and offsets for the compilation units in it. Usually an executable | |
2384 | will have just one pointer size, but this is not guaranteed, and so we try | |
2385 | not to make any assumptions. Returns zero upon failure, or the number of | |
2386 | compilation units upon success. */ | |
2387 | ||
2388 | static unsigned int | |
2389 | load_debug_info (void * file) | |
2390 | { | |
2391 | /* Reset the last pointer size so that we can issue correct error | |
2392 | messages if we are displaying the contents of more than one section. */ | |
2393 | last_pointer_size = 0; | |
2394 | warned_about_missing_comp_units = FALSE; | |
2395 | ||
1febe64d NC |
2396 | /* If we have already tried and failed to load the .debug_info |
2397 | section then do not bother to repear the task. */ | |
cc86f28f | 2398 | if (num_debug_info_entries == DEBUG_INFO_UNAVAILABLE) |
1febe64d NC |
2399 | return 0; |
2400 | ||
19e6b90e L |
2401 | /* If we already have the information there is nothing else to do. */ |
2402 | if (num_debug_info_entries > 0) | |
2403 | return num_debug_info_entries; | |
2404 | ||
2405 | if (load_debug_section (info, file) | |
6f875884 | 2406 | && process_debug_info (&debug_displays [info].section, file, abbrev, 1, 0)) |
19e6b90e | 2407 | return num_debug_info_entries; |
1febe64d | 2408 | |
cc86f28f | 2409 | num_debug_info_entries = DEBUG_INFO_UNAVAILABLE; |
1febe64d | 2410 | return 0; |
19e6b90e L |
2411 | } |
2412 | ||
19e6b90e | 2413 | static int |
a262ae96 NC |
2414 | display_debug_lines_raw (struct dwarf_section *section, |
2415 | unsigned char *data, | |
2416 | unsigned char *end) | |
19e6b90e L |
2417 | { |
2418 | unsigned char *start = section->start; | |
19e6b90e | 2419 | |
a262ae96 NC |
2420 | printf (_("Raw dump of debug contents of section %s:\n\n"), |
2421 | section->name); | |
19e6b90e L |
2422 | |
2423 | while (data < end) | |
2424 | { | |
91d6fa6a | 2425 | DWARF2_Internal_LineInfo linfo; |
19e6b90e L |
2426 | unsigned char *standard_opcodes; |
2427 | unsigned char *end_of_sequence; | |
2428 | unsigned char *hdrptr; | |
6523721c | 2429 | unsigned long hdroff; |
19e6b90e L |
2430 | int initial_length_size; |
2431 | int offset_size; | |
2432 | int i; | |
2433 | ||
2434 | hdrptr = data; | |
6523721c | 2435 | hdroff = hdrptr - start; |
19e6b90e L |
2436 | |
2437 | /* Check the length of the block. */ | |
91d6fa6a | 2438 | linfo.li_length = byte_get (hdrptr, 4); |
19e6b90e L |
2439 | hdrptr += 4; |
2440 | ||
91d6fa6a | 2441 | if (linfo.li_length == 0xffffffff) |
19e6b90e L |
2442 | { |
2443 | /* This section is 64-bit DWARF 3. */ | |
91d6fa6a | 2444 | linfo.li_length = byte_get (hdrptr, 8); |
19e6b90e L |
2445 | hdrptr += 8; |
2446 | offset_size = 8; | |
2447 | initial_length_size = 12; | |
2448 | } | |
2449 | else | |
2450 | { | |
2451 | offset_size = 4; | |
2452 | initial_length_size = 4; | |
2453 | } | |
2454 | ||
91d6fa6a | 2455 | if (linfo.li_length + initial_length_size > section->size) |
19e6b90e L |
2456 | { |
2457 | warn | |
cf13d699 NC |
2458 | (_("The information in section %s appears to be corrupt - the section is too small\n"), |
2459 | section->name); | |
19e6b90e L |
2460 | return 0; |
2461 | } | |
2462 | ||
2463 | /* Check its version number. */ | |
91d6fa6a | 2464 | linfo.li_version = byte_get (hdrptr, 2); |
19e6b90e | 2465 | hdrptr += 2; |
932fd279 JJ |
2466 | if (linfo.li_version != 2 |
2467 | && linfo.li_version != 3 | |
2468 | && linfo.li_version != 4) | |
19e6b90e | 2469 | { |
932fd279 | 2470 | warn (_("Only DWARF version 2, 3 and 4 line info is currently supported.\n")); |
19e6b90e L |
2471 | return 0; |
2472 | } | |
2473 | ||
91d6fa6a | 2474 | linfo.li_prologue_length = byte_get (hdrptr, offset_size); |
19e6b90e | 2475 | hdrptr += offset_size; |
91d6fa6a | 2476 | linfo.li_min_insn_length = byte_get (hdrptr, 1); |
19e6b90e | 2477 | hdrptr++; |
a233b20c JJ |
2478 | if (linfo.li_version >= 4) |
2479 | { | |
2480 | linfo.li_max_ops_per_insn = byte_get (hdrptr, 1); | |
2481 | hdrptr++; | |
2482 | if (linfo.li_max_ops_per_insn == 0) | |
2483 | { | |
2484 | warn (_("Invalid maximum operations per insn.\n")); | |
2485 | return 0; | |
2486 | } | |
2487 | } | |
2488 | else | |
2489 | linfo.li_max_ops_per_insn = 1; | |
91d6fa6a | 2490 | linfo.li_default_is_stmt = byte_get (hdrptr, 1); |
19e6b90e | 2491 | hdrptr++; |
91d6fa6a | 2492 | linfo.li_line_base = byte_get (hdrptr, 1); |
19e6b90e | 2493 | hdrptr++; |
91d6fa6a | 2494 | linfo.li_line_range = byte_get (hdrptr, 1); |
19e6b90e | 2495 | hdrptr++; |
91d6fa6a | 2496 | linfo.li_opcode_base = byte_get (hdrptr, 1); |
19e6b90e L |
2497 | hdrptr++; |
2498 | ||
2499 | /* Sign extend the line base field. */ | |
91d6fa6a NC |
2500 | linfo.li_line_base <<= 24; |
2501 | linfo.li_line_base >>= 24; | |
19e6b90e | 2502 | |
6523721c | 2503 | printf (_(" Offset: 0x%lx\n"), hdroff); |
47704ddf | 2504 | printf (_(" Length: %ld\n"), (long) linfo.li_length); |
91d6fa6a NC |
2505 | printf (_(" DWARF Version: %d\n"), linfo.li_version); |
2506 | printf (_(" Prologue Length: %d\n"), linfo.li_prologue_length); | |
2507 | printf (_(" Minimum Instruction Length: %d\n"), linfo.li_min_insn_length); | |
a233b20c JJ |
2508 | if (linfo.li_version >= 4) |
2509 | printf (_(" Maximum Ops per Instruction: %d\n"), linfo.li_max_ops_per_insn); | |
91d6fa6a NC |
2510 | printf (_(" Initial value of 'is_stmt': %d\n"), linfo.li_default_is_stmt); |
2511 | printf (_(" Line Base: %d\n"), linfo.li_line_base); | |
2512 | printf (_(" Line Range: %d\n"), linfo.li_line_range); | |
2513 | printf (_(" Opcode Base: %d\n"), linfo.li_opcode_base); | |
19e6b90e | 2514 | |
91d6fa6a | 2515 | end_of_sequence = data + linfo.li_length + initial_length_size; |
19e6b90e | 2516 | |
91d6fa6a | 2517 | reset_state_machine (linfo.li_default_is_stmt); |
19e6b90e L |
2518 | |
2519 | /* Display the contents of the Opcodes table. */ | |
2520 | standard_opcodes = hdrptr; | |
2521 | ||
2522 | printf (_("\n Opcodes:\n")); | |
2523 | ||
91d6fa6a | 2524 | for (i = 1; i < linfo.li_opcode_base; i++) |
19e6b90e L |
2525 | printf (_(" Opcode %d has %d args\n"), i, standard_opcodes[i - 1]); |
2526 | ||
2527 | /* Display the contents of the Directory table. */ | |
91d6fa6a | 2528 | data = standard_opcodes + linfo.li_opcode_base - 1; |
19e6b90e L |
2529 | |
2530 | if (*data == 0) | |
2531 | printf (_("\n The Directory Table is empty.\n")); | |
2532 | else | |
2533 | { | |
2534 | printf (_("\n The Directory Table:\n")); | |
2535 | ||
2536 | while (*data != 0) | |
2537 | { | |
cc5914eb | 2538 | printf (" %s\n", data); |
19e6b90e L |
2539 | |
2540 | data += strlen ((char *) data) + 1; | |
2541 | } | |
2542 | } | |
2543 | ||
2544 | /* Skip the NUL at the end of the table. */ | |
2545 | data++; | |
2546 | ||
2547 | /* Display the contents of the File Name table. */ | |
2548 | if (*data == 0) | |
2549 | printf (_("\n The File Name Table is empty.\n")); | |
2550 | else | |
2551 | { | |
2552 | printf (_("\n The File Name Table:\n")); | |
2553 | printf (_(" Entry\tDir\tTime\tSize\tName\n")); | |
2554 | ||
2555 | while (*data != 0) | |
2556 | { | |
2557 | unsigned char *name; | |
2558 | unsigned int bytes_read; | |
2559 | ||
cc5914eb | 2560 | printf (" %d\t", ++state_machine_regs.last_file_entry); |
19e6b90e L |
2561 | name = data; |
2562 | ||
2563 | data += strlen ((char *) data) + 1; | |
2564 | ||
467c65bc NC |
2565 | printf ("%s\t", |
2566 | dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); | |
19e6b90e | 2567 | data += bytes_read; |
467c65bc NC |
2568 | printf ("%s\t", |
2569 | dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); | |
19e6b90e | 2570 | data += bytes_read; |
467c65bc NC |
2571 | printf ("%s\t", |
2572 | dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); | |
19e6b90e | 2573 | data += bytes_read; |
cc5914eb | 2574 | printf ("%s\n", name); |
19e6b90e L |
2575 | } |
2576 | } | |
2577 | ||
2578 | /* Skip the NUL at the end of the table. */ | |
2579 | data++; | |
2580 | ||
2581 | /* Now display the statements. */ | |
2582 | printf (_("\n Line Number Statements:\n")); | |
2583 | ||
2584 | while (data < end_of_sequence) | |
2585 | { | |
2586 | unsigned char op_code; | |
467c65bc NC |
2587 | dwarf_signed_vma adv; |
2588 | dwarf_vma uladv; | |
19e6b90e L |
2589 | unsigned int bytes_read; |
2590 | ||
2591 | op_code = *data++; | |
2592 | ||
91d6fa6a | 2593 | if (op_code >= linfo.li_opcode_base) |
19e6b90e | 2594 | { |
91d6fa6a | 2595 | op_code -= linfo.li_opcode_base; |
a233b20c JJ |
2596 | uladv = (op_code / linfo.li_line_range); |
2597 | if (linfo.li_max_ops_per_insn == 1) | |
2598 | { | |
2599 | uladv *= linfo.li_min_insn_length; | |
2600 | state_machine_regs.address += uladv; | |
467c65bc NC |
2601 | printf (_(" Special opcode %d: " |
2602 | "advance Address by %s to 0x%s"), | |
2603 | op_code, dwarf_vmatoa ("u", uladv), | |
2604 | dwarf_vmatoa ("x", state_machine_regs.address)); | |
a233b20c JJ |
2605 | } |
2606 | else | |
2607 | { | |
2608 | state_machine_regs.address | |
2609 | += ((state_machine_regs.op_index + uladv) | |
2610 | / linfo.li_max_ops_per_insn) | |
2611 | * linfo.li_min_insn_length; | |
2612 | state_machine_regs.op_index | |
2613 | = (state_machine_regs.op_index + uladv) | |
2614 | % linfo.li_max_ops_per_insn; | |
467c65bc NC |
2615 | printf (_(" Special opcode %d: " |
2616 | "advance Address by %s to 0x%s[%d]"), | |
2617 | op_code, dwarf_vmatoa ("u", uladv), | |
2618 | dwarf_vmatoa ("x", state_machine_regs.address), | |
a233b20c JJ |
2619 | state_machine_regs.op_index); |
2620 | } | |
91d6fa6a | 2621 | adv = (op_code % linfo.li_line_range) + linfo.li_line_base; |
19e6b90e | 2622 | state_machine_regs.line += adv; |
467c65bc NC |
2623 | printf (_(" and Line by %s to %d\n"), |
2624 | dwarf_vmatoa ("d", adv), state_machine_regs.line); | |
19e6b90e L |
2625 | } |
2626 | else switch (op_code) | |
2627 | { | |
2628 | case DW_LNS_extended_op: | |
91d6fa6a | 2629 | data += process_extended_line_op (data, linfo.li_default_is_stmt); |
19e6b90e L |
2630 | break; |
2631 | ||
2632 | case DW_LNS_copy: | |
2633 | printf (_(" Copy\n")); | |
2634 | break; | |
2635 | ||
2636 | case DW_LNS_advance_pc: | |
2637 | uladv = read_leb128 (data, & bytes_read, 0); | |
19e6b90e | 2638 | data += bytes_read; |
a233b20c JJ |
2639 | if (linfo.li_max_ops_per_insn == 1) |
2640 | { | |
2641 | uladv *= linfo.li_min_insn_length; | |
2642 | state_machine_regs.address += uladv; | |
467c65bc NC |
2643 | printf (_(" Advance PC by %s to 0x%s\n"), |
2644 | dwarf_vmatoa ("u", uladv), | |
2645 | dwarf_vmatoa ("x", state_machine_regs.address)); | |
a233b20c JJ |
2646 | } |
2647 | else | |
2648 | { | |
2649 | state_machine_regs.address | |
2650 | += ((state_machine_regs.op_index + uladv) | |
2651 | / linfo.li_max_ops_per_insn) | |
2652 | * linfo.li_min_insn_length; | |
2653 | state_machine_regs.op_index | |
2654 | = (state_machine_regs.op_index + uladv) | |
2655 | % linfo.li_max_ops_per_insn; | |
467c65bc NC |
2656 | printf (_(" Advance PC by %s to 0x%s[%d]\n"), |
2657 | dwarf_vmatoa ("u", uladv), | |
2658 | dwarf_vmatoa ("x", state_machine_regs.address), | |
a233b20c JJ |
2659 | state_machine_regs.op_index); |
2660 | } | |
19e6b90e L |
2661 | break; |
2662 | ||
2663 | case DW_LNS_advance_line: | |
467c65bc | 2664 | adv = read_sleb128 (data, & bytes_read); |
19e6b90e L |
2665 | data += bytes_read; |
2666 | state_machine_regs.line += adv; | |
467c65bc NC |
2667 | printf (_(" Advance Line by %s to %d\n"), |
2668 | dwarf_vmatoa ("d", adv), | |
2669 | state_machine_regs.line); | |
19e6b90e L |
2670 | break; |
2671 | ||
2672 | case DW_LNS_set_file: | |
2673 | adv = read_leb128 (data, & bytes_read, 0); | |
2674 | data += bytes_read; | |
467c65bc NC |
2675 | printf (_(" Set File Name to entry %s in the File Name Table\n"), |
2676 | dwarf_vmatoa ("d", adv)); | |
19e6b90e L |
2677 | state_machine_regs.file = adv; |
2678 | break; | |
2679 | ||
2680 | case DW_LNS_set_column: | |
2681 | uladv = read_leb128 (data, & bytes_read, 0); | |
2682 | data += bytes_read; | |
467c65bc NC |
2683 | printf (_(" Set column to %s\n"), |
2684 | dwarf_vmatoa ("u", uladv)); | |
19e6b90e L |
2685 | state_machine_regs.column = uladv; |
2686 | break; | |
2687 | ||
2688 | case DW_LNS_negate_stmt: | |
2689 | adv = state_machine_regs.is_stmt; | |
2690 | adv = ! adv; | |
467c65bc | 2691 | printf (_(" Set is_stmt to %s\n"), dwarf_vmatoa ("d", adv)); |
19e6b90e L |
2692 | state_machine_regs.is_stmt = adv; |
2693 | break; | |
2694 | ||
2695 | case DW_LNS_set_basic_block: | |
2696 | printf (_(" Set basic block\n")); | |
2697 | state_machine_regs.basic_block = 1; | |
2698 | break; | |
2699 | ||
2700 | case DW_LNS_const_add_pc: | |
a233b20c JJ |
2701 | uladv = ((255 - linfo.li_opcode_base) / linfo.li_line_range); |
2702 | if (linfo.li_max_ops_per_insn) | |
2703 | { | |
2704 | uladv *= linfo.li_min_insn_length; | |
2705 | state_machine_regs.address += uladv; | |
467c65bc NC |
2706 | printf (_(" Advance PC by constant %s to 0x%s\n"), |
2707 | dwarf_vmatoa ("u", uladv), | |
2708 | dwarf_vmatoa ("x", state_machine_regs.address)); | |
a233b20c JJ |
2709 | } |
2710 | else | |
2711 | { | |
2712 | state_machine_regs.address | |
2713 | += ((state_machine_regs.op_index + uladv) | |
2714 | / linfo.li_max_ops_per_insn) | |
2715 | * linfo.li_min_insn_length; | |
2716 | state_machine_regs.op_index | |
2717 | = (state_machine_regs.op_index + uladv) | |
2718 | % linfo.li_max_ops_per_insn; | |
467c65bc NC |
2719 | printf (_(" Advance PC by constant %s to 0x%s[%d]\n"), |
2720 | dwarf_vmatoa ("u", uladv), | |
2721 | dwarf_vmatoa ("x", state_machine_regs.address), | |
a233b20c JJ |
2722 | state_machine_regs.op_index); |
2723 | } | |
19e6b90e L |
2724 | break; |
2725 | ||
2726 | case DW_LNS_fixed_advance_pc: | |
2727 | uladv = byte_get (data, 2); | |
2728 | data += 2; | |
2729 | state_machine_regs.address += uladv; | |
a233b20c | 2730 | state_machine_regs.op_index = 0; |
467c65bc NC |
2731 | printf (_(" Advance PC by fixed size amount %s to 0x%s\n"), |
2732 | dwarf_vmatoa ("u", uladv), | |
2733 | dwarf_vmatoa ("x", state_machine_regs.address)); | |
19e6b90e L |
2734 | break; |
2735 | ||
2736 | case DW_LNS_set_prologue_end: | |
2737 | printf (_(" Set prologue_end to true\n")); | |
2738 | break; | |
2739 | ||
2740 | case DW_LNS_set_epilogue_begin: | |
2741 | printf (_(" Set epilogue_begin to true\n")); | |
2742 | break; | |
2743 | ||
2744 | case DW_LNS_set_isa: | |
2745 | uladv = read_leb128 (data, & bytes_read, 0); | |
2746 | data += bytes_read; | |
467c65bc | 2747 | printf (_(" Set ISA to %s\n"), dwarf_vmatoa ("u", uladv)); |
19e6b90e L |
2748 | break; |
2749 | ||
2750 | default: | |
2751 | printf (_(" Unknown opcode %d with operands: "), op_code); | |
2752 | ||
2753 | for (i = standard_opcodes[op_code - 1]; i > 0 ; --i) | |
2754 | { | |
467c65bc NC |
2755 | printf ("0x%s%s", dwarf_vmatoa ("x", read_leb128 (data, |
2756 | &bytes_read, 0)), | |
19e6b90e L |
2757 | i == 1 ? "" : ", "); |
2758 | data += bytes_read; | |
2759 | } | |
2760 | putchar ('\n'); | |
2761 | break; | |
2762 | } | |
2763 | } | |
2764 | putchar ('\n'); | |
2765 | } | |
2766 | ||
2767 | return 1; | |
2768 | } | |
2769 | ||
a262ae96 NC |
2770 | typedef struct |
2771 | { | |
467c65bc NC |
2772 | unsigned char *name; |
2773 | unsigned int directory_index; | |
2774 | unsigned int modification_date; | |
2775 | unsigned int length; | |
a262ae96 NC |
2776 | } File_Entry; |
2777 | ||
2778 | /* Output a decoded representation of the .debug_line section. */ | |
2779 | ||
2780 | static int | |
2781 | display_debug_lines_decoded (struct dwarf_section *section, | |
2782 | unsigned char *data, | |
2783 | unsigned char *end) | |
2784 | { | |
2785 | printf (_("Decoded dump of debug contents of section %s:\n\n"), | |
2786 | section->name); | |
2787 | ||
2788 | while (data < end) | |
2789 | { | |
2790 | /* This loop amounts to one iteration per compilation unit. */ | |
91d6fa6a | 2791 | DWARF2_Internal_LineInfo linfo; |
a262ae96 NC |
2792 | unsigned char *standard_opcodes; |
2793 | unsigned char *end_of_sequence; | |
2794 | unsigned char *hdrptr; | |
2795 | int initial_length_size; | |
2796 | int offset_size; | |
2797 | int i; | |
2798 | File_Entry *file_table = NULL; | |
2799 | unsigned char **directory_table = NULL; | |
a262ae96 NC |
2800 | |
2801 | hdrptr = data; | |
2802 | ||
2803 | /* Extract information from the Line Number Program Header. | |
2804 | (section 6.2.4 in the Dwarf3 doc). */ | |
2805 | ||
2806 | /* Get the length of this CU's line number information block. */ | |
91d6fa6a | 2807 | linfo.li_length = byte_get (hdrptr, 4); |
a262ae96 NC |
2808 | hdrptr += 4; |
2809 | ||
91d6fa6a | 2810 | if (linfo.li_length == 0xffffffff) |
a262ae96 NC |
2811 | { |
2812 | /* This section is 64-bit DWARF 3. */ | |
91d6fa6a | 2813 | linfo.li_length = byte_get (hdrptr, 8); |
a262ae96 NC |
2814 | hdrptr += 8; |
2815 | offset_size = 8; | |
2816 | initial_length_size = 12; | |
2817 | } | |
2818 | else | |
2819 | { | |
2820 | offset_size = 4; | |
2821 | initial_length_size = 4; | |
2822 | } | |
2823 | ||
91d6fa6a | 2824 | if (linfo.li_length + initial_length_size > section->size) |
a262ae96 NC |
2825 | { |
2826 | warn (_("The line info appears to be corrupt - " | |
2827 | "the section is too small\n")); | |
2828 | return 0; | |
2829 | } | |
2830 | ||
2831 | /* Get this CU's Line Number Block version number. */ | |
91d6fa6a | 2832 | linfo.li_version = byte_get (hdrptr, 2); |
a262ae96 | 2833 | hdrptr += 2; |
932fd279 JJ |
2834 | if (linfo.li_version != 2 |
2835 | && linfo.li_version != 3 | |
2836 | && linfo.li_version != 4) | |
a262ae96 | 2837 | { |
932fd279 | 2838 | warn (_("Only DWARF version 2, 3 and 4 line info is currently " |
a262ae96 NC |
2839 | "supported.\n")); |
2840 | return 0; | |
2841 | } | |
2842 | ||
91d6fa6a | 2843 | linfo.li_prologue_length = byte_get (hdrptr, offset_size); |
a262ae96 | 2844 | hdrptr += offset_size; |
91d6fa6a | 2845 | linfo.li_min_insn_length = byte_get (hdrptr, 1); |
a262ae96 | 2846 | hdrptr++; |
a233b20c JJ |
2847 | if (linfo.li_version >= 4) |
2848 | { | |
2849 | linfo.li_max_ops_per_insn = byte_get (hdrptr, 1); | |
2850 | hdrptr++; | |
2851 | if (linfo.li_max_ops_per_insn == 0) | |
2852 | { | |
2853 | warn (_("Invalid maximum operations per insn.\n")); | |
2854 | return 0; | |
2855 | } | |
2856 | } | |
2857 | else | |
2858 | linfo.li_max_ops_per_insn = 1; | |
91d6fa6a | 2859 | linfo.li_default_is_stmt = byte_get (hdrptr, 1); |
a262ae96 | 2860 | hdrptr++; |
91d6fa6a | 2861 | linfo.li_line_base = byte_get (hdrptr, 1); |
a262ae96 | 2862 | hdrptr++; |
91d6fa6a | 2863 | linfo.li_line_range = byte_get (hdrptr, 1); |
a262ae96 | 2864 | hdrptr++; |
91d6fa6a | 2865 | linfo.li_opcode_base = byte_get (hdrptr, 1); |
a262ae96 NC |
2866 | hdrptr++; |
2867 | ||
2868 | /* Sign extend the line base field. */ | |
91d6fa6a NC |
2869 | linfo.li_line_base <<= 24; |
2870 | linfo.li_line_base >>= 24; | |
a262ae96 NC |
2871 | |
2872 | /* Find the end of this CU's Line Number Information Block. */ | |
91d6fa6a | 2873 | end_of_sequence = data + linfo.li_length + initial_length_size; |
a262ae96 | 2874 | |
91d6fa6a | 2875 | reset_state_machine (linfo.li_default_is_stmt); |
a262ae96 NC |
2876 | |
2877 | /* Save a pointer to the contents of the Opcodes table. */ | |
2878 | standard_opcodes = hdrptr; | |
2879 | ||
2880 | /* Traverse the Directory table just to count entries. */ | |
91d6fa6a | 2881 | data = standard_opcodes + linfo.li_opcode_base - 1; |
a262ae96 NC |
2882 | if (*data != 0) |
2883 | { | |
2884 | unsigned int n_directories = 0; | |
2885 | unsigned char *ptr_directory_table = data; | |
a262ae96 NC |
2886 | |
2887 | while (*data != 0) | |
2888 | { | |
2889 | data += strlen ((char *) data) + 1; | |
2890 | n_directories++; | |
2891 | } | |
2892 | ||
2893 | /* Go through the directory table again to save the directories. */ | |
3f5e193b NC |
2894 | directory_table = (unsigned char **) |
2895 | xmalloc (n_directories * sizeof (unsigned char *)); | |
a262ae96 NC |
2896 | |
2897 | i = 0; | |
2898 | while (*ptr_directory_table != 0) | |
2899 | { | |
2900 | directory_table[i] = ptr_directory_table; | |
2901 | ptr_directory_table += strlen ((char *) ptr_directory_table) + 1; | |
2902 | i++; | |
2903 | } | |
2904 | } | |
2905 | /* Skip the NUL at the end of the table. */ | |
2906 | data++; | |
2907 | ||
2908 | /* Traverse the File Name table just to count the entries. */ | |
2909 | if (*data != 0) | |
2910 | { | |
2911 | unsigned int n_files = 0; | |
2912 | unsigned char *ptr_file_name_table = data; | |
a262ae96 NC |
2913 | |
2914 | while (*data != 0) | |
2915 | { | |
2916 | unsigned int bytes_read; | |
2917 | ||
2918 | /* Skip Name, directory index, last modification time and length | |
2919 | of file. */ | |
2920 | data += strlen ((char *) data) + 1; | |
2921 | read_leb128 (data, & bytes_read, 0); | |
2922 | data += bytes_read; | |
2923 | read_leb128 (data, & bytes_read, 0); | |
2924 | data += bytes_read; | |
2925 | read_leb128 (data, & bytes_read, 0); | |
2926 | data += bytes_read; | |
2927 | ||
2928 | n_files++; | |
2929 | } | |
2930 | ||
2931 | /* Go through the file table again to save the strings. */ | |
3f5e193b | 2932 | file_table = (File_Entry *) xmalloc (n_files * sizeof (File_Entry)); |
a262ae96 NC |
2933 | |
2934 | i = 0; | |
2935 | while (*ptr_file_name_table != 0) | |
2936 | { | |
2937 | unsigned int bytes_read; | |
2938 | ||
2939 | file_table[i].name = ptr_file_name_table; | |
2940 | ptr_file_name_table += strlen ((char *) ptr_file_name_table) + 1; | |
2941 | ||
2942 | /* We are not interested in directory, time or size. */ | |
2943 | file_table[i].directory_index = read_leb128 (ptr_file_name_table, | |
2944 | & bytes_read, 0); | |
2945 | ptr_file_name_table += bytes_read; | |
2946 | file_table[i].modification_date = read_leb128 (ptr_file_name_table, | |
2947 | & bytes_read, 0); | |
2948 | ptr_file_name_table += bytes_read; | |
2949 | file_table[i].length = read_leb128 (ptr_file_name_table, & bytes_read, 0); | |
2950 | ptr_file_name_table += bytes_read; | |
2951 | i++; | |
2952 | } | |
2953 | i = 0; | |
2954 | ||
2955 | /* Print the Compilation Unit's name and a header. */ | |
2956 | if (directory_table == NULL) | |
2957 | { | |
2958 | printf (_("CU: %s:\n"), file_table[0].name); | |
2959 | printf (_("File name Line number Starting address\n")); | |
2960 | } | |
2961 | else | |
2962 | { | |
2963 | if (do_wide || strlen ((char *) directory_table[0]) < 76) | |
cc5914eb AM |
2964 | printf (_("CU: %s/%s:\n"), directory_table[0], |
2965 | file_table[0].name); | |
a262ae96 | 2966 | else |
cc5914eb AM |
2967 | printf ("%s:\n", file_table[0].name); |
2968 | ||
a262ae96 NC |
2969 | printf (_("File name Line number Starting address\n")); |
2970 | } | |
2971 | } | |
2972 | ||
2973 | /* Skip the NUL at the end of the table. */ | |
2974 | data++; | |
2975 | ||
2976 | /* This loop iterates through the Dwarf Line Number Program. */ | |
2977 | while (data < end_of_sequence) | |
2978 | { | |
2979 | unsigned char op_code; | |
2980 | int adv; | |
2981 | unsigned long int uladv; | |
2982 | unsigned int bytes_read; | |
2983 | int is_special_opcode = 0; | |
2984 | ||
2985 | op_code = *data++; | |
a262ae96 | 2986 | |
91d6fa6a | 2987 | if (op_code >= linfo.li_opcode_base) |
a262ae96 | 2988 | { |
91d6fa6a | 2989 | op_code -= linfo.li_opcode_base; |
a233b20c JJ |
2990 | uladv = (op_code / linfo.li_line_range); |
2991 | if (linfo.li_max_ops_per_insn == 1) | |
2992 | { | |
2993 | uladv *= linfo.li_min_insn_length; | |
2994 | state_machine_regs.address += uladv; | |
2995 | } | |
2996 | else | |
2997 | { | |
2998 | state_machine_regs.address | |
2999 | += ((state_machine_regs.op_index + uladv) | |
3000 | / linfo.li_max_ops_per_insn) | |
3001 | * linfo.li_min_insn_length; | |
3002 | state_machine_regs.op_index | |
3003 | = (state_machine_regs.op_index + uladv) | |
3004 | % linfo.li_max_ops_per_insn; | |
3005 | } | |
a262ae96 | 3006 | |
91d6fa6a | 3007 | adv = (op_code % linfo.li_line_range) + linfo.li_line_base; |
a262ae96 NC |
3008 | state_machine_regs.line += adv; |
3009 | is_special_opcode = 1; | |
3010 | } | |
3011 | else switch (op_code) | |
3012 | { | |
3013 | case DW_LNS_extended_op: | |
3014 | { | |
3015 | unsigned int ext_op_code_len; | |
a262ae96 NC |
3016 | unsigned char ext_op_code; |
3017 | unsigned char *op_code_data = data; | |
3018 | ||
3019 | ext_op_code_len = read_leb128 (op_code_data, &bytes_read, 0); | |
3020 | op_code_data += bytes_read; | |
3021 | ||
3022 | if (ext_op_code_len == 0) | |
3023 | { | |
3024 | warn (_("badly formed extended line op encountered!\n")); | |
3025 | break; | |
3026 | } | |
3027 | ext_op_code_len += bytes_read; | |
3028 | ext_op_code = *op_code_data++; | |
3029 | ||
3030 | switch (ext_op_code) | |
3031 | { | |
3032 | case DW_LNE_end_sequence: | |
91d6fa6a | 3033 | reset_state_machine (linfo.li_default_is_stmt); |
a262ae96 NC |
3034 | break; |
3035 | case DW_LNE_set_address: | |
3036 | state_machine_regs.address = | |
3037 | byte_get (op_code_data, ext_op_code_len - bytes_read - 1); | |
a233b20c | 3038 | state_machine_regs.op_index = 0; |
a262ae96 NC |
3039 | break; |
3040 | case DW_LNE_define_file: | |
3041 | { | |
3042 | unsigned int dir_index = 0; | |
3043 | ||
3044 | ++state_machine_regs.last_file_entry; | |
3045 | op_code_data += strlen ((char *) op_code_data) + 1; | |
3046 | dir_index = read_leb128 (op_code_data, & bytes_read, 0); | |
3047 | op_code_data += bytes_read; | |
3048 | read_leb128 (op_code_data, & bytes_read, 0); | |
3049 | op_code_data += bytes_read; | |
3050 | read_leb128 (op_code_data, & bytes_read, 0); | |
3051 | ||
cc5914eb | 3052 | printf ("%s:\n", directory_table[dir_index]); |
a262ae96 NC |
3053 | break; |
3054 | } | |
3055 | default: | |
3056 | printf (_("UNKNOWN: length %d\n"), ext_op_code_len - bytes_read); | |
3057 | break; | |
3058 | } | |
3059 | data += ext_op_code_len; | |
3060 | break; | |
3061 | } | |
3062 | case DW_LNS_copy: | |
3063 | break; | |
3064 | ||
3065 | case DW_LNS_advance_pc: | |
3066 | uladv = read_leb128 (data, & bytes_read, 0); | |
a262ae96 | 3067 | data += bytes_read; |
a233b20c JJ |
3068 | if (linfo.li_max_ops_per_insn == 1) |
3069 | { | |
3070 | uladv *= linfo.li_min_insn_length; | |
3071 | state_machine_regs.address += uladv; | |
3072 | } | |
3073 | else | |
3074 | { | |
3075 | state_machine_regs.address | |
3076 | += ((state_machine_regs.op_index + uladv) | |
3077 | / linfo.li_max_ops_per_insn) | |
3078 | * linfo.li_min_insn_length; | |
3079 | state_machine_regs.op_index | |
3080 | = (state_machine_regs.op_index + uladv) | |
3081 | % linfo.li_max_ops_per_insn; | |
3082 | } | |
a262ae96 NC |
3083 | break; |
3084 | ||
3085 | case DW_LNS_advance_line: | |
467c65bc | 3086 | adv = read_sleb128 (data, & bytes_read); |
a262ae96 NC |
3087 | data += bytes_read; |
3088 | state_machine_regs.line += adv; | |
3089 | break; | |
3090 | ||
3091 | case DW_LNS_set_file: | |
3092 | adv = read_leb128 (data, & bytes_read, 0); | |
3093 | data += bytes_read; | |
3094 | state_machine_regs.file = adv; | |
3095 | if (file_table[state_machine_regs.file - 1].directory_index == 0) | |
3096 | { | |
3097 | /* If directory index is 0, that means current directory. */ | |
cc5914eb | 3098 | printf ("\n./%s:[++]\n", |
a262ae96 NC |
3099 | file_table[state_machine_regs.file - 1].name); |
3100 | } | |
3101 | else | |
3102 | { | |
3103 | /* The directory index starts counting at 1. */ | |
cc5914eb | 3104 | printf ("\n%s/%s:\n", |
a262ae96 NC |
3105 | directory_table[file_table[state_machine_regs.file - 1].directory_index - 1], |
3106 | file_table[state_machine_regs.file - 1].name); | |
3107 | } | |
3108 | break; | |
3109 | ||
3110 | case DW_LNS_set_column: | |
3111 | uladv = read_leb128 (data, & bytes_read, 0); | |
3112 | data += bytes_read; | |
3113 | state_machine_regs.column = uladv; | |
3114 | break; | |
3115 | ||
3116 | case DW_LNS_negate_stmt: | |
3117 | adv = state_machine_regs.is_stmt; | |
3118 | adv = ! adv; | |
3119 | state_machine_regs.is_stmt = adv; | |
3120 | break; | |
3121 | ||
3122 | case DW_LNS_set_basic_block: | |
3123 | state_machine_regs.basic_block = 1; | |
3124 | break; | |
3125 | ||
3126 | case DW_LNS_const_add_pc: | |
a233b20c JJ |
3127 | uladv = ((255 - linfo.li_opcode_base) / linfo.li_line_range); |
3128 | if (linfo.li_max_ops_per_insn == 1) | |
3129 | { | |
3130 | uladv *= linfo.li_min_insn_length; | |
3131 | state_machine_regs.address += uladv; | |
3132 | } | |
3133 | else | |
3134 | { | |
3135 | state_machine_regs.address | |
3136 | += ((state_machine_regs.op_index + uladv) | |
3137 | / linfo.li_max_ops_per_insn) | |
3138 | * linfo.li_min_insn_length; | |
3139 | state_machine_regs.op_index | |
3140 | = (state_machine_regs.op_index + uladv) | |
3141 | % linfo.li_max_ops_per_insn; | |
3142 | } | |
a262ae96 NC |
3143 | break; |
3144 | ||
3145 | case DW_LNS_fixed_advance_pc: | |
3146 | uladv = byte_get (data, 2); | |
3147 | data += 2; | |
3148 | state_machine_regs.address += uladv; | |
a233b20c | 3149 | state_machine_regs.op_index = 0; |
a262ae96 NC |
3150 | break; |
3151 | ||
3152 | case DW_LNS_set_prologue_end: | |
3153 | break; | |
3154 | ||
3155 | case DW_LNS_set_epilogue_begin: | |
3156 | break; | |
3157 | ||
3158 | case DW_LNS_set_isa: | |
3159 | uladv = read_leb128 (data, & bytes_read, 0); | |
3160 | data += bytes_read; | |
3161 | printf (_(" Set ISA to %lu\n"), uladv); | |
3162 | break; | |
3163 | ||
3164 | default: | |
3165 | printf (_(" Unknown opcode %d with operands: "), op_code); | |
3166 | ||
3167 | for (i = standard_opcodes[op_code - 1]; i > 0 ; --i) | |
3168 | { | |
467c65bc NC |
3169 | printf ("0x%s%s", dwarf_vmatoa ("x", read_leb128 (data, |
3170 | &bytes_read, 0)), | |
a262ae96 NC |
3171 | i == 1 ? "" : ", "); |
3172 | data += bytes_read; | |
3173 | } | |
3174 | putchar ('\n'); | |
3175 | break; | |
3176 | } | |
3177 | ||
3178 | /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row | |
3179 | to the DWARF address/line matrix. */ | |
3180 | if ((is_special_opcode) || (op_code == DW_LNE_end_sequence) | |
3181 | || (op_code == DW_LNS_copy)) | |
3182 | { | |
3183 | const unsigned int MAX_FILENAME_LENGTH = 35; | |
3184 | char *fileName = (char *)file_table[state_machine_regs.file - 1].name; | |
3185 | char *newFileName = NULL; | |
3186 | size_t fileNameLength = strlen (fileName); | |
3187 | ||
3188 | if ((fileNameLength > MAX_FILENAME_LENGTH) && (!do_wide)) | |
3189 | { | |
3f5e193b | 3190 | newFileName = (char *) xmalloc (MAX_FILENAME_LENGTH + 1); |
a262ae96 NC |
3191 | /* Truncate file name */ |
3192 | strncpy (newFileName, | |
3193 | fileName + fileNameLength - MAX_FILENAME_LENGTH, | |
3194 | MAX_FILENAME_LENGTH + 1); | |
3195 | } | |
3196 | else | |
3197 | { | |
3f5e193b | 3198 | newFileName = (char *) xmalloc (fileNameLength + 1); |
a262ae96 NC |
3199 | strncpy (newFileName, fileName, fileNameLength + 1); |
3200 | } | |
3201 | ||
3202 | if (!do_wide || (fileNameLength <= MAX_FILENAME_LENGTH)) | |
3203 | { | |
a233b20c | 3204 | if (linfo.li_max_ops_per_insn == 1) |
467c65bc NC |
3205 | printf ("%-35s %11d %#18" DWARF_VMA_FMT "x\n", |
3206 | newFileName, state_machine_regs.line, | |
a233b20c JJ |
3207 | state_machine_regs.address); |
3208 | else | |
467c65bc NC |
3209 | printf ("%-35s %11d %#18" DWARF_VMA_FMT "x[%d]\n", |
3210 | newFileName, state_machine_regs.line, | |
a233b20c JJ |
3211 | state_machine_regs.address, |
3212 | state_machine_regs.op_index); | |
a262ae96 NC |
3213 | } |
3214 | else | |
3215 | { | |
a233b20c | 3216 | if (linfo.li_max_ops_per_insn == 1) |
467c65bc NC |
3217 | printf ("%s %11d %#18" DWARF_VMA_FMT "x\n", |
3218 | newFileName, state_machine_regs.line, | |
a233b20c JJ |
3219 | state_machine_regs.address); |
3220 | else | |
467c65bc NC |
3221 | printf ("%s %11d %#18" DWARF_VMA_FMT "x[%d]\n", |
3222 | newFileName, state_machine_regs.line, | |
a233b20c JJ |
3223 | state_machine_regs.address, |
3224 | state_machine_regs.op_index); | |
a262ae96 NC |
3225 | } |
3226 | ||
3227 | if (op_code == DW_LNE_end_sequence) | |
3228 | printf ("\n"); | |
3229 | ||
3230 | free (newFileName); | |
3231 | } | |
3232 | } | |
3233 | free (file_table); | |
3234 | file_table = NULL; | |
3235 | free (directory_table); | |
3236 | directory_table = NULL; | |
3237 | putchar ('\n'); | |
3238 | } | |
3239 | ||
3240 | return 1; | |
3241 | } | |
3242 | ||
3243 | static int | |
1c4cc746 | 3244 | display_debug_lines (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED) |
a262ae96 NC |
3245 | { |
3246 | unsigned char *data = section->start; | |
3247 | unsigned char *end = data + section->size; | |
4cb93e3b TG |
3248 | int retValRaw = 1; |
3249 | int retValDecoded = 1; | |
a262ae96 | 3250 | |
008f4c78 NC |
3251 | if (do_debug_lines == 0) |
3252 | do_debug_lines |= FLAG_DEBUG_LINES_RAW; | |
3253 | ||
4cb93e3b | 3254 | if (do_debug_lines & FLAG_DEBUG_LINES_RAW) |
a262ae96 NC |
3255 | retValRaw = display_debug_lines_raw (section, data, end); |
3256 | ||
4cb93e3b | 3257 | if (do_debug_lines & FLAG_DEBUG_LINES_DECODED) |
a262ae96 NC |
3258 | retValDecoded = display_debug_lines_decoded (section, data, end); |
3259 | ||
4cb93e3b | 3260 | if (!retValRaw || !retValDecoded) |
a262ae96 NC |
3261 | return 0; |
3262 | ||
3263 | return 1; | |
3264 | } | |
3265 | ||
6e3d6dc1 NC |
3266 | static debug_info * |
3267 | find_debug_info_for_offset (unsigned long offset) | |
3268 | { | |
3269 | unsigned int i; | |
3270 | ||
3271 | if (num_debug_info_entries == DEBUG_INFO_UNAVAILABLE) | |
3272 | return NULL; | |
3273 | ||
3274 | for (i = 0; i < num_debug_info_entries; i++) | |
3275 | if (debug_information[i].cu_offset == offset) | |
3276 | return debug_information + i; | |
3277 | ||
3278 | return NULL; | |
3279 | } | |
3280 | ||
19e6b90e L |
3281 | static int |
3282 | display_debug_pubnames (struct dwarf_section *section, | |
3283 | void *file ATTRIBUTE_UNUSED) | |
3284 | { | |
91d6fa6a | 3285 | DWARF2_Internal_PubNames names; |
19e6b90e L |
3286 | unsigned char *start = section->start; |
3287 | unsigned char *end = start + section->size; | |
3288 | ||
6e3d6dc1 NC |
3289 | /* It does not matter if this load fails, |
3290 | we test for that later on. */ | |
3291 | load_debug_info (file); | |
3292 | ||
19e6b90e L |
3293 | printf (_("Contents of the %s section:\n\n"), section->name); |
3294 | ||
3295 | while (start < end) | |
3296 | { | |
3297 | unsigned char *data; | |
3298 | unsigned long offset; | |
3299 | int offset_size, initial_length_size; | |
3300 | ||
3301 | data = start; | |
3302 | ||
91d6fa6a | 3303 | names.pn_length = byte_get (data, 4); |
19e6b90e | 3304 | data += 4; |
91d6fa6a | 3305 | if (names.pn_length == 0xffffffff) |
19e6b90e | 3306 | { |
91d6fa6a | 3307 | names.pn_length = byte_get (data, 8); |
19e6b90e L |
3308 | data += 8; |
3309 | offset_size = 8; | |
3310 | initial_length_size = 12; | |
3311 | } | |
3312 | else | |
3313 | { | |
3314 | offset_size = 4; | |
3315 | initial_length_size = 4; | |
3316 | } | |
3317 | ||
91d6fa6a | 3318 | names.pn_version = byte_get (data, 2); |
19e6b90e | 3319 | data += 2; |
6e3d6dc1 | 3320 | |
91d6fa6a | 3321 | names.pn_offset = byte_get (data, offset_size); |
19e6b90e | 3322 | data += offset_size; |
6e3d6dc1 NC |
3323 | |
3324 | if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE | |
3325 | && num_debug_info_entries > 0 | |
91d6fa6a | 3326 | && find_debug_info_for_offset (names.pn_offset) == NULL) |
6e3d6dc1 | 3327 | warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"), |
47704ddf | 3328 | (unsigned long) names.pn_offset, section->name); |
cecf136e | 3329 | |
91d6fa6a | 3330 | names.pn_size = byte_get (data, offset_size); |
19e6b90e L |
3331 | data += offset_size; |
3332 | ||
91d6fa6a | 3333 | start += names.pn_length + initial_length_size; |
19e6b90e | 3334 | |
91d6fa6a | 3335 | if (names.pn_version != 2 && names.pn_version != 3) |
19e6b90e L |
3336 | { |
3337 | static int warned = 0; | |
3338 | ||
3339 | if (! warned) | |
3340 | { | |
3341 | warn (_("Only DWARF 2 and 3 pubnames are currently supported\n")); | |
3342 | warned = 1; | |
3343 | } | |
3344 | ||
3345 | continue; | |
3346 | } | |
3347 | ||
3348 | printf (_(" Length: %ld\n"), | |
47704ddf | 3349 | (long) names.pn_length); |
19e6b90e | 3350 | printf (_(" Version: %d\n"), |
91d6fa6a | 3351 | names.pn_version); |
6e3d6dc1 | 3352 | printf (_(" Offset into .debug_info section: 0x%lx\n"), |
47704ddf | 3353 | (unsigned long) names.pn_offset); |
19e6b90e | 3354 | printf (_(" Size of area in .debug_info section: %ld\n"), |
47704ddf | 3355 | (long) names.pn_size); |
19e6b90e L |
3356 | |
3357 | printf (_("\n Offset\tName\n")); | |
3358 | ||
3359 | do | |
3360 | { | |
3361 | offset = byte_get (data, offset_size); | |
3362 | ||
3363 | if (offset != 0) | |
3364 | { | |
3365 | data += offset_size; | |
80c35038 | 3366 | printf (" %-6lx\t%s\n", offset, data); |
19e6b90e L |
3367 | data += strlen ((char *) data) + 1; |
3368 | } | |
3369 | } | |
3370 | while (offset != 0); | |
3371 | } | |
3372 | ||
3373 | printf ("\n"); | |
3374 | return 1; | |
3375 | } | |
3376 | ||
3377 | static int | |
3378 | display_debug_macinfo (struct dwarf_section *section, | |
3379 | void *file ATTRIBUTE_UNUSED) | |
3380 | { | |
3381 | unsigned char *start = section->start; | |
3382 | unsigned char *end = start + section->size; | |
3383 | unsigned char *curr = start; | |
3384 | unsigned int bytes_read; | |
3385 | enum dwarf_macinfo_record_type op; | |
3386 | ||
3387 | printf (_("Contents of the %s section:\n\n"), section->name); | |
3388 | ||
3389 | while (curr < end) | |
3390 | { | |
3391 | unsigned int lineno; | |
3392 | const char *string; | |
3393 | ||
3f5e193b | 3394 | op = (enum dwarf_macinfo_record_type) *curr; |
19e6b90e L |
3395 | curr++; |
3396 | ||
3397 | switch (op) | |
3398 | { | |
3399 | case DW_MACINFO_start_file: | |
3400 | { | |
3401 | unsigned int filenum; | |
3402 | ||
3403 | lineno = read_leb128 (curr, & bytes_read, 0); | |
3404 | curr += bytes_read; | |
3405 | filenum = read_leb128 (curr, & bytes_read, 0); | |
3406 | curr += bytes_read; | |
3407 | ||
3408 | printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"), | |
3409 | lineno, filenum); | |
3410 | } | |
3411 | break; | |
3412 | ||
3413 | case DW_MACINFO_end_file: | |
3414 | printf (_(" DW_MACINFO_end_file\n")); | |
3415 | break; | |
3416 | ||
3417 | case DW_MACINFO_define: | |
3418 | lineno = read_leb128 (curr, & bytes_read, 0); | |
3419 | curr += bytes_read; | |
3420 | string = (char *) curr; | |
3421 | curr += strlen (string) + 1; | |
3422 | printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"), | |
3423 | lineno, string); | |
3424 | break; | |
3425 | ||
3426 | case DW_MACINFO_undef: | |
3427 | lineno = read_leb128 (curr, & bytes_read, 0); | |
3428 | curr += bytes_read; | |
3429 | string = (char *) curr; | |
3430 | curr += strlen (string) + 1; | |
3431 | printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"), | |
3432 | lineno, string); | |
3433 | break; | |
3434 | ||
3435 | case DW_MACINFO_vendor_ext: | |
3436 | { | |
3437 | unsigned int constant; | |
3438 | ||
3439 | constant = read_leb128 (curr, & bytes_read, 0); | |
3440 | curr += bytes_read; | |
3441 | string = (char *) curr; | |
3442 | curr += strlen (string) + 1; | |
3443 | printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"), | |
3444 | constant, string); | |
3445 | } | |
3446 | break; | |
3447 | } | |
3448 | } | |
3449 | ||
3450 | return 1; | |
3451 | } | |
3452 | ||
3453 | static int | |
3454 | display_debug_abbrev (struct dwarf_section *section, | |
3455 | void *file ATTRIBUTE_UNUSED) | |
3456 | { | |
3457 | abbrev_entry *entry; | |
3458 | unsigned char *start = section->start; | |
3459 | unsigned char *end = start + section->size; | |
3460 | ||
3461 | printf (_("Contents of the %s section:\n\n"), section->name); | |
3462 | ||
3463 | do | |
3464 | { | |
3465 | free_abbrevs (); | |
3466 | ||
3467 | start = process_abbrev_section (start, end); | |
3468 | ||
3469 | if (first_abbrev == NULL) | |
3470 | continue; | |
3471 | ||
3472 | printf (_(" Number TAG\n")); | |
3473 | ||
3474 | for (entry = first_abbrev; entry; entry = entry->next) | |
3475 | { | |
3476 | abbrev_attr *attr; | |
3477 | ||
cc5914eb | 3478 | printf (" %ld %s [%s]\n", |
19e6b90e L |
3479 | entry->entry, |
3480 | get_TAG_name (entry->tag), | |
3481 | entry->children ? _("has children") : _("no children")); | |
3482 | ||
3483 | for (attr = entry->first_attr; attr; attr = attr->next) | |
cc5914eb | 3484 | printf (" %-18s %s\n", |
19e6b90e L |
3485 | get_AT_name (attr->attribute), |
3486 | get_FORM_name (attr->form)); | |
3487 | } | |
3488 | } | |
3489 | while (start); | |
3490 | ||
3491 | printf ("\n"); | |
3492 | ||
3493 | return 1; | |
3494 | } | |
3495 | ||
51d0d03f JJ |
3496 | /* Sort array of indexes in ascending order of loc_offsets[idx]. */ |
3497 | ||
3498 | static dwarf_vma *loc_offsets; | |
3499 | ||
3500 | static int | |
3501 | loc_offsets_compar (const void *ap, const void *bp) | |
3502 | { | |
3503 | dwarf_vma a = loc_offsets[*(const unsigned int *) ap]; | |
3504 | dwarf_vma b = loc_offsets[*(const unsigned int *) bp]; | |
3505 | ||
3506 | return (a > b) - (b > a); | |
3507 | } | |
3508 | ||
19e6b90e L |
3509 | static int |
3510 | display_debug_loc (struct dwarf_section *section, void *file) | |
3511 | { | |
3512 | unsigned char *start = section->start; | |
3513 | unsigned char *section_end; | |
3514 | unsigned long bytes; | |
3515 | unsigned char *section_begin = start; | |
3516 | unsigned int num_loc_list = 0; | |
3517 | unsigned long last_offset = 0; | |
3518 | unsigned int first = 0; | |
3519 | unsigned int i; | |
3520 | unsigned int j; | |
51d0d03f | 3521 | unsigned int k; |
19e6b90e | 3522 | int seen_first_offset = 0; |
51d0d03f | 3523 | int locs_sorted = 1; |
19e6b90e | 3524 | unsigned char *next; |
51d0d03f | 3525 | unsigned int *array = NULL; |
19e6b90e L |
3526 | |
3527 | bytes = section->size; | |
3528 | section_end = start + bytes; | |
3529 | ||
3530 | if (bytes == 0) | |
3531 | { | |
3532 | printf (_("\nThe %s section is empty.\n"), section->name); | |
3533 | return 0; | |
3534 | } | |
3535 | ||
1febe64d NC |
3536 | if (load_debug_info (file) == 0) |
3537 | { | |
3538 | warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"), | |
3539 | section->name); | |
3540 | return 0; | |
3541 | } | |
19e6b90e L |
3542 | |
3543 | /* Check the order of location list in .debug_info section. If | |
3544 | offsets of location lists are in the ascending order, we can | |
3545 | use `debug_information' directly. */ | |
3546 | for (i = 0; i < num_debug_info_entries; i++) | |
3547 | { | |
3548 | unsigned int num; | |
3549 | ||
3550 | num = debug_information [i].num_loc_offsets; | |
51d0d03f JJ |
3551 | if (num > num_loc_list) |
3552 | num_loc_list = num; | |
19e6b90e L |
3553 | |
3554 | /* Check if we can use `debug_information' directly. */ | |
51d0d03f | 3555 | if (locs_sorted && num != 0) |
19e6b90e L |
3556 | { |
3557 | if (!seen_first_offset) | |
3558 | { | |
3559 | /* This is the first location list. */ | |
3560 | last_offset = debug_information [i].loc_offsets [0]; | |
3561 | first = i; | |
3562 | seen_first_offset = 1; | |
3563 | j = 1; | |
3564 | } | |
3565 | else | |
3566 | j = 0; | |
3567 | ||
3568 | for (; j < num; j++) | |
3569 | { | |
3570 | if (last_offset > | |
3571 | debug_information [i].loc_offsets [j]) | |
3572 | { | |
51d0d03f | 3573 | locs_sorted = 0; |
19e6b90e L |
3574 | break; |
3575 | } | |
3576 | last_offset = debug_information [i].loc_offsets [j]; | |
3577 | } | |
3578 | } | |
3579 | } | |
3580 | ||
19e6b90e L |
3581 | if (!seen_first_offset) |
3582 | error (_("No location lists in .debug_info section!\n")); | |
3583 | ||
bfe2612a | 3584 | /* DWARF sections under Mach-O have non-zero addresses. */ |
d4bfc77b AS |
3585 | if (debug_information [first].num_loc_offsets > 0 |
3586 | && debug_information [first].loc_offsets [0] != section->address) | |
47704ddf KT |
3587 | warn (_("Location lists in %s section start at 0x%s\n"), |
3588 | section->name, | |
3589 | dwarf_vmatoa ("x", debug_information [first].loc_offsets [0])); | |
19e6b90e | 3590 | |
51d0d03f JJ |
3591 | if (!locs_sorted) |
3592 | array = (unsigned int *) xcmalloc (num_loc_list, sizeof (unsigned int)); | |
19e6b90e L |
3593 | printf (_("Contents of the %s section:\n\n"), section->name); |
3594 | printf (_(" Offset Begin End Expression\n")); | |
3595 | ||
3596 | seen_first_offset = 0; | |
3597 | for (i = first; i < num_debug_info_entries; i++) | |
3598 | { | |
2d9472a2 NC |
3599 | dwarf_vma begin; |
3600 | dwarf_vma end; | |
19e6b90e L |
3601 | unsigned short length; |
3602 | unsigned long offset; | |
3603 | unsigned int pointer_size; | |
b7807392 JJ |
3604 | unsigned int offset_size; |
3605 | int dwarf_version; | |
19e6b90e L |
3606 | unsigned long cu_offset; |
3607 | unsigned long base_address; | |
3608 | int need_frame_base; | |
3609 | int has_frame_base; | |
3610 | ||
3611 | pointer_size = debug_information [i].pointer_size; | |
3612 | cu_offset = debug_information [i].cu_offset; | |
b7807392 JJ |
3613 | offset_size = debug_information [i].offset_size; |
3614 | dwarf_version = debug_information [i].dwarf_version; | |
51d0d03f JJ |
3615 | if (!locs_sorted) |
3616 | { | |
3617 | for (k = 0; k < debug_information [i].num_loc_offsets; k++) | |
3618 | array[k] = k; | |
3619 | loc_offsets = debug_information [i].loc_offsets; | |
3620 | qsort (array, debug_information [i].num_loc_offsets, | |
3621 | sizeof (*array), loc_offsets_compar); | |
3622 | } | |
19e6b90e | 3623 | |
51d0d03f | 3624 | for (k = 0; k < debug_information [i].num_loc_offsets; k++) |
19e6b90e | 3625 | { |
51d0d03f JJ |
3626 | j = locs_sorted ? k : array[k]; |
3627 | if (k | |
3628 | && debug_information [i].loc_offsets [locs_sorted | |
3629 | ? k - 1 : array [k - 1]] | |
3630 | == debug_information [i].loc_offsets [j]) | |
3631 | continue; | |
19e6b90e | 3632 | has_frame_base = debug_information [i].have_frame_base [j]; |
bfe2612a | 3633 | /* DWARF sections under Mach-O have non-zero addresses. */ |
cecf136e | 3634 | offset = debug_information [i].loc_offsets [j] - section->address; |
19e6b90e L |
3635 | next = section_begin + offset; |
3636 | base_address = debug_information [i].base_address; | |
3637 | ||
3638 | if (!seen_first_offset) | |
3639 | seen_first_offset = 1; | |
3640 | else | |
3641 | { | |
3642 | if (start < next) | |
3643 | warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"), | |
0af1713e AM |
3644 | (unsigned long) (start - section_begin), |
3645 | (unsigned long) (next - section_begin)); | |
19e6b90e L |
3646 | else if (start > next) |
3647 | warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"), | |
0af1713e AM |
3648 | (unsigned long) (start - section_begin), |
3649 | (unsigned long) (next - section_begin)); | |
19e6b90e L |
3650 | } |
3651 | start = next; | |
3652 | ||
3653 | if (offset >= bytes) | |
3654 | { | |
3655 | warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"), | |
3656 | offset); | |
3657 | continue; | |
3658 | } | |
3659 | ||
3660 | while (1) | |
3661 | { | |
3662 | if (start + 2 * pointer_size > section_end) | |
3663 | { | |
3664 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), | |
3665 | offset); | |
3666 | break; | |
3667 | } | |
3668 | ||
2d9472a2 NC |
3669 | /* Note: we use sign extension here in order to be sure that |
3670 | we can detect the -1 escape value. Sign extension into the | |
3671 | top 32 bits of a 32-bit address will not affect the values | |
3672 | that we display since we always show hex values, and always | |
cecf136e | 3673 | the bottom 32-bits. */ |
2d9472a2 | 3674 | begin = byte_get_signed (start, pointer_size); |
19e6b90e | 3675 | start += pointer_size; |
2d9472a2 | 3676 | end = byte_get_signed (start, pointer_size); |
19e6b90e L |
3677 | start += pointer_size; |
3678 | ||
2d9472a2 NC |
3679 | printf (" %8.8lx ", offset); |
3680 | ||
19e6b90e L |
3681 | if (begin == 0 && end == 0) |
3682 | { | |
2d9472a2 | 3683 | printf (_("<End of list>\n")); |
19e6b90e L |
3684 | break; |
3685 | } | |
3686 | ||
3687 | /* Check base address specifiers. */ | |
2d9472a2 | 3688 | if (begin == (dwarf_vma) -1 && end != (dwarf_vma) -1) |
19e6b90e L |
3689 | { |
3690 | base_address = end; | |
2d9472a2 NC |
3691 | print_dwarf_vma (begin, pointer_size); |
3692 | print_dwarf_vma (end, pointer_size); | |
3693 | printf (_("(base address)\n")); | |
19e6b90e L |
3694 | continue; |
3695 | } | |
3696 | ||
3697 | if (start + 2 > section_end) | |
3698 | { | |
3699 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), | |
3700 | offset); | |
3701 | break; | |
3702 | } | |
3703 | ||
3704 | length = byte_get (start, 2); | |
3705 | start += 2; | |
3706 | ||
3707 | if (start + length > section_end) | |
3708 | { | |
3709 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), | |
3710 | offset); | |
3711 | break; | |
3712 | } | |
3713 | ||
2d9472a2 NC |
3714 | print_dwarf_vma (begin + base_address, pointer_size); |
3715 | print_dwarf_vma (end + base_address, pointer_size); | |
3716 | ||
3717 | putchar ('('); | |
19e6b90e L |
3718 | need_frame_base = decode_location_expression (start, |
3719 | pointer_size, | |
b7807392 JJ |
3720 | offset_size, |
3721 | dwarf_version, | |
19e6b90e | 3722 | length, |
f1c4cc75 | 3723 | cu_offset, section); |
19e6b90e L |
3724 | putchar (')'); |
3725 | ||
3726 | if (need_frame_base && !has_frame_base) | |
3727 | printf (_(" [without DW_AT_frame_base]")); | |
3728 | ||
3729 | if (begin == end) | |
3730 | fputs (_(" (start == end)"), stdout); | |
3731 | else if (begin > end) | |
3732 | fputs (_(" (start > end)"), stdout); | |
3733 | ||
3734 | putchar ('\n'); | |
3735 | ||
3736 | start += length; | |
3737 | } | |
3738 | } | |
3739 | } | |
031cd65f NC |
3740 | |
3741 | if (start < section_end) | |
3742 | warn (_("There are %ld unused bytes at the end of section %s\n"), | |
0eb090cb | 3743 | (long) (section_end - start), section->name); |
98fb390a | 3744 | putchar ('\n'); |
51d0d03f | 3745 | free (array); |
19e6b90e L |
3746 | return 1; |
3747 | } | |
3748 | ||
3749 | static int | |
3750 | display_debug_str (struct dwarf_section *section, | |
3751 | void *file ATTRIBUTE_UNUSED) | |
3752 | { | |
3753 | unsigned char *start = section->start; | |
3754 | unsigned long bytes = section->size; | |
3755 | dwarf_vma addr = section->address; | |
3756 | ||
3757 | if (bytes == 0) | |
3758 | { | |
3759 | printf (_("\nThe %s section is empty.\n"), section->name); | |
3760 | return 0; | |
3761 | } | |
3762 | ||
3763 | printf (_("Contents of the %s section:\n\n"), section->name); | |
3764 | ||
3765 | while (bytes) | |
3766 | { | |
3767 | int j; | |
3768 | int k; | |
3769 | int lbytes; | |
3770 | ||
3771 | lbytes = (bytes > 16 ? 16 : bytes); | |
3772 | ||
3773 | printf (" 0x%8.8lx ", (unsigned long) addr); | |
3774 | ||
3775 | for (j = 0; j < 16; j++) | |
3776 | { | |
3777 | if (j < lbytes) | |
3778 | printf ("%2.2x", start[j]); | |
3779 | else | |
3780 | printf (" "); | |
3781 | ||
3782 | if ((j & 3) == 3) | |
3783 | printf (" "); | |
3784 | } | |
3785 | ||
3786 | for (j = 0; j < lbytes; j++) | |
3787 | { | |
3788 | k = start[j]; | |
3789 | if (k >= ' ' && k < 0x80) | |
3790 | printf ("%c", k); | |
3791 | else | |
3792 | printf ("."); | |
3793 | } | |
3794 | ||
3795 | putchar ('\n'); | |
3796 | ||
3797 | start += lbytes; | |
3798 | addr += lbytes; | |
3799 | bytes -= lbytes; | |
3800 | } | |
3801 | ||
3802 | putchar ('\n'); | |
3803 | ||
3804 | return 1; | |
3805 | } | |
3806 | ||
19e6b90e L |
3807 | static int |
3808 | display_debug_info (struct dwarf_section *section, void *file) | |
3809 | { | |
6f875884 | 3810 | return process_debug_info (section, file, abbrev, 0, 0); |
19e6b90e L |
3811 | } |
3812 | ||
2b6f5997 CC |
3813 | static int |
3814 | display_debug_types (struct dwarf_section *section, void *file) | |
3815 | { | |
6f875884 TG |
3816 | return process_debug_info (section, file, abbrev, 0, 1); |
3817 | } | |
3818 | ||
3819 | static int | |
3820 | display_trace_info (struct dwarf_section *section, void *file) | |
3821 | { | |
3822 | return process_debug_info (section, file, trace_abbrev, 0, 0); | |
2b6f5997 | 3823 | } |
19e6b90e L |
3824 | |
3825 | static int | |
3826 | display_debug_aranges (struct dwarf_section *section, | |
3827 | void *file ATTRIBUTE_UNUSED) | |
3828 | { | |
3829 | unsigned char *start = section->start; | |
3830 | unsigned char *end = start + section->size; | |
3831 | ||
80c35038 | 3832 | printf (_("Contents of the %s section:\n\n"), section->name); |
19e6b90e | 3833 | |
6e3d6dc1 NC |
3834 | /* It does not matter if this load fails, |
3835 | we test for that later on. */ | |
3836 | load_debug_info (file); | |
3837 | ||
19e6b90e L |
3838 | while (start < end) |
3839 | { | |
3840 | unsigned char *hdrptr; | |
3841 | DWARF2_Internal_ARange arange; | |
91d6fa6a | 3842 | unsigned char *addr_ranges; |
2d9472a2 NC |
3843 | dwarf_vma length; |
3844 | dwarf_vma address; | |
53b8873b | 3845 | unsigned char address_size; |
19e6b90e L |
3846 | int excess; |
3847 | int offset_size; | |
3848 | int initial_length_size; | |
3849 | ||
3850 | hdrptr = start; | |
3851 | ||
3852 | arange.ar_length = byte_get (hdrptr, 4); | |
3853 | hdrptr += 4; | |
3854 | ||
3855 | if (arange.ar_length == 0xffffffff) | |
3856 | { | |
3857 | arange.ar_length = byte_get (hdrptr, 8); | |
3858 | hdrptr += 8; | |
3859 | offset_size = 8; | |
3860 | initial_length_size = 12; | |
3861 | } | |
3862 | else | |
3863 | { | |
3864 | offset_size = 4; | |
3865 | initial_length_size = 4; | |
3866 | } | |
3867 | ||
3868 | arange.ar_version = byte_get (hdrptr, 2); | |
3869 | hdrptr += 2; | |
3870 | ||
3871 | arange.ar_info_offset = byte_get (hdrptr, offset_size); | |
3872 | hdrptr += offset_size; | |
3873 | ||
6e3d6dc1 NC |
3874 | if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE |
3875 | && num_debug_info_entries > 0 | |
3876 | && find_debug_info_for_offset (arange.ar_info_offset) == NULL) | |
3877 | warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"), | |
47704ddf | 3878 | (unsigned long) arange.ar_info_offset, section->name); |
6e3d6dc1 | 3879 | |
19e6b90e L |
3880 | arange.ar_pointer_size = byte_get (hdrptr, 1); |
3881 | hdrptr += 1; | |
3882 | ||
3883 | arange.ar_segment_size = byte_get (hdrptr, 1); | |
3884 | hdrptr += 1; | |
3885 | ||
3886 | if (arange.ar_version != 2 && arange.ar_version != 3) | |
3887 | { | |
3888 | warn (_("Only DWARF 2 and 3 aranges are currently supported.\n")); | |
3889 | break; | |
3890 | } | |
3891 | ||
47704ddf KT |
3892 | printf (_(" Length: %ld\n"), |
3893 | (long) arange.ar_length); | |
19e6b90e | 3894 | printf (_(" Version: %d\n"), arange.ar_version); |
47704ddf KT |
3895 | printf (_(" Offset into .debug_info: 0x%lx\n"), |
3896 | (unsigned long) arange.ar_info_offset); | |
19e6b90e L |
3897 | printf (_(" Pointer Size: %d\n"), arange.ar_pointer_size); |
3898 | printf (_(" Segment Size: %d\n"), arange.ar_segment_size); | |
3899 | ||
53b8873b NC |
3900 | address_size = arange.ar_pointer_size + arange.ar_segment_size; |
3901 | ||
3902 | /* The DWARF spec does not require that the address size be a power | |
3903 | of two, but we do. This will have to change if we ever encounter | |
3904 | an uneven architecture. */ | |
3905 | if ((address_size & (address_size - 1)) != 0) | |
3906 | { | |
3907 | warn (_("Pointer size + Segment size is not a power of two.\n")); | |
3908 | break; | |
3909 | } | |
cecf136e | 3910 | |
209c9a13 NC |
3911 | if (address_size > 4) |
3912 | printf (_("\n Address Length\n")); | |
3913 | else | |
3914 | printf (_("\n Address Length\n")); | |
19e6b90e | 3915 | |
91d6fa6a | 3916 | addr_ranges = hdrptr; |
19e6b90e | 3917 | |
53b8873b NC |
3918 | /* Must pad to an alignment boundary that is twice the address size. */ |
3919 | excess = (hdrptr - start) % (2 * address_size); | |
19e6b90e | 3920 | if (excess) |
91d6fa6a | 3921 | addr_ranges += (2 * address_size) - excess; |
19e6b90e | 3922 | |
1617e571 AM |
3923 | start += arange.ar_length + initial_length_size; |
3924 | ||
91d6fa6a | 3925 | while (addr_ranges + 2 * address_size <= start) |
19e6b90e | 3926 | { |
91d6fa6a | 3927 | address = byte_get (addr_ranges, address_size); |
19e6b90e | 3928 | |
91d6fa6a | 3929 | addr_ranges += address_size; |
19e6b90e | 3930 | |
91d6fa6a | 3931 | length = byte_get (addr_ranges, address_size); |
19e6b90e | 3932 | |
91d6fa6a | 3933 | addr_ranges += address_size; |
19e6b90e | 3934 | |
80c35038 | 3935 | printf (" "); |
2d9472a2 NC |
3936 | print_dwarf_vma (address, address_size); |
3937 | print_dwarf_vma (length, address_size); | |
3938 | putchar ('\n'); | |
19e6b90e | 3939 | } |
19e6b90e L |
3940 | } |
3941 | ||
3942 | printf ("\n"); | |
3943 | ||
3944 | return 1; | |
3945 | } | |
3946 | ||
01a8f077 JK |
3947 | /* Each debug_information[x].range_lists[y] gets this representation for |
3948 | sorting purposes. */ | |
3949 | ||
3950 | struct range_entry | |
467c65bc NC |
3951 | { |
3952 | /* The debug_information[x].range_lists[y] value. */ | |
3953 | unsigned long ranges_offset; | |
01a8f077 | 3954 | |
467c65bc NC |
3955 | /* Original debug_information to find parameters of the data. */ |
3956 | debug_info *debug_info_p; | |
3957 | }; | |
01a8f077 JK |
3958 | |
3959 | /* Sort struct range_entry in ascending order of its RANGES_OFFSET. */ | |
3960 | ||
3961 | static int | |
3962 | range_entry_compar (const void *ap, const void *bp) | |
3963 | { | |
3f5e193b NC |
3964 | const struct range_entry *a_re = (const struct range_entry *) ap; |
3965 | const struct range_entry *b_re = (const struct range_entry *) bp; | |
01a8f077 JK |
3966 | const unsigned long a = a_re->ranges_offset; |
3967 | const unsigned long b = b_re->ranges_offset; | |
3968 | ||
3969 | return (a > b) - (b > a); | |
3970 | } | |
3971 | ||
19e6b90e L |
3972 | static int |
3973 | display_debug_ranges (struct dwarf_section *section, | |
3974 | void *file ATTRIBUTE_UNUSED) | |
3975 | { | |
3976 | unsigned char *start = section->start; | |
19e6b90e L |
3977 | unsigned long bytes; |
3978 | unsigned char *section_begin = start; | |
01a8f077 JK |
3979 | unsigned int num_range_list, i; |
3980 | struct range_entry *range_entries, *range_entry_fill; | |
19e6b90e L |
3981 | |
3982 | bytes = section->size; | |
19e6b90e L |
3983 | |
3984 | if (bytes == 0) | |
3985 | { | |
3986 | printf (_("\nThe %s section is empty.\n"), section->name); | |
3987 | return 0; | |
3988 | } | |
3989 | ||
1febe64d NC |
3990 | if (load_debug_info (file) == 0) |
3991 | { | |
3992 | warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"), | |
3993 | section->name); | |
3994 | return 0; | |
3995 | } | |
19e6b90e | 3996 | |
01a8f077 | 3997 | num_range_list = 0; |
19e6b90e | 3998 | for (i = 0; i < num_debug_info_entries; i++) |
01a8f077 | 3999 | num_range_list += debug_information [i].num_range_lists; |
19e6b90e | 4000 | |
01a8f077 JK |
4001 | if (num_range_list == 0) |
4002 | error (_("No range lists in .debug_info section!\n")); | |
19e6b90e | 4003 | |
3f5e193b NC |
4004 | range_entries = (struct range_entry *) |
4005 | xmalloc (sizeof (*range_entries) * num_range_list); | |
01a8f077 | 4006 | range_entry_fill = range_entries; |
19e6b90e | 4007 | |
01a8f077 JK |
4008 | for (i = 0; i < num_debug_info_entries; i++) |
4009 | { | |
4010 | debug_info *debug_info_p = &debug_information[i]; | |
4011 | unsigned int j; | |
4012 | ||
4013 | for (j = 0; j < debug_info_p->num_range_lists; j++) | |
4014 | { | |
4015 | range_entry_fill->ranges_offset = debug_info_p->range_lists[j]; | |
4016 | range_entry_fill->debug_info_p = debug_info_p; | |
4017 | range_entry_fill++; | |
19e6b90e L |
4018 | } |
4019 | } | |
4020 | ||
01a8f077 JK |
4021 | qsort (range_entries, num_range_list, sizeof (*range_entries), |
4022 | range_entry_compar); | |
19e6b90e | 4023 | |
bfe2612a | 4024 | /* DWARF sections under Mach-O have non-zero addresses. */ |
01a8f077 | 4025 | if (range_entries[0].ranges_offset != section->address) |
19e6b90e | 4026 | warn (_("Range lists in %s section start at 0x%lx\n"), |
01a8f077 | 4027 | section->name, range_entries[0].ranges_offset); |
19e6b90e L |
4028 | |
4029 | printf (_("Contents of the %s section:\n\n"), section->name); | |
4030 | printf (_(" Offset Begin End\n")); | |
4031 | ||
01a8f077 | 4032 | for (i = 0; i < num_range_list; i++) |
19e6b90e | 4033 | { |
01a8f077 JK |
4034 | struct range_entry *range_entry = &range_entries[i]; |
4035 | debug_info *debug_info_p = range_entry->debug_info_p; | |
19e6b90e | 4036 | unsigned int pointer_size; |
01a8f077 JK |
4037 | unsigned long offset; |
4038 | unsigned char *next; | |
19e6b90e L |
4039 | unsigned long base_address; |
4040 | ||
01a8f077 JK |
4041 | pointer_size = debug_info_p->pointer_size; |
4042 | ||
4043 | /* DWARF sections under Mach-O have non-zero addresses. */ | |
4044 | offset = range_entry->ranges_offset - section->address; | |
4045 | next = section_begin + offset; | |
4046 | base_address = debug_info_p->base_address; | |
cecf136e | 4047 | |
01a8f077 | 4048 | if (i > 0) |
19e6b90e | 4049 | { |
01a8f077 JK |
4050 | if (start < next) |
4051 | warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"), | |
4052 | (unsigned long) (start - section_begin), | |
4053 | (unsigned long) (next - section_begin), section->name); | |
4054 | else if (start > next) | |
4055 | warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"), | |
4056 | (unsigned long) (start - section_begin), | |
4057 | (unsigned long) (next - section_begin), section->name); | |
4058 | } | |
4059 | start = next; | |
19e6b90e | 4060 | |
01a8f077 JK |
4061 | while (1) |
4062 | { | |
4063 | dwarf_vma begin; | |
4064 | dwarf_vma end; | |
4065 | ||
4066 | /* Note: we use sign extension here in order to be sure that | |
4067 | we can detect the -1 escape value. Sign extension into the | |
4068 | top 32 bits of a 32-bit address will not affect the values | |
4069 | that we display since we always show hex values, and always | |
4070 | the bottom 32-bits. */ | |
4071 | begin = byte_get_signed (start, pointer_size); | |
4072 | start += pointer_size; | |
4073 | end = byte_get_signed (start, pointer_size); | |
4074 | start += pointer_size; | |
4075 | ||
4076 | printf (" %8.8lx ", offset); | |
4077 | ||
4078 | if (begin == 0 && end == 0) | |
19e6b90e | 4079 | { |
01a8f077 JK |
4080 | printf (_("<End of list>\n")); |
4081 | break; | |
19e6b90e | 4082 | } |
19e6b90e | 4083 | |
01a8f077 JK |
4084 | /* Check base address specifiers. */ |
4085 | if (begin == (dwarf_vma) -1 && end != (dwarf_vma) -1) | |
19e6b90e | 4086 | { |
01a8f077 JK |
4087 | base_address = end; |
4088 | print_dwarf_vma (begin, pointer_size); | |
4089 | print_dwarf_vma (end, pointer_size); | |
4090 | printf ("(base address)\n"); | |
4091 | continue; | |
4092 | } | |
19e6b90e | 4093 | |
01a8f077 JK |
4094 | print_dwarf_vma (begin + base_address, pointer_size); |
4095 | print_dwarf_vma (end + base_address, pointer_size); | |
4a149252 | 4096 | |
01a8f077 JK |
4097 | if (begin == end) |
4098 | fputs (_("(start == end)"), stdout); | |
4099 | else if (begin > end) | |
4100 | fputs (_("(start > end)"), stdout); | |
19e6b90e | 4101 | |
01a8f077 | 4102 | putchar ('\n'); |
19e6b90e L |
4103 | } |
4104 | } | |
4105 | putchar ('\n'); | |
01a8f077 JK |
4106 | |
4107 | free (range_entries); | |
4108 | ||
19e6b90e L |
4109 | return 1; |
4110 | } | |
4111 | ||
4112 | typedef struct Frame_Chunk | |
4113 | { | |
4114 | struct Frame_Chunk *next; | |
4115 | unsigned char *chunk_start; | |
4116 | int ncols; | |
4117 | /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */ | |
4118 | short int *col_type; | |
4119 | int *col_offset; | |
4120 | char *augmentation; | |
4121 | unsigned int code_factor; | |
4122 | int data_factor; | |
4123 | unsigned long pc_begin; | |
4124 | unsigned long pc_range; | |
4125 | int cfa_reg; | |
4126 | int cfa_offset; | |
4127 | int ra; | |
4128 | unsigned char fde_encoding; | |
4129 | unsigned char cfa_exp; | |
604282a7 JJ |
4130 | unsigned char ptr_size; |
4131 | unsigned char segment_size; | |
19e6b90e L |
4132 | } |
4133 | Frame_Chunk; | |
4134 | ||
665ce1f6 L |
4135 | static const char *const *dwarf_regnames; |
4136 | static unsigned int dwarf_regnames_count; | |
4137 | ||
19e6b90e L |
4138 | /* A marker for a col_type that means this column was never referenced |
4139 | in the frame info. */ | |
4140 | #define DW_CFA_unreferenced (-1) | |
4141 | ||
665ce1f6 L |
4142 | /* Return 0 if not more space is needed, 1 if more space is needed, |
4143 | -1 for invalid reg. */ | |
4144 | ||
4145 | static int | |
4146 | frame_need_space (Frame_Chunk *fc, unsigned int reg) | |
19e6b90e L |
4147 | { |
4148 | int prev = fc->ncols; | |
4149 | ||
665ce1f6 L |
4150 | if (reg < (unsigned int) fc->ncols) |
4151 | return 0; | |
4152 | ||
4153 | if (dwarf_regnames_count | |
4154 | && reg > dwarf_regnames_count) | |
4155 | return -1; | |
19e6b90e L |
4156 | |
4157 | fc->ncols = reg + 1; | |
3f5e193b NC |
4158 | fc->col_type = (short int *) xcrealloc (fc->col_type, fc->ncols, |
4159 | sizeof (short int)); | |
4160 | fc->col_offset = (int *) xcrealloc (fc->col_offset, fc->ncols, sizeof (int)); | |
19e6b90e L |
4161 | |
4162 | while (prev < fc->ncols) | |
4163 | { | |
4164 | fc->col_type[prev] = DW_CFA_unreferenced; | |
4165 | fc->col_offset[prev] = 0; | |
4166 | prev++; | |
4167 | } | |
665ce1f6 | 4168 | return 1; |
19e6b90e L |
4169 | } |
4170 | ||
2dc4cec1 L |
4171 | static const char *const dwarf_regnames_i386[] = |
4172 | { | |
4173 | "eax", "ecx", "edx", "ebx", | |
4174 | "esp", "ebp", "esi", "edi", | |
4175 | "eip", "eflags", NULL, | |
4176 | "st0", "st1", "st2", "st3", | |
4177 | "st4", "st5", "st6", "st7", | |
4178 | NULL, NULL, | |
4179 | "xmm0", "xmm1", "xmm2", "xmm3", | |
4180 | "xmm4", "xmm5", "xmm6", "xmm7", | |
4181 | "mm0", "mm1", "mm2", "mm3", | |
4182 | "mm4", "mm5", "mm6", "mm7", | |
4183 | "fcw", "fsw", "mxcsr", | |
4184 | "es", "cs", "ss", "ds", "fs", "gs", NULL, NULL, | |
a656ed5b | 4185 | "tr", "ldtr" |
2dc4cec1 L |
4186 | }; |
4187 | ||
b129eb0e RH |
4188 | void |
4189 | init_dwarf_regnames_i386 (void) | |
4190 | { | |
4191 | dwarf_regnames = dwarf_regnames_i386; | |
4192 | dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_i386); | |
4193 | } | |
4194 | ||
2dc4cec1 L |
4195 | static const char *const dwarf_regnames_x86_64[] = |
4196 | { | |
4197 | "rax", "rdx", "rcx", "rbx", | |
4198 | "rsi", "rdi", "rbp", "rsp", | |
4199 | "r8", "r9", "r10", "r11", | |
4200 | "r12", "r13", "r14", "r15", | |
4201 | "rip", | |
4202 | "xmm0", "xmm1", "xmm2", "xmm3", | |
4203 | "xmm4", "xmm5", "xmm6", "xmm7", | |
4204 | "xmm8", "xmm9", "xmm10", "xmm11", | |
4205 | "xmm12", "xmm13", "xmm14", "xmm15", | |
4206 | "st0", "st1", "st2", "st3", | |
4207 | "st4", "st5", "st6", "st7", | |
4208 | "mm0", "mm1", "mm2", "mm3", | |
4209 | "mm4", "mm5", "mm6", "mm7", | |
4210 | "rflags", | |
4211 | "es", "cs", "ss", "ds", "fs", "gs", NULL, NULL, | |
4212 | "fs.base", "gs.base", NULL, NULL, | |
4213 | "tr", "ldtr", | |
a656ed5b | 4214 | "mxcsr", "fcw", "fsw" |
2dc4cec1 L |
4215 | }; |
4216 | ||
b129eb0e RH |
4217 | void |
4218 | init_dwarf_regnames_x86_64 (void) | |
4219 | { | |
4220 | dwarf_regnames = dwarf_regnames_x86_64; | |
4221 | dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_x86_64); | |
4222 | } | |
4223 | ||
2dc4cec1 L |
4224 | void |
4225 | init_dwarf_regnames (unsigned int e_machine) | |
4226 | { | |
4227 | switch (e_machine) | |
4228 | { | |
4229 | case EM_386: | |
4230 | case EM_486: | |
b129eb0e | 4231 | init_dwarf_regnames_i386 (); |
2dc4cec1 L |
4232 | break; |
4233 | ||
4234 | case EM_X86_64: | |
7f502d6c | 4235 | case EM_L1OM: |
7a9068fe | 4236 | case EM_K1OM: |
b129eb0e | 4237 | init_dwarf_regnames_x86_64 (); |
2dc4cec1 L |
4238 | break; |
4239 | ||
4240 | default: | |
4241 | break; | |
4242 | } | |
4243 | } | |
4244 | ||
4245 | static const char * | |
4246 | regname (unsigned int regno, int row) | |
4247 | { | |
4248 | static char reg[64]; | |
4249 | if (dwarf_regnames | |
4250 | && regno < dwarf_regnames_count | |
4251 | && dwarf_regnames [regno] != NULL) | |
4252 | { | |
4253 | if (row) | |
4254 | return dwarf_regnames [regno]; | |
4255 | snprintf (reg, sizeof (reg), "r%d (%s)", regno, | |
4256 | dwarf_regnames [regno]); | |
4257 | } | |
4258 | else | |
4259 | snprintf (reg, sizeof (reg), "r%d", regno); | |
4260 | return reg; | |
4261 | } | |
4262 | ||
19e6b90e L |
4263 | static void |
4264 | frame_display_row (Frame_Chunk *fc, int *need_col_headers, int *max_regs) | |
4265 | { | |
4266 | int r; | |
4267 | char tmp[100]; | |
4268 | ||
4269 | if (*max_regs < fc->ncols) | |
4270 | *max_regs = fc->ncols; | |
4271 | ||
4272 | if (*need_col_headers) | |
4273 | { | |
91d6fa6a | 4274 | static const char *sloc = " LOC"; |
2dc4cec1 | 4275 | |
19e6b90e L |
4276 | *need_col_headers = 0; |
4277 | ||
91d6fa6a | 4278 | printf ("%-*s CFA ", eh_addr_size * 2, sloc); |
19e6b90e L |
4279 | |
4280 | for (r = 0; r < *max_regs; r++) | |
4281 | if (fc->col_type[r] != DW_CFA_unreferenced) | |
4282 | { | |
4283 | if (r == fc->ra) | |
2dc4cec1 | 4284 | printf ("ra "); |
19e6b90e | 4285 | else |
2dc4cec1 | 4286 | printf ("%-5s ", regname (r, 1)); |
19e6b90e L |
4287 | } |
4288 | ||
4289 | printf ("\n"); | |
4290 | } | |
4291 | ||
2dc4cec1 | 4292 | printf ("%0*lx ", eh_addr_size * 2, fc->pc_begin); |
19e6b90e L |
4293 | if (fc->cfa_exp) |
4294 | strcpy (tmp, "exp"); | |
4295 | else | |
2dc4cec1 | 4296 | sprintf (tmp, "%s%+d", regname (fc->cfa_reg, 1), fc->cfa_offset); |
19e6b90e L |
4297 | printf ("%-8s ", tmp); |
4298 | ||
4299 | for (r = 0; r < fc->ncols; r++) | |
4300 | { | |
4301 | if (fc->col_type[r] != DW_CFA_unreferenced) | |
4302 | { | |
4303 | switch (fc->col_type[r]) | |
4304 | { | |
4305 | case DW_CFA_undefined: | |
4306 | strcpy (tmp, "u"); | |
4307 | break; | |
4308 | case DW_CFA_same_value: | |
4309 | strcpy (tmp, "s"); | |
4310 | break; | |
4311 | case DW_CFA_offset: | |
4312 | sprintf (tmp, "c%+d", fc->col_offset[r]); | |
4313 | break; | |
12eae2d3 JJ |
4314 | case DW_CFA_val_offset: |
4315 | sprintf (tmp, "v%+d", fc->col_offset[r]); | |
4316 | break; | |
19e6b90e | 4317 | case DW_CFA_register: |
2dc4cec1 | 4318 | sprintf (tmp, "%s", regname (fc->col_offset[r], 0)); |
19e6b90e L |
4319 | break; |
4320 | case DW_CFA_expression: | |
4321 | strcpy (tmp, "exp"); | |
4322 | break; | |
12eae2d3 JJ |
4323 | case DW_CFA_val_expression: |
4324 | strcpy (tmp, "vexp"); | |
4325 | break; | |
19e6b90e L |
4326 | default: |
4327 | strcpy (tmp, "n/a"); | |
4328 | break; | |
4329 | } | |
2dc4cec1 | 4330 | printf ("%-5s ", tmp); |
19e6b90e L |
4331 | } |
4332 | } | |
4333 | printf ("\n"); | |
4334 | } | |
4335 | ||
19e6b90e L |
4336 | #define GET(N) byte_get (start, N); start += N |
4337 | #define LEB() read_leb128 (start, & length_return, 0); start += length_return | |
467c65bc | 4338 | #define SLEB() read_sleb128 (start, & length_return); start += length_return |
19e6b90e L |
4339 | |
4340 | static int | |
4341 | display_debug_frames (struct dwarf_section *section, | |
4342 | void *file ATTRIBUTE_UNUSED) | |
4343 | { | |
4344 | unsigned char *start = section->start; | |
4345 | unsigned char *end = start + section->size; | |
4346 | unsigned char *section_start = start; | |
4347 | Frame_Chunk *chunks = 0; | |
4348 | Frame_Chunk *remembered_state = 0; | |
4349 | Frame_Chunk *rs; | |
4350 | int is_eh = strcmp (section->name, ".eh_frame") == 0; | |
4351 | unsigned int length_return; | |
4352 | int max_regs = 0; | |
665ce1f6 | 4353 | const char *bad_reg = _("bad register: "); |
604282a7 | 4354 | int saved_eh_addr_size = eh_addr_size; |
19e6b90e | 4355 | |
80c35038 | 4356 | printf (_("Contents of the %s section:\n"), section->name); |
19e6b90e L |
4357 | |
4358 | while (start < end) | |
4359 | { | |
4360 | unsigned char *saved_start; | |
4361 | unsigned char *block_end; | |
4362 | unsigned long length; | |
4363 | unsigned long cie_id; | |
4364 | Frame_Chunk *fc; | |
4365 | Frame_Chunk *cie; | |
4366 | int need_col_headers = 1; | |
4367 | unsigned char *augmentation_data = NULL; | |
4368 | unsigned long augmentation_data_len = 0; | |
604282a7 | 4369 | int encoded_ptr_size = saved_eh_addr_size; |
19e6b90e L |
4370 | int offset_size; |
4371 | int initial_length_size; | |
4372 | ||
4373 | saved_start = start; | |
4374 | length = byte_get (start, 4); start += 4; | |
4375 | ||
4376 | if (length == 0) | |
4377 | { | |
4378 | printf ("\n%08lx ZERO terminator\n\n", | |
4379 | (unsigned long)(saved_start - section_start)); | |
b758e50f | 4380 | continue; |
19e6b90e L |
4381 | } |
4382 | ||
4383 | if (length == 0xffffffff) | |
4384 | { | |
4385 | length = byte_get (start, 8); | |
4386 | start += 8; | |
4387 | offset_size = 8; | |
4388 | initial_length_size = 12; | |
4389 | } | |
4390 | else | |
4391 | { | |
4392 | offset_size = 4; | |
4393 | initial_length_size = 4; | |
4394 | } | |
4395 | ||
4396 | block_end = saved_start + length + initial_length_size; | |
53b8873b NC |
4397 | if (block_end > end) |
4398 | { | |
4399 | warn ("Invalid length %#08lx in FDE at %#08lx\n", | |
4400 | length, (unsigned long)(saved_start - section_start)); | |
4401 | block_end = end; | |
4402 | } | |
19e6b90e L |
4403 | cie_id = byte_get (start, offset_size); start += offset_size; |
4404 | ||
4405 | if (is_eh ? (cie_id == 0) : (cie_id == DW_CIE_ID)) | |
4406 | { | |
4407 | int version; | |
4408 | ||
3f5e193b | 4409 | fc = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk)); |
19e6b90e L |
4410 | memset (fc, 0, sizeof (Frame_Chunk)); |
4411 | ||
4412 | fc->next = chunks; | |
4413 | chunks = fc; | |
4414 | fc->chunk_start = saved_start; | |
4415 | fc->ncols = 0; | |
3f5e193b NC |
4416 | fc->col_type = (short int *) xmalloc (sizeof (short int)); |
4417 | fc->col_offset = (int *) xmalloc (sizeof (int)); | |
cc86f28f | 4418 | frame_need_space (fc, max_regs - 1); |
19e6b90e L |
4419 | |
4420 | version = *start++; | |
4421 | ||
4422 | fc->augmentation = (char *) start; | |
4423 | start = (unsigned char *) strchr ((char *) start, '\0') + 1; | |
4424 | ||
604282a7 JJ |
4425 | if (strcmp (fc->augmentation, "eh") == 0) |
4426 | start += eh_addr_size; | |
4427 | ||
4428 | if (version >= 4) | |
19e6b90e | 4429 | { |
604282a7 JJ |
4430 | fc->ptr_size = GET (1); |
4431 | fc->segment_size = GET (1); | |
4432 | eh_addr_size = fc->ptr_size; | |
19e6b90e | 4433 | } |
604282a7 | 4434 | else |
19e6b90e | 4435 | { |
604282a7 JJ |
4436 | fc->ptr_size = eh_addr_size; |
4437 | fc->segment_size = 0; | |
4438 | } | |
4439 | fc->code_factor = LEB (); | |
4440 | fc->data_factor = SLEB (); | |
4441 | if (version == 1) | |
4442 | { | |
4443 | fc->ra = GET (1); | |
19e6b90e L |
4444 | } |
4445 | else | |
4446 | { | |
604282a7 JJ |
4447 | fc->ra = LEB (); |
4448 | } | |
4449 | ||
4450 | if (fc->augmentation[0] == 'z') | |
4451 | { | |
4452 | augmentation_data_len = LEB (); | |
4453 | augmentation_data = start; | |
4454 | start += augmentation_data_len; | |
19e6b90e L |
4455 | } |
4456 | cie = fc; | |
4457 | ||
4458 | if (do_debug_frames_interp) | |
4459 | printf ("\n%08lx %08lx %08lx CIE \"%s\" cf=%d df=%d ra=%d\n", | |
4460 | (unsigned long)(saved_start - section_start), length, cie_id, | |
4461 | fc->augmentation, fc->code_factor, fc->data_factor, | |
4462 | fc->ra); | |
4463 | else | |
4464 | { | |
4465 | printf ("\n%08lx %08lx %08lx CIE\n", | |
4466 | (unsigned long)(saved_start - section_start), length, cie_id); | |
4467 | printf (" Version: %d\n", version); | |
4468 | printf (" Augmentation: \"%s\"\n", fc->augmentation); | |
604282a7 JJ |
4469 | if (version >= 4) |
4470 | { | |
4471 | printf (" Pointer Size: %u\n", fc->ptr_size); | |
4472 | printf (" Segment Size: %u\n", fc->segment_size); | |
4473 | } | |
19e6b90e L |
4474 | printf (" Code alignment factor: %u\n", fc->code_factor); |
4475 | printf (" Data alignment factor: %d\n", fc->data_factor); | |
4476 | printf (" Return address column: %d\n", fc->ra); | |
4477 | ||
4478 | if (augmentation_data_len) | |
4479 | { | |
4480 | unsigned long i; | |
4481 | printf (" Augmentation data: "); | |
4482 | for (i = 0; i < augmentation_data_len; ++i) | |
4483 | printf (" %02x", augmentation_data[i]); | |
4484 | putchar ('\n'); | |
4485 | } | |
4486 | putchar ('\n'); | |
4487 | } | |
4488 | ||
4489 | if (augmentation_data_len) | |
4490 | { | |
4491 | unsigned char *p, *q; | |
4492 | p = (unsigned char *) fc->augmentation + 1; | |
4493 | q = augmentation_data; | |
4494 | ||
4495 | while (1) | |
4496 | { | |
4497 | if (*p == 'L') | |
4498 | q++; | |
4499 | else if (*p == 'P') | |
4500 | q += 1 + size_of_encoded_value (*q); | |
4501 | else if (*p == 'R') | |
4502 | fc->fde_encoding = *q++; | |
d80e8de2 JB |
4503 | else if (*p == 'S') |
4504 | ; | |
19e6b90e L |
4505 | else |
4506 | break; | |
4507 | p++; | |
4508 | } | |
4509 | ||
4510 | if (fc->fde_encoding) | |
4511 | encoded_ptr_size = size_of_encoded_value (fc->fde_encoding); | |
4512 | } | |
4513 | ||
4514 | frame_need_space (fc, fc->ra); | |
4515 | } | |
4516 | else | |
4517 | { | |
4518 | unsigned char *look_for; | |
4519 | static Frame_Chunk fde_fc; | |
604282a7 | 4520 | unsigned long segment_selector; |
19e6b90e L |
4521 | |
4522 | fc = & fde_fc; | |
4523 | memset (fc, 0, sizeof (Frame_Chunk)); | |
4524 | ||
4525 | look_for = is_eh ? start - 4 - cie_id : section_start + cie_id; | |
4526 | ||
4527 | for (cie = chunks; cie ; cie = cie->next) | |
4528 | if (cie->chunk_start == look_for) | |
4529 | break; | |
4530 | ||
4531 | if (!cie) | |
4532 | { | |
53b8873b | 4533 | warn ("Invalid CIE pointer %#08lx in FDE at %#08lx\n", |
1617e571 | 4534 | cie_id, (unsigned long)(saved_start - section_start)); |
19e6b90e | 4535 | fc->ncols = 0; |
3f5e193b NC |
4536 | fc->col_type = (short int *) xmalloc (sizeof (short int)); |
4537 | fc->col_offset = (int *) xmalloc (sizeof (int)); | |
19e6b90e L |
4538 | frame_need_space (fc, max_regs - 1); |
4539 | cie = fc; | |
4540 | fc->augmentation = ""; | |
4541 | fc->fde_encoding = 0; | |
604282a7 JJ |
4542 | fc->ptr_size = eh_addr_size; |
4543 | fc->segment_size = 0; | |
19e6b90e L |
4544 | } |
4545 | else | |
4546 | { | |
4547 | fc->ncols = cie->ncols; | |
3f5e193b NC |
4548 | fc->col_type = (short int *) xcmalloc (fc->ncols, sizeof (short int)); |
4549 | fc->col_offset = (int *) xcmalloc (fc->ncols, sizeof (int)); | |
19e6b90e L |
4550 | memcpy (fc->col_type, cie->col_type, fc->ncols * sizeof (short int)); |
4551 | memcpy (fc->col_offset, cie->col_offset, fc->ncols * sizeof (int)); | |
4552 | fc->augmentation = cie->augmentation; | |
604282a7 JJ |
4553 | fc->ptr_size = cie->ptr_size; |
4554 | eh_addr_size = cie->ptr_size; | |
4555 | fc->segment_size = cie->segment_size; | |
19e6b90e L |
4556 | fc->code_factor = cie->code_factor; |
4557 | fc->data_factor = cie->data_factor; | |
4558 | fc->cfa_reg = cie->cfa_reg; | |
4559 | fc->cfa_offset = cie->cfa_offset; | |
4560 | fc->ra = cie->ra; | |
cc86f28f | 4561 | frame_need_space (fc, max_regs - 1); |
19e6b90e L |
4562 | fc->fde_encoding = cie->fde_encoding; |
4563 | } | |
4564 | ||
4565 | if (fc->fde_encoding) | |
4566 | encoded_ptr_size = size_of_encoded_value (fc->fde_encoding); | |
4567 | ||
604282a7 JJ |
4568 | segment_selector = 0; |
4569 | if (fc->segment_size) | |
4570 | { | |
4571 | segment_selector = byte_get (start, fc->segment_size); | |
4572 | start += fc->segment_size; | |
4573 | } | |
bad62cf5 | 4574 | fc->pc_begin = get_encoded_value (start, fc->fde_encoding, section); |
19e6b90e L |
4575 | start += encoded_ptr_size; |
4576 | fc->pc_range = byte_get (start, encoded_ptr_size); | |
4577 | start += encoded_ptr_size; | |
4578 | ||
4579 | if (cie->augmentation[0] == 'z') | |
4580 | { | |
4581 | augmentation_data_len = LEB (); | |
4582 | augmentation_data = start; | |
4583 | start += augmentation_data_len; | |
4584 | } | |
4585 | ||
604282a7 | 4586 | printf ("\n%08lx %08lx %08lx FDE cie=%08lx pc=", |
19e6b90e | 4587 | (unsigned long)(saved_start - section_start), length, cie_id, |
604282a7 JJ |
4588 | (unsigned long)(cie->chunk_start - section_start)); |
4589 | if (fc->segment_size) | |
4590 | printf ("%04lx:", segment_selector); | |
4591 | printf ("%08lx..%08lx\n", fc->pc_begin, fc->pc_begin + fc->pc_range); | |
19e6b90e L |
4592 | if (! do_debug_frames_interp && augmentation_data_len) |
4593 | { | |
4594 | unsigned long i; | |
4595 | ||
4596 | printf (" Augmentation data: "); | |
4597 | for (i = 0; i < augmentation_data_len; ++i) | |
4598 | printf (" %02x", augmentation_data[i]); | |
4599 | putchar ('\n'); | |
4600 | putchar ('\n'); | |
4601 | } | |
4602 | } | |
4603 | ||
4604 | /* At this point, fc is the current chunk, cie (if any) is set, and | |
4605 | we're about to interpret instructions for the chunk. */ | |
4606 | /* ??? At present we need to do this always, since this sizes the | |
4607 | fc->col_type and fc->col_offset arrays, which we write into always. | |
4608 | We should probably split the interpreted and non-interpreted bits | |
4609 | into two different routines, since there's so much that doesn't | |
4610 | really overlap between them. */ | |
4611 | if (1 || do_debug_frames_interp) | |
4612 | { | |
4613 | /* Start by making a pass over the chunk, allocating storage | |
4614 | and taking note of what registers are used. */ | |
4615 | unsigned char *tmp = start; | |
4616 | ||
4617 | while (start < block_end) | |
4618 | { | |
4619 | unsigned op, opa; | |
91d6fa6a | 4620 | unsigned long reg, temp; |
19e6b90e L |
4621 | |
4622 | op = *start++; | |
4623 | opa = op & 0x3f; | |
4624 | if (op & 0xc0) | |
4625 | op &= 0xc0; | |
4626 | ||
4627 | /* Warning: if you add any more cases to this switch, be | |
4628 | sure to add them to the corresponding switch below. */ | |
4629 | switch (op) | |
4630 | { | |
4631 | case DW_CFA_advance_loc: | |
4632 | break; | |
4633 | case DW_CFA_offset: | |
4634 | LEB (); | |
665ce1f6 L |
4635 | if (frame_need_space (fc, opa) >= 0) |
4636 | fc->col_type[opa] = DW_CFA_undefined; | |
19e6b90e L |
4637 | break; |
4638 | case DW_CFA_restore: | |
665ce1f6 L |
4639 | if (frame_need_space (fc, opa) >= 0) |
4640 | fc->col_type[opa] = DW_CFA_undefined; | |
19e6b90e L |
4641 | break; |
4642 | case DW_CFA_set_loc: | |
4643 | start += encoded_ptr_size; | |
4644 | break; | |
4645 | case DW_CFA_advance_loc1: | |
4646 | start += 1; | |
4647 | break; | |
4648 | case DW_CFA_advance_loc2: | |
4649 | start += 2; | |
4650 | break; | |
4651 | case DW_CFA_advance_loc4: | |
4652 | start += 4; | |
4653 | break; | |
4654 | case DW_CFA_offset_extended: | |
12eae2d3 | 4655 | case DW_CFA_val_offset: |
19e6b90e | 4656 | reg = LEB (); LEB (); |
665ce1f6 L |
4657 | if (frame_need_space (fc, reg) >= 0) |
4658 | fc->col_type[reg] = DW_CFA_undefined; | |
19e6b90e L |
4659 | break; |
4660 | case DW_CFA_restore_extended: | |
4661 | reg = LEB (); | |
4662 | frame_need_space (fc, reg); | |
665ce1f6 L |
4663 | if (frame_need_space (fc, reg) >= 0) |
4664 | fc->col_type[reg] = DW_CFA_undefined; | |
19e6b90e L |
4665 | break; |
4666 | case DW_CFA_undefined: | |
4667 | reg = LEB (); | |
665ce1f6 L |
4668 | if (frame_need_space (fc, reg) >= 0) |
4669 | fc->col_type[reg] = DW_CFA_undefined; | |
19e6b90e L |
4670 | break; |
4671 | case DW_CFA_same_value: | |
4672 | reg = LEB (); | |
665ce1f6 L |
4673 | if (frame_need_space (fc, reg) >= 0) |
4674 | fc->col_type[reg] = DW_CFA_undefined; | |
19e6b90e L |
4675 | break; |
4676 | case DW_CFA_register: | |
4677 | reg = LEB (); LEB (); | |
665ce1f6 L |
4678 | if (frame_need_space (fc, reg) >= 0) |
4679 | fc->col_type[reg] = DW_CFA_undefined; | |
19e6b90e L |
4680 | break; |
4681 | case DW_CFA_def_cfa: | |
4682 | LEB (); LEB (); | |
4683 | break; | |
4684 | case DW_CFA_def_cfa_register: | |
4685 | LEB (); | |
4686 | break; | |
4687 | case DW_CFA_def_cfa_offset: | |
4688 | LEB (); | |
4689 | break; | |
4690 | case DW_CFA_def_cfa_expression: | |
91d6fa6a NC |
4691 | temp = LEB (); |
4692 | start += temp; | |
19e6b90e L |
4693 | break; |
4694 | case DW_CFA_expression: | |
12eae2d3 | 4695 | case DW_CFA_val_expression: |
19e6b90e | 4696 | reg = LEB (); |
91d6fa6a NC |
4697 | temp = LEB (); |
4698 | start += temp; | |
665ce1f6 L |
4699 | if (frame_need_space (fc, reg) >= 0) |
4700 | fc->col_type[reg] = DW_CFA_undefined; | |
19e6b90e L |
4701 | break; |
4702 | case DW_CFA_offset_extended_sf: | |
12eae2d3 | 4703 | case DW_CFA_val_offset_sf: |
19e6b90e | 4704 | reg = LEB (); SLEB (); |
665ce1f6 L |
4705 | if (frame_need_space (fc, reg) >= 0) |
4706 | fc->col_type[reg] = DW_CFA_undefined; | |
19e6b90e L |
4707 | break; |
4708 | case DW_CFA_def_cfa_sf: | |
4709 | LEB (); SLEB (); | |
4710 | break; | |
4711 | case DW_CFA_def_cfa_offset_sf: | |
4712 | SLEB (); | |
4713 | break; | |
4714 | case DW_CFA_MIPS_advance_loc8: | |
4715 | start += 8; | |
4716 | break; | |
4717 | case DW_CFA_GNU_args_size: | |
4718 | LEB (); | |
4719 | break; | |
4720 | case DW_CFA_GNU_negative_offset_extended: | |
4721 | reg = LEB (); LEB (); | |
665ce1f6 L |
4722 | if (frame_need_space (fc, reg) >= 0) |
4723 | fc->col_type[reg] = DW_CFA_undefined; | |
4724 | break; | |
19e6b90e L |
4725 | default: |
4726 | break; | |
4727 | } | |
4728 | } | |
4729 | start = tmp; | |
4730 | } | |
4731 | ||
4732 | /* Now we know what registers are used, make a second pass over | |
4733 | the chunk, this time actually printing out the info. */ | |
4734 | ||
4735 | while (start < block_end) | |
4736 | { | |
4737 | unsigned op, opa; | |
4738 | unsigned long ul, reg, roffs; | |
4739 | long l, ofs; | |
4740 | dwarf_vma vma; | |
665ce1f6 | 4741 | const char *reg_prefix = ""; |
19e6b90e L |
4742 | |
4743 | op = *start++; | |
4744 | opa = op & 0x3f; | |
4745 | if (op & 0xc0) | |
4746 | op &= 0xc0; | |
4747 | ||
4748 | /* Warning: if you add any more cases to this switch, be | |
4749 | sure to add them to the corresponding switch above. */ | |
4750 | switch (op) | |
4751 | { | |
4752 | case DW_CFA_advance_loc: | |
4753 | if (do_debug_frames_interp) | |
4754 | frame_display_row (fc, &need_col_headers, &max_regs); | |
4755 | else | |
4756 | printf (" DW_CFA_advance_loc: %d to %08lx\n", | |
4757 | opa * fc->code_factor, | |
4758 | fc->pc_begin + opa * fc->code_factor); | |
4759 | fc->pc_begin += opa * fc->code_factor; | |
4760 | break; | |
4761 | ||
4762 | case DW_CFA_offset: | |
4763 | roffs = LEB (); | |
665ce1f6 L |
4764 | if (opa >= (unsigned int) fc->ncols) |
4765 | reg_prefix = bad_reg; | |
4766 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
4767 | printf (" DW_CFA_offset: %s%s at cfa%+ld\n", | |
4768 | reg_prefix, regname (opa, 0), | |
4769 | roffs * fc->data_factor); | |
4770 | if (*reg_prefix == '\0') | |
4771 | { | |
4772 | fc->col_type[opa] = DW_CFA_offset; | |
4773 | fc->col_offset[opa] = roffs * fc->data_factor; | |
4774 | } | |
19e6b90e L |
4775 | break; |
4776 | ||
4777 | case DW_CFA_restore: | |
665ce1f6 L |
4778 | if (opa >= (unsigned int) cie->ncols |
4779 | || opa >= (unsigned int) fc->ncols) | |
4780 | reg_prefix = bad_reg; | |
4781 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
4782 | printf (" DW_CFA_restore: %s%s\n", | |
4783 | reg_prefix, regname (opa, 0)); | |
4784 | if (*reg_prefix == '\0') | |
4785 | { | |
4786 | fc->col_type[opa] = cie->col_type[opa]; | |
4787 | fc->col_offset[opa] = cie->col_offset[opa]; | |
4788 | } | |
19e6b90e L |
4789 | break; |
4790 | ||
4791 | case DW_CFA_set_loc: | |
bad62cf5 | 4792 | vma = get_encoded_value (start, fc->fde_encoding, section); |
19e6b90e L |
4793 | start += encoded_ptr_size; |
4794 | if (do_debug_frames_interp) | |
4795 | frame_display_row (fc, &need_col_headers, &max_regs); | |
4796 | else | |
4797 | printf (" DW_CFA_set_loc: %08lx\n", (unsigned long)vma); | |
4798 | fc->pc_begin = vma; | |
4799 | break; | |
4800 | ||
4801 | case DW_CFA_advance_loc1: | |
4802 | ofs = byte_get (start, 1); start += 1; | |
4803 | if (do_debug_frames_interp) | |
4804 | frame_display_row (fc, &need_col_headers, &max_regs); | |
4805 | else | |
4806 | printf (" DW_CFA_advance_loc1: %ld to %08lx\n", | |
4807 | ofs * fc->code_factor, | |
4808 | fc->pc_begin + ofs * fc->code_factor); | |
4809 | fc->pc_begin += ofs * fc->code_factor; | |
4810 | break; | |
4811 | ||
4812 | case DW_CFA_advance_loc2: | |
4813 | ofs = byte_get (start, 2); start += 2; | |
4814 | if (do_debug_frames_interp) | |
4815 | frame_display_row (fc, &need_col_headers, &max_regs); | |
4816 | else | |
4817 | printf (" DW_CFA_advance_loc2: %ld to %08lx\n", | |
4818 | ofs * fc->code_factor, | |
4819 | fc->pc_begin + ofs * fc->code_factor); | |
4820 | fc->pc_begin += ofs * fc->code_factor; | |
4821 | break; | |
4822 | ||
4823 | case DW_CFA_advance_loc4: | |
4824 | ofs = byte_get (start, 4); start += 4; | |
4825 | if (do_debug_frames_interp) | |
4826 | frame_display_row (fc, &need_col_headers, &max_regs); | |
4827 | else | |
4828 | printf (" DW_CFA_advance_loc4: %ld to %08lx\n", | |
4829 | ofs * fc->code_factor, | |
4830 | fc->pc_begin + ofs * fc->code_factor); | |
4831 | fc->pc_begin += ofs * fc->code_factor; | |
4832 | break; | |
4833 | ||
4834 | case DW_CFA_offset_extended: | |
4835 | reg = LEB (); | |
4836 | roffs = LEB (); | |
665ce1f6 L |
4837 | if (reg >= (unsigned int) fc->ncols) |
4838 | reg_prefix = bad_reg; | |
4839 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
4840 | printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n", | |
4841 | reg_prefix, regname (reg, 0), | |
4842 | roffs * fc->data_factor); | |
4843 | if (*reg_prefix == '\0') | |
4844 | { | |
4845 | fc->col_type[reg] = DW_CFA_offset; | |
4846 | fc->col_offset[reg] = roffs * fc->data_factor; | |
4847 | } | |
19e6b90e L |
4848 | break; |
4849 | ||
12eae2d3 JJ |
4850 | case DW_CFA_val_offset: |
4851 | reg = LEB (); | |
4852 | roffs = LEB (); | |
665ce1f6 L |
4853 | if (reg >= (unsigned int) fc->ncols) |
4854 | reg_prefix = bad_reg; | |
4855 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
4856 | printf (" DW_CFA_val_offset: %s%s at cfa%+ld\n", | |
4857 | reg_prefix, regname (reg, 0), | |
4858 | roffs * fc->data_factor); | |
4859 | if (*reg_prefix == '\0') | |
4860 | { | |
4861 | fc->col_type[reg] = DW_CFA_val_offset; | |
4862 | fc->col_offset[reg] = roffs * fc->data_factor; | |
4863 | } | |
12eae2d3 JJ |
4864 | break; |
4865 | ||
19e6b90e L |
4866 | case DW_CFA_restore_extended: |
4867 | reg = LEB (); | |
665ce1f6 L |
4868 | if (reg >= (unsigned int) cie->ncols |
4869 | || reg >= (unsigned int) fc->ncols) | |
4870 | reg_prefix = bad_reg; | |
4871 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
4872 | printf (" DW_CFA_restore_extended: %s%s\n", | |
4873 | reg_prefix, regname (reg, 0)); | |
4874 | if (*reg_prefix == '\0') | |
4875 | { | |
4876 | fc->col_type[reg] = cie->col_type[reg]; | |
4877 | fc->col_offset[reg] = cie->col_offset[reg]; | |
4878 | } | |
19e6b90e L |
4879 | break; |
4880 | ||
4881 | case DW_CFA_undefined: | |
4882 | reg = LEB (); | |
665ce1f6 L |
4883 | if (reg >= (unsigned int) fc->ncols) |
4884 | reg_prefix = bad_reg; | |
4885 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
4886 | printf (" DW_CFA_undefined: %s%s\n", | |
4887 | reg_prefix, regname (reg, 0)); | |
4888 | if (*reg_prefix == '\0') | |
4889 | { | |
4890 | fc->col_type[reg] = DW_CFA_undefined; | |
4891 | fc->col_offset[reg] = 0; | |
4892 | } | |
19e6b90e L |
4893 | break; |
4894 | ||
4895 | case DW_CFA_same_value: | |
4896 | reg = LEB (); | |
665ce1f6 L |
4897 | if (reg >= (unsigned int) fc->ncols) |
4898 | reg_prefix = bad_reg; | |
4899 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
4900 | printf (" DW_CFA_same_value: %s%s\n", | |
4901 | reg_prefix, regname (reg, 0)); | |
4902 | if (*reg_prefix == '\0') | |
4903 | { | |
4904 | fc->col_type[reg] = DW_CFA_same_value; | |
4905 | fc->col_offset[reg] = 0; | |
4906 | } | |
19e6b90e L |
4907 | break; |
4908 | ||
4909 | case DW_CFA_register: | |
4910 | reg = LEB (); | |
4911 | roffs = LEB (); | |
665ce1f6 L |
4912 | if (reg >= (unsigned int) fc->ncols) |
4913 | reg_prefix = bad_reg; | |
4914 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
2dc4cec1 | 4915 | { |
665ce1f6 L |
4916 | printf (" DW_CFA_register: %s%s in ", |
4917 | reg_prefix, regname (reg, 0)); | |
2dc4cec1 L |
4918 | puts (regname (roffs, 0)); |
4919 | } | |
665ce1f6 L |
4920 | if (*reg_prefix == '\0') |
4921 | { | |
4922 | fc->col_type[reg] = DW_CFA_register; | |
4923 | fc->col_offset[reg] = roffs; | |
4924 | } | |
19e6b90e L |
4925 | break; |
4926 | ||
4927 | case DW_CFA_remember_state: | |
4928 | if (! do_debug_frames_interp) | |
4929 | printf (" DW_CFA_remember_state\n"); | |
3f5e193b | 4930 | rs = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk)); |
19e6b90e | 4931 | rs->ncols = fc->ncols; |
3f5e193b NC |
4932 | rs->col_type = (short int *) xcmalloc (rs->ncols, |
4933 | sizeof (short int)); | |
4934 | rs->col_offset = (int *) xcmalloc (rs->ncols, sizeof (int)); | |
19e6b90e L |
4935 | memcpy (rs->col_type, fc->col_type, rs->ncols); |
4936 | memcpy (rs->col_offset, fc->col_offset, rs->ncols * sizeof (int)); | |
4937 | rs->next = remembered_state; | |
4938 | remembered_state = rs; | |
4939 | break; | |
4940 | ||
4941 | case DW_CFA_restore_state: | |
4942 | if (! do_debug_frames_interp) | |
4943 | printf (" DW_CFA_restore_state\n"); | |
4944 | rs = remembered_state; | |
4945 | if (rs) | |
4946 | { | |
4947 | remembered_state = rs->next; | |
cc86f28f | 4948 | frame_need_space (fc, rs->ncols - 1); |
19e6b90e L |
4949 | memcpy (fc->col_type, rs->col_type, rs->ncols); |
4950 | memcpy (fc->col_offset, rs->col_offset, | |
4951 | rs->ncols * sizeof (int)); | |
4952 | free (rs->col_type); | |
4953 | free (rs->col_offset); | |
4954 | free (rs); | |
4955 | } | |
4956 | else if (do_debug_frames_interp) | |
4957 | printf ("Mismatched DW_CFA_restore_state\n"); | |
4958 | break; | |
4959 | ||
4960 | case DW_CFA_def_cfa: | |
4961 | fc->cfa_reg = LEB (); | |
4962 | fc->cfa_offset = LEB (); | |
4963 | fc->cfa_exp = 0; | |
4964 | if (! do_debug_frames_interp) | |
2dc4cec1 L |
4965 | printf (" DW_CFA_def_cfa: %s ofs %d\n", |
4966 | regname (fc->cfa_reg, 0), fc->cfa_offset); | |
19e6b90e L |
4967 | break; |
4968 | ||
4969 | case DW_CFA_def_cfa_register: | |
4970 | fc->cfa_reg = LEB (); | |
4971 | fc->cfa_exp = 0; | |
4972 | if (! do_debug_frames_interp) | |
2dc4cec1 L |
4973 | printf (" DW_CFA_def_cfa_register: %s\n", |
4974 | regname (fc->cfa_reg, 0)); | |
19e6b90e L |
4975 | break; |
4976 | ||
4977 | case DW_CFA_def_cfa_offset: | |
4978 | fc->cfa_offset = LEB (); | |
4979 | if (! do_debug_frames_interp) | |
4980 | printf (" DW_CFA_def_cfa_offset: %d\n", fc->cfa_offset); | |
4981 | break; | |
4982 | ||
4983 | case DW_CFA_nop: | |
4984 | if (! do_debug_frames_interp) | |
4985 | printf (" DW_CFA_nop\n"); | |
4986 | break; | |
4987 | ||
4988 | case DW_CFA_def_cfa_expression: | |
4989 | ul = LEB (); | |
4990 | if (! do_debug_frames_interp) | |
4991 | { | |
4992 | printf (" DW_CFA_def_cfa_expression ("); | |
b7807392 JJ |
4993 | decode_location_expression (start, eh_addr_size, 0, -1, |
4994 | ul, 0, section); | |
19e6b90e L |
4995 | printf (")\n"); |
4996 | } | |
4997 | fc->cfa_exp = 1; | |
4998 | start += ul; | |
4999 | break; | |
5000 | ||
5001 | case DW_CFA_expression: | |
5002 | reg = LEB (); | |
5003 | ul = LEB (); | |
665ce1f6 L |
5004 | if (reg >= (unsigned int) fc->ncols) |
5005 | reg_prefix = bad_reg; | |
5006 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
19e6b90e | 5007 | { |
665ce1f6 L |
5008 | printf (" DW_CFA_expression: %s%s (", |
5009 | reg_prefix, regname (reg, 0)); | |
b7807392 | 5010 | decode_location_expression (start, eh_addr_size, 0, -1, |
f1c4cc75 | 5011 | ul, 0, section); |
19e6b90e L |
5012 | printf (")\n"); |
5013 | } | |
665ce1f6 L |
5014 | if (*reg_prefix == '\0') |
5015 | fc->col_type[reg] = DW_CFA_expression; | |
19e6b90e L |
5016 | start += ul; |
5017 | break; | |
5018 | ||
12eae2d3 JJ |
5019 | case DW_CFA_val_expression: |
5020 | reg = LEB (); | |
5021 | ul = LEB (); | |
665ce1f6 L |
5022 | if (reg >= (unsigned int) fc->ncols) |
5023 | reg_prefix = bad_reg; | |
5024 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
12eae2d3 | 5025 | { |
665ce1f6 L |
5026 | printf (" DW_CFA_val_expression: %s%s (", |
5027 | reg_prefix, regname (reg, 0)); | |
b7807392 JJ |
5028 | decode_location_expression (start, eh_addr_size, 0, -1, |
5029 | ul, 0, section); | |
12eae2d3 JJ |
5030 | printf (")\n"); |
5031 | } | |
665ce1f6 L |
5032 | if (*reg_prefix == '\0') |
5033 | fc->col_type[reg] = DW_CFA_val_expression; | |
12eae2d3 JJ |
5034 | start += ul; |
5035 | break; | |
5036 | ||
19e6b90e L |
5037 | case DW_CFA_offset_extended_sf: |
5038 | reg = LEB (); | |
5039 | l = SLEB (); | |
665ce1f6 L |
5040 | if (frame_need_space (fc, reg) < 0) |
5041 | reg_prefix = bad_reg; | |
5042 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
5043 | printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n", | |
5044 | reg_prefix, regname (reg, 0), | |
5045 | l * fc->data_factor); | |
5046 | if (*reg_prefix == '\0') | |
5047 | { | |
5048 | fc->col_type[reg] = DW_CFA_offset; | |
5049 | fc->col_offset[reg] = l * fc->data_factor; | |
5050 | } | |
19e6b90e L |
5051 | break; |
5052 | ||
12eae2d3 JJ |
5053 | case DW_CFA_val_offset_sf: |
5054 | reg = LEB (); | |
5055 | l = SLEB (); | |
665ce1f6 L |
5056 | if (frame_need_space (fc, reg) < 0) |
5057 | reg_prefix = bad_reg; | |
5058 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
5059 | printf (" DW_CFA_val_offset_sf: %s%s at cfa%+ld\n", | |
5060 | reg_prefix, regname (reg, 0), | |
5061 | l * fc->data_factor); | |
5062 | if (*reg_prefix == '\0') | |
5063 | { | |
5064 | fc->col_type[reg] = DW_CFA_val_offset; | |
5065 | fc->col_offset[reg] = l * fc->data_factor; | |
5066 | } | |
12eae2d3 JJ |
5067 | break; |
5068 | ||
19e6b90e L |
5069 | case DW_CFA_def_cfa_sf: |
5070 | fc->cfa_reg = LEB (); | |
5071 | fc->cfa_offset = SLEB (); | |
5072 | fc->cfa_offset = fc->cfa_offset * fc->data_factor; | |
5073 | fc->cfa_exp = 0; | |
5074 | if (! do_debug_frames_interp) | |
2dc4cec1 L |
5075 | printf (" DW_CFA_def_cfa_sf: %s ofs %d\n", |
5076 | regname (fc->cfa_reg, 0), fc->cfa_offset); | |
19e6b90e L |
5077 | break; |
5078 | ||
5079 | case DW_CFA_def_cfa_offset_sf: | |
5080 | fc->cfa_offset = SLEB (); | |
5081 | fc->cfa_offset = fc->cfa_offset * fc->data_factor; | |
5082 | if (! do_debug_frames_interp) | |
5083 | printf (" DW_CFA_def_cfa_offset_sf: %d\n", fc->cfa_offset); | |
5084 | break; | |
5085 | ||
5086 | case DW_CFA_MIPS_advance_loc8: | |
5087 | ofs = byte_get (start, 8); start += 8; | |
5088 | if (do_debug_frames_interp) | |
5089 | frame_display_row (fc, &need_col_headers, &max_regs); | |
5090 | else | |
5091 | printf (" DW_CFA_MIPS_advance_loc8: %ld to %08lx\n", | |
5092 | ofs * fc->code_factor, | |
5093 | fc->pc_begin + ofs * fc->code_factor); | |
5094 | fc->pc_begin += ofs * fc->code_factor; | |
5095 | break; | |
5096 | ||
5097 | case DW_CFA_GNU_window_save: | |
5098 | if (! do_debug_frames_interp) | |
5099 | printf (" DW_CFA_GNU_window_save\n"); | |
5100 | break; | |
5101 | ||
5102 | case DW_CFA_GNU_args_size: | |
5103 | ul = LEB (); | |
5104 | if (! do_debug_frames_interp) | |
5105 | printf (" DW_CFA_GNU_args_size: %ld\n", ul); | |
5106 | break; | |
5107 | ||
5108 | case DW_CFA_GNU_negative_offset_extended: | |
5109 | reg = LEB (); | |
5110 | l = - LEB (); | |
665ce1f6 L |
5111 | if (frame_need_space (fc, reg) < 0) |
5112 | reg_prefix = bad_reg; | |
5113 | if (! do_debug_frames_interp || *reg_prefix != '\0') | |
5114 | printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n", | |
5115 | reg_prefix, regname (reg, 0), | |
5116 | l * fc->data_factor); | |
5117 | if (*reg_prefix == '\0') | |
5118 | { | |
5119 | fc->col_type[reg] = DW_CFA_offset; | |
5120 | fc->col_offset[reg] = l * fc->data_factor; | |
5121 | } | |
19e6b90e L |
5122 | break; |
5123 | ||
5124 | default: | |
53b8873b NC |
5125 | if (op >= DW_CFA_lo_user && op <= DW_CFA_hi_user) |
5126 | printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op); | |
5127 | else | |
cecf136e | 5128 | warn (_("unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op); |
19e6b90e L |
5129 | start = block_end; |
5130 | } | |
5131 | } | |
5132 | ||
5133 | if (do_debug_frames_interp) | |
5134 | frame_display_row (fc, &need_col_headers, &max_regs); | |
5135 | ||
5136 | start = block_end; | |
604282a7 | 5137 | eh_addr_size = saved_eh_addr_size; |
19e6b90e L |
5138 | } |
5139 | ||
5140 | printf ("\n"); | |
5141 | ||
5142 | return 1; | |
5143 | } | |
5144 | ||
5145 | #undef GET | |
5146 | #undef LEB | |
5147 | #undef SLEB | |
5148 | ||
5bbdf3d5 DE |
5149 | static int |
5150 | display_gdb_index (struct dwarf_section *section, | |
5151 | void *file ATTRIBUTE_UNUSED) | |
5152 | { | |
5153 | unsigned char *start = section->start; | |
5154 | uint32_t version; | |
5155 | uint32_t cu_list_offset, tu_list_offset; | |
5156 | uint32_t address_table_offset, symbol_table_offset, constant_pool_offset; | |
5157 | unsigned int cu_list_elements, tu_list_elements; | |
5158 | unsigned int address_table_size, symbol_table_slots; | |
5159 | unsigned char *cu_list, *tu_list; | |
5160 | unsigned char *address_table, *symbol_table, *constant_pool; | |
5161 | unsigned int i; | |
5162 | ||
5163 | /* The documentation for the format of this file is in gdb/dwarf2read.c. */ | |
5164 | ||
5165 | printf (_("Contents of the %s section:\n"), section->name); | |
5166 | ||
5167 | if (section->size < 6 * sizeof (uint32_t)) | |
5168 | { | |
5169 | warn (_("Truncated header in the %s section.\n"), section->name); | |
5170 | return 0; | |
5171 | } | |
5172 | ||
5173 | version = byte_get_little_endian (start, 4); | |
da88a764 | 5174 | printf (_("Version %ld\n"), (long) version); |
5bbdf3d5 DE |
5175 | |
5176 | /* Prior versions are obsolete, and future versions may not be | |
5177 | backwards compatible. */ | |
6ec8b48e | 5178 | switch (version) |
5bbdf3d5 | 5179 | { |
6ec8b48e JK |
5180 | case 3: |
5181 | warn (_("The address table data in version 3 may be wrong.\n")); | |
5182 | break; | |
5183 | case 4: | |
6adc060c JK |
5184 | warn (_("Version 4 does not support case insensitive lookups.\n")); |
5185 | break; | |
5186 | case 5: | |
6ec8b48e JK |
5187 | break; |
5188 | default: | |
da88a764 | 5189 | warn (_("Unsupported version %lu.\n"), (unsigned long) version); |
5bbdf3d5 DE |
5190 | return 0; |
5191 | } | |
5192 | ||
5193 | cu_list_offset = byte_get_little_endian (start + 4, 4); | |
5194 | tu_list_offset = byte_get_little_endian (start + 8, 4); | |
5195 | address_table_offset = byte_get_little_endian (start + 12, 4); | |
5196 | symbol_table_offset = byte_get_little_endian (start + 16, 4); | |
5197 | constant_pool_offset = byte_get_little_endian (start + 20, 4); | |
5198 | ||
5199 | if (cu_list_offset > section->size | |
5200 | || tu_list_offset > section->size | |
5201 | || address_table_offset > section->size | |
5202 | || symbol_table_offset > section->size | |
5203 | || constant_pool_offset > section->size) | |
5204 | { | |
5205 | warn (_("Corrupt header in the %s section.\n"), section->name); | |
5206 | return 0; | |
5207 | } | |
5208 | ||
5209 | cu_list_elements = (tu_list_offset - cu_list_offset) / 8; | |
5210 | tu_list_elements = (address_table_offset - tu_list_offset) / 8; | |
5211 | address_table_size = symbol_table_offset - address_table_offset; | |
5212 | symbol_table_slots = (constant_pool_offset - symbol_table_offset) / 8; | |
5213 | ||
5214 | cu_list = start + cu_list_offset; | |
5215 | tu_list = start + tu_list_offset; | |
5216 | address_table = start + address_table_offset; | |
5217 | symbol_table = start + symbol_table_offset; | |
5218 | constant_pool = start + constant_pool_offset; | |
5219 | ||
5220 | printf (_("\nCU table:\n")); | |
5221 | for (i = 0; i < cu_list_elements; i += 2) | |
5222 | { | |
5223 | uint64_t cu_offset = byte_get_little_endian (cu_list + i * 8, 8); | |
5224 | uint64_t cu_length = byte_get_little_endian (cu_list + i * 8 + 8, 8); | |
5225 | ||
5226 | printf (_("[%3u] 0x%lx - 0x%lx\n"), i / 2, | |
5227 | (unsigned long) cu_offset, | |
5228 | (unsigned long) (cu_offset + cu_length - 1)); | |
5229 | } | |
5230 | ||
5231 | printf (_("\nTU table:\n")); | |
5232 | for (i = 0; i < tu_list_elements; i += 3) | |
5233 | { | |
5234 | uint64_t tu_offset = byte_get_little_endian (tu_list + i * 8, 8); | |
5235 | uint64_t type_offset = byte_get_little_endian (tu_list + i * 8 + 8, 8); | |
5236 | uint64_t signature = byte_get_little_endian (tu_list + i * 8 + 16, 8); | |
5237 | ||
5238 | printf (_("[%3u] 0x%lx 0x%lx "), i / 3, | |
5239 | (unsigned long) tu_offset, | |
5240 | (unsigned long) type_offset); | |
5241 | print_dwarf_vma (signature, 8); | |
5242 | printf ("\n"); | |
5243 | } | |
5244 | ||
5245 | printf (_("\nAddress table:\n")); | |
5246 | for (i = 0; i < address_table_size; i += 2 * 8 + 4) | |
5247 | { | |
5248 | uint64_t low = byte_get_little_endian (address_table + i, 8); | |
5249 | uint64_t high = byte_get_little_endian (address_table + i + 8, 8); | |
5250 | uint32_t cu_index = byte_get_little_endian (address_table + i + 16, 4); | |
5251 | ||
5252 | print_dwarf_vma (low, 8); | |
5253 | print_dwarf_vma (high, 8); | |
da88a764 | 5254 | printf (_("%lu\n"), (unsigned long) cu_index); |
5bbdf3d5 DE |
5255 | } |
5256 | ||
5257 | printf (_("\nSymbol table:\n")); | |
5258 | for (i = 0; i < symbol_table_slots; ++i) | |
5259 | { | |
5260 | uint32_t name_offset = byte_get_little_endian (symbol_table + i * 8, 4); | |
5261 | uint32_t cu_vector_offset = byte_get_little_endian (symbol_table + i * 8 + 4, 4); | |
5262 | uint32_t num_cus, cu; | |
5263 | ||
5264 | if (name_offset != 0 | |
5265 | || cu_vector_offset != 0) | |
5266 | { | |
5267 | unsigned int j; | |
5268 | ||
5269 | printf ("[%3u] %s:", i, constant_pool + name_offset); | |
5270 | num_cus = byte_get_little_endian (constant_pool + cu_vector_offset, 4); | |
5271 | for (j = 0; j < num_cus; ++j) | |
5272 | { | |
5273 | cu = byte_get_little_endian (constant_pool + cu_vector_offset + 4 + j * 4, 4); | |
5274 | /* Convert to TU number if it's for a type unit. */ | |
ad6b52dd CC |
5275 | if (cu >= cu_list_elements / 2) |
5276 | printf (" T%lu", (unsigned long) (cu - cu_list_elements / 2)); | |
5bbdf3d5 | 5277 | else |
da88a764 | 5278 | printf (" %lu", (unsigned long) cu); |
5bbdf3d5 DE |
5279 | } |
5280 | printf ("\n"); | |
5281 | } | |
5282 | } | |
5283 | ||
5284 | return 1; | |
5285 | } | |
5286 | ||
19e6b90e L |
5287 | static int |
5288 | display_debug_not_supported (struct dwarf_section *section, | |
5289 | void *file ATTRIBUTE_UNUSED) | |
5290 | { | |
5291 | printf (_("Displaying the debug contents of section %s is not yet supported.\n"), | |
5292 | section->name); | |
5293 | ||
5294 | return 1; | |
5295 | } | |
5296 | ||
5297 | void * | |
5298 | cmalloc (size_t nmemb, size_t size) | |
5299 | { | |
5300 | /* Check for overflow. */ | |
5301 | if (nmemb >= ~(size_t) 0 / size) | |
5302 | return NULL; | |
5303 | else | |
5304 | return malloc (nmemb * size); | |
5305 | } | |
5306 | ||
5307 | void * | |
5308 | xcmalloc (size_t nmemb, size_t size) | |
5309 | { | |
5310 | /* Check for overflow. */ | |
5311 | if (nmemb >= ~(size_t) 0 / size) | |
5312 | return NULL; | |
5313 | else | |
5314 | return xmalloc (nmemb * size); | |
5315 | } | |
5316 | ||
5317 | void * | |
5318 | xcrealloc (void *ptr, size_t nmemb, size_t size) | |
5319 | { | |
5320 | /* Check for overflow. */ | |
5321 | if (nmemb >= ~(size_t) 0 / size) | |
5322 | return NULL; | |
5323 | else | |
5324 | return xrealloc (ptr, nmemb * size); | |
5325 | } | |
5326 | ||
19e6b90e L |
5327 | void |
5328 | free_debug_memory (void) | |
5329 | { | |
3f5e193b | 5330 | unsigned int i; |
19e6b90e L |
5331 | |
5332 | free_abbrevs (); | |
5333 | ||
5334 | for (i = 0; i < max; i++) | |
3f5e193b | 5335 | free_debug_section ((enum dwarf_section_display_enum) i); |
19e6b90e | 5336 | |
cc86f28f | 5337 | if (debug_information != NULL) |
19e6b90e | 5338 | { |
cc86f28f | 5339 | if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE) |
19e6b90e | 5340 | { |
cc86f28f | 5341 | for (i = 0; i < num_debug_info_entries; i++) |
19e6b90e | 5342 | { |
cc86f28f NC |
5343 | if (!debug_information [i].max_loc_offsets) |
5344 | { | |
5345 | free (debug_information [i].loc_offsets); | |
5346 | free (debug_information [i].have_frame_base); | |
5347 | } | |
5348 | if (!debug_information [i].max_range_lists) | |
5349 | free (debug_information [i].range_lists); | |
19e6b90e | 5350 | } |
19e6b90e | 5351 | } |
cc86f28f | 5352 | |
19e6b90e L |
5353 | free (debug_information); |
5354 | debug_information = NULL; | |
5355 | num_debug_info_entries = 0; | |
5356 | } | |
19e6b90e L |
5357 | } |
5358 | ||
4cb93e3b TG |
5359 | void |
5360 | dwarf_select_sections_by_names (const char *names) | |
5361 | { | |
5362 | typedef struct | |
5363 | { | |
5364 | const char * option; | |
5365 | int * variable; | |
f9f0e732 | 5366 | int val; |
4cb93e3b TG |
5367 | } |
5368 | debug_dump_long_opts; | |
5369 | ||
5370 | static const debug_dump_long_opts opts_table [] = | |
5371 | { | |
5372 | /* Please keep this table alpha- sorted. */ | |
5373 | { "Ranges", & do_debug_ranges, 1 }, | |
5374 | { "abbrev", & do_debug_abbrevs, 1 }, | |
5375 | { "aranges", & do_debug_aranges, 1 }, | |
5376 | { "frames", & do_debug_frames, 1 }, | |
5377 | { "frames-interp", & do_debug_frames_interp, 1 }, | |
5378 | { "info", & do_debug_info, 1 }, | |
5379 | { "line", & do_debug_lines, FLAG_DEBUG_LINES_RAW }, /* For backwards compatibility. */ | |
5380 | { "rawline", & do_debug_lines, FLAG_DEBUG_LINES_RAW }, | |
5381 | { "decodedline", & do_debug_lines, FLAG_DEBUG_LINES_DECODED }, | |
5382 | { "loc", & do_debug_loc, 1 }, | |
5383 | { "macro", & do_debug_macinfo, 1 }, | |
5384 | { "pubnames", & do_debug_pubnames, 1 }, | |
357da287 | 5385 | { "pubtypes", & do_debug_pubtypes, 1 }, |
4cb93e3b TG |
5386 | /* This entry is for compatability |
5387 | with earlier versions of readelf. */ | |
5388 | { "ranges", & do_debug_aranges, 1 }, | |
5389 | { "str", & do_debug_str, 1 }, | |
5bbdf3d5 DE |
5390 | /* The special .gdb_index section. */ |
5391 | { "gdb_index", & do_gdb_index, 1 }, | |
6f875884 TG |
5392 | /* These trace_* sections are used by Itanium VMS. */ |
5393 | { "trace_abbrev", & do_trace_abbrevs, 1 }, | |
5394 | { "trace_aranges", & do_trace_aranges, 1 }, | |
5395 | { "trace_info", & do_trace_info, 1 }, | |
4cb93e3b TG |
5396 | { NULL, NULL, 0 } |
5397 | }; | |
5398 | ||
5399 | const char *p; | |
467c65bc | 5400 | |
4cb93e3b TG |
5401 | p = names; |
5402 | while (*p) | |
5403 | { | |
5404 | const debug_dump_long_opts * entry; | |
467c65bc | 5405 | |
4cb93e3b TG |
5406 | for (entry = opts_table; entry->option; entry++) |
5407 | { | |
5408 | size_t len = strlen (entry->option); | |
467c65bc | 5409 | |
4cb93e3b TG |
5410 | if (strncmp (p, entry->option, len) == 0 |
5411 | && (p[len] == ',' || p[len] == '\0')) | |
5412 | { | |
5413 | * entry->variable |= entry->val; | |
467c65bc | 5414 | |
4cb93e3b TG |
5415 | /* The --debug-dump=frames-interp option also |
5416 | enables the --debug-dump=frames option. */ | |
5417 | if (do_debug_frames_interp) | |
5418 | do_debug_frames = 1; | |
5419 | ||
5420 | p += len; | |
5421 | break; | |
5422 | } | |
5423 | } | |
467c65bc | 5424 | |
4cb93e3b TG |
5425 | if (entry->option == NULL) |
5426 | { | |
5427 | warn (_("Unrecognized debug option '%s'\n"), p); | |
5428 | p = strchr (p, ','); | |
5429 | if (p == NULL) | |
5430 | break; | |
5431 | } | |
467c65bc | 5432 | |
4cb93e3b TG |
5433 | if (*p == ',') |
5434 | p++; | |
5435 | } | |
5436 | } | |
5437 | ||
5438 | void | |
5439 | dwarf_select_sections_by_letters (const char *letters) | |
5440 | { | |
91d6fa6a | 5441 | unsigned int lindex = 0; |
4cb93e3b | 5442 | |
91d6fa6a NC |
5443 | while (letters[lindex]) |
5444 | switch (letters[lindex++]) | |
4cb93e3b TG |
5445 | { |
5446 | case 'i': | |
5447 | do_debug_info = 1; | |
5448 | break; | |
467c65bc | 5449 | |
4cb93e3b TG |
5450 | case 'a': |
5451 | do_debug_abbrevs = 1; | |
5452 | break; | |
467c65bc | 5453 | |
4cb93e3b TG |
5454 | case 'l': |
5455 | do_debug_lines |= FLAG_DEBUG_LINES_RAW; | |
5456 | break; | |
467c65bc | 5457 | |
4cb93e3b TG |
5458 | case 'L': |
5459 | do_debug_lines |= FLAG_DEBUG_LINES_DECODED; | |
5460 | break; | |
467c65bc | 5461 | |
4cb93e3b TG |
5462 | case 'p': |
5463 | do_debug_pubnames = 1; | |
5464 | break; | |
467c65bc | 5465 | |
f9f0e732 NC |
5466 | case 't': |
5467 | do_debug_pubtypes = 1; | |
5468 | break; | |
467c65bc | 5469 | |
4cb93e3b TG |
5470 | case 'r': |
5471 | do_debug_aranges = 1; | |
5472 | break; | |
467c65bc | 5473 | |
4cb93e3b TG |
5474 | case 'R': |
5475 | do_debug_ranges = 1; | |
5476 | break; | |
467c65bc | 5477 | |
4cb93e3b TG |
5478 | case 'F': |
5479 | do_debug_frames_interp = 1; | |
5480 | case 'f': | |
5481 | do_debug_frames = 1; | |
5482 | break; | |
467c65bc | 5483 | |
4cb93e3b TG |
5484 | case 'm': |
5485 | do_debug_macinfo = 1; | |
5486 | break; | |
467c65bc | 5487 | |
4cb93e3b TG |
5488 | case 's': |
5489 | do_debug_str = 1; | |
5490 | break; | |
467c65bc | 5491 | |
4cb93e3b TG |
5492 | case 'o': |
5493 | do_debug_loc = 1; | |
5494 | break; | |
467c65bc | 5495 | |
4cb93e3b TG |
5496 | default: |
5497 | warn (_("Unrecognized debug option '%s'\n"), optarg); | |
5498 | break; | |
5499 | } | |
5500 | } | |
5501 | ||
5502 | void | |
5503 | dwarf_select_sections_all (void) | |
5504 | { | |
5505 | do_debug_info = 1; | |
5506 | do_debug_abbrevs = 1; | |
5507 | do_debug_lines = FLAG_DEBUG_LINES_RAW; | |
5508 | do_debug_pubnames = 1; | |
f9f0e732 | 5509 | do_debug_pubtypes = 1; |
4cb93e3b TG |
5510 | do_debug_aranges = 1; |
5511 | do_debug_ranges = 1; | |
5512 | do_debug_frames = 1; | |
5513 | do_debug_macinfo = 1; | |
5514 | do_debug_str = 1; | |
5515 | do_debug_loc = 1; | |
5bbdf3d5 | 5516 | do_gdb_index = 1; |
6f875884 TG |
5517 | do_trace_info = 1; |
5518 | do_trace_abbrevs = 1; | |
5519 | do_trace_aranges = 1; | |
4cb93e3b TG |
5520 | } |
5521 | ||
19e6b90e L |
5522 | struct dwarf_section_display debug_displays[] = |
5523 | { | |
6f875884 | 5524 | { { ".debug_abbrev", ".zdebug_abbrev", NULL, NULL, 0, 0 }, |
c8450da8 | 5525 | display_debug_abbrev, &do_debug_abbrevs, 0 }, |
6f875884 | 5526 | { { ".debug_aranges", ".zdebug_aranges", NULL, NULL, 0, 0 }, |
c8450da8 | 5527 | display_debug_aranges, &do_debug_aranges, 1 }, |
6f875884 | 5528 | { { ".debug_frame", ".zdebug_frame", NULL, NULL, 0, 0 }, |
c8450da8 | 5529 | display_debug_frames, &do_debug_frames, 1 }, |
6f875884 | 5530 | { { ".debug_info", ".zdebug_info", NULL, NULL, 0, 0 }, |
c8450da8 | 5531 | display_debug_info, &do_debug_info, 1 }, |
6f875884 | 5532 | { { ".debug_line", ".zdebug_line", NULL, NULL, 0, 0 }, |
c8450da8 | 5533 | display_debug_lines, &do_debug_lines, 1 }, |
6f875884 | 5534 | { { ".debug_pubnames", ".zdebug_pubnames", NULL, NULL, 0, 0 }, |
c8450da8 | 5535 | display_debug_pubnames, &do_debug_pubnames, 0 }, |
6f875884 | 5536 | { { ".eh_frame", "", NULL, NULL, 0, 0 }, |
c8450da8 | 5537 | display_debug_frames, &do_debug_frames, 1 }, |
6f875884 | 5538 | { { ".debug_macinfo", ".zdebug_macinfo", NULL, NULL, 0, 0 }, |
c8450da8 | 5539 | display_debug_macinfo, &do_debug_macinfo, 0 }, |
6f875884 | 5540 | { { ".debug_str", ".zdebug_str", NULL, NULL, 0, 0 }, |
c8450da8 | 5541 | display_debug_str, &do_debug_str, 0 }, |
6f875884 | 5542 | { { ".debug_loc", ".zdebug_loc", NULL, NULL, 0, 0 }, |
c8450da8 | 5543 | display_debug_loc, &do_debug_loc, 1 }, |
6f875884 | 5544 | { { ".debug_pubtypes", ".zdebug_pubtypes", NULL, NULL, 0, 0 }, |
f9f0e732 | 5545 | display_debug_pubnames, &do_debug_pubtypes, 0 }, |
6f875884 | 5546 | { { ".debug_ranges", ".zdebug_ranges", NULL, NULL, 0, 0 }, |
c8450da8 | 5547 | display_debug_ranges, &do_debug_ranges, 1 }, |
6f875884 | 5548 | { { ".debug_static_func", ".zdebug_static_func", NULL, NULL, 0, 0 }, |
c8450da8 | 5549 | display_debug_not_supported, NULL, 0 }, |
6f875884 | 5550 | { { ".debug_static_vars", ".zdebug_static_vars", NULL, NULL, 0, 0 }, |
c8450da8 | 5551 | display_debug_not_supported, NULL, 0 }, |
6f875884 | 5552 | { { ".debug_types", ".zdebug_types", NULL, NULL, 0, 0 }, |
2b6f5997 | 5553 | display_debug_types, &do_debug_info, 1 }, |
6f875884 TG |
5554 | { { ".debug_weaknames", ".zdebug_weaknames", NULL, NULL, 0, 0 }, |
5555 | display_debug_not_supported, NULL, 0 }, | |
5bbdf3d5 DE |
5556 | { { ".gdb_index", "", NULL, NULL, 0, 0 }, |
5557 | display_gdb_index, &do_gdb_index, 0 }, | |
6f875884 TG |
5558 | { { ".trace_info", "", NULL, NULL, 0, 0 }, |
5559 | display_trace_info, &do_trace_info, 1 }, | |
5560 | { { ".trace_abbrev", "", NULL, NULL, 0, 0 }, | |
5561 | display_debug_abbrev, &do_trace_abbrevs, 0 }, | |
5562 | { { ".trace_aranges", "", NULL, NULL, 0, 0 }, | |
5563 | display_debug_aranges, &do_trace_aranges, 0 } | |
19e6b90e | 5564 | }; |