1 /* dwarf.c -- display DWARF contents of a BFD binary file
2 Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 Free Software Foundation, Inc.
5 This file is part of GNU Binutils.
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
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
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.
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
23 #include "libiberty.h"
25 #include "bfd_stdint.h"
28 #include "elf/common.h"
31 #include "gdb/gdb-index.h"
33 static const char *regname (unsigned int regno
, int row
);
35 static int have_frame_base
;
36 static int need_base_address
;
38 static unsigned int last_pointer_size
= 0;
39 static int warned_about_missing_comp_units
= FALSE
;
41 static unsigned int num_debug_info_entries
= 0;
42 static debug_info
*debug_information
= NULL
;
43 /* Special value for num_debug_info_entries to indicate
44 that the .debug_info section could not be loaded/parsed. */
45 #define DEBUG_INFO_UNAVAILABLE (unsigned int) -1
52 int do_debug_pubnames
;
53 int do_debug_pubtypes
;
57 int do_debug_frames_interp
;
67 int dwarf_cutoff_level
= -1;
68 unsigned long dwarf_start_die
;
72 /* Values for do_debug_lines. */
73 #define FLAG_DEBUG_LINES_RAW 1
74 #define FLAG_DEBUG_LINES_DECODED 2
77 size_of_encoded_value (int encoding
)
79 switch (encoding
& 0x7)
82 case 0: return eh_addr_size
;
90 get_encoded_value (unsigned char *data
,
92 struct dwarf_section
*section
)
94 int size
= size_of_encoded_value (encoding
);
97 if (encoding
& DW_EH_PE_signed
)
98 val
= byte_get_signed (data
, size
);
100 val
= byte_get (data
, size
);
102 if ((encoding
& 0x70) == DW_EH_PE_pcrel
)
103 val
+= section
->address
+ (data
- section
->start
);
107 /* Print a dwarf_vma value (typically an address, offset or length) in
108 hexadecimal format, followed by a space. The length of the value (and
109 hence the precision displayed) is determined by the byte_size parameter. */
112 print_dwarf_vma (dwarf_vma val
, unsigned byte_size
)
114 static char buff
[18];
117 /* Printf does not have a way of specifiying a maximum field width for an
118 integer value, so we print the full value into a buffer and then select
119 the precision we need. */
120 #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
122 snprintf (buff
, sizeof (buff
), "%16.16llx ", val
);
124 snprintf (buff
, sizeof (buff
), "%016I64x ", val
);
127 snprintf (buff
, sizeof (buff
), "%16.16lx ", val
);
132 if (byte_size
> 0 && byte_size
<= 8)
133 offset
= 16 - 2 * byte_size
;
135 error (_("Wrong size in print_dwarf_vma"));
138 fputs (buff
+ offset
, stdout
);
141 #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
143 #define DWARF_VMA_FMT "ll"
145 #define DWARF_VMA_FMT "I64"
148 #define DWARF_VMA_FMT "l"
152 dwarf_vmatoa (const char *fmtch
, dwarf_vma value
)
154 /* As dwarf_vmatoa is used more then once in a printf call
155 for output, we are cycling through an fixed array of pointers
156 for return address. */
157 static int buf_pos
= 0;
158 static struct dwarf_vmatoa_buf
165 sprintf (fmt
, "%%%s%s", DWARF_VMA_FMT
, fmtch
);
167 ret
= buf
[buf_pos
++].place
;
168 buf_pos
%= ARRAY_SIZE (buf
);
170 snprintf (ret
, sizeof (buf
[0].place
), fmt
, value
);
175 /* Format a 64-bit value, given as two 32-bit values, in hex.
176 For reentrancy, this uses a buffer provided by the caller. */
179 dwarf_vmatoa64 (dwarf_vma hvalue
, dwarf_vma lvalue
, char *buf
,
180 unsigned int buf_len
)
185 snprintf (buf
, buf_len
, "%" DWARF_VMA_FMT
"x", lvalue
);
188 len
= snprintf (buf
, buf_len
, "%" DWARF_VMA_FMT
"x", hvalue
);
189 snprintf (buf
+ len
, buf_len
- len
,
190 "%08" DWARF_VMA_FMT
"x", lvalue
);
197 read_leb128 (unsigned char *data
, unsigned int *length_return
, int sign
)
199 dwarf_vma result
= 0;
200 unsigned int num_read
= 0;
201 unsigned int shift
= 0;
209 result
|= ((dwarf_vma
) (byte
& 0x7f)) << shift
;
216 if (length_return
!= NULL
)
217 *length_return
= num_read
;
219 if (sign
&& (shift
< 8 * sizeof (result
)) && (byte
& 0x40))
220 result
|= -1L << shift
;
225 /* Create a signed version to avoid painful typecasts. */
226 static dwarf_signed_vma
227 read_sleb128 (unsigned char *data
, unsigned int *length_return
)
229 return (dwarf_signed_vma
) read_leb128 (data
, length_return
, 1);
232 typedef struct State_Machine_Registers
240 unsigned char op_index
;
241 unsigned char end_sequence
;
242 /* This variable hold the number of the last entry seen
243 in the File Table. */
244 unsigned int last_file_entry
;
247 static SMR state_machine_regs
;
250 reset_state_machine (int is_stmt
)
252 state_machine_regs
.address
= 0;
253 state_machine_regs
.op_index
= 0;
254 state_machine_regs
.file
= 1;
255 state_machine_regs
.line
= 1;
256 state_machine_regs
.column
= 0;
257 state_machine_regs
.is_stmt
= is_stmt
;
258 state_machine_regs
.basic_block
= 0;
259 state_machine_regs
.end_sequence
= 0;
260 state_machine_regs
.last_file_entry
= 0;
263 /* Handled an extend line op.
264 Returns the number of bytes read. */
267 process_extended_line_op (unsigned char *data
, int is_stmt
)
269 unsigned char op_code
;
270 unsigned int bytes_read
;
274 unsigned char *orig_data
= data
;
276 len
= read_leb128 (data
, & bytes_read
, 0);
281 warn (_("badly formed extended line op encountered!\n"));
288 printf (_(" Extended opcode %d: "), op_code
);
292 case DW_LNE_end_sequence
:
293 printf (_("End of Sequence\n\n"));
294 reset_state_machine (is_stmt
);
297 case DW_LNE_set_address
:
298 adr
= byte_get (data
, len
- bytes_read
- 1);
299 printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr
));
300 state_machine_regs
.address
= adr
;
301 state_machine_regs
.op_index
= 0;
304 case DW_LNE_define_file
:
305 printf (_("define new File Table entry\n"));
306 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
308 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
310 data
+= strlen ((char *) data
) + 1;
311 printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data
, & bytes_read
, 0)));
313 printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data
, & bytes_read
, 0)));
315 printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data
, & bytes_read
, 0)));
318 if ((unsigned int) (data
- orig_data
) != len
)
319 printf (_(" [Bad opcode length]"));
323 case DW_LNE_set_discriminator
:
324 printf (_("set Discriminator to %s\n"),
325 dwarf_vmatoa ("u", read_leb128 (data
, & bytes_read
, 0)));
329 case DW_LNE_HP_negate_is_UV_update
:
330 printf ("DW_LNE_HP_negate_is_UV_update\n");
332 case DW_LNE_HP_push_context
:
333 printf ("DW_LNE_HP_push_context\n");
335 case DW_LNE_HP_pop_context
:
336 printf ("DW_LNE_HP_pop_context\n");
338 case DW_LNE_HP_set_file_line_column
:
339 printf ("DW_LNE_HP_set_file_line_column\n");
341 case DW_LNE_HP_set_routine_name
:
342 printf ("DW_LNE_HP_set_routine_name\n");
344 case DW_LNE_HP_set_sequence
:
345 printf ("DW_LNE_HP_set_sequence\n");
347 case DW_LNE_HP_negate_post_semantics
:
348 printf ("DW_LNE_HP_negate_post_semantics\n");
350 case DW_LNE_HP_negate_function_exit
:
351 printf ("DW_LNE_HP_negate_function_exit\n");
353 case DW_LNE_HP_negate_front_end_logical
:
354 printf ("DW_LNE_HP_negate_front_end_logical\n");
356 case DW_LNE_HP_define_proc
:
357 printf ("DW_LNE_HP_define_proc\n");
359 case DW_LNE_HP_source_file_correlation
:
361 unsigned char *edata
= data
+ len
- bytes_read
- 1;
363 printf ("DW_LNE_HP_source_file_correlation\n");
369 opc
= read_leb128 (data
, & bytes_read
, 0);
374 case DW_LNE_HP_SFC_formfeed
:
375 printf (" DW_LNE_HP_SFC_formfeed\n");
377 case DW_LNE_HP_SFC_set_listing_line
:
378 printf (" DW_LNE_HP_SFC_set_listing_line (%s)\n",
380 read_leb128 (data
, & bytes_read
, 0)));
383 case DW_LNE_HP_SFC_associate
:
384 printf (" DW_LNE_HP_SFC_associate ");
387 read_leb128 (data
, & bytes_read
, 0)));
391 read_leb128 (data
, & bytes_read
, 0)));
395 read_leb128 (data
, & bytes_read
, 0)));
399 printf (_(" UNKNOWN DW_LNE_HP_SFC opcode (%u)\n"), opc
);
409 unsigned int rlen
= len
- bytes_read
- 1;
411 if (op_code
>= DW_LNE_lo_user
412 /* The test against DW_LNW_hi_user is redundant due to
413 the limited range of the unsigned char data type used
415 /*&& op_code <= DW_LNE_hi_user*/)
416 printf (_("user defined: "));
418 printf (_("UNKNOWN: "));
419 printf (_("length %d ["), rlen
);
421 printf (" %02x", *data
++);
431 fetch_indirect_string (dwarf_vma offset
)
433 struct dwarf_section
*section
= &debug_displays
[str
].section
;
435 if (section
->start
== NULL
)
436 return _("<no .debug_str section>");
438 /* DWARF sections under Mach-O have non-zero addresses. */
439 offset
-= section
->address
;
440 if (offset
> section
->size
)
442 warn (_("DW_FORM_strp offset too big: %s\n"),
443 dwarf_vmatoa ("x", offset
));
444 return _("<offset is too big>");
447 return (const char *) section
->start
+ offset
;
451 fetch_indexed_string (dwarf_vma idx
, dwarf_vma offset_size
, int dwo
)
453 enum dwarf_section_display_enum str_sec_idx
= dwo
? str_dwo
: str
;
454 enum dwarf_section_display_enum idx_sec_idx
= dwo
? str_index_dwo
: str_index
;
455 struct dwarf_section
*index_section
= &debug_displays
[idx_sec_idx
].section
;
456 struct dwarf_section
*str_section
= &debug_displays
[str_sec_idx
].section
;
457 dwarf_vma index_offset
= idx
* offset_size
;
458 dwarf_vma str_offset
;
460 if (index_section
->start
== NULL
)
461 return (dwo
? _("<no .debug_str_offsets.dwo section>")
462 : _("<no .debug_str_offsets section>"));
464 /* DWARF sections under Mach-O have non-zero addresses. */
465 index_offset
-= index_section
->address
;
466 if (index_offset
> index_section
->size
)
468 warn (_("DW_FORM_GNU_str_index offset too big: %s\n"),
469 dwarf_vmatoa ("x", index_offset
));
470 return _("<index offset is too big>");
473 if (str_section
->start
== NULL
)
474 return (dwo
? _("<no .debug_str.dwo section>")
475 : _("<no .debug_str section>"));
477 str_offset
= byte_get (index_section
->start
+ index_offset
, offset_size
);
478 str_offset
-= str_section
->address
;
479 if (str_offset
> str_section
->size
)
481 warn (_("DW_FORM_GNU_str_index indirect offset too big: %s\n"),
482 dwarf_vmatoa ("x", str_offset
));
483 return _("<indirect index offset is too big>");
486 return (const char *) str_section
->start
+ str_offset
;
490 fetch_indexed_value (dwarf_vma offset
, dwarf_vma bytes
)
492 struct dwarf_section
*section
= &debug_displays
[debug_addr
].section
;
494 if (section
->start
== NULL
)
495 return (_("<no .debug_addr section>"));
497 if (offset
+ bytes
> section
->size
)
499 warn (_("Offset into section %s too big: %s\n"),
500 section
->name
, dwarf_vmatoa ("x", offset
));
501 return "<offset too big>";
504 return dwarf_vmatoa ("x", byte_get (section
->start
+ offset
, bytes
));
508 /* FIXME: There are better and more efficient ways to handle
509 these structures. For now though, I just want something that
510 is simple to implement. */
511 typedef struct abbrev_attr
513 unsigned long attribute
;
515 struct abbrev_attr
*next
;
519 typedef struct abbrev_entry
524 struct abbrev_attr
*first_attr
;
525 struct abbrev_attr
*last_attr
;
526 struct abbrev_entry
*next
;
530 static abbrev_entry
*first_abbrev
= NULL
;
531 static abbrev_entry
*last_abbrev
= NULL
;
538 for (abbrv
= first_abbrev
; abbrv
;)
540 abbrev_entry
*next_abbrev
= abbrv
->next
;
543 for (attr
= abbrv
->first_attr
; attr
;)
545 abbrev_attr
*next_attr
= attr
->next
;
555 last_abbrev
= first_abbrev
= NULL
;
559 add_abbrev (unsigned long number
, unsigned long tag
, int children
)
563 entry
= (abbrev_entry
*) malloc (sizeof (*entry
));
568 entry
->entry
= number
;
570 entry
->children
= children
;
571 entry
->first_attr
= NULL
;
572 entry
->last_attr
= NULL
;
575 if (first_abbrev
== NULL
)
576 first_abbrev
= entry
;
578 last_abbrev
->next
= entry
;
584 add_abbrev_attr (unsigned long attribute
, unsigned long form
)
588 attr
= (abbrev_attr
*) malloc (sizeof (*attr
));
593 attr
->attribute
= attribute
;
597 if (last_abbrev
->first_attr
== NULL
)
598 last_abbrev
->first_attr
= attr
;
600 last_abbrev
->last_attr
->next
= attr
;
602 last_abbrev
->last_attr
= attr
;
605 /* Processes the (partial) contents of a .debug_abbrev section.
606 Returns NULL if the end of the section was encountered.
607 Returns the address after the last byte read if the end of
608 an abbreviation set was found. */
610 static unsigned char *
611 process_abbrev_section (unsigned char *start
, unsigned char *end
)
613 if (first_abbrev
!= NULL
)
618 unsigned int bytes_read
;
621 unsigned long attribute
;
624 entry
= read_leb128 (start
, & bytes_read
, 0);
627 /* A single zero is supposed to end the section according
628 to the standard. If there's more, then signal that to
631 return start
== end
? NULL
: start
;
633 tag
= read_leb128 (start
, & bytes_read
, 0);
638 add_abbrev (entry
, tag
, children
);
644 attribute
= read_leb128 (start
, & bytes_read
, 0);
647 form
= read_leb128 (start
, & bytes_read
, 0);
650 add_abbrev_attr (attribute
, form
);
652 while (attribute
!= 0);
655 /* Report the missing single zero which ends the section. */
656 error (_(".debug_abbrev section not zero terminated\n"));
662 get_TAG_name (unsigned long tag
)
664 const char *name
= get_DW_TAG_name ((unsigned int)tag
);
668 static char buffer
[100];
670 snprintf (buffer
, sizeof (buffer
), _("Unknown TAG value: %lx"), tag
);
678 get_FORM_name (unsigned long form
)
683 return "DW_FORM value: 0";
685 name
= get_DW_FORM_name (form
);
688 static char buffer
[100];
690 snprintf (buffer
, sizeof (buffer
), _("Unknown FORM value: %lx"), form
);
697 static unsigned char *
698 display_block (unsigned char *data
, dwarf_vma length
)
700 printf (_(" %s byte block: "), dwarf_vmatoa ("u", length
));
703 printf ("%lx ", (unsigned long) byte_get (data
++, 1));
709 decode_location_expression (unsigned char * data
,
710 unsigned int pointer_size
,
711 unsigned int offset_size
,
715 struct dwarf_section
* section
)
718 unsigned int bytes_read
;
720 unsigned char *end
= data
+ length
;
721 int need_frame_base
= 0;
730 printf ("DW_OP_addr: %s",
731 dwarf_vmatoa ("x", byte_get (data
, pointer_size
)));
732 data
+= pointer_size
;
735 printf ("DW_OP_deref");
738 printf ("DW_OP_const1u: %lu", (unsigned long) byte_get (data
++, 1));
741 printf ("DW_OP_const1s: %ld", (long) byte_get_signed (data
++, 1));
744 printf ("DW_OP_const2u: %lu", (unsigned long) byte_get (data
, 2));
748 printf ("DW_OP_const2s: %ld", (long) byte_get_signed (data
, 2));
752 printf ("DW_OP_const4u: %lu", (unsigned long) byte_get (data
, 4));
756 printf ("DW_OP_const4s: %ld", (long) byte_get_signed (data
, 4));
760 printf ("DW_OP_const8u: %lu %lu", (unsigned long) byte_get (data
, 4),
761 (unsigned long) byte_get (data
+ 4, 4));
765 printf ("DW_OP_const8s: %ld %ld", (long) byte_get (data
, 4),
766 (long) byte_get (data
+ 4, 4));
770 printf ("DW_OP_constu: %s",
771 dwarf_vmatoa ("u", read_leb128 (data
, &bytes_read
, 0)));
775 printf ("DW_OP_consts: %s",
776 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
)));
780 printf ("DW_OP_dup");
783 printf ("DW_OP_drop");
786 printf ("DW_OP_over");
789 printf ("DW_OP_pick: %ld", (unsigned long) byte_get (data
++, 1));
792 printf ("DW_OP_swap");
795 printf ("DW_OP_rot");
798 printf ("DW_OP_xderef");
801 printf ("DW_OP_abs");
804 printf ("DW_OP_and");
807 printf ("DW_OP_div");
810 printf ("DW_OP_minus");
813 printf ("DW_OP_mod");
816 printf ("DW_OP_mul");
819 printf ("DW_OP_neg");
822 printf ("DW_OP_not");
828 printf ("DW_OP_plus");
830 case DW_OP_plus_uconst
:
831 printf ("DW_OP_plus_uconst: %s",
832 dwarf_vmatoa ("u", read_leb128 (data
, &bytes_read
, 0)));
836 printf ("DW_OP_shl");
839 printf ("DW_OP_shr");
842 printf ("DW_OP_shra");
845 printf ("DW_OP_xor");
848 printf ("DW_OP_bra: %ld", (long) byte_get_signed (data
, 2));
870 printf ("DW_OP_skip: %ld", (long) byte_get_signed (data
, 2));
906 printf ("DW_OP_lit%d", op
- DW_OP_lit0
);
941 printf ("DW_OP_reg%d (%s)", op
- DW_OP_reg0
,
942 regname (op
- DW_OP_reg0
, 1));
977 printf ("DW_OP_breg%d (%s): %s",
979 regname (op
- DW_OP_breg0
, 1),
980 dwarf_vmatoa ("d", (dwarf_signed_vma
)
981 read_leb128 (data
, &bytes_read
, 1)));
986 uvalue
= read_leb128 (data
, &bytes_read
, 0);
988 printf ("DW_OP_regx: %s (%s)",
989 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1));
993 printf ("DW_OP_fbreg: %s",
994 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
)));
998 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1000 printf ("DW_OP_bregx: %s (%s) %s",
1001 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1),
1002 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
)));
1006 printf ("DW_OP_piece: %s",
1007 dwarf_vmatoa ("u", read_leb128 (data
, &bytes_read
, 0)));
1010 case DW_OP_deref_size
:
1011 printf ("DW_OP_deref_size: %ld", (long) byte_get (data
++, 1));
1013 case DW_OP_xderef_size
:
1014 printf ("DW_OP_xderef_size: %ld", (long) byte_get (data
++, 1));
1017 printf ("DW_OP_nop");
1020 /* DWARF 3 extensions. */
1021 case DW_OP_push_object_address
:
1022 printf ("DW_OP_push_object_address");
1025 /* XXX: Strictly speaking for 64-bit DWARF3 files
1026 this ought to be an 8-byte wide computation. */
1027 printf ("DW_OP_call2: <0x%s>",
1028 dwarf_vmatoa ("x", (dwarf_signed_vma
) byte_get (data
, 2)
1033 /* XXX: Strictly speaking for 64-bit DWARF3 files
1034 this ought to be an 8-byte wide computation. */
1035 printf ("DW_OP_call4: <0x%s>",
1036 dwarf_vmatoa ("x", (dwarf_signed_vma
) byte_get (data
, 4)
1040 case DW_OP_call_ref
:
1041 /* XXX: Strictly speaking for 64-bit DWARF3 files
1042 this ought to be an 8-byte wide computation. */
1043 if (dwarf_version
== -1)
1045 printf (_("(DW_OP_call_ref in frame info)"));
1046 /* No way to tell where the next op is, so just bail. */
1047 return need_frame_base
;
1049 if (dwarf_version
== 2)
1051 printf ("DW_OP_call_ref: <0x%s>",
1052 dwarf_vmatoa ("x", byte_get (data
, pointer_size
)));
1053 data
+= pointer_size
;
1057 printf ("DW_OP_call_ref: <0x%s>",
1058 dwarf_vmatoa ("x", byte_get (data
, offset_size
)));
1059 data
+= offset_size
;
1062 case DW_OP_form_tls_address
:
1063 printf ("DW_OP_form_tls_address");
1065 case DW_OP_call_frame_cfa
:
1066 printf ("DW_OP_call_frame_cfa");
1068 case DW_OP_bit_piece
:
1069 printf ("DW_OP_bit_piece: ");
1070 printf (_("size: %s "),
1071 dwarf_vmatoa ("u", read_leb128 (data
, &bytes_read
, 0)));
1073 printf (_("offset: %s "),
1074 dwarf_vmatoa ("u", read_leb128 (data
, &bytes_read
, 0)));
1078 /* DWARF 4 extensions. */
1079 case DW_OP_stack_value
:
1080 printf ("DW_OP_stack_value");
1083 case DW_OP_implicit_value
:
1084 printf ("DW_OP_implicit_value");
1085 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1087 display_block (data
, uvalue
);
1091 /* GNU extensions. */
1092 case DW_OP_GNU_push_tls_address
:
1093 printf (_("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown"));
1095 case DW_OP_GNU_uninit
:
1096 printf ("DW_OP_GNU_uninit");
1097 /* FIXME: Is there data associated with this OP ? */
1099 case DW_OP_GNU_encoded_addr
:
1105 addr
= get_encoded_value (data
, encoding
, section
);
1106 data
+= size_of_encoded_value (encoding
);
1108 printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding
);
1109 print_dwarf_vma (addr
, pointer_size
);
1112 case DW_OP_GNU_implicit_pointer
:
1113 /* XXX: Strictly speaking for 64-bit DWARF3 files
1114 this ought to be an 8-byte wide computation. */
1115 if (dwarf_version
== -1)
1117 printf (_("(DW_OP_GNU_implicit_pointer in frame info)"));
1118 /* No way to tell where the next op is, so just bail. */
1119 return need_frame_base
;
1121 if (dwarf_version
== 2)
1123 printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s",
1124 dwarf_vmatoa ("x", byte_get (data
, pointer_size
)),
1125 dwarf_vmatoa ("d", read_sleb128 (data
+ pointer_size
,
1127 data
+= pointer_size
+ bytes_read
;
1131 printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s",
1132 dwarf_vmatoa ("x", byte_get (data
, offset_size
)),
1133 dwarf_vmatoa ("d", read_sleb128 (data
+ offset_size
,
1135 data
+= offset_size
+ bytes_read
;
1138 case DW_OP_GNU_entry_value
:
1139 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1141 printf ("DW_OP_GNU_entry_value: (");
1142 if (decode_location_expression (data
, pointer_size
, offset_size
,
1143 dwarf_version
, uvalue
,
1144 cu_offset
, section
))
1145 need_frame_base
= 1;
1149 case DW_OP_GNU_const_type
:
1150 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1152 printf ("DW_OP_GNU_const_type: <0x%s> ",
1153 dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1154 uvalue
= byte_get (data
++, 1);
1155 display_block (data
, uvalue
);
1158 case DW_OP_GNU_regval_type
:
1159 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1161 printf ("DW_OP_GNU_regval_type: %s (%s)",
1162 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1));
1163 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1165 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1167 case DW_OP_GNU_deref_type
:
1168 printf ("DW_OP_GNU_deref_type: %ld", (long) byte_get (data
++, 1));
1169 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1171 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1173 case DW_OP_GNU_convert
:
1174 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1176 printf ("DW_OP_GNU_convert <0x%s>",
1177 dwarf_vmatoa ("x", uvalue
? cu_offset
+ uvalue
: 0));
1179 case DW_OP_GNU_reinterpret
:
1180 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1182 printf ("DW_OP_GNU_reinterpret <0x%s>",
1183 dwarf_vmatoa ("x", uvalue
? cu_offset
+ uvalue
: 0));
1185 case DW_OP_GNU_parameter_ref
:
1186 printf ("DW_OP_GNU_parameter_ref: <0x%s>",
1187 dwarf_vmatoa ("x", cu_offset
+ byte_get (data
, 4)));
1190 case DW_OP_GNU_addr_index
:
1191 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1193 printf ("DW_OP_GNU_addr_index <0x%s>", dwarf_vmatoa ("x", uvalue
));
1195 case DW_OP_GNU_const_index
:
1196 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1198 printf ("DW_OP_GNU_const_index <0x%s>", dwarf_vmatoa ("x", uvalue
));
1201 /* HP extensions. */
1202 case DW_OP_HP_is_value
:
1203 printf ("DW_OP_HP_is_value");
1204 /* FIXME: Is there data associated with this OP ? */
1206 case DW_OP_HP_fltconst4
:
1207 printf ("DW_OP_HP_fltconst4");
1208 /* FIXME: Is there data associated with this OP ? */
1210 case DW_OP_HP_fltconst8
:
1211 printf ("DW_OP_HP_fltconst8");
1212 /* FIXME: Is there data associated with this OP ? */
1214 case DW_OP_HP_mod_range
:
1215 printf ("DW_OP_HP_mod_range");
1216 /* FIXME: Is there data associated with this OP ? */
1218 case DW_OP_HP_unmod_range
:
1219 printf ("DW_OP_HP_unmod_range");
1220 /* FIXME: Is there data associated with this OP ? */
1223 printf ("DW_OP_HP_tls");
1224 /* FIXME: Is there data associated with this OP ? */
1227 /* PGI (STMicroelectronics) extensions. */
1228 case DW_OP_PGI_omp_thread_num
:
1229 /* Pushes the thread number for the current thread as it would be
1230 returned by the standard OpenMP library function:
1231 omp_get_thread_num(). The "current thread" is the thread for
1232 which the expression is being evaluated. */
1233 printf ("DW_OP_PGI_omp_thread_num");
1237 if (op
>= DW_OP_lo_user
1238 && op
<= DW_OP_hi_user
)
1239 printf (_("(User defined location op)"));
1241 printf (_("(Unknown location op)"));
1242 /* No way to tell where the next op is, so just bail. */
1243 return need_frame_base
;
1246 /* Separate the ops. */
1251 return need_frame_base
;
1254 static unsigned char *
1255 read_and_display_attr_value (unsigned long attribute
,
1257 unsigned char * data
,
1258 dwarf_vma cu_offset
,
1259 dwarf_vma pointer_size
,
1260 dwarf_vma offset_size
,
1262 debug_info
* debug_info_p
,
1264 struct dwarf_section
* section
)
1266 dwarf_vma uvalue
= 0;
1267 unsigned char *block_start
= NULL
;
1268 unsigned char * orig_data
= data
;
1269 unsigned int bytes_read
;
1276 case DW_FORM_ref_addr
:
1277 if (dwarf_version
== 2)
1279 uvalue
= byte_get (data
, pointer_size
);
1280 data
+= pointer_size
;
1282 else if (dwarf_version
== 3 || dwarf_version
== 4)
1284 uvalue
= byte_get (data
, offset_size
);
1285 data
+= offset_size
;
1288 error (_("Internal error: DWARF version is not 2, 3 or 4.\n"));
1293 uvalue
= byte_get (data
, pointer_size
);
1294 data
+= pointer_size
;
1298 case DW_FORM_sec_offset
:
1299 case DW_FORM_GNU_ref_alt
:
1300 case DW_FORM_GNU_strp_alt
:
1301 uvalue
= byte_get (data
, offset_size
);
1302 data
+= offset_size
;
1305 case DW_FORM_flag_present
:
1312 uvalue
= byte_get (data
++, 1);
1317 uvalue
= byte_get (data
, 2);
1323 uvalue
= byte_get (data
, 4);
1328 uvalue
= read_leb128 (data
, & bytes_read
, 1);
1332 case DW_FORM_GNU_str_index
:
1333 uvalue
= read_leb128 (data
, & bytes_read
, 0);
1337 case DW_FORM_ref_udata
:
1339 uvalue
= read_leb128 (data
, & bytes_read
, 0);
1343 case DW_FORM_indirect
:
1344 form
= read_leb128 (data
, & bytes_read
, 0);
1347 printf (" %s", get_FORM_name (form
));
1348 return read_and_display_attr_value (attribute
, form
, data
,
1349 cu_offset
, pointer_size
,
1350 offset_size
, dwarf_version
,
1351 debug_info_p
, do_loc
,
1353 case DW_FORM_GNU_addr_index
:
1354 uvalue
= read_leb128 (data
, & bytes_read
, 0);
1361 case DW_FORM_ref_addr
:
1363 printf (" <0x%s>", dwarf_vmatoa ("x",uvalue
));
1366 case DW_FORM_GNU_ref_alt
:
1368 printf (" <alt 0x%s>", dwarf_vmatoa ("x",uvalue
));
1374 case DW_FORM_ref_udata
:
1376 printf (" <0x%s>", dwarf_vmatoa ("x", uvalue
+ cu_offset
));
1381 case DW_FORM_sec_offset
:
1383 printf (" 0x%s", dwarf_vmatoa ("x", uvalue
));
1386 case DW_FORM_flag_present
:
1393 printf (" %s", dwarf_vmatoa ("d", uvalue
));
1400 dwarf_vma high_bits
;
1403 byte_get_64 (data
, &high_bits
, &uvalue
);
1405 dwarf_vmatoa64 (high_bits
, uvalue
, buf
, sizeof (buf
)));
1407 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1408 && num_debug_info_entries
== 0)
1410 if (sizeof (uvalue
) == 8)
1411 uvalue
= byte_get (data
, 8);
1413 error (_("DW_FORM_data8 is unsupported when sizeof (dwarf_vma) != 8\n"));
1418 case DW_FORM_string
:
1420 printf (" %s", data
);
1421 data
+= strlen ((char *) data
) + 1;
1425 case DW_FORM_exprloc
:
1426 uvalue
= read_leb128 (data
, & bytes_read
, 0);
1427 block_start
= data
+ bytes_read
;
1429 data
= block_start
+ uvalue
;
1431 data
= display_block (block_start
, uvalue
);
1434 case DW_FORM_block1
:
1435 uvalue
= byte_get (data
, 1);
1436 block_start
= data
+ 1;
1438 data
= block_start
+ uvalue
;
1440 data
= display_block (block_start
, uvalue
);
1443 case DW_FORM_block2
:
1444 uvalue
= byte_get (data
, 2);
1445 block_start
= data
+ 2;
1447 data
= block_start
+ uvalue
;
1449 data
= display_block (block_start
, uvalue
);
1452 case DW_FORM_block4
:
1453 uvalue
= byte_get (data
, 4);
1454 block_start
= data
+ 4;
1456 data
= block_start
+ uvalue
;
1458 data
= display_block (block_start
, uvalue
);
1463 printf (_(" (indirect string, offset: 0x%s): %s"),
1464 dwarf_vmatoa ("x", uvalue
),
1465 fetch_indirect_string (uvalue
));
1468 case DW_FORM_GNU_str_index
:
1471 const char *suffix
= strrchr (section
->name
, '.');
1472 int dwo
= (suffix
&& strcmp (suffix
, ".dwo") == 0) ? 1 : 0;
1474 printf (_(" (indexed string: 0x%s): %s"),
1475 dwarf_vmatoa ("x", uvalue
),
1476 fetch_indexed_string (uvalue
, offset_size
, dwo
));
1480 case DW_FORM_GNU_strp_alt
:
1482 printf (_(" (alt indirect string, offset: 0x%s)"),
1483 dwarf_vmatoa ("x", uvalue
));
1486 case DW_FORM_indirect
:
1487 /* Handled above. */
1490 case DW_FORM_ref_sig8
:
1493 dwarf_vma high_bits
;
1496 byte_get_64 (data
, &high_bits
, &uvalue
);
1497 printf (" signature: 0x%s",
1498 dwarf_vmatoa64 (high_bits
, uvalue
, buf
, sizeof (buf
)));
1503 case DW_FORM_GNU_addr_index
:
1505 printf (_(" (addr_index: 0x%s): %s"),
1506 dwarf_vmatoa ("x", uvalue
),
1507 fetch_indexed_value (uvalue
* pointer_size
, pointer_size
));
1511 warn (_("Unrecognized form: %lu\n"), form
);
1515 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1516 && num_debug_info_entries
== 0
1517 && debug_info_p
!= NULL
)
1521 case DW_AT_frame_base
:
1522 have_frame_base
= 1;
1523 case DW_AT_location
:
1524 case DW_AT_string_length
:
1525 case DW_AT_return_addr
:
1526 case DW_AT_data_member_location
:
1527 case DW_AT_vtable_elem_location
:
1529 case DW_AT_static_link
:
1530 case DW_AT_use_location
:
1531 case DW_AT_GNU_call_site_value
:
1532 case DW_AT_GNU_call_site_data_value
:
1533 case DW_AT_GNU_call_site_target
:
1534 case DW_AT_GNU_call_site_target_clobbered
:
1535 if ((dwarf_version
< 4
1536 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
1537 || form
== DW_FORM_sec_offset
)
1539 /* Process location list. */
1540 unsigned int lmax
= debug_info_p
->max_loc_offsets
;
1541 unsigned int num
= debug_info_p
->num_loc_offsets
;
1543 if (lmax
== 0 || num
>= lmax
)
1546 debug_info_p
->loc_offsets
= (dwarf_vma
*)
1547 xcrealloc (debug_info_p
->loc_offsets
,
1548 lmax
, sizeof (*debug_info_p
->loc_offsets
));
1549 debug_info_p
->have_frame_base
= (int *)
1550 xcrealloc (debug_info_p
->have_frame_base
,
1551 lmax
, sizeof (*debug_info_p
->have_frame_base
));
1552 debug_info_p
->max_loc_offsets
= lmax
;
1554 debug_info_p
->loc_offsets
[num
] = uvalue
;
1555 debug_info_p
->have_frame_base
[num
] = have_frame_base
;
1556 debug_info_p
->num_loc_offsets
++;
1561 if (need_base_address
)
1562 debug_info_p
->base_address
= uvalue
;
1565 case DW_AT_GNU_addr_base
:
1566 debug_info_p
->addr_base
= uvalue
;
1569 case DW_AT_GNU_ranges_base
:
1570 debug_info_p
->ranges_base
= uvalue
;
1574 if ((dwarf_version
< 4
1575 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
1576 || form
== DW_FORM_sec_offset
)
1578 /* Process range list. */
1579 unsigned int lmax
= debug_info_p
->max_range_lists
;
1580 unsigned int num
= debug_info_p
->num_range_lists
;
1582 if (lmax
== 0 || num
>= lmax
)
1585 debug_info_p
->range_lists
= (dwarf_vma
*)
1586 xcrealloc (debug_info_p
->range_lists
,
1587 lmax
, sizeof (*debug_info_p
->range_lists
));
1588 debug_info_p
->max_range_lists
= lmax
;
1590 debug_info_p
->range_lists
[num
] = uvalue
;
1591 debug_info_p
->num_range_lists
++;
1600 if (do_loc
|| attribute
== 0)
1603 /* For some attributes we can display further information. */
1611 case DW_INL_not_inlined
:
1612 printf (_("(not inlined)"));
1614 case DW_INL_inlined
:
1615 printf (_("(inlined)"));
1617 case DW_INL_declared_not_inlined
:
1618 printf (_("(declared as inline but ignored)"));
1620 case DW_INL_declared_inlined
:
1621 printf (_("(declared as inline and inlined)"));
1624 printf (_(" (Unknown inline attribute value: %s)"),
1625 dwarf_vmatoa ("x", uvalue
));
1630 case DW_AT_language
:
1633 /* Ordered by the numeric value of these constants. */
1634 case DW_LANG_C89
: printf ("(ANSI C)"); break;
1635 case DW_LANG_C
: printf ("(non-ANSI C)"); break;
1636 case DW_LANG_Ada83
: printf ("(Ada)"); break;
1637 case DW_LANG_C_plus_plus
: printf ("(C++)"); break;
1638 case DW_LANG_Cobol74
: printf ("(Cobol 74)"); break;
1639 case DW_LANG_Cobol85
: printf ("(Cobol 85)"); break;
1640 case DW_LANG_Fortran77
: printf ("(FORTRAN 77)"); break;
1641 case DW_LANG_Fortran90
: printf ("(Fortran 90)"); break;
1642 case DW_LANG_Pascal83
: printf ("(ANSI Pascal)"); break;
1643 case DW_LANG_Modula2
: printf ("(Modula 2)"); break;
1644 /* DWARF 2.1 values. */
1645 case DW_LANG_Java
: printf ("(Java)"); break;
1646 case DW_LANG_C99
: printf ("(ANSI C99)"); break;
1647 case DW_LANG_Ada95
: printf ("(ADA 95)"); break;
1648 case DW_LANG_Fortran95
: printf ("(Fortran 95)"); break;
1649 /* DWARF 3 values. */
1650 case DW_LANG_PLI
: printf ("(PLI)"); break;
1651 case DW_LANG_ObjC
: printf ("(Objective C)"); break;
1652 case DW_LANG_ObjC_plus_plus
: printf ("(Objective C++)"); break;
1653 case DW_LANG_UPC
: printf ("(Unified Parallel C)"); break;
1654 case DW_LANG_D
: printf ("(D)"); break;
1655 /* DWARF 4 values. */
1656 case DW_LANG_Python
: printf ("(Python)"); break;
1657 /* DWARF 5 values. */
1658 case DW_LANG_Go
: printf ("(Go)"); break;
1659 /* MIPS extension. */
1660 case DW_LANG_Mips_Assembler
: printf ("(MIPS assembler)"); break;
1661 /* UPC extension. */
1662 case DW_LANG_Upc
: printf ("(Unified Parallel C)"); break;
1664 if (uvalue
>= DW_LANG_lo_user
&& uvalue
<= DW_LANG_hi_user
)
1665 printf (_("(implementation defined: %s)"),
1666 dwarf_vmatoa ("x", uvalue
));
1668 printf (_("(Unknown: %s)"), dwarf_vmatoa ("x", uvalue
));
1673 case DW_AT_encoding
:
1676 case DW_ATE_void
: printf ("(void)"); break;
1677 case DW_ATE_address
: printf ("(machine address)"); break;
1678 case DW_ATE_boolean
: printf ("(boolean)"); break;
1679 case DW_ATE_complex_float
: printf ("(complex float)"); break;
1680 case DW_ATE_float
: printf ("(float)"); break;
1681 case DW_ATE_signed
: printf ("(signed)"); break;
1682 case DW_ATE_signed_char
: printf ("(signed char)"); break;
1683 case DW_ATE_unsigned
: printf ("(unsigned)"); break;
1684 case DW_ATE_unsigned_char
: printf ("(unsigned char)"); break;
1685 /* DWARF 2.1 values: */
1686 case DW_ATE_imaginary_float
: printf ("(imaginary float)"); break;
1687 case DW_ATE_decimal_float
: printf ("(decimal float)"); break;
1688 /* DWARF 3 values: */
1689 case DW_ATE_packed_decimal
: printf ("(packed_decimal)"); break;
1690 case DW_ATE_numeric_string
: printf ("(numeric_string)"); break;
1691 case DW_ATE_edited
: printf ("(edited)"); break;
1692 case DW_ATE_signed_fixed
: printf ("(signed_fixed)"); break;
1693 case DW_ATE_unsigned_fixed
: printf ("(unsigned_fixed)"); break;
1694 /* HP extensions: */
1695 case DW_ATE_HP_float80
: printf ("(HP_float80)"); break;
1696 case DW_ATE_HP_complex_float80
: printf ("(HP_complex_float80)"); break;
1697 case DW_ATE_HP_float128
: printf ("(HP_float128)"); break;
1698 case DW_ATE_HP_complex_float128
:printf ("(HP_complex_float128)"); break;
1699 case DW_ATE_HP_floathpintel
: printf ("(HP_floathpintel)"); break;
1700 case DW_ATE_HP_imaginary_float80
: printf ("(HP_imaginary_float80)"); break;
1701 case DW_ATE_HP_imaginary_float128
: printf ("(HP_imaginary_float128)"); break;
1704 if (uvalue
>= DW_ATE_lo_user
1705 && uvalue
<= DW_ATE_hi_user
)
1706 printf (_("(user defined type)"));
1708 printf (_("(unknown type)"));
1713 case DW_AT_accessibility
:
1716 case DW_ACCESS_public
: printf ("(public)"); break;
1717 case DW_ACCESS_protected
: printf ("(protected)"); break;
1718 case DW_ACCESS_private
: printf ("(private)"); break;
1720 printf (_("(unknown accessibility)"));
1725 case DW_AT_visibility
:
1728 case DW_VIS_local
: printf ("(local)"); break;
1729 case DW_VIS_exported
: printf ("(exported)"); break;
1730 case DW_VIS_qualified
: printf ("(qualified)"); break;
1731 default: printf (_("(unknown visibility)")); break;
1735 case DW_AT_virtuality
:
1738 case DW_VIRTUALITY_none
: printf ("(none)"); break;
1739 case DW_VIRTUALITY_virtual
: printf ("(virtual)"); break;
1740 case DW_VIRTUALITY_pure_virtual
:printf ("(pure_virtual)"); break;
1741 default: printf (_("(unknown virtuality)")); break;
1745 case DW_AT_identifier_case
:
1748 case DW_ID_case_sensitive
: printf ("(case_sensitive)"); break;
1749 case DW_ID_up_case
: printf ("(up_case)"); break;
1750 case DW_ID_down_case
: printf ("(down_case)"); break;
1751 case DW_ID_case_insensitive
: printf ("(case_insensitive)"); break;
1752 default: printf (_("(unknown case)")); break;
1756 case DW_AT_calling_convention
:
1759 case DW_CC_normal
: printf ("(normal)"); break;
1760 case DW_CC_program
: printf ("(program)"); break;
1761 case DW_CC_nocall
: printf ("(nocall)"); break;
1763 if (uvalue
>= DW_CC_lo_user
1764 && uvalue
<= DW_CC_hi_user
)
1765 printf (_("(user defined)"));
1767 printf (_("(unknown convention)"));
1771 case DW_AT_ordering
:
1774 case -1: printf (_("(undefined)")); break;
1775 case 0: printf ("(row major)"); break;
1776 case 1: printf ("(column major)"); break;
1780 case DW_AT_frame_base
:
1781 have_frame_base
= 1;
1782 case DW_AT_location
:
1783 case DW_AT_string_length
:
1784 case DW_AT_return_addr
:
1785 case DW_AT_data_member_location
:
1786 case DW_AT_vtable_elem_location
:
1788 case DW_AT_static_link
:
1789 case DW_AT_use_location
:
1790 case DW_AT_GNU_call_site_value
:
1791 case DW_AT_GNU_call_site_data_value
:
1792 case DW_AT_GNU_call_site_target
:
1793 case DW_AT_GNU_call_site_target_clobbered
:
1794 if ((dwarf_version
< 4
1795 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
1796 || form
== DW_FORM_sec_offset
)
1797 printf (_("(location list)"));
1799 case DW_AT_allocated
:
1800 case DW_AT_associated
:
1801 case DW_AT_data_location
:
1803 case DW_AT_upper_bound
:
1804 case DW_AT_lower_bound
:
1807 int need_frame_base
;
1810 need_frame_base
= decode_location_expression (block_start
,
1815 cu_offset
, section
);
1817 if (need_frame_base
&& !have_frame_base
)
1818 printf (_(" [without DW_AT_frame_base]"));
1824 if (form
== DW_FORM_ref_sig8
1825 || form
== DW_FORM_GNU_ref_alt
)
1828 if (form
== DW_FORM_ref1
1829 || form
== DW_FORM_ref2
1830 || form
== DW_FORM_ref4
1831 || form
== DW_FORM_ref_udata
)
1832 uvalue
+= cu_offset
;
1834 if (uvalue
>= section
->size
)
1835 warn (_("Offset %s used as value for DW_AT_import attribute of DIE at offset %lx is too big.\n"),
1836 dwarf_vmatoa ("x", uvalue
),
1837 (unsigned long) (orig_data
- section
->start
));
1840 unsigned long abbrev_number
;
1841 abbrev_entry
* entry
;
1843 abbrev_number
= read_leb128 (section
->start
+ uvalue
, NULL
, 0);
1845 printf (_("[Abbrev Number: %ld"), abbrev_number
);
1846 /* Don't look up abbrev for DW_FORM_ref_addr, as it very often will
1847 use different abbrev table, and we don't track .debug_info chunks
1849 if (form
!= DW_FORM_ref_addr
)
1851 for (entry
= first_abbrev
; entry
!= NULL
; entry
= entry
->next
)
1852 if (entry
->entry
== abbrev_number
)
1855 printf (" (%s)", get_TAG_name (entry
->tag
));
1870 get_AT_name (unsigned long attribute
)
1875 return "DW_AT value: 0";
1877 /* One value is shared by the MIPS and HP extensions: */
1878 if (attribute
== DW_AT_MIPS_fde
)
1879 return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable";
1881 name
= get_DW_AT_name (attribute
);
1885 static char buffer
[100];
1887 snprintf (buffer
, sizeof (buffer
), _("Unknown AT value: %lx"),
1895 static unsigned char *
1896 read_and_display_attr (unsigned long attribute
,
1898 unsigned char * data
,
1899 dwarf_vma cu_offset
,
1900 dwarf_vma pointer_size
,
1901 dwarf_vma offset_size
,
1903 debug_info
* debug_info_p
,
1905 struct dwarf_section
* section
)
1908 printf (" %-18s:", get_AT_name (attribute
));
1909 data
= read_and_display_attr_value (attribute
, form
, data
, cu_offset
,
1910 pointer_size
, offset_size
,
1911 dwarf_version
, debug_info_p
,
1919 /* Process the contents of a .debug_info section. If do_loc is non-zero
1920 then we are scanning for location lists and we do not want to display
1921 anything to the user. If do_types is non-zero, we are processing
1922 a .debug_types section instead of a .debug_info section. */
1925 process_debug_info (struct dwarf_section
*section
,
1927 enum dwarf_section_display_enum abbrev_sec
,
1931 unsigned char *start
= section
->start
;
1932 unsigned char *end
= start
+ section
->size
;
1933 unsigned char *section_begin
;
1935 unsigned int num_units
= 0;
1937 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1938 && num_debug_info_entries
== 0
1943 /* First scan the section to get the number of comp units. */
1944 for (section_begin
= start
, num_units
= 0; section_begin
< end
;
1947 /* Read the first 4 bytes. For a 32-bit DWARF section, this
1948 will be the length. For a 64-bit DWARF section, it'll be
1949 the escape code 0xffffffff followed by an 8 byte length. */
1950 length
= byte_get (section_begin
, 4);
1952 if (length
== 0xffffffff)
1954 length
= byte_get (section_begin
+ 4, 8);
1955 section_begin
+= length
+ 12;
1957 else if (length
>= 0xfffffff0 && length
< 0xffffffff)
1959 warn (_("Reserved length value (0x%s) found in section %s\n"),
1960 dwarf_vmatoa ("x", length
), section
->name
);
1964 section_begin
+= length
+ 4;
1966 /* Negative values are illegal, they may even cause infinite
1967 looping. This can happen if we can't accurately apply
1968 relocations to an object file. */
1969 if ((signed long) length
<= 0)
1971 warn (_("Corrupt unit length (0x%s) found in section %s\n"),
1972 dwarf_vmatoa ("x", length
), section
->name
);
1979 error (_("No comp units in %s section ?"), section
->name
);
1983 /* Then allocate an array to hold the information. */
1984 debug_information
= (debug_info
*) cmalloc (num_units
,
1985 sizeof (* debug_information
));
1986 if (debug_information
== NULL
)
1988 error (_("Not enough memory for a debug info array of %u entries"),
1996 if (dwarf_start_die
== 0)
1997 printf (_("Contents of the %s section:\n\n"), section
->name
);
1999 load_debug_section (str
, file
);
2000 load_debug_section (str_dwo
, file
);
2001 load_debug_section (str_index
, file
);
2002 load_debug_section (str_index_dwo
, file
);
2003 load_debug_section (debug_addr
, file
);
2006 load_debug_section (abbrev_sec
, file
);
2007 if (debug_displays
[abbrev_sec
].section
.start
== NULL
)
2009 warn (_("Unable to locate %s section!\n"),
2010 debug_displays
[abbrev_sec
].section
.name
);
2014 for (section_begin
= start
, unit
= 0; start
< end
; unit
++)
2016 DWARF2_Internal_CompUnit compunit
;
2017 unsigned char *hdrptr
;
2018 unsigned char *tags
;
2019 int level
, last_level
, saved_level
;
2020 dwarf_vma cu_offset
;
2022 int initial_length_size
;
2023 dwarf_vma signature_high
= 0;
2024 dwarf_vma signature_low
= 0;
2025 dwarf_vma type_offset
= 0;
2029 compunit
.cu_length
= byte_get (hdrptr
, 4);
2032 if (compunit
.cu_length
== 0xffffffff)
2034 compunit
.cu_length
= byte_get (hdrptr
, 8);
2037 initial_length_size
= 12;
2042 initial_length_size
= 4;
2045 compunit
.cu_version
= byte_get (hdrptr
, 2);
2048 cu_offset
= start
- section_begin
;
2050 compunit
.cu_abbrev_offset
= byte_get (hdrptr
, offset_size
);
2051 hdrptr
+= offset_size
;
2053 compunit
.cu_pointer_size
= byte_get (hdrptr
, 1);
2058 byte_get_64 (hdrptr
, &signature_high
, &signature_low
);
2060 type_offset
= byte_get (hdrptr
, offset_size
);
2061 hdrptr
+= offset_size
;
2064 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2065 && num_debug_info_entries
== 0
2068 debug_information
[unit
].cu_offset
= cu_offset
;
2069 debug_information
[unit
].pointer_size
2070 = compunit
.cu_pointer_size
;
2071 debug_information
[unit
].offset_size
= offset_size
;
2072 debug_information
[unit
].dwarf_version
= compunit
.cu_version
;
2073 debug_information
[unit
].base_address
= 0;
2074 debug_information
[unit
].addr_base
= DEBUG_INFO_UNAVAILABLE
;
2075 debug_information
[unit
].ranges_base
= DEBUG_INFO_UNAVAILABLE
;
2076 debug_information
[unit
].loc_offsets
= NULL
;
2077 debug_information
[unit
].have_frame_base
= NULL
;
2078 debug_information
[unit
].max_loc_offsets
= 0;
2079 debug_information
[unit
].num_loc_offsets
= 0;
2080 debug_information
[unit
].range_lists
= NULL
;
2081 debug_information
[unit
].max_range_lists
= 0;
2082 debug_information
[unit
].num_range_lists
= 0;
2085 if (!do_loc
&& dwarf_start_die
== 0)
2087 printf (_(" Compilation Unit @ offset 0x%s:\n"),
2088 dwarf_vmatoa ("x", cu_offset
));
2089 printf (_(" Length: 0x%s (%s)\n"),
2090 dwarf_vmatoa ("x", compunit
.cu_length
),
2091 offset_size
== 8 ? "64-bit" : "32-bit");
2092 printf (_(" Version: %d\n"), compunit
.cu_version
);
2093 printf (_(" Abbrev Offset: 0x%s\n"),
2094 dwarf_vmatoa ("x", compunit
.cu_abbrev_offset
));
2095 printf (_(" Pointer Size: %d\n"), compunit
.cu_pointer_size
);
2100 printf (_(" Signature: 0x%s\n"),
2101 dwarf_vmatoa64 (signature_high
, signature_low
,
2102 buf
, sizeof (buf
)));
2103 printf (_(" Type Offset: 0x%s\n"),
2104 dwarf_vmatoa ("x", type_offset
));
2108 if (cu_offset
+ compunit
.cu_length
+ initial_length_size
2111 warn (_("Debug info is corrupted, length of CU at %s"
2112 " extends beyond end of section (length = %s)\n"),
2113 dwarf_vmatoa ("x", cu_offset
),
2114 dwarf_vmatoa ("x", compunit
.cu_length
));
2118 start
+= compunit
.cu_length
+ initial_length_size
;
2120 if (compunit
.cu_version
!= 2
2121 && compunit
.cu_version
!= 3
2122 && compunit
.cu_version
!= 4)
2124 warn (_("CU at offset %s contains corrupt or "
2125 "unsupported version number: %d.\n"),
2126 dwarf_vmatoa ("x", cu_offset
), compunit
.cu_version
);
2132 /* Process the abbrevs used by this compilation unit. DWARF
2133 sections under Mach-O have non-zero addresses. */
2134 if (compunit
.cu_abbrev_offset
>= debug_displays
[abbrev_sec
].section
.size
)
2135 warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"),
2136 (unsigned long) compunit
.cu_abbrev_offset
,
2137 (unsigned long) debug_displays
[abbrev_sec
].section
.size
);
2139 process_abbrev_section
2140 ((unsigned char *) debug_displays
[abbrev_sec
].section
.start
2141 + compunit
.cu_abbrev_offset
,
2142 (unsigned char *) debug_displays
[abbrev_sec
].section
.start
2143 + debug_displays
[abbrev_sec
].section
.size
);
2148 while (tags
< start
)
2150 unsigned int bytes_read
;
2151 unsigned long abbrev_number
;
2152 unsigned long die_offset
;
2153 abbrev_entry
*entry
;
2155 int do_printing
= 1;
2157 die_offset
= tags
- section_begin
;
2159 abbrev_number
= read_leb128 (tags
, & bytes_read
, 0);
2162 /* A null DIE marks the end of a list of siblings or it may also be
2163 a section padding. */
2164 if (abbrev_number
== 0)
2166 /* Check if it can be a section padding for the last CU. */
2167 if (level
== 0 && start
== end
)
2171 for (chk
= tags
; chk
< start
; chk
++)
2178 if (!do_loc
&& die_offset
>= dwarf_start_die
)
2179 printf (_(" <%d><%lx>: Abbrev Number: 0\n"),
2185 static unsigned num_bogus_warns
= 0;
2187 if (num_bogus_warns
< 3)
2189 warn (_("Bogus end-of-siblings marker detected at offset %lx in %s section\n"),
2190 die_offset
, section
->name
);
2192 if (num_bogus_warns
== 3)
2193 warn (_("Further warnings about bogus end-of-sibling markers suppressed\n"));
2196 if (dwarf_start_die
!= 0 && level
< saved_level
)
2203 if (dwarf_start_die
!= 0 && die_offset
< dwarf_start_die
)
2207 if (dwarf_start_die
!= 0 && die_offset
== dwarf_start_die
)
2208 saved_level
= level
;
2209 do_printing
= (dwarf_cutoff_level
== -1
2210 || level
< dwarf_cutoff_level
);
2212 printf (_(" <%d><%lx>: Abbrev Number: %lu"),
2213 level
, die_offset
, abbrev_number
);
2214 else if (dwarf_cutoff_level
== -1
2215 || last_level
< dwarf_cutoff_level
)
2216 printf (_(" <%d><%lx>: ...\n"), level
, die_offset
);
2221 /* Scan through the abbreviation list until we reach the
2223 for (entry
= first_abbrev
;
2224 entry
&& entry
->entry
!= abbrev_number
;
2225 entry
= entry
->next
)
2230 if (!do_loc
&& do_printing
)
2235 warn (_("DIE at offset %lx refers to abbreviation number %lu which does not exist\n"),
2236 die_offset
, abbrev_number
);
2240 if (!do_loc
&& do_printing
)
2241 printf (" (%s)\n", get_TAG_name (entry
->tag
));
2246 need_base_address
= 0;
2248 case DW_TAG_compile_unit
:
2249 need_base_address
= 1;
2251 case DW_TAG_entry_point
:
2252 case DW_TAG_subprogram
:
2253 need_base_address
= 0;
2254 /* Assuming that there is no DW_AT_frame_base. */
2255 have_frame_base
= 0;
2259 for (attr
= entry
->first_attr
;
2260 attr
&& attr
->attribute
;
2265 if (! do_loc
&& do_printing
)
2266 /* Show the offset from where the tag was extracted. */
2267 printf (" <%lx>", (unsigned long)(tags
- section_begin
));
2269 arg
= debug_information
;
2270 if (debug_information
)
2273 tags
= read_and_display_attr (attr
->attribute
,
2276 compunit
.cu_pointer_size
,
2278 compunit
.cu_version
,
2280 do_loc
|| ! do_printing
, section
);
2283 if (entry
->children
)
2288 /* Set num_debug_info_entries here so that it can be used to check if
2289 we need to process .debug_loc and .debug_ranges sections. */
2290 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2291 && num_debug_info_entries
== 0
2293 num_debug_info_entries
= num_units
;
2301 /* Locate and scan the .debug_info section in the file and record the pointer
2302 sizes and offsets for the compilation units in it. Usually an executable
2303 will have just one pointer size, but this is not guaranteed, and so we try
2304 not to make any assumptions. Returns zero upon failure, or the number of
2305 compilation units upon success. */
2308 load_debug_info (void * file
)
2310 /* Reset the last pointer size so that we can issue correct error
2311 messages if we are displaying the contents of more than one section. */
2312 last_pointer_size
= 0;
2313 warned_about_missing_comp_units
= FALSE
;
2315 /* If we have already tried and failed to load the .debug_info
2316 section then do not bother to repear the task. */
2317 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
2320 /* If we already have the information there is nothing else to do. */
2321 if (num_debug_info_entries
> 0)
2322 return num_debug_info_entries
;
2324 if (load_debug_section (info
, file
)
2325 && process_debug_info (&debug_displays
[info
].section
, file
, abbrev
, 1, 0))
2326 return num_debug_info_entries
;
2327 else if (load_debug_section (info_dwo
, file
)
2328 && process_debug_info (&debug_displays
[info_dwo
].section
, file
,
2330 return num_debug_info_entries
;
2332 num_debug_info_entries
= DEBUG_INFO_UNAVAILABLE
;
2337 display_debug_lines_raw (struct dwarf_section
*section
,
2338 unsigned char *data
,
2341 unsigned char *start
= section
->start
;
2343 printf (_("Raw dump of debug contents of section %s:\n\n"),
2348 DWARF2_Internal_LineInfo linfo
;
2349 unsigned char *standard_opcodes
;
2350 unsigned char *end_of_sequence
;
2351 unsigned char *hdrptr
;
2352 unsigned long hdroff
;
2353 int initial_length_size
;
2358 hdroff
= hdrptr
- start
;
2360 /* Check the length of the block. */
2361 linfo
.li_length
= byte_get (hdrptr
, 4);
2364 if (linfo
.li_length
== 0xffffffff)
2366 /* This section is 64-bit DWARF 3. */
2367 linfo
.li_length
= byte_get (hdrptr
, 8);
2370 initial_length_size
= 12;
2375 initial_length_size
= 4;
2378 if (linfo
.li_length
+ initial_length_size
> section
->size
)
2381 (_("The information in section %s appears to be corrupt - the section is too small\n"),
2386 /* Check its version number. */
2387 linfo
.li_version
= byte_get (hdrptr
, 2);
2389 if (linfo
.li_version
!= 2
2390 && linfo
.li_version
!= 3
2391 && linfo
.li_version
!= 4)
2393 warn (_("Only DWARF version 2, 3 and 4 line info is currently supported.\n"));
2397 linfo
.li_prologue_length
= byte_get (hdrptr
, offset_size
);
2398 hdrptr
+= offset_size
;
2399 linfo
.li_min_insn_length
= byte_get (hdrptr
, 1);
2401 if (linfo
.li_version
>= 4)
2403 linfo
.li_max_ops_per_insn
= byte_get (hdrptr
, 1);
2405 if (linfo
.li_max_ops_per_insn
== 0)
2407 warn (_("Invalid maximum operations per insn.\n"));
2412 linfo
.li_max_ops_per_insn
= 1;
2413 linfo
.li_default_is_stmt
= byte_get (hdrptr
, 1);
2415 linfo
.li_line_base
= byte_get (hdrptr
, 1);
2417 linfo
.li_line_range
= byte_get (hdrptr
, 1);
2419 linfo
.li_opcode_base
= byte_get (hdrptr
, 1);
2422 /* Sign extend the line base field. */
2423 linfo
.li_line_base
<<= 24;
2424 linfo
.li_line_base
>>= 24;
2426 printf (_(" Offset: 0x%lx\n"), hdroff
);
2427 printf (_(" Length: %ld\n"), (long) linfo
.li_length
);
2428 printf (_(" DWARF Version: %d\n"), linfo
.li_version
);
2429 printf (_(" Prologue Length: %d\n"), linfo
.li_prologue_length
);
2430 printf (_(" Minimum Instruction Length: %d\n"), linfo
.li_min_insn_length
);
2431 if (linfo
.li_version
>= 4)
2432 printf (_(" Maximum Ops per Instruction: %d\n"), linfo
.li_max_ops_per_insn
);
2433 printf (_(" Initial value of 'is_stmt': %d\n"), linfo
.li_default_is_stmt
);
2434 printf (_(" Line Base: %d\n"), linfo
.li_line_base
);
2435 printf (_(" Line Range: %d\n"), linfo
.li_line_range
);
2436 printf (_(" Opcode Base: %d\n"), linfo
.li_opcode_base
);
2438 end_of_sequence
= data
+ linfo
.li_length
+ initial_length_size
;
2440 reset_state_machine (linfo
.li_default_is_stmt
);
2442 /* Display the contents of the Opcodes table. */
2443 standard_opcodes
= hdrptr
;
2445 printf (_("\n Opcodes:\n"));
2447 for (i
= 1; i
< linfo
.li_opcode_base
; i
++)
2448 printf (_(" Opcode %d has %d args\n"), i
, standard_opcodes
[i
- 1]);
2450 /* Display the contents of the Directory table. */
2451 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
2454 printf (_("\n The Directory Table is empty.\n"));
2457 printf (_("\n The Directory Table:\n"));
2461 printf (" %s\n", data
);
2463 data
+= strlen ((char *) data
) + 1;
2467 /* Skip the NUL at the end of the table. */
2470 /* Display the contents of the File Name table. */
2472 printf (_("\n The File Name Table is empty.\n"));
2475 printf (_("\n The File Name Table:\n"));
2476 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
2480 unsigned char *name
;
2481 unsigned int bytes_read
;
2483 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
2486 data
+= strlen ((char *) data
) + 1;
2489 dwarf_vmatoa ("u", read_leb128 (data
, & bytes_read
, 0)));
2492 dwarf_vmatoa ("u", read_leb128 (data
, & bytes_read
, 0)));
2495 dwarf_vmatoa ("u", read_leb128 (data
, & bytes_read
, 0)));
2497 printf ("%s\n", name
);
2501 /* Skip the NUL at the end of the table. */
2504 /* Now display the statements. */
2505 printf (_("\n Line Number Statements:\n"));
2507 while (data
< end_of_sequence
)
2509 unsigned char op_code
;
2510 dwarf_signed_vma adv
;
2512 unsigned int bytes_read
;
2516 if (op_code
>= linfo
.li_opcode_base
)
2518 op_code
-= linfo
.li_opcode_base
;
2519 uladv
= (op_code
/ linfo
.li_line_range
);
2520 if (linfo
.li_max_ops_per_insn
== 1)
2522 uladv
*= linfo
.li_min_insn_length
;
2523 state_machine_regs
.address
+= uladv
;
2524 printf (_(" Special opcode %d: "
2525 "advance Address by %s to 0x%s"),
2526 op_code
, dwarf_vmatoa ("u", uladv
),
2527 dwarf_vmatoa ("x", state_machine_regs
.address
));
2531 state_machine_regs
.address
2532 += ((state_machine_regs
.op_index
+ uladv
)
2533 / linfo
.li_max_ops_per_insn
)
2534 * linfo
.li_min_insn_length
;
2535 state_machine_regs
.op_index
2536 = (state_machine_regs
.op_index
+ uladv
)
2537 % linfo
.li_max_ops_per_insn
;
2538 printf (_(" Special opcode %d: "
2539 "advance Address by %s to 0x%s[%d]"),
2540 op_code
, dwarf_vmatoa ("u", uladv
),
2541 dwarf_vmatoa ("x", state_machine_regs
.address
),
2542 state_machine_regs
.op_index
);
2544 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
2545 state_machine_regs
.line
+= adv
;
2546 printf (_(" and Line by %s to %d\n"),
2547 dwarf_vmatoa ("d", adv
), state_machine_regs
.line
);
2549 else switch (op_code
)
2551 case DW_LNS_extended_op
:
2552 data
+= process_extended_line_op (data
, linfo
.li_default_is_stmt
);
2556 printf (_(" Copy\n"));
2559 case DW_LNS_advance_pc
:
2560 uladv
= read_leb128 (data
, & bytes_read
, 0);
2562 if (linfo
.li_max_ops_per_insn
== 1)
2564 uladv
*= linfo
.li_min_insn_length
;
2565 state_machine_regs
.address
+= uladv
;
2566 printf (_(" Advance PC by %s to 0x%s\n"),
2567 dwarf_vmatoa ("u", uladv
),
2568 dwarf_vmatoa ("x", state_machine_regs
.address
));
2572 state_machine_regs
.address
2573 += ((state_machine_regs
.op_index
+ uladv
)
2574 / linfo
.li_max_ops_per_insn
)
2575 * linfo
.li_min_insn_length
;
2576 state_machine_regs
.op_index
2577 = (state_machine_regs
.op_index
+ uladv
)
2578 % linfo
.li_max_ops_per_insn
;
2579 printf (_(" Advance PC by %s to 0x%s[%d]\n"),
2580 dwarf_vmatoa ("u", uladv
),
2581 dwarf_vmatoa ("x", state_machine_regs
.address
),
2582 state_machine_regs
.op_index
);
2586 case DW_LNS_advance_line
:
2587 adv
= read_sleb128 (data
, & bytes_read
);
2589 state_machine_regs
.line
+= adv
;
2590 printf (_(" Advance Line by %s to %d\n"),
2591 dwarf_vmatoa ("d", adv
),
2592 state_machine_regs
.line
);
2595 case DW_LNS_set_file
:
2596 adv
= read_leb128 (data
, & bytes_read
, 0);
2598 printf (_(" Set File Name to entry %s in the File Name Table\n"),
2599 dwarf_vmatoa ("d", adv
));
2600 state_machine_regs
.file
= adv
;
2603 case DW_LNS_set_column
:
2604 uladv
= read_leb128 (data
, & bytes_read
, 0);
2606 printf (_(" Set column to %s\n"),
2607 dwarf_vmatoa ("u", uladv
));
2608 state_machine_regs
.column
= uladv
;
2611 case DW_LNS_negate_stmt
:
2612 adv
= state_machine_regs
.is_stmt
;
2614 printf (_(" Set is_stmt to %s\n"), dwarf_vmatoa ("d", adv
));
2615 state_machine_regs
.is_stmt
= adv
;
2618 case DW_LNS_set_basic_block
:
2619 printf (_(" Set basic block\n"));
2620 state_machine_regs
.basic_block
= 1;
2623 case DW_LNS_const_add_pc
:
2624 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
2625 if (linfo
.li_max_ops_per_insn
)
2627 uladv
*= linfo
.li_min_insn_length
;
2628 state_machine_regs
.address
+= uladv
;
2629 printf (_(" Advance PC by constant %s to 0x%s\n"),
2630 dwarf_vmatoa ("u", uladv
),
2631 dwarf_vmatoa ("x", state_machine_regs
.address
));
2635 state_machine_regs
.address
2636 += ((state_machine_regs
.op_index
+ uladv
)
2637 / linfo
.li_max_ops_per_insn
)
2638 * linfo
.li_min_insn_length
;
2639 state_machine_regs
.op_index
2640 = (state_machine_regs
.op_index
+ uladv
)
2641 % linfo
.li_max_ops_per_insn
;
2642 printf (_(" Advance PC by constant %s to 0x%s[%d]\n"),
2643 dwarf_vmatoa ("u", uladv
),
2644 dwarf_vmatoa ("x", state_machine_regs
.address
),
2645 state_machine_regs
.op_index
);
2649 case DW_LNS_fixed_advance_pc
:
2650 uladv
= byte_get (data
, 2);
2652 state_machine_regs
.address
+= uladv
;
2653 state_machine_regs
.op_index
= 0;
2654 printf (_(" Advance PC by fixed size amount %s to 0x%s\n"),
2655 dwarf_vmatoa ("u", uladv
),
2656 dwarf_vmatoa ("x", state_machine_regs
.address
));
2659 case DW_LNS_set_prologue_end
:
2660 printf (_(" Set prologue_end to true\n"));
2663 case DW_LNS_set_epilogue_begin
:
2664 printf (_(" Set epilogue_begin to true\n"));
2667 case DW_LNS_set_isa
:
2668 uladv
= read_leb128 (data
, & bytes_read
, 0);
2670 printf (_(" Set ISA to %s\n"), dwarf_vmatoa ("u", uladv
));
2674 printf (_(" Unknown opcode %d with operands: "), op_code
);
2676 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
2678 printf ("0x%s%s", dwarf_vmatoa ("x", read_leb128 (data
,
2680 i
== 1 ? "" : ", ");
2695 unsigned char *name
;
2696 unsigned int directory_index
;
2697 unsigned int modification_date
;
2698 unsigned int length
;
2701 /* Output a decoded representation of the .debug_line section. */
2704 display_debug_lines_decoded (struct dwarf_section
*section
,
2705 unsigned char *data
,
2708 printf (_("Decoded dump of debug contents of section %s:\n\n"),
2713 /* This loop amounts to one iteration per compilation unit. */
2714 DWARF2_Internal_LineInfo linfo
;
2715 unsigned char *standard_opcodes
;
2716 unsigned char *end_of_sequence
;
2717 unsigned char *hdrptr
;
2718 int initial_length_size
;
2721 File_Entry
*file_table
= NULL
;
2722 unsigned int n_files
= 0;
2723 unsigned char **directory_table
= NULL
;
2724 unsigned int n_directories
= 0;
2728 /* Extract information from the Line Number Program Header.
2729 (section 6.2.4 in the Dwarf3 doc). */
2731 /* Get the length of this CU's line number information block. */
2732 linfo
.li_length
= byte_get (hdrptr
, 4);
2735 if (linfo
.li_length
== 0xffffffff)
2737 /* This section is 64-bit DWARF 3. */
2738 linfo
.li_length
= byte_get (hdrptr
, 8);
2741 initial_length_size
= 12;
2746 initial_length_size
= 4;
2749 if (linfo
.li_length
+ initial_length_size
> section
->size
)
2751 warn (_("The line info appears to be corrupt - "
2752 "the section is too small\n"));
2756 /* Get this CU's Line Number Block version number. */
2757 linfo
.li_version
= byte_get (hdrptr
, 2);
2759 if (linfo
.li_version
!= 2
2760 && linfo
.li_version
!= 3
2761 && linfo
.li_version
!= 4)
2763 warn (_("Only DWARF version 2, 3 and 4 line info is currently "
2768 linfo
.li_prologue_length
= byte_get (hdrptr
, offset_size
);
2769 hdrptr
+= offset_size
;
2770 linfo
.li_min_insn_length
= byte_get (hdrptr
, 1);
2772 if (linfo
.li_version
>= 4)
2774 linfo
.li_max_ops_per_insn
= byte_get (hdrptr
, 1);
2776 if (linfo
.li_max_ops_per_insn
== 0)
2778 warn (_("Invalid maximum operations per insn.\n"));
2783 linfo
.li_max_ops_per_insn
= 1;
2784 linfo
.li_default_is_stmt
= byte_get (hdrptr
, 1);
2786 linfo
.li_line_base
= byte_get (hdrptr
, 1);
2788 linfo
.li_line_range
= byte_get (hdrptr
, 1);
2790 linfo
.li_opcode_base
= byte_get (hdrptr
, 1);
2793 /* Sign extend the line base field. */
2794 linfo
.li_line_base
<<= 24;
2795 linfo
.li_line_base
>>= 24;
2797 /* Find the end of this CU's Line Number Information Block. */
2798 end_of_sequence
= data
+ linfo
.li_length
+ initial_length_size
;
2800 reset_state_machine (linfo
.li_default_is_stmt
);
2802 /* Save a pointer to the contents of the Opcodes table. */
2803 standard_opcodes
= hdrptr
;
2805 /* Traverse the Directory table just to count entries. */
2806 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
2809 unsigned char *ptr_directory_table
= data
;
2813 data
+= strlen ((char *) data
) + 1;
2817 /* Go through the directory table again to save the directories. */
2818 directory_table
= (unsigned char **)
2819 xmalloc (n_directories
* sizeof (unsigned char *));
2822 while (*ptr_directory_table
!= 0)
2824 directory_table
[i
] = ptr_directory_table
;
2825 ptr_directory_table
+= strlen ((char *) ptr_directory_table
) + 1;
2829 /* Skip the NUL at the end of the table. */
2832 /* Traverse the File Name table just to count the entries. */
2835 unsigned char *ptr_file_name_table
= data
;
2839 unsigned int bytes_read
;
2841 /* Skip Name, directory index, last modification time and length
2843 data
+= strlen ((char *) data
) + 1;
2844 read_leb128 (data
, & bytes_read
, 0);
2846 read_leb128 (data
, & bytes_read
, 0);
2848 read_leb128 (data
, & bytes_read
, 0);
2854 /* Go through the file table again to save the strings. */
2855 file_table
= (File_Entry
*) xmalloc (n_files
* sizeof (File_Entry
));
2858 while (*ptr_file_name_table
!= 0)
2860 unsigned int bytes_read
;
2862 file_table
[i
].name
= ptr_file_name_table
;
2863 ptr_file_name_table
+= strlen ((char *) ptr_file_name_table
) + 1;
2865 /* We are not interested in directory, time or size. */
2866 file_table
[i
].directory_index
= read_leb128 (ptr_file_name_table
,
2868 ptr_file_name_table
+= bytes_read
;
2869 file_table
[i
].modification_date
= read_leb128 (ptr_file_name_table
,
2871 ptr_file_name_table
+= bytes_read
;
2872 file_table
[i
].length
= read_leb128 (ptr_file_name_table
, & bytes_read
, 0);
2873 ptr_file_name_table
+= bytes_read
;
2878 /* Print the Compilation Unit's name and a header. */
2879 if (directory_table
== NULL
)
2881 printf (_("CU: %s:\n"), file_table
[0].name
);
2882 printf (_("File name Line number Starting address\n"));
2886 unsigned int ix
= file_table
[0].directory_index
;
2887 const char *directory
= ix
? (char *)directory_table
[ix
- 1] : ".";
2888 if (do_wide
|| strlen (directory
) < 76)
2889 printf (_("CU: %s/%s:\n"), directory
, file_table
[0].name
);
2891 printf ("%s:\n", file_table
[0].name
);
2893 printf (_("File name Line number Starting address\n"));
2897 /* Skip the NUL at the end of the table. */
2900 /* This loop iterates through the Dwarf Line Number Program. */
2901 while (data
< end_of_sequence
)
2903 unsigned char op_code
;
2905 unsigned long int uladv
;
2906 unsigned int bytes_read
;
2907 int is_special_opcode
= 0;
2911 if (op_code
>= linfo
.li_opcode_base
)
2913 op_code
-= linfo
.li_opcode_base
;
2914 uladv
= (op_code
/ linfo
.li_line_range
);
2915 if (linfo
.li_max_ops_per_insn
== 1)
2917 uladv
*= linfo
.li_min_insn_length
;
2918 state_machine_regs
.address
+= uladv
;
2922 state_machine_regs
.address
2923 += ((state_machine_regs
.op_index
+ uladv
)
2924 / linfo
.li_max_ops_per_insn
)
2925 * linfo
.li_min_insn_length
;
2926 state_machine_regs
.op_index
2927 = (state_machine_regs
.op_index
+ uladv
)
2928 % linfo
.li_max_ops_per_insn
;
2931 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
2932 state_machine_regs
.line
+= adv
;
2933 is_special_opcode
= 1;
2935 else switch (op_code
)
2937 case DW_LNS_extended_op
:
2939 unsigned int ext_op_code_len
;
2940 unsigned char ext_op_code
;
2941 unsigned char *op_code_data
= data
;
2943 ext_op_code_len
= read_leb128 (op_code_data
, &bytes_read
, 0);
2944 op_code_data
+= bytes_read
;
2946 if (ext_op_code_len
== 0)
2948 warn (_("badly formed extended line op encountered!\n"));
2951 ext_op_code_len
+= bytes_read
;
2952 ext_op_code
= *op_code_data
++;
2954 switch (ext_op_code
)
2956 case DW_LNE_end_sequence
:
2957 reset_state_machine (linfo
.li_default_is_stmt
);
2959 case DW_LNE_set_address
:
2960 state_machine_regs
.address
=
2961 byte_get (op_code_data
, ext_op_code_len
- bytes_read
- 1);
2962 state_machine_regs
.op_index
= 0;
2964 case DW_LNE_define_file
:
2966 file_table
= (File_Entry
*) xrealloc
2967 (file_table
, (n_files
+ 1) * sizeof (File_Entry
));
2969 ++state_machine_regs
.last_file_entry
;
2970 /* Source file name. */
2971 file_table
[n_files
].name
= op_code_data
;
2972 op_code_data
+= strlen ((char *) op_code_data
) + 1;
2973 /* Directory index. */
2974 file_table
[n_files
].directory_index
=
2975 read_leb128 (op_code_data
, & bytes_read
, 0);
2976 op_code_data
+= bytes_read
;
2977 /* Last modification time. */
2978 file_table
[n_files
].modification_date
=
2979 read_leb128 (op_code_data
, & bytes_read
, 0);
2980 op_code_data
+= bytes_read
;
2982 file_table
[n_files
].length
=
2983 read_leb128 (op_code_data
, & bytes_read
, 0);
2988 case DW_LNE_set_discriminator
:
2989 case DW_LNE_HP_set_sequence
:
2990 /* Simply ignored. */
2994 printf (_("UNKNOWN (%u): length %d\n"),
2995 ext_op_code
, ext_op_code_len
- bytes_read
);
2998 data
+= ext_op_code_len
;
3004 case DW_LNS_advance_pc
:
3005 uladv
= read_leb128 (data
, & bytes_read
, 0);
3007 if (linfo
.li_max_ops_per_insn
== 1)
3009 uladv
*= linfo
.li_min_insn_length
;
3010 state_machine_regs
.address
+= uladv
;
3014 state_machine_regs
.address
3015 += ((state_machine_regs
.op_index
+ uladv
)
3016 / linfo
.li_max_ops_per_insn
)
3017 * linfo
.li_min_insn_length
;
3018 state_machine_regs
.op_index
3019 = (state_machine_regs
.op_index
+ uladv
)
3020 % linfo
.li_max_ops_per_insn
;
3024 case DW_LNS_advance_line
:
3025 adv
= read_sleb128 (data
, & bytes_read
);
3027 state_machine_regs
.line
+= adv
;
3030 case DW_LNS_set_file
:
3031 adv
= read_leb128 (data
, & bytes_read
, 0);
3033 state_machine_regs
.file
= adv
;
3034 if (file_table
[state_machine_regs
.file
- 1].directory_index
== 0)
3036 /* If directory index is 0, that means current directory. */
3037 printf ("\n./%s:[++]\n",
3038 file_table
[state_machine_regs
.file
- 1].name
);
3042 /* The directory index starts counting at 1. */
3043 printf ("\n%s/%s:\n",
3044 directory_table
[file_table
[state_machine_regs
.file
- 1].directory_index
- 1],
3045 file_table
[state_machine_regs
.file
- 1].name
);
3049 case DW_LNS_set_column
:
3050 uladv
= read_leb128 (data
, & bytes_read
, 0);
3052 state_machine_regs
.column
= uladv
;
3055 case DW_LNS_negate_stmt
:
3056 adv
= state_machine_regs
.is_stmt
;
3058 state_machine_regs
.is_stmt
= adv
;
3061 case DW_LNS_set_basic_block
:
3062 state_machine_regs
.basic_block
= 1;
3065 case DW_LNS_const_add_pc
:
3066 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
3067 if (linfo
.li_max_ops_per_insn
== 1)
3069 uladv
*= linfo
.li_min_insn_length
;
3070 state_machine_regs
.address
+= uladv
;
3074 state_machine_regs
.address
3075 += ((state_machine_regs
.op_index
+ uladv
)
3076 / linfo
.li_max_ops_per_insn
)
3077 * linfo
.li_min_insn_length
;
3078 state_machine_regs
.op_index
3079 = (state_machine_regs
.op_index
+ uladv
)
3080 % linfo
.li_max_ops_per_insn
;
3084 case DW_LNS_fixed_advance_pc
:
3085 uladv
= byte_get (data
, 2);
3087 state_machine_regs
.address
+= uladv
;
3088 state_machine_regs
.op_index
= 0;
3091 case DW_LNS_set_prologue_end
:
3094 case DW_LNS_set_epilogue_begin
:
3097 case DW_LNS_set_isa
:
3098 uladv
= read_leb128 (data
, & bytes_read
, 0);
3100 printf (_(" Set ISA to %lu\n"), uladv
);
3104 printf (_(" Unknown opcode %d with operands: "), op_code
);
3106 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
3108 printf ("0x%s%s", dwarf_vmatoa ("x", read_leb128 (data
,
3110 i
== 1 ? "" : ", ");
3117 /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row
3118 to the DWARF address/line matrix. */
3119 if ((is_special_opcode
) || (op_code
== DW_LNE_end_sequence
)
3120 || (op_code
== DW_LNS_copy
))
3122 const unsigned int MAX_FILENAME_LENGTH
= 35;
3123 char *fileName
= (char *)file_table
[state_machine_regs
.file
- 1].name
;
3124 char *newFileName
= NULL
;
3125 size_t fileNameLength
= strlen (fileName
);
3127 if ((fileNameLength
> MAX_FILENAME_LENGTH
) && (!do_wide
))
3129 newFileName
= (char *) xmalloc (MAX_FILENAME_LENGTH
+ 1);
3130 /* Truncate file name */
3131 strncpy (newFileName
,
3132 fileName
+ fileNameLength
- MAX_FILENAME_LENGTH
,
3133 MAX_FILENAME_LENGTH
+ 1);
3137 newFileName
= (char *) xmalloc (fileNameLength
+ 1);
3138 strncpy (newFileName
, fileName
, fileNameLength
+ 1);
3141 if (!do_wide
|| (fileNameLength
<= MAX_FILENAME_LENGTH
))
3143 if (linfo
.li_max_ops_per_insn
== 1)
3144 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x\n",
3145 newFileName
, state_machine_regs
.line
,
3146 state_machine_regs
.address
);
3148 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x[%d]\n",
3149 newFileName
, state_machine_regs
.line
,
3150 state_machine_regs
.address
,
3151 state_machine_regs
.op_index
);
3155 if (linfo
.li_max_ops_per_insn
== 1)
3156 printf ("%s %11d %#18" DWARF_VMA_FMT
"x\n",
3157 newFileName
, state_machine_regs
.line
,
3158 state_machine_regs
.address
);
3160 printf ("%s %11d %#18" DWARF_VMA_FMT
"x[%d]\n",
3161 newFileName
, state_machine_regs
.line
,
3162 state_machine_regs
.address
,
3163 state_machine_regs
.op_index
);
3166 if (op_code
== DW_LNE_end_sequence
)
3174 free (directory_table
);
3175 directory_table
= NULL
;
3183 display_debug_lines (struct dwarf_section
*section
, void *file ATTRIBUTE_UNUSED
)
3185 unsigned char *data
= section
->start
;
3186 unsigned char *end
= data
+ section
->size
;
3188 int retValDecoded
= 1;
3190 if (do_debug_lines
== 0)
3191 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
3193 if (do_debug_lines
& FLAG_DEBUG_LINES_RAW
)
3194 retValRaw
= display_debug_lines_raw (section
, data
, end
);
3196 if (do_debug_lines
& FLAG_DEBUG_LINES_DECODED
)
3197 retValDecoded
= display_debug_lines_decoded (section
, data
, end
);
3199 if (!retValRaw
|| !retValDecoded
)
3206 find_debug_info_for_offset (unsigned long offset
)
3210 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
3213 for (i
= 0; i
< num_debug_info_entries
; i
++)
3214 if (debug_information
[i
].cu_offset
== offset
)
3215 return debug_information
+ i
;
3221 display_debug_pubnames (struct dwarf_section
*section
,
3222 void *file ATTRIBUTE_UNUSED
)
3224 DWARF2_Internal_PubNames names
;
3225 unsigned char *start
= section
->start
;
3226 unsigned char *end
= start
+ section
->size
;
3228 /* It does not matter if this load fails,
3229 we test for that later on. */
3230 load_debug_info (file
);
3232 printf (_("Contents of the %s section:\n\n"), section
->name
);
3236 unsigned char *data
;
3237 unsigned long offset
;
3238 int offset_size
, initial_length_size
;
3242 names
.pn_length
= byte_get (data
, 4);
3244 if (names
.pn_length
== 0xffffffff)
3246 names
.pn_length
= byte_get (data
, 8);
3249 initial_length_size
= 12;
3254 initial_length_size
= 4;
3257 names
.pn_version
= byte_get (data
, 2);
3260 names
.pn_offset
= byte_get (data
, offset_size
);
3261 data
+= offset_size
;
3263 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
3264 && num_debug_info_entries
> 0
3265 && find_debug_info_for_offset (names
.pn_offset
) == NULL
)
3266 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
3267 (unsigned long) names
.pn_offset
, section
->name
);
3269 names
.pn_size
= byte_get (data
, offset_size
);
3270 data
+= offset_size
;
3272 start
+= names
.pn_length
+ initial_length_size
;
3274 if (names
.pn_version
!= 2 && names
.pn_version
!= 3)
3276 static int warned
= 0;
3280 warn (_("Only DWARF 2 and 3 pubnames are currently supported\n"));
3287 printf (_(" Length: %ld\n"),
3288 (long) names
.pn_length
);
3289 printf (_(" Version: %d\n"),
3291 printf (_(" Offset into .debug_info section: 0x%lx\n"),
3292 (unsigned long) names
.pn_offset
);
3293 printf (_(" Size of area in .debug_info section: %ld\n"),
3294 (long) names
.pn_size
);
3296 printf (_("\n Offset\tName\n"));
3300 offset
= byte_get (data
, offset_size
);
3304 data
+= offset_size
;
3305 printf (" %-6lx\t%s\n", offset
, data
);
3306 data
+= strlen ((char *) data
) + 1;
3309 while (offset
!= 0);
3317 display_debug_macinfo (struct dwarf_section
*section
,
3318 void *file ATTRIBUTE_UNUSED
)
3320 unsigned char *start
= section
->start
;
3321 unsigned char *end
= start
+ section
->size
;
3322 unsigned char *curr
= start
;
3323 unsigned int bytes_read
;
3324 enum dwarf_macinfo_record_type op
;
3326 printf (_("Contents of the %s section:\n\n"), section
->name
);
3330 unsigned int lineno
;
3333 op
= (enum dwarf_macinfo_record_type
) *curr
;
3338 case DW_MACINFO_start_file
:
3340 unsigned int filenum
;
3342 lineno
= read_leb128 (curr
, & bytes_read
, 0);
3344 filenum
= read_leb128 (curr
, & bytes_read
, 0);
3347 printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"),
3352 case DW_MACINFO_end_file
:
3353 printf (_(" DW_MACINFO_end_file\n"));
3356 case DW_MACINFO_define
:
3357 lineno
= read_leb128 (curr
, & bytes_read
, 0);
3359 string
= (char *) curr
;
3360 curr
+= strlen (string
) + 1;
3361 printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"),
3365 case DW_MACINFO_undef
:
3366 lineno
= read_leb128 (curr
, & bytes_read
, 0);
3368 string
= (char *) curr
;
3369 curr
+= strlen (string
) + 1;
3370 printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"),
3374 case DW_MACINFO_vendor_ext
:
3376 unsigned int constant
;
3378 constant
= read_leb128 (curr
, & bytes_read
, 0);
3380 string
= (char *) curr
;
3381 curr
+= strlen (string
) + 1;
3382 printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"),
3392 /* Given LINE_OFFSET into the .debug_line section, attempt to return
3393 filename and dirname corresponding to file name table entry with index
3394 FILEIDX. Return NULL on failure. */
3396 static unsigned char *
3397 get_line_filename_and_dirname (dwarf_vma line_offset
, dwarf_vma fileidx
,
3398 unsigned char **dir_name
)
3400 struct dwarf_section
*section
= &debug_displays
[line
].section
;
3401 unsigned char *hdrptr
, *dirtable
, *file_name
;
3402 unsigned int offset_size
, initial_length_size
;
3403 unsigned int version
, opcode_base
, bytes_read
;
3404 dwarf_vma length
, diridx
;
3407 if (section
->start
== NULL
3408 || line_offset
>= section
->size
3412 hdrptr
= section
->start
+ line_offset
;
3413 length
= byte_get (hdrptr
, 4);
3415 if (length
== 0xffffffff)
3417 /* This section is 64-bit DWARF 3. */
3418 length
= byte_get (hdrptr
, 8);
3421 initial_length_size
= 12;
3426 initial_length_size
= 4;
3428 if (length
+ initial_length_size
> section
->size
)
3430 version
= byte_get (hdrptr
, 2);
3432 if (version
!= 2 && version
!= 3 && version
!= 4)
3434 hdrptr
+= offset_size
+ 1;/* Skip prologue_length and min_insn_length. */
3436 hdrptr
++; /* Skip max_ops_per_insn. */
3437 hdrptr
+= 3; /* Skip default_is_stmt, line_base, line_range. */
3438 opcode_base
= byte_get (hdrptr
, 1);
3439 if (opcode_base
== 0)
3442 hdrptr
+= opcode_base
- 1;
3444 /* Skip over dirname table. */
3445 while (*hdrptr
!= '\0')
3446 hdrptr
+= strlen ((char *) hdrptr
) + 1;
3447 hdrptr
++; /* Skip the NUL at the end of the table. */
3448 /* Now skip over preceding filename table entries. */
3449 for (; *hdrptr
!= '\0' && fileidx
> 1; fileidx
--)
3451 hdrptr
+= strlen ((char *) hdrptr
) + 1;
3452 read_leb128 (hdrptr
, &bytes_read
, 0);
3453 hdrptr
+= bytes_read
;
3454 read_leb128 (hdrptr
, &bytes_read
, 0);
3455 hdrptr
+= bytes_read
;
3456 read_leb128 (hdrptr
, &bytes_read
, 0);
3457 hdrptr
+= bytes_read
;
3459 if (*hdrptr
== '\0')
3462 hdrptr
+= strlen ((char *) hdrptr
) + 1;
3463 diridx
= read_leb128 (hdrptr
, &bytes_read
, 0);
3466 for (; *dirtable
!= '\0' && diridx
> 1; diridx
--)
3467 dirtable
+= strlen ((char *) dirtable
) + 1;
3468 if (*dirtable
== '\0')
3470 *dir_name
= dirtable
;
3475 display_debug_macro (struct dwarf_section
*section
,
3478 unsigned char *start
= section
->start
;
3479 unsigned char *end
= start
+ section
->size
;
3480 unsigned char *curr
= start
;
3481 unsigned char *extended_op_buf
[256];
3482 unsigned int bytes_read
;
3484 load_debug_section (str
, file
);
3485 load_debug_section (line
, file
);
3487 printf (_("Contents of the %s section:\n\n"), section
->name
);
3491 unsigned int lineno
, version
, flags
;
3492 unsigned int offset_size
= 4;
3494 dwarf_vma line_offset
= 0, sec_offset
= curr
- start
, offset
;
3495 unsigned char **extended_ops
= NULL
;
3497 version
= byte_get (curr
, 2);
3502 error (_("Only GNU extension to DWARF 4 of %s is currently supported.\n"),
3507 flags
= byte_get (curr
++, 1);
3510 printf (_(" Offset: 0x%lx\n"),
3511 (unsigned long) sec_offset
);
3512 printf (_(" Version: %d\n"), version
);
3513 printf (_(" Offset size: %d\n"), offset_size
);
3516 line_offset
= byte_get (curr
, offset_size
);
3517 curr
+= offset_size
;
3518 printf (_(" Offset into .debug_line: 0x%lx\n"),
3519 (unsigned long) line_offset
);
3523 unsigned int i
, count
= byte_get (curr
++, 1), op
;
3525 memset (extended_op_buf
, 0, sizeof (extended_op_buf
));
3526 extended_ops
= extended_op_buf
;
3529 printf (_(" Extension opcode arguments:\n"));
3530 for (i
= 0; i
< count
; i
++)
3532 op
= byte_get (curr
++, 1);
3533 extended_ops
[op
] = curr
;
3534 nargs
= read_leb128 (curr
, &bytes_read
, 0);
3537 printf (_(" DW_MACRO_GNU_%02x has no arguments\n"), op
);
3540 printf (_(" DW_MACRO_GNU_%02x arguments: "), op
);
3541 for (n
= 0; n
< nargs
; n
++)
3543 unsigned int form
= byte_get (curr
++, 1);
3544 printf ("%s%s", get_FORM_name (form
),
3545 n
== nargs
- 1 ? "\n" : ", ");
3555 case DW_FORM_block1
:
3556 case DW_FORM_block2
:
3557 case DW_FORM_block4
:
3559 case DW_FORM_string
:
3561 case DW_FORM_sec_offset
:
3564 error (_("Invalid extension opcode form %s\n"),
3565 get_FORM_name (form
));
3581 error (_(".debug_macro section not zero terminated\n"));
3585 op
= byte_get (curr
++, 1);
3591 case DW_MACRO_GNU_start_file
:
3593 unsigned int filenum
;
3594 unsigned char *file_name
= NULL
, *dir_name
= NULL
;
3596 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3598 filenum
= read_leb128 (curr
, &bytes_read
, 0);
3601 if ((flags
& 2) == 0)
3602 error (_("DW_MACRO_GNU_start_file used, but no .debug_line offset provided.\n"));
3605 = get_line_filename_and_dirname (line_offset
, filenum
,
3607 if (file_name
== NULL
)
3608 printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d\n"),
3611 printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d filename: %s%s%s\n"),
3613 dir_name
!= NULL
? (const char *) dir_name
: "",
3614 dir_name
!= NULL
? "/" : "", file_name
);
3618 case DW_MACRO_GNU_end_file
:
3619 printf (_(" DW_MACRO_GNU_end_file\n"));
3622 case DW_MACRO_GNU_define
:
3623 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3625 string
= (char *) curr
;
3626 curr
+= strlen (string
) + 1;
3627 printf (_(" DW_MACRO_GNU_define - lineno : %d macro : %s\n"),
3631 case DW_MACRO_GNU_undef
:
3632 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3634 string
= (char *) curr
;
3635 curr
+= strlen (string
) + 1;
3636 printf (_(" DW_MACRO_GNU_undef - lineno : %d macro : %s\n"),
3640 case DW_MACRO_GNU_define_indirect
:
3641 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3643 offset
= byte_get (curr
, offset_size
);
3644 curr
+= offset_size
;
3645 string
= fetch_indirect_string (offset
);
3646 printf (_(" DW_MACRO_GNU_define_indirect - lineno : %d macro : %s\n"),
3650 case DW_MACRO_GNU_undef_indirect
:
3651 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3653 offset
= byte_get (curr
, offset_size
);
3654 curr
+= offset_size
;
3655 string
= fetch_indirect_string (offset
);
3656 printf (_(" DW_MACRO_GNU_undef_indirect - lineno : %d macro : %s\n"),
3660 case DW_MACRO_GNU_transparent_include
:
3661 offset
= byte_get (curr
, offset_size
);
3662 curr
+= offset_size
;
3663 printf (_(" DW_MACRO_GNU_transparent_include - offset : 0x%lx\n"),
3664 (unsigned long) offset
);
3667 case DW_MACRO_GNU_define_indirect_alt
:
3668 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3670 offset
= byte_get (curr
, offset_size
);
3671 curr
+= offset_size
;
3672 printf (_(" DW_MACRO_GNU_define_indirect_alt - lineno : %d macro offset : 0x%lx\n"),
3673 lineno
, (unsigned long) offset
);
3676 case DW_MACRO_GNU_undef_indirect_alt
:
3677 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3679 offset
= byte_get (curr
, offset_size
);
3680 curr
+= offset_size
;
3681 printf (_(" DW_MACRO_GNU_undef_indirect_alt - lineno : %d macro offset : 0x%lx\n"),
3682 lineno
, (unsigned long) offset
);
3685 case DW_MACRO_GNU_transparent_include_alt
:
3686 offset
= byte_get (curr
, offset_size
);
3687 curr
+= offset_size
;
3688 printf (_(" DW_MACRO_GNU_transparent_include_alt - offset : 0x%lx\n"),
3689 (unsigned long) offset
);
3693 if (extended_ops
== NULL
|| extended_ops
[op
] == NULL
)
3695 error (_(" Unknown macro opcode %02x seen\n"), op
);
3700 /* Skip over unhandled opcodes. */
3702 unsigned char *desc
= extended_ops
[op
];
3703 nargs
= read_leb128 (desc
, &bytes_read
, 0);
3707 printf (_(" DW_MACRO_GNU_%02x\n"), op
);
3710 printf (_(" DW_MACRO_GNU_%02x -"), op
);
3711 for (n
= 0; n
< nargs
; n
++)
3714 = read_and_display_attr_value (0, byte_get (desc
++, 1),
3715 curr
, 0, 0, offset_size
,
3716 version
, NULL
, 0, NULL
);
3733 display_debug_abbrev (struct dwarf_section
*section
,
3734 void *file ATTRIBUTE_UNUSED
)
3736 abbrev_entry
*entry
;
3737 unsigned char *start
= section
->start
;
3738 unsigned char *end
= start
+ section
->size
;
3740 printf (_("Contents of the %s section:\n\n"), section
->name
);
3744 unsigned char *last
;
3749 start
= process_abbrev_section (start
, end
);
3751 if (first_abbrev
== NULL
)
3754 printf (_(" Number TAG (0x%lx)\n"), (long) (last
- section
->start
));
3756 for (entry
= first_abbrev
; entry
; entry
= entry
->next
)
3760 printf (" %ld %s [%s]\n",
3762 get_TAG_name (entry
->tag
),
3763 entry
->children
? _("has children") : _("no children"));
3765 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
3766 printf (" %-18s %s\n",
3767 get_AT_name (attr
->attribute
),
3768 get_FORM_name (attr
->form
));
3778 /* Display a location list from a normal (ie, non-dwo) .debug_loc section. */
3781 display_loc_list (struct dwarf_section
*section
,
3782 unsigned char **start_ptr
,
3783 int debug_info_entry
,
3784 unsigned long offset
,
3785 unsigned long base_address
,
3788 unsigned char *start
= *start_ptr
;
3789 unsigned char *section_end
= section
->start
+ section
->size
;
3790 unsigned long cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
3791 unsigned int pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
3792 unsigned int offset_size
= debug_information
[debug_info_entry
].offset_size
;
3793 int dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
3797 unsigned short length
;
3798 int need_frame_base
;
3802 if (start
+ 2 * pointer_size
> section_end
)
3804 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3809 /* Note: we use sign extension here in order to be sure that we can detect
3810 the -1 escape value. Sign extension into the top 32 bits of a 32-bit
3811 address will not affect the values that we display since we always show
3812 hex values, and always the bottom 32-bits. */
3813 begin
= byte_get_signed (start
, pointer_size
);
3814 start
+= pointer_size
;
3815 end
= byte_get_signed (start
, pointer_size
);
3816 start
+= pointer_size
;
3818 printf (" %8.8lx ", offset
);
3820 if (begin
== 0 && end
== 0)
3822 printf (_("<End of list>\n"));
3826 /* Check base address specifiers. */
3827 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
3830 print_dwarf_vma (begin
, pointer_size
);
3831 print_dwarf_vma (end
, pointer_size
);
3832 printf (_("(base address)\n"));
3836 if (start
+ 2 > section_end
)
3838 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3843 length
= byte_get (start
, 2);
3846 if (start
+ length
> section_end
)
3848 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3853 print_dwarf_vma (begin
+ base_address
, pointer_size
);
3854 print_dwarf_vma (end
+ base_address
, pointer_size
);
3857 need_frame_base
= decode_location_expression (start
,
3862 cu_offset
, section
);
3865 if (need_frame_base
&& !has_frame_base
)
3866 printf (_(" [without DW_AT_frame_base]"));
3869 fputs (_(" (start == end)"), stdout
);
3870 else if (begin
> end
)
3871 fputs (_(" (start > end)"), stdout
);
3881 /* Display a location list from a .dwo section. It uses address indexes rather
3882 than embedded addresses. This code closely follows display_loc_list, but the
3883 two are sufficiently different that combining things is very ugly. */
3886 display_loc_list_dwo (struct dwarf_section
*section
,
3887 unsigned char **start_ptr
,
3888 int debug_info_entry
,
3889 unsigned long offset
,
3892 unsigned char *start
= *start_ptr
;
3893 unsigned char *section_end
= section
->start
+ section
->size
;
3894 unsigned long cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
3895 unsigned int pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
3896 unsigned int offset_size
= debug_information
[debug_info_entry
].offset_size
;
3897 int dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
3899 unsigned short length
;
3900 int need_frame_base
;
3902 unsigned int bytes_read
;
3906 printf (" %8.8lx ", offset
);
3908 if (start
+ 2 > section_end
)
3910 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3915 entry_type
= byte_get (start
, 1);
3919 case 0: /* A terminating entry. */
3920 idx
= byte_get (start
, 1);
3924 printf (_("<End of list>\n"));
3926 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3929 case 1: /* A base-address entry. */
3930 idx
= read_leb128 (start
, &bytes_read
, 0);
3931 start
+= bytes_read
;
3932 print_dwarf_vma (idx
, pointer_size
);
3933 printf (_("(base address index)\n"));
3935 case 2: /* A normal entry. */
3936 idx
= read_leb128 (start
, &bytes_read
, 0);
3937 start
+= bytes_read
;
3938 print_dwarf_vma (idx
, pointer_size
);
3939 idx
= read_leb128 (start
, &bytes_read
, 0);
3940 start
+= bytes_read
;
3941 print_dwarf_vma (idx
, pointer_size
);
3944 warn (_("Unknown location-list type 0x%x.\n"), entry_type
);
3949 if (start
+ 2 > section_end
)
3951 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3956 length
= byte_get (start
, 2);
3959 if (start
+ length
> section_end
)
3961 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3967 need_frame_base
= decode_location_expression (start
,
3972 cu_offset
, section
);
3975 if (need_frame_base
&& !has_frame_base
)
3976 printf (_(" [without DW_AT_frame_base]"));
3986 /* Sort array of indexes in ascending order of loc_offsets[idx]. */
3988 static dwarf_vma
*loc_offsets
;
3991 loc_offsets_compar (const void *ap
, const void *bp
)
3993 dwarf_vma a
= loc_offsets
[*(const unsigned int *) ap
];
3994 dwarf_vma b
= loc_offsets
[*(const unsigned int *) bp
];
3996 return (a
> b
) - (b
> a
);
4000 display_debug_loc (struct dwarf_section
*section
, void *file
)
4002 unsigned char *start
= section
->start
;
4003 unsigned long bytes
;
4004 unsigned char *section_begin
= start
;
4005 unsigned int num_loc_list
= 0;
4006 unsigned long last_offset
= 0;
4007 unsigned int first
= 0;
4011 int seen_first_offset
= 0;
4012 int locs_sorted
= 1;
4013 unsigned char *next
;
4014 unsigned int *array
= NULL
;
4015 const char *suffix
= strrchr (section
->name
, '.');
4018 if (suffix
&& strcmp (suffix
, ".dwo") == 0)
4021 bytes
= section
->size
;
4025 printf (_("\nThe %s section is empty.\n"), section
->name
);
4029 if (load_debug_info (file
) == 0)
4031 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4036 /* Check the order of location list in .debug_info section. If
4037 offsets of location lists are in the ascending order, we can
4038 use `debug_information' directly. */
4039 for (i
= 0; i
< num_debug_info_entries
; i
++)
4043 num
= debug_information
[i
].num_loc_offsets
;
4044 if (num
> num_loc_list
)
4047 /* Check if we can use `debug_information' directly. */
4048 if (locs_sorted
&& num
!= 0)
4050 if (!seen_first_offset
)
4052 /* This is the first location list. */
4053 last_offset
= debug_information
[i
].loc_offsets
[0];
4055 seen_first_offset
= 1;
4061 for (; j
< num
; j
++)
4064 debug_information
[i
].loc_offsets
[j
])
4069 last_offset
= debug_information
[i
].loc_offsets
[j
];
4074 if (!seen_first_offset
)
4075 error (_("No location lists in .debug_info section!\n"));
4077 /* DWARF sections under Mach-O have non-zero addresses. */
4078 if (debug_information
[first
].num_loc_offsets
> 0
4079 && debug_information
[first
].loc_offsets
[0] != section
->address
)
4080 warn (_("Location lists in %s section start at 0x%s\n"),
4082 dwarf_vmatoa ("x", debug_information
[first
].loc_offsets
[0]));
4085 array
= (unsigned int *) xcmalloc (num_loc_list
, sizeof (unsigned int));
4086 printf (_("Contents of the %s section:\n\n"), section
->name
);
4088 printf (_(" Offset Begin End Expression\n"));
4090 printf (_(" Offset Begin idx End idx Expression\n"));
4092 seen_first_offset
= 0;
4093 for (i
= first
; i
< num_debug_info_entries
; i
++)
4095 unsigned long offset
;
4096 unsigned long base_address
;
4101 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
4103 loc_offsets
= debug_information
[i
].loc_offsets
;
4104 qsort (array
, debug_information
[i
].num_loc_offsets
,
4105 sizeof (*array
), loc_offsets_compar
);
4108 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
4110 j
= locs_sorted
? k
: array
[k
];
4112 && debug_information
[i
].loc_offsets
[locs_sorted
4113 ? k
- 1 : array
[k
- 1]]
4114 == debug_information
[i
].loc_offsets
[j
])
4116 has_frame_base
= debug_information
[i
].have_frame_base
[j
];
4117 /* DWARF sections under Mach-O have non-zero addresses. */
4118 offset
= debug_information
[i
].loc_offsets
[j
] - section
->address
;
4119 next
= section_begin
+ offset
;
4120 base_address
= debug_information
[i
].base_address
;
4122 if (!seen_first_offset
)
4123 seen_first_offset
= 1;
4127 warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"),
4128 (unsigned long) (start
- section_begin
),
4129 (unsigned long) (next
- section_begin
));
4130 else if (start
> next
)
4131 warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"),
4132 (unsigned long) (start
- section_begin
),
4133 (unsigned long) (next
- section_begin
));
4137 if (offset
>= bytes
)
4139 warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"),
4145 display_loc_list_dwo (section
, &start
, i
, offset
, has_frame_base
);
4147 display_loc_list (section
, &start
, i
, offset
, base_address
,
4152 if (start
< section
->start
+ section
->size
)
4153 warn (_("There are %ld unused bytes at the end of section %s\n"),
4154 (long) (section
->start
+ section
->size
- start
), section
->name
);
4161 display_debug_str (struct dwarf_section
*section
,
4162 void *file ATTRIBUTE_UNUSED
)
4164 unsigned char *start
= section
->start
;
4165 unsigned long bytes
= section
->size
;
4166 dwarf_vma addr
= section
->address
;
4170 printf (_("\nThe %s section is empty.\n"), section
->name
);
4174 printf (_("Contents of the %s section:\n\n"), section
->name
);
4182 lbytes
= (bytes
> 16 ? 16 : bytes
);
4184 printf (" 0x%8.8lx ", (unsigned long) addr
);
4186 for (j
= 0; j
< 16; j
++)
4189 printf ("%2.2x", start
[j
]);
4197 for (j
= 0; j
< lbytes
; j
++)
4200 if (k
>= ' ' && k
< 0x80)
4219 display_debug_info (struct dwarf_section
*section
, void *file
)
4221 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 0);
4225 display_debug_types (struct dwarf_section
*section
, void *file
)
4227 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 1);
4231 display_trace_info (struct dwarf_section
*section
, void *file
)
4233 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 0);
4237 display_debug_aranges (struct dwarf_section
*section
,
4238 void *file ATTRIBUTE_UNUSED
)
4240 unsigned char *start
= section
->start
;
4241 unsigned char *end
= start
+ section
->size
;
4243 printf (_("Contents of the %s section:\n\n"), section
->name
);
4245 /* It does not matter if this load fails,
4246 we test for that later on. */
4247 load_debug_info (file
);
4251 unsigned char *hdrptr
;
4252 DWARF2_Internal_ARange arange
;
4253 unsigned char *addr_ranges
;
4256 unsigned char address_size
;
4259 int initial_length_size
;
4263 arange
.ar_length
= byte_get (hdrptr
, 4);
4266 if (arange
.ar_length
== 0xffffffff)
4268 arange
.ar_length
= byte_get (hdrptr
, 8);
4271 initial_length_size
= 12;
4276 initial_length_size
= 4;
4279 arange
.ar_version
= byte_get (hdrptr
, 2);
4282 arange
.ar_info_offset
= byte_get (hdrptr
, offset_size
);
4283 hdrptr
+= offset_size
;
4285 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
4286 && num_debug_info_entries
> 0
4287 && find_debug_info_for_offset (arange
.ar_info_offset
) == NULL
)
4288 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
4289 (unsigned long) arange
.ar_info_offset
, section
->name
);
4291 arange
.ar_pointer_size
= byte_get (hdrptr
, 1);
4294 arange
.ar_segment_size
= byte_get (hdrptr
, 1);
4297 if (arange
.ar_version
!= 2 && arange
.ar_version
!= 3)
4299 warn (_("Only DWARF 2 and 3 aranges are currently supported.\n"));
4303 printf (_(" Length: %ld\n"),
4304 (long) arange
.ar_length
);
4305 printf (_(" Version: %d\n"), arange
.ar_version
);
4306 printf (_(" Offset into .debug_info: 0x%lx\n"),
4307 (unsigned long) arange
.ar_info_offset
);
4308 printf (_(" Pointer Size: %d\n"), arange
.ar_pointer_size
);
4309 printf (_(" Segment Size: %d\n"), arange
.ar_segment_size
);
4311 address_size
= arange
.ar_pointer_size
+ arange
.ar_segment_size
;
4313 if (address_size
== 0)
4315 error (_("Invalid address size in %s section!\n"),
4320 /* The DWARF spec does not require that the address size be a power
4321 of two, but we do. This will have to change if we ever encounter
4322 an uneven architecture. */
4323 if ((address_size
& (address_size
- 1)) != 0)
4325 warn (_("Pointer size + Segment size is not a power of two.\n"));
4329 if (address_size
> 4)
4330 printf (_("\n Address Length\n"));
4332 printf (_("\n Address Length\n"));
4334 addr_ranges
= hdrptr
;
4336 /* Must pad to an alignment boundary that is twice the address size. */
4337 excess
= (hdrptr
- start
) % (2 * address_size
);
4339 addr_ranges
+= (2 * address_size
) - excess
;
4341 start
+= arange
.ar_length
+ initial_length_size
;
4343 while (addr_ranges
+ 2 * address_size
<= start
)
4345 address
= byte_get (addr_ranges
, address_size
);
4347 addr_ranges
+= address_size
;
4349 length
= byte_get (addr_ranges
, address_size
);
4351 addr_ranges
+= address_size
;
4354 print_dwarf_vma (address
, address_size
);
4355 print_dwarf_vma (length
, address_size
);
4365 /* Comparison function for qsort. */
4367 comp_addr_base (const void * v0
, const void * v1
)
4369 debug_info
* info0
= (debug_info
*) v0
;
4370 debug_info
* info1
= (debug_info
*) v1
;
4371 return info0
->addr_base
- info1
->addr_base
;
4374 /* Display the debug_addr section. */
4376 display_debug_addr (struct dwarf_section
*section
,
4379 debug_info
**debug_addr_info
;
4380 unsigned char *entry
;
4385 if (section
->size
== 0)
4387 printf (_("\nThe %s section is empty.\n"), section
->name
);
4391 if (load_debug_info (file
) == 0)
4393 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4398 printf (_("Contents of the %s section:\n\n"), section
->name
);
4400 debug_addr_info
= (debug_info
**) xmalloc (num_debug_info_entries
+ 1
4401 * sizeof (debug_info
*));
4404 for (i
= 0; i
< num_debug_info_entries
; i
++)
4406 if (debug_information
[i
].addr_base
!= DEBUG_INFO_UNAVAILABLE
)
4407 debug_addr_info
[count
++] = &debug_information
[i
];
4410 /* Add a sentinel to make iteration convenient. */
4411 debug_addr_info
[count
] = (debug_info
*) xmalloc (sizeof (debug_info
));
4412 debug_addr_info
[count
]->addr_base
= section
->size
;
4414 qsort (debug_addr_info
, count
, sizeof (debug_info
*), comp_addr_base
);
4415 for (i
= 0; i
< count
; i
++)
4419 printf (_(" For compilation unit at offset 0x%s:\n"),
4420 dwarf_vmatoa ("x", debug_addr_info
[i
]->cu_offset
));
4422 printf (_("\tIndex\tOffset\n"));
4423 entry
= section
->start
+ debug_addr_info
[i
]->addr_base
;
4424 end
= section
->start
+ debug_addr_info
[i
+ 1]->addr_base
;
4428 dwarf_vma base
= byte_get (entry
, debug_addr_info
[i
]->pointer_size
);
4429 printf (_("\t%d:\t%s\n"), idx
, dwarf_vmatoa ("x", base
));
4430 entry
+= debug_addr_info
[i
]->pointer_size
;
4436 free (debug_addr_info
);
4440 /* Display the .debug_str_offsets and .debug_str_offsets.dwo sections. */
4442 display_debug_str_offsets (struct dwarf_section
*section
,
4443 void *file ATTRIBUTE_UNUSED
)
4445 if (section
->size
== 0)
4447 printf (_("\nThe %s section is empty.\n"), section
->name
);
4450 /* TODO: Dump the contents. This is made somewhat difficult by not knowing
4451 what the offset size is for this section. */
4455 /* Each debug_information[x].range_lists[y] gets this representation for
4456 sorting purposes. */
4460 /* The debug_information[x].range_lists[y] value. */
4461 unsigned long ranges_offset
;
4463 /* Original debug_information to find parameters of the data. */
4464 debug_info
*debug_info_p
;
4467 /* Sort struct range_entry in ascending order of its RANGES_OFFSET. */
4470 range_entry_compar (const void *ap
, const void *bp
)
4472 const struct range_entry
*a_re
= (const struct range_entry
*) ap
;
4473 const struct range_entry
*b_re
= (const struct range_entry
*) bp
;
4474 const unsigned long a
= a_re
->ranges_offset
;
4475 const unsigned long b
= b_re
->ranges_offset
;
4477 return (a
> b
) - (b
> a
);
4481 display_debug_ranges (struct dwarf_section
*section
,
4482 void *file ATTRIBUTE_UNUSED
)
4484 unsigned char *start
= section
->start
;
4485 unsigned char *last_start
= start
;
4486 unsigned long bytes
;
4487 unsigned char *section_begin
= start
;
4488 unsigned int num_range_list
, i
;
4489 struct range_entry
*range_entries
, *range_entry_fill
;
4491 bytes
= section
->size
;
4495 printf (_("\nThe %s section is empty.\n"), section
->name
);
4499 if (load_debug_info (file
) == 0)
4501 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4507 for (i
= 0; i
< num_debug_info_entries
; i
++)
4508 num_range_list
+= debug_information
[i
].num_range_lists
;
4510 if (num_range_list
== 0)
4512 /* This can happen when the file was compiled with -gsplit-debug
4513 which removes references to range lists from the primary .o file. */
4514 printf (_("No range lists in .debug_info section.\n"));
4518 range_entries
= (struct range_entry
*)
4519 xmalloc (sizeof (*range_entries
) * num_range_list
);
4520 range_entry_fill
= range_entries
;
4522 for (i
= 0; i
< num_debug_info_entries
; i
++)
4524 debug_info
*debug_info_p
= &debug_information
[i
];
4527 for (j
= 0; j
< debug_info_p
->num_range_lists
; j
++)
4529 range_entry_fill
->ranges_offset
= debug_info_p
->range_lists
[j
];
4530 range_entry_fill
->debug_info_p
= debug_info_p
;
4535 qsort (range_entries
, num_range_list
, sizeof (*range_entries
),
4536 range_entry_compar
);
4538 /* DWARF sections under Mach-O have non-zero addresses. */
4539 if (dwarf_check
!= 0 && range_entries
[0].ranges_offset
!= section
->address
)
4540 warn (_("Range lists in %s section start at 0x%lx\n"),
4541 section
->name
, range_entries
[0].ranges_offset
);
4543 printf (_("Contents of the %s section:\n\n"), section
->name
);
4544 printf (_(" Offset Begin End\n"));
4546 for (i
= 0; i
< num_range_list
; i
++)
4548 struct range_entry
*range_entry
= &range_entries
[i
];
4549 debug_info
*debug_info_p
= range_entry
->debug_info_p
;
4550 unsigned int pointer_size
;
4551 unsigned long offset
;
4552 unsigned char *next
;
4553 unsigned long base_address
;
4555 pointer_size
= debug_info_p
->pointer_size
;
4557 /* DWARF sections under Mach-O have non-zero addresses. */
4558 offset
= range_entry
->ranges_offset
- section
->address
;
4559 next
= section_begin
+ offset
;
4560 base_address
= debug_info_p
->base_address
;
4562 if (dwarf_check
!= 0 && i
> 0)
4565 warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"),
4566 (unsigned long) (start
- section_begin
),
4567 (unsigned long) (next
- section_begin
), section
->name
);
4568 else if (start
> next
)
4570 if (next
== last_start
)
4572 warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"),
4573 (unsigned long) (start
- section_begin
),
4574 (unsigned long) (next
- section_begin
), section
->name
);
4585 /* Note: we use sign extension here in order to be sure that
4586 we can detect the -1 escape value. Sign extension into the
4587 top 32 bits of a 32-bit address will not affect the values
4588 that we display since we always show hex values, and always
4589 the bottom 32-bits. */
4590 begin
= byte_get_signed (start
, pointer_size
);
4591 start
+= pointer_size
;
4592 end
= byte_get_signed (start
, pointer_size
);
4593 start
+= pointer_size
;
4595 printf (" %8.8lx ", offset
);
4597 if (begin
== 0 && end
== 0)
4599 printf (_("<End of list>\n"));
4603 /* Check base address specifiers. */
4604 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
4607 print_dwarf_vma (begin
, pointer_size
);
4608 print_dwarf_vma (end
, pointer_size
);
4609 printf ("(base address)\n");
4613 print_dwarf_vma (begin
+ base_address
, pointer_size
);
4614 print_dwarf_vma (end
+ base_address
, pointer_size
);
4617 fputs (_("(start == end)"), stdout
);
4618 else if (begin
> end
)
4619 fputs (_("(start > end)"), stdout
);
4626 free (range_entries
);
4631 typedef struct Frame_Chunk
4633 struct Frame_Chunk
*next
;
4634 unsigned char *chunk_start
;
4636 /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
4637 short int *col_type
;
4640 unsigned int code_factor
;
4642 unsigned long pc_begin
;
4643 unsigned long pc_range
;
4647 unsigned char fde_encoding
;
4648 unsigned char cfa_exp
;
4649 unsigned char ptr_size
;
4650 unsigned char segment_size
;
4654 static const char *const *dwarf_regnames
;
4655 static unsigned int dwarf_regnames_count
;
4657 /* A marker for a col_type that means this column was never referenced
4658 in the frame info. */
4659 #define DW_CFA_unreferenced (-1)
4661 /* Return 0 if not more space is needed, 1 if more space is needed,
4662 -1 for invalid reg. */
4665 frame_need_space (Frame_Chunk
*fc
, unsigned int reg
)
4667 int prev
= fc
->ncols
;
4669 if (reg
< (unsigned int) fc
->ncols
)
4672 if (dwarf_regnames_count
4673 && reg
> dwarf_regnames_count
)
4676 fc
->ncols
= reg
+ 1;
4677 fc
->col_type
= (short int *) xcrealloc (fc
->col_type
, fc
->ncols
,
4678 sizeof (short int));
4679 fc
->col_offset
= (int *) xcrealloc (fc
->col_offset
, fc
->ncols
, sizeof (int));
4681 while (prev
< fc
->ncols
)
4683 fc
->col_type
[prev
] = DW_CFA_unreferenced
;
4684 fc
->col_offset
[prev
] = 0;
4690 static const char *const dwarf_regnames_i386
[] =
4692 "eax", "ecx", "edx", "ebx",
4693 "esp", "ebp", "esi", "edi",
4694 "eip", "eflags", NULL
,
4695 "st0", "st1", "st2", "st3",
4696 "st4", "st5", "st6", "st7",
4698 "xmm0", "xmm1", "xmm2", "xmm3",
4699 "xmm4", "xmm5", "xmm6", "xmm7",
4700 "mm0", "mm1", "mm2", "mm3",
4701 "mm4", "mm5", "mm6", "mm7",
4702 "fcw", "fsw", "mxcsr",
4703 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
4708 init_dwarf_regnames_i386 (void)
4710 dwarf_regnames
= dwarf_regnames_i386
;
4711 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_i386
);
4714 static const char *const dwarf_regnames_x86_64
[] =
4716 "rax", "rdx", "rcx", "rbx",
4717 "rsi", "rdi", "rbp", "rsp",
4718 "r8", "r9", "r10", "r11",
4719 "r12", "r13", "r14", "r15",
4721 "xmm0", "xmm1", "xmm2", "xmm3",
4722 "xmm4", "xmm5", "xmm6", "xmm7",
4723 "xmm8", "xmm9", "xmm10", "xmm11",
4724 "xmm12", "xmm13", "xmm14", "xmm15",
4725 "st0", "st1", "st2", "st3",
4726 "st4", "st5", "st6", "st7",
4727 "mm0", "mm1", "mm2", "mm3",
4728 "mm4", "mm5", "mm6", "mm7",
4730 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
4731 "fs.base", "gs.base", NULL
, NULL
,
4733 "mxcsr", "fcw", "fsw"
4737 init_dwarf_regnames_x86_64 (void)
4739 dwarf_regnames
= dwarf_regnames_x86_64
;
4740 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_x86_64
);
4744 init_dwarf_regnames (unsigned int e_machine
)
4750 init_dwarf_regnames_i386 ();
4756 init_dwarf_regnames_x86_64 ();
4765 regname (unsigned int regno
, int row
)
4767 static char reg
[64];
4769 && regno
< dwarf_regnames_count
4770 && dwarf_regnames
[regno
] != NULL
)
4773 return dwarf_regnames
[regno
];
4774 snprintf (reg
, sizeof (reg
), "r%d (%s)", regno
,
4775 dwarf_regnames
[regno
]);
4778 snprintf (reg
, sizeof (reg
), "r%d", regno
);
4783 frame_display_row (Frame_Chunk
*fc
, int *need_col_headers
, int *max_regs
)
4788 if (*max_regs
< fc
->ncols
)
4789 *max_regs
= fc
->ncols
;
4791 if (*need_col_headers
)
4793 static const char *sloc
= " LOC";
4795 *need_col_headers
= 0;
4797 printf ("%-*s CFA ", eh_addr_size
* 2, sloc
);
4799 for (r
= 0; r
< *max_regs
; r
++)
4800 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
4805 printf ("%-5s ", regname (r
, 1));
4811 printf ("%0*lx ", eh_addr_size
* 2, fc
->pc_begin
);
4813 strcpy (tmp
, "exp");
4815 sprintf (tmp
, "%s%+d", regname (fc
->cfa_reg
, 1), fc
->cfa_offset
);
4816 printf ("%-8s ", tmp
);
4818 for (r
= 0; r
< fc
->ncols
; r
++)
4820 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
4822 switch (fc
->col_type
[r
])
4824 case DW_CFA_undefined
:
4827 case DW_CFA_same_value
:
4831 sprintf (tmp
, "c%+d", fc
->col_offset
[r
]);
4833 case DW_CFA_val_offset
:
4834 sprintf (tmp
, "v%+d", fc
->col_offset
[r
]);
4836 case DW_CFA_register
:
4837 sprintf (tmp
, "%s", regname (fc
->col_offset
[r
], 0));
4839 case DW_CFA_expression
:
4840 strcpy (tmp
, "exp");
4842 case DW_CFA_val_expression
:
4843 strcpy (tmp
, "vexp");
4846 strcpy (tmp
, "n/a");
4849 printf ("%-5s ", tmp
);
4855 #define GET(N) byte_get (start, N); start += N
4856 #define LEB() read_leb128 (start, & length_return, 0); start += length_return
4857 #define SLEB() read_sleb128 (start, & length_return); start += length_return
4860 display_debug_frames (struct dwarf_section
*section
,
4861 void *file ATTRIBUTE_UNUSED
)
4863 unsigned char *start
= section
->start
;
4864 unsigned char *end
= start
+ section
->size
;
4865 unsigned char *section_start
= start
;
4866 Frame_Chunk
*chunks
= 0;
4867 Frame_Chunk
*remembered_state
= 0;
4869 int is_eh
= strcmp (section
->name
, ".eh_frame") == 0;
4870 unsigned int length_return
;
4872 const char *bad_reg
= _("bad register: ");
4873 int saved_eh_addr_size
= eh_addr_size
;
4875 printf (_("Contents of the %s section:\n"), section
->name
);
4879 unsigned char *saved_start
;
4880 unsigned char *block_end
;
4881 unsigned long length
;
4882 unsigned long cie_id
;
4885 int need_col_headers
= 1;
4886 unsigned char *augmentation_data
= NULL
;
4887 unsigned long augmentation_data_len
= 0;
4888 int encoded_ptr_size
= saved_eh_addr_size
;
4890 int initial_length_size
;
4892 saved_start
= start
;
4893 length
= byte_get (start
, 4); start
+= 4;
4897 printf ("\n%08lx ZERO terminator\n\n",
4898 (unsigned long)(saved_start
- section_start
));
4902 if (length
== 0xffffffff)
4904 length
= byte_get (start
, 8);
4907 initial_length_size
= 12;
4912 initial_length_size
= 4;
4915 block_end
= saved_start
+ length
+ initial_length_size
;
4916 if (block_end
> end
)
4918 warn ("Invalid length %#08lx in FDE at %#08lx\n",
4919 length
, (unsigned long)(saved_start
- section_start
));
4922 cie_id
= byte_get (start
, offset_size
); start
+= offset_size
;
4924 if (is_eh
? (cie_id
== 0) : (cie_id
== DW_CIE_ID
))
4928 fc
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
4929 memset (fc
, 0, sizeof (Frame_Chunk
));
4933 fc
->chunk_start
= saved_start
;
4935 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
4936 fc
->col_offset
= (int *) xmalloc (sizeof (int));
4937 frame_need_space (fc
, max_regs
- 1);
4941 fc
->augmentation
= (char *) start
;
4942 start
= (unsigned char *) strchr ((char *) start
, '\0') + 1;
4944 if (strcmp (fc
->augmentation
, "eh") == 0)
4945 start
+= eh_addr_size
;
4949 fc
->ptr_size
= GET (1);
4950 fc
->segment_size
= GET (1);
4951 eh_addr_size
= fc
->ptr_size
;
4955 fc
->ptr_size
= eh_addr_size
;
4956 fc
->segment_size
= 0;
4958 fc
->code_factor
= LEB ();
4959 fc
->data_factor
= SLEB ();
4969 if (fc
->augmentation
[0] == 'z')
4971 augmentation_data_len
= LEB ();
4972 augmentation_data
= start
;
4973 start
+= augmentation_data_len
;
4977 if (do_debug_frames_interp
)
4978 printf ("\n%08lx %08lx %08lx CIE \"%s\" cf=%d df=%d ra=%d\n",
4979 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
4980 fc
->augmentation
, fc
->code_factor
, fc
->data_factor
,
4984 printf ("\n%08lx %08lx %08lx CIE\n",
4985 (unsigned long)(saved_start
- section_start
), length
, cie_id
);
4986 printf (" Version: %d\n", version
);
4987 printf (" Augmentation: \"%s\"\n", fc
->augmentation
);
4990 printf (" Pointer Size: %u\n", fc
->ptr_size
);
4991 printf (" Segment Size: %u\n", fc
->segment_size
);
4993 printf (" Code alignment factor: %u\n", fc
->code_factor
);
4994 printf (" Data alignment factor: %d\n", fc
->data_factor
);
4995 printf (" Return address column: %d\n", fc
->ra
);
4997 if (augmentation_data_len
)
5000 printf (" Augmentation data: ");
5001 for (i
= 0; i
< augmentation_data_len
; ++i
)
5002 printf (" %02x", augmentation_data
[i
]);
5008 if (augmentation_data_len
)
5010 unsigned char *p
, *q
;
5011 p
= (unsigned char *) fc
->augmentation
+ 1;
5012 q
= augmentation_data
;
5019 q
+= 1 + size_of_encoded_value (*q
);
5021 fc
->fde_encoding
= *q
++;
5029 if (fc
->fde_encoding
)
5030 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
5033 frame_need_space (fc
, fc
->ra
);
5037 unsigned char *look_for
;
5038 static Frame_Chunk fde_fc
;
5039 unsigned long segment_selector
;
5042 memset (fc
, 0, sizeof (Frame_Chunk
));
5044 look_for
= is_eh
? start
- 4 - cie_id
: section_start
+ cie_id
;
5046 for (cie
= chunks
; cie
; cie
= cie
->next
)
5047 if (cie
->chunk_start
== look_for
)
5052 warn ("Invalid CIE pointer %#08lx in FDE at %#08lx\n",
5053 cie_id
, (unsigned long)(saved_start
- section_start
));
5055 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
5056 fc
->col_offset
= (int *) xmalloc (sizeof (int));
5057 frame_need_space (fc
, max_regs
- 1);
5059 fc
->augmentation
= "";
5060 fc
->fde_encoding
= 0;
5061 fc
->ptr_size
= eh_addr_size
;
5062 fc
->segment_size
= 0;
5066 fc
->ncols
= cie
->ncols
;
5067 fc
->col_type
= (short int *) xcmalloc (fc
->ncols
, sizeof (short int));
5068 fc
->col_offset
= (int *) xcmalloc (fc
->ncols
, sizeof (int));
5069 memcpy (fc
->col_type
, cie
->col_type
, fc
->ncols
* sizeof (short int));
5070 memcpy (fc
->col_offset
, cie
->col_offset
, fc
->ncols
* sizeof (int));
5071 fc
->augmentation
= cie
->augmentation
;
5072 fc
->ptr_size
= cie
->ptr_size
;
5073 eh_addr_size
= cie
->ptr_size
;
5074 fc
->segment_size
= cie
->segment_size
;
5075 fc
->code_factor
= cie
->code_factor
;
5076 fc
->data_factor
= cie
->data_factor
;
5077 fc
->cfa_reg
= cie
->cfa_reg
;
5078 fc
->cfa_offset
= cie
->cfa_offset
;
5080 frame_need_space (fc
, max_regs
- 1);
5081 fc
->fde_encoding
= cie
->fde_encoding
;
5084 if (fc
->fde_encoding
)
5085 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
5087 segment_selector
= 0;
5088 if (fc
->segment_size
)
5090 segment_selector
= byte_get (start
, fc
->segment_size
);
5091 start
+= fc
->segment_size
;
5093 fc
->pc_begin
= get_encoded_value (start
, fc
->fde_encoding
, section
);
5094 start
+= encoded_ptr_size
;
5095 fc
->pc_range
= byte_get (start
, encoded_ptr_size
);
5096 start
+= encoded_ptr_size
;
5098 if (cie
->augmentation
[0] == 'z')
5100 augmentation_data_len
= LEB ();
5101 augmentation_data
= start
;
5102 start
+= augmentation_data_len
;
5105 printf ("\n%08lx %08lx %08lx FDE cie=%08lx pc=",
5106 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
5107 (unsigned long)(cie
->chunk_start
- section_start
));
5108 if (fc
->segment_size
)
5109 printf ("%04lx:", segment_selector
);
5110 printf ("%08lx..%08lx\n", fc
->pc_begin
, fc
->pc_begin
+ fc
->pc_range
);
5111 if (! do_debug_frames_interp
&& augmentation_data_len
)
5115 printf (" Augmentation data: ");
5116 for (i
= 0; i
< augmentation_data_len
; ++i
)
5117 printf (" %02x", augmentation_data
[i
]);
5123 /* At this point, fc is the current chunk, cie (if any) is set, and
5124 we're about to interpret instructions for the chunk. */
5125 /* ??? At present we need to do this always, since this sizes the
5126 fc->col_type and fc->col_offset arrays, which we write into always.
5127 We should probably split the interpreted and non-interpreted bits
5128 into two different routines, since there's so much that doesn't
5129 really overlap between them. */
5130 if (1 || do_debug_frames_interp
)
5132 /* Start by making a pass over the chunk, allocating storage
5133 and taking note of what registers are used. */
5134 unsigned char *tmp
= start
;
5136 while (start
< block_end
)
5139 unsigned long reg
, temp
;
5146 /* Warning: if you add any more cases to this switch, be
5147 sure to add them to the corresponding switch below. */
5150 case DW_CFA_advance_loc
:
5154 if (frame_need_space (fc
, opa
) >= 0)
5155 fc
->col_type
[opa
] = DW_CFA_undefined
;
5157 case DW_CFA_restore
:
5158 if (frame_need_space (fc
, opa
) >= 0)
5159 fc
->col_type
[opa
] = DW_CFA_undefined
;
5161 case DW_CFA_set_loc
:
5162 start
+= encoded_ptr_size
;
5164 case DW_CFA_advance_loc1
:
5167 case DW_CFA_advance_loc2
:
5170 case DW_CFA_advance_loc4
:
5173 case DW_CFA_offset_extended
:
5174 case DW_CFA_val_offset
:
5175 reg
= LEB (); LEB ();
5176 if (frame_need_space (fc
, reg
) >= 0)
5177 fc
->col_type
[reg
] = DW_CFA_undefined
;
5179 case DW_CFA_restore_extended
:
5181 frame_need_space (fc
, reg
);
5182 if (frame_need_space (fc
, reg
) >= 0)
5183 fc
->col_type
[reg
] = DW_CFA_undefined
;
5185 case DW_CFA_undefined
:
5187 if (frame_need_space (fc
, reg
) >= 0)
5188 fc
->col_type
[reg
] = DW_CFA_undefined
;
5190 case DW_CFA_same_value
:
5192 if (frame_need_space (fc
, reg
) >= 0)
5193 fc
->col_type
[reg
] = DW_CFA_undefined
;
5195 case DW_CFA_register
:
5196 reg
= LEB (); LEB ();
5197 if (frame_need_space (fc
, reg
) >= 0)
5198 fc
->col_type
[reg
] = DW_CFA_undefined
;
5200 case DW_CFA_def_cfa
:
5203 case DW_CFA_def_cfa_register
:
5206 case DW_CFA_def_cfa_offset
:
5209 case DW_CFA_def_cfa_expression
:
5213 case DW_CFA_expression
:
5214 case DW_CFA_val_expression
:
5218 if (frame_need_space (fc
, reg
) >= 0)
5219 fc
->col_type
[reg
] = DW_CFA_undefined
;
5221 case DW_CFA_offset_extended_sf
:
5222 case DW_CFA_val_offset_sf
:
5223 reg
= LEB (); SLEB ();
5224 if (frame_need_space (fc
, reg
) >= 0)
5225 fc
->col_type
[reg
] = DW_CFA_undefined
;
5227 case DW_CFA_def_cfa_sf
:
5230 case DW_CFA_def_cfa_offset_sf
:
5233 case DW_CFA_MIPS_advance_loc8
:
5236 case DW_CFA_GNU_args_size
:
5239 case DW_CFA_GNU_negative_offset_extended
:
5240 reg
= LEB (); LEB ();
5241 if (frame_need_space (fc
, reg
) >= 0)
5242 fc
->col_type
[reg
] = DW_CFA_undefined
;
5251 /* Now we know what registers are used, make a second pass over
5252 the chunk, this time actually printing out the info. */
5254 while (start
< block_end
)
5257 unsigned long ul
, reg
, roffs
;
5260 const char *reg_prefix
= "";
5267 /* Warning: if you add any more cases to this switch, be
5268 sure to add them to the corresponding switch above. */
5271 case DW_CFA_advance_loc
:
5272 if (do_debug_frames_interp
)
5273 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5275 printf (" DW_CFA_advance_loc: %d to %08lx\n",
5276 opa
* fc
->code_factor
,
5277 fc
->pc_begin
+ opa
* fc
->code_factor
);
5278 fc
->pc_begin
+= opa
* fc
->code_factor
;
5283 if (opa
>= (unsigned int) fc
->ncols
)
5284 reg_prefix
= bad_reg
;
5285 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5286 printf (" DW_CFA_offset: %s%s at cfa%+ld\n",
5287 reg_prefix
, regname (opa
, 0),
5288 roffs
* fc
->data_factor
);
5289 if (*reg_prefix
== '\0')
5291 fc
->col_type
[opa
] = DW_CFA_offset
;
5292 fc
->col_offset
[opa
] = roffs
* fc
->data_factor
;
5296 case DW_CFA_restore
:
5297 if (opa
>= (unsigned int) cie
->ncols
5298 || opa
>= (unsigned int) fc
->ncols
)
5299 reg_prefix
= bad_reg
;
5300 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5301 printf (" DW_CFA_restore: %s%s\n",
5302 reg_prefix
, regname (opa
, 0));
5303 if (*reg_prefix
== '\0')
5305 fc
->col_type
[opa
] = cie
->col_type
[opa
];
5306 fc
->col_offset
[opa
] = cie
->col_offset
[opa
];
5307 if (do_debug_frames_interp
5308 && fc
->col_type
[opa
] == DW_CFA_unreferenced
)
5309 fc
->col_type
[opa
] = DW_CFA_undefined
;
5313 case DW_CFA_set_loc
:
5314 vma
= get_encoded_value (start
, fc
->fde_encoding
, section
);
5315 start
+= encoded_ptr_size
;
5316 if (do_debug_frames_interp
)
5317 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5319 printf (" DW_CFA_set_loc: %08lx\n", (unsigned long)vma
);
5323 case DW_CFA_advance_loc1
:
5324 ofs
= byte_get (start
, 1); start
+= 1;
5325 if (do_debug_frames_interp
)
5326 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5328 printf (" DW_CFA_advance_loc1: %ld to %08lx\n",
5329 ofs
* fc
->code_factor
,
5330 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5331 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5334 case DW_CFA_advance_loc2
:
5335 ofs
= byte_get (start
, 2); start
+= 2;
5336 if (do_debug_frames_interp
)
5337 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5339 printf (" DW_CFA_advance_loc2: %ld to %08lx\n",
5340 ofs
* fc
->code_factor
,
5341 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5342 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5345 case DW_CFA_advance_loc4
:
5346 ofs
= byte_get (start
, 4); start
+= 4;
5347 if (do_debug_frames_interp
)
5348 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5350 printf (" DW_CFA_advance_loc4: %ld to %08lx\n",
5351 ofs
* fc
->code_factor
,
5352 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5353 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5356 case DW_CFA_offset_extended
:
5359 if (reg
>= (unsigned int) fc
->ncols
)
5360 reg_prefix
= bad_reg
;
5361 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5362 printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n",
5363 reg_prefix
, regname (reg
, 0),
5364 roffs
* fc
->data_factor
);
5365 if (*reg_prefix
== '\0')
5367 fc
->col_type
[reg
] = DW_CFA_offset
;
5368 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
5372 case DW_CFA_val_offset
:
5375 if (reg
>= (unsigned int) fc
->ncols
)
5376 reg_prefix
= bad_reg
;
5377 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5378 printf (" DW_CFA_val_offset: %s%s at cfa%+ld\n",
5379 reg_prefix
, regname (reg
, 0),
5380 roffs
* fc
->data_factor
);
5381 if (*reg_prefix
== '\0')
5383 fc
->col_type
[reg
] = DW_CFA_val_offset
;
5384 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
5388 case DW_CFA_restore_extended
:
5390 if (reg
>= (unsigned int) cie
->ncols
5391 || reg
>= (unsigned int) fc
->ncols
)
5392 reg_prefix
= bad_reg
;
5393 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5394 printf (" DW_CFA_restore_extended: %s%s\n",
5395 reg_prefix
, regname (reg
, 0));
5396 if (*reg_prefix
== '\0')
5398 fc
->col_type
[reg
] = cie
->col_type
[reg
];
5399 fc
->col_offset
[reg
] = cie
->col_offset
[reg
];
5403 case DW_CFA_undefined
:
5405 if (reg
>= (unsigned int) fc
->ncols
)
5406 reg_prefix
= bad_reg
;
5407 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5408 printf (" DW_CFA_undefined: %s%s\n",
5409 reg_prefix
, regname (reg
, 0));
5410 if (*reg_prefix
== '\0')
5412 fc
->col_type
[reg
] = DW_CFA_undefined
;
5413 fc
->col_offset
[reg
] = 0;
5417 case DW_CFA_same_value
:
5419 if (reg
>= (unsigned int) fc
->ncols
)
5420 reg_prefix
= bad_reg
;
5421 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5422 printf (" DW_CFA_same_value: %s%s\n",
5423 reg_prefix
, regname (reg
, 0));
5424 if (*reg_prefix
== '\0')
5426 fc
->col_type
[reg
] = DW_CFA_same_value
;
5427 fc
->col_offset
[reg
] = 0;
5431 case DW_CFA_register
:
5434 if (reg
>= (unsigned int) fc
->ncols
)
5435 reg_prefix
= bad_reg
;
5436 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5438 printf (" DW_CFA_register: %s%s in ",
5439 reg_prefix
, regname (reg
, 0));
5440 puts (regname (roffs
, 0));
5442 if (*reg_prefix
== '\0')
5444 fc
->col_type
[reg
] = DW_CFA_register
;
5445 fc
->col_offset
[reg
] = roffs
;
5449 case DW_CFA_remember_state
:
5450 if (! do_debug_frames_interp
)
5451 printf (" DW_CFA_remember_state\n");
5452 rs
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
5453 rs
->ncols
= fc
->ncols
;
5454 rs
->col_type
= (short int *) xcmalloc (rs
->ncols
,
5455 sizeof (short int));
5456 rs
->col_offset
= (int *) xcmalloc (rs
->ncols
, sizeof (int));
5457 memcpy (rs
->col_type
, fc
->col_type
, rs
->ncols
);
5458 memcpy (rs
->col_offset
, fc
->col_offset
, rs
->ncols
* sizeof (int));
5459 rs
->next
= remembered_state
;
5460 remembered_state
= rs
;
5463 case DW_CFA_restore_state
:
5464 if (! do_debug_frames_interp
)
5465 printf (" DW_CFA_restore_state\n");
5466 rs
= remembered_state
;
5469 remembered_state
= rs
->next
;
5470 frame_need_space (fc
, rs
->ncols
- 1);
5471 memcpy (fc
->col_type
, rs
->col_type
, rs
->ncols
);
5472 memcpy (fc
->col_offset
, rs
->col_offset
,
5473 rs
->ncols
* sizeof (int));
5474 free (rs
->col_type
);
5475 free (rs
->col_offset
);
5478 else if (do_debug_frames_interp
)
5479 printf ("Mismatched DW_CFA_restore_state\n");
5482 case DW_CFA_def_cfa
:
5483 fc
->cfa_reg
= LEB ();
5484 fc
->cfa_offset
= LEB ();
5486 if (! do_debug_frames_interp
)
5487 printf (" DW_CFA_def_cfa: %s ofs %d\n",
5488 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
5491 case DW_CFA_def_cfa_register
:
5492 fc
->cfa_reg
= LEB ();
5494 if (! do_debug_frames_interp
)
5495 printf (" DW_CFA_def_cfa_register: %s\n",
5496 regname (fc
->cfa_reg
, 0));
5499 case DW_CFA_def_cfa_offset
:
5500 fc
->cfa_offset
= LEB ();
5501 if (! do_debug_frames_interp
)
5502 printf (" DW_CFA_def_cfa_offset: %d\n", fc
->cfa_offset
);
5506 if (! do_debug_frames_interp
)
5507 printf (" DW_CFA_nop\n");
5510 case DW_CFA_def_cfa_expression
:
5512 if (! do_debug_frames_interp
)
5514 printf (" DW_CFA_def_cfa_expression (");
5515 decode_location_expression (start
, eh_addr_size
, 0, -1,
5523 case DW_CFA_expression
:
5526 if (reg
>= (unsigned int) fc
->ncols
)
5527 reg_prefix
= bad_reg
;
5528 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5530 printf (" DW_CFA_expression: %s%s (",
5531 reg_prefix
, regname (reg
, 0));
5532 decode_location_expression (start
, eh_addr_size
, 0, -1,
5536 if (*reg_prefix
== '\0')
5537 fc
->col_type
[reg
] = DW_CFA_expression
;
5541 case DW_CFA_val_expression
:
5544 if (reg
>= (unsigned int) fc
->ncols
)
5545 reg_prefix
= bad_reg
;
5546 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5548 printf (" DW_CFA_val_expression: %s%s (",
5549 reg_prefix
, regname (reg
, 0));
5550 decode_location_expression (start
, eh_addr_size
, 0, -1,
5554 if (*reg_prefix
== '\0')
5555 fc
->col_type
[reg
] = DW_CFA_val_expression
;
5559 case DW_CFA_offset_extended_sf
:
5562 if (frame_need_space (fc
, reg
) < 0)
5563 reg_prefix
= bad_reg
;
5564 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5565 printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n",
5566 reg_prefix
, regname (reg
, 0),
5567 l
* fc
->data_factor
);
5568 if (*reg_prefix
== '\0')
5570 fc
->col_type
[reg
] = DW_CFA_offset
;
5571 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
5575 case DW_CFA_val_offset_sf
:
5578 if (frame_need_space (fc
, reg
) < 0)
5579 reg_prefix
= bad_reg
;
5580 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5581 printf (" DW_CFA_val_offset_sf: %s%s at cfa%+ld\n",
5582 reg_prefix
, regname (reg
, 0),
5583 l
* fc
->data_factor
);
5584 if (*reg_prefix
== '\0')
5586 fc
->col_type
[reg
] = DW_CFA_val_offset
;
5587 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
5591 case DW_CFA_def_cfa_sf
:
5592 fc
->cfa_reg
= LEB ();
5593 fc
->cfa_offset
= SLEB ();
5594 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
5596 if (! do_debug_frames_interp
)
5597 printf (" DW_CFA_def_cfa_sf: %s ofs %d\n",
5598 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
5601 case DW_CFA_def_cfa_offset_sf
:
5602 fc
->cfa_offset
= SLEB ();
5603 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
5604 if (! do_debug_frames_interp
)
5605 printf (" DW_CFA_def_cfa_offset_sf: %d\n", fc
->cfa_offset
);
5608 case DW_CFA_MIPS_advance_loc8
:
5609 ofs
= byte_get (start
, 8); start
+= 8;
5610 if (do_debug_frames_interp
)
5611 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5613 printf (" DW_CFA_MIPS_advance_loc8: %ld to %08lx\n",
5614 ofs
* fc
->code_factor
,
5615 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5616 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5619 case DW_CFA_GNU_window_save
:
5620 if (! do_debug_frames_interp
)
5621 printf (" DW_CFA_GNU_window_save\n");
5624 case DW_CFA_GNU_args_size
:
5626 if (! do_debug_frames_interp
)
5627 printf (" DW_CFA_GNU_args_size: %ld\n", ul
);
5630 case DW_CFA_GNU_negative_offset_extended
:
5633 if (frame_need_space (fc
, reg
) < 0)
5634 reg_prefix
= bad_reg
;
5635 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5636 printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n",
5637 reg_prefix
, regname (reg
, 0),
5638 l
* fc
->data_factor
);
5639 if (*reg_prefix
== '\0')
5641 fc
->col_type
[reg
] = DW_CFA_offset
;
5642 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
5647 if (op
>= DW_CFA_lo_user
&& op
<= DW_CFA_hi_user
)
5648 printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op
);
5650 warn (_("unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op
);
5655 if (do_debug_frames_interp
)
5656 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5659 eh_addr_size
= saved_eh_addr_size
;
5672 display_gdb_index (struct dwarf_section
*section
,
5673 void *file ATTRIBUTE_UNUSED
)
5675 unsigned char *start
= section
->start
;
5677 uint32_t cu_list_offset
, tu_list_offset
;
5678 uint32_t address_table_offset
, symbol_table_offset
, constant_pool_offset
;
5679 unsigned int cu_list_elements
, tu_list_elements
;
5680 unsigned int address_table_size
, symbol_table_slots
;
5681 unsigned char *cu_list
, *tu_list
;
5682 unsigned char *address_table
, *symbol_table
, *constant_pool
;
5685 /* The documentation for the format of this file is in gdb/dwarf2read.c. */
5687 printf (_("Contents of the %s section:\n"), section
->name
);
5689 if (section
->size
< 6 * sizeof (uint32_t))
5691 warn (_("Truncated header in the %s section.\n"), section
->name
);
5695 version
= byte_get_little_endian (start
, 4);
5696 printf (_("Version %ld\n"), (long) version
);
5698 /* Prior versions are obsolete, and future versions may not be
5699 backwards compatible. */
5700 if (version
< 3 || version
> 7)
5702 warn (_("Unsupported version %lu.\n"), (unsigned long) version
);
5706 warn (_("The address table data in version 3 may be wrong.\n"));
5708 warn (_("Version 4 does not support case insensitive lookups.\n"));
5710 warn (_("Version 5 does not include inlined functions.\n"));
5712 warn (_("Version 6 does not include symbol attributes.\n"));
5714 cu_list_offset
= byte_get_little_endian (start
+ 4, 4);
5715 tu_list_offset
= byte_get_little_endian (start
+ 8, 4);
5716 address_table_offset
= byte_get_little_endian (start
+ 12, 4);
5717 symbol_table_offset
= byte_get_little_endian (start
+ 16, 4);
5718 constant_pool_offset
= byte_get_little_endian (start
+ 20, 4);
5720 if (cu_list_offset
> section
->size
5721 || tu_list_offset
> section
->size
5722 || address_table_offset
> section
->size
5723 || symbol_table_offset
> section
->size
5724 || constant_pool_offset
> section
->size
)
5726 warn (_("Corrupt header in the %s section.\n"), section
->name
);
5730 cu_list_elements
= (tu_list_offset
- cu_list_offset
) / 8;
5731 tu_list_elements
= (address_table_offset
- tu_list_offset
) / 8;
5732 address_table_size
= symbol_table_offset
- address_table_offset
;
5733 symbol_table_slots
= (constant_pool_offset
- symbol_table_offset
) / 8;
5735 cu_list
= start
+ cu_list_offset
;
5736 tu_list
= start
+ tu_list_offset
;
5737 address_table
= start
+ address_table_offset
;
5738 symbol_table
= start
+ symbol_table_offset
;
5739 constant_pool
= start
+ constant_pool_offset
;
5741 printf (_("\nCU table:\n"));
5742 for (i
= 0; i
< cu_list_elements
; i
+= 2)
5744 uint64_t cu_offset
= byte_get_little_endian (cu_list
+ i
* 8, 8);
5745 uint64_t cu_length
= byte_get_little_endian (cu_list
+ i
* 8 + 8, 8);
5747 printf (_("[%3u] 0x%lx - 0x%lx\n"), i
/ 2,
5748 (unsigned long) cu_offset
,
5749 (unsigned long) (cu_offset
+ cu_length
- 1));
5752 printf (_("\nTU table:\n"));
5753 for (i
= 0; i
< tu_list_elements
; i
+= 3)
5755 uint64_t tu_offset
= byte_get_little_endian (tu_list
+ i
* 8, 8);
5756 uint64_t type_offset
= byte_get_little_endian (tu_list
+ i
* 8 + 8, 8);
5757 uint64_t signature
= byte_get_little_endian (tu_list
+ i
* 8 + 16, 8);
5759 printf (_("[%3u] 0x%lx 0x%lx "), i
/ 3,
5760 (unsigned long) tu_offset
,
5761 (unsigned long) type_offset
);
5762 print_dwarf_vma (signature
, 8);
5766 printf (_("\nAddress table:\n"));
5767 for (i
= 0; i
< address_table_size
; i
+= 2 * 8 + 4)
5769 uint64_t low
= byte_get_little_endian (address_table
+ i
, 8);
5770 uint64_t high
= byte_get_little_endian (address_table
+ i
+ 8, 8);
5771 uint32_t cu_index
= byte_get_little_endian (address_table
+ i
+ 16, 4);
5773 print_dwarf_vma (low
, 8);
5774 print_dwarf_vma (high
, 8);
5775 printf (_("%lu\n"), (unsigned long) cu_index
);
5778 printf (_("\nSymbol table:\n"));
5779 for (i
= 0; i
< symbol_table_slots
; ++i
)
5781 uint32_t name_offset
= byte_get_little_endian (symbol_table
+ i
* 8, 4);
5782 uint32_t cu_vector_offset
= byte_get_little_endian (symbol_table
+ i
* 8 + 4, 4);
5783 uint32_t num_cus
, cu
;
5785 if (name_offset
!= 0
5786 || cu_vector_offset
!= 0)
5790 printf ("[%3u] %s:", i
, constant_pool
+ name_offset
);
5791 num_cus
= byte_get_little_endian (constant_pool
+ cu_vector_offset
, 4);
5794 for (j
= 0; j
< num_cus
; ++j
)
5796 gdb_index_symbol_kind kind
;
5798 cu
= byte_get_little_endian (constant_pool
+ cu_vector_offset
+ 4 + j
* 4, 4);
5799 kind
= GDB_INDEX_SYMBOL_KIND_VALUE (cu
);
5800 cu
= GDB_INDEX_CU_VALUE (cu
);
5801 /* Convert to TU number if it's for a type unit. */
5802 if (cu
>= cu_list_elements
/ 2)
5803 printf ("%cT%lu", num_cus
> 1 ? '\t' : ' ',
5804 (unsigned long) (cu
- cu_list_elements
/ 2));
5806 printf ("%c%lu", num_cus
> 1 ? '\t' : ' ', (unsigned long) cu
);
5810 case GDB_INDEX_SYMBOL_KIND_NONE
:
5811 printf (_(" [no symbol information]"));
5813 case GDB_INDEX_SYMBOL_KIND_TYPE
:
5814 printf (_(" [type]"));
5816 case GDB_INDEX_SYMBOL_KIND_VARIABLE
:
5817 printf (_(" [variable]"));
5819 case GDB_INDEX_SYMBOL_KIND_FUNCTION
:
5820 printf (_(" [function]"));
5822 case GDB_INDEX_SYMBOL_KIND_OTHER
:
5823 printf (_(" [other]"));
5826 printf (_(" [unknown: %d]"), kind
);
5841 display_debug_not_supported (struct dwarf_section
*section
,
5842 void *file ATTRIBUTE_UNUSED
)
5844 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
5851 cmalloc (size_t nmemb
, size_t size
)
5853 /* Check for overflow. */
5854 if (nmemb
>= ~(size_t) 0 / size
)
5857 return malloc (nmemb
* size
);
5861 xcmalloc (size_t nmemb
, size_t size
)
5863 /* Check for overflow. */
5864 if (nmemb
>= ~(size_t) 0 / size
)
5867 return xmalloc (nmemb
* size
);
5871 xcrealloc (void *ptr
, size_t nmemb
, size_t size
)
5873 /* Check for overflow. */
5874 if (nmemb
>= ~(size_t) 0 / size
)
5877 return xrealloc (ptr
, nmemb
* size
);
5881 free_debug_memory (void)
5887 for (i
= 0; i
< max
; i
++)
5888 free_debug_section ((enum dwarf_section_display_enum
) i
);
5890 if (debug_information
!= NULL
)
5892 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
)
5894 for (i
= 0; i
< num_debug_info_entries
; i
++)
5896 if (!debug_information
[i
].max_loc_offsets
)
5898 free (debug_information
[i
].loc_offsets
);
5899 free (debug_information
[i
].have_frame_base
);
5901 if (!debug_information
[i
].max_range_lists
)
5902 free (debug_information
[i
].range_lists
);
5906 free (debug_information
);
5907 debug_information
= NULL
;
5908 num_debug_info_entries
= 0;
5913 dwarf_select_sections_by_names (const char *names
)
5917 const char * option
;
5921 debug_dump_long_opts
;
5923 static const debug_dump_long_opts opts_table
[] =
5925 /* Please keep this table alpha- sorted. */
5926 { "Ranges", & do_debug_ranges
, 1 },
5927 { "abbrev", & do_debug_abbrevs
, 1 },
5928 { "aranges", & do_debug_aranges
, 1 },
5929 { "frames", & do_debug_frames
, 1 },
5930 { "frames-interp", & do_debug_frames_interp
, 1 },
5931 { "info", & do_debug_info
, 1 },
5932 { "line", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
}, /* For backwards compatibility. */
5933 { "rawline", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
},
5934 { "decodedline", & do_debug_lines
, FLAG_DEBUG_LINES_DECODED
},
5935 { "loc", & do_debug_loc
, 1 },
5936 { "macro", & do_debug_macinfo
, 1 },
5937 { "pubnames", & do_debug_pubnames
, 1 },
5938 { "pubtypes", & do_debug_pubtypes
, 1 },
5939 /* This entry is for compatability
5940 with earlier versions of readelf. */
5941 { "ranges", & do_debug_aranges
, 1 },
5942 { "str", & do_debug_str
, 1 },
5943 /* The special .gdb_index section. */
5944 { "gdb_index", & do_gdb_index
, 1 },
5945 /* These trace_* sections are used by Itanium VMS. */
5946 { "trace_abbrev", & do_trace_abbrevs
, 1 },
5947 { "trace_aranges", & do_trace_aranges
, 1 },
5948 { "trace_info", & do_trace_info
, 1 },
5957 const debug_dump_long_opts
* entry
;
5959 for (entry
= opts_table
; entry
->option
; entry
++)
5961 size_t len
= strlen (entry
->option
);
5963 if (strncmp (p
, entry
->option
, len
) == 0
5964 && (p
[len
] == ',' || p
[len
] == '\0'))
5966 * entry
->variable
|= entry
->val
;
5968 /* The --debug-dump=frames-interp option also
5969 enables the --debug-dump=frames option. */
5970 if (do_debug_frames_interp
)
5971 do_debug_frames
= 1;
5978 if (entry
->option
== NULL
)
5980 warn (_("Unrecognized debug option '%s'\n"), p
);
5981 p
= strchr (p
, ',');
5992 dwarf_select_sections_by_letters (const char *letters
)
5994 unsigned int lindex
= 0;
5996 while (letters
[lindex
])
5997 switch (letters
[lindex
++])
6004 do_debug_abbrevs
= 1;
6008 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
6012 do_debug_lines
|= FLAG_DEBUG_LINES_DECODED
;
6016 do_debug_pubnames
= 1;
6020 do_debug_pubtypes
= 1;
6024 do_debug_aranges
= 1;
6028 do_debug_ranges
= 1;
6032 do_debug_frames_interp
= 1;
6034 do_debug_frames
= 1;
6038 do_debug_macinfo
= 1;
6050 warn (_("Unrecognized debug option '%s'\n"), optarg
);
6056 dwarf_select_sections_all (void)
6059 do_debug_abbrevs
= 1;
6060 do_debug_lines
= FLAG_DEBUG_LINES_RAW
;
6061 do_debug_pubnames
= 1;
6062 do_debug_pubtypes
= 1;
6063 do_debug_aranges
= 1;
6064 do_debug_ranges
= 1;
6065 do_debug_frames
= 1;
6066 do_debug_macinfo
= 1;
6071 do_trace_abbrevs
= 1;
6072 do_trace_aranges
= 1;
6075 struct dwarf_section_display debug_displays
[] =
6077 { { ".debug_abbrev", ".zdebug_abbrev", NULL
, NULL
, 0, 0, abbrev
},
6078 display_debug_abbrev
, &do_debug_abbrevs
, 0 },
6079 { { ".debug_aranges", ".zdebug_aranges", NULL
, NULL
, 0, 0, abbrev
},
6080 display_debug_aranges
, &do_debug_aranges
, 1 },
6081 { { ".debug_frame", ".zdebug_frame", NULL
, NULL
, 0, 0, abbrev
},
6082 display_debug_frames
, &do_debug_frames
, 1 },
6083 { { ".debug_info", ".zdebug_info", NULL
, NULL
, 0, 0, abbrev
},
6084 display_debug_info
, &do_debug_info
, 1 },
6085 { { ".debug_line", ".zdebug_line", NULL
, NULL
, 0, 0, abbrev
},
6086 display_debug_lines
, &do_debug_lines
, 1 },
6087 { { ".debug_pubnames", ".zdebug_pubnames", NULL
, NULL
, 0, 0, abbrev
},
6088 display_debug_pubnames
, &do_debug_pubnames
, 0 },
6089 { { ".eh_frame", "", NULL
, NULL
, 0, 0, abbrev
},
6090 display_debug_frames
, &do_debug_frames
, 1 },
6091 { { ".debug_macinfo", ".zdebug_macinfo", NULL
, NULL
, 0, 0, abbrev
},
6092 display_debug_macinfo
, &do_debug_macinfo
, 0 },
6093 { { ".debug_macro", ".zdebug_macro", NULL
, NULL
, 0, 0, abbrev
},
6094 display_debug_macro
, &do_debug_macinfo
, 1 },
6095 { { ".debug_str", ".zdebug_str", NULL
, NULL
, 0, 0, abbrev
},
6096 display_debug_str
, &do_debug_str
, 0 },
6097 { { ".debug_loc", ".zdebug_loc", NULL
, NULL
, 0, 0, abbrev
},
6098 display_debug_loc
, &do_debug_loc
, 1 },
6099 { { ".debug_pubtypes", ".zdebug_pubtypes", NULL
, NULL
, 0, 0, abbrev
},
6100 display_debug_pubnames
, &do_debug_pubtypes
, 0 },
6101 { { ".debug_ranges", ".zdebug_ranges", NULL
, NULL
, 0, 0, abbrev
},
6102 display_debug_ranges
, &do_debug_ranges
, 1 },
6103 { { ".debug_static_func", ".zdebug_static_func", NULL
, NULL
, 0, 0, abbrev
},
6104 display_debug_not_supported
, NULL
, 0 },
6105 { { ".debug_static_vars", ".zdebug_static_vars", NULL
, NULL
, 0, 0, abbrev
},
6106 display_debug_not_supported
, NULL
, 0 },
6107 { { ".debug_types", ".zdebug_types", NULL
, NULL
, 0, 0, abbrev
},
6108 display_debug_types
, &do_debug_info
, 1 },
6109 { { ".debug_weaknames", ".zdebug_weaknames", NULL
, NULL
, 0, 0, abbrev
},
6110 display_debug_not_supported
, NULL
, 0 },
6111 { { ".gdb_index", "", NULL
, NULL
, 0, 0, abbrev
},
6112 display_gdb_index
, &do_gdb_index
, 0 },
6113 { { ".trace_info", "", NULL
, NULL
, 0, 0, trace_abbrev
},
6114 display_trace_info
, &do_trace_info
, 1 },
6115 { { ".trace_abbrev", "", NULL
, NULL
, 0, 0, abbrev
},
6116 display_debug_abbrev
, &do_trace_abbrevs
, 0 },
6117 { { ".trace_aranges", "", NULL
, NULL
, 0, 0, abbrev
},
6118 display_debug_aranges
, &do_trace_aranges
, 0 },
6119 { { ".debug_info.dwo", ".zdebug_info.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6120 display_debug_info
, &do_debug_info
, 1 },
6121 { { ".debug_abbrev.dwo", ".zdebug_abbrev.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6122 display_debug_abbrev
, &do_debug_abbrevs
, 0 },
6123 { { ".debug_types.dwo", ".zdebug_types.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6124 display_debug_types
, &do_debug_info
, 1 },
6125 { { ".debug_line.dwo", ".zdebug_line.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6126 display_debug_lines
, &do_debug_lines
, 1 },
6127 { { ".debug_loc.dwo", ".zdebug_loc.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6128 display_debug_loc
, &do_debug_loc
, 1 },
6129 { { ".debug_macro.dwo", ".zdebug_macro.dwo",NULL
, NULL
, 0, 0, abbrev
},
6130 display_debug_macro
, &do_debug_macinfo
, 1 },
6131 { { ".debug_macinfo.dwo", ".zdebug_macinfo.dwo",NULL
, NULL
, 0, 0, abbrev
},
6132 display_debug_macinfo
, &do_debug_macinfo
, 0 },
6133 { { ".debug_str.dwo", ".zdebug_str.dwo", NULL
, NULL
, 0, 0, str_dwo
},
6134 display_debug_str
, &do_debug_str
, 1 },
6135 { { ".debug_str_offsets",".zdebug_str_offsets", NULL
, NULL
, 0, 0, abbrev
},
6136 display_debug_str_offsets
, NULL
, 0 },
6137 { { ".debug_str_offsets.dwo",".zdebug_str_offsets.dwo", NULL
, NULL
, 0, 0,
6139 display_debug_str_offsets
, NULL
, 0 },
6140 { { ".debug_addr",".zdebug_addr", NULL
, NULL
, 0, 0, debug_addr
},
6141 display_debug_addr
, NULL
, 1 },