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);
651 add_abbrev_attr (attribute
, form
);
653 while (attribute
!= 0);
660 get_TAG_name (unsigned long tag
)
662 const char *name
= get_DW_TAG_name ((unsigned int)tag
);
666 static char buffer
[100];
668 snprintf (buffer
, sizeof (buffer
), _("Unknown TAG value: %lx"), tag
);
676 get_FORM_name (unsigned long form
)
678 const char *name
= get_DW_FORM_name (form
);
682 static char buffer
[100];
684 snprintf (buffer
, sizeof (buffer
), _("Unknown FORM value: %lx"), form
);
691 static unsigned char *
692 display_block (unsigned char *data
, dwarf_vma length
)
694 printf (_(" %s byte block: "), dwarf_vmatoa ("u", length
));
697 printf ("%lx ", (unsigned long) byte_get (data
++, 1));
703 decode_location_expression (unsigned char * data
,
704 unsigned int pointer_size
,
705 unsigned int offset_size
,
709 struct dwarf_section
* section
)
712 unsigned int bytes_read
;
714 unsigned char *end
= data
+ length
;
715 int need_frame_base
= 0;
724 printf ("DW_OP_addr: %s",
725 dwarf_vmatoa ("x", byte_get (data
, pointer_size
)));
726 data
+= pointer_size
;
729 printf ("DW_OP_deref");
732 printf ("DW_OP_const1u: %lu", (unsigned long) byte_get (data
++, 1));
735 printf ("DW_OP_const1s: %ld", (long) byte_get_signed (data
++, 1));
738 printf ("DW_OP_const2u: %lu", (unsigned long) byte_get (data
, 2));
742 printf ("DW_OP_const2s: %ld", (long) byte_get_signed (data
, 2));
746 printf ("DW_OP_const4u: %lu", (unsigned long) byte_get (data
, 4));
750 printf ("DW_OP_const4s: %ld", (long) byte_get_signed (data
, 4));
754 printf ("DW_OP_const8u: %lu %lu", (unsigned long) byte_get (data
, 4),
755 (unsigned long) byte_get (data
+ 4, 4));
759 printf ("DW_OP_const8s: %ld %ld", (long) byte_get (data
, 4),
760 (long) byte_get (data
+ 4, 4));
764 printf ("DW_OP_constu: %s",
765 dwarf_vmatoa ("u", read_leb128 (data
, &bytes_read
, 0)));
769 printf ("DW_OP_consts: %s",
770 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
)));
774 printf ("DW_OP_dup");
777 printf ("DW_OP_drop");
780 printf ("DW_OP_over");
783 printf ("DW_OP_pick: %ld", (unsigned long) byte_get (data
++, 1));
786 printf ("DW_OP_swap");
789 printf ("DW_OP_rot");
792 printf ("DW_OP_xderef");
795 printf ("DW_OP_abs");
798 printf ("DW_OP_and");
801 printf ("DW_OP_div");
804 printf ("DW_OP_minus");
807 printf ("DW_OP_mod");
810 printf ("DW_OP_mul");
813 printf ("DW_OP_neg");
816 printf ("DW_OP_not");
822 printf ("DW_OP_plus");
824 case DW_OP_plus_uconst
:
825 printf ("DW_OP_plus_uconst: %s",
826 dwarf_vmatoa ("u", read_leb128 (data
, &bytes_read
, 0)));
830 printf ("DW_OP_shl");
833 printf ("DW_OP_shr");
836 printf ("DW_OP_shra");
839 printf ("DW_OP_xor");
842 printf ("DW_OP_bra: %ld", (long) byte_get_signed (data
, 2));
864 printf ("DW_OP_skip: %ld", (long) byte_get_signed (data
, 2));
900 printf ("DW_OP_lit%d", op
- DW_OP_lit0
);
935 printf ("DW_OP_reg%d (%s)", op
- DW_OP_reg0
,
936 regname (op
- DW_OP_reg0
, 1));
971 printf ("DW_OP_breg%d (%s): %s",
973 regname (op
- DW_OP_breg0
, 1),
974 dwarf_vmatoa ("d", (dwarf_signed_vma
)
975 read_leb128 (data
, &bytes_read
, 1)));
980 uvalue
= read_leb128 (data
, &bytes_read
, 0);
982 printf ("DW_OP_regx: %s (%s)",
983 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1));
987 printf ("DW_OP_fbreg: %s",
988 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
)));
992 uvalue
= read_leb128 (data
, &bytes_read
, 0);
994 printf ("DW_OP_bregx: %s (%s) %s",
995 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1),
996 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
)));
1000 printf ("DW_OP_piece: %s",
1001 dwarf_vmatoa ("u", read_leb128 (data
, &bytes_read
, 0)));
1004 case DW_OP_deref_size
:
1005 printf ("DW_OP_deref_size: %ld", (long) byte_get (data
++, 1));
1007 case DW_OP_xderef_size
:
1008 printf ("DW_OP_xderef_size: %ld", (long) byte_get (data
++, 1));
1011 printf ("DW_OP_nop");
1014 /* DWARF 3 extensions. */
1015 case DW_OP_push_object_address
:
1016 printf ("DW_OP_push_object_address");
1019 /* XXX: Strictly speaking for 64-bit DWARF3 files
1020 this ought to be an 8-byte wide computation. */
1021 printf ("DW_OP_call2: <0x%s>",
1022 dwarf_vmatoa ("x", (dwarf_signed_vma
) byte_get (data
, 2)
1027 /* XXX: Strictly speaking for 64-bit DWARF3 files
1028 this ought to be an 8-byte wide computation. */
1029 printf ("DW_OP_call4: <0x%s>",
1030 dwarf_vmatoa ("x", (dwarf_signed_vma
) byte_get (data
, 4)
1034 case DW_OP_call_ref
:
1035 /* XXX: Strictly speaking for 64-bit DWARF3 files
1036 this ought to be an 8-byte wide computation. */
1037 if (dwarf_version
== -1)
1039 printf (_("(DW_OP_call_ref in frame info)"));
1040 /* No way to tell where the next op is, so just bail. */
1041 return need_frame_base
;
1043 if (dwarf_version
== 2)
1045 printf ("DW_OP_call_ref: <0x%s>",
1046 dwarf_vmatoa ("x", byte_get (data
, pointer_size
)));
1047 data
+= pointer_size
;
1051 printf ("DW_OP_call_ref: <0x%s>",
1052 dwarf_vmatoa ("x", byte_get (data
, offset_size
)));
1053 data
+= offset_size
;
1056 case DW_OP_form_tls_address
:
1057 printf ("DW_OP_form_tls_address");
1059 case DW_OP_call_frame_cfa
:
1060 printf ("DW_OP_call_frame_cfa");
1062 case DW_OP_bit_piece
:
1063 printf ("DW_OP_bit_piece: ");
1064 printf (_("size: %s "),
1065 dwarf_vmatoa ("u", read_leb128 (data
, &bytes_read
, 0)));
1067 printf (_("offset: %s "),
1068 dwarf_vmatoa ("u", read_leb128 (data
, &bytes_read
, 0)));
1072 /* DWARF 4 extensions. */
1073 case DW_OP_stack_value
:
1074 printf ("DW_OP_stack_value");
1077 case DW_OP_implicit_value
:
1078 printf ("DW_OP_implicit_value");
1079 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1081 display_block (data
, uvalue
);
1085 /* GNU extensions. */
1086 case DW_OP_GNU_push_tls_address
:
1087 printf (_("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown"));
1089 case DW_OP_GNU_uninit
:
1090 printf ("DW_OP_GNU_uninit");
1091 /* FIXME: Is there data associated with this OP ? */
1093 case DW_OP_GNU_encoded_addr
:
1099 addr
= get_encoded_value (data
, encoding
, section
);
1100 data
+= size_of_encoded_value (encoding
);
1102 printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding
);
1103 print_dwarf_vma (addr
, pointer_size
);
1106 case DW_OP_GNU_implicit_pointer
:
1107 /* XXX: Strictly speaking for 64-bit DWARF3 files
1108 this ought to be an 8-byte wide computation. */
1109 if (dwarf_version
== -1)
1111 printf (_("(DW_OP_GNU_implicit_pointer in frame info)"));
1112 /* No way to tell where the next op is, so just bail. */
1113 return need_frame_base
;
1115 if (dwarf_version
== 2)
1117 printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s",
1118 dwarf_vmatoa ("x", byte_get (data
, pointer_size
)),
1119 dwarf_vmatoa ("d", read_sleb128 (data
+ pointer_size
,
1121 data
+= pointer_size
+ bytes_read
;
1125 printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s",
1126 dwarf_vmatoa ("x", byte_get (data
, offset_size
)),
1127 dwarf_vmatoa ("d", read_sleb128 (data
+ offset_size
,
1129 data
+= offset_size
+ bytes_read
;
1132 case DW_OP_GNU_entry_value
:
1133 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1135 printf ("DW_OP_GNU_entry_value: (");
1136 if (decode_location_expression (data
, pointer_size
, offset_size
,
1137 dwarf_version
, uvalue
,
1138 cu_offset
, section
))
1139 need_frame_base
= 1;
1143 case DW_OP_GNU_const_type
:
1144 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1146 printf ("DW_OP_GNU_const_type: <0x%s> ",
1147 dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1148 uvalue
= byte_get (data
++, 1);
1149 display_block (data
, uvalue
);
1152 case DW_OP_GNU_regval_type
:
1153 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1155 printf ("DW_OP_GNU_regval_type: %s (%s)",
1156 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1));
1157 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1159 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1161 case DW_OP_GNU_deref_type
:
1162 printf ("DW_OP_GNU_deref_type: %ld", (long) byte_get (data
++, 1));
1163 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1165 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1167 case DW_OP_GNU_convert
:
1168 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1170 printf ("DW_OP_GNU_convert <0x%s>",
1171 dwarf_vmatoa ("x", uvalue
? cu_offset
+ uvalue
: 0));
1173 case DW_OP_GNU_reinterpret
:
1174 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1176 printf ("DW_OP_GNU_reinterpret <0x%s>",
1177 dwarf_vmatoa ("x", uvalue
? cu_offset
+ uvalue
: 0));
1179 case DW_OP_GNU_parameter_ref
:
1180 printf ("DW_OP_GNU_parameter_ref: <0x%s>",
1181 dwarf_vmatoa ("x", cu_offset
+ byte_get (data
, 4)));
1184 case DW_OP_GNU_addr_index
:
1185 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1187 printf ("DW_OP_GNU_addr_index <0x%s>", dwarf_vmatoa ("x", uvalue
));
1190 /* HP extensions. */
1191 case DW_OP_HP_is_value
:
1192 printf ("DW_OP_HP_is_value");
1193 /* FIXME: Is there data associated with this OP ? */
1195 case DW_OP_HP_fltconst4
:
1196 printf ("DW_OP_HP_fltconst4");
1197 /* FIXME: Is there data associated with this OP ? */
1199 case DW_OP_HP_fltconst8
:
1200 printf ("DW_OP_HP_fltconst8");
1201 /* FIXME: Is there data associated with this OP ? */
1203 case DW_OP_HP_mod_range
:
1204 printf ("DW_OP_HP_mod_range");
1205 /* FIXME: Is there data associated with this OP ? */
1207 case DW_OP_HP_unmod_range
:
1208 printf ("DW_OP_HP_unmod_range");
1209 /* FIXME: Is there data associated with this OP ? */
1212 printf ("DW_OP_HP_tls");
1213 /* FIXME: Is there data associated with this OP ? */
1216 /* PGI (STMicroelectronics) extensions. */
1217 case DW_OP_PGI_omp_thread_num
:
1218 /* Pushes the thread number for the current thread as it would be
1219 returned by the standard OpenMP library function:
1220 omp_get_thread_num(). The "current thread" is the thread for
1221 which the expression is being evaluated. */
1222 printf ("DW_OP_PGI_omp_thread_num");
1226 if (op
>= DW_OP_lo_user
1227 && op
<= DW_OP_hi_user
)
1228 printf (_("(User defined location op)"));
1230 printf (_("(Unknown location op)"));
1231 /* No way to tell where the next op is, so just bail. */
1232 return need_frame_base
;
1235 /* Separate the ops. */
1240 return need_frame_base
;
1243 static unsigned char *
1244 read_and_display_attr_value (unsigned long attribute
,
1246 unsigned char * data
,
1247 dwarf_vma cu_offset
,
1248 dwarf_vma pointer_size
,
1249 dwarf_vma offset_size
,
1251 debug_info
* debug_info_p
,
1253 struct dwarf_section
* section
)
1255 dwarf_vma uvalue
= 0;
1256 unsigned char *block_start
= NULL
;
1257 unsigned char * orig_data
= data
;
1258 unsigned int bytes_read
;
1265 case DW_FORM_ref_addr
:
1266 if (dwarf_version
== 2)
1268 uvalue
= byte_get (data
, pointer_size
);
1269 data
+= pointer_size
;
1271 else if (dwarf_version
== 3 || dwarf_version
== 4)
1273 uvalue
= byte_get (data
, offset_size
);
1274 data
+= offset_size
;
1277 error (_("Internal error: DWARF version is not 2, 3 or 4.\n"));
1282 uvalue
= byte_get (data
, pointer_size
);
1283 data
+= pointer_size
;
1287 case DW_FORM_sec_offset
:
1288 case DW_FORM_GNU_ref_alt
:
1289 case DW_FORM_GNU_strp_alt
:
1290 uvalue
= byte_get (data
, offset_size
);
1291 data
+= offset_size
;
1294 case DW_FORM_flag_present
:
1301 uvalue
= byte_get (data
++, 1);
1306 uvalue
= byte_get (data
, 2);
1312 uvalue
= byte_get (data
, 4);
1317 uvalue
= read_leb128 (data
, & bytes_read
, 1);
1321 case DW_FORM_GNU_str_index
:
1322 uvalue
= read_leb128 (data
, & bytes_read
, 0);
1326 case DW_FORM_ref_udata
:
1328 uvalue
= read_leb128 (data
, & bytes_read
, 0);
1332 case DW_FORM_indirect
:
1333 form
= read_leb128 (data
, & bytes_read
, 0);
1336 printf (" %s", get_FORM_name (form
));
1337 return read_and_display_attr_value (attribute
, form
, data
,
1338 cu_offset
, pointer_size
,
1339 offset_size
, dwarf_version
,
1340 debug_info_p
, do_loc
,
1342 case DW_FORM_GNU_addr_index
:
1343 uvalue
= read_leb128 (data
, & bytes_read
, 0);
1350 case DW_FORM_ref_addr
:
1352 printf (" <0x%s>", dwarf_vmatoa ("x",uvalue
));
1355 case DW_FORM_GNU_ref_alt
:
1357 printf (" <alt 0x%s>", dwarf_vmatoa ("x",uvalue
));
1363 case DW_FORM_ref_udata
:
1365 printf (" <0x%s>", dwarf_vmatoa ("x", uvalue
+ cu_offset
));
1370 case DW_FORM_sec_offset
:
1372 printf (" 0x%s", dwarf_vmatoa ("x", uvalue
));
1375 case DW_FORM_flag_present
:
1382 printf (" %s", dwarf_vmatoa ("d", uvalue
));
1389 dwarf_vma high_bits
;
1392 byte_get_64 (data
, &high_bits
, &uvalue
);
1394 dwarf_vmatoa64 (high_bits
, uvalue
, buf
, sizeof (buf
)));
1396 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1397 && num_debug_info_entries
== 0)
1399 if (sizeof (uvalue
) == 8)
1400 uvalue
= byte_get (data
, 8);
1402 error (_("DW_FORM_data8 is unsupported when sizeof (dwarf_vma) != 8\n"));
1407 case DW_FORM_string
:
1409 printf (" %s", data
);
1410 data
+= strlen ((char *) data
) + 1;
1414 case DW_FORM_exprloc
:
1415 uvalue
= read_leb128 (data
, & bytes_read
, 0);
1416 block_start
= data
+ bytes_read
;
1418 data
= block_start
+ uvalue
;
1420 data
= display_block (block_start
, uvalue
);
1423 case DW_FORM_block1
:
1424 uvalue
= byte_get (data
, 1);
1425 block_start
= data
+ 1;
1427 data
= block_start
+ uvalue
;
1429 data
= display_block (block_start
, uvalue
);
1432 case DW_FORM_block2
:
1433 uvalue
= byte_get (data
, 2);
1434 block_start
= data
+ 2;
1436 data
= block_start
+ uvalue
;
1438 data
= display_block (block_start
, uvalue
);
1441 case DW_FORM_block4
:
1442 uvalue
= byte_get (data
, 4);
1443 block_start
= data
+ 4;
1445 data
= block_start
+ uvalue
;
1447 data
= display_block (block_start
, uvalue
);
1452 printf (_(" (indirect string, offset: 0x%s): %s"),
1453 dwarf_vmatoa ("x", uvalue
),
1454 fetch_indirect_string (uvalue
));
1457 case DW_FORM_GNU_str_index
:
1460 const char *suffix
= strrchr (section
->name
, '.');
1461 int dwo
= (suffix
&& strcmp (suffix
, ".dwo") == 0) ? 1 : 0;
1463 printf (_(" (indexed string: 0x%s): %s"),
1464 dwarf_vmatoa ("x", uvalue
),
1465 fetch_indexed_string (uvalue
, offset_size
, dwo
));
1469 case DW_FORM_GNU_strp_alt
:
1471 printf (_(" (alt indirect string, offset: 0x%s)"),
1472 dwarf_vmatoa ("x", uvalue
));
1475 case DW_FORM_indirect
:
1476 /* Handled above. */
1479 case DW_FORM_ref_sig8
:
1482 dwarf_vma high_bits
;
1485 byte_get_64 (data
, &high_bits
, &uvalue
);
1486 printf (" signature: 0x%s",
1487 dwarf_vmatoa64 (high_bits
, uvalue
, buf
, sizeof (buf
)));
1492 case DW_FORM_GNU_addr_index
:
1494 printf (_(" (addr_index: 0x%s): %s"),
1495 dwarf_vmatoa ("x", uvalue
),
1496 fetch_indexed_value (uvalue
* pointer_size
, pointer_size
));
1500 warn (_("Unrecognized form: %lu\n"), form
);
1504 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1505 && num_debug_info_entries
== 0
1506 && debug_info_p
!= NULL
)
1510 case DW_AT_frame_base
:
1511 have_frame_base
= 1;
1512 case DW_AT_location
:
1513 case DW_AT_string_length
:
1514 case DW_AT_return_addr
:
1515 case DW_AT_data_member_location
:
1516 case DW_AT_vtable_elem_location
:
1518 case DW_AT_static_link
:
1519 case DW_AT_use_location
:
1520 case DW_AT_GNU_call_site_value
:
1521 case DW_AT_GNU_call_site_data_value
:
1522 case DW_AT_GNU_call_site_target
:
1523 case DW_AT_GNU_call_site_target_clobbered
:
1524 if ((dwarf_version
< 4
1525 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
1526 || form
== DW_FORM_sec_offset
)
1528 /* Process location list. */
1529 unsigned int lmax
= debug_info_p
->max_loc_offsets
;
1530 unsigned int num
= debug_info_p
->num_loc_offsets
;
1532 if (lmax
== 0 || num
>= lmax
)
1535 debug_info_p
->loc_offsets
= (dwarf_vma
*)
1536 xcrealloc (debug_info_p
->loc_offsets
,
1537 lmax
, sizeof (*debug_info_p
->loc_offsets
));
1538 debug_info_p
->have_frame_base
= (int *)
1539 xcrealloc (debug_info_p
->have_frame_base
,
1540 lmax
, sizeof (*debug_info_p
->have_frame_base
));
1541 debug_info_p
->max_loc_offsets
= lmax
;
1543 debug_info_p
->loc_offsets
[num
] = uvalue
;
1544 debug_info_p
->have_frame_base
[num
] = have_frame_base
;
1545 debug_info_p
->num_loc_offsets
++;
1550 if (need_base_address
)
1551 debug_info_p
->base_address
= uvalue
;
1554 case DW_AT_GNU_addr_base
:
1555 debug_info_p
->addr_base
= uvalue
;
1558 case DW_AT_GNU_ranges_base
:
1559 debug_info_p
->ranges_base
= uvalue
;
1563 if ((dwarf_version
< 4
1564 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
1565 || form
== DW_FORM_sec_offset
)
1567 /* Process range list. */
1568 unsigned int lmax
= debug_info_p
->max_range_lists
;
1569 unsigned int num
= debug_info_p
->num_range_lists
;
1571 if (lmax
== 0 || num
>= lmax
)
1574 debug_info_p
->range_lists
= (dwarf_vma
*)
1575 xcrealloc (debug_info_p
->range_lists
,
1576 lmax
, sizeof (*debug_info_p
->range_lists
));
1577 debug_info_p
->max_range_lists
= lmax
;
1579 debug_info_p
->range_lists
[num
] = uvalue
;
1580 debug_info_p
->num_range_lists
++;
1589 if (do_loc
|| attribute
== 0)
1592 /* For some attributes we can display further information. */
1600 case DW_INL_not_inlined
:
1601 printf (_("(not inlined)"));
1603 case DW_INL_inlined
:
1604 printf (_("(inlined)"));
1606 case DW_INL_declared_not_inlined
:
1607 printf (_("(declared as inline but ignored)"));
1609 case DW_INL_declared_inlined
:
1610 printf (_("(declared as inline and inlined)"));
1613 printf (_(" (Unknown inline attribute value: %s)"),
1614 dwarf_vmatoa ("x", uvalue
));
1619 case DW_AT_language
:
1622 /* Ordered by the numeric value of these constants. */
1623 case DW_LANG_C89
: printf ("(ANSI C)"); break;
1624 case DW_LANG_C
: printf ("(non-ANSI C)"); break;
1625 case DW_LANG_Ada83
: printf ("(Ada)"); break;
1626 case DW_LANG_C_plus_plus
: printf ("(C++)"); break;
1627 case DW_LANG_Cobol74
: printf ("(Cobol 74)"); break;
1628 case DW_LANG_Cobol85
: printf ("(Cobol 85)"); break;
1629 case DW_LANG_Fortran77
: printf ("(FORTRAN 77)"); break;
1630 case DW_LANG_Fortran90
: printf ("(Fortran 90)"); break;
1631 case DW_LANG_Pascal83
: printf ("(ANSI Pascal)"); break;
1632 case DW_LANG_Modula2
: printf ("(Modula 2)"); break;
1633 /* DWARF 2.1 values. */
1634 case DW_LANG_Java
: printf ("(Java)"); break;
1635 case DW_LANG_C99
: printf ("(ANSI C99)"); break;
1636 case DW_LANG_Ada95
: printf ("(ADA 95)"); break;
1637 case DW_LANG_Fortran95
: printf ("(Fortran 95)"); break;
1638 /* DWARF 3 values. */
1639 case DW_LANG_PLI
: printf ("(PLI)"); break;
1640 case DW_LANG_ObjC
: printf ("(Objective C)"); break;
1641 case DW_LANG_ObjC_plus_plus
: printf ("(Objective C++)"); break;
1642 case DW_LANG_UPC
: printf ("(Unified Parallel C)"); break;
1643 case DW_LANG_D
: printf ("(D)"); break;
1644 /* DWARF 4 values. */
1645 case DW_LANG_Python
: printf ("(Python)"); break;
1646 /* DWARF 5 values. */
1647 case DW_LANG_Go
: printf ("(Go)"); break;
1648 /* MIPS extension. */
1649 case DW_LANG_Mips_Assembler
: printf ("(MIPS assembler)"); break;
1650 /* UPC extension. */
1651 case DW_LANG_Upc
: printf ("(Unified Parallel C)"); break;
1653 if (uvalue
>= DW_LANG_lo_user
&& uvalue
<= DW_LANG_hi_user
)
1654 printf (_("(implementation defined: %s)"),
1655 dwarf_vmatoa ("x", uvalue
));
1657 printf (_("(Unknown: %s)"), dwarf_vmatoa ("x", uvalue
));
1662 case DW_AT_encoding
:
1665 case DW_ATE_void
: printf ("(void)"); break;
1666 case DW_ATE_address
: printf ("(machine address)"); break;
1667 case DW_ATE_boolean
: printf ("(boolean)"); break;
1668 case DW_ATE_complex_float
: printf ("(complex float)"); break;
1669 case DW_ATE_float
: printf ("(float)"); break;
1670 case DW_ATE_signed
: printf ("(signed)"); break;
1671 case DW_ATE_signed_char
: printf ("(signed char)"); break;
1672 case DW_ATE_unsigned
: printf ("(unsigned)"); break;
1673 case DW_ATE_unsigned_char
: printf ("(unsigned char)"); break;
1674 /* DWARF 2.1 values: */
1675 case DW_ATE_imaginary_float
: printf ("(imaginary float)"); break;
1676 case DW_ATE_decimal_float
: printf ("(decimal float)"); break;
1677 /* DWARF 3 values: */
1678 case DW_ATE_packed_decimal
: printf ("(packed_decimal)"); break;
1679 case DW_ATE_numeric_string
: printf ("(numeric_string)"); break;
1680 case DW_ATE_edited
: printf ("(edited)"); break;
1681 case DW_ATE_signed_fixed
: printf ("(signed_fixed)"); break;
1682 case DW_ATE_unsigned_fixed
: printf ("(unsigned_fixed)"); break;
1683 /* HP extensions: */
1684 case DW_ATE_HP_float80
: printf ("(HP_float80)"); break;
1685 case DW_ATE_HP_complex_float80
: printf ("(HP_complex_float80)"); break;
1686 case DW_ATE_HP_float128
: printf ("(HP_float128)"); break;
1687 case DW_ATE_HP_complex_float128
:printf ("(HP_complex_float128)"); break;
1688 case DW_ATE_HP_floathpintel
: printf ("(HP_floathpintel)"); break;
1689 case DW_ATE_HP_imaginary_float80
: printf ("(HP_imaginary_float80)"); break;
1690 case DW_ATE_HP_imaginary_float128
: printf ("(HP_imaginary_float128)"); break;
1693 if (uvalue
>= DW_ATE_lo_user
1694 && uvalue
<= DW_ATE_hi_user
)
1695 printf (_("(user defined type)"));
1697 printf (_("(unknown type)"));
1702 case DW_AT_accessibility
:
1705 case DW_ACCESS_public
: printf ("(public)"); break;
1706 case DW_ACCESS_protected
: printf ("(protected)"); break;
1707 case DW_ACCESS_private
: printf ("(private)"); break;
1709 printf (_("(unknown accessibility)"));
1714 case DW_AT_visibility
:
1717 case DW_VIS_local
: printf ("(local)"); break;
1718 case DW_VIS_exported
: printf ("(exported)"); break;
1719 case DW_VIS_qualified
: printf ("(qualified)"); break;
1720 default: printf (_("(unknown visibility)")); break;
1724 case DW_AT_virtuality
:
1727 case DW_VIRTUALITY_none
: printf ("(none)"); break;
1728 case DW_VIRTUALITY_virtual
: printf ("(virtual)"); break;
1729 case DW_VIRTUALITY_pure_virtual
:printf ("(pure_virtual)"); break;
1730 default: printf (_("(unknown virtuality)")); break;
1734 case DW_AT_identifier_case
:
1737 case DW_ID_case_sensitive
: printf ("(case_sensitive)"); break;
1738 case DW_ID_up_case
: printf ("(up_case)"); break;
1739 case DW_ID_down_case
: printf ("(down_case)"); break;
1740 case DW_ID_case_insensitive
: printf ("(case_insensitive)"); break;
1741 default: printf (_("(unknown case)")); break;
1745 case DW_AT_calling_convention
:
1748 case DW_CC_normal
: printf ("(normal)"); break;
1749 case DW_CC_program
: printf ("(program)"); break;
1750 case DW_CC_nocall
: printf ("(nocall)"); break;
1752 if (uvalue
>= DW_CC_lo_user
1753 && uvalue
<= DW_CC_hi_user
)
1754 printf (_("(user defined)"));
1756 printf (_("(unknown convention)"));
1760 case DW_AT_ordering
:
1763 case -1: printf (_("(undefined)")); break;
1764 case 0: printf ("(row major)"); break;
1765 case 1: printf ("(column major)"); break;
1769 case DW_AT_frame_base
:
1770 have_frame_base
= 1;
1771 case DW_AT_location
:
1772 case DW_AT_string_length
:
1773 case DW_AT_return_addr
:
1774 case DW_AT_data_member_location
:
1775 case DW_AT_vtable_elem_location
:
1777 case DW_AT_static_link
:
1778 case DW_AT_use_location
:
1779 case DW_AT_GNU_call_site_value
:
1780 case DW_AT_GNU_call_site_data_value
:
1781 case DW_AT_GNU_call_site_target
:
1782 case DW_AT_GNU_call_site_target_clobbered
:
1783 if ((dwarf_version
< 4
1784 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
1785 || form
== DW_FORM_sec_offset
)
1786 printf (_("(location list)"));
1788 case DW_AT_allocated
:
1789 case DW_AT_associated
:
1790 case DW_AT_data_location
:
1792 case DW_AT_upper_bound
:
1793 case DW_AT_lower_bound
:
1796 int need_frame_base
;
1799 need_frame_base
= decode_location_expression (block_start
,
1804 cu_offset
, section
);
1806 if (need_frame_base
&& !have_frame_base
)
1807 printf (_(" [without DW_AT_frame_base]"));
1813 if (form
== DW_FORM_ref_sig8
1814 || form
== DW_FORM_GNU_ref_alt
)
1817 if (form
== DW_FORM_ref1
1818 || form
== DW_FORM_ref2
1819 || form
== DW_FORM_ref4
1820 || form
== DW_FORM_ref_udata
)
1821 uvalue
+= cu_offset
;
1823 if (uvalue
>= section
->size
)
1824 warn (_("Offset %s used as value for DW_AT_import attribute of DIE at offset %lx is too big.\n"),
1825 dwarf_vmatoa ("x", uvalue
),
1826 (unsigned long) (orig_data
- section
->start
));
1829 unsigned long abbrev_number
;
1830 abbrev_entry
* entry
;
1832 abbrev_number
= read_leb128 (section
->start
+ uvalue
, NULL
, 0);
1834 printf (_("[Abbrev Number: %ld"), abbrev_number
);
1835 /* Don't look up abbrev for DW_FORM_ref_addr, as it very often will
1836 use different abbrev table, and we don't track .debug_info chunks
1838 if (form
!= DW_FORM_ref_addr
)
1840 for (entry
= first_abbrev
; entry
!= NULL
; entry
= entry
->next
)
1841 if (entry
->entry
== abbrev_number
)
1844 printf (" (%s)", get_TAG_name (entry
->tag
));
1859 get_AT_name (unsigned long attribute
)
1863 /* One value is shared by the MIPS and HP extensions: */
1864 if (attribute
== DW_AT_MIPS_fde
)
1865 return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable";
1867 name
= get_DW_AT_name (attribute
);
1871 static char buffer
[100];
1873 snprintf (buffer
, sizeof (buffer
), _("Unknown AT value: %lx"),
1881 static unsigned char *
1882 read_and_display_attr (unsigned long attribute
,
1884 unsigned char * data
,
1885 dwarf_vma cu_offset
,
1886 dwarf_vma pointer_size
,
1887 dwarf_vma offset_size
,
1889 debug_info
* debug_info_p
,
1891 struct dwarf_section
* section
)
1894 printf (" %-18s:", get_AT_name (attribute
));
1895 data
= read_and_display_attr_value (attribute
, form
, data
, cu_offset
,
1896 pointer_size
, offset_size
,
1897 dwarf_version
, debug_info_p
,
1905 /* Process the contents of a .debug_info section. If do_loc is non-zero
1906 then we are scanning for location lists and we do not want to display
1907 anything to the user. If do_types is non-zero, we are processing
1908 a .debug_types section instead of a .debug_info section. */
1911 process_debug_info (struct dwarf_section
*section
,
1913 enum dwarf_section_display_enum abbrev_sec
,
1917 unsigned char *start
= section
->start
;
1918 unsigned char *end
= start
+ section
->size
;
1919 unsigned char *section_begin
;
1921 unsigned int num_units
= 0;
1923 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1924 && num_debug_info_entries
== 0
1929 /* First scan the section to get the number of comp units. */
1930 for (section_begin
= start
, num_units
= 0; section_begin
< end
;
1933 /* Read the first 4 bytes. For a 32-bit DWARF section, this
1934 will be the length. For a 64-bit DWARF section, it'll be
1935 the escape code 0xffffffff followed by an 8 byte length. */
1936 length
= byte_get (section_begin
, 4);
1938 if (length
== 0xffffffff)
1940 length
= byte_get (section_begin
+ 4, 8);
1941 section_begin
+= length
+ 12;
1943 else if (length
>= 0xfffffff0 && length
< 0xffffffff)
1945 warn (_("Reserved length value (0x%s) found in section %s\n"),
1946 dwarf_vmatoa ("x", length
), section
->name
);
1950 section_begin
+= length
+ 4;
1952 /* Negative values are illegal, they may even cause infinite
1953 looping. This can happen if we can't accurately apply
1954 relocations to an object file. */
1955 if ((signed long) length
<= 0)
1957 warn (_("Corrupt unit length (0x%s) found in section %s\n"),
1958 dwarf_vmatoa ("x", length
), section
->name
);
1965 error (_("No comp units in %s section ?"), section
->name
);
1969 /* Then allocate an array to hold the information. */
1970 debug_information
= (debug_info
*) cmalloc (num_units
,
1971 sizeof (* debug_information
));
1972 if (debug_information
== NULL
)
1974 error (_("Not enough memory for a debug info array of %u entries"),
1982 if (dwarf_start_die
== 0)
1983 printf (_("Contents of the %s section:\n\n"), section
->name
);
1985 load_debug_section (str
, file
);
1986 load_debug_section (str_dwo
, file
);
1987 load_debug_section (str_index
, file
);
1988 load_debug_section (str_index_dwo
, file
);
1989 load_debug_section (debug_addr
, file
);
1992 load_debug_section (abbrev_sec
, file
);
1993 if (debug_displays
[abbrev_sec
].section
.start
== NULL
)
1995 warn (_("Unable to locate %s section!\n"),
1996 debug_displays
[abbrev_sec
].section
.name
);
2000 for (section_begin
= start
, unit
= 0; start
< end
; unit
++)
2002 DWARF2_Internal_CompUnit compunit
;
2003 unsigned char *hdrptr
;
2004 unsigned char *tags
;
2005 int level
, last_level
, saved_level
;
2006 dwarf_vma cu_offset
;
2008 int initial_length_size
;
2009 dwarf_vma signature_high
= 0;
2010 dwarf_vma signature_low
= 0;
2011 dwarf_vma type_offset
= 0;
2015 compunit
.cu_length
= byte_get (hdrptr
, 4);
2018 if (compunit
.cu_length
== 0xffffffff)
2020 compunit
.cu_length
= byte_get (hdrptr
, 8);
2023 initial_length_size
= 12;
2028 initial_length_size
= 4;
2031 compunit
.cu_version
= byte_get (hdrptr
, 2);
2034 cu_offset
= start
- section_begin
;
2036 compunit
.cu_abbrev_offset
= byte_get (hdrptr
, offset_size
);
2037 hdrptr
+= offset_size
;
2039 compunit
.cu_pointer_size
= byte_get (hdrptr
, 1);
2044 byte_get_64 (hdrptr
, &signature_high
, &signature_low
);
2046 type_offset
= byte_get (hdrptr
, offset_size
);
2047 hdrptr
+= offset_size
;
2050 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2051 && num_debug_info_entries
== 0
2054 debug_information
[unit
].cu_offset
= cu_offset
;
2055 debug_information
[unit
].pointer_size
2056 = compunit
.cu_pointer_size
;
2057 debug_information
[unit
].offset_size
= offset_size
;
2058 debug_information
[unit
].dwarf_version
= compunit
.cu_version
;
2059 debug_information
[unit
].base_address
= 0;
2060 debug_information
[unit
].addr_base
= DEBUG_INFO_UNAVAILABLE
;
2061 debug_information
[unit
].ranges_base
= DEBUG_INFO_UNAVAILABLE
;
2062 debug_information
[unit
].loc_offsets
= NULL
;
2063 debug_information
[unit
].have_frame_base
= NULL
;
2064 debug_information
[unit
].max_loc_offsets
= 0;
2065 debug_information
[unit
].num_loc_offsets
= 0;
2066 debug_information
[unit
].range_lists
= NULL
;
2067 debug_information
[unit
].max_range_lists
= 0;
2068 debug_information
[unit
].num_range_lists
= 0;
2071 if (!do_loc
&& dwarf_start_die
== 0)
2073 printf (_(" Compilation Unit @ offset 0x%s:\n"),
2074 dwarf_vmatoa ("x", cu_offset
));
2075 printf (_(" Length: 0x%s (%s)\n"),
2076 dwarf_vmatoa ("x", compunit
.cu_length
),
2077 offset_size
== 8 ? "64-bit" : "32-bit");
2078 printf (_(" Version: %d\n"), compunit
.cu_version
);
2079 printf (_(" Abbrev Offset: 0x%s\n"),
2080 dwarf_vmatoa ("x", compunit
.cu_abbrev_offset
));
2081 printf (_(" Pointer Size: %d\n"), compunit
.cu_pointer_size
);
2086 printf (_(" Signature: 0x%s\n"),
2087 dwarf_vmatoa64 (signature_high
, signature_low
,
2088 buf
, sizeof (buf
)));
2089 printf (_(" Type Offset: 0x%s\n"),
2090 dwarf_vmatoa ("x", type_offset
));
2094 if (cu_offset
+ compunit
.cu_length
+ initial_length_size
2097 warn (_("Debug info is corrupted, length of CU at %s"
2098 " extends beyond end of section (length = %s)\n"),
2099 dwarf_vmatoa ("x", cu_offset
),
2100 dwarf_vmatoa ("x", compunit
.cu_length
));
2104 start
+= compunit
.cu_length
+ initial_length_size
;
2106 if (compunit
.cu_version
!= 2
2107 && compunit
.cu_version
!= 3
2108 && compunit
.cu_version
!= 4)
2110 warn (_("CU at offset %s contains corrupt or "
2111 "unsupported version number: %d.\n"),
2112 dwarf_vmatoa ("x", cu_offset
), compunit
.cu_version
);
2118 /* Process the abbrevs used by this compilation unit. DWARF
2119 sections under Mach-O have non-zero addresses. */
2120 if (compunit
.cu_abbrev_offset
>= debug_displays
[abbrev_sec
].section
.size
)
2121 warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"),
2122 (unsigned long) compunit
.cu_abbrev_offset
,
2123 (unsigned long) debug_displays
[abbrev_sec
].section
.size
);
2125 process_abbrev_section
2126 ((unsigned char *) debug_displays
[abbrev_sec
].section
.start
2127 + compunit
.cu_abbrev_offset
,
2128 (unsigned char *) debug_displays
[abbrev_sec
].section
.start
2129 + debug_displays
[abbrev_sec
].section
.size
);
2134 while (tags
< start
)
2136 unsigned int bytes_read
;
2137 unsigned long abbrev_number
;
2138 unsigned long die_offset
;
2139 abbrev_entry
*entry
;
2141 int do_printing
= 1;
2143 die_offset
= tags
- section_begin
;
2145 abbrev_number
= read_leb128 (tags
, & bytes_read
, 0);
2148 /* A null DIE marks the end of a list of siblings or it may also be
2149 a section padding. */
2150 if (abbrev_number
== 0)
2152 /* Check if it can be a section padding for the last CU. */
2153 if (level
== 0 && start
== end
)
2157 for (chk
= tags
; chk
< start
; chk
++)
2167 static unsigned num_bogus_warns
= 0;
2169 if (num_bogus_warns
< 3)
2171 warn (_("Bogus end-of-siblings marker detected at offset %lx in %s section\n"),
2172 die_offset
, section
->name
);
2174 if (num_bogus_warns
== 3)
2175 warn (_("Further warnings about bogus end-of-sibling markers suppressed\n"));
2178 if (dwarf_start_die
!= 0 && level
< saved_level
)
2185 if (dwarf_start_die
!= 0 && die_offset
< dwarf_start_die
)
2189 if (dwarf_start_die
!= 0 && die_offset
== dwarf_start_die
)
2190 saved_level
= level
;
2191 do_printing
= (dwarf_cutoff_level
== -1
2192 || level
< dwarf_cutoff_level
);
2194 printf (_(" <%d><%lx>: Abbrev Number: %lu"),
2195 level
, die_offset
, abbrev_number
);
2196 else if (dwarf_cutoff_level
== -1
2197 || last_level
< dwarf_cutoff_level
)
2198 printf (_(" <%d><%lx>: ...\n"), level
, die_offset
);
2203 /* Scan through the abbreviation list until we reach the
2205 for (entry
= first_abbrev
;
2206 entry
&& entry
->entry
!= abbrev_number
;
2207 entry
= entry
->next
)
2212 if (!do_loc
&& do_printing
)
2217 warn (_("DIE at offset %lx refers to abbreviation number %lu which does not exist\n"),
2218 die_offset
, abbrev_number
);
2222 if (!do_loc
&& do_printing
)
2223 printf (" (%s)\n", get_TAG_name (entry
->tag
));
2228 need_base_address
= 0;
2230 case DW_TAG_compile_unit
:
2231 need_base_address
= 1;
2233 case DW_TAG_entry_point
:
2234 case DW_TAG_subprogram
:
2235 need_base_address
= 0;
2236 /* Assuming that there is no DW_AT_frame_base. */
2237 have_frame_base
= 0;
2241 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
2245 if (! do_loc
&& do_printing
)
2246 /* Show the offset from where the tag was extracted. */
2247 printf (" <%lx>", (unsigned long)(tags
- section_begin
));
2249 arg
= debug_information
;
2250 if (debug_information
)
2253 tags
= read_and_display_attr (attr
->attribute
,
2256 compunit
.cu_pointer_size
,
2258 compunit
.cu_version
,
2260 do_loc
|| ! do_printing
, section
);
2263 if (entry
->children
)
2268 /* Set num_debug_info_entries here so that it can be used to check if
2269 we need to process .debug_loc and .debug_ranges sections. */
2270 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2271 && num_debug_info_entries
== 0
2273 num_debug_info_entries
= num_units
;
2281 /* Locate and scan the .debug_info section in the file and record the pointer
2282 sizes and offsets for the compilation units in it. Usually an executable
2283 will have just one pointer size, but this is not guaranteed, and so we try
2284 not to make any assumptions. Returns zero upon failure, or the number of
2285 compilation units upon success. */
2288 load_debug_info (void * file
)
2290 /* Reset the last pointer size so that we can issue correct error
2291 messages if we are displaying the contents of more than one section. */
2292 last_pointer_size
= 0;
2293 warned_about_missing_comp_units
= FALSE
;
2295 /* If we have already tried and failed to load the .debug_info
2296 section then do not bother to repear the task. */
2297 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
2300 /* If we already have the information there is nothing else to do. */
2301 if (num_debug_info_entries
> 0)
2302 return num_debug_info_entries
;
2304 if (load_debug_section (info
, file
)
2305 && process_debug_info (&debug_displays
[info
].section
, file
, abbrev
, 1, 0))
2306 return num_debug_info_entries
;
2307 else if (load_debug_section (info_dwo
, file
)
2308 && process_debug_info (&debug_displays
[info_dwo
].section
, file
,
2310 return num_debug_info_entries
;
2312 num_debug_info_entries
= DEBUG_INFO_UNAVAILABLE
;
2317 display_debug_lines_raw (struct dwarf_section
*section
,
2318 unsigned char *data
,
2321 unsigned char *start
= section
->start
;
2323 printf (_("Raw dump of debug contents of section %s:\n\n"),
2328 DWARF2_Internal_LineInfo linfo
;
2329 unsigned char *standard_opcodes
;
2330 unsigned char *end_of_sequence
;
2331 unsigned char *hdrptr
;
2332 unsigned long hdroff
;
2333 int initial_length_size
;
2338 hdroff
= hdrptr
- start
;
2340 /* Check the length of the block. */
2341 linfo
.li_length
= byte_get (hdrptr
, 4);
2344 if (linfo
.li_length
== 0xffffffff)
2346 /* This section is 64-bit DWARF 3. */
2347 linfo
.li_length
= byte_get (hdrptr
, 8);
2350 initial_length_size
= 12;
2355 initial_length_size
= 4;
2358 if (linfo
.li_length
+ initial_length_size
> section
->size
)
2361 (_("The information in section %s appears to be corrupt - the section is too small\n"),
2366 /* Check its version number. */
2367 linfo
.li_version
= byte_get (hdrptr
, 2);
2369 if (linfo
.li_version
!= 2
2370 && linfo
.li_version
!= 3
2371 && linfo
.li_version
!= 4)
2373 warn (_("Only DWARF version 2, 3 and 4 line info is currently supported.\n"));
2377 linfo
.li_prologue_length
= byte_get (hdrptr
, offset_size
);
2378 hdrptr
+= offset_size
;
2379 linfo
.li_min_insn_length
= byte_get (hdrptr
, 1);
2381 if (linfo
.li_version
>= 4)
2383 linfo
.li_max_ops_per_insn
= byte_get (hdrptr
, 1);
2385 if (linfo
.li_max_ops_per_insn
== 0)
2387 warn (_("Invalid maximum operations per insn.\n"));
2392 linfo
.li_max_ops_per_insn
= 1;
2393 linfo
.li_default_is_stmt
= byte_get (hdrptr
, 1);
2395 linfo
.li_line_base
= byte_get (hdrptr
, 1);
2397 linfo
.li_line_range
= byte_get (hdrptr
, 1);
2399 linfo
.li_opcode_base
= byte_get (hdrptr
, 1);
2402 /* Sign extend the line base field. */
2403 linfo
.li_line_base
<<= 24;
2404 linfo
.li_line_base
>>= 24;
2406 printf (_(" Offset: 0x%lx\n"), hdroff
);
2407 printf (_(" Length: %ld\n"), (long) linfo
.li_length
);
2408 printf (_(" DWARF Version: %d\n"), linfo
.li_version
);
2409 printf (_(" Prologue Length: %d\n"), linfo
.li_prologue_length
);
2410 printf (_(" Minimum Instruction Length: %d\n"), linfo
.li_min_insn_length
);
2411 if (linfo
.li_version
>= 4)
2412 printf (_(" Maximum Ops per Instruction: %d\n"), linfo
.li_max_ops_per_insn
);
2413 printf (_(" Initial value of 'is_stmt': %d\n"), linfo
.li_default_is_stmt
);
2414 printf (_(" Line Base: %d\n"), linfo
.li_line_base
);
2415 printf (_(" Line Range: %d\n"), linfo
.li_line_range
);
2416 printf (_(" Opcode Base: %d\n"), linfo
.li_opcode_base
);
2418 end_of_sequence
= data
+ linfo
.li_length
+ initial_length_size
;
2420 reset_state_machine (linfo
.li_default_is_stmt
);
2422 /* Display the contents of the Opcodes table. */
2423 standard_opcodes
= hdrptr
;
2425 printf (_("\n Opcodes:\n"));
2427 for (i
= 1; i
< linfo
.li_opcode_base
; i
++)
2428 printf (_(" Opcode %d has %d args\n"), i
, standard_opcodes
[i
- 1]);
2430 /* Display the contents of the Directory table. */
2431 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
2434 printf (_("\n The Directory Table is empty.\n"));
2437 printf (_("\n The Directory Table:\n"));
2441 printf (" %s\n", data
);
2443 data
+= strlen ((char *) data
) + 1;
2447 /* Skip the NUL at the end of the table. */
2450 /* Display the contents of the File Name table. */
2452 printf (_("\n The File Name Table is empty.\n"));
2455 printf (_("\n The File Name Table:\n"));
2456 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
2460 unsigned char *name
;
2461 unsigned int bytes_read
;
2463 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
2466 data
+= strlen ((char *) data
) + 1;
2469 dwarf_vmatoa ("u", read_leb128 (data
, & bytes_read
, 0)));
2472 dwarf_vmatoa ("u", read_leb128 (data
, & bytes_read
, 0)));
2475 dwarf_vmatoa ("u", read_leb128 (data
, & bytes_read
, 0)));
2477 printf ("%s\n", name
);
2481 /* Skip the NUL at the end of the table. */
2484 /* Now display the statements. */
2485 printf (_("\n Line Number Statements:\n"));
2487 while (data
< end_of_sequence
)
2489 unsigned char op_code
;
2490 dwarf_signed_vma adv
;
2492 unsigned int bytes_read
;
2496 if (op_code
>= linfo
.li_opcode_base
)
2498 op_code
-= linfo
.li_opcode_base
;
2499 uladv
= (op_code
/ linfo
.li_line_range
);
2500 if (linfo
.li_max_ops_per_insn
== 1)
2502 uladv
*= linfo
.li_min_insn_length
;
2503 state_machine_regs
.address
+= uladv
;
2504 printf (_(" Special opcode %d: "
2505 "advance Address by %s to 0x%s"),
2506 op_code
, dwarf_vmatoa ("u", uladv
),
2507 dwarf_vmatoa ("x", state_machine_regs
.address
));
2511 state_machine_regs
.address
2512 += ((state_machine_regs
.op_index
+ uladv
)
2513 / linfo
.li_max_ops_per_insn
)
2514 * linfo
.li_min_insn_length
;
2515 state_machine_regs
.op_index
2516 = (state_machine_regs
.op_index
+ uladv
)
2517 % linfo
.li_max_ops_per_insn
;
2518 printf (_(" Special opcode %d: "
2519 "advance Address by %s to 0x%s[%d]"),
2520 op_code
, dwarf_vmatoa ("u", uladv
),
2521 dwarf_vmatoa ("x", state_machine_regs
.address
),
2522 state_machine_regs
.op_index
);
2524 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
2525 state_machine_regs
.line
+= adv
;
2526 printf (_(" and Line by %s to %d\n"),
2527 dwarf_vmatoa ("d", adv
), state_machine_regs
.line
);
2529 else switch (op_code
)
2531 case DW_LNS_extended_op
:
2532 data
+= process_extended_line_op (data
, linfo
.li_default_is_stmt
);
2536 printf (_(" Copy\n"));
2539 case DW_LNS_advance_pc
:
2540 uladv
= read_leb128 (data
, & bytes_read
, 0);
2542 if (linfo
.li_max_ops_per_insn
== 1)
2544 uladv
*= linfo
.li_min_insn_length
;
2545 state_machine_regs
.address
+= uladv
;
2546 printf (_(" Advance PC by %s to 0x%s\n"),
2547 dwarf_vmatoa ("u", uladv
),
2548 dwarf_vmatoa ("x", state_machine_regs
.address
));
2552 state_machine_regs
.address
2553 += ((state_machine_regs
.op_index
+ uladv
)
2554 / linfo
.li_max_ops_per_insn
)
2555 * linfo
.li_min_insn_length
;
2556 state_machine_regs
.op_index
2557 = (state_machine_regs
.op_index
+ uladv
)
2558 % linfo
.li_max_ops_per_insn
;
2559 printf (_(" Advance PC by %s to 0x%s[%d]\n"),
2560 dwarf_vmatoa ("u", uladv
),
2561 dwarf_vmatoa ("x", state_machine_regs
.address
),
2562 state_machine_regs
.op_index
);
2566 case DW_LNS_advance_line
:
2567 adv
= read_sleb128 (data
, & bytes_read
);
2569 state_machine_regs
.line
+= adv
;
2570 printf (_(" Advance Line by %s to %d\n"),
2571 dwarf_vmatoa ("d", adv
),
2572 state_machine_regs
.line
);
2575 case DW_LNS_set_file
:
2576 adv
= read_leb128 (data
, & bytes_read
, 0);
2578 printf (_(" Set File Name to entry %s in the File Name Table\n"),
2579 dwarf_vmatoa ("d", adv
));
2580 state_machine_regs
.file
= adv
;
2583 case DW_LNS_set_column
:
2584 uladv
= read_leb128 (data
, & bytes_read
, 0);
2586 printf (_(" Set column to %s\n"),
2587 dwarf_vmatoa ("u", uladv
));
2588 state_machine_regs
.column
= uladv
;
2591 case DW_LNS_negate_stmt
:
2592 adv
= state_machine_regs
.is_stmt
;
2594 printf (_(" Set is_stmt to %s\n"), dwarf_vmatoa ("d", adv
));
2595 state_machine_regs
.is_stmt
= adv
;
2598 case DW_LNS_set_basic_block
:
2599 printf (_(" Set basic block\n"));
2600 state_machine_regs
.basic_block
= 1;
2603 case DW_LNS_const_add_pc
:
2604 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
2605 if (linfo
.li_max_ops_per_insn
)
2607 uladv
*= linfo
.li_min_insn_length
;
2608 state_machine_regs
.address
+= uladv
;
2609 printf (_(" Advance PC by constant %s to 0x%s\n"),
2610 dwarf_vmatoa ("u", uladv
),
2611 dwarf_vmatoa ("x", state_machine_regs
.address
));
2615 state_machine_regs
.address
2616 += ((state_machine_regs
.op_index
+ uladv
)
2617 / linfo
.li_max_ops_per_insn
)
2618 * linfo
.li_min_insn_length
;
2619 state_machine_regs
.op_index
2620 = (state_machine_regs
.op_index
+ uladv
)
2621 % linfo
.li_max_ops_per_insn
;
2622 printf (_(" Advance PC by constant %s to 0x%s[%d]\n"),
2623 dwarf_vmatoa ("u", uladv
),
2624 dwarf_vmatoa ("x", state_machine_regs
.address
),
2625 state_machine_regs
.op_index
);
2629 case DW_LNS_fixed_advance_pc
:
2630 uladv
= byte_get (data
, 2);
2632 state_machine_regs
.address
+= uladv
;
2633 state_machine_regs
.op_index
= 0;
2634 printf (_(" Advance PC by fixed size amount %s to 0x%s\n"),
2635 dwarf_vmatoa ("u", uladv
),
2636 dwarf_vmatoa ("x", state_machine_regs
.address
));
2639 case DW_LNS_set_prologue_end
:
2640 printf (_(" Set prologue_end to true\n"));
2643 case DW_LNS_set_epilogue_begin
:
2644 printf (_(" Set epilogue_begin to true\n"));
2647 case DW_LNS_set_isa
:
2648 uladv
= read_leb128 (data
, & bytes_read
, 0);
2650 printf (_(" Set ISA to %s\n"), dwarf_vmatoa ("u", uladv
));
2654 printf (_(" Unknown opcode %d with operands: "), op_code
);
2656 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
2658 printf ("0x%s%s", dwarf_vmatoa ("x", read_leb128 (data
,
2660 i
== 1 ? "" : ", ");
2675 unsigned char *name
;
2676 unsigned int directory_index
;
2677 unsigned int modification_date
;
2678 unsigned int length
;
2681 /* Output a decoded representation of the .debug_line section. */
2684 display_debug_lines_decoded (struct dwarf_section
*section
,
2685 unsigned char *data
,
2688 printf (_("Decoded dump of debug contents of section %s:\n\n"),
2693 /* This loop amounts to one iteration per compilation unit. */
2694 DWARF2_Internal_LineInfo linfo
;
2695 unsigned char *standard_opcodes
;
2696 unsigned char *end_of_sequence
;
2697 unsigned char *hdrptr
;
2698 int initial_length_size
;
2701 File_Entry
*file_table
= NULL
;
2702 unsigned int n_files
= 0;
2703 unsigned char **directory_table
= NULL
;
2704 unsigned int n_directories
= 0;
2708 /* Extract information from the Line Number Program Header.
2709 (section 6.2.4 in the Dwarf3 doc). */
2711 /* Get the length of this CU's line number information block. */
2712 linfo
.li_length
= byte_get (hdrptr
, 4);
2715 if (linfo
.li_length
== 0xffffffff)
2717 /* This section is 64-bit DWARF 3. */
2718 linfo
.li_length
= byte_get (hdrptr
, 8);
2721 initial_length_size
= 12;
2726 initial_length_size
= 4;
2729 if (linfo
.li_length
+ initial_length_size
> section
->size
)
2731 warn (_("The line info appears to be corrupt - "
2732 "the section is too small\n"));
2736 /* Get this CU's Line Number Block version number. */
2737 linfo
.li_version
= byte_get (hdrptr
, 2);
2739 if (linfo
.li_version
!= 2
2740 && linfo
.li_version
!= 3
2741 && linfo
.li_version
!= 4)
2743 warn (_("Only DWARF version 2, 3 and 4 line info is currently "
2748 linfo
.li_prologue_length
= byte_get (hdrptr
, offset_size
);
2749 hdrptr
+= offset_size
;
2750 linfo
.li_min_insn_length
= byte_get (hdrptr
, 1);
2752 if (linfo
.li_version
>= 4)
2754 linfo
.li_max_ops_per_insn
= byte_get (hdrptr
, 1);
2756 if (linfo
.li_max_ops_per_insn
== 0)
2758 warn (_("Invalid maximum operations per insn.\n"));
2763 linfo
.li_max_ops_per_insn
= 1;
2764 linfo
.li_default_is_stmt
= byte_get (hdrptr
, 1);
2766 linfo
.li_line_base
= byte_get (hdrptr
, 1);
2768 linfo
.li_line_range
= byte_get (hdrptr
, 1);
2770 linfo
.li_opcode_base
= byte_get (hdrptr
, 1);
2773 /* Sign extend the line base field. */
2774 linfo
.li_line_base
<<= 24;
2775 linfo
.li_line_base
>>= 24;
2777 /* Find the end of this CU's Line Number Information Block. */
2778 end_of_sequence
= data
+ linfo
.li_length
+ initial_length_size
;
2780 reset_state_machine (linfo
.li_default_is_stmt
);
2782 /* Save a pointer to the contents of the Opcodes table. */
2783 standard_opcodes
= hdrptr
;
2785 /* Traverse the Directory table just to count entries. */
2786 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
2789 unsigned char *ptr_directory_table
= data
;
2793 data
+= strlen ((char *) data
) + 1;
2797 /* Go through the directory table again to save the directories. */
2798 directory_table
= (unsigned char **)
2799 xmalloc (n_directories
* sizeof (unsigned char *));
2802 while (*ptr_directory_table
!= 0)
2804 directory_table
[i
] = ptr_directory_table
;
2805 ptr_directory_table
+= strlen ((char *) ptr_directory_table
) + 1;
2809 /* Skip the NUL at the end of the table. */
2812 /* Traverse the File Name table just to count the entries. */
2815 unsigned char *ptr_file_name_table
= data
;
2819 unsigned int bytes_read
;
2821 /* Skip Name, directory index, last modification time and length
2823 data
+= strlen ((char *) data
) + 1;
2824 read_leb128 (data
, & bytes_read
, 0);
2826 read_leb128 (data
, & bytes_read
, 0);
2828 read_leb128 (data
, & bytes_read
, 0);
2834 /* Go through the file table again to save the strings. */
2835 file_table
= (File_Entry
*) xmalloc (n_files
* sizeof (File_Entry
));
2838 while (*ptr_file_name_table
!= 0)
2840 unsigned int bytes_read
;
2842 file_table
[i
].name
= ptr_file_name_table
;
2843 ptr_file_name_table
+= strlen ((char *) ptr_file_name_table
) + 1;
2845 /* We are not interested in directory, time or size. */
2846 file_table
[i
].directory_index
= read_leb128 (ptr_file_name_table
,
2848 ptr_file_name_table
+= bytes_read
;
2849 file_table
[i
].modification_date
= read_leb128 (ptr_file_name_table
,
2851 ptr_file_name_table
+= bytes_read
;
2852 file_table
[i
].length
= read_leb128 (ptr_file_name_table
, & bytes_read
, 0);
2853 ptr_file_name_table
+= bytes_read
;
2858 /* Print the Compilation Unit's name and a header. */
2859 if (directory_table
== NULL
)
2861 printf (_("CU: %s:\n"), file_table
[0].name
);
2862 printf (_("File name Line number Starting address\n"));
2866 unsigned int ix
= file_table
[0].directory_index
;
2867 const char *directory
= ix
? (char *)directory_table
[ix
- 1] : ".";
2868 if (do_wide
|| strlen (directory
) < 76)
2869 printf (_("CU: %s/%s:\n"), directory
, file_table
[0].name
);
2871 printf ("%s:\n", file_table
[0].name
);
2873 printf (_("File name Line number Starting address\n"));
2877 /* Skip the NUL at the end of the table. */
2880 /* This loop iterates through the Dwarf Line Number Program. */
2881 while (data
< end_of_sequence
)
2883 unsigned char op_code
;
2885 unsigned long int uladv
;
2886 unsigned int bytes_read
;
2887 int is_special_opcode
= 0;
2891 if (op_code
>= linfo
.li_opcode_base
)
2893 op_code
-= linfo
.li_opcode_base
;
2894 uladv
= (op_code
/ linfo
.li_line_range
);
2895 if (linfo
.li_max_ops_per_insn
== 1)
2897 uladv
*= linfo
.li_min_insn_length
;
2898 state_machine_regs
.address
+= uladv
;
2902 state_machine_regs
.address
2903 += ((state_machine_regs
.op_index
+ uladv
)
2904 / linfo
.li_max_ops_per_insn
)
2905 * linfo
.li_min_insn_length
;
2906 state_machine_regs
.op_index
2907 = (state_machine_regs
.op_index
+ uladv
)
2908 % linfo
.li_max_ops_per_insn
;
2911 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
2912 state_machine_regs
.line
+= adv
;
2913 is_special_opcode
= 1;
2915 else switch (op_code
)
2917 case DW_LNS_extended_op
:
2919 unsigned int ext_op_code_len
;
2920 unsigned char ext_op_code
;
2921 unsigned char *op_code_data
= data
;
2923 ext_op_code_len
= read_leb128 (op_code_data
, &bytes_read
, 0);
2924 op_code_data
+= bytes_read
;
2926 if (ext_op_code_len
== 0)
2928 warn (_("badly formed extended line op encountered!\n"));
2931 ext_op_code_len
+= bytes_read
;
2932 ext_op_code
= *op_code_data
++;
2934 switch (ext_op_code
)
2936 case DW_LNE_end_sequence
:
2937 reset_state_machine (linfo
.li_default_is_stmt
);
2939 case DW_LNE_set_address
:
2940 state_machine_regs
.address
=
2941 byte_get (op_code_data
, ext_op_code_len
- bytes_read
- 1);
2942 state_machine_regs
.op_index
= 0;
2944 case DW_LNE_define_file
:
2946 file_table
= (File_Entry
*) xrealloc
2947 (file_table
, (n_files
+ 1) * sizeof (File_Entry
));
2949 ++state_machine_regs
.last_file_entry
;
2950 /* Source file name. */
2951 file_table
[n_files
].name
= op_code_data
;
2952 op_code_data
+= strlen ((char *) op_code_data
) + 1;
2953 /* Directory index. */
2954 file_table
[n_files
].directory_index
=
2955 read_leb128 (op_code_data
, & bytes_read
, 0);
2956 op_code_data
+= bytes_read
;
2957 /* Last modification time. */
2958 file_table
[n_files
].modification_date
=
2959 read_leb128 (op_code_data
, & bytes_read
, 0);
2960 op_code_data
+= bytes_read
;
2962 file_table
[n_files
].length
=
2963 read_leb128 (op_code_data
, & bytes_read
, 0);
2968 case DW_LNE_set_discriminator
:
2969 case DW_LNE_HP_set_sequence
:
2970 /* Simply ignored. */
2974 printf (_("UNKNOWN (%u): length %d\n"),
2975 ext_op_code
, ext_op_code_len
- bytes_read
);
2978 data
+= ext_op_code_len
;
2984 case DW_LNS_advance_pc
:
2985 uladv
= read_leb128 (data
, & bytes_read
, 0);
2987 if (linfo
.li_max_ops_per_insn
== 1)
2989 uladv
*= linfo
.li_min_insn_length
;
2990 state_machine_regs
.address
+= uladv
;
2994 state_machine_regs
.address
2995 += ((state_machine_regs
.op_index
+ uladv
)
2996 / linfo
.li_max_ops_per_insn
)
2997 * linfo
.li_min_insn_length
;
2998 state_machine_regs
.op_index
2999 = (state_machine_regs
.op_index
+ uladv
)
3000 % linfo
.li_max_ops_per_insn
;
3004 case DW_LNS_advance_line
:
3005 adv
= read_sleb128 (data
, & bytes_read
);
3007 state_machine_regs
.line
+= adv
;
3010 case DW_LNS_set_file
:
3011 adv
= read_leb128 (data
, & bytes_read
, 0);
3013 state_machine_regs
.file
= adv
;
3014 if (file_table
[state_machine_regs
.file
- 1].directory_index
== 0)
3016 /* If directory index is 0, that means current directory. */
3017 printf ("\n./%s:[++]\n",
3018 file_table
[state_machine_regs
.file
- 1].name
);
3022 /* The directory index starts counting at 1. */
3023 printf ("\n%s/%s:\n",
3024 directory_table
[file_table
[state_machine_regs
.file
- 1].directory_index
- 1],
3025 file_table
[state_machine_regs
.file
- 1].name
);
3029 case DW_LNS_set_column
:
3030 uladv
= read_leb128 (data
, & bytes_read
, 0);
3032 state_machine_regs
.column
= uladv
;
3035 case DW_LNS_negate_stmt
:
3036 adv
= state_machine_regs
.is_stmt
;
3038 state_machine_regs
.is_stmt
= adv
;
3041 case DW_LNS_set_basic_block
:
3042 state_machine_regs
.basic_block
= 1;
3045 case DW_LNS_const_add_pc
:
3046 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
3047 if (linfo
.li_max_ops_per_insn
== 1)
3049 uladv
*= linfo
.li_min_insn_length
;
3050 state_machine_regs
.address
+= uladv
;
3054 state_machine_regs
.address
3055 += ((state_machine_regs
.op_index
+ uladv
)
3056 / linfo
.li_max_ops_per_insn
)
3057 * linfo
.li_min_insn_length
;
3058 state_machine_regs
.op_index
3059 = (state_machine_regs
.op_index
+ uladv
)
3060 % linfo
.li_max_ops_per_insn
;
3064 case DW_LNS_fixed_advance_pc
:
3065 uladv
= byte_get (data
, 2);
3067 state_machine_regs
.address
+= uladv
;
3068 state_machine_regs
.op_index
= 0;
3071 case DW_LNS_set_prologue_end
:
3074 case DW_LNS_set_epilogue_begin
:
3077 case DW_LNS_set_isa
:
3078 uladv
= read_leb128 (data
, & bytes_read
, 0);
3080 printf (_(" Set ISA to %lu\n"), uladv
);
3084 printf (_(" Unknown opcode %d with operands: "), op_code
);
3086 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
3088 printf ("0x%s%s", dwarf_vmatoa ("x", read_leb128 (data
,
3090 i
== 1 ? "" : ", ");
3097 /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row
3098 to the DWARF address/line matrix. */
3099 if ((is_special_opcode
) || (op_code
== DW_LNE_end_sequence
)
3100 || (op_code
== DW_LNS_copy
))
3102 const unsigned int MAX_FILENAME_LENGTH
= 35;
3103 char *fileName
= (char *)file_table
[state_machine_regs
.file
- 1].name
;
3104 char *newFileName
= NULL
;
3105 size_t fileNameLength
= strlen (fileName
);
3107 if ((fileNameLength
> MAX_FILENAME_LENGTH
) && (!do_wide
))
3109 newFileName
= (char *) xmalloc (MAX_FILENAME_LENGTH
+ 1);
3110 /* Truncate file name */
3111 strncpy (newFileName
,
3112 fileName
+ fileNameLength
- MAX_FILENAME_LENGTH
,
3113 MAX_FILENAME_LENGTH
+ 1);
3117 newFileName
= (char *) xmalloc (fileNameLength
+ 1);
3118 strncpy (newFileName
, fileName
, fileNameLength
+ 1);
3121 if (!do_wide
|| (fileNameLength
<= MAX_FILENAME_LENGTH
))
3123 if (linfo
.li_max_ops_per_insn
== 1)
3124 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x\n",
3125 newFileName
, state_machine_regs
.line
,
3126 state_machine_regs
.address
);
3128 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x[%d]\n",
3129 newFileName
, state_machine_regs
.line
,
3130 state_machine_regs
.address
,
3131 state_machine_regs
.op_index
);
3135 if (linfo
.li_max_ops_per_insn
== 1)
3136 printf ("%s %11d %#18" DWARF_VMA_FMT
"x\n",
3137 newFileName
, state_machine_regs
.line
,
3138 state_machine_regs
.address
);
3140 printf ("%s %11d %#18" DWARF_VMA_FMT
"x[%d]\n",
3141 newFileName
, state_machine_regs
.line
,
3142 state_machine_regs
.address
,
3143 state_machine_regs
.op_index
);
3146 if (op_code
== DW_LNE_end_sequence
)
3154 free (directory_table
);
3155 directory_table
= NULL
;
3163 display_debug_lines (struct dwarf_section
*section
, void *file ATTRIBUTE_UNUSED
)
3165 unsigned char *data
= section
->start
;
3166 unsigned char *end
= data
+ section
->size
;
3168 int retValDecoded
= 1;
3170 if (do_debug_lines
== 0)
3171 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
3173 if (do_debug_lines
& FLAG_DEBUG_LINES_RAW
)
3174 retValRaw
= display_debug_lines_raw (section
, data
, end
);
3176 if (do_debug_lines
& FLAG_DEBUG_LINES_DECODED
)
3177 retValDecoded
= display_debug_lines_decoded (section
, data
, end
);
3179 if (!retValRaw
|| !retValDecoded
)
3186 find_debug_info_for_offset (unsigned long offset
)
3190 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
3193 for (i
= 0; i
< num_debug_info_entries
; i
++)
3194 if (debug_information
[i
].cu_offset
== offset
)
3195 return debug_information
+ i
;
3201 display_debug_pubnames (struct dwarf_section
*section
,
3202 void *file ATTRIBUTE_UNUSED
)
3204 DWARF2_Internal_PubNames names
;
3205 unsigned char *start
= section
->start
;
3206 unsigned char *end
= start
+ section
->size
;
3208 /* It does not matter if this load fails,
3209 we test for that later on. */
3210 load_debug_info (file
);
3212 printf (_("Contents of the %s section:\n\n"), section
->name
);
3216 unsigned char *data
;
3217 unsigned long offset
;
3218 int offset_size
, initial_length_size
;
3222 names
.pn_length
= byte_get (data
, 4);
3224 if (names
.pn_length
== 0xffffffff)
3226 names
.pn_length
= byte_get (data
, 8);
3229 initial_length_size
= 12;
3234 initial_length_size
= 4;
3237 names
.pn_version
= byte_get (data
, 2);
3240 names
.pn_offset
= byte_get (data
, offset_size
);
3241 data
+= offset_size
;
3243 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
3244 && num_debug_info_entries
> 0
3245 && find_debug_info_for_offset (names
.pn_offset
) == NULL
)
3246 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
3247 (unsigned long) names
.pn_offset
, section
->name
);
3249 names
.pn_size
= byte_get (data
, offset_size
);
3250 data
+= offset_size
;
3252 start
+= names
.pn_length
+ initial_length_size
;
3254 if (names
.pn_version
!= 2 && names
.pn_version
!= 3)
3256 static int warned
= 0;
3260 warn (_("Only DWARF 2 and 3 pubnames are currently supported\n"));
3267 printf (_(" Length: %ld\n"),
3268 (long) names
.pn_length
);
3269 printf (_(" Version: %d\n"),
3271 printf (_(" Offset into .debug_info section: 0x%lx\n"),
3272 (unsigned long) names
.pn_offset
);
3273 printf (_(" Size of area in .debug_info section: %ld\n"),
3274 (long) names
.pn_size
);
3276 printf (_("\n Offset\tName\n"));
3280 offset
= byte_get (data
, offset_size
);
3284 data
+= offset_size
;
3285 printf (" %-6lx\t%s\n", offset
, data
);
3286 data
+= strlen ((char *) data
) + 1;
3289 while (offset
!= 0);
3297 display_debug_macinfo (struct dwarf_section
*section
,
3298 void *file ATTRIBUTE_UNUSED
)
3300 unsigned char *start
= section
->start
;
3301 unsigned char *end
= start
+ section
->size
;
3302 unsigned char *curr
= start
;
3303 unsigned int bytes_read
;
3304 enum dwarf_macinfo_record_type op
;
3306 printf (_("Contents of the %s section:\n\n"), section
->name
);
3310 unsigned int lineno
;
3313 op
= (enum dwarf_macinfo_record_type
) *curr
;
3318 case DW_MACINFO_start_file
:
3320 unsigned int filenum
;
3322 lineno
= read_leb128 (curr
, & bytes_read
, 0);
3324 filenum
= read_leb128 (curr
, & bytes_read
, 0);
3327 printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"),
3332 case DW_MACINFO_end_file
:
3333 printf (_(" DW_MACINFO_end_file\n"));
3336 case DW_MACINFO_define
:
3337 lineno
= read_leb128 (curr
, & bytes_read
, 0);
3339 string
= (char *) curr
;
3340 curr
+= strlen (string
) + 1;
3341 printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"),
3345 case DW_MACINFO_undef
:
3346 lineno
= read_leb128 (curr
, & bytes_read
, 0);
3348 string
= (char *) curr
;
3349 curr
+= strlen (string
) + 1;
3350 printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"),
3354 case DW_MACINFO_vendor_ext
:
3356 unsigned int constant
;
3358 constant
= read_leb128 (curr
, & bytes_read
, 0);
3360 string
= (char *) curr
;
3361 curr
+= strlen (string
) + 1;
3362 printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"),
3372 /* Given LINE_OFFSET into the .debug_line section, attempt to return
3373 filename and dirname corresponding to file name table entry with index
3374 FILEIDX. Return NULL on failure. */
3376 static unsigned char *
3377 get_line_filename_and_dirname (dwarf_vma line_offset
, dwarf_vma fileidx
,
3378 unsigned char **dir_name
)
3380 struct dwarf_section
*section
= &debug_displays
[line
].section
;
3381 unsigned char *hdrptr
, *dirtable
, *file_name
;
3382 unsigned int offset_size
, initial_length_size
;
3383 unsigned int version
, opcode_base
, bytes_read
;
3384 dwarf_vma length
, diridx
;
3387 if (section
->start
== NULL
3388 || line_offset
>= section
->size
3392 hdrptr
= section
->start
+ line_offset
;
3393 length
= byte_get (hdrptr
, 4);
3395 if (length
== 0xffffffff)
3397 /* This section is 64-bit DWARF 3. */
3398 length
= byte_get (hdrptr
, 8);
3401 initial_length_size
= 12;
3406 initial_length_size
= 4;
3408 if (length
+ initial_length_size
> section
->size
)
3410 version
= byte_get (hdrptr
, 2);
3412 if (version
!= 2 && version
!= 3 && version
!= 4)
3414 hdrptr
+= offset_size
+ 1;/* Skip prologue_length and min_insn_length. */
3416 hdrptr
++; /* Skip max_ops_per_insn. */
3417 hdrptr
+= 3; /* Skip default_is_stmt, line_base, line_range. */
3418 opcode_base
= byte_get (hdrptr
, 1);
3419 if (opcode_base
== 0)
3422 hdrptr
+= opcode_base
- 1;
3424 /* Skip over dirname table. */
3425 while (*hdrptr
!= '\0')
3426 hdrptr
+= strlen ((char *) hdrptr
) + 1;
3427 hdrptr
++; /* Skip the NUL at the end of the table. */
3428 /* Now skip over preceding filename table entries. */
3429 for (; *hdrptr
!= '\0' && fileidx
> 1; fileidx
--)
3431 hdrptr
+= strlen ((char *) hdrptr
) + 1;
3432 read_leb128 (hdrptr
, &bytes_read
, 0);
3433 hdrptr
+= bytes_read
;
3434 read_leb128 (hdrptr
, &bytes_read
, 0);
3435 hdrptr
+= bytes_read
;
3436 read_leb128 (hdrptr
, &bytes_read
, 0);
3437 hdrptr
+= bytes_read
;
3439 if (*hdrptr
== '\0')
3442 hdrptr
+= strlen ((char *) hdrptr
) + 1;
3443 diridx
= read_leb128 (hdrptr
, &bytes_read
, 0);
3446 for (; *dirtable
!= '\0' && diridx
> 1; diridx
--)
3447 dirtable
+= strlen ((char *) dirtable
) + 1;
3448 if (*dirtable
== '\0')
3450 *dir_name
= dirtable
;
3455 display_debug_macro (struct dwarf_section
*section
,
3458 unsigned char *start
= section
->start
;
3459 unsigned char *end
= start
+ section
->size
;
3460 unsigned char *curr
= start
;
3461 unsigned char *extended_op_buf
[256];
3462 unsigned int bytes_read
;
3464 load_debug_section (str
, file
);
3465 load_debug_section (line
, file
);
3467 printf (_("Contents of the %s section:\n\n"), section
->name
);
3471 unsigned int lineno
, version
, flags
;
3472 unsigned int offset_size
= 4;
3474 dwarf_vma line_offset
= 0, sec_offset
= curr
- start
, offset
;
3475 unsigned char **extended_ops
= NULL
;
3477 version
= byte_get (curr
, 2);
3482 error (_("Only GNU extension to DWARF 4 of %s is currently supported.\n"),
3487 flags
= byte_get (curr
++, 1);
3490 printf (_(" Offset: 0x%lx\n"),
3491 (unsigned long) sec_offset
);
3492 printf (_(" Version: %d\n"), version
);
3493 printf (_(" Offset size: %d\n"), offset_size
);
3496 line_offset
= byte_get (curr
, offset_size
);
3497 curr
+= offset_size
;
3498 printf (_(" Offset into .debug_line: 0x%lx\n"),
3499 (unsigned long) line_offset
);
3503 unsigned int i
, count
= byte_get (curr
++, 1), op
;
3505 memset (extended_op_buf
, 0, sizeof (extended_op_buf
));
3506 extended_ops
= extended_op_buf
;
3509 printf (_(" Extension opcode arguments:\n"));
3510 for (i
= 0; i
< count
; i
++)
3512 op
= byte_get (curr
++, 1);
3513 extended_ops
[op
] = curr
;
3514 nargs
= read_leb128 (curr
, &bytes_read
, 0);
3517 printf (_(" DW_MACRO_GNU_%02x has no arguments\n"), op
);
3520 printf (_(" DW_MACRO_GNU_%02x arguments: "), op
);
3521 for (n
= 0; n
< nargs
; n
++)
3523 unsigned int form
= byte_get (curr
++, 1);
3524 printf ("%s%s", get_FORM_name (form
),
3525 n
== nargs
- 1 ? "\n" : ", ");
3535 case DW_FORM_block1
:
3536 case DW_FORM_block2
:
3537 case DW_FORM_block4
:
3539 case DW_FORM_string
:
3541 case DW_FORM_sec_offset
:
3544 error (_("Invalid extension opcode form %s\n"),
3545 get_FORM_name (form
));
3561 error (_(".debug_macro section not zero terminated\n"));
3565 op
= byte_get (curr
++, 1);
3571 case DW_MACRO_GNU_start_file
:
3573 unsigned int filenum
;
3574 unsigned char *file_name
= NULL
, *dir_name
= NULL
;
3576 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3578 filenum
= read_leb128 (curr
, &bytes_read
, 0);
3581 if ((flags
& 2) == 0)
3582 error (_("DW_MACRO_GNU_start_file used, but no .debug_line offset provided.\n"));
3585 = get_line_filename_and_dirname (line_offset
, filenum
,
3587 if (file_name
== NULL
)
3588 printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d\n"),
3591 printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d filename: %s%s%s\n"),
3593 dir_name
!= NULL
? (const char *) dir_name
: "",
3594 dir_name
!= NULL
? "/" : "", file_name
);
3598 case DW_MACRO_GNU_end_file
:
3599 printf (_(" DW_MACRO_GNU_end_file\n"));
3602 case DW_MACRO_GNU_define
:
3603 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3605 string
= (char *) curr
;
3606 curr
+= strlen (string
) + 1;
3607 printf (_(" DW_MACRO_GNU_define - lineno : %d macro : %s\n"),
3611 case DW_MACRO_GNU_undef
:
3612 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3614 string
= (char *) curr
;
3615 curr
+= strlen (string
) + 1;
3616 printf (_(" DW_MACRO_GNU_undef - lineno : %d macro : %s\n"),
3620 case DW_MACRO_GNU_define_indirect
:
3621 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3623 offset
= byte_get (curr
, offset_size
);
3624 curr
+= offset_size
;
3625 string
= fetch_indirect_string (offset
);
3626 printf (_(" DW_MACRO_GNU_define_indirect - lineno : %d macro : %s\n"),
3630 case DW_MACRO_GNU_undef_indirect
:
3631 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3633 offset
= byte_get (curr
, offset_size
);
3634 curr
+= offset_size
;
3635 string
= fetch_indirect_string (offset
);
3636 printf (_(" DW_MACRO_GNU_undef_indirect - lineno : %d macro : %s\n"),
3640 case DW_MACRO_GNU_transparent_include
:
3641 offset
= byte_get (curr
, offset_size
);
3642 curr
+= offset_size
;
3643 printf (_(" DW_MACRO_GNU_transparent_include - offset : 0x%lx\n"),
3644 (unsigned long) offset
);
3647 case DW_MACRO_GNU_define_indirect_alt
:
3648 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3650 offset
= byte_get (curr
, offset_size
);
3651 curr
+= offset_size
;
3652 printf (_(" DW_MACRO_GNU_define_indirect_alt - lineno : %d macro offset : 0x%lx\n"),
3653 lineno
, (unsigned long) offset
);
3656 case DW_MACRO_GNU_undef_indirect_alt
:
3657 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3659 offset
= byte_get (curr
, offset_size
);
3660 curr
+= offset_size
;
3661 printf (_(" DW_MACRO_GNU_undef_indirect_alt - lineno : %d macro offset : 0x%lx\n"),
3662 lineno
, (unsigned long) offset
);
3665 case DW_MACRO_GNU_transparent_include_alt
:
3666 offset
= byte_get (curr
, offset_size
);
3667 curr
+= offset_size
;
3668 printf (_(" DW_MACRO_GNU_transparent_include_alt - offset : 0x%lx\n"),
3669 (unsigned long) offset
);
3673 if (extended_ops
== NULL
|| extended_ops
[op
] == NULL
)
3675 error (_(" Unknown macro opcode %02x seen\n"), op
);
3680 /* Skip over unhandled opcodes. */
3682 unsigned char *desc
= extended_ops
[op
];
3683 nargs
= read_leb128 (desc
, &bytes_read
, 0);
3687 printf (_(" DW_MACRO_GNU_%02x\n"), op
);
3690 printf (_(" DW_MACRO_GNU_%02x -"), op
);
3691 for (n
= 0; n
< nargs
; n
++)
3694 = read_and_display_attr_value (0, byte_get (desc
++, 1),
3695 curr
, 0, 0, offset_size
,
3696 version
, NULL
, 0, NULL
);
3713 display_debug_abbrev (struct dwarf_section
*section
,
3714 void *file ATTRIBUTE_UNUSED
)
3716 abbrev_entry
*entry
;
3717 unsigned char *start
= section
->start
;
3718 unsigned char *end
= start
+ section
->size
;
3720 printf (_("Contents of the %s section:\n\n"), section
->name
);
3724 unsigned char *last
;
3729 start
= process_abbrev_section (start
, end
);
3731 if (first_abbrev
== NULL
)
3734 printf (_(" Number TAG (0x%lx)\n"), (long) (last
- section
->start
));
3736 for (entry
= first_abbrev
; entry
; entry
= entry
->next
)
3740 printf (" %ld %s [%s]\n",
3742 get_TAG_name (entry
->tag
),
3743 entry
->children
? _("has children") : _("no children"));
3745 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
3746 printf (" %-18s %s\n",
3747 get_AT_name (attr
->attribute
),
3748 get_FORM_name (attr
->form
));
3758 /* Display a location list from a normal (ie, non-dwo) .debug_loc section. */
3761 display_loc_list (struct dwarf_section
*section
,
3762 unsigned char **start_ptr
,
3763 int debug_info_entry
,
3764 unsigned long offset
,
3765 unsigned long base_address
,
3768 unsigned char *start
= *start_ptr
;
3769 unsigned char *section_end
= section
->start
+ section
->size
;
3770 unsigned long cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
3771 unsigned int pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
3772 unsigned int offset_size
= debug_information
[debug_info_entry
].offset_size
;
3773 int dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
3777 unsigned short length
;
3778 int need_frame_base
;
3782 if (start
+ 2 * pointer_size
> section_end
)
3784 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3789 /* Note: we use sign extension here in order to be sure that we can detect
3790 the -1 escape value. Sign extension into the top 32 bits of a 32-bit
3791 address will not affect the values that we display since we always show
3792 hex values, and always the bottom 32-bits. */
3793 begin
= byte_get_signed (start
, pointer_size
);
3794 start
+= pointer_size
;
3795 end
= byte_get_signed (start
, pointer_size
);
3796 start
+= pointer_size
;
3798 printf (" %8.8lx ", offset
);
3800 if (begin
== 0 && end
== 0)
3802 printf (_("<End of list>\n"));
3806 /* Check base address specifiers. */
3807 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
3810 print_dwarf_vma (begin
, pointer_size
);
3811 print_dwarf_vma (end
, pointer_size
);
3812 printf (_("(base address)\n"));
3816 if (start
+ 2 > section_end
)
3818 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3823 length
= byte_get (start
, 2);
3826 if (start
+ length
> section_end
)
3828 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3833 print_dwarf_vma (begin
+ base_address
, pointer_size
);
3834 print_dwarf_vma (end
+ base_address
, pointer_size
);
3837 need_frame_base
= decode_location_expression (start
,
3842 cu_offset
, section
);
3845 if (need_frame_base
&& !has_frame_base
)
3846 printf (_(" [without DW_AT_frame_base]"));
3849 fputs (_(" (start == end)"), stdout
);
3850 else if (begin
> end
)
3851 fputs (_(" (start > end)"), stdout
);
3861 /* Display a location list from a .dwo section. It uses address indexes rather
3862 than embedded addresses. This code closely follows display_loc_list, but the
3863 two are sufficiently different that combining things is very ugly. */
3866 display_loc_list_dwo (struct dwarf_section
*section
,
3867 unsigned char **start_ptr
,
3868 int debug_info_entry
,
3869 unsigned long offset
,
3872 unsigned char *start
= *start_ptr
;
3873 unsigned char *section_end
= section
->start
+ section
->size
;
3874 unsigned long cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
3875 unsigned int pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
3876 unsigned int offset_size
= debug_information
[debug_info_entry
].offset_size
;
3877 int dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
3879 unsigned short length
;
3880 int need_frame_base
;
3882 unsigned int bytes_read
;
3886 printf (" %8.8lx ", offset
);
3888 if (start
+ 2 > section_end
)
3890 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3895 entry_type
= byte_get (start
, 1);
3899 case 0: /* A terminating entry. */
3900 idx
= byte_get (start
, 1);
3904 printf (_("<End of list>\n"));
3906 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3909 case 1: /* A base-address entry. */
3910 idx
= read_leb128 (start
, &bytes_read
, 0);
3911 start
+= bytes_read
;
3912 print_dwarf_vma (idx
, pointer_size
);
3913 printf (_("(base address index)\n"));
3915 case 2: /* A normal entry. */
3916 idx
= read_leb128 (start
, &bytes_read
, 0);
3917 start
+= bytes_read
;
3918 print_dwarf_vma (idx
, pointer_size
);
3919 idx
= read_leb128 (start
, &bytes_read
, 0);
3920 start
+= bytes_read
;
3921 print_dwarf_vma (idx
, pointer_size
);
3924 warn (_("Unknown location-list type 0x%x.\n"), entry_type
);
3929 if (start
+ 2 > section_end
)
3931 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3936 length
= byte_get (start
, 2);
3939 if (start
+ length
> section_end
)
3941 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3947 need_frame_base
= decode_location_expression (start
,
3952 cu_offset
, section
);
3955 if (need_frame_base
&& !has_frame_base
)
3956 printf (_(" [without DW_AT_frame_base]"));
3966 /* Sort array of indexes in ascending order of loc_offsets[idx]. */
3968 static dwarf_vma
*loc_offsets
;
3971 loc_offsets_compar (const void *ap
, const void *bp
)
3973 dwarf_vma a
= loc_offsets
[*(const unsigned int *) ap
];
3974 dwarf_vma b
= loc_offsets
[*(const unsigned int *) bp
];
3976 return (a
> b
) - (b
> a
);
3980 display_debug_loc (struct dwarf_section
*section
, void *file
)
3982 unsigned char *start
= section
->start
;
3983 unsigned long bytes
;
3984 unsigned char *section_begin
= start
;
3985 unsigned int num_loc_list
= 0;
3986 unsigned long last_offset
= 0;
3987 unsigned int first
= 0;
3991 int seen_first_offset
= 0;
3992 int locs_sorted
= 1;
3993 unsigned char *next
;
3994 unsigned int *array
= NULL
;
3995 const char *suffix
= strrchr (section
->name
, '.');
3998 if (suffix
&& strcmp (suffix
, ".dwo") == 0)
4001 bytes
= section
->size
;
4005 printf (_("\nThe %s section is empty.\n"), section
->name
);
4009 if (load_debug_info (file
) == 0)
4011 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4016 /* Check the order of location list in .debug_info section. If
4017 offsets of location lists are in the ascending order, we can
4018 use `debug_information' directly. */
4019 for (i
= 0; i
< num_debug_info_entries
; i
++)
4023 num
= debug_information
[i
].num_loc_offsets
;
4024 if (num
> num_loc_list
)
4027 /* Check if we can use `debug_information' directly. */
4028 if (locs_sorted
&& num
!= 0)
4030 if (!seen_first_offset
)
4032 /* This is the first location list. */
4033 last_offset
= debug_information
[i
].loc_offsets
[0];
4035 seen_first_offset
= 1;
4041 for (; j
< num
; j
++)
4044 debug_information
[i
].loc_offsets
[j
])
4049 last_offset
= debug_information
[i
].loc_offsets
[j
];
4054 if (!seen_first_offset
)
4055 error (_("No location lists in .debug_info section!\n"));
4057 /* DWARF sections under Mach-O have non-zero addresses. */
4058 if (debug_information
[first
].num_loc_offsets
> 0
4059 && debug_information
[first
].loc_offsets
[0] != section
->address
)
4060 warn (_("Location lists in %s section start at 0x%s\n"),
4062 dwarf_vmatoa ("x", debug_information
[first
].loc_offsets
[0]));
4065 array
= (unsigned int *) xcmalloc (num_loc_list
, sizeof (unsigned int));
4066 printf (_("Contents of the %s section:\n\n"), section
->name
);
4068 printf (_(" Offset Begin End Expression\n"));
4070 printf (_(" Offset Begin idx End idx Expression\n"));
4072 seen_first_offset
= 0;
4073 for (i
= first
; i
< num_debug_info_entries
; i
++)
4075 unsigned long offset
;
4076 unsigned long base_address
;
4081 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
4083 loc_offsets
= debug_information
[i
].loc_offsets
;
4084 qsort (array
, debug_information
[i
].num_loc_offsets
,
4085 sizeof (*array
), loc_offsets_compar
);
4088 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
4090 j
= locs_sorted
? k
: array
[k
];
4092 && debug_information
[i
].loc_offsets
[locs_sorted
4093 ? k
- 1 : array
[k
- 1]]
4094 == debug_information
[i
].loc_offsets
[j
])
4096 has_frame_base
= debug_information
[i
].have_frame_base
[j
];
4097 /* DWARF sections under Mach-O have non-zero addresses. */
4098 offset
= debug_information
[i
].loc_offsets
[j
] - section
->address
;
4099 next
= section_begin
+ offset
;
4100 base_address
= debug_information
[i
].base_address
;
4102 if (!seen_first_offset
)
4103 seen_first_offset
= 1;
4107 warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"),
4108 (unsigned long) (start
- section_begin
),
4109 (unsigned long) (next
- section_begin
));
4110 else if (start
> next
)
4111 warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"),
4112 (unsigned long) (start
- section_begin
),
4113 (unsigned long) (next
- section_begin
));
4117 if (offset
>= bytes
)
4119 warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"),
4125 display_loc_list_dwo (section
, &start
, i
, offset
, has_frame_base
);
4127 display_loc_list (section
, &start
, i
, offset
, base_address
,
4132 if (start
< section
->start
+ section
->size
)
4133 warn (_("There are %ld unused bytes at the end of section %s\n"),
4134 (long) (section
->start
+ section
->size
- start
), section
->name
);
4141 display_debug_str (struct dwarf_section
*section
,
4142 void *file ATTRIBUTE_UNUSED
)
4144 unsigned char *start
= section
->start
;
4145 unsigned long bytes
= section
->size
;
4146 dwarf_vma addr
= section
->address
;
4150 printf (_("\nThe %s section is empty.\n"), section
->name
);
4154 printf (_("Contents of the %s section:\n\n"), section
->name
);
4162 lbytes
= (bytes
> 16 ? 16 : bytes
);
4164 printf (" 0x%8.8lx ", (unsigned long) addr
);
4166 for (j
= 0; j
< 16; j
++)
4169 printf ("%2.2x", start
[j
]);
4177 for (j
= 0; j
< lbytes
; j
++)
4180 if (k
>= ' ' && k
< 0x80)
4199 display_debug_info (struct dwarf_section
*section
, void *file
)
4201 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 0);
4205 display_debug_types (struct dwarf_section
*section
, void *file
)
4207 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 1);
4211 display_trace_info (struct dwarf_section
*section
, void *file
)
4213 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 0);
4217 display_debug_aranges (struct dwarf_section
*section
,
4218 void *file ATTRIBUTE_UNUSED
)
4220 unsigned char *start
= section
->start
;
4221 unsigned char *end
= start
+ section
->size
;
4223 printf (_("Contents of the %s section:\n\n"), section
->name
);
4225 /* It does not matter if this load fails,
4226 we test for that later on. */
4227 load_debug_info (file
);
4231 unsigned char *hdrptr
;
4232 DWARF2_Internal_ARange arange
;
4233 unsigned char *addr_ranges
;
4236 unsigned char address_size
;
4239 int initial_length_size
;
4243 arange
.ar_length
= byte_get (hdrptr
, 4);
4246 if (arange
.ar_length
== 0xffffffff)
4248 arange
.ar_length
= byte_get (hdrptr
, 8);
4251 initial_length_size
= 12;
4256 initial_length_size
= 4;
4259 arange
.ar_version
= byte_get (hdrptr
, 2);
4262 arange
.ar_info_offset
= byte_get (hdrptr
, offset_size
);
4263 hdrptr
+= offset_size
;
4265 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
4266 && num_debug_info_entries
> 0
4267 && find_debug_info_for_offset (arange
.ar_info_offset
) == NULL
)
4268 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
4269 (unsigned long) arange
.ar_info_offset
, section
->name
);
4271 arange
.ar_pointer_size
= byte_get (hdrptr
, 1);
4274 arange
.ar_segment_size
= byte_get (hdrptr
, 1);
4277 if (arange
.ar_version
!= 2 && arange
.ar_version
!= 3)
4279 warn (_("Only DWARF 2 and 3 aranges are currently supported.\n"));
4283 printf (_(" Length: %ld\n"),
4284 (long) arange
.ar_length
);
4285 printf (_(" Version: %d\n"), arange
.ar_version
);
4286 printf (_(" Offset into .debug_info: 0x%lx\n"),
4287 (unsigned long) arange
.ar_info_offset
);
4288 printf (_(" Pointer Size: %d\n"), arange
.ar_pointer_size
);
4289 printf (_(" Segment Size: %d\n"), arange
.ar_segment_size
);
4291 address_size
= arange
.ar_pointer_size
+ arange
.ar_segment_size
;
4293 if (address_size
== 0)
4295 error (_("Invalid address size in %s section!\n"),
4300 /* The DWARF spec does not require that the address size be a power
4301 of two, but we do. This will have to change if we ever encounter
4302 an uneven architecture. */
4303 if ((address_size
& (address_size
- 1)) != 0)
4305 warn (_("Pointer size + Segment size is not a power of two.\n"));
4309 if (address_size
> 4)
4310 printf (_("\n Address Length\n"));
4312 printf (_("\n Address Length\n"));
4314 addr_ranges
= hdrptr
;
4316 /* Must pad to an alignment boundary that is twice the address size. */
4317 excess
= (hdrptr
- start
) % (2 * address_size
);
4319 addr_ranges
+= (2 * address_size
) - excess
;
4321 start
+= arange
.ar_length
+ initial_length_size
;
4323 while (addr_ranges
+ 2 * address_size
<= start
)
4325 address
= byte_get (addr_ranges
, address_size
);
4327 addr_ranges
+= address_size
;
4329 length
= byte_get (addr_ranges
, address_size
);
4331 addr_ranges
+= address_size
;
4334 print_dwarf_vma (address
, address_size
);
4335 print_dwarf_vma (length
, address_size
);
4345 /* Comparison function for qsort. */
4347 comp_addr_base (const void * v0
, const void * v1
)
4349 debug_info
* info0
= (debug_info
*) v0
;
4350 debug_info
* info1
= (debug_info
*) v1
;
4351 return info0
->addr_base
- info1
->addr_base
;
4354 /* Display the debug_addr section. */
4356 display_debug_addr (struct dwarf_section
*section
,
4359 debug_info
**debug_addr_info
;
4360 unsigned char *entry
;
4365 if (section
->size
== 0)
4367 printf (_("\nThe %s section is empty.\n"), section
->name
);
4371 if (load_debug_info (file
) == 0)
4373 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4378 printf (_("Contents of the %s section:\n\n"), section
->name
);
4380 debug_addr_info
= (debug_info
**) xmalloc (num_debug_info_entries
+ 1
4381 * sizeof (debug_info
*));
4384 for (i
= 0; i
< num_debug_info_entries
; i
++)
4386 if (debug_information
[i
].addr_base
!= DEBUG_INFO_UNAVAILABLE
)
4387 debug_addr_info
[count
++] = &debug_information
[i
];
4390 /* Add a sentinel to make iteration convenient. */
4391 debug_addr_info
[count
] = (debug_info
*) xmalloc (sizeof (debug_info
));
4392 debug_addr_info
[count
]->addr_base
= section
->size
;
4394 qsort (debug_addr_info
, count
, sizeof (debug_info
*), comp_addr_base
);
4395 for (i
= 0; i
< count
; i
++)
4399 printf (_(" For compilation unit at offset 0x%s:\n"),
4400 dwarf_vmatoa ("x", debug_addr_info
[i
]->cu_offset
));
4402 printf (_("\tIndex\tOffset\n"));
4403 entry
= section
->start
+ debug_addr_info
[i
]->addr_base
;
4404 end
= section
->start
+ debug_addr_info
[i
+ 1]->addr_base
;
4408 dwarf_vma base
= byte_get (entry
, debug_addr_info
[i
]->pointer_size
);
4409 printf (_("\t%d:\t%s\n"), idx
, dwarf_vmatoa ("x", base
));
4410 entry
+= debug_addr_info
[i
]->pointer_size
;
4416 free (debug_addr_info
);
4420 /* Display the .debug_str_offsets and .debug_str_offsets.dwo sections. */
4422 display_debug_str_offsets (struct dwarf_section
*section
,
4423 void *file ATTRIBUTE_UNUSED
)
4425 if (section
->size
== 0)
4427 printf (_("\nThe %s section is empty.\n"), section
->name
);
4430 /* TODO: Dump the contents. This is made somewhat difficult by not knowing
4431 what the offset size is for this section. */
4435 /* Each debug_information[x].range_lists[y] gets this representation for
4436 sorting purposes. */
4440 /* The debug_information[x].range_lists[y] value. */
4441 unsigned long ranges_offset
;
4443 /* Original debug_information to find parameters of the data. */
4444 debug_info
*debug_info_p
;
4447 /* Sort struct range_entry in ascending order of its RANGES_OFFSET. */
4450 range_entry_compar (const void *ap
, const void *bp
)
4452 const struct range_entry
*a_re
= (const struct range_entry
*) ap
;
4453 const struct range_entry
*b_re
= (const struct range_entry
*) bp
;
4454 const unsigned long a
= a_re
->ranges_offset
;
4455 const unsigned long b
= b_re
->ranges_offset
;
4457 return (a
> b
) - (b
> a
);
4461 display_debug_ranges (struct dwarf_section
*section
,
4462 void *file ATTRIBUTE_UNUSED
)
4464 unsigned char *start
= section
->start
;
4465 unsigned char *last_start
= start
;
4466 unsigned long bytes
;
4467 unsigned char *section_begin
= start
;
4468 unsigned int num_range_list
, i
;
4469 struct range_entry
*range_entries
, *range_entry_fill
;
4471 bytes
= section
->size
;
4475 printf (_("\nThe %s section is empty.\n"), section
->name
);
4479 if (load_debug_info (file
) == 0)
4481 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4487 for (i
= 0; i
< num_debug_info_entries
; i
++)
4488 num_range_list
+= debug_information
[i
].num_range_lists
;
4490 if (num_range_list
== 0)
4492 /* This can happen when the file was compiled with -gsplit-debug
4493 which removes references to range lists from the primary .o file. */
4494 printf (_("No range lists in .debug_info section.\n"));
4498 range_entries
= (struct range_entry
*)
4499 xmalloc (sizeof (*range_entries
) * num_range_list
);
4500 range_entry_fill
= range_entries
;
4502 for (i
= 0; i
< num_debug_info_entries
; i
++)
4504 debug_info
*debug_info_p
= &debug_information
[i
];
4507 for (j
= 0; j
< debug_info_p
->num_range_lists
; j
++)
4509 range_entry_fill
->ranges_offset
= debug_info_p
->range_lists
[j
];
4510 range_entry_fill
->debug_info_p
= debug_info_p
;
4515 qsort (range_entries
, num_range_list
, sizeof (*range_entries
),
4516 range_entry_compar
);
4518 /* DWARF sections under Mach-O have non-zero addresses. */
4519 if (dwarf_check
!= 0 && range_entries
[0].ranges_offset
!= section
->address
)
4520 warn (_("Range lists in %s section start at 0x%lx\n"),
4521 section
->name
, range_entries
[0].ranges_offset
);
4523 printf (_("Contents of the %s section:\n\n"), section
->name
);
4524 printf (_(" Offset Begin End\n"));
4526 for (i
= 0; i
< num_range_list
; i
++)
4528 struct range_entry
*range_entry
= &range_entries
[i
];
4529 debug_info
*debug_info_p
= range_entry
->debug_info_p
;
4530 unsigned int pointer_size
;
4531 unsigned long offset
;
4532 unsigned char *next
;
4533 unsigned long base_address
;
4535 pointer_size
= debug_info_p
->pointer_size
;
4537 /* DWARF sections under Mach-O have non-zero addresses. */
4538 offset
= range_entry
->ranges_offset
- section
->address
;
4539 next
= section_begin
+ offset
;
4540 base_address
= debug_info_p
->base_address
;
4542 if (dwarf_check
!= 0 && i
> 0)
4545 warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"),
4546 (unsigned long) (start
- section_begin
),
4547 (unsigned long) (next
- section_begin
), section
->name
);
4548 else if (start
> next
)
4550 if (next
== last_start
)
4552 warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"),
4553 (unsigned long) (start
- section_begin
),
4554 (unsigned long) (next
- section_begin
), section
->name
);
4565 /* Note: we use sign extension here in order to be sure that
4566 we can detect the -1 escape value. Sign extension into the
4567 top 32 bits of a 32-bit address will not affect the values
4568 that we display since we always show hex values, and always
4569 the bottom 32-bits. */
4570 begin
= byte_get_signed (start
, pointer_size
);
4571 start
+= pointer_size
;
4572 end
= byte_get_signed (start
, pointer_size
);
4573 start
+= pointer_size
;
4575 printf (" %8.8lx ", offset
);
4577 if (begin
== 0 && end
== 0)
4579 printf (_("<End of list>\n"));
4583 /* Check base address specifiers. */
4584 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
4587 print_dwarf_vma (begin
, pointer_size
);
4588 print_dwarf_vma (end
, pointer_size
);
4589 printf ("(base address)\n");
4593 print_dwarf_vma (begin
+ base_address
, pointer_size
);
4594 print_dwarf_vma (end
+ base_address
, pointer_size
);
4597 fputs (_("(start == end)"), stdout
);
4598 else if (begin
> end
)
4599 fputs (_("(start > end)"), stdout
);
4606 free (range_entries
);
4611 typedef struct Frame_Chunk
4613 struct Frame_Chunk
*next
;
4614 unsigned char *chunk_start
;
4616 /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
4617 short int *col_type
;
4620 unsigned int code_factor
;
4622 unsigned long pc_begin
;
4623 unsigned long pc_range
;
4627 unsigned char fde_encoding
;
4628 unsigned char cfa_exp
;
4629 unsigned char ptr_size
;
4630 unsigned char segment_size
;
4634 static const char *const *dwarf_regnames
;
4635 static unsigned int dwarf_regnames_count
;
4637 /* A marker for a col_type that means this column was never referenced
4638 in the frame info. */
4639 #define DW_CFA_unreferenced (-1)
4641 /* Return 0 if not more space is needed, 1 if more space is needed,
4642 -1 for invalid reg. */
4645 frame_need_space (Frame_Chunk
*fc
, unsigned int reg
)
4647 int prev
= fc
->ncols
;
4649 if (reg
< (unsigned int) fc
->ncols
)
4652 if (dwarf_regnames_count
4653 && reg
> dwarf_regnames_count
)
4656 fc
->ncols
= reg
+ 1;
4657 fc
->col_type
= (short int *) xcrealloc (fc
->col_type
, fc
->ncols
,
4658 sizeof (short int));
4659 fc
->col_offset
= (int *) xcrealloc (fc
->col_offset
, fc
->ncols
, sizeof (int));
4661 while (prev
< fc
->ncols
)
4663 fc
->col_type
[prev
] = DW_CFA_unreferenced
;
4664 fc
->col_offset
[prev
] = 0;
4670 static const char *const dwarf_regnames_i386
[] =
4672 "eax", "ecx", "edx", "ebx",
4673 "esp", "ebp", "esi", "edi",
4674 "eip", "eflags", NULL
,
4675 "st0", "st1", "st2", "st3",
4676 "st4", "st5", "st6", "st7",
4678 "xmm0", "xmm1", "xmm2", "xmm3",
4679 "xmm4", "xmm5", "xmm6", "xmm7",
4680 "mm0", "mm1", "mm2", "mm3",
4681 "mm4", "mm5", "mm6", "mm7",
4682 "fcw", "fsw", "mxcsr",
4683 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
4688 init_dwarf_regnames_i386 (void)
4690 dwarf_regnames
= dwarf_regnames_i386
;
4691 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_i386
);
4694 static const char *const dwarf_regnames_x86_64
[] =
4696 "rax", "rdx", "rcx", "rbx",
4697 "rsi", "rdi", "rbp", "rsp",
4698 "r8", "r9", "r10", "r11",
4699 "r12", "r13", "r14", "r15",
4701 "xmm0", "xmm1", "xmm2", "xmm3",
4702 "xmm4", "xmm5", "xmm6", "xmm7",
4703 "xmm8", "xmm9", "xmm10", "xmm11",
4704 "xmm12", "xmm13", "xmm14", "xmm15",
4705 "st0", "st1", "st2", "st3",
4706 "st4", "st5", "st6", "st7",
4707 "mm0", "mm1", "mm2", "mm3",
4708 "mm4", "mm5", "mm6", "mm7",
4710 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
4711 "fs.base", "gs.base", NULL
, NULL
,
4713 "mxcsr", "fcw", "fsw"
4717 init_dwarf_regnames_x86_64 (void)
4719 dwarf_regnames
= dwarf_regnames_x86_64
;
4720 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_x86_64
);
4724 init_dwarf_regnames (unsigned int e_machine
)
4730 init_dwarf_regnames_i386 ();
4736 init_dwarf_regnames_x86_64 ();
4745 regname (unsigned int regno
, int row
)
4747 static char reg
[64];
4749 && regno
< dwarf_regnames_count
4750 && dwarf_regnames
[regno
] != NULL
)
4753 return dwarf_regnames
[regno
];
4754 snprintf (reg
, sizeof (reg
), "r%d (%s)", regno
,
4755 dwarf_regnames
[regno
]);
4758 snprintf (reg
, sizeof (reg
), "r%d", regno
);
4763 frame_display_row (Frame_Chunk
*fc
, int *need_col_headers
, int *max_regs
)
4768 if (*max_regs
< fc
->ncols
)
4769 *max_regs
= fc
->ncols
;
4771 if (*need_col_headers
)
4773 static const char *sloc
= " LOC";
4775 *need_col_headers
= 0;
4777 printf ("%-*s CFA ", eh_addr_size
* 2, sloc
);
4779 for (r
= 0; r
< *max_regs
; r
++)
4780 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
4785 printf ("%-5s ", regname (r
, 1));
4791 printf ("%0*lx ", eh_addr_size
* 2, fc
->pc_begin
);
4793 strcpy (tmp
, "exp");
4795 sprintf (tmp
, "%s%+d", regname (fc
->cfa_reg
, 1), fc
->cfa_offset
);
4796 printf ("%-8s ", tmp
);
4798 for (r
= 0; r
< fc
->ncols
; r
++)
4800 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
4802 switch (fc
->col_type
[r
])
4804 case DW_CFA_undefined
:
4807 case DW_CFA_same_value
:
4811 sprintf (tmp
, "c%+d", fc
->col_offset
[r
]);
4813 case DW_CFA_val_offset
:
4814 sprintf (tmp
, "v%+d", fc
->col_offset
[r
]);
4816 case DW_CFA_register
:
4817 sprintf (tmp
, "%s", regname (fc
->col_offset
[r
], 0));
4819 case DW_CFA_expression
:
4820 strcpy (tmp
, "exp");
4822 case DW_CFA_val_expression
:
4823 strcpy (tmp
, "vexp");
4826 strcpy (tmp
, "n/a");
4829 printf ("%-5s ", tmp
);
4835 #define GET(N) byte_get (start, N); start += N
4836 #define LEB() read_leb128 (start, & length_return, 0); start += length_return
4837 #define SLEB() read_sleb128 (start, & length_return); start += length_return
4840 display_debug_frames (struct dwarf_section
*section
,
4841 void *file ATTRIBUTE_UNUSED
)
4843 unsigned char *start
= section
->start
;
4844 unsigned char *end
= start
+ section
->size
;
4845 unsigned char *section_start
= start
;
4846 Frame_Chunk
*chunks
= 0;
4847 Frame_Chunk
*remembered_state
= 0;
4849 int is_eh
= strcmp (section
->name
, ".eh_frame") == 0;
4850 unsigned int length_return
;
4852 const char *bad_reg
= _("bad register: ");
4853 int saved_eh_addr_size
= eh_addr_size
;
4855 printf (_("Contents of the %s section:\n"), section
->name
);
4859 unsigned char *saved_start
;
4860 unsigned char *block_end
;
4861 unsigned long length
;
4862 unsigned long cie_id
;
4865 int need_col_headers
= 1;
4866 unsigned char *augmentation_data
= NULL
;
4867 unsigned long augmentation_data_len
= 0;
4868 int encoded_ptr_size
= saved_eh_addr_size
;
4870 int initial_length_size
;
4872 saved_start
= start
;
4873 length
= byte_get (start
, 4); start
+= 4;
4877 printf ("\n%08lx ZERO terminator\n\n",
4878 (unsigned long)(saved_start
- section_start
));
4882 if (length
== 0xffffffff)
4884 length
= byte_get (start
, 8);
4887 initial_length_size
= 12;
4892 initial_length_size
= 4;
4895 block_end
= saved_start
+ length
+ initial_length_size
;
4896 if (block_end
> end
)
4898 warn ("Invalid length %#08lx in FDE at %#08lx\n",
4899 length
, (unsigned long)(saved_start
- section_start
));
4902 cie_id
= byte_get (start
, offset_size
); start
+= offset_size
;
4904 if (is_eh
? (cie_id
== 0) : (cie_id
== DW_CIE_ID
))
4908 fc
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
4909 memset (fc
, 0, sizeof (Frame_Chunk
));
4913 fc
->chunk_start
= saved_start
;
4915 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
4916 fc
->col_offset
= (int *) xmalloc (sizeof (int));
4917 frame_need_space (fc
, max_regs
- 1);
4921 fc
->augmentation
= (char *) start
;
4922 start
= (unsigned char *) strchr ((char *) start
, '\0') + 1;
4924 if (strcmp (fc
->augmentation
, "eh") == 0)
4925 start
+= eh_addr_size
;
4929 fc
->ptr_size
= GET (1);
4930 fc
->segment_size
= GET (1);
4931 eh_addr_size
= fc
->ptr_size
;
4935 fc
->ptr_size
= eh_addr_size
;
4936 fc
->segment_size
= 0;
4938 fc
->code_factor
= LEB ();
4939 fc
->data_factor
= SLEB ();
4949 if (fc
->augmentation
[0] == 'z')
4951 augmentation_data_len
= LEB ();
4952 augmentation_data
= start
;
4953 start
+= augmentation_data_len
;
4957 if (do_debug_frames_interp
)
4958 printf ("\n%08lx %08lx %08lx CIE \"%s\" cf=%d df=%d ra=%d\n",
4959 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
4960 fc
->augmentation
, fc
->code_factor
, fc
->data_factor
,
4964 printf ("\n%08lx %08lx %08lx CIE\n",
4965 (unsigned long)(saved_start
- section_start
), length
, cie_id
);
4966 printf (" Version: %d\n", version
);
4967 printf (" Augmentation: \"%s\"\n", fc
->augmentation
);
4970 printf (" Pointer Size: %u\n", fc
->ptr_size
);
4971 printf (" Segment Size: %u\n", fc
->segment_size
);
4973 printf (" Code alignment factor: %u\n", fc
->code_factor
);
4974 printf (" Data alignment factor: %d\n", fc
->data_factor
);
4975 printf (" Return address column: %d\n", fc
->ra
);
4977 if (augmentation_data_len
)
4980 printf (" Augmentation data: ");
4981 for (i
= 0; i
< augmentation_data_len
; ++i
)
4982 printf (" %02x", augmentation_data
[i
]);
4988 if (augmentation_data_len
)
4990 unsigned char *p
, *q
;
4991 p
= (unsigned char *) fc
->augmentation
+ 1;
4992 q
= augmentation_data
;
4999 q
+= 1 + size_of_encoded_value (*q
);
5001 fc
->fde_encoding
= *q
++;
5009 if (fc
->fde_encoding
)
5010 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
5013 frame_need_space (fc
, fc
->ra
);
5017 unsigned char *look_for
;
5018 static Frame_Chunk fde_fc
;
5019 unsigned long segment_selector
;
5022 memset (fc
, 0, sizeof (Frame_Chunk
));
5024 look_for
= is_eh
? start
- 4 - cie_id
: section_start
+ cie_id
;
5026 for (cie
= chunks
; cie
; cie
= cie
->next
)
5027 if (cie
->chunk_start
== look_for
)
5032 warn ("Invalid CIE pointer %#08lx in FDE at %#08lx\n",
5033 cie_id
, (unsigned long)(saved_start
- section_start
));
5035 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
5036 fc
->col_offset
= (int *) xmalloc (sizeof (int));
5037 frame_need_space (fc
, max_regs
- 1);
5039 fc
->augmentation
= "";
5040 fc
->fde_encoding
= 0;
5041 fc
->ptr_size
= eh_addr_size
;
5042 fc
->segment_size
= 0;
5046 fc
->ncols
= cie
->ncols
;
5047 fc
->col_type
= (short int *) xcmalloc (fc
->ncols
, sizeof (short int));
5048 fc
->col_offset
= (int *) xcmalloc (fc
->ncols
, sizeof (int));
5049 memcpy (fc
->col_type
, cie
->col_type
, fc
->ncols
* sizeof (short int));
5050 memcpy (fc
->col_offset
, cie
->col_offset
, fc
->ncols
* sizeof (int));
5051 fc
->augmentation
= cie
->augmentation
;
5052 fc
->ptr_size
= cie
->ptr_size
;
5053 eh_addr_size
= cie
->ptr_size
;
5054 fc
->segment_size
= cie
->segment_size
;
5055 fc
->code_factor
= cie
->code_factor
;
5056 fc
->data_factor
= cie
->data_factor
;
5057 fc
->cfa_reg
= cie
->cfa_reg
;
5058 fc
->cfa_offset
= cie
->cfa_offset
;
5060 frame_need_space (fc
, max_regs
- 1);
5061 fc
->fde_encoding
= cie
->fde_encoding
;
5064 if (fc
->fde_encoding
)
5065 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
5067 segment_selector
= 0;
5068 if (fc
->segment_size
)
5070 segment_selector
= byte_get (start
, fc
->segment_size
);
5071 start
+= fc
->segment_size
;
5073 fc
->pc_begin
= get_encoded_value (start
, fc
->fde_encoding
, section
);
5074 start
+= encoded_ptr_size
;
5075 fc
->pc_range
= byte_get (start
, encoded_ptr_size
);
5076 start
+= encoded_ptr_size
;
5078 if (cie
->augmentation
[0] == 'z')
5080 augmentation_data_len
= LEB ();
5081 augmentation_data
= start
;
5082 start
+= augmentation_data_len
;
5085 printf ("\n%08lx %08lx %08lx FDE cie=%08lx pc=",
5086 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
5087 (unsigned long)(cie
->chunk_start
- section_start
));
5088 if (fc
->segment_size
)
5089 printf ("%04lx:", segment_selector
);
5090 printf ("%08lx..%08lx\n", fc
->pc_begin
, fc
->pc_begin
+ fc
->pc_range
);
5091 if (! do_debug_frames_interp
&& augmentation_data_len
)
5095 printf (" Augmentation data: ");
5096 for (i
= 0; i
< augmentation_data_len
; ++i
)
5097 printf (" %02x", augmentation_data
[i
]);
5103 /* At this point, fc is the current chunk, cie (if any) is set, and
5104 we're about to interpret instructions for the chunk. */
5105 /* ??? At present we need to do this always, since this sizes the
5106 fc->col_type and fc->col_offset arrays, which we write into always.
5107 We should probably split the interpreted and non-interpreted bits
5108 into two different routines, since there's so much that doesn't
5109 really overlap between them. */
5110 if (1 || do_debug_frames_interp
)
5112 /* Start by making a pass over the chunk, allocating storage
5113 and taking note of what registers are used. */
5114 unsigned char *tmp
= start
;
5116 while (start
< block_end
)
5119 unsigned long reg
, temp
;
5126 /* Warning: if you add any more cases to this switch, be
5127 sure to add them to the corresponding switch below. */
5130 case DW_CFA_advance_loc
:
5134 if (frame_need_space (fc
, opa
) >= 0)
5135 fc
->col_type
[opa
] = DW_CFA_undefined
;
5137 case DW_CFA_restore
:
5138 if (frame_need_space (fc
, opa
) >= 0)
5139 fc
->col_type
[opa
] = DW_CFA_undefined
;
5141 case DW_CFA_set_loc
:
5142 start
+= encoded_ptr_size
;
5144 case DW_CFA_advance_loc1
:
5147 case DW_CFA_advance_loc2
:
5150 case DW_CFA_advance_loc4
:
5153 case DW_CFA_offset_extended
:
5154 case DW_CFA_val_offset
:
5155 reg
= LEB (); LEB ();
5156 if (frame_need_space (fc
, reg
) >= 0)
5157 fc
->col_type
[reg
] = DW_CFA_undefined
;
5159 case DW_CFA_restore_extended
:
5161 frame_need_space (fc
, reg
);
5162 if (frame_need_space (fc
, reg
) >= 0)
5163 fc
->col_type
[reg
] = DW_CFA_undefined
;
5165 case DW_CFA_undefined
:
5167 if (frame_need_space (fc
, reg
) >= 0)
5168 fc
->col_type
[reg
] = DW_CFA_undefined
;
5170 case DW_CFA_same_value
:
5172 if (frame_need_space (fc
, reg
) >= 0)
5173 fc
->col_type
[reg
] = DW_CFA_undefined
;
5175 case DW_CFA_register
:
5176 reg
= LEB (); LEB ();
5177 if (frame_need_space (fc
, reg
) >= 0)
5178 fc
->col_type
[reg
] = DW_CFA_undefined
;
5180 case DW_CFA_def_cfa
:
5183 case DW_CFA_def_cfa_register
:
5186 case DW_CFA_def_cfa_offset
:
5189 case DW_CFA_def_cfa_expression
:
5193 case DW_CFA_expression
:
5194 case DW_CFA_val_expression
:
5198 if (frame_need_space (fc
, reg
) >= 0)
5199 fc
->col_type
[reg
] = DW_CFA_undefined
;
5201 case DW_CFA_offset_extended_sf
:
5202 case DW_CFA_val_offset_sf
:
5203 reg
= LEB (); SLEB ();
5204 if (frame_need_space (fc
, reg
) >= 0)
5205 fc
->col_type
[reg
] = DW_CFA_undefined
;
5207 case DW_CFA_def_cfa_sf
:
5210 case DW_CFA_def_cfa_offset_sf
:
5213 case DW_CFA_MIPS_advance_loc8
:
5216 case DW_CFA_GNU_args_size
:
5219 case DW_CFA_GNU_negative_offset_extended
:
5220 reg
= LEB (); LEB ();
5221 if (frame_need_space (fc
, reg
) >= 0)
5222 fc
->col_type
[reg
] = DW_CFA_undefined
;
5231 /* Now we know what registers are used, make a second pass over
5232 the chunk, this time actually printing out the info. */
5234 while (start
< block_end
)
5237 unsigned long ul
, reg
, roffs
;
5240 const char *reg_prefix
= "";
5247 /* Warning: if you add any more cases to this switch, be
5248 sure to add them to the corresponding switch above. */
5251 case DW_CFA_advance_loc
:
5252 if (do_debug_frames_interp
)
5253 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5255 printf (" DW_CFA_advance_loc: %d to %08lx\n",
5256 opa
* fc
->code_factor
,
5257 fc
->pc_begin
+ opa
* fc
->code_factor
);
5258 fc
->pc_begin
+= opa
* fc
->code_factor
;
5263 if (opa
>= (unsigned int) fc
->ncols
)
5264 reg_prefix
= bad_reg
;
5265 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5266 printf (" DW_CFA_offset: %s%s at cfa%+ld\n",
5267 reg_prefix
, regname (opa
, 0),
5268 roffs
* fc
->data_factor
);
5269 if (*reg_prefix
== '\0')
5271 fc
->col_type
[opa
] = DW_CFA_offset
;
5272 fc
->col_offset
[opa
] = roffs
* fc
->data_factor
;
5276 case DW_CFA_restore
:
5277 if (opa
>= (unsigned int) cie
->ncols
5278 || opa
>= (unsigned int) fc
->ncols
)
5279 reg_prefix
= bad_reg
;
5280 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5281 printf (" DW_CFA_restore: %s%s\n",
5282 reg_prefix
, regname (opa
, 0));
5283 if (*reg_prefix
== '\0')
5285 fc
->col_type
[opa
] = cie
->col_type
[opa
];
5286 fc
->col_offset
[opa
] = cie
->col_offset
[opa
];
5287 if (do_debug_frames_interp
5288 && fc
->col_type
[opa
] == DW_CFA_unreferenced
)
5289 fc
->col_type
[opa
] = DW_CFA_undefined
;
5293 case DW_CFA_set_loc
:
5294 vma
= get_encoded_value (start
, fc
->fde_encoding
, section
);
5295 start
+= encoded_ptr_size
;
5296 if (do_debug_frames_interp
)
5297 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5299 printf (" DW_CFA_set_loc: %08lx\n", (unsigned long)vma
);
5303 case DW_CFA_advance_loc1
:
5304 ofs
= byte_get (start
, 1); start
+= 1;
5305 if (do_debug_frames_interp
)
5306 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5308 printf (" DW_CFA_advance_loc1: %ld to %08lx\n",
5309 ofs
* fc
->code_factor
,
5310 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5311 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5314 case DW_CFA_advance_loc2
:
5315 ofs
= byte_get (start
, 2); start
+= 2;
5316 if (do_debug_frames_interp
)
5317 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5319 printf (" DW_CFA_advance_loc2: %ld to %08lx\n",
5320 ofs
* fc
->code_factor
,
5321 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5322 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5325 case DW_CFA_advance_loc4
:
5326 ofs
= byte_get (start
, 4); start
+= 4;
5327 if (do_debug_frames_interp
)
5328 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5330 printf (" DW_CFA_advance_loc4: %ld to %08lx\n",
5331 ofs
* fc
->code_factor
,
5332 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5333 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5336 case DW_CFA_offset_extended
:
5339 if (reg
>= (unsigned int) fc
->ncols
)
5340 reg_prefix
= bad_reg
;
5341 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5342 printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n",
5343 reg_prefix
, regname (reg
, 0),
5344 roffs
* fc
->data_factor
);
5345 if (*reg_prefix
== '\0')
5347 fc
->col_type
[reg
] = DW_CFA_offset
;
5348 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
5352 case DW_CFA_val_offset
:
5355 if (reg
>= (unsigned int) fc
->ncols
)
5356 reg_prefix
= bad_reg
;
5357 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5358 printf (" DW_CFA_val_offset: %s%s at cfa%+ld\n",
5359 reg_prefix
, regname (reg
, 0),
5360 roffs
* fc
->data_factor
);
5361 if (*reg_prefix
== '\0')
5363 fc
->col_type
[reg
] = DW_CFA_val_offset
;
5364 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
5368 case DW_CFA_restore_extended
:
5370 if (reg
>= (unsigned int) cie
->ncols
5371 || reg
>= (unsigned int) fc
->ncols
)
5372 reg_prefix
= bad_reg
;
5373 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5374 printf (" DW_CFA_restore_extended: %s%s\n",
5375 reg_prefix
, regname (reg
, 0));
5376 if (*reg_prefix
== '\0')
5378 fc
->col_type
[reg
] = cie
->col_type
[reg
];
5379 fc
->col_offset
[reg
] = cie
->col_offset
[reg
];
5383 case DW_CFA_undefined
:
5385 if (reg
>= (unsigned int) fc
->ncols
)
5386 reg_prefix
= bad_reg
;
5387 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5388 printf (" DW_CFA_undefined: %s%s\n",
5389 reg_prefix
, regname (reg
, 0));
5390 if (*reg_prefix
== '\0')
5392 fc
->col_type
[reg
] = DW_CFA_undefined
;
5393 fc
->col_offset
[reg
] = 0;
5397 case DW_CFA_same_value
:
5399 if (reg
>= (unsigned int) fc
->ncols
)
5400 reg_prefix
= bad_reg
;
5401 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5402 printf (" DW_CFA_same_value: %s%s\n",
5403 reg_prefix
, regname (reg
, 0));
5404 if (*reg_prefix
== '\0')
5406 fc
->col_type
[reg
] = DW_CFA_same_value
;
5407 fc
->col_offset
[reg
] = 0;
5411 case DW_CFA_register
:
5414 if (reg
>= (unsigned int) fc
->ncols
)
5415 reg_prefix
= bad_reg
;
5416 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5418 printf (" DW_CFA_register: %s%s in ",
5419 reg_prefix
, regname (reg
, 0));
5420 puts (regname (roffs
, 0));
5422 if (*reg_prefix
== '\0')
5424 fc
->col_type
[reg
] = DW_CFA_register
;
5425 fc
->col_offset
[reg
] = roffs
;
5429 case DW_CFA_remember_state
:
5430 if (! do_debug_frames_interp
)
5431 printf (" DW_CFA_remember_state\n");
5432 rs
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
5433 rs
->ncols
= fc
->ncols
;
5434 rs
->col_type
= (short int *) xcmalloc (rs
->ncols
,
5435 sizeof (short int));
5436 rs
->col_offset
= (int *) xcmalloc (rs
->ncols
, sizeof (int));
5437 memcpy (rs
->col_type
, fc
->col_type
, rs
->ncols
);
5438 memcpy (rs
->col_offset
, fc
->col_offset
, rs
->ncols
* sizeof (int));
5439 rs
->next
= remembered_state
;
5440 remembered_state
= rs
;
5443 case DW_CFA_restore_state
:
5444 if (! do_debug_frames_interp
)
5445 printf (" DW_CFA_restore_state\n");
5446 rs
= remembered_state
;
5449 remembered_state
= rs
->next
;
5450 frame_need_space (fc
, rs
->ncols
- 1);
5451 memcpy (fc
->col_type
, rs
->col_type
, rs
->ncols
);
5452 memcpy (fc
->col_offset
, rs
->col_offset
,
5453 rs
->ncols
* sizeof (int));
5454 free (rs
->col_type
);
5455 free (rs
->col_offset
);
5458 else if (do_debug_frames_interp
)
5459 printf ("Mismatched DW_CFA_restore_state\n");
5462 case DW_CFA_def_cfa
:
5463 fc
->cfa_reg
= LEB ();
5464 fc
->cfa_offset
= LEB ();
5466 if (! do_debug_frames_interp
)
5467 printf (" DW_CFA_def_cfa: %s ofs %d\n",
5468 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
5471 case DW_CFA_def_cfa_register
:
5472 fc
->cfa_reg
= LEB ();
5474 if (! do_debug_frames_interp
)
5475 printf (" DW_CFA_def_cfa_register: %s\n",
5476 regname (fc
->cfa_reg
, 0));
5479 case DW_CFA_def_cfa_offset
:
5480 fc
->cfa_offset
= LEB ();
5481 if (! do_debug_frames_interp
)
5482 printf (" DW_CFA_def_cfa_offset: %d\n", fc
->cfa_offset
);
5486 if (! do_debug_frames_interp
)
5487 printf (" DW_CFA_nop\n");
5490 case DW_CFA_def_cfa_expression
:
5492 if (! do_debug_frames_interp
)
5494 printf (" DW_CFA_def_cfa_expression (");
5495 decode_location_expression (start
, eh_addr_size
, 0, -1,
5503 case DW_CFA_expression
:
5506 if (reg
>= (unsigned int) fc
->ncols
)
5507 reg_prefix
= bad_reg
;
5508 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5510 printf (" DW_CFA_expression: %s%s (",
5511 reg_prefix
, regname (reg
, 0));
5512 decode_location_expression (start
, eh_addr_size
, 0, -1,
5516 if (*reg_prefix
== '\0')
5517 fc
->col_type
[reg
] = DW_CFA_expression
;
5521 case DW_CFA_val_expression
:
5524 if (reg
>= (unsigned int) fc
->ncols
)
5525 reg_prefix
= bad_reg
;
5526 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5528 printf (" DW_CFA_val_expression: %s%s (",
5529 reg_prefix
, regname (reg
, 0));
5530 decode_location_expression (start
, eh_addr_size
, 0, -1,
5534 if (*reg_prefix
== '\0')
5535 fc
->col_type
[reg
] = DW_CFA_val_expression
;
5539 case DW_CFA_offset_extended_sf
:
5542 if (frame_need_space (fc
, reg
) < 0)
5543 reg_prefix
= bad_reg
;
5544 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5545 printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n",
5546 reg_prefix
, regname (reg
, 0),
5547 l
* fc
->data_factor
);
5548 if (*reg_prefix
== '\0')
5550 fc
->col_type
[reg
] = DW_CFA_offset
;
5551 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
5555 case DW_CFA_val_offset_sf
:
5558 if (frame_need_space (fc
, reg
) < 0)
5559 reg_prefix
= bad_reg
;
5560 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5561 printf (" DW_CFA_val_offset_sf: %s%s at cfa%+ld\n",
5562 reg_prefix
, regname (reg
, 0),
5563 l
* fc
->data_factor
);
5564 if (*reg_prefix
== '\0')
5566 fc
->col_type
[reg
] = DW_CFA_val_offset
;
5567 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
5571 case DW_CFA_def_cfa_sf
:
5572 fc
->cfa_reg
= LEB ();
5573 fc
->cfa_offset
= SLEB ();
5574 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
5576 if (! do_debug_frames_interp
)
5577 printf (" DW_CFA_def_cfa_sf: %s ofs %d\n",
5578 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
5581 case DW_CFA_def_cfa_offset_sf
:
5582 fc
->cfa_offset
= SLEB ();
5583 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
5584 if (! do_debug_frames_interp
)
5585 printf (" DW_CFA_def_cfa_offset_sf: %d\n", fc
->cfa_offset
);
5588 case DW_CFA_MIPS_advance_loc8
:
5589 ofs
= byte_get (start
, 8); start
+= 8;
5590 if (do_debug_frames_interp
)
5591 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5593 printf (" DW_CFA_MIPS_advance_loc8: %ld to %08lx\n",
5594 ofs
* fc
->code_factor
,
5595 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5596 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5599 case DW_CFA_GNU_window_save
:
5600 if (! do_debug_frames_interp
)
5601 printf (" DW_CFA_GNU_window_save\n");
5604 case DW_CFA_GNU_args_size
:
5606 if (! do_debug_frames_interp
)
5607 printf (" DW_CFA_GNU_args_size: %ld\n", ul
);
5610 case DW_CFA_GNU_negative_offset_extended
:
5613 if (frame_need_space (fc
, reg
) < 0)
5614 reg_prefix
= bad_reg
;
5615 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5616 printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n",
5617 reg_prefix
, regname (reg
, 0),
5618 l
* fc
->data_factor
);
5619 if (*reg_prefix
== '\0')
5621 fc
->col_type
[reg
] = DW_CFA_offset
;
5622 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
5627 if (op
>= DW_CFA_lo_user
&& op
<= DW_CFA_hi_user
)
5628 printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op
);
5630 warn (_("unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op
);
5635 if (do_debug_frames_interp
)
5636 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5639 eh_addr_size
= saved_eh_addr_size
;
5652 display_gdb_index (struct dwarf_section
*section
,
5653 void *file ATTRIBUTE_UNUSED
)
5655 unsigned char *start
= section
->start
;
5657 uint32_t cu_list_offset
, tu_list_offset
;
5658 uint32_t address_table_offset
, symbol_table_offset
, constant_pool_offset
;
5659 unsigned int cu_list_elements
, tu_list_elements
;
5660 unsigned int address_table_size
, symbol_table_slots
;
5661 unsigned char *cu_list
, *tu_list
;
5662 unsigned char *address_table
, *symbol_table
, *constant_pool
;
5665 /* The documentation for the format of this file is in gdb/dwarf2read.c. */
5667 printf (_("Contents of the %s section:\n"), section
->name
);
5669 if (section
->size
< 6 * sizeof (uint32_t))
5671 warn (_("Truncated header in the %s section.\n"), section
->name
);
5675 version
= byte_get_little_endian (start
, 4);
5676 printf (_("Version %ld\n"), (long) version
);
5678 /* Prior versions are obsolete, and future versions may not be
5679 backwards compatible. */
5680 if (version
< 3 || version
> 7)
5682 warn (_("Unsupported version %lu.\n"), (unsigned long) version
);
5686 warn (_("The address table data in version 3 may be wrong.\n"));
5688 warn (_("Version 4 does not support case insensitive lookups.\n"));
5690 warn (_("Version 5 does not include inlined functions.\n"));
5692 warn (_("Version 6 does not include symbol attributes.\n"));
5694 cu_list_offset
= byte_get_little_endian (start
+ 4, 4);
5695 tu_list_offset
= byte_get_little_endian (start
+ 8, 4);
5696 address_table_offset
= byte_get_little_endian (start
+ 12, 4);
5697 symbol_table_offset
= byte_get_little_endian (start
+ 16, 4);
5698 constant_pool_offset
= byte_get_little_endian (start
+ 20, 4);
5700 if (cu_list_offset
> section
->size
5701 || tu_list_offset
> section
->size
5702 || address_table_offset
> section
->size
5703 || symbol_table_offset
> section
->size
5704 || constant_pool_offset
> section
->size
)
5706 warn (_("Corrupt header in the %s section.\n"), section
->name
);
5710 cu_list_elements
= (tu_list_offset
- cu_list_offset
) / 8;
5711 tu_list_elements
= (address_table_offset
- tu_list_offset
) / 8;
5712 address_table_size
= symbol_table_offset
- address_table_offset
;
5713 symbol_table_slots
= (constant_pool_offset
- symbol_table_offset
) / 8;
5715 cu_list
= start
+ cu_list_offset
;
5716 tu_list
= start
+ tu_list_offset
;
5717 address_table
= start
+ address_table_offset
;
5718 symbol_table
= start
+ symbol_table_offset
;
5719 constant_pool
= start
+ constant_pool_offset
;
5721 printf (_("\nCU table:\n"));
5722 for (i
= 0; i
< cu_list_elements
; i
+= 2)
5724 uint64_t cu_offset
= byte_get_little_endian (cu_list
+ i
* 8, 8);
5725 uint64_t cu_length
= byte_get_little_endian (cu_list
+ i
* 8 + 8, 8);
5727 printf (_("[%3u] 0x%lx - 0x%lx\n"), i
/ 2,
5728 (unsigned long) cu_offset
,
5729 (unsigned long) (cu_offset
+ cu_length
- 1));
5732 printf (_("\nTU table:\n"));
5733 for (i
= 0; i
< tu_list_elements
; i
+= 3)
5735 uint64_t tu_offset
= byte_get_little_endian (tu_list
+ i
* 8, 8);
5736 uint64_t type_offset
= byte_get_little_endian (tu_list
+ i
* 8 + 8, 8);
5737 uint64_t signature
= byte_get_little_endian (tu_list
+ i
* 8 + 16, 8);
5739 printf (_("[%3u] 0x%lx 0x%lx "), i
/ 3,
5740 (unsigned long) tu_offset
,
5741 (unsigned long) type_offset
);
5742 print_dwarf_vma (signature
, 8);
5746 printf (_("\nAddress table:\n"));
5747 for (i
= 0; i
< address_table_size
; i
+= 2 * 8 + 4)
5749 uint64_t low
= byte_get_little_endian (address_table
+ i
, 8);
5750 uint64_t high
= byte_get_little_endian (address_table
+ i
+ 8, 8);
5751 uint32_t cu_index
= byte_get_little_endian (address_table
+ i
+ 16, 4);
5753 print_dwarf_vma (low
, 8);
5754 print_dwarf_vma (high
, 8);
5755 printf (_("%lu\n"), (unsigned long) cu_index
);
5758 printf (_("\nSymbol table:\n"));
5759 for (i
= 0; i
< symbol_table_slots
; ++i
)
5761 uint32_t name_offset
= byte_get_little_endian (symbol_table
+ i
* 8, 4);
5762 uint32_t cu_vector_offset
= byte_get_little_endian (symbol_table
+ i
* 8 + 4, 4);
5763 uint32_t num_cus
, cu
;
5765 if (name_offset
!= 0
5766 || cu_vector_offset
!= 0)
5770 printf ("[%3u] %s:", i
, constant_pool
+ name_offset
);
5771 num_cus
= byte_get_little_endian (constant_pool
+ cu_vector_offset
, 4);
5774 for (j
= 0; j
< num_cus
; ++j
)
5776 gdb_index_symbol_kind kind
;
5778 cu
= byte_get_little_endian (constant_pool
+ cu_vector_offset
+ 4 + j
* 4, 4);
5779 kind
= GDB_INDEX_SYMBOL_KIND_VALUE (cu
);
5780 cu
= GDB_INDEX_CU_VALUE (cu
);
5781 /* Convert to TU number if it's for a type unit. */
5782 if (cu
>= cu_list_elements
/ 2)
5783 printf ("%cT%lu", num_cus
> 1 ? '\t' : ' ',
5784 (unsigned long) (cu
- cu_list_elements
/ 2));
5786 printf ("%c%lu", num_cus
> 1 ? '\t' : ' ', (unsigned long) cu
);
5790 case GDB_INDEX_SYMBOL_KIND_NONE
:
5791 printf (_(" [no symbol information]"));
5793 case GDB_INDEX_SYMBOL_KIND_TYPE
:
5794 printf (_(" [type]"));
5796 case GDB_INDEX_SYMBOL_KIND_VARIABLE
:
5797 printf (_(" [variable]"));
5799 case GDB_INDEX_SYMBOL_KIND_FUNCTION
:
5800 printf (_(" [function]"));
5802 case GDB_INDEX_SYMBOL_KIND_OTHER
:
5803 printf (_(" [other]"));
5806 printf (_(" [unknown: %d]"), kind
);
5821 display_debug_not_supported (struct dwarf_section
*section
,
5822 void *file ATTRIBUTE_UNUSED
)
5824 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
5831 cmalloc (size_t nmemb
, size_t size
)
5833 /* Check for overflow. */
5834 if (nmemb
>= ~(size_t) 0 / size
)
5837 return malloc (nmemb
* size
);
5841 xcmalloc (size_t nmemb
, size_t size
)
5843 /* Check for overflow. */
5844 if (nmemb
>= ~(size_t) 0 / size
)
5847 return xmalloc (nmemb
* size
);
5851 xcrealloc (void *ptr
, size_t nmemb
, size_t size
)
5853 /* Check for overflow. */
5854 if (nmemb
>= ~(size_t) 0 / size
)
5857 return xrealloc (ptr
, nmemb
* size
);
5861 free_debug_memory (void)
5867 for (i
= 0; i
< max
; i
++)
5868 free_debug_section ((enum dwarf_section_display_enum
) i
);
5870 if (debug_information
!= NULL
)
5872 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
)
5874 for (i
= 0; i
< num_debug_info_entries
; i
++)
5876 if (!debug_information
[i
].max_loc_offsets
)
5878 free (debug_information
[i
].loc_offsets
);
5879 free (debug_information
[i
].have_frame_base
);
5881 if (!debug_information
[i
].max_range_lists
)
5882 free (debug_information
[i
].range_lists
);
5886 free (debug_information
);
5887 debug_information
= NULL
;
5888 num_debug_info_entries
= 0;
5893 dwarf_select_sections_by_names (const char *names
)
5897 const char * option
;
5901 debug_dump_long_opts
;
5903 static const debug_dump_long_opts opts_table
[] =
5905 /* Please keep this table alpha- sorted. */
5906 { "Ranges", & do_debug_ranges
, 1 },
5907 { "abbrev", & do_debug_abbrevs
, 1 },
5908 { "aranges", & do_debug_aranges
, 1 },
5909 { "frames", & do_debug_frames
, 1 },
5910 { "frames-interp", & do_debug_frames_interp
, 1 },
5911 { "info", & do_debug_info
, 1 },
5912 { "line", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
}, /* For backwards compatibility. */
5913 { "rawline", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
},
5914 { "decodedline", & do_debug_lines
, FLAG_DEBUG_LINES_DECODED
},
5915 { "loc", & do_debug_loc
, 1 },
5916 { "macro", & do_debug_macinfo
, 1 },
5917 { "pubnames", & do_debug_pubnames
, 1 },
5918 { "pubtypes", & do_debug_pubtypes
, 1 },
5919 /* This entry is for compatability
5920 with earlier versions of readelf. */
5921 { "ranges", & do_debug_aranges
, 1 },
5922 { "str", & do_debug_str
, 1 },
5923 /* The special .gdb_index section. */
5924 { "gdb_index", & do_gdb_index
, 1 },
5925 /* These trace_* sections are used by Itanium VMS. */
5926 { "trace_abbrev", & do_trace_abbrevs
, 1 },
5927 { "trace_aranges", & do_trace_aranges
, 1 },
5928 { "trace_info", & do_trace_info
, 1 },
5937 const debug_dump_long_opts
* entry
;
5939 for (entry
= opts_table
; entry
->option
; entry
++)
5941 size_t len
= strlen (entry
->option
);
5943 if (strncmp (p
, entry
->option
, len
) == 0
5944 && (p
[len
] == ',' || p
[len
] == '\0'))
5946 * entry
->variable
|= entry
->val
;
5948 /* The --debug-dump=frames-interp option also
5949 enables the --debug-dump=frames option. */
5950 if (do_debug_frames_interp
)
5951 do_debug_frames
= 1;
5958 if (entry
->option
== NULL
)
5960 warn (_("Unrecognized debug option '%s'\n"), p
);
5961 p
= strchr (p
, ',');
5972 dwarf_select_sections_by_letters (const char *letters
)
5974 unsigned int lindex
= 0;
5976 while (letters
[lindex
])
5977 switch (letters
[lindex
++])
5984 do_debug_abbrevs
= 1;
5988 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
5992 do_debug_lines
|= FLAG_DEBUG_LINES_DECODED
;
5996 do_debug_pubnames
= 1;
6000 do_debug_pubtypes
= 1;
6004 do_debug_aranges
= 1;
6008 do_debug_ranges
= 1;
6012 do_debug_frames_interp
= 1;
6014 do_debug_frames
= 1;
6018 do_debug_macinfo
= 1;
6030 warn (_("Unrecognized debug option '%s'\n"), optarg
);
6036 dwarf_select_sections_all (void)
6039 do_debug_abbrevs
= 1;
6040 do_debug_lines
= FLAG_DEBUG_LINES_RAW
;
6041 do_debug_pubnames
= 1;
6042 do_debug_pubtypes
= 1;
6043 do_debug_aranges
= 1;
6044 do_debug_ranges
= 1;
6045 do_debug_frames
= 1;
6046 do_debug_macinfo
= 1;
6051 do_trace_abbrevs
= 1;
6052 do_trace_aranges
= 1;
6055 struct dwarf_section_display debug_displays
[] =
6057 { { ".debug_abbrev", ".zdebug_abbrev", NULL
, NULL
, 0, 0, abbrev
},
6058 display_debug_abbrev
, &do_debug_abbrevs
, 0 },
6059 { { ".debug_aranges", ".zdebug_aranges", NULL
, NULL
, 0, 0, abbrev
},
6060 display_debug_aranges
, &do_debug_aranges
, 1 },
6061 { { ".debug_frame", ".zdebug_frame", NULL
, NULL
, 0, 0, abbrev
},
6062 display_debug_frames
, &do_debug_frames
, 1 },
6063 { { ".debug_info", ".zdebug_info", NULL
, NULL
, 0, 0, abbrev
},
6064 display_debug_info
, &do_debug_info
, 1 },
6065 { { ".debug_line", ".zdebug_line", NULL
, NULL
, 0, 0, abbrev
},
6066 display_debug_lines
, &do_debug_lines
, 1 },
6067 { { ".debug_pubnames", ".zdebug_pubnames", NULL
, NULL
, 0, 0, abbrev
},
6068 display_debug_pubnames
, &do_debug_pubnames
, 0 },
6069 { { ".eh_frame", "", NULL
, NULL
, 0, 0, abbrev
},
6070 display_debug_frames
, &do_debug_frames
, 1 },
6071 { { ".debug_macinfo", ".zdebug_macinfo", NULL
, NULL
, 0, 0, abbrev
},
6072 display_debug_macinfo
, &do_debug_macinfo
, 0 },
6073 { { ".debug_macro", ".zdebug_macro", NULL
, NULL
, 0, 0, abbrev
},
6074 display_debug_macro
, &do_debug_macinfo
, 1 },
6075 { { ".debug_str", ".zdebug_str", NULL
, NULL
, 0, 0, abbrev
},
6076 display_debug_str
, &do_debug_str
, 0 },
6077 { { ".debug_loc", ".zdebug_loc", NULL
, NULL
, 0, 0, abbrev
},
6078 display_debug_loc
, &do_debug_loc
, 1 },
6079 { { ".debug_pubtypes", ".zdebug_pubtypes", NULL
, NULL
, 0, 0, abbrev
},
6080 display_debug_pubnames
, &do_debug_pubtypes
, 0 },
6081 { { ".debug_ranges", ".zdebug_ranges", NULL
, NULL
, 0, 0, abbrev
},
6082 display_debug_ranges
, &do_debug_ranges
, 1 },
6083 { { ".debug_static_func", ".zdebug_static_func", NULL
, NULL
, 0, 0, abbrev
},
6084 display_debug_not_supported
, NULL
, 0 },
6085 { { ".debug_static_vars", ".zdebug_static_vars", NULL
, NULL
, 0, 0, abbrev
},
6086 display_debug_not_supported
, NULL
, 0 },
6087 { { ".debug_types", ".zdebug_types", NULL
, NULL
, 0, 0, abbrev
},
6088 display_debug_types
, &do_debug_info
, 1 },
6089 { { ".debug_weaknames", ".zdebug_weaknames", NULL
, NULL
, 0, 0, abbrev
},
6090 display_debug_not_supported
, NULL
, 0 },
6091 { { ".gdb_index", "", NULL
, NULL
, 0, 0, abbrev
},
6092 display_gdb_index
, &do_gdb_index
, 0 },
6093 { { ".trace_info", "", NULL
, NULL
, 0, 0, trace_abbrev
},
6094 display_trace_info
, &do_trace_info
, 1 },
6095 { { ".trace_abbrev", "", NULL
, NULL
, 0, 0, abbrev
},
6096 display_debug_abbrev
, &do_trace_abbrevs
, 0 },
6097 { { ".trace_aranges", "", NULL
, NULL
, 0, 0, abbrev
},
6098 display_debug_aranges
, &do_trace_aranges
, 0 },
6099 { { ".debug_info.dwo", ".zdebug_info.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6100 display_debug_info
, &do_debug_info
, 1 },
6101 { { ".debug_abbrev.dwo", ".zdebug_abbrev.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6102 display_debug_abbrev
, &do_debug_abbrevs
, 0 },
6103 { { ".debug_types.dwo", ".zdebug_types.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6104 display_debug_types
, &do_debug_info
, 1 },
6105 { { ".debug_line.dwo", ".zdebug_line.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6106 display_debug_lines
, &do_debug_lines
, 1 },
6107 { { ".debug_loc.dwo", ".zdebug_loc.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6108 display_debug_loc
, &do_debug_loc
, 1 },
6109 { { ".debug_macro.dwo", ".zdebug_macro.dwo",NULL
, NULL
, 0, 0, abbrev
},
6110 display_debug_macro
, &do_debug_macinfo
, 1 },
6111 { { ".debug_macinfo.dwo", ".zdebug_macinfo.dwo",NULL
, NULL
, 0, 0, abbrev
},
6112 display_debug_macinfo
, &do_debug_macinfo
, 0 },
6113 { { ".debug_str.dwo", ".zdebug_str.dwo", NULL
, NULL
, 0, 0, str_dwo
},
6114 display_debug_str
, &do_debug_str
, 1 },
6115 { { ".debug_str_offsets",".zdebug_str_offsets", NULL
, NULL
, 0, 0, abbrev
},
6116 display_debug_str_offsets
, NULL
, 0 },
6117 { { ".debug_str_offsets.dwo",".zdebug_str_offsets.dwo", NULL
, NULL
, 0, 0,
6119 display_debug_str_offsets
, NULL
, 0 },
6120 { { ".debug_addr",".zdebug_addr", NULL
, NULL
, 0, 0, debug_addr
},
6121 display_debug_addr
, NULL
, 1 },