1 /* dwarf.c -- display DWARF contents of a BFD binary file
2 Copyright 2005-2013 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
22 #include "libiberty.h"
24 #include "bfd_stdint.h"
27 #include "elf/common.h"
30 #include "gdb/gdb-index.h"
32 static const char *regname (unsigned int regno
, int row
);
34 static int have_frame_base
;
35 static int need_base_address
;
37 static unsigned int last_pointer_size
= 0;
38 static int warned_about_missing_comp_units
= FALSE
;
40 static unsigned int num_debug_info_entries
= 0;
41 static debug_info
*debug_information
= NULL
;
42 /* Special value for num_debug_info_entries to indicate
43 that the .debug_info section could not be loaded/parsed. */
44 #define DEBUG_INFO_UNAVAILABLE (unsigned int) -1
51 int do_debug_pubnames
;
52 int do_debug_pubtypes
;
56 int do_debug_frames_interp
;
65 int do_debug_cu_index
;
68 int dwarf_cutoff_level
= -1;
69 unsigned long dwarf_start_die
;
73 /* Collection of CU/TU section sets from .debug_cu_index and .debug_tu_index
74 sections. For version 1 package files, each set is stored in SHNDX_POOL
75 as a zero-terminated list of section indexes comprising one set of debug
76 sections from a .dwo file. */
78 static int cu_tu_indexes_read
= 0;
79 static unsigned int *shndx_pool
= NULL
;
80 static unsigned int shndx_pool_size
= 0;
81 static unsigned int shndx_pool_used
= 0;
83 /* For version 2 package files, each set contains an array of section offsets
84 and an array of section sizes, giving the offset and size of the
85 contribution from a CU or TU within one of the debug sections.
86 When displaying debug info from a package file, we need to use these
87 tables to locate the corresponding contributions to each section. */
92 dwarf_vma section_offsets
[DW_SECT_MAX
];
93 size_t section_sizes
[DW_SECT_MAX
];
96 static int cu_count
= 0;
97 static int tu_count
= 0;
98 static struct cu_tu_set
*cu_sets
= NULL
;
99 static struct cu_tu_set
*tu_sets
= NULL
;
101 static void load_cu_tu_indexes (void *file
);
103 /* Values for do_debug_lines. */
104 #define FLAG_DEBUG_LINES_RAW 1
105 #define FLAG_DEBUG_LINES_DECODED 2
108 size_of_encoded_value (int encoding
)
110 switch (encoding
& 0x7)
113 case 0: return eh_addr_size
;
121 get_encoded_value (unsigned char *data
,
123 struct dwarf_section
*section
)
125 int size
= size_of_encoded_value (encoding
);
128 if (encoding
& DW_EH_PE_signed
)
129 val
= byte_get_signed (data
, size
);
131 val
= byte_get (data
, size
);
133 if ((encoding
& 0x70) == DW_EH_PE_pcrel
)
134 val
+= section
->address
+ (data
- section
->start
);
138 /* Print a dwarf_vma value (typically an address, offset or length) in
139 hexadecimal format, followed by a space. The length of the value (and
140 hence the precision displayed) is determined by the byte_size parameter. */
143 print_dwarf_vma (dwarf_vma val
, unsigned byte_size
)
145 static char buff
[18];
148 /* Printf does not have a way of specifiying a maximum field width for an
149 integer value, so we print the full value into a buffer and then select
150 the precision we need. */
151 #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
153 snprintf (buff
, sizeof (buff
), "%16.16llx ", val
);
155 snprintf (buff
, sizeof (buff
), "%016I64x ", val
);
158 snprintf (buff
, sizeof (buff
), "%16.16lx ", val
);
163 if (byte_size
> 0 && byte_size
<= 8)
164 offset
= 16 - 2 * byte_size
;
166 error (_("Wrong size in print_dwarf_vma"));
169 fputs (buff
+ offset
, stdout
);
172 #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
174 #define DWARF_VMA_FMT "ll"
176 #define DWARF_VMA_FMT "I64"
179 #define DWARF_VMA_FMT "l"
183 dwarf_vmatoa (const char *fmtch
, dwarf_vma value
)
185 /* As dwarf_vmatoa is used more then once in a printf call
186 for output, we are cycling through an fixed array of pointers
187 for return address. */
188 static int buf_pos
= 0;
189 static struct dwarf_vmatoa_buf
196 sprintf (fmt
, "%%%s%s", DWARF_VMA_FMT
, fmtch
);
198 ret
= buf
[buf_pos
++].place
;
199 buf_pos
%= ARRAY_SIZE (buf
);
201 snprintf (ret
, sizeof (buf
[0].place
), fmt
, value
);
206 /* Format a 64-bit value, given as two 32-bit values, in hex.
207 For reentrancy, this uses a buffer provided by the caller. */
210 dwarf_vmatoa64 (dwarf_vma hvalue
, dwarf_vma lvalue
, char *buf
,
211 unsigned int buf_len
)
216 snprintf (buf
, buf_len
, "%" DWARF_VMA_FMT
"x", lvalue
);
219 len
= snprintf (buf
, buf_len
, "%" DWARF_VMA_FMT
"x", hvalue
);
220 snprintf (buf
+ len
, buf_len
- len
,
221 "%08" DWARF_VMA_FMT
"x", lvalue
);
227 /* Read in a LEB128 encoded value starting at address DATA.
228 If SIGN is true, return a signed LEB128 value.
229 If LENGTH_RETURN is not NULL, return in it the number of bytes read.
230 No bytes will be read at address END or beyond. */
233 read_leb128 (unsigned char *data
,
234 unsigned int *length_return
,
236 const unsigned char * const end
)
238 dwarf_vma result
= 0;
239 unsigned int num_read
= 0;
240 unsigned int shift
= 0;
241 unsigned char byte
= 0;
248 result
|= ((dwarf_vma
) (byte
& 0x7f)) << shift
;
251 if ((byte
& 0x80) == 0)
255 if (length_return
!= NULL
)
256 *length_return
= num_read
;
258 if (sign
&& (shift
< 8 * sizeof (result
)) && (byte
& 0x40))
259 result
|= -1L << shift
;
264 /* Create a signed version to avoid painful typecasts. */
265 static inline dwarf_signed_vma
266 read_sleb128 (unsigned char * data
,
267 unsigned int * length_return
,
268 const unsigned char * const end
)
270 return (dwarf_signed_vma
) read_leb128 (data
, length_return
, TRUE
, end
);
273 static inline dwarf_vma
274 read_uleb128 (unsigned char * data
,
275 unsigned int * length_return
,
276 const unsigned char * const end
)
278 return read_leb128 (data
, length_return
, FALSE
, end
);
281 #define SAFE_BYTE_GET(VAL, PTR, AMOUNT, END) \
284 unsigned int amount = (AMOUNT); \
285 if (((PTR) + amount) >= (END)) \
288 amount = (END) - (PTR); \
293 VAL = byte_get ((PTR), amount); \
299 #define SAFE_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \
302 SAFE_BYTE_GET (VAL, PTR, AMOUNT, END); \
307 #define SAFE_SIGNED_BYTE_GET(VAL, PTR, AMOUNT, END) \
310 unsigned int amount = (AMOUNT); \
311 if (((PTR) + amount) >= (END)) \
314 amount = (END) - (PTR); \
319 VAL = byte_get_signed ((PTR), amount); \
325 #define SAFE_SIGNED_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \
328 SAFE_SIGNED_BYTE_GET (VAL, PTR, AMOUNT, END); \
333 #define SAFE_BYTE_GET64(PTR, HIGH, LOW, END) \
336 if (((PTR) + 8) < (END)) \
338 byte_get_64 ((PTR), (HIGH), (LOW)); \
343 * (LOW) = * (HIGH) = 0; \
348 typedef struct State_Machine_Registers
356 unsigned char op_index
;
357 unsigned char end_sequence
;
358 /* This variable hold the number of the last entry seen
359 in the File Table. */
360 unsigned int last_file_entry
;
363 static SMR state_machine_regs
;
366 reset_state_machine (int is_stmt
)
368 state_machine_regs
.address
= 0;
369 state_machine_regs
.op_index
= 0;
370 state_machine_regs
.file
= 1;
371 state_machine_regs
.line
= 1;
372 state_machine_regs
.column
= 0;
373 state_machine_regs
.is_stmt
= is_stmt
;
374 state_machine_regs
.basic_block
= 0;
375 state_machine_regs
.end_sequence
= 0;
376 state_machine_regs
.last_file_entry
= 0;
379 /* Handled an extend line op.
380 Returns the number of bytes read. */
383 process_extended_line_op (unsigned char * data
,
387 unsigned char op_code
;
388 unsigned int bytes_read
;
391 unsigned char *orig_data
= data
;
394 len
= read_uleb128 (data
, & bytes_read
, end
);
397 if (len
== 0 || data
== end
)
399 warn (_("badly formed extended line op encountered!\n"));
406 printf (_(" Extended opcode %d: "), op_code
);
410 case DW_LNE_end_sequence
:
411 printf (_("End of Sequence\n\n"));
412 reset_state_machine (is_stmt
);
415 case DW_LNE_set_address
:
416 SAFE_BYTE_GET (adr
, data
, len
- bytes_read
- 1, end
);
417 printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr
));
418 state_machine_regs
.address
= adr
;
419 state_machine_regs
.op_index
= 0;
422 case DW_LNE_define_file
:
423 printf (_("define new File Table entry\n"));
424 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
425 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
428 data
+= strnlen ((char *) data
, end
- data
) + 1;
429 printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
431 printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
433 printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
435 printf ("%s\n\n", name
);
437 if (((unsigned int) (data
- orig_data
) != len
) || data
== end
)
438 warn (_("DW_LNE_define_file: Bad opcode length\n"));
441 case DW_LNE_set_discriminator
:
442 printf (_("set Discriminator to %s\n"),
443 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
447 case DW_LNE_HP_negate_is_UV_update
:
448 printf ("DW_LNE_HP_negate_is_UV_update\n");
450 case DW_LNE_HP_push_context
:
451 printf ("DW_LNE_HP_push_context\n");
453 case DW_LNE_HP_pop_context
:
454 printf ("DW_LNE_HP_pop_context\n");
456 case DW_LNE_HP_set_file_line_column
:
457 printf ("DW_LNE_HP_set_file_line_column\n");
459 case DW_LNE_HP_set_routine_name
:
460 printf ("DW_LNE_HP_set_routine_name\n");
462 case DW_LNE_HP_set_sequence
:
463 printf ("DW_LNE_HP_set_sequence\n");
465 case DW_LNE_HP_negate_post_semantics
:
466 printf ("DW_LNE_HP_negate_post_semantics\n");
468 case DW_LNE_HP_negate_function_exit
:
469 printf ("DW_LNE_HP_negate_function_exit\n");
471 case DW_LNE_HP_negate_front_end_logical
:
472 printf ("DW_LNE_HP_negate_front_end_logical\n");
474 case DW_LNE_HP_define_proc
:
475 printf ("DW_LNE_HP_define_proc\n");
477 case DW_LNE_HP_source_file_correlation
:
479 unsigned char *edata
= data
+ len
- bytes_read
- 1;
481 printf ("DW_LNE_HP_source_file_correlation\n");
487 opc
= read_uleb128 (data
, & bytes_read
, edata
);
492 case DW_LNE_HP_SFC_formfeed
:
493 printf (" DW_LNE_HP_SFC_formfeed\n");
495 case DW_LNE_HP_SFC_set_listing_line
:
496 printf (" DW_LNE_HP_SFC_set_listing_line (%s)\n",
498 read_uleb128 (data
, & bytes_read
, edata
)));
501 case DW_LNE_HP_SFC_associate
:
502 printf (" DW_LNE_HP_SFC_associate ");
505 read_uleb128 (data
, & bytes_read
, edata
)));
509 read_uleb128 (data
, & bytes_read
, edata
)));
513 read_uleb128 (data
, & bytes_read
, edata
)));
517 printf (_(" UNKNOWN DW_LNE_HP_SFC opcode (%u)\n"), opc
);
527 unsigned int rlen
= len
- bytes_read
- 1;
529 if (op_code
>= DW_LNE_lo_user
530 /* The test against DW_LNW_hi_user is redundant due to
531 the limited range of the unsigned char data type used
533 /*&& op_code <= DW_LNE_hi_user*/)
534 printf (_("user defined: "));
536 printf (_("UNKNOWN: "));
537 printf (_("length %d ["), rlen
);
539 printf (" %02x", *data
++);
548 static const unsigned char *
549 fetch_indirect_string (dwarf_vma offset
)
551 struct dwarf_section
*section
= &debug_displays
[str
].section
;
553 if (section
->start
== NULL
)
554 return (const unsigned char *) _("<no .debug_str section>");
556 /* DWARF sections under Mach-O have non-zero addresses. */
557 offset
-= section
->address
;
558 if (offset
> section
->size
)
560 warn (_("DW_FORM_strp offset too big: %s\n"),
561 dwarf_vmatoa ("x", offset
));
562 return (const unsigned char *) _("<offset is too big>");
565 return (const unsigned char *) section
->start
+ offset
;
569 fetch_indexed_string (dwarf_vma idx
, struct cu_tu_set
*this_set
,
570 dwarf_vma offset_size
, int dwo
)
572 enum dwarf_section_display_enum str_sec_idx
= dwo
? str_dwo
: str
;
573 enum dwarf_section_display_enum idx_sec_idx
= dwo
? str_index_dwo
: str_index
;
574 struct dwarf_section
*index_section
= &debug_displays
[idx_sec_idx
].section
;
575 struct dwarf_section
*str_section
= &debug_displays
[str_sec_idx
].section
;
576 dwarf_vma index_offset
= idx
* offset_size
;
577 dwarf_vma str_offset
;
579 if (index_section
->start
== NULL
)
580 return (dwo
? _("<no .debug_str_offsets.dwo section>")
581 : _("<no .debug_str_offsets section>"));
583 /* DWARF sections under Mach-O have non-zero addresses. */
584 index_offset
-= index_section
->address
;
585 if (this_set
!= NULL
)
586 index_offset
+= this_set
->section_offsets
[DW_SECT_STR_OFFSETS
];
587 if (index_offset
> index_section
->size
)
589 warn (_("DW_FORM_GNU_str_index offset too big: %s\n"),
590 dwarf_vmatoa ("x", index_offset
));
591 return _("<index offset is too big>");
594 if (str_section
->start
== NULL
)
595 return (dwo
? _("<no .debug_str.dwo section>")
596 : _("<no .debug_str section>"));
598 str_offset
= byte_get (index_section
->start
+ index_offset
, offset_size
);
599 str_offset
-= str_section
->address
;
600 if (str_offset
> str_section
->size
)
602 warn (_("DW_FORM_GNU_str_index indirect offset too big: %s\n"),
603 dwarf_vmatoa ("x", str_offset
));
604 return _("<indirect index offset is too big>");
607 return (const char *) str_section
->start
+ str_offset
;
611 fetch_indexed_value (dwarf_vma offset
, dwarf_vma bytes
)
613 struct dwarf_section
*section
= &debug_displays
[debug_addr
].section
;
615 if (section
->start
== NULL
)
616 return (_("<no .debug_addr section>"));
618 if (offset
+ bytes
> section
->size
)
620 warn (_("Offset into section %s too big: %s\n"),
621 section
->name
, dwarf_vmatoa ("x", offset
));
622 return "<offset too big>";
625 return dwarf_vmatoa ("x", byte_get (section
->start
+ offset
, bytes
));
629 /* FIXME: There are better and more efficient ways to handle
630 these structures. For now though, I just want something that
631 is simple to implement. */
632 typedef struct abbrev_attr
634 unsigned long attribute
;
636 struct abbrev_attr
*next
;
640 typedef struct abbrev_entry
645 struct abbrev_attr
*first_attr
;
646 struct abbrev_attr
*last_attr
;
647 struct abbrev_entry
*next
;
651 static abbrev_entry
*first_abbrev
= NULL
;
652 static abbrev_entry
*last_abbrev
= NULL
;
659 for (abbrv
= first_abbrev
; abbrv
;)
661 abbrev_entry
*next_abbrev
= abbrv
->next
;
664 for (attr
= abbrv
->first_attr
; attr
;)
666 abbrev_attr
*next_attr
= attr
->next
;
676 last_abbrev
= first_abbrev
= NULL
;
680 add_abbrev (unsigned long number
, unsigned long tag
, int children
)
684 entry
= (abbrev_entry
*) malloc (sizeof (*entry
));
689 entry
->entry
= number
;
691 entry
->children
= children
;
692 entry
->first_attr
= NULL
;
693 entry
->last_attr
= NULL
;
696 if (first_abbrev
== NULL
)
697 first_abbrev
= entry
;
699 last_abbrev
->next
= entry
;
705 add_abbrev_attr (unsigned long attribute
, unsigned long form
)
709 attr
= (abbrev_attr
*) malloc (sizeof (*attr
));
714 attr
->attribute
= attribute
;
718 if (last_abbrev
->first_attr
== NULL
)
719 last_abbrev
->first_attr
= attr
;
721 last_abbrev
->last_attr
->next
= attr
;
723 last_abbrev
->last_attr
= attr
;
726 /* Processes the (partial) contents of a .debug_abbrev section.
727 Returns NULL if the end of the section was encountered.
728 Returns the address after the last byte read if the end of
729 an abbreviation set was found. */
731 static unsigned char *
732 process_abbrev_section (unsigned char *start
, unsigned char *end
)
734 if (first_abbrev
!= NULL
)
739 unsigned int bytes_read
;
742 unsigned long attribute
;
745 entry
= read_uleb128 (start
, & bytes_read
, end
);
748 /* A single zero is supposed to end the section according
749 to the standard. If there's more, then signal that to
756 tag
= read_uleb128 (start
, & bytes_read
, end
);
763 add_abbrev (entry
, tag
, children
);
769 attribute
= read_uleb128 (start
, & bytes_read
, end
);
774 form
= read_uleb128 (start
, & bytes_read
, end
);
779 add_abbrev_attr (attribute
, form
);
781 while (attribute
!= 0);
784 /* Report the missing single zero which ends the section. */
785 error (_(".debug_abbrev section not zero terminated\n"));
791 get_TAG_name (unsigned long tag
)
793 const char *name
= get_DW_TAG_name ((unsigned int)tag
);
797 static char buffer
[100];
799 snprintf (buffer
, sizeof (buffer
), _("Unknown TAG value: %lx"), tag
);
807 get_FORM_name (unsigned long form
)
812 return "DW_FORM value: 0";
814 name
= get_DW_FORM_name (form
);
817 static char buffer
[100];
819 snprintf (buffer
, sizeof (buffer
), _("Unknown FORM value: %lx"), form
);
826 static unsigned char *
827 display_block (unsigned char *data
,
829 const unsigned char * const end
)
833 printf (_(" %s byte block: "), dwarf_vmatoa ("u", length
));
835 maxlen
= (dwarf_vma
) (end
- data
);
836 length
= length
> maxlen
? maxlen
: length
;
839 printf ("%lx ", (unsigned long) byte_get (data
++, 1));
845 decode_location_expression (unsigned char * data
,
846 unsigned int pointer_size
,
847 unsigned int offset_size
,
851 struct dwarf_section
* section
)
854 unsigned int bytes_read
;
856 dwarf_signed_vma svalue
;
857 unsigned char *end
= data
+ length
;
858 int need_frame_base
= 0;
867 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
868 printf ("DW_OP_addr: %s", dwarf_vmatoa ("x", uvalue
));
871 printf ("DW_OP_deref");
874 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
875 printf ("DW_OP_const1u: %lu", (unsigned long) uvalue
);
878 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 1, end
);
879 printf ("DW_OP_const1s: %ld", (long) svalue
);
882 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
883 printf ("DW_OP_const2u: %lu", (unsigned long) uvalue
);
886 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
887 printf ("DW_OP_const2s: %ld", (long) svalue
);
890 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
891 printf ("DW_OP_const4u: %lu", (unsigned long) uvalue
);
894 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
895 printf ("DW_OP_const4s: %ld", (long) svalue
);
898 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
899 printf ("DW_OP_const8u: %lu ", (unsigned long) uvalue
);
900 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
901 printf ("%lu", (unsigned long) uvalue
);
904 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
905 printf ("DW_OP_const8s: %ld ", (long) svalue
);
906 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
907 printf ("%ld", (long) svalue
);
910 printf ("DW_OP_constu: %s",
911 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
915 printf ("DW_OP_consts: %s",
916 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
920 printf ("DW_OP_dup");
923 printf ("DW_OP_drop");
926 printf ("DW_OP_over");
929 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
930 printf ("DW_OP_pick: %ld", (unsigned long) uvalue
);
933 printf ("DW_OP_swap");
936 printf ("DW_OP_rot");
939 printf ("DW_OP_xderef");
942 printf ("DW_OP_abs");
945 printf ("DW_OP_and");
948 printf ("DW_OP_div");
951 printf ("DW_OP_minus");
954 printf ("DW_OP_mod");
957 printf ("DW_OP_mul");
960 printf ("DW_OP_neg");
963 printf ("DW_OP_not");
969 printf ("DW_OP_plus");
971 case DW_OP_plus_uconst
:
972 printf ("DW_OP_plus_uconst: %s",
973 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
977 printf ("DW_OP_shl");
980 printf ("DW_OP_shr");
983 printf ("DW_OP_shra");
986 printf ("DW_OP_xor");
989 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
990 printf ("DW_OP_bra: %ld", (long) svalue
);
1002 printf ("DW_OP_le");
1005 printf ("DW_OP_lt");
1008 printf ("DW_OP_ne");
1011 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
1012 printf ("DW_OP_skip: %ld", (long) svalue
);
1047 printf ("DW_OP_lit%d", op
- DW_OP_lit0
);
1082 printf ("DW_OP_reg%d (%s)", op
- DW_OP_reg0
,
1083 regname (op
- DW_OP_reg0
, 1));
1118 printf ("DW_OP_breg%d (%s): %s",
1120 regname (op
- DW_OP_breg0
, 1),
1121 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
1126 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1128 printf ("DW_OP_regx: %s (%s)",
1129 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1));
1132 need_frame_base
= 1;
1133 printf ("DW_OP_fbreg: %s",
1134 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
1138 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1140 printf ("DW_OP_bregx: %s (%s) %s",
1141 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1),
1142 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
1146 printf ("DW_OP_piece: %s",
1147 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1150 case DW_OP_deref_size
:
1151 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1152 printf ("DW_OP_deref_size: %ld", (long) uvalue
);
1154 case DW_OP_xderef_size
:
1155 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1156 printf ("DW_OP_xderef_size: %ld", (long) uvalue
);
1159 printf ("DW_OP_nop");
1162 /* DWARF 3 extensions. */
1163 case DW_OP_push_object_address
:
1164 printf ("DW_OP_push_object_address");
1167 /* XXX: Strictly speaking for 64-bit DWARF3 files
1168 this ought to be an 8-byte wide computation. */
1169 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
1170 printf ("DW_OP_call2: <0x%s>",
1171 dwarf_vmatoa ("x", svalue
+ cu_offset
));
1174 /* XXX: Strictly speaking for 64-bit DWARF3 files
1175 this ought to be an 8-byte wide computation. */
1176 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
1177 printf ("DW_OP_call4: <0x%s>",
1178 dwarf_vmatoa ("x", svalue
+ cu_offset
));
1180 case DW_OP_call_ref
:
1181 /* XXX: Strictly speaking for 64-bit DWARF3 files
1182 this ought to be an 8-byte wide computation. */
1183 if (dwarf_version
== -1)
1185 printf (_("(DW_OP_call_ref in frame info)"));
1186 /* No way to tell where the next op is, so just bail. */
1187 return need_frame_base
;
1189 if (dwarf_version
== 2)
1191 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1195 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1197 printf ("DW_OP_call_ref: <0x%s>", dwarf_vmatoa ("x", uvalue
));
1199 case DW_OP_form_tls_address
:
1200 printf ("DW_OP_form_tls_address");
1202 case DW_OP_call_frame_cfa
:
1203 printf ("DW_OP_call_frame_cfa");
1205 case DW_OP_bit_piece
:
1206 printf ("DW_OP_bit_piece: ");
1207 printf (_("size: %s "),
1208 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1210 printf (_("offset: %s "),
1211 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1215 /* DWARF 4 extensions. */
1216 case DW_OP_stack_value
:
1217 printf ("DW_OP_stack_value");
1220 case DW_OP_implicit_value
:
1221 printf ("DW_OP_implicit_value");
1222 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1224 display_block (data
, uvalue
, end
);
1228 /* GNU extensions. */
1229 case DW_OP_GNU_push_tls_address
:
1230 printf (_("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown"));
1232 case DW_OP_GNU_uninit
:
1233 printf ("DW_OP_GNU_uninit");
1234 /* FIXME: Is there data associated with this OP ? */
1236 case DW_OP_GNU_encoded_addr
:
1242 addr
= get_encoded_value (data
, encoding
, section
);
1243 data
+= size_of_encoded_value (encoding
);
1245 printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding
);
1246 print_dwarf_vma (addr
, pointer_size
);
1249 case DW_OP_GNU_implicit_pointer
:
1250 /* XXX: Strictly speaking for 64-bit DWARF3 files
1251 this ought to be an 8-byte wide computation. */
1252 if (dwarf_version
== -1)
1254 printf (_("(DW_OP_GNU_implicit_pointer in frame info)"));
1255 /* No way to tell where the next op is, so just bail. */
1256 return need_frame_base
;
1258 if (dwarf_version
== 2)
1260 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1264 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1266 printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s",
1267 dwarf_vmatoa ("x", uvalue
),
1268 dwarf_vmatoa ("d", read_sleb128 (data
,
1269 &bytes_read
, end
)));
1272 case DW_OP_GNU_entry_value
:
1273 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1275 printf ("DW_OP_GNU_entry_value: (");
1276 if (decode_location_expression (data
, pointer_size
, offset_size
,
1277 dwarf_version
, uvalue
,
1278 cu_offset
, section
))
1279 need_frame_base
= 1;
1283 case DW_OP_GNU_const_type
:
1284 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1286 printf ("DW_OP_GNU_const_type: <0x%s> ",
1287 dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1288 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1289 display_block (data
, uvalue
, end
);
1292 case DW_OP_GNU_regval_type
:
1293 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1295 printf ("DW_OP_GNU_regval_type: %s (%s)",
1296 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1));
1297 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1299 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1301 case DW_OP_GNU_deref_type
:
1302 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1303 printf ("DW_OP_GNU_deref_type: %ld", (long) uvalue
);
1304 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1306 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1308 case DW_OP_GNU_convert
:
1309 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1311 printf ("DW_OP_GNU_convert <0x%s>",
1312 dwarf_vmatoa ("x", uvalue
? cu_offset
+ uvalue
: 0));
1314 case DW_OP_GNU_reinterpret
:
1315 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1317 printf ("DW_OP_GNU_reinterpret <0x%s>",
1318 dwarf_vmatoa ("x", uvalue
? cu_offset
+ uvalue
: 0));
1320 case DW_OP_GNU_parameter_ref
:
1321 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
1322 printf ("DW_OP_GNU_parameter_ref: <0x%s>",
1323 dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1325 case DW_OP_GNU_addr_index
:
1326 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1328 printf ("DW_OP_GNU_addr_index <0x%s>", dwarf_vmatoa ("x", uvalue
));
1330 case DW_OP_GNU_const_index
:
1331 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1333 printf ("DW_OP_GNU_const_index <0x%s>", dwarf_vmatoa ("x", uvalue
));
1336 /* HP extensions. */
1337 case DW_OP_HP_is_value
:
1338 printf ("DW_OP_HP_is_value");
1339 /* FIXME: Is there data associated with this OP ? */
1341 case DW_OP_HP_fltconst4
:
1342 printf ("DW_OP_HP_fltconst4");
1343 /* FIXME: Is there data associated with this OP ? */
1345 case DW_OP_HP_fltconst8
:
1346 printf ("DW_OP_HP_fltconst8");
1347 /* FIXME: Is there data associated with this OP ? */
1349 case DW_OP_HP_mod_range
:
1350 printf ("DW_OP_HP_mod_range");
1351 /* FIXME: Is there data associated with this OP ? */
1353 case DW_OP_HP_unmod_range
:
1354 printf ("DW_OP_HP_unmod_range");
1355 /* FIXME: Is there data associated with this OP ? */
1358 printf ("DW_OP_HP_tls");
1359 /* FIXME: Is there data associated with this OP ? */
1362 /* PGI (STMicroelectronics) extensions. */
1363 case DW_OP_PGI_omp_thread_num
:
1364 /* Pushes the thread number for the current thread as it would be
1365 returned by the standard OpenMP library function:
1366 omp_get_thread_num(). The "current thread" is the thread for
1367 which the expression is being evaluated. */
1368 printf ("DW_OP_PGI_omp_thread_num");
1372 if (op
>= DW_OP_lo_user
1373 && op
<= DW_OP_hi_user
)
1374 printf (_("(User defined location op)"));
1376 printf (_("(Unknown location op)"));
1377 /* No way to tell where the next op is, so just bail. */
1378 return need_frame_base
;
1381 /* Separate the ops. */
1386 return need_frame_base
;
1389 /* Find the CU or TU set corresponding to the given CU_OFFSET.
1390 This is used for DWARF package files. */
1392 static struct cu_tu_set
*
1393 find_cu_tu_set_v2 (dwarf_vma cu_offset
, int do_types
)
1395 struct cu_tu_set
*p
;
1397 unsigned int dw_sect
;
1403 dw_sect
= DW_SECT_TYPES
;
1409 dw_sect
= DW_SECT_INFO
;
1413 if (p
->section_offsets
[dw_sect
] == cu_offset
)
1421 static unsigned char *
1422 read_and_display_attr_value (unsigned long attribute
,
1424 unsigned char * data
,
1425 unsigned char * end
,
1426 dwarf_vma cu_offset
,
1427 dwarf_vma pointer_size
,
1428 dwarf_vma offset_size
,
1430 debug_info
* debug_info_p
,
1432 struct dwarf_section
* section
,
1433 struct cu_tu_set
* this_set
)
1435 dwarf_vma uvalue
= 0;
1436 unsigned char *block_start
= NULL
;
1437 unsigned char * orig_data
= data
;
1438 unsigned int bytes_read
;
1442 warn (_("corrupt attribute\n"));
1451 case DW_FORM_ref_addr
:
1452 if (dwarf_version
== 2)
1453 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1454 else if (dwarf_version
== 3 || dwarf_version
== 4)
1455 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1457 error (_("Internal error: DWARF version is not 2, 3 or 4.\n"));
1462 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1466 case DW_FORM_sec_offset
:
1467 case DW_FORM_GNU_ref_alt
:
1468 case DW_FORM_GNU_strp_alt
:
1469 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1472 case DW_FORM_flag_present
:
1479 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1484 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 2, end
);
1489 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
1493 uvalue
= read_sleb128 (data
, & bytes_read
, end
);
1497 case DW_FORM_GNU_str_index
:
1498 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
1502 case DW_FORM_ref_udata
:
1504 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
1508 case DW_FORM_indirect
:
1509 form
= read_uleb128 (data
, & bytes_read
, end
);
1512 printf (" %s", get_FORM_name (form
));
1513 return read_and_display_attr_value (attribute
, form
, data
, end
,
1514 cu_offset
, pointer_size
,
1515 offset_size
, dwarf_version
,
1516 debug_info_p
, do_loc
,
1518 case DW_FORM_GNU_addr_index
:
1519 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
1526 case DW_FORM_ref_addr
:
1528 printf (" <0x%s>", dwarf_vmatoa ("x",uvalue
));
1531 case DW_FORM_GNU_ref_alt
:
1533 printf (" <alt 0x%s>", dwarf_vmatoa ("x",uvalue
));
1539 case DW_FORM_ref_udata
:
1541 printf (" <0x%s>", dwarf_vmatoa ("x", uvalue
+ cu_offset
));
1546 case DW_FORM_sec_offset
:
1548 printf (" 0x%s", dwarf_vmatoa ("x", uvalue
));
1551 case DW_FORM_flag_present
:
1558 printf (" %s", dwarf_vmatoa ("d", uvalue
));
1565 dwarf_vma high_bits
;
1568 SAFE_BYTE_GET64 (data
, &high_bits
, &uvalue
, end
);
1571 dwarf_vmatoa64 (high_bits
, uvalue
, buf
, sizeof (buf
)));
1574 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1575 && num_debug_info_entries
== 0)
1577 if (sizeof (uvalue
) == 8)
1578 SAFE_BYTE_GET (uvalue
, data
, 8, end
);
1580 error (_("DW_FORM_data8 is unsupported when sizeof (dwarf_vma) != 8\n"));
1586 case DW_FORM_string
:
1588 printf (" %.*s", (int) (end
- data
), data
);
1589 data
+= strnlen ((char *) data
, end
- data
) + 1;
1593 case DW_FORM_exprloc
:
1594 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
1595 block_start
= data
+ bytes_read
;
1597 data
= block_start
+ uvalue
;
1599 data
= display_block (block_start
, uvalue
, end
);
1602 case DW_FORM_block1
:
1603 SAFE_BYTE_GET (uvalue
, data
, 1, end
);
1604 block_start
= data
+ 1;
1606 data
= block_start
+ uvalue
;
1608 data
= display_block (block_start
, uvalue
, end
);
1611 case DW_FORM_block2
:
1612 SAFE_BYTE_GET (uvalue
, data
, 2, end
);
1613 block_start
= data
+ 2;
1615 data
= block_start
+ uvalue
;
1617 data
= display_block (block_start
, uvalue
, end
);
1620 case DW_FORM_block4
:
1621 SAFE_BYTE_GET (uvalue
, data
, 4, end
);
1622 block_start
= data
+ 4;
1624 data
= block_start
+ uvalue
;
1626 data
= display_block (block_start
, uvalue
, end
);
1631 printf (_(" (indirect string, offset: 0x%s): %s"),
1632 dwarf_vmatoa ("x", uvalue
),
1633 fetch_indirect_string (uvalue
));
1636 case DW_FORM_GNU_str_index
:
1639 const char *suffix
= strrchr (section
->name
, '.');
1640 int dwo
= (suffix
&& strcmp (suffix
, ".dwo") == 0) ? 1 : 0;
1642 printf (_(" (indexed string: 0x%s): %s"),
1643 dwarf_vmatoa ("x", uvalue
),
1644 fetch_indexed_string (uvalue
, this_set
, offset_size
, dwo
));
1648 case DW_FORM_GNU_strp_alt
:
1650 printf (_(" (alt indirect string, offset: 0x%s)"),
1651 dwarf_vmatoa ("x", uvalue
));
1654 case DW_FORM_indirect
:
1655 /* Handled above. */
1658 case DW_FORM_ref_sig8
:
1661 dwarf_vma high_bits
;
1664 SAFE_BYTE_GET64 (data
, &high_bits
, &uvalue
, end
);
1665 printf (" signature: 0x%s",
1666 dwarf_vmatoa64 (high_bits
, uvalue
, buf
, sizeof (buf
)));
1671 case DW_FORM_GNU_addr_index
:
1673 printf (_(" (addr_index: 0x%s): %s"),
1674 dwarf_vmatoa ("x", uvalue
),
1675 fetch_indexed_value (uvalue
* pointer_size
, pointer_size
));
1679 warn (_("Unrecognized form: %lu\n"), form
);
1683 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1684 && num_debug_info_entries
== 0
1685 && debug_info_p
!= NULL
)
1689 case DW_AT_frame_base
:
1690 have_frame_base
= 1;
1691 case DW_AT_location
:
1692 case DW_AT_string_length
:
1693 case DW_AT_return_addr
:
1694 case DW_AT_data_member_location
:
1695 case DW_AT_vtable_elem_location
:
1697 case DW_AT_static_link
:
1698 case DW_AT_use_location
:
1699 case DW_AT_GNU_call_site_value
:
1700 case DW_AT_GNU_call_site_data_value
:
1701 case DW_AT_GNU_call_site_target
:
1702 case DW_AT_GNU_call_site_target_clobbered
:
1703 if ((dwarf_version
< 4
1704 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
1705 || form
== DW_FORM_sec_offset
)
1707 /* Process location list. */
1708 unsigned int lmax
= debug_info_p
->max_loc_offsets
;
1709 unsigned int num
= debug_info_p
->num_loc_offsets
;
1711 if (lmax
== 0 || num
>= lmax
)
1714 debug_info_p
->loc_offsets
= (dwarf_vma
*)
1715 xcrealloc (debug_info_p
->loc_offsets
,
1716 lmax
, sizeof (*debug_info_p
->loc_offsets
));
1717 debug_info_p
->have_frame_base
= (int *)
1718 xcrealloc (debug_info_p
->have_frame_base
,
1719 lmax
, sizeof (*debug_info_p
->have_frame_base
));
1720 debug_info_p
->max_loc_offsets
= lmax
;
1722 if (this_set
!= NULL
)
1723 uvalue
+= this_set
->section_offsets
[DW_SECT_LOC
];
1724 debug_info_p
->loc_offsets
[num
] = uvalue
;
1725 debug_info_p
->have_frame_base
[num
] = have_frame_base
;
1726 debug_info_p
->num_loc_offsets
++;
1731 if (need_base_address
)
1732 debug_info_p
->base_address
= uvalue
;
1735 case DW_AT_GNU_addr_base
:
1736 debug_info_p
->addr_base
= uvalue
;
1739 case DW_AT_GNU_ranges_base
:
1740 debug_info_p
->ranges_base
= uvalue
;
1744 if ((dwarf_version
< 4
1745 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
1746 || form
== DW_FORM_sec_offset
)
1748 /* Process range list. */
1749 unsigned int lmax
= debug_info_p
->max_range_lists
;
1750 unsigned int num
= debug_info_p
->num_range_lists
;
1752 if (lmax
== 0 || num
>= lmax
)
1755 debug_info_p
->range_lists
= (dwarf_vma
*)
1756 xcrealloc (debug_info_p
->range_lists
,
1757 lmax
, sizeof (*debug_info_p
->range_lists
));
1758 debug_info_p
->max_range_lists
= lmax
;
1760 debug_info_p
->range_lists
[num
] = uvalue
;
1761 debug_info_p
->num_range_lists
++;
1770 if (do_loc
|| attribute
== 0)
1773 /* For some attributes we can display further information. */
1781 case DW_INL_not_inlined
:
1782 printf (_("(not inlined)"));
1784 case DW_INL_inlined
:
1785 printf (_("(inlined)"));
1787 case DW_INL_declared_not_inlined
:
1788 printf (_("(declared as inline but ignored)"));
1790 case DW_INL_declared_inlined
:
1791 printf (_("(declared as inline and inlined)"));
1794 printf (_(" (Unknown inline attribute value: %s)"),
1795 dwarf_vmatoa ("x", uvalue
));
1800 case DW_AT_language
:
1803 /* Ordered by the numeric value of these constants. */
1804 case DW_LANG_C89
: printf ("(ANSI C)"); break;
1805 case DW_LANG_C
: printf ("(non-ANSI C)"); break;
1806 case DW_LANG_Ada83
: printf ("(Ada)"); break;
1807 case DW_LANG_C_plus_plus
: printf ("(C++)"); break;
1808 case DW_LANG_Cobol74
: printf ("(Cobol 74)"); break;
1809 case DW_LANG_Cobol85
: printf ("(Cobol 85)"); break;
1810 case DW_LANG_Fortran77
: printf ("(FORTRAN 77)"); break;
1811 case DW_LANG_Fortran90
: printf ("(Fortran 90)"); break;
1812 case DW_LANG_Pascal83
: printf ("(ANSI Pascal)"); break;
1813 case DW_LANG_Modula2
: printf ("(Modula 2)"); break;
1814 /* DWARF 2.1 values. */
1815 case DW_LANG_Java
: printf ("(Java)"); break;
1816 case DW_LANG_C99
: printf ("(ANSI C99)"); break;
1817 case DW_LANG_Ada95
: printf ("(ADA 95)"); break;
1818 case DW_LANG_Fortran95
: printf ("(Fortran 95)"); break;
1819 /* DWARF 3 values. */
1820 case DW_LANG_PLI
: printf ("(PLI)"); break;
1821 case DW_LANG_ObjC
: printf ("(Objective C)"); break;
1822 case DW_LANG_ObjC_plus_plus
: printf ("(Objective C++)"); break;
1823 case DW_LANG_UPC
: printf ("(Unified Parallel C)"); break;
1824 case DW_LANG_D
: printf ("(D)"); break;
1825 /* DWARF 4 values. */
1826 case DW_LANG_Python
: printf ("(Python)"); break;
1827 /* DWARF 5 values. */
1828 case DW_LANG_Go
: printf ("(Go)"); break;
1829 /* MIPS extension. */
1830 case DW_LANG_Mips_Assembler
: printf ("(MIPS assembler)"); break;
1831 /* UPC extension. */
1832 case DW_LANG_Upc
: printf ("(Unified Parallel C)"); break;
1834 if (uvalue
>= DW_LANG_lo_user
&& uvalue
<= DW_LANG_hi_user
)
1835 printf (_("(implementation defined: %s)"),
1836 dwarf_vmatoa ("x", uvalue
));
1838 printf (_("(Unknown: %s)"), dwarf_vmatoa ("x", uvalue
));
1843 case DW_AT_encoding
:
1846 case DW_ATE_void
: printf ("(void)"); break;
1847 case DW_ATE_address
: printf ("(machine address)"); break;
1848 case DW_ATE_boolean
: printf ("(boolean)"); break;
1849 case DW_ATE_complex_float
: printf ("(complex float)"); break;
1850 case DW_ATE_float
: printf ("(float)"); break;
1851 case DW_ATE_signed
: printf ("(signed)"); break;
1852 case DW_ATE_signed_char
: printf ("(signed char)"); break;
1853 case DW_ATE_unsigned
: printf ("(unsigned)"); break;
1854 case DW_ATE_unsigned_char
: printf ("(unsigned char)"); break;
1855 /* DWARF 2.1 values: */
1856 case DW_ATE_imaginary_float
: printf ("(imaginary float)"); break;
1857 case DW_ATE_decimal_float
: printf ("(decimal float)"); break;
1858 /* DWARF 3 values: */
1859 case DW_ATE_packed_decimal
: printf ("(packed_decimal)"); break;
1860 case DW_ATE_numeric_string
: printf ("(numeric_string)"); break;
1861 case DW_ATE_edited
: printf ("(edited)"); break;
1862 case DW_ATE_signed_fixed
: printf ("(signed_fixed)"); break;
1863 case DW_ATE_unsigned_fixed
: printf ("(unsigned_fixed)"); break;
1864 /* HP extensions: */
1865 case DW_ATE_HP_float80
: printf ("(HP_float80)"); break;
1866 case DW_ATE_HP_complex_float80
: printf ("(HP_complex_float80)"); break;
1867 case DW_ATE_HP_float128
: printf ("(HP_float128)"); break;
1868 case DW_ATE_HP_complex_float128
:printf ("(HP_complex_float128)"); break;
1869 case DW_ATE_HP_floathpintel
: printf ("(HP_floathpintel)"); break;
1870 case DW_ATE_HP_imaginary_float80
: printf ("(HP_imaginary_float80)"); break;
1871 case DW_ATE_HP_imaginary_float128
: printf ("(HP_imaginary_float128)"); break;
1874 if (uvalue
>= DW_ATE_lo_user
1875 && uvalue
<= DW_ATE_hi_user
)
1876 printf (_("(user defined type)"));
1878 printf (_("(unknown type)"));
1883 case DW_AT_accessibility
:
1886 case DW_ACCESS_public
: printf ("(public)"); break;
1887 case DW_ACCESS_protected
: printf ("(protected)"); break;
1888 case DW_ACCESS_private
: printf ("(private)"); break;
1890 printf (_("(unknown accessibility)"));
1895 case DW_AT_visibility
:
1898 case DW_VIS_local
: printf ("(local)"); break;
1899 case DW_VIS_exported
: printf ("(exported)"); break;
1900 case DW_VIS_qualified
: printf ("(qualified)"); break;
1901 default: printf (_("(unknown visibility)")); break;
1905 case DW_AT_virtuality
:
1908 case DW_VIRTUALITY_none
: printf ("(none)"); break;
1909 case DW_VIRTUALITY_virtual
: printf ("(virtual)"); break;
1910 case DW_VIRTUALITY_pure_virtual
:printf ("(pure_virtual)"); break;
1911 default: printf (_("(unknown virtuality)")); break;
1915 case DW_AT_identifier_case
:
1918 case DW_ID_case_sensitive
: printf ("(case_sensitive)"); break;
1919 case DW_ID_up_case
: printf ("(up_case)"); break;
1920 case DW_ID_down_case
: printf ("(down_case)"); break;
1921 case DW_ID_case_insensitive
: printf ("(case_insensitive)"); break;
1922 default: printf (_("(unknown case)")); break;
1926 case DW_AT_calling_convention
:
1929 case DW_CC_normal
: printf ("(normal)"); break;
1930 case DW_CC_program
: printf ("(program)"); break;
1931 case DW_CC_nocall
: printf ("(nocall)"); break;
1933 if (uvalue
>= DW_CC_lo_user
1934 && uvalue
<= DW_CC_hi_user
)
1935 printf (_("(user defined)"));
1937 printf (_("(unknown convention)"));
1941 case DW_AT_ordering
:
1944 case -1: printf (_("(undefined)")); break;
1945 case 0: printf ("(row major)"); break;
1946 case 1: printf ("(column major)"); break;
1950 case DW_AT_frame_base
:
1951 have_frame_base
= 1;
1952 case DW_AT_location
:
1953 case DW_AT_string_length
:
1954 case DW_AT_return_addr
:
1955 case DW_AT_data_member_location
:
1956 case DW_AT_vtable_elem_location
:
1958 case DW_AT_static_link
:
1959 case DW_AT_use_location
:
1960 case DW_AT_GNU_call_site_value
:
1961 case DW_AT_GNU_call_site_data_value
:
1962 case DW_AT_GNU_call_site_target
:
1963 case DW_AT_GNU_call_site_target_clobbered
:
1964 if ((dwarf_version
< 4
1965 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
1966 || form
== DW_FORM_sec_offset
)
1967 printf (_("(location list)"));
1969 case DW_AT_allocated
:
1970 case DW_AT_associated
:
1971 case DW_AT_data_location
:
1973 case DW_AT_upper_bound
:
1974 case DW_AT_lower_bound
:
1977 int need_frame_base
;
1980 need_frame_base
= decode_location_expression (block_start
,
1985 cu_offset
, section
);
1987 if (need_frame_base
&& !have_frame_base
)
1988 printf (_(" [without DW_AT_frame_base]"));
1994 if (form
== DW_FORM_ref_sig8
1995 || form
== DW_FORM_GNU_ref_alt
)
1998 if (form
== DW_FORM_ref1
1999 || form
== DW_FORM_ref2
2000 || form
== DW_FORM_ref4
2001 || form
== DW_FORM_ref_udata
)
2002 uvalue
+= cu_offset
;
2004 if (uvalue
>= section
->size
)
2005 warn (_("Offset %s used as value for DW_AT_import attribute of DIE at offset %lx is too big.\n"),
2006 dwarf_vmatoa ("x", uvalue
),
2007 (unsigned long) (orig_data
- section
->start
));
2010 unsigned long abbrev_number
;
2011 abbrev_entry
* entry
;
2013 abbrev_number
= read_uleb128 (section
->start
+ uvalue
, NULL
, end
);
2015 printf (_("[Abbrev Number: %ld"), abbrev_number
);
2016 /* Don't look up abbrev for DW_FORM_ref_addr, as it very often will
2017 use different abbrev table, and we don't track .debug_info chunks
2019 if (form
!= DW_FORM_ref_addr
)
2021 for (entry
= first_abbrev
; entry
!= NULL
; entry
= entry
->next
)
2022 if (entry
->entry
== abbrev_number
)
2025 printf (" (%s)", get_TAG_name (entry
->tag
));
2040 get_AT_name (unsigned long attribute
)
2045 return "DW_AT value: 0";
2047 /* One value is shared by the MIPS and HP extensions: */
2048 if (attribute
== DW_AT_MIPS_fde
)
2049 return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable";
2051 name
= get_DW_AT_name (attribute
);
2055 static char buffer
[100];
2057 snprintf (buffer
, sizeof (buffer
), _("Unknown AT value: %lx"),
2065 static unsigned char *
2066 read_and_display_attr (unsigned long attribute
,
2068 unsigned char * data
,
2069 unsigned char * end
,
2070 dwarf_vma cu_offset
,
2071 dwarf_vma pointer_size
,
2072 dwarf_vma offset_size
,
2074 debug_info
* debug_info_p
,
2076 struct dwarf_section
* section
,
2077 struct cu_tu_set
* this_set
)
2080 printf (" %-18s:", get_AT_name (attribute
));
2081 data
= read_and_display_attr_value (attribute
, form
, data
, end
,
2082 cu_offset
, pointer_size
, offset_size
,
2083 dwarf_version
, debug_info_p
,
2084 do_loc
, section
, this_set
);
2090 /* Process the contents of a .debug_info section. If do_loc is non-zero
2091 then we are scanning for location lists and we do not want to display
2092 anything to the user. If do_types is non-zero, we are processing
2093 a .debug_types section instead of a .debug_info section. */
2096 process_debug_info (struct dwarf_section
*section
,
2098 enum dwarf_section_display_enum abbrev_sec
,
2102 unsigned char *start
= section
->start
;
2103 unsigned char *end
= start
+ section
->size
;
2104 unsigned char *section_begin
;
2106 unsigned int num_units
= 0;
2108 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2109 && num_debug_info_entries
== 0
2114 /* First scan the section to get the number of comp units. */
2115 for (section_begin
= start
, num_units
= 0; section_begin
< end
;
2118 /* Read the first 4 bytes. For a 32-bit DWARF section, this
2119 will be the length. For a 64-bit DWARF section, it'll be
2120 the escape code 0xffffffff followed by an 8 byte length. */
2121 SAFE_BYTE_GET (length
, section_begin
, 4, end
);
2123 if (length
== 0xffffffff)
2125 SAFE_BYTE_GET (length
, section_begin
+ 4, 8, end
);
2126 section_begin
+= length
+ 12;
2128 else if (length
>= 0xfffffff0 && length
< 0xffffffff)
2130 warn (_("Reserved length value (0x%s) found in section %s\n"),
2131 dwarf_vmatoa ("x", length
), section
->name
);
2135 section_begin
+= length
+ 4;
2137 /* Negative values are illegal, they may even cause infinite
2138 looping. This can happen if we can't accurately apply
2139 relocations to an object file. */
2140 if ((signed long) length
<= 0)
2142 warn (_("Corrupt unit length (0x%s) found in section %s\n"),
2143 dwarf_vmatoa ("x", length
), section
->name
);
2150 error (_("No comp units in %s section ?"), section
->name
);
2154 /* Then allocate an array to hold the information. */
2155 debug_information
= (debug_info
*) cmalloc (num_units
,
2156 sizeof (* debug_information
));
2157 if (debug_information
== NULL
)
2159 error (_("Not enough memory for a debug info array of %u entries"),
2167 if (dwarf_start_die
== 0)
2168 printf (_("Contents of the %s section:\n\n"), section
->name
);
2170 load_debug_section (str
, file
);
2171 load_debug_section (str_dwo
, file
);
2172 load_debug_section (str_index
, file
);
2173 load_debug_section (str_index_dwo
, file
);
2174 load_debug_section (debug_addr
, file
);
2177 load_debug_section (abbrev_sec
, file
);
2178 if (debug_displays
[abbrev_sec
].section
.start
== NULL
)
2180 warn (_("Unable to locate %s section!\n"),
2181 debug_displays
[abbrev_sec
].section
.name
);
2185 for (section_begin
= start
, unit
= 0; start
< end
; unit
++)
2187 DWARF2_Internal_CompUnit compunit
;
2188 unsigned char *hdrptr
;
2189 unsigned char *tags
;
2190 int level
, last_level
, saved_level
;
2191 dwarf_vma cu_offset
;
2193 int initial_length_size
;
2194 dwarf_vma signature_high
= 0;
2195 dwarf_vma signature_low
= 0;
2196 dwarf_vma type_offset
= 0;
2197 struct cu_tu_set
*this_set
;
2198 dwarf_vma abbrev_base
;
2203 SAFE_BYTE_GET_AND_INC (compunit
.cu_length
, hdrptr
, 4, end
);
2205 if (compunit
.cu_length
== 0xffffffff)
2207 SAFE_BYTE_GET_AND_INC (compunit
.cu_length
, hdrptr
, 8, end
);
2209 initial_length_size
= 12;
2214 initial_length_size
= 4;
2217 SAFE_BYTE_GET_AND_INC (compunit
.cu_version
, hdrptr
, 2, end
);
2219 cu_offset
= start
- section_begin
;
2221 this_set
= find_cu_tu_set_v2 (cu_offset
, do_types
);
2223 SAFE_BYTE_GET_AND_INC (compunit
.cu_abbrev_offset
, hdrptr
, offset_size
, end
);
2225 if (this_set
== NULL
)
2228 abbrev_size
= debug_displays
[abbrev_sec
].section
.size
;
2232 abbrev_base
= this_set
->section_offsets
[DW_SECT_ABBREV
];
2233 abbrev_size
= this_set
->section_sizes
[DW_SECT_ABBREV
];
2236 SAFE_BYTE_GET_AND_INC (compunit
.cu_pointer_size
, hdrptr
, 1, end
);
2240 SAFE_BYTE_GET64 (hdrptr
, &signature_high
, &signature_low
, end
);
2241 SAFE_BYTE_GET_AND_INC (type_offset
, hdrptr
, offset_size
, end
);
2244 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2245 && num_debug_info_entries
== 0
2248 debug_information
[unit
].cu_offset
= cu_offset
;
2249 debug_information
[unit
].pointer_size
2250 = compunit
.cu_pointer_size
;
2251 debug_information
[unit
].offset_size
= offset_size
;
2252 debug_information
[unit
].dwarf_version
= compunit
.cu_version
;
2253 debug_information
[unit
].base_address
= 0;
2254 debug_information
[unit
].addr_base
= DEBUG_INFO_UNAVAILABLE
;
2255 debug_information
[unit
].ranges_base
= DEBUG_INFO_UNAVAILABLE
;
2256 debug_information
[unit
].loc_offsets
= NULL
;
2257 debug_information
[unit
].have_frame_base
= NULL
;
2258 debug_information
[unit
].max_loc_offsets
= 0;
2259 debug_information
[unit
].num_loc_offsets
= 0;
2260 debug_information
[unit
].range_lists
= NULL
;
2261 debug_information
[unit
].max_range_lists
= 0;
2262 debug_information
[unit
].num_range_lists
= 0;
2265 if (!do_loc
&& dwarf_start_die
== 0)
2267 printf (_(" Compilation Unit @ offset 0x%s:\n"),
2268 dwarf_vmatoa ("x", cu_offset
));
2269 printf (_(" Length: 0x%s (%s)\n"),
2270 dwarf_vmatoa ("x", compunit
.cu_length
),
2271 offset_size
== 8 ? "64-bit" : "32-bit");
2272 printf (_(" Version: %d\n"), compunit
.cu_version
);
2273 printf (_(" Abbrev Offset: 0x%s\n"),
2274 dwarf_vmatoa ("x", compunit
.cu_abbrev_offset
));
2275 printf (_(" Pointer Size: %d\n"), compunit
.cu_pointer_size
);
2280 printf (_(" Signature: 0x%s\n"),
2281 dwarf_vmatoa64 (signature_high
, signature_low
,
2282 buf
, sizeof (buf
)));
2283 printf (_(" Type Offset: 0x%s\n"),
2284 dwarf_vmatoa ("x", type_offset
));
2286 if (this_set
!= NULL
)
2288 dwarf_vma
*offsets
= this_set
->section_offsets
;
2289 size_t *sizes
= this_set
->section_sizes
;
2291 printf (_(" Section contributions:\n"));
2292 printf (_(" .debug_abbrev.dwo: 0x%s 0x%s\n"),
2293 dwarf_vmatoa ("x", offsets
[DW_SECT_ABBREV
]),
2294 dwarf_vmatoa ("x", sizes
[DW_SECT_ABBREV
]));
2295 printf (_(" .debug_line.dwo: 0x%s 0x%s\n"),
2296 dwarf_vmatoa ("x", offsets
[DW_SECT_LINE
]),
2297 dwarf_vmatoa ("x", sizes
[DW_SECT_LINE
]));
2298 printf (_(" .debug_loc.dwo: 0x%s 0x%s\n"),
2299 dwarf_vmatoa ("x", offsets
[DW_SECT_LOC
]),
2300 dwarf_vmatoa ("x", sizes
[DW_SECT_LOC
]));
2301 printf (_(" .debug_str_offsets.dwo: 0x%s 0x%s\n"),
2302 dwarf_vmatoa ("x", offsets
[DW_SECT_STR_OFFSETS
]),
2303 dwarf_vmatoa ("x", sizes
[DW_SECT_STR_OFFSETS
]));
2307 if (cu_offset
+ compunit
.cu_length
+ initial_length_size
2310 warn (_("Debug info is corrupted, length of CU at %s"
2311 " extends beyond end of section (length = %s)\n"),
2312 dwarf_vmatoa ("x", cu_offset
),
2313 dwarf_vmatoa ("x", compunit
.cu_length
));
2317 start
+= compunit
.cu_length
+ initial_length_size
;
2319 if (compunit
.cu_version
!= 2
2320 && compunit
.cu_version
!= 3
2321 && compunit
.cu_version
!= 4)
2323 warn (_("CU at offset %s contains corrupt or "
2324 "unsupported version number: %d.\n"),
2325 dwarf_vmatoa ("x", cu_offset
), compunit
.cu_version
);
2331 /* Process the abbrevs used by this compilation unit. DWARF
2332 sections under Mach-O have non-zero addresses. */
2333 if (compunit
.cu_abbrev_offset
>= abbrev_size
)
2334 warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"),
2335 (unsigned long) compunit
.cu_abbrev_offset
,
2336 (unsigned long) abbrev_size
);
2338 process_abbrev_section
2339 (((unsigned char *) debug_displays
[abbrev_sec
].section
.start
2340 + abbrev_base
+ compunit
.cu_abbrev_offset
),
2341 ((unsigned char *) debug_displays
[abbrev_sec
].section
.start
2342 + abbrev_base
+ abbrev_size
));
2347 while (tags
< start
)
2349 unsigned int bytes_read
;
2350 unsigned long abbrev_number
;
2351 unsigned long die_offset
;
2352 abbrev_entry
*entry
;
2354 int do_printing
= 1;
2356 die_offset
= tags
- section_begin
;
2358 abbrev_number
= read_uleb128 (tags
, & bytes_read
, start
);
2361 /* A null DIE marks the end of a list of siblings or it may also be
2362 a section padding. */
2363 if (abbrev_number
== 0)
2365 /* Check if it can be a section padding for the last CU. */
2366 if (level
== 0 && start
== end
)
2370 for (chk
= tags
; chk
< start
; chk
++)
2377 if (!do_loc
&& die_offset
>= dwarf_start_die
)
2378 printf (_(" <%d><%lx>: Abbrev Number: 0\n"),
2384 static unsigned num_bogus_warns
= 0;
2386 if (num_bogus_warns
< 3)
2388 warn (_("Bogus end-of-siblings marker detected at offset %lx in %s section\n"),
2389 die_offset
, section
->name
);
2391 if (num_bogus_warns
== 3)
2392 warn (_("Further warnings about bogus end-of-sibling markers suppressed\n"));
2395 if (dwarf_start_die
!= 0 && level
< saved_level
)
2402 if (dwarf_start_die
!= 0 && die_offset
< dwarf_start_die
)
2406 if (dwarf_start_die
!= 0 && die_offset
== dwarf_start_die
)
2407 saved_level
= level
;
2408 do_printing
= (dwarf_cutoff_level
== -1
2409 || level
< dwarf_cutoff_level
);
2411 printf (_(" <%d><%lx>: Abbrev Number: %lu"),
2412 level
, die_offset
, abbrev_number
);
2413 else if (dwarf_cutoff_level
== -1
2414 || last_level
< dwarf_cutoff_level
)
2415 printf (_(" <%d><%lx>: ...\n"), level
, die_offset
);
2420 /* Scan through the abbreviation list until we reach the
2422 for (entry
= first_abbrev
;
2423 entry
&& entry
->entry
!= abbrev_number
;
2424 entry
= entry
->next
)
2429 if (!do_loc
&& do_printing
)
2434 warn (_("DIE at offset %lx refers to abbreviation number %lu which does not exist\n"),
2435 die_offset
, abbrev_number
);
2439 if (!do_loc
&& do_printing
)
2440 printf (" (%s)\n", get_TAG_name (entry
->tag
));
2445 need_base_address
= 0;
2447 case DW_TAG_compile_unit
:
2448 need_base_address
= 1;
2450 case DW_TAG_entry_point
:
2451 case DW_TAG_subprogram
:
2452 need_base_address
= 0;
2453 /* Assuming that there is no DW_AT_frame_base. */
2454 have_frame_base
= 0;
2458 for (attr
= entry
->first_attr
;
2459 attr
&& attr
->attribute
;
2464 if (! do_loc
&& do_printing
)
2465 /* Show the offset from where the tag was extracted. */
2466 printf (" <%lx>", (unsigned long)(tags
- section_begin
));
2468 arg
= debug_information
;
2469 if (debug_information
)
2472 tags
= read_and_display_attr (attr
->attribute
,
2477 compunit
.cu_pointer_size
,
2479 compunit
.cu_version
,
2481 do_loc
|| ! do_printing
,
2486 if (entry
->children
)
2491 /* Set num_debug_info_entries here so that it can be used to check if
2492 we need to process .debug_loc and .debug_ranges sections. */
2493 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2494 && num_debug_info_entries
== 0
2496 num_debug_info_entries
= num_units
;
2504 /* Locate and scan the .debug_info section in the file and record the pointer
2505 sizes and offsets for the compilation units in it. Usually an executable
2506 will have just one pointer size, but this is not guaranteed, and so we try
2507 not to make any assumptions. Returns zero upon failure, or the number of
2508 compilation units upon success. */
2511 load_debug_info (void * file
)
2513 /* Reset the last pointer size so that we can issue correct error
2514 messages if we are displaying the contents of more than one section. */
2515 last_pointer_size
= 0;
2516 warned_about_missing_comp_units
= FALSE
;
2518 /* If we have already tried and failed to load the .debug_info
2519 section then do not bother to repeat the task. */
2520 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
2523 /* If we already have the information there is nothing else to do. */
2524 if (num_debug_info_entries
> 0)
2525 return num_debug_info_entries
;
2527 /* If this is a DWARF package file, load the CU and TU indexes. */
2528 load_cu_tu_indexes (file
);
2530 if (load_debug_section (info
, file
)
2531 && process_debug_info (&debug_displays
[info
].section
, file
, abbrev
, 1, 0))
2532 return num_debug_info_entries
;
2533 else if (load_debug_section (info_dwo
, file
)
2534 && process_debug_info (&debug_displays
[info_dwo
].section
, file
,
2536 return num_debug_info_entries
;
2538 num_debug_info_entries
= DEBUG_INFO_UNAVAILABLE
;
2543 display_debug_lines_raw (struct dwarf_section
*section
,
2544 unsigned char *data
,
2547 unsigned char *start
= section
->start
;
2549 printf (_("Raw dump of debug contents of section %s:\n\n"),
2554 DWARF2_Internal_LineInfo linfo
;
2555 unsigned char *standard_opcodes
;
2556 unsigned char *end_of_sequence
;
2557 unsigned char *hdrptr
;
2558 unsigned long hdroff
;
2559 int initial_length_size
;
2564 hdroff
= hdrptr
- start
;
2566 /* Check the length of the block. */
2567 SAFE_BYTE_GET_AND_INC (linfo
.li_length
, hdrptr
, 4, end
);
2569 if (linfo
.li_length
== 0xffffffff)
2571 /* This section is 64-bit DWARF 3. */
2572 SAFE_BYTE_GET_AND_INC (linfo
.li_length
, hdrptr
, 8, end
);
2574 initial_length_size
= 12;
2579 initial_length_size
= 4;
2582 if (linfo
.li_length
+ initial_length_size
> section
->size
)
2585 (_("The information in section %s appears to be corrupt - the section is too small\n"),
2590 /* Check its version number. */
2591 SAFE_BYTE_GET_AND_INC (linfo
.li_version
, hdrptr
, 2, end
);
2592 if (linfo
.li_version
!= 2
2593 && linfo
.li_version
!= 3
2594 && linfo
.li_version
!= 4)
2596 warn (_("Only DWARF version 2, 3 and 4 line info is currently supported.\n"));
2600 SAFE_BYTE_GET_AND_INC (linfo
.li_prologue_length
, hdrptr
, offset_size
, end
);
2601 SAFE_BYTE_GET_AND_INC (linfo
.li_min_insn_length
, hdrptr
, 1, end
);
2603 if (linfo
.li_version
>= 4)
2605 SAFE_BYTE_GET_AND_INC (linfo
.li_max_ops_per_insn
, hdrptr
, 1, end
);
2607 if (linfo
.li_max_ops_per_insn
== 0)
2609 warn (_("Invalid maximum operations per insn.\n"));
2614 linfo
.li_max_ops_per_insn
= 1;
2616 SAFE_BYTE_GET_AND_INC (linfo
.li_default_is_stmt
, hdrptr
, 1, end
);
2617 SAFE_BYTE_GET_AND_INC (linfo
.li_line_base
, hdrptr
, 1, end
);
2618 SAFE_BYTE_GET_AND_INC (linfo
.li_line_range
, hdrptr
, 1, end
);
2619 SAFE_BYTE_GET_AND_INC (linfo
.li_opcode_base
, hdrptr
, 1, end
);
2621 /* Sign extend the line base field. */
2622 linfo
.li_line_base
<<= 24;
2623 linfo
.li_line_base
>>= 24;
2625 printf (_(" Offset: 0x%lx\n"), hdroff
);
2626 printf (_(" Length: %ld\n"), (long) linfo
.li_length
);
2627 printf (_(" DWARF Version: %d\n"), linfo
.li_version
);
2628 printf (_(" Prologue Length: %d\n"), linfo
.li_prologue_length
);
2629 printf (_(" Minimum Instruction Length: %d\n"), linfo
.li_min_insn_length
);
2630 if (linfo
.li_version
>= 4)
2631 printf (_(" Maximum Ops per Instruction: %d\n"), linfo
.li_max_ops_per_insn
);
2632 printf (_(" Initial value of 'is_stmt': %d\n"), linfo
.li_default_is_stmt
);
2633 printf (_(" Line Base: %d\n"), linfo
.li_line_base
);
2634 printf (_(" Line Range: %d\n"), linfo
.li_line_range
);
2635 printf (_(" Opcode Base: %d\n"), linfo
.li_opcode_base
);
2637 end_of_sequence
= data
+ linfo
.li_length
+ initial_length_size
;
2639 reset_state_machine (linfo
.li_default_is_stmt
);
2641 /* Display the contents of the Opcodes table. */
2642 standard_opcodes
= hdrptr
;
2644 printf (_("\n Opcodes:\n"));
2646 for (i
= 1; i
< linfo
.li_opcode_base
; i
++)
2647 printf (_(" Opcode %d has %d args\n"), i
, standard_opcodes
[i
- 1]);
2649 /* Display the contents of the Directory table. */
2650 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
2653 printf (_("\n The Directory Table is empty.\n"));
2656 printf (_("\n The Directory Table:\n"));
2660 printf (" %s\n", data
);
2662 data
+= strnlen ((char *) data
, end
- data
) + 1;
2666 /* Skip the NUL at the end of the table. */
2669 /* Display the contents of the File Name table. */
2671 printf (_("\n The File Name Table is empty.\n"));
2674 printf (_("\n The File Name Table:\n"));
2675 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
2679 unsigned char *name
;
2680 unsigned int bytes_read
;
2682 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
2684 data
+= strnlen ((char *) data
, end
- data
) + 1;
2687 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
2690 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
2693 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
2695 printf ("%s\n", name
);
2699 warn (_("Corrupt file name table entry\n"));
2705 /* Skip the NUL at the end of the table. */
2708 /* Now display the statements. */
2709 printf (_("\n Line Number Statements:\n"));
2711 while (data
< end_of_sequence
)
2713 unsigned char op_code
;
2714 dwarf_signed_vma adv
;
2716 unsigned int bytes_read
;
2720 if (op_code
>= linfo
.li_opcode_base
)
2722 op_code
-= linfo
.li_opcode_base
;
2723 uladv
= (op_code
/ linfo
.li_line_range
);
2724 if (linfo
.li_max_ops_per_insn
== 1)
2726 uladv
*= linfo
.li_min_insn_length
;
2727 state_machine_regs
.address
+= uladv
;
2728 printf (_(" Special opcode %d: "
2729 "advance Address by %s to 0x%s"),
2730 op_code
, dwarf_vmatoa ("u", uladv
),
2731 dwarf_vmatoa ("x", state_machine_regs
.address
));
2735 state_machine_regs
.address
2736 += ((state_machine_regs
.op_index
+ uladv
)
2737 / linfo
.li_max_ops_per_insn
)
2738 * linfo
.li_min_insn_length
;
2739 state_machine_regs
.op_index
2740 = (state_machine_regs
.op_index
+ uladv
)
2741 % linfo
.li_max_ops_per_insn
;
2742 printf (_(" Special opcode %d: "
2743 "advance Address by %s to 0x%s[%d]"),
2744 op_code
, dwarf_vmatoa ("u", uladv
),
2745 dwarf_vmatoa ("x", state_machine_regs
.address
),
2746 state_machine_regs
.op_index
);
2748 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
2749 state_machine_regs
.line
+= adv
;
2750 printf (_(" and Line by %s to %d\n"),
2751 dwarf_vmatoa ("d", adv
), state_machine_regs
.line
);
2753 else switch (op_code
)
2755 case DW_LNS_extended_op
:
2756 data
+= process_extended_line_op (data
, linfo
.li_default_is_stmt
, end
);
2760 printf (_(" Copy\n"));
2763 case DW_LNS_advance_pc
:
2764 uladv
= read_uleb128 (data
, & bytes_read
, end
);
2766 if (linfo
.li_max_ops_per_insn
== 1)
2768 uladv
*= linfo
.li_min_insn_length
;
2769 state_machine_regs
.address
+= uladv
;
2770 printf (_(" Advance PC by %s to 0x%s\n"),
2771 dwarf_vmatoa ("u", uladv
),
2772 dwarf_vmatoa ("x", state_machine_regs
.address
));
2776 state_machine_regs
.address
2777 += ((state_machine_regs
.op_index
+ uladv
)
2778 / linfo
.li_max_ops_per_insn
)
2779 * linfo
.li_min_insn_length
;
2780 state_machine_regs
.op_index
2781 = (state_machine_regs
.op_index
+ uladv
)
2782 % linfo
.li_max_ops_per_insn
;
2783 printf (_(" Advance PC by %s to 0x%s[%d]\n"),
2784 dwarf_vmatoa ("u", uladv
),
2785 dwarf_vmatoa ("x", state_machine_regs
.address
),
2786 state_machine_regs
.op_index
);
2790 case DW_LNS_advance_line
:
2791 adv
= read_sleb128 (data
, & bytes_read
, end
);
2793 state_machine_regs
.line
+= adv
;
2794 printf (_(" Advance Line by %s to %d\n"),
2795 dwarf_vmatoa ("d", adv
),
2796 state_machine_regs
.line
);
2799 case DW_LNS_set_file
:
2800 adv
= read_uleb128 (data
, & bytes_read
, end
);
2802 printf (_(" Set File Name to entry %s in the File Name Table\n"),
2803 dwarf_vmatoa ("d", adv
));
2804 state_machine_regs
.file
= adv
;
2807 case DW_LNS_set_column
:
2808 uladv
= read_uleb128 (data
, & bytes_read
, end
);
2810 printf (_(" Set column to %s\n"),
2811 dwarf_vmatoa ("u", uladv
));
2812 state_machine_regs
.column
= uladv
;
2815 case DW_LNS_negate_stmt
:
2816 adv
= state_machine_regs
.is_stmt
;
2818 printf (_(" Set is_stmt to %s\n"), dwarf_vmatoa ("d", adv
));
2819 state_machine_regs
.is_stmt
= adv
;
2822 case DW_LNS_set_basic_block
:
2823 printf (_(" Set basic block\n"));
2824 state_machine_regs
.basic_block
= 1;
2827 case DW_LNS_const_add_pc
:
2828 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
2829 if (linfo
.li_max_ops_per_insn
)
2831 uladv
*= linfo
.li_min_insn_length
;
2832 state_machine_regs
.address
+= uladv
;
2833 printf (_(" Advance PC by constant %s to 0x%s\n"),
2834 dwarf_vmatoa ("u", uladv
),
2835 dwarf_vmatoa ("x", state_machine_regs
.address
));
2839 state_machine_regs
.address
2840 += ((state_machine_regs
.op_index
+ uladv
)
2841 / linfo
.li_max_ops_per_insn
)
2842 * linfo
.li_min_insn_length
;
2843 state_machine_regs
.op_index
2844 = (state_machine_regs
.op_index
+ uladv
)
2845 % linfo
.li_max_ops_per_insn
;
2846 printf (_(" Advance PC by constant %s to 0x%s[%d]\n"),
2847 dwarf_vmatoa ("u", uladv
),
2848 dwarf_vmatoa ("x", state_machine_regs
.address
),
2849 state_machine_regs
.op_index
);
2853 case DW_LNS_fixed_advance_pc
:
2854 SAFE_BYTE_GET_AND_INC (uladv
, data
, 2, end
);
2855 state_machine_regs
.address
+= uladv
;
2856 state_machine_regs
.op_index
= 0;
2857 printf (_(" Advance PC by fixed size amount %s to 0x%s\n"),
2858 dwarf_vmatoa ("u", uladv
),
2859 dwarf_vmatoa ("x", state_machine_regs
.address
));
2862 case DW_LNS_set_prologue_end
:
2863 printf (_(" Set prologue_end to true\n"));
2866 case DW_LNS_set_epilogue_begin
:
2867 printf (_(" Set epilogue_begin to true\n"));
2870 case DW_LNS_set_isa
:
2871 uladv
= read_uleb128 (data
, & bytes_read
, end
);
2873 printf (_(" Set ISA to %s\n"), dwarf_vmatoa ("u", uladv
));
2877 printf (_(" Unknown opcode %d with operands: "), op_code
);
2879 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
2881 printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data
,
2883 i
== 1 ? "" : ", ");
2898 unsigned char *name
;
2899 unsigned int directory_index
;
2900 unsigned int modification_date
;
2901 unsigned int length
;
2904 /* Output a decoded representation of the .debug_line section. */
2907 display_debug_lines_decoded (struct dwarf_section
*section
,
2908 unsigned char *data
,
2911 printf (_("Decoded dump of debug contents of section %s:\n\n"),
2916 /* This loop amounts to one iteration per compilation unit. */
2917 DWARF2_Internal_LineInfo linfo
;
2918 unsigned char *standard_opcodes
;
2919 unsigned char *end_of_sequence
;
2920 unsigned char *hdrptr
;
2921 int initial_length_size
;
2924 File_Entry
*file_table
= NULL
;
2925 unsigned int n_files
= 0;
2926 unsigned char **directory_table
= NULL
;
2927 unsigned int n_directories
= 0;
2931 /* Extract information from the Line Number Program Header.
2932 (section 6.2.4 in the Dwarf3 doc). */
2934 /* Get the length of this CU's line number information block. */
2935 SAFE_BYTE_GET_AND_INC (linfo
.li_length
, hdrptr
, 4, end
);
2937 if (linfo
.li_length
== 0xffffffff)
2939 /* This section is 64-bit DWARF 3. */
2940 SAFE_BYTE_GET_AND_INC (linfo
.li_length
, hdrptr
, 8, end
);
2942 initial_length_size
= 12;
2947 initial_length_size
= 4;
2950 if (linfo
.li_length
+ initial_length_size
> section
->size
)
2952 warn (_("The line info appears to be corrupt - "
2953 "the section is too small\n"));
2957 /* Get this CU's Line Number Block version number. */
2958 SAFE_BYTE_GET_AND_INC (linfo
.li_version
, hdrptr
, 2, end
);
2959 if (linfo
.li_version
!= 2
2960 && linfo
.li_version
!= 3
2961 && linfo
.li_version
!= 4)
2963 warn (_("Only DWARF version 2, 3 and 4 line info is currently "
2968 SAFE_BYTE_GET_AND_INC (linfo
.li_prologue_length
, hdrptr
, offset_size
, end
);
2969 SAFE_BYTE_GET_AND_INC (linfo
.li_min_insn_length
, hdrptr
, 1, end
);
2971 if (linfo
.li_version
>= 4)
2973 SAFE_BYTE_GET_AND_INC (linfo
.li_max_ops_per_insn
, hdrptr
, 1, end
);
2974 if (linfo
.li_max_ops_per_insn
== 0)
2976 warn (_("Invalid maximum operations per insn.\n"));
2981 linfo
.li_max_ops_per_insn
= 1;
2983 SAFE_BYTE_GET_AND_INC (linfo
.li_default_is_stmt
, hdrptr
, 1, end
);
2984 SAFE_BYTE_GET_AND_INC (linfo
.li_line_base
, hdrptr
, 1, end
);
2985 SAFE_BYTE_GET_AND_INC (linfo
.li_line_range
, hdrptr
, 1, end
);
2986 SAFE_BYTE_GET_AND_INC (linfo
.li_opcode_base
, hdrptr
, 1, end
);
2988 /* Sign extend the line base field. */
2989 linfo
.li_line_base
<<= 24;
2990 linfo
.li_line_base
>>= 24;
2992 /* Find the end of this CU's Line Number Information Block. */
2993 end_of_sequence
= data
+ linfo
.li_length
+ initial_length_size
;
2995 reset_state_machine (linfo
.li_default_is_stmt
);
2997 /* Save a pointer to the contents of the Opcodes table. */
2998 standard_opcodes
= hdrptr
;
3000 /* Traverse the Directory table just to count entries. */
3001 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
3004 unsigned char *ptr_directory_table
= data
;
3008 data
+= strnlen ((char *) data
, end
- data
) + 1;
3012 /* Go through the directory table again to save the directories. */
3013 directory_table
= (unsigned char **)
3014 xmalloc (n_directories
* sizeof (unsigned char *));
3017 while (*ptr_directory_table
!= 0)
3019 directory_table
[i
] = ptr_directory_table
;
3020 ptr_directory_table
+= strnlen ((char *) ptr_directory_table
,
3021 ptr_directory_table
- end
) + 1;
3025 /* Skip the NUL at the end of the table. */
3028 /* Traverse the File Name table just to count the entries. */
3031 unsigned char *ptr_file_name_table
= data
;
3035 unsigned int bytes_read
;
3037 /* Skip Name, directory index, last modification time and length
3039 data
+= strnlen ((char *) data
, end
- data
) + 1;
3040 read_uleb128 (data
, & bytes_read
, end
);
3042 read_uleb128 (data
, & bytes_read
, end
);
3044 read_uleb128 (data
, & bytes_read
, end
);
3050 /* Go through the file table again to save the strings. */
3051 file_table
= (File_Entry
*) xmalloc (n_files
* sizeof (File_Entry
));
3054 while (*ptr_file_name_table
!= 0)
3056 unsigned int bytes_read
;
3058 file_table
[i
].name
= ptr_file_name_table
;
3059 ptr_file_name_table
+= strnlen ((char *) ptr_file_name_table
,
3060 end
- ptr_file_name_table
) + 1;
3062 /* We are not interested in directory, time or size. */
3063 file_table
[i
].directory_index
= read_uleb128 (ptr_file_name_table
,
3065 ptr_file_name_table
+= bytes_read
;
3066 file_table
[i
].modification_date
= read_uleb128 (ptr_file_name_table
,
3068 ptr_file_name_table
+= bytes_read
;
3069 file_table
[i
].length
= read_uleb128 (ptr_file_name_table
, & bytes_read
, end
);
3070 ptr_file_name_table
+= bytes_read
;
3075 /* Print the Compilation Unit's name and a header. */
3076 if (directory_table
== NULL
)
3078 printf (_("CU: %s:\n"), file_table
[0].name
);
3079 printf (_("File name Line number Starting address\n"));
3083 unsigned int ix
= file_table
[0].directory_index
;
3084 const char *directory
= ix
? (char *)directory_table
[ix
- 1] : ".";
3086 if (do_wide
|| strlen (directory
) < 76)
3087 printf (_("CU: %s/%s:\n"), directory
, file_table
[0].name
);
3089 printf ("%s:\n", file_table
[0].name
);
3091 printf (_("File name Line number Starting address\n"));
3095 /* Skip the NUL at the end of the table. */
3098 /* This loop iterates through the Dwarf Line Number Program. */
3099 while (data
< end_of_sequence
)
3101 unsigned char op_code
;
3103 unsigned long int uladv
;
3104 unsigned int bytes_read
;
3105 int is_special_opcode
= 0;
3109 if (op_code
>= linfo
.li_opcode_base
)
3111 op_code
-= linfo
.li_opcode_base
;
3112 uladv
= (op_code
/ linfo
.li_line_range
);
3113 if (linfo
.li_max_ops_per_insn
== 1)
3115 uladv
*= linfo
.li_min_insn_length
;
3116 state_machine_regs
.address
+= uladv
;
3120 state_machine_regs
.address
3121 += ((state_machine_regs
.op_index
+ uladv
)
3122 / linfo
.li_max_ops_per_insn
)
3123 * linfo
.li_min_insn_length
;
3124 state_machine_regs
.op_index
3125 = (state_machine_regs
.op_index
+ uladv
)
3126 % linfo
.li_max_ops_per_insn
;
3129 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
3130 state_machine_regs
.line
+= adv
;
3131 is_special_opcode
= 1;
3133 else switch (op_code
)
3135 case DW_LNS_extended_op
:
3137 unsigned int ext_op_code_len
;
3138 unsigned char ext_op_code
;
3139 unsigned char *op_code_data
= data
;
3141 ext_op_code_len
= read_uleb128 (op_code_data
, &bytes_read
,
3143 op_code_data
+= bytes_read
;
3145 if (ext_op_code_len
== 0)
3147 warn (_("badly formed extended line op encountered!\n"));
3150 ext_op_code_len
+= bytes_read
;
3151 ext_op_code
= *op_code_data
++;
3153 switch (ext_op_code
)
3155 case DW_LNE_end_sequence
:
3156 reset_state_machine (linfo
.li_default_is_stmt
);
3158 case DW_LNE_set_address
:
3159 SAFE_BYTE_GET_AND_INC (state_machine_regs
.address
,
3160 op_code_data
, ext_op_code_len
- bytes_read
- 1,
3162 state_machine_regs
.op_index
= 0;
3164 case DW_LNE_define_file
:
3166 file_table
= (File_Entry
*) xrealloc
3167 (file_table
, (n_files
+ 1) * sizeof (File_Entry
));
3169 ++state_machine_regs
.last_file_entry
;
3170 /* Source file name. */
3171 file_table
[n_files
].name
= op_code_data
;
3172 op_code_data
+= strlen ((char *) op_code_data
) + 1;
3173 /* Directory index. */
3174 file_table
[n_files
].directory_index
=
3175 read_uleb128 (op_code_data
, & bytes_read
,
3177 op_code_data
+= bytes_read
;
3178 /* Last modification time. */
3179 file_table
[n_files
].modification_date
=
3180 read_uleb128 (op_code_data
, & bytes_read
,
3182 op_code_data
+= bytes_read
;
3184 file_table
[n_files
].length
=
3185 read_uleb128 (op_code_data
, & bytes_read
,
3191 case DW_LNE_set_discriminator
:
3192 case DW_LNE_HP_set_sequence
:
3193 /* Simply ignored. */
3197 printf (_("UNKNOWN (%u): length %d\n"),
3198 ext_op_code
, ext_op_code_len
- bytes_read
);
3201 data
+= ext_op_code_len
;
3207 case DW_LNS_advance_pc
:
3208 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3210 if (linfo
.li_max_ops_per_insn
== 1)
3212 uladv
*= linfo
.li_min_insn_length
;
3213 state_machine_regs
.address
+= uladv
;
3217 state_machine_regs
.address
3218 += ((state_machine_regs
.op_index
+ uladv
)
3219 / linfo
.li_max_ops_per_insn
)
3220 * linfo
.li_min_insn_length
;
3221 state_machine_regs
.op_index
3222 = (state_machine_regs
.op_index
+ uladv
)
3223 % linfo
.li_max_ops_per_insn
;
3227 case DW_LNS_advance_line
:
3228 adv
= read_sleb128 (data
, & bytes_read
, end
);
3230 state_machine_regs
.line
+= adv
;
3233 case DW_LNS_set_file
:
3234 adv
= read_uleb128 (data
, & bytes_read
, end
);
3236 state_machine_regs
.file
= adv
;
3237 if (file_table
[state_machine_regs
.file
- 1].directory_index
== 0)
3239 /* If directory index is 0, that means current directory. */
3240 printf ("\n./%s:[++]\n",
3241 file_table
[state_machine_regs
.file
- 1].name
);
3245 /* The directory index starts counting at 1. */
3246 printf ("\n%s/%s:\n",
3247 directory_table
[file_table
[state_machine_regs
.file
- 1].directory_index
- 1],
3248 file_table
[state_machine_regs
.file
- 1].name
);
3252 case DW_LNS_set_column
:
3253 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3255 state_machine_regs
.column
= uladv
;
3258 case DW_LNS_negate_stmt
:
3259 adv
= state_machine_regs
.is_stmt
;
3261 state_machine_regs
.is_stmt
= adv
;
3264 case DW_LNS_set_basic_block
:
3265 state_machine_regs
.basic_block
= 1;
3268 case DW_LNS_const_add_pc
:
3269 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
3270 if (linfo
.li_max_ops_per_insn
== 1)
3272 uladv
*= linfo
.li_min_insn_length
;
3273 state_machine_regs
.address
+= uladv
;
3277 state_machine_regs
.address
3278 += ((state_machine_regs
.op_index
+ uladv
)
3279 / linfo
.li_max_ops_per_insn
)
3280 * linfo
.li_min_insn_length
;
3281 state_machine_regs
.op_index
3282 = (state_machine_regs
.op_index
+ uladv
)
3283 % linfo
.li_max_ops_per_insn
;
3287 case DW_LNS_fixed_advance_pc
:
3288 SAFE_BYTE_GET_AND_INC (uladv
, data
, 2, end
);
3289 state_machine_regs
.address
+= uladv
;
3290 state_machine_regs
.op_index
= 0;
3293 case DW_LNS_set_prologue_end
:
3296 case DW_LNS_set_epilogue_begin
:
3299 case DW_LNS_set_isa
:
3300 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3302 printf (_(" Set ISA to %lu\n"), uladv
);
3306 printf (_(" Unknown opcode %d with operands: "), op_code
);
3308 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
3310 printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data
,
3312 i
== 1 ? "" : ", ");
3319 /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row
3320 to the DWARF address/line matrix. */
3321 if ((is_special_opcode
) || (op_code
== DW_LNE_end_sequence
)
3322 || (op_code
== DW_LNS_copy
))
3324 const unsigned int MAX_FILENAME_LENGTH
= 35;
3325 char *fileName
= (char *)file_table
[state_machine_regs
.file
- 1].name
;
3326 char *newFileName
= NULL
;
3327 size_t fileNameLength
= strlen (fileName
);
3329 if ((fileNameLength
> MAX_FILENAME_LENGTH
) && (!do_wide
))
3331 newFileName
= (char *) xmalloc (MAX_FILENAME_LENGTH
+ 1);
3332 /* Truncate file name */
3333 strncpy (newFileName
,
3334 fileName
+ fileNameLength
- MAX_FILENAME_LENGTH
,
3335 MAX_FILENAME_LENGTH
+ 1);
3339 newFileName
= (char *) xmalloc (fileNameLength
+ 1);
3340 strncpy (newFileName
, fileName
, fileNameLength
+ 1);
3343 if (!do_wide
|| (fileNameLength
<= MAX_FILENAME_LENGTH
))
3345 if (linfo
.li_max_ops_per_insn
== 1)
3346 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x\n",
3347 newFileName
, state_machine_regs
.line
,
3348 state_machine_regs
.address
);
3350 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x[%d]\n",
3351 newFileName
, state_machine_regs
.line
,
3352 state_machine_regs
.address
,
3353 state_machine_regs
.op_index
);
3357 if (linfo
.li_max_ops_per_insn
== 1)
3358 printf ("%s %11d %#18" DWARF_VMA_FMT
"x\n",
3359 newFileName
, state_machine_regs
.line
,
3360 state_machine_regs
.address
);
3362 printf ("%s %11d %#18" DWARF_VMA_FMT
"x[%d]\n",
3363 newFileName
, state_machine_regs
.line
,
3364 state_machine_regs
.address
,
3365 state_machine_regs
.op_index
);
3368 if (op_code
== DW_LNE_end_sequence
)
3376 free (directory_table
);
3377 directory_table
= NULL
;
3385 display_debug_lines (struct dwarf_section
*section
, void *file ATTRIBUTE_UNUSED
)
3387 unsigned char *data
= section
->start
;
3388 unsigned char *end
= data
+ section
->size
;
3390 int retValDecoded
= 1;
3392 if (do_debug_lines
== 0)
3393 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
3395 if (do_debug_lines
& FLAG_DEBUG_LINES_RAW
)
3396 retValRaw
= display_debug_lines_raw (section
, data
, end
);
3398 if (do_debug_lines
& FLAG_DEBUG_LINES_DECODED
)
3399 retValDecoded
= display_debug_lines_decoded (section
, data
, end
);
3401 if (!retValRaw
|| !retValDecoded
)
3408 find_debug_info_for_offset (unsigned long offset
)
3412 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
3415 for (i
= 0; i
< num_debug_info_entries
; i
++)
3416 if (debug_information
[i
].cu_offset
== offset
)
3417 return debug_information
+ i
;
3423 display_debug_pubnames (struct dwarf_section
*section
,
3424 void *file ATTRIBUTE_UNUSED
)
3426 DWARF2_Internal_PubNames names
;
3427 unsigned char *start
= section
->start
;
3428 unsigned char *end
= start
+ section
->size
;
3430 /* It does not matter if this load fails,
3431 we test for that later on. */
3432 load_debug_info (file
);
3434 printf (_("Contents of the %s section:\n\n"), section
->name
);
3438 unsigned char *data
;
3439 unsigned long offset
;
3440 int offset_size
, initial_length_size
;
3444 SAFE_BYTE_GET_AND_INC (names
.pn_length
, data
, 4, end
);
3445 if (names
.pn_length
== 0xffffffff)
3447 SAFE_BYTE_GET_AND_INC (names
.pn_length
, data
, 8, end
);
3449 initial_length_size
= 12;
3454 initial_length_size
= 4;
3457 SAFE_BYTE_GET_AND_INC (names
.pn_version
, data
, 2, end
);
3458 SAFE_BYTE_GET_AND_INC (names
.pn_offset
, data
, offset_size
, end
);
3460 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
3461 && num_debug_info_entries
> 0
3462 && find_debug_info_for_offset (names
.pn_offset
) == NULL
)
3463 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
3464 (unsigned long) names
.pn_offset
, section
->name
);
3466 SAFE_BYTE_GET_AND_INC (names
.pn_size
, data
, offset_size
, end
);
3468 start
+= names
.pn_length
+ initial_length_size
;
3470 if (names
.pn_version
!= 2 && names
.pn_version
!= 3)
3472 static int warned
= 0;
3476 warn (_("Only DWARF 2 and 3 pubnames are currently supported\n"));
3483 printf (_(" Length: %ld\n"),
3484 (long) names
.pn_length
);
3485 printf (_(" Version: %d\n"),
3487 printf (_(" Offset into .debug_info section: 0x%lx\n"),
3488 (unsigned long) names
.pn_offset
);
3489 printf (_(" Size of area in .debug_info section: %ld\n"),
3490 (long) names
.pn_size
);
3492 printf (_("\n Offset\tName\n"));
3496 SAFE_BYTE_GET (offset
, data
, offset_size
, end
);
3500 data
+= offset_size
;
3501 printf (" %-6lx\t%s\n", offset
, data
);
3502 data
+= strnlen ((char *) data
, end
- data
) + 1;
3505 while (offset
!= 0);
3513 display_debug_macinfo (struct dwarf_section
*section
,
3514 void *file ATTRIBUTE_UNUSED
)
3516 unsigned char *start
= section
->start
;
3517 unsigned char *end
= start
+ section
->size
;
3518 unsigned char *curr
= start
;
3519 unsigned int bytes_read
;
3520 enum dwarf_macinfo_record_type op
;
3522 printf (_("Contents of the %s section:\n\n"), section
->name
);
3526 unsigned int lineno
;
3527 const unsigned char *string
;
3529 op
= (enum dwarf_macinfo_record_type
) *curr
;
3534 case DW_MACINFO_start_file
:
3536 unsigned int filenum
;
3538 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
3540 filenum
= read_uleb128 (curr
, & bytes_read
, end
);
3543 printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"),
3548 case DW_MACINFO_end_file
:
3549 printf (_(" DW_MACINFO_end_file\n"));
3552 case DW_MACINFO_define
:
3553 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
3556 curr
+= strnlen ((char *) string
, end
- string
) + 1;
3557 printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"),
3561 case DW_MACINFO_undef
:
3562 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
3565 curr
+= strnlen ((char *) string
, end
- string
) + 1;
3566 printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"),
3570 case DW_MACINFO_vendor_ext
:
3572 unsigned int constant
;
3574 constant
= read_uleb128 (curr
, & bytes_read
, end
);
3577 curr
+= strnlen ((char *) string
, end
- string
) + 1;
3578 printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"),
3588 /* Given LINE_OFFSET into the .debug_line section, attempt to return
3589 filename and dirname corresponding to file name table entry with index
3590 FILEIDX. Return NULL on failure. */
3592 static unsigned char *
3593 get_line_filename_and_dirname (dwarf_vma line_offset
,
3595 unsigned char **dir_name
)
3597 struct dwarf_section
*section
= &debug_displays
[line
].section
;
3598 unsigned char *hdrptr
, *dirtable
, *file_name
;
3599 unsigned int offset_size
, initial_length_size
;
3600 unsigned int version
, opcode_base
, bytes_read
;
3601 dwarf_vma length
, diridx
;
3602 const unsigned char * end
;
3605 if (section
->start
== NULL
3606 || line_offset
>= section
->size
3610 hdrptr
= section
->start
+ line_offset
;
3611 end
= section
->start
+ section
->size
;
3613 SAFE_BYTE_GET_AND_INC (length
, hdrptr
, 4, end
);
3614 if (length
== 0xffffffff)
3616 /* This section is 64-bit DWARF 3. */
3617 SAFE_BYTE_GET_AND_INC (length
, hdrptr
, 8, end
);
3619 initial_length_size
= 12;
3624 initial_length_size
= 4;
3626 if (length
+ initial_length_size
> section
->size
)
3629 SAFE_BYTE_GET_AND_INC (version
, hdrptr
, 2, end
);
3630 if (version
!= 2 && version
!= 3 && version
!= 4)
3632 hdrptr
+= offset_size
+ 1;/* Skip prologue_length and min_insn_length. */
3634 hdrptr
++; /* Skip max_ops_per_insn. */
3635 hdrptr
+= 3; /* Skip default_is_stmt, line_base, line_range. */
3637 SAFE_BYTE_GET_AND_INC (opcode_base
, hdrptr
, 1, end
);
3638 if (opcode_base
== 0)
3641 hdrptr
+= opcode_base
- 1;
3643 /* Skip over dirname table. */
3644 while (*hdrptr
!= '\0')
3645 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
3646 hdrptr
++; /* Skip the NUL at the end of the table. */
3647 /* Now skip over preceding filename table entries. */
3648 for (; *hdrptr
!= '\0' && fileidx
> 1; fileidx
--)
3650 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
3651 read_uleb128 (hdrptr
, &bytes_read
, end
);
3652 hdrptr
+= bytes_read
;
3653 read_uleb128 (hdrptr
, &bytes_read
, end
);
3654 hdrptr
+= bytes_read
;
3655 read_uleb128 (hdrptr
, &bytes_read
, end
);
3656 hdrptr
+= bytes_read
;
3658 if (hdrptr
== end
|| *hdrptr
== '\0')
3661 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
3662 diridx
= read_uleb128 (hdrptr
, &bytes_read
, end
);
3665 for (; *dirtable
!= '\0' && diridx
> 1; diridx
--)
3666 dirtable
+= strnlen ((char *) dirtable
, end
- dirtable
) + 1;
3667 if (*dirtable
== '\0')
3669 *dir_name
= dirtable
;
3674 display_debug_macro (struct dwarf_section
*section
,
3677 unsigned char *start
= section
->start
;
3678 unsigned char *end
= start
+ section
->size
;
3679 unsigned char *curr
= start
;
3680 unsigned char *extended_op_buf
[256];
3681 unsigned int bytes_read
;
3683 load_debug_section (str
, file
);
3684 load_debug_section (line
, file
);
3686 printf (_("Contents of the %s section:\n\n"), section
->name
);
3690 unsigned int lineno
, version
, flags
;
3691 unsigned int offset_size
= 4;
3692 const unsigned char *string
;
3693 dwarf_vma line_offset
= 0, sec_offset
= curr
- start
, offset
;
3694 unsigned char **extended_ops
= NULL
;
3696 SAFE_BYTE_GET_AND_INC (version
, curr
, 2, end
);
3699 error (_("Only GNU extension to DWARF 4 of %s is currently supported.\n"),
3704 SAFE_BYTE_GET_AND_INC (flags
, curr
, 1, end
);
3707 printf (_(" Offset: 0x%lx\n"),
3708 (unsigned long) sec_offset
);
3709 printf (_(" Version: %d\n"), version
);
3710 printf (_(" Offset size: %d\n"), offset_size
);
3713 SAFE_BYTE_GET_AND_INC (line_offset
, curr
, offset_size
, end
);
3714 printf (_(" Offset into .debug_line: 0x%lx\n"),
3715 (unsigned long) line_offset
);
3719 unsigned int i
, count
, op
;
3722 SAFE_BYTE_GET_AND_INC (count
, curr
, 1, end
);
3724 memset (extended_op_buf
, 0, sizeof (extended_op_buf
));
3725 extended_ops
= extended_op_buf
;
3728 printf (_(" Extension opcode arguments:\n"));
3729 for (i
= 0; i
< count
; i
++)
3731 SAFE_BYTE_GET_AND_INC (op
, curr
, 1, end
);
3732 extended_ops
[op
] = curr
;
3733 nargs
= read_uleb128 (curr
, &bytes_read
, end
);
3736 printf (_(" DW_MACRO_GNU_%02x has no arguments\n"), op
);
3739 printf (_(" DW_MACRO_GNU_%02x arguments: "), op
);
3740 for (n
= 0; n
< nargs
; n
++)
3744 SAFE_BYTE_GET_AND_INC (form
, curr
, 1, end
);
3745 printf ("%s%s", get_FORM_name (form
),
3746 n
== nargs
- 1 ? "\n" : ", ");
3756 case DW_FORM_block1
:
3757 case DW_FORM_block2
:
3758 case DW_FORM_block4
:
3760 case DW_FORM_string
:
3762 case DW_FORM_sec_offset
:
3765 error (_("Invalid extension opcode form %s\n"),
3766 get_FORM_name (form
));
3782 error (_(".debug_macro section not zero terminated\n"));
3786 SAFE_BYTE_GET_AND_INC (op
, curr
, 1, end
);
3792 case DW_MACRO_GNU_start_file
:
3794 unsigned int filenum
;
3795 unsigned char *file_name
= NULL
, *dir_name
= NULL
;
3797 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3799 filenum
= read_uleb128 (curr
, &bytes_read
, end
);
3802 if ((flags
& 2) == 0)
3803 error (_("DW_MACRO_GNU_start_file used, but no .debug_line offset provided.\n"));
3806 = get_line_filename_and_dirname (line_offset
, filenum
,
3808 if (file_name
== NULL
)
3809 printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d\n"),
3812 printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d filename: %s%s%s\n"),
3814 dir_name
!= NULL
? (const char *) dir_name
: "",
3815 dir_name
!= NULL
? "/" : "", file_name
);
3819 case DW_MACRO_GNU_end_file
:
3820 printf (_(" DW_MACRO_GNU_end_file\n"));
3823 case DW_MACRO_GNU_define
:
3824 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3827 curr
+= strnlen ((char *) string
, end
- string
) + 1;
3828 printf (_(" DW_MACRO_GNU_define - lineno : %d macro : %s\n"),
3832 case DW_MACRO_GNU_undef
:
3833 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3836 curr
+= strnlen ((char *) string
, end
- string
) + 1;
3837 printf (_(" DW_MACRO_GNU_undef - lineno : %d macro : %s\n"),
3841 case DW_MACRO_GNU_define_indirect
:
3842 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3844 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
3845 string
= fetch_indirect_string (offset
);
3846 printf (_(" DW_MACRO_GNU_define_indirect - lineno : %d macro : %s\n"),
3850 case DW_MACRO_GNU_undef_indirect
:
3851 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3853 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
3854 string
= fetch_indirect_string (offset
);
3855 printf (_(" DW_MACRO_GNU_undef_indirect - lineno : %d macro : %s\n"),
3859 case DW_MACRO_GNU_transparent_include
:
3860 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
3861 printf (_(" DW_MACRO_GNU_transparent_include - offset : 0x%lx\n"),
3862 (unsigned long) offset
);
3865 case DW_MACRO_GNU_define_indirect_alt
:
3866 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3868 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
3869 printf (_(" DW_MACRO_GNU_define_indirect_alt - lineno : %d macro offset : 0x%lx\n"),
3870 lineno
, (unsigned long) offset
);
3873 case DW_MACRO_GNU_undef_indirect_alt
:
3874 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3876 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
3877 printf (_(" DW_MACRO_GNU_undef_indirect_alt - lineno : %d macro offset : 0x%lx\n"),
3878 lineno
, (unsigned long) offset
);
3881 case DW_MACRO_GNU_transparent_include_alt
:
3882 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
3883 printf (_(" DW_MACRO_GNU_transparent_include_alt - offset : 0x%lx\n"),
3884 (unsigned long) offset
);
3888 if (extended_ops
== NULL
|| extended_ops
[op
] == NULL
)
3890 error (_(" Unknown macro opcode %02x seen\n"), op
);
3895 /* Skip over unhandled opcodes. */
3897 unsigned char *desc
= extended_ops
[op
];
3898 nargs
= read_uleb128 (desc
, &bytes_read
, end
);
3902 printf (_(" DW_MACRO_GNU_%02x\n"), op
);
3905 printf (_(" DW_MACRO_GNU_%02x -"), op
);
3906 for (n
= 0; n
< nargs
; n
++)
3910 SAFE_BYTE_GET_AND_INC (val
, desc
, 1, end
);
3912 = read_and_display_attr_value (0, val
,
3913 curr
, end
, 0, 0, offset_size
,
3914 version
, NULL
, 0, NULL
,
3932 display_debug_abbrev (struct dwarf_section
*section
,
3933 void *file ATTRIBUTE_UNUSED
)
3935 abbrev_entry
*entry
;
3936 unsigned char *start
= section
->start
;
3937 unsigned char *end
= start
+ section
->size
;
3939 printf (_("Contents of the %s section:\n\n"), section
->name
);
3943 unsigned char *last
;
3948 start
= process_abbrev_section (start
, end
);
3950 if (first_abbrev
== NULL
)
3953 printf (_(" Number TAG (0x%lx)\n"), (long) (last
- section
->start
));
3955 for (entry
= first_abbrev
; entry
; entry
= entry
->next
)
3959 printf (" %ld %s [%s]\n",
3961 get_TAG_name (entry
->tag
),
3962 entry
->children
? _("has children") : _("no children"));
3964 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
3965 printf (" %-18s %s\n",
3966 get_AT_name (attr
->attribute
),
3967 get_FORM_name (attr
->form
));
3977 /* Display a location list from a normal (ie, non-dwo) .debug_loc section. */
3980 display_loc_list (struct dwarf_section
*section
,
3981 unsigned char **start_ptr
,
3982 int debug_info_entry
,
3983 unsigned long offset
,
3984 unsigned long base_address
,
3987 unsigned char *start
= *start_ptr
;
3988 unsigned char *section_end
= section
->start
+ section
->size
;
3989 unsigned long cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
3990 unsigned int pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
3991 unsigned int offset_size
= debug_information
[debug_info_entry
].offset_size
;
3992 int dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
3996 unsigned short length
;
3997 int need_frame_base
;
4001 if (start
+ 2 * pointer_size
> section_end
)
4003 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4008 printf (" %8.8lx ", offset
+ (start
- *start_ptr
));
4010 /* Note: we use sign extension here in order to be sure that we can detect
4011 the -1 escape value. Sign extension into the top 32 bits of a 32-bit
4012 address will not affect the values that we display since we always show
4013 hex values, and always the bottom 32-bits. */
4014 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, section_end
);
4015 SAFE_BYTE_GET_AND_INC (end
, start
, pointer_size
, section_end
);
4017 if (begin
== 0 && end
== 0)
4019 printf (_("<End of list>\n"));
4023 /* Check base address specifiers. */
4024 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
4027 print_dwarf_vma (begin
, pointer_size
);
4028 print_dwarf_vma (end
, pointer_size
);
4029 printf (_("(base address)\n"));
4033 if (start
+ 2 > section_end
)
4035 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4040 SAFE_BYTE_GET_AND_INC (length
, start
, 2, section_end
);
4042 if (start
+ length
> section_end
)
4044 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4049 print_dwarf_vma (begin
+ base_address
, pointer_size
);
4050 print_dwarf_vma (end
+ base_address
, pointer_size
);
4053 need_frame_base
= decode_location_expression (start
,
4058 cu_offset
, section
);
4061 if (need_frame_base
&& !has_frame_base
)
4062 printf (_(" [without DW_AT_frame_base]"));
4065 fputs (_(" (start == end)"), stdout
);
4066 else if (begin
> end
)
4067 fputs (_(" (start > end)"), stdout
);
4077 /* Print a .debug_addr table index in decimal, surrounded by square brackets,
4078 right-adjusted in a field of length LEN, and followed by a space. */
4081 print_addr_index (unsigned int idx
, unsigned int len
)
4083 static char buf
[15];
4084 snprintf (buf
, sizeof (buf
), "[%d]", idx
);
4085 printf ("%*s ", len
, buf
);
4088 /* Display a location list from a .dwo section. It uses address indexes rather
4089 than embedded addresses. This code closely follows display_loc_list, but the
4090 two are sufficiently different that combining things is very ugly. */
4093 display_loc_list_dwo (struct dwarf_section
*section
,
4094 unsigned char **start_ptr
,
4095 int debug_info_entry
,
4096 unsigned long offset
,
4099 unsigned char *start
= *start_ptr
;
4100 unsigned char *section_end
= section
->start
+ section
->size
;
4101 unsigned long cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
4102 unsigned int pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
4103 unsigned int offset_size
= debug_information
[debug_info_entry
].offset_size
;
4104 int dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
4106 unsigned short length
;
4107 int need_frame_base
;
4109 unsigned int bytes_read
;
4113 printf (" %8.8lx ", offset
+ (start
- *start_ptr
));
4115 if (start
>= section_end
)
4117 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4122 SAFE_BYTE_GET_AND_INC (entry_type
, start
, 1, section_end
);
4125 case 0: /* A terminating entry. */
4127 printf (_("<End of list>\n"));
4129 case 1: /* A base-address entry. */
4130 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
4131 start
+= bytes_read
;
4132 print_addr_index (idx
, 8);
4134 printf (_("(base address selection entry)\n"));
4136 case 2: /* A start/end entry. */
4137 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
4138 start
+= bytes_read
;
4139 print_addr_index (idx
, 8);
4140 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
4141 start
+= bytes_read
;
4142 print_addr_index (idx
, 8);
4144 case 3: /* A start/length entry. */
4145 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
4146 start
+= bytes_read
;
4147 print_addr_index (idx
, 8);
4148 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
4149 printf ("%08x ", idx
);
4151 case 4: /* An offset pair entry. */
4152 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
4153 printf ("%08x ", idx
);
4154 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
4155 printf ("%08x ", idx
);
4158 warn (_("Unknown location list entry type 0x%x.\n"), entry_type
);
4163 if (start
+ 2 > section_end
)
4165 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4170 SAFE_BYTE_GET_AND_INC (length
, start
, 2, section_end
);
4171 if (start
+ length
> section_end
)
4173 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4179 need_frame_base
= decode_location_expression (start
,
4184 cu_offset
, section
);
4187 if (need_frame_base
&& !has_frame_base
)
4188 printf (_(" [without DW_AT_frame_base]"));
4198 /* Sort array of indexes in ascending order of loc_offsets[idx]. */
4200 static dwarf_vma
*loc_offsets
;
4203 loc_offsets_compar (const void *ap
, const void *bp
)
4205 dwarf_vma a
= loc_offsets
[*(const unsigned int *) ap
];
4206 dwarf_vma b
= loc_offsets
[*(const unsigned int *) bp
];
4208 return (a
> b
) - (b
> a
);
4212 display_debug_loc (struct dwarf_section
*section
, void *file
)
4214 unsigned char *start
= section
->start
;
4215 unsigned long bytes
;
4216 unsigned char *section_begin
= start
;
4217 unsigned int num_loc_list
= 0;
4218 unsigned long last_offset
= 0;
4219 unsigned int first
= 0;
4223 int seen_first_offset
= 0;
4224 int locs_sorted
= 1;
4225 unsigned char *next
;
4226 unsigned int *array
= NULL
;
4227 const char *suffix
= strrchr (section
->name
, '.');
4230 if (suffix
&& strcmp (suffix
, ".dwo") == 0)
4233 bytes
= section
->size
;
4237 printf (_("\nThe %s section is empty.\n"), section
->name
);
4241 if (load_debug_info (file
) == 0)
4243 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4248 /* Check the order of location list in .debug_info section. If
4249 offsets of location lists are in the ascending order, we can
4250 use `debug_information' directly. */
4251 for (i
= 0; i
< num_debug_info_entries
; i
++)
4255 num
= debug_information
[i
].num_loc_offsets
;
4256 if (num
> num_loc_list
)
4259 /* Check if we can use `debug_information' directly. */
4260 if (locs_sorted
&& num
!= 0)
4262 if (!seen_first_offset
)
4264 /* This is the first location list. */
4265 last_offset
= debug_information
[i
].loc_offsets
[0];
4267 seen_first_offset
= 1;
4273 for (; j
< num
; j
++)
4276 debug_information
[i
].loc_offsets
[j
])
4281 last_offset
= debug_information
[i
].loc_offsets
[j
];
4286 if (!seen_first_offset
)
4287 error (_("No location lists in .debug_info section!\n"));
4289 /* DWARF sections under Mach-O have non-zero addresses. */
4290 if (debug_information
[first
].num_loc_offsets
> 0
4291 && debug_information
[first
].loc_offsets
[0] != section
->address
)
4292 warn (_("Location lists in %s section start at 0x%s\n"),
4294 dwarf_vmatoa ("x", debug_information
[first
].loc_offsets
[0]));
4297 array
= (unsigned int *) xcmalloc (num_loc_list
, sizeof (unsigned int));
4298 printf (_("Contents of the %s section:\n\n"), section
->name
);
4299 printf (_(" Offset Begin End Expression\n"));
4301 seen_first_offset
= 0;
4302 for (i
= first
; i
< num_debug_info_entries
; i
++)
4304 unsigned long offset
;
4305 unsigned long base_address
;
4310 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
4312 loc_offsets
= debug_information
[i
].loc_offsets
;
4313 qsort (array
, debug_information
[i
].num_loc_offsets
,
4314 sizeof (*array
), loc_offsets_compar
);
4317 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
4319 j
= locs_sorted
? k
: array
[k
];
4321 && debug_information
[i
].loc_offsets
[locs_sorted
4322 ? k
- 1 : array
[k
- 1]]
4323 == debug_information
[i
].loc_offsets
[j
])
4325 has_frame_base
= debug_information
[i
].have_frame_base
[j
];
4326 /* DWARF sections under Mach-O have non-zero addresses. */
4327 offset
= debug_information
[i
].loc_offsets
[j
] - section
->address
;
4328 next
= section_begin
+ offset
;
4329 base_address
= debug_information
[i
].base_address
;
4331 if (!seen_first_offset
)
4332 seen_first_offset
= 1;
4336 warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"),
4337 (unsigned long) (start
- section_begin
),
4338 (unsigned long) (next
- section_begin
));
4339 else if (start
> next
)
4340 warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"),
4341 (unsigned long) (start
- section_begin
),
4342 (unsigned long) (next
- section_begin
));
4346 if (offset
>= bytes
)
4348 warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"),
4354 display_loc_list_dwo (section
, &start
, i
, offset
, has_frame_base
);
4356 display_loc_list (section
, &start
, i
, offset
, base_address
,
4361 if (start
< section
->start
+ section
->size
)
4362 warn (_("There are %ld unused bytes at the end of section %s\n"),
4363 (long) (section
->start
+ section
->size
- start
), section
->name
);
4370 display_debug_str (struct dwarf_section
*section
,
4371 void *file ATTRIBUTE_UNUSED
)
4373 unsigned char *start
= section
->start
;
4374 unsigned long bytes
= section
->size
;
4375 dwarf_vma addr
= section
->address
;
4379 printf (_("\nThe %s section is empty.\n"), section
->name
);
4383 printf (_("Contents of the %s section:\n\n"), section
->name
);
4391 lbytes
= (bytes
> 16 ? 16 : bytes
);
4393 printf (" 0x%8.8lx ", (unsigned long) addr
);
4395 for (j
= 0; j
< 16; j
++)
4398 printf ("%2.2x", start
[j
]);
4406 for (j
= 0; j
< lbytes
; j
++)
4409 if (k
>= ' ' && k
< 0x80)
4428 display_debug_info (struct dwarf_section
*section
, void *file
)
4430 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 0);
4434 display_debug_types (struct dwarf_section
*section
, void *file
)
4436 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 1);
4440 display_trace_info (struct dwarf_section
*section
, void *file
)
4442 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 0);
4446 display_debug_aranges (struct dwarf_section
*section
,
4447 void *file ATTRIBUTE_UNUSED
)
4449 unsigned char *start
= section
->start
;
4450 unsigned char *end
= start
+ section
->size
;
4452 printf (_("Contents of the %s section:\n\n"), section
->name
);
4454 /* It does not matter if this load fails,
4455 we test for that later on. */
4456 load_debug_info (file
);
4460 unsigned char *hdrptr
;
4461 DWARF2_Internal_ARange arange
;
4462 unsigned char *addr_ranges
;
4465 unsigned char address_size
;
4468 int initial_length_size
;
4472 SAFE_BYTE_GET_AND_INC (arange
.ar_length
, hdrptr
, 4, end
);
4473 if (arange
.ar_length
== 0xffffffff)
4475 SAFE_BYTE_GET_AND_INC (arange
.ar_length
, hdrptr
, 8, end
);
4477 initial_length_size
= 12;
4482 initial_length_size
= 4;
4485 SAFE_BYTE_GET_AND_INC (arange
.ar_version
, hdrptr
, 2, end
);
4486 SAFE_BYTE_GET_AND_INC (arange
.ar_info_offset
, hdrptr
, offset_size
, end
);
4488 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
4489 && num_debug_info_entries
> 0
4490 && find_debug_info_for_offset (arange
.ar_info_offset
) == NULL
)
4491 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
4492 (unsigned long) arange
.ar_info_offset
, section
->name
);
4494 SAFE_BYTE_GET_AND_INC (arange
.ar_pointer_size
, hdrptr
, 1, end
);
4495 SAFE_BYTE_GET_AND_INC (arange
.ar_segment_size
, hdrptr
, 1, end
);
4497 if (arange
.ar_version
!= 2 && arange
.ar_version
!= 3)
4499 warn (_("Only DWARF 2 and 3 aranges are currently supported.\n"));
4503 printf (_(" Length: %ld\n"),
4504 (long) arange
.ar_length
);
4505 printf (_(" Version: %d\n"), arange
.ar_version
);
4506 printf (_(" Offset into .debug_info: 0x%lx\n"),
4507 (unsigned long) arange
.ar_info_offset
);
4508 printf (_(" Pointer Size: %d\n"), arange
.ar_pointer_size
);
4509 printf (_(" Segment Size: %d\n"), arange
.ar_segment_size
);
4511 address_size
= arange
.ar_pointer_size
+ arange
.ar_segment_size
;
4513 if (address_size
== 0)
4515 error (_("Invalid address size in %s section!\n"),
4520 /* The DWARF spec does not require that the address size be a power
4521 of two, but we do. This will have to change if we ever encounter
4522 an uneven architecture. */
4523 if ((address_size
& (address_size
- 1)) != 0)
4525 warn (_("Pointer size + Segment size is not a power of two.\n"));
4529 if (address_size
> 4)
4530 printf (_("\n Address Length\n"));
4532 printf (_("\n Address Length\n"));
4534 addr_ranges
= hdrptr
;
4536 /* Must pad to an alignment boundary that is twice the address size. */
4537 excess
= (hdrptr
- start
) % (2 * address_size
);
4539 addr_ranges
+= (2 * address_size
) - excess
;
4541 start
+= arange
.ar_length
+ initial_length_size
;
4543 while (addr_ranges
+ 2 * address_size
<= start
)
4545 SAFE_BYTE_GET_AND_INC (address
, addr_ranges
, address_size
, end
);
4546 SAFE_BYTE_GET_AND_INC (length
, addr_ranges
, address_size
, end
);
4549 print_dwarf_vma (address
, address_size
);
4550 print_dwarf_vma (length
, address_size
);
4560 /* Comparison function for qsort. */
4562 comp_addr_base (const void * v0
, const void * v1
)
4564 debug_info
* info0
= (debug_info
*) v0
;
4565 debug_info
* info1
= (debug_info
*) v1
;
4566 return info0
->addr_base
- info1
->addr_base
;
4569 /* Display the debug_addr section. */
4571 display_debug_addr (struct dwarf_section
*section
,
4574 debug_info
**debug_addr_info
;
4575 unsigned char *entry
;
4580 if (section
->size
== 0)
4582 printf (_("\nThe %s section is empty.\n"), section
->name
);
4586 if (load_debug_info (file
) == 0)
4588 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4593 printf (_("Contents of the %s section:\n\n"), section
->name
);
4595 debug_addr_info
= (debug_info
**) xmalloc ((num_debug_info_entries
+ 1)
4596 * sizeof (debug_info
*));
4599 for (i
= 0; i
< num_debug_info_entries
; i
++)
4601 if (debug_information
[i
].addr_base
!= DEBUG_INFO_UNAVAILABLE
)
4602 debug_addr_info
[count
++] = &debug_information
[i
];
4605 /* Add a sentinel to make iteration convenient. */
4606 debug_addr_info
[count
] = (debug_info
*) xmalloc (sizeof (debug_info
));
4607 debug_addr_info
[count
]->addr_base
= section
->size
;
4609 qsort (debug_addr_info
, count
, sizeof (debug_info
*), comp_addr_base
);
4610 for (i
= 0; i
< count
; i
++)
4613 unsigned int address_size
= debug_addr_info
[i
]->pointer_size
;
4615 printf (_(" For compilation unit at offset 0x%s:\n"),
4616 dwarf_vmatoa ("x", debug_addr_info
[i
]->cu_offset
));
4618 printf (_("\tIndex\tAddress\n"));
4619 entry
= section
->start
+ debug_addr_info
[i
]->addr_base
;
4620 end
= section
->start
+ debug_addr_info
[i
+ 1]->addr_base
;
4624 dwarf_vma base
= byte_get (entry
, address_size
);
4625 printf (_("\t%d:\t"), idx
);
4626 print_dwarf_vma (base
, address_size
);
4628 entry
+= address_size
;
4634 free (debug_addr_info
);
4638 /* Display the .debug_str_offsets and .debug_str_offsets.dwo sections. */
4640 display_debug_str_offsets (struct dwarf_section
*section
,
4641 void *file ATTRIBUTE_UNUSED
)
4643 if (section
->size
== 0)
4645 printf (_("\nThe %s section is empty.\n"), section
->name
);
4648 /* TODO: Dump the contents. This is made somewhat difficult by not knowing
4649 what the offset size is for this section. */
4653 /* Each debug_information[x].range_lists[y] gets this representation for
4654 sorting purposes. */
4658 /* The debug_information[x].range_lists[y] value. */
4659 unsigned long ranges_offset
;
4661 /* Original debug_information to find parameters of the data. */
4662 debug_info
*debug_info_p
;
4665 /* Sort struct range_entry in ascending order of its RANGES_OFFSET. */
4668 range_entry_compar (const void *ap
, const void *bp
)
4670 const struct range_entry
*a_re
= (const struct range_entry
*) ap
;
4671 const struct range_entry
*b_re
= (const struct range_entry
*) bp
;
4672 const unsigned long a
= a_re
->ranges_offset
;
4673 const unsigned long b
= b_re
->ranges_offset
;
4675 return (a
> b
) - (b
> a
);
4679 display_debug_ranges (struct dwarf_section
*section
,
4680 void *file ATTRIBUTE_UNUSED
)
4682 unsigned char *start
= section
->start
;
4683 unsigned char *last_start
= start
;
4684 unsigned long bytes
= section
->size
;
4685 unsigned char *section_begin
= start
;
4686 unsigned char *finish
= start
+ bytes
;
4687 unsigned int num_range_list
, i
;
4688 struct range_entry
*range_entries
, *range_entry_fill
;
4692 printf (_("\nThe %s section is empty.\n"), section
->name
);
4696 if (load_debug_info (file
) == 0)
4698 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4704 for (i
= 0; i
< num_debug_info_entries
; i
++)
4705 num_range_list
+= debug_information
[i
].num_range_lists
;
4707 if (num_range_list
== 0)
4709 /* This can happen when the file was compiled with -gsplit-debug
4710 which removes references to range lists from the primary .o file. */
4711 printf (_("No range lists in .debug_info section.\n"));
4715 range_entries
= (struct range_entry
*)
4716 xmalloc (sizeof (*range_entries
) * num_range_list
);
4717 range_entry_fill
= range_entries
;
4719 for (i
= 0; i
< num_debug_info_entries
; i
++)
4721 debug_info
*debug_info_p
= &debug_information
[i
];
4724 for (j
= 0; j
< debug_info_p
->num_range_lists
; j
++)
4726 range_entry_fill
->ranges_offset
= debug_info_p
->range_lists
[j
];
4727 range_entry_fill
->debug_info_p
= debug_info_p
;
4732 qsort (range_entries
, num_range_list
, sizeof (*range_entries
),
4733 range_entry_compar
);
4735 /* DWARF sections under Mach-O have non-zero addresses. */
4736 if (dwarf_check
!= 0 && range_entries
[0].ranges_offset
!= section
->address
)
4737 warn (_("Range lists in %s section start at 0x%lx\n"),
4738 section
->name
, range_entries
[0].ranges_offset
);
4740 printf (_("Contents of the %s section:\n\n"), section
->name
);
4741 printf (_(" Offset Begin End\n"));
4743 for (i
= 0; i
< num_range_list
; i
++)
4745 struct range_entry
*range_entry
= &range_entries
[i
];
4746 debug_info
*debug_info_p
= range_entry
->debug_info_p
;
4747 unsigned int pointer_size
;
4748 unsigned long offset
;
4749 unsigned char *next
;
4750 unsigned long base_address
;
4752 pointer_size
= debug_info_p
->pointer_size
;
4754 /* DWARF sections under Mach-O have non-zero addresses. */
4755 offset
= range_entry
->ranges_offset
- section
->address
;
4756 next
= section_begin
+ offset
;
4757 base_address
= debug_info_p
->base_address
;
4759 if (dwarf_check
!= 0 && i
> 0)
4762 warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"),
4763 (unsigned long) (start
- section_begin
),
4764 (unsigned long) (next
- section_begin
), section
->name
);
4765 else if (start
> next
)
4767 if (next
== last_start
)
4769 warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"),
4770 (unsigned long) (start
- section_begin
),
4771 (unsigned long) (next
- section_begin
), section
->name
);
4777 while (start
< finish
)
4782 /* Note: we use sign extension here in order to be sure that
4783 we can detect the -1 escape value. Sign extension into the
4784 top 32 bits of a 32-bit address will not affect the values
4785 that we display since we always show hex values, and always
4786 the bottom 32-bits. */
4787 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, finish
);
4788 if (start
>= finish
)
4790 SAFE_SIGNED_BYTE_GET_AND_INC (end
, start
, pointer_size
, finish
);
4792 printf (" %8.8lx ", offset
);
4794 if (begin
== 0 && end
== 0)
4796 printf (_("<End of list>\n"));
4800 /* Check base address specifiers. */
4801 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
4804 print_dwarf_vma (begin
, pointer_size
);
4805 print_dwarf_vma (end
, pointer_size
);
4806 printf ("(base address)\n");
4810 print_dwarf_vma (begin
+ base_address
, pointer_size
);
4811 print_dwarf_vma (end
+ base_address
, pointer_size
);
4814 fputs (_("(start == end)"), stdout
);
4815 else if (begin
> end
)
4816 fputs (_("(start > end)"), stdout
);
4823 free (range_entries
);
4828 typedef struct Frame_Chunk
4830 struct Frame_Chunk
*next
;
4831 unsigned char *chunk_start
;
4833 /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
4834 short int *col_type
;
4837 unsigned int code_factor
;
4839 unsigned long pc_begin
;
4840 unsigned long pc_range
;
4844 unsigned char fde_encoding
;
4845 unsigned char cfa_exp
;
4846 unsigned char ptr_size
;
4847 unsigned char segment_size
;
4851 static const char *const *dwarf_regnames
;
4852 static unsigned int dwarf_regnames_count
;
4854 /* A marker for a col_type that means this column was never referenced
4855 in the frame info. */
4856 #define DW_CFA_unreferenced (-1)
4858 /* Return 0 if not more space is needed, 1 if more space is needed,
4859 -1 for invalid reg. */
4862 frame_need_space (Frame_Chunk
*fc
, unsigned int reg
)
4864 int prev
= fc
->ncols
;
4866 if (reg
< (unsigned int) fc
->ncols
)
4869 if (dwarf_regnames_count
4870 && reg
> dwarf_regnames_count
)
4873 fc
->ncols
= reg
+ 1;
4874 fc
->col_type
= (short int *) xcrealloc (fc
->col_type
, fc
->ncols
,
4875 sizeof (short int));
4876 fc
->col_offset
= (int *) xcrealloc (fc
->col_offset
, fc
->ncols
, sizeof (int));
4878 while (prev
< fc
->ncols
)
4880 fc
->col_type
[prev
] = DW_CFA_unreferenced
;
4881 fc
->col_offset
[prev
] = 0;
4887 static const char *const dwarf_regnames_i386
[] =
4889 "eax", "ecx", "edx", "ebx",
4890 "esp", "ebp", "esi", "edi",
4891 "eip", "eflags", NULL
,
4892 "st0", "st1", "st2", "st3",
4893 "st4", "st5", "st6", "st7",
4895 "xmm0", "xmm1", "xmm2", "xmm3",
4896 "xmm4", "xmm5", "xmm6", "xmm7",
4897 "mm0", "mm1", "mm2", "mm3",
4898 "mm4", "mm5", "mm6", "mm7",
4899 "fcw", "fsw", "mxcsr",
4900 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
4905 init_dwarf_regnames_i386 (void)
4907 dwarf_regnames
= dwarf_regnames_i386
;
4908 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_i386
);
4911 static const char *const dwarf_regnames_x86_64
[] =
4913 "rax", "rdx", "rcx", "rbx",
4914 "rsi", "rdi", "rbp", "rsp",
4915 "r8", "r9", "r10", "r11",
4916 "r12", "r13", "r14", "r15",
4918 "xmm0", "xmm1", "xmm2", "xmm3",
4919 "xmm4", "xmm5", "xmm6", "xmm7",
4920 "xmm8", "xmm9", "xmm10", "xmm11",
4921 "xmm12", "xmm13", "xmm14", "xmm15",
4922 "st0", "st1", "st2", "st3",
4923 "st4", "st5", "st6", "st7",
4924 "mm0", "mm1", "mm2", "mm3",
4925 "mm4", "mm5", "mm6", "mm7",
4927 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
4928 "fs.base", "gs.base", NULL
, NULL
,
4930 "mxcsr", "fcw", "fsw"
4934 init_dwarf_regnames_x86_64 (void)
4936 dwarf_regnames
= dwarf_regnames_x86_64
;
4937 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_x86_64
);
4941 init_dwarf_regnames (unsigned int e_machine
)
4947 init_dwarf_regnames_i386 ();
4953 init_dwarf_regnames_x86_64 ();
4962 regname (unsigned int regno
, int row
)
4964 static char reg
[64];
4966 && regno
< dwarf_regnames_count
4967 && dwarf_regnames
[regno
] != NULL
)
4970 return dwarf_regnames
[regno
];
4971 snprintf (reg
, sizeof (reg
), "r%d (%s)", regno
,
4972 dwarf_regnames
[regno
]);
4975 snprintf (reg
, sizeof (reg
), "r%d", regno
);
4980 frame_display_row (Frame_Chunk
*fc
, int *need_col_headers
, int *max_regs
)
4985 if (*max_regs
< fc
->ncols
)
4986 *max_regs
= fc
->ncols
;
4988 if (*need_col_headers
)
4990 static const char *sloc
= " LOC";
4992 *need_col_headers
= 0;
4994 printf ("%-*s CFA ", eh_addr_size
* 2, sloc
);
4996 for (r
= 0; r
< *max_regs
; r
++)
4997 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
5002 printf ("%-5s ", regname (r
, 1));
5008 printf ("%0*lx ", eh_addr_size
* 2, fc
->pc_begin
);
5010 strcpy (tmp
, "exp");
5012 sprintf (tmp
, "%s%+d", regname (fc
->cfa_reg
, 1), fc
->cfa_offset
);
5013 printf ("%-8s ", tmp
);
5015 for (r
= 0; r
< fc
->ncols
; r
++)
5017 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
5019 switch (fc
->col_type
[r
])
5021 case DW_CFA_undefined
:
5024 case DW_CFA_same_value
:
5028 sprintf (tmp
, "c%+d", fc
->col_offset
[r
]);
5030 case DW_CFA_val_offset
:
5031 sprintf (tmp
, "v%+d", fc
->col_offset
[r
]);
5033 case DW_CFA_register
:
5034 sprintf (tmp
, "%s", regname (fc
->col_offset
[r
], 0));
5036 case DW_CFA_expression
:
5037 strcpy (tmp
, "exp");
5039 case DW_CFA_val_expression
:
5040 strcpy (tmp
, "vexp");
5043 strcpy (tmp
, "n/a");
5046 printf ("%-5s ", tmp
);
5052 #define GET(VAR, N) SAFE_BYTE_GET_AND_INC (VAR, start, N, end);
5053 #define LEB() read_uleb128 (start, & length_return, end); start += length_return
5054 #define SLEB() read_sleb128 (start, & length_return, end); start += length_return
5057 display_debug_frames (struct dwarf_section
*section
,
5058 void *file ATTRIBUTE_UNUSED
)
5060 unsigned char *start
= section
->start
;
5061 unsigned char *end
= start
+ section
->size
;
5062 unsigned char *section_start
= start
;
5063 Frame_Chunk
*chunks
= 0;
5064 Frame_Chunk
*remembered_state
= 0;
5066 int is_eh
= strcmp (section
->name
, ".eh_frame") == 0;
5067 unsigned int length_return
;
5069 const char *bad_reg
= _("bad register: ");
5070 int saved_eh_addr_size
= eh_addr_size
;
5072 printf (_("Contents of the %s section:\n"), section
->name
);
5076 unsigned char *saved_start
;
5077 unsigned char *block_end
;
5078 unsigned long length
;
5079 unsigned long cie_id
;
5082 int need_col_headers
= 1;
5083 unsigned char *augmentation_data
= NULL
;
5084 unsigned long augmentation_data_len
= 0;
5085 int encoded_ptr_size
= saved_eh_addr_size
;
5087 int initial_length_size
;
5089 saved_start
= start
;
5091 SAFE_BYTE_GET_AND_INC (length
, start
, 4, end
);
5094 printf ("\n%08lx ZERO terminator\n\n",
5095 (unsigned long)(saved_start
- section_start
));
5099 if (length
== 0xffffffff)
5101 SAFE_BYTE_GET_AND_INC (length
, start
, 8, end
);
5103 initial_length_size
= 12;
5108 initial_length_size
= 4;
5111 block_end
= saved_start
+ length
+ initial_length_size
;
5112 if (block_end
> end
)
5114 warn ("Invalid length %#08lx in FDE at %#08lx\n",
5115 length
, (unsigned long)(saved_start
- section_start
));
5119 SAFE_BYTE_GET_AND_INC (cie_id
, start
, offset_size
, end
);
5121 if (is_eh
? (cie_id
== 0) : (cie_id
== DW_CIE_ID
))
5125 fc
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
5126 memset (fc
, 0, sizeof (Frame_Chunk
));
5130 fc
->chunk_start
= saved_start
;
5132 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
5133 fc
->col_offset
= (int *) xmalloc (sizeof (int));
5134 frame_need_space (fc
, max_regs
- 1);
5138 fc
->augmentation
= (char *) start
;
5139 start
= (unsigned char *) strchr ((char *) start
, '\0') + 1;
5141 if (strcmp (fc
->augmentation
, "eh") == 0)
5142 start
+= eh_addr_size
;
5146 GET (fc
->ptr_size
, 1);
5147 GET (fc
->segment_size
, 1);
5148 eh_addr_size
= fc
->ptr_size
;
5152 fc
->ptr_size
= eh_addr_size
;
5153 fc
->segment_size
= 0;
5155 fc
->code_factor
= LEB ();
5156 fc
->data_factor
= SLEB ();
5166 if (fc
->augmentation
[0] == 'z')
5168 augmentation_data_len
= LEB ();
5169 augmentation_data
= start
;
5170 start
+= augmentation_data_len
;
5174 if (do_debug_frames_interp
)
5175 printf ("\n%08lx %08lx %08lx CIE \"%s\" cf=%d df=%d ra=%d\n",
5176 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
5177 fc
->augmentation
, fc
->code_factor
, fc
->data_factor
,
5181 printf ("\n%08lx %08lx %08lx CIE\n",
5182 (unsigned long)(saved_start
- section_start
), length
, cie_id
);
5183 printf (" Version: %d\n", version
);
5184 printf (" Augmentation: \"%s\"\n", fc
->augmentation
);
5187 printf (" Pointer Size: %u\n", fc
->ptr_size
);
5188 printf (" Segment Size: %u\n", fc
->segment_size
);
5190 printf (" Code alignment factor: %u\n", fc
->code_factor
);
5191 printf (" Data alignment factor: %d\n", fc
->data_factor
);
5192 printf (" Return address column: %d\n", fc
->ra
);
5194 if (augmentation_data_len
)
5197 printf (" Augmentation data: ");
5198 for (i
= 0; i
< augmentation_data_len
; ++i
)
5199 printf (" %02x", augmentation_data
[i
]);
5205 if (augmentation_data_len
)
5207 unsigned char *p
, *q
;
5208 p
= (unsigned char *) fc
->augmentation
+ 1;
5209 q
= augmentation_data
;
5216 q
+= 1 + size_of_encoded_value (*q
);
5218 fc
->fde_encoding
= *q
++;
5226 if (fc
->fde_encoding
)
5227 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
5230 frame_need_space (fc
, fc
->ra
);
5234 unsigned char *look_for
;
5235 static Frame_Chunk fde_fc
;
5236 unsigned long segment_selector
;
5239 memset (fc
, 0, sizeof (Frame_Chunk
));
5241 look_for
= is_eh
? start
- 4 - cie_id
: section_start
+ cie_id
;
5243 for (cie
= chunks
; cie
; cie
= cie
->next
)
5244 if (cie
->chunk_start
== look_for
)
5249 warn ("Invalid CIE pointer %#08lx in FDE at %#08lx\n",
5250 cie_id
, (unsigned long)(saved_start
- section_start
));
5252 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
5253 fc
->col_offset
= (int *) xmalloc (sizeof (int));
5254 frame_need_space (fc
, max_regs
- 1);
5256 fc
->augmentation
= "";
5257 fc
->fde_encoding
= 0;
5258 fc
->ptr_size
= eh_addr_size
;
5259 fc
->segment_size
= 0;
5263 fc
->ncols
= cie
->ncols
;
5264 fc
->col_type
= (short int *) xcmalloc (fc
->ncols
, sizeof (short int));
5265 fc
->col_offset
= (int *) xcmalloc (fc
->ncols
, sizeof (int));
5266 memcpy (fc
->col_type
, cie
->col_type
, fc
->ncols
* sizeof (short int));
5267 memcpy (fc
->col_offset
, cie
->col_offset
, fc
->ncols
* sizeof (int));
5268 fc
->augmentation
= cie
->augmentation
;
5269 fc
->ptr_size
= cie
->ptr_size
;
5270 eh_addr_size
= cie
->ptr_size
;
5271 fc
->segment_size
= cie
->segment_size
;
5272 fc
->code_factor
= cie
->code_factor
;
5273 fc
->data_factor
= cie
->data_factor
;
5274 fc
->cfa_reg
= cie
->cfa_reg
;
5275 fc
->cfa_offset
= cie
->cfa_offset
;
5277 frame_need_space (fc
, max_regs
- 1);
5278 fc
->fde_encoding
= cie
->fde_encoding
;
5281 if (fc
->fde_encoding
)
5282 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
5284 segment_selector
= 0;
5285 if (fc
->segment_size
)
5287 SAFE_BYTE_GET_AND_INC (segment_selector
, start
, fc
->segment_size
, end
);
5289 fc
->pc_begin
= get_encoded_value (start
, fc
->fde_encoding
, section
);
5290 start
+= encoded_ptr_size
;
5292 /* FIXME: It appears that sometimes the final pc_range value is
5293 encoded in less than encoded_ptr_size bytes. See the x86_64
5294 run of the "objcopy on compressed debug sections" test for an
5296 SAFE_BYTE_GET_AND_INC (fc
->pc_range
, start
, encoded_ptr_size
, end
);
5298 if (cie
->augmentation
[0] == 'z')
5300 augmentation_data_len
= LEB ();
5301 augmentation_data
= start
;
5302 start
+= augmentation_data_len
;
5305 printf ("\n%08lx %08lx %08lx FDE cie=%08lx pc=",
5306 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
5307 (unsigned long)(cie
->chunk_start
- section_start
));
5308 if (fc
->segment_size
)
5309 printf ("%04lx:", segment_selector
);
5310 printf ("%08lx..%08lx\n", fc
->pc_begin
, fc
->pc_begin
+ fc
->pc_range
);
5311 if (! do_debug_frames_interp
&& augmentation_data_len
)
5315 printf (" Augmentation data: ");
5316 for (i
= 0; i
< augmentation_data_len
; ++i
)
5317 printf (" %02x", augmentation_data
[i
]);
5323 /* At this point, fc is the current chunk, cie (if any) is set, and
5324 we're about to interpret instructions for the chunk. */
5325 /* ??? At present we need to do this always, since this sizes the
5326 fc->col_type and fc->col_offset arrays, which we write into always.
5327 We should probably split the interpreted and non-interpreted bits
5328 into two different routines, since there's so much that doesn't
5329 really overlap between them. */
5330 if (1 || do_debug_frames_interp
)
5332 /* Start by making a pass over the chunk, allocating storage
5333 and taking note of what registers are used. */
5334 unsigned char *tmp
= start
;
5336 while (start
< block_end
)
5339 unsigned long reg
, temp
;
5346 /* Warning: if you add any more cases to this switch, be
5347 sure to add them to the corresponding switch below. */
5350 case DW_CFA_advance_loc
:
5354 if (frame_need_space (fc
, opa
) >= 0)
5355 fc
->col_type
[opa
] = DW_CFA_undefined
;
5357 case DW_CFA_restore
:
5358 if (frame_need_space (fc
, opa
) >= 0)
5359 fc
->col_type
[opa
] = DW_CFA_undefined
;
5361 case DW_CFA_set_loc
:
5362 start
+= encoded_ptr_size
;
5364 case DW_CFA_advance_loc1
:
5367 case DW_CFA_advance_loc2
:
5370 case DW_CFA_advance_loc4
:
5373 case DW_CFA_offset_extended
:
5374 case DW_CFA_val_offset
:
5375 reg
= LEB (); LEB ();
5376 if (frame_need_space (fc
, reg
) >= 0)
5377 fc
->col_type
[reg
] = DW_CFA_undefined
;
5379 case DW_CFA_restore_extended
:
5381 frame_need_space (fc
, reg
);
5382 if (frame_need_space (fc
, reg
) >= 0)
5383 fc
->col_type
[reg
] = DW_CFA_undefined
;
5385 case DW_CFA_undefined
:
5387 if (frame_need_space (fc
, reg
) >= 0)
5388 fc
->col_type
[reg
] = DW_CFA_undefined
;
5390 case DW_CFA_same_value
:
5392 if (frame_need_space (fc
, reg
) >= 0)
5393 fc
->col_type
[reg
] = DW_CFA_undefined
;
5395 case DW_CFA_register
:
5396 reg
= LEB (); LEB ();
5397 if (frame_need_space (fc
, reg
) >= 0)
5398 fc
->col_type
[reg
] = DW_CFA_undefined
;
5400 case DW_CFA_def_cfa
:
5403 case DW_CFA_def_cfa_register
:
5406 case DW_CFA_def_cfa_offset
:
5409 case DW_CFA_def_cfa_expression
:
5413 case DW_CFA_expression
:
5414 case DW_CFA_val_expression
:
5418 if (frame_need_space (fc
, reg
) >= 0)
5419 fc
->col_type
[reg
] = DW_CFA_undefined
;
5421 case DW_CFA_offset_extended_sf
:
5422 case DW_CFA_val_offset_sf
:
5423 reg
= LEB (); SLEB ();
5424 if (frame_need_space (fc
, reg
) >= 0)
5425 fc
->col_type
[reg
] = DW_CFA_undefined
;
5427 case DW_CFA_def_cfa_sf
:
5430 case DW_CFA_def_cfa_offset_sf
:
5433 case DW_CFA_MIPS_advance_loc8
:
5436 case DW_CFA_GNU_args_size
:
5439 case DW_CFA_GNU_negative_offset_extended
:
5440 reg
= LEB (); LEB ();
5441 if (frame_need_space (fc
, reg
) >= 0)
5442 fc
->col_type
[reg
] = DW_CFA_undefined
;
5451 /* Now we know what registers are used, make a second pass over
5452 the chunk, this time actually printing out the info. */
5454 while (start
< block_end
)
5457 unsigned long ul
, reg
, roffs
;
5460 const char *reg_prefix
= "";
5467 /* Warning: if you add any more cases to this switch, be
5468 sure to add them to the corresponding switch above. */
5471 case DW_CFA_advance_loc
:
5472 if (do_debug_frames_interp
)
5473 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5475 printf (" DW_CFA_advance_loc: %d to %08lx\n",
5476 opa
* fc
->code_factor
,
5477 fc
->pc_begin
+ opa
* fc
->code_factor
);
5478 fc
->pc_begin
+= opa
* fc
->code_factor
;
5483 if (opa
>= (unsigned int) fc
->ncols
)
5484 reg_prefix
= bad_reg
;
5485 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5486 printf (" DW_CFA_offset: %s%s at cfa%+ld\n",
5487 reg_prefix
, regname (opa
, 0),
5488 roffs
* fc
->data_factor
);
5489 if (*reg_prefix
== '\0')
5491 fc
->col_type
[opa
] = DW_CFA_offset
;
5492 fc
->col_offset
[opa
] = roffs
* fc
->data_factor
;
5496 case DW_CFA_restore
:
5497 if (opa
>= (unsigned int) cie
->ncols
5498 || opa
>= (unsigned int) fc
->ncols
)
5499 reg_prefix
= bad_reg
;
5500 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5501 printf (" DW_CFA_restore: %s%s\n",
5502 reg_prefix
, regname (opa
, 0));
5503 if (*reg_prefix
== '\0')
5505 fc
->col_type
[opa
] = cie
->col_type
[opa
];
5506 fc
->col_offset
[opa
] = cie
->col_offset
[opa
];
5507 if (do_debug_frames_interp
5508 && fc
->col_type
[opa
] == DW_CFA_unreferenced
)
5509 fc
->col_type
[opa
] = DW_CFA_undefined
;
5513 case DW_CFA_set_loc
:
5514 vma
= get_encoded_value (start
, fc
->fde_encoding
, section
);
5515 start
+= encoded_ptr_size
;
5516 if (do_debug_frames_interp
)
5517 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5519 printf (" DW_CFA_set_loc: %08lx\n", (unsigned long)vma
);
5523 case DW_CFA_advance_loc1
:
5524 SAFE_BYTE_GET_AND_INC (ofs
, start
, 1, end
);
5525 if (do_debug_frames_interp
)
5526 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5528 printf (" DW_CFA_advance_loc1: %ld to %08lx\n",
5529 ofs
* fc
->code_factor
,
5530 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5531 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5534 case DW_CFA_advance_loc2
:
5535 SAFE_BYTE_GET_AND_INC (ofs
, start
, 2, end
);
5536 if (do_debug_frames_interp
)
5537 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5539 printf (" DW_CFA_advance_loc2: %ld to %08lx\n",
5540 ofs
* fc
->code_factor
,
5541 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5542 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5545 case DW_CFA_advance_loc4
:
5546 SAFE_BYTE_GET_AND_INC (ofs
, start
, 4, end
);
5547 if (do_debug_frames_interp
)
5548 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5550 printf (" DW_CFA_advance_loc4: %ld to %08lx\n",
5551 ofs
* fc
->code_factor
,
5552 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5553 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5556 case DW_CFA_offset_extended
:
5559 if (reg
>= (unsigned int) fc
->ncols
)
5560 reg_prefix
= bad_reg
;
5561 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5562 printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n",
5563 reg_prefix
, regname (reg
, 0),
5564 roffs
* fc
->data_factor
);
5565 if (*reg_prefix
== '\0')
5567 fc
->col_type
[reg
] = DW_CFA_offset
;
5568 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
5572 case DW_CFA_val_offset
:
5575 if (reg
>= (unsigned int) fc
->ncols
)
5576 reg_prefix
= bad_reg
;
5577 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5578 printf (" DW_CFA_val_offset: %s%s at cfa%+ld\n",
5579 reg_prefix
, regname (reg
, 0),
5580 roffs
* fc
->data_factor
);
5581 if (*reg_prefix
== '\0')
5583 fc
->col_type
[reg
] = DW_CFA_val_offset
;
5584 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
5588 case DW_CFA_restore_extended
:
5590 if (reg
>= (unsigned int) cie
->ncols
5591 || reg
>= (unsigned int) fc
->ncols
)
5592 reg_prefix
= bad_reg
;
5593 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5594 printf (" DW_CFA_restore_extended: %s%s\n",
5595 reg_prefix
, regname (reg
, 0));
5596 if (*reg_prefix
== '\0')
5598 fc
->col_type
[reg
] = cie
->col_type
[reg
];
5599 fc
->col_offset
[reg
] = cie
->col_offset
[reg
];
5603 case DW_CFA_undefined
:
5605 if (reg
>= (unsigned int) fc
->ncols
)
5606 reg_prefix
= bad_reg
;
5607 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5608 printf (" DW_CFA_undefined: %s%s\n",
5609 reg_prefix
, regname (reg
, 0));
5610 if (*reg_prefix
== '\0')
5612 fc
->col_type
[reg
] = DW_CFA_undefined
;
5613 fc
->col_offset
[reg
] = 0;
5617 case DW_CFA_same_value
:
5619 if (reg
>= (unsigned int) fc
->ncols
)
5620 reg_prefix
= bad_reg
;
5621 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5622 printf (" DW_CFA_same_value: %s%s\n",
5623 reg_prefix
, regname (reg
, 0));
5624 if (*reg_prefix
== '\0')
5626 fc
->col_type
[reg
] = DW_CFA_same_value
;
5627 fc
->col_offset
[reg
] = 0;
5631 case DW_CFA_register
:
5634 if (reg
>= (unsigned int) fc
->ncols
)
5635 reg_prefix
= bad_reg
;
5636 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5638 printf (" DW_CFA_register: %s%s in ",
5639 reg_prefix
, regname (reg
, 0));
5640 puts (regname (roffs
, 0));
5642 if (*reg_prefix
== '\0')
5644 fc
->col_type
[reg
] = DW_CFA_register
;
5645 fc
->col_offset
[reg
] = roffs
;
5649 case DW_CFA_remember_state
:
5650 if (! do_debug_frames_interp
)
5651 printf (" DW_CFA_remember_state\n");
5652 rs
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
5653 rs
->ncols
= fc
->ncols
;
5654 rs
->col_type
= (short int *) xcmalloc (rs
->ncols
,
5655 sizeof (short int));
5656 rs
->col_offset
= (int *) xcmalloc (rs
->ncols
, sizeof (int));
5657 memcpy (rs
->col_type
, fc
->col_type
, rs
->ncols
);
5658 memcpy (rs
->col_offset
, fc
->col_offset
, rs
->ncols
* sizeof (int));
5659 rs
->next
= remembered_state
;
5660 remembered_state
= rs
;
5663 case DW_CFA_restore_state
:
5664 if (! do_debug_frames_interp
)
5665 printf (" DW_CFA_restore_state\n");
5666 rs
= remembered_state
;
5669 remembered_state
= rs
->next
;
5670 frame_need_space (fc
, rs
->ncols
- 1);
5671 memcpy (fc
->col_type
, rs
->col_type
, rs
->ncols
);
5672 memcpy (fc
->col_offset
, rs
->col_offset
,
5673 rs
->ncols
* sizeof (int));
5674 free (rs
->col_type
);
5675 free (rs
->col_offset
);
5678 else if (do_debug_frames_interp
)
5679 printf ("Mismatched DW_CFA_restore_state\n");
5682 case DW_CFA_def_cfa
:
5683 fc
->cfa_reg
= LEB ();
5684 fc
->cfa_offset
= LEB ();
5686 if (! do_debug_frames_interp
)
5687 printf (" DW_CFA_def_cfa: %s ofs %d\n",
5688 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
5691 case DW_CFA_def_cfa_register
:
5692 fc
->cfa_reg
= LEB ();
5694 if (! do_debug_frames_interp
)
5695 printf (" DW_CFA_def_cfa_register: %s\n",
5696 regname (fc
->cfa_reg
, 0));
5699 case DW_CFA_def_cfa_offset
:
5700 fc
->cfa_offset
= LEB ();
5701 if (! do_debug_frames_interp
)
5702 printf (" DW_CFA_def_cfa_offset: %d\n", fc
->cfa_offset
);
5706 if (! do_debug_frames_interp
)
5707 printf (" DW_CFA_nop\n");
5710 case DW_CFA_def_cfa_expression
:
5712 if (! do_debug_frames_interp
)
5714 printf (" DW_CFA_def_cfa_expression (");
5715 decode_location_expression (start
, eh_addr_size
, 0, -1,
5723 case DW_CFA_expression
:
5726 if (reg
>= (unsigned int) fc
->ncols
)
5727 reg_prefix
= bad_reg
;
5728 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5730 printf (" DW_CFA_expression: %s%s (",
5731 reg_prefix
, regname (reg
, 0));
5732 decode_location_expression (start
, eh_addr_size
, 0, -1,
5736 if (*reg_prefix
== '\0')
5737 fc
->col_type
[reg
] = DW_CFA_expression
;
5741 case DW_CFA_val_expression
:
5744 if (reg
>= (unsigned int) fc
->ncols
)
5745 reg_prefix
= bad_reg
;
5746 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5748 printf (" DW_CFA_val_expression: %s%s (",
5749 reg_prefix
, regname (reg
, 0));
5750 decode_location_expression (start
, eh_addr_size
, 0, -1,
5754 if (*reg_prefix
== '\0')
5755 fc
->col_type
[reg
] = DW_CFA_val_expression
;
5759 case DW_CFA_offset_extended_sf
:
5762 if (frame_need_space (fc
, reg
) < 0)
5763 reg_prefix
= bad_reg
;
5764 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5765 printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n",
5766 reg_prefix
, regname (reg
, 0),
5767 l
* fc
->data_factor
);
5768 if (*reg_prefix
== '\0')
5770 fc
->col_type
[reg
] = DW_CFA_offset
;
5771 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
5775 case DW_CFA_val_offset_sf
:
5778 if (frame_need_space (fc
, reg
) < 0)
5779 reg_prefix
= bad_reg
;
5780 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5781 printf (" DW_CFA_val_offset_sf: %s%s at cfa%+ld\n",
5782 reg_prefix
, regname (reg
, 0),
5783 l
* fc
->data_factor
);
5784 if (*reg_prefix
== '\0')
5786 fc
->col_type
[reg
] = DW_CFA_val_offset
;
5787 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
5791 case DW_CFA_def_cfa_sf
:
5792 fc
->cfa_reg
= LEB ();
5793 fc
->cfa_offset
= SLEB ();
5794 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
5796 if (! do_debug_frames_interp
)
5797 printf (" DW_CFA_def_cfa_sf: %s ofs %d\n",
5798 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
5801 case DW_CFA_def_cfa_offset_sf
:
5802 fc
->cfa_offset
= SLEB ();
5803 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
5804 if (! do_debug_frames_interp
)
5805 printf (" DW_CFA_def_cfa_offset_sf: %d\n", fc
->cfa_offset
);
5808 case DW_CFA_MIPS_advance_loc8
:
5809 SAFE_BYTE_GET_AND_INC (ofs
, start
, 8, end
);
5810 if (do_debug_frames_interp
)
5811 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5813 printf (" DW_CFA_MIPS_advance_loc8: %ld to %08lx\n",
5814 ofs
* fc
->code_factor
,
5815 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5816 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5819 case DW_CFA_GNU_window_save
:
5820 if (! do_debug_frames_interp
)
5821 printf (" DW_CFA_GNU_window_save\n");
5824 case DW_CFA_GNU_args_size
:
5826 if (! do_debug_frames_interp
)
5827 printf (" DW_CFA_GNU_args_size: %ld\n", ul
);
5830 case DW_CFA_GNU_negative_offset_extended
:
5833 if (frame_need_space (fc
, reg
) < 0)
5834 reg_prefix
= bad_reg
;
5835 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5836 printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n",
5837 reg_prefix
, regname (reg
, 0),
5838 l
* fc
->data_factor
);
5839 if (*reg_prefix
== '\0')
5841 fc
->col_type
[reg
] = DW_CFA_offset
;
5842 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
5847 if (op
>= DW_CFA_lo_user
&& op
<= DW_CFA_hi_user
)
5848 printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op
);
5850 warn (_("unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op
);
5855 if (do_debug_frames_interp
)
5856 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5859 eh_addr_size
= saved_eh_addr_size
;
5872 display_gdb_index (struct dwarf_section
*section
,
5873 void *file ATTRIBUTE_UNUSED
)
5875 unsigned char *start
= section
->start
;
5877 uint32_t cu_list_offset
, tu_list_offset
;
5878 uint32_t address_table_offset
, symbol_table_offset
, constant_pool_offset
;
5879 unsigned int cu_list_elements
, tu_list_elements
;
5880 unsigned int address_table_size
, symbol_table_slots
;
5881 unsigned char *cu_list
, *tu_list
;
5882 unsigned char *address_table
, *symbol_table
, *constant_pool
;
5885 /* The documentation for the format of this file is in gdb/dwarf2read.c. */
5887 printf (_("Contents of the %s section:\n"), section
->name
);
5889 if (section
->size
< 6 * sizeof (uint32_t))
5891 warn (_("Truncated header in the %s section.\n"), section
->name
);
5895 version
= byte_get_little_endian (start
, 4);
5896 printf (_("Version %ld\n"), (long) version
);
5898 /* Prior versions are obsolete, and future versions may not be
5899 backwards compatible. */
5900 if (version
< 3 || version
> 8)
5902 warn (_("Unsupported version %lu.\n"), (unsigned long) version
);
5906 warn (_("The address table data in version 3 may be wrong.\n"));
5908 warn (_("Version 4 does not support case insensitive lookups.\n"));
5910 warn (_("Version 5 does not include inlined functions.\n"));
5912 warn (_("Version 6 does not include symbol attributes.\n"));
5913 /* Version 7 indices generated by Gold have bad type unit references,
5914 PR binutils/15021. But we don't know if the index was generated by
5915 Gold or not, so to avoid worrying users with gdb-generated indices
5916 we say nothing for version 7 here. */
5918 cu_list_offset
= byte_get_little_endian (start
+ 4, 4);
5919 tu_list_offset
= byte_get_little_endian (start
+ 8, 4);
5920 address_table_offset
= byte_get_little_endian (start
+ 12, 4);
5921 symbol_table_offset
= byte_get_little_endian (start
+ 16, 4);
5922 constant_pool_offset
= byte_get_little_endian (start
+ 20, 4);
5924 if (cu_list_offset
> section
->size
5925 || tu_list_offset
> section
->size
5926 || address_table_offset
> section
->size
5927 || symbol_table_offset
> section
->size
5928 || constant_pool_offset
> section
->size
)
5930 warn (_("Corrupt header in the %s section.\n"), section
->name
);
5934 cu_list_elements
= (tu_list_offset
- cu_list_offset
) / 8;
5935 tu_list_elements
= (address_table_offset
- tu_list_offset
) / 8;
5936 address_table_size
= symbol_table_offset
- address_table_offset
;
5937 symbol_table_slots
= (constant_pool_offset
- symbol_table_offset
) / 8;
5939 cu_list
= start
+ cu_list_offset
;
5940 tu_list
= start
+ tu_list_offset
;
5941 address_table
= start
+ address_table_offset
;
5942 symbol_table
= start
+ symbol_table_offset
;
5943 constant_pool
= start
+ constant_pool_offset
;
5945 printf (_("\nCU table:\n"));
5946 for (i
= 0; i
< cu_list_elements
; i
+= 2)
5948 uint64_t cu_offset
= byte_get_little_endian (cu_list
+ i
* 8, 8);
5949 uint64_t cu_length
= byte_get_little_endian (cu_list
+ i
* 8 + 8, 8);
5951 printf (_("[%3u] 0x%lx - 0x%lx\n"), i
/ 2,
5952 (unsigned long) cu_offset
,
5953 (unsigned long) (cu_offset
+ cu_length
- 1));
5956 printf (_("\nTU table:\n"));
5957 for (i
= 0; i
< tu_list_elements
; i
+= 3)
5959 uint64_t tu_offset
= byte_get_little_endian (tu_list
+ i
* 8, 8);
5960 uint64_t type_offset
= byte_get_little_endian (tu_list
+ i
* 8 + 8, 8);
5961 uint64_t signature
= byte_get_little_endian (tu_list
+ i
* 8 + 16, 8);
5963 printf (_("[%3u] 0x%lx 0x%lx "), i
/ 3,
5964 (unsigned long) tu_offset
,
5965 (unsigned long) type_offset
);
5966 print_dwarf_vma (signature
, 8);
5970 printf (_("\nAddress table:\n"));
5971 for (i
= 0; i
< address_table_size
; i
+= 2 * 8 + 4)
5973 uint64_t low
= byte_get_little_endian (address_table
+ i
, 8);
5974 uint64_t high
= byte_get_little_endian (address_table
+ i
+ 8, 8);
5975 uint32_t cu_index
= byte_get_little_endian (address_table
+ i
+ 16, 4);
5977 print_dwarf_vma (low
, 8);
5978 print_dwarf_vma (high
, 8);
5979 printf (_("%lu\n"), (unsigned long) cu_index
);
5982 printf (_("\nSymbol table:\n"));
5983 for (i
= 0; i
< symbol_table_slots
; ++i
)
5985 uint32_t name_offset
= byte_get_little_endian (symbol_table
+ i
* 8, 4);
5986 uint32_t cu_vector_offset
= byte_get_little_endian (symbol_table
+ i
* 8 + 4, 4);
5987 uint32_t num_cus
, cu
;
5989 if (name_offset
!= 0
5990 || cu_vector_offset
!= 0)
5994 printf ("[%3u] %s:", i
, constant_pool
+ name_offset
);
5995 num_cus
= byte_get_little_endian (constant_pool
+ cu_vector_offset
, 4);
5998 for (j
= 0; j
< num_cus
; ++j
)
6001 gdb_index_symbol_kind kind
;
6003 cu
= byte_get_little_endian (constant_pool
+ cu_vector_offset
+ 4 + j
* 4, 4);
6004 is_static
= GDB_INDEX_SYMBOL_STATIC_VALUE (cu
);
6005 kind
= GDB_INDEX_SYMBOL_KIND_VALUE (cu
);
6006 cu
= GDB_INDEX_CU_VALUE (cu
);
6007 /* Convert to TU number if it's for a type unit. */
6008 if (cu
>= cu_list_elements
/ 2)
6009 printf ("%cT%lu", num_cus
> 1 ? '\t' : ' ',
6010 (unsigned long) (cu
- cu_list_elements
/ 2));
6012 printf ("%c%lu", num_cus
> 1 ? '\t' : ' ', (unsigned long) cu
);
6016 case GDB_INDEX_SYMBOL_KIND_NONE
:
6017 printf (_(" [no symbol information]"));
6019 case GDB_INDEX_SYMBOL_KIND_TYPE
:
6021 ? _(" [static type]")
6022 : _(" [global type]"));
6024 case GDB_INDEX_SYMBOL_KIND_VARIABLE
:
6026 ? _(" [static variable]")
6027 : _(" [global variable]"));
6029 case GDB_INDEX_SYMBOL_KIND_FUNCTION
:
6031 ? _(" [static function]")
6032 : _(" [global function]"));
6034 case GDB_INDEX_SYMBOL_KIND_OTHER
:
6036 ? _(" [static other]")
6037 : _(" [global other]"));
6041 ? _(" [static unknown: %d]")
6042 : _(" [global unknown: %d]"),
6057 /* Pre-allocate enough space for the CU/TU sets needed. */
6060 prealloc_cu_tu_list (unsigned int nshndx
)
6062 if (shndx_pool
== NULL
)
6064 shndx_pool_size
= nshndx
;
6065 shndx_pool_used
= 0;
6066 shndx_pool
= (unsigned int *) xcmalloc (shndx_pool_size
,
6067 sizeof (unsigned int));
6071 shndx_pool_size
= shndx_pool_used
+ nshndx
;
6072 shndx_pool
= (unsigned int *) xcrealloc (shndx_pool
, shndx_pool_size
,
6073 sizeof (unsigned int));
6078 add_shndx_to_cu_tu_entry (unsigned int shndx
)
6080 if (shndx_pool_used
>= shndx_pool_size
)
6082 error (_("Internal error: out of space in the shndx pool.\n"));
6085 shndx_pool
[shndx_pool_used
++] = shndx
;
6089 end_cu_tu_entry (void)
6091 if (shndx_pool_used
>= shndx_pool_size
)
6093 error (_("Internal error: out of space in the shndx pool.\n"));
6096 shndx_pool
[shndx_pool_used
++] = 0;
6099 /* Return the short name of a DWARF section given by a DW_SECT enumerator. */
6102 get_DW_SECT_short_name (unsigned int dw_sect
)
6104 static char buf
[16];
6112 case DW_SECT_ABBREV
:
6118 case DW_SECT_STR_OFFSETS
:
6120 case DW_SECT_MACINFO
:
6128 snprintf (buf
, sizeof (buf
), "%d", dw_sect
);
6132 /* Process a CU or TU index. If DO_DISPLAY is true, print the contents.
6133 These sections are extensions for Fission.
6134 See http://gcc.gnu.org/wiki/DebugFissionDWP. */
6137 process_cu_tu_index (struct dwarf_section
*section
, int do_display
)
6139 unsigned char *phdr
= section
->start
;
6140 unsigned char *limit
= phdr
+ section
->size
;
6141 unsigned char *phash
;
6142 unsigned char *pindex
;
6143 unsigned char *ppool
;
6144 unsigned int version
;
6145 unsigned int ncols
= 0;
6147 unsigned int nslots
;
6150 dwarf_vma signature_high
;
6151 dwarf_vma signature_low
;
6154 version
= byte_get (phdr
, 4);
6156 ncols
= byte_get (phdr
+ 4, 4);
6157 nused
= byte_get (phdr
+ 8, 4);
6158 nslots
= byte_get (phdr
+ 12, 4);
6160 pindex
= phash
+ nslots
* 8;
6161 ppool
= pindex
+ nslots
* 4;
6165 printf (_("Contents of the %s section:\n\n"), section
->name
);
6166 printf (_(" Version: %d\n"), version
);
6168 printf (_(" Number of columns: %d\n"), ncols
);
6169 printf (_(" Number of used entries: %d\n"), nused
);
6170 printf (_(" Number of slots: %d\n\n"), nslots
);
6175 warn (_("Section %s too small for %d hash table entries\n"),
6176 section
->name
, nslots
);
6183 prealloc_cu_tu_list ((limit
- ppool
) / 4);
6184 for (i
= 0; i
< nslots
; i
++)
6186 unsigned char *shndx_list
;
6189 byte_get_64 (phash
, &signature_high
, &signature_low
);
6190 if (signature_high
!= 0 || signature_low
!= 0)
6192 j
= byte_get (pindex
, 4);
6193 shndx_list
= ppool
+ j
* 4;
6195 printf (_(" [%3d] Signature: 0x%s Sections: "),
6196 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
6197 buf
, sizeof (buf
)));
6200 if (shndx_list
>= limit
)
6202 warn (_("Section %s too small for shndx pool\n"),
6206 shndx
= byte_get (shndx_list
, 4);
6210 printf (" %d", shndx
);
6212 add_shndx_to_cu_tu_entry (shndx
);
6224 else if (version
== 2)
6227 unsigned int dw_sect
;
6228 unsigned char *ph
= phash
;
6229 unsigned char *pi
= pindex
;
6230 unsigned char *poffsets
= ppool
+ ncols
* 4;
6231 unsigned char *psizes
= poffsets
+ nused
* ncols
* 4;
6232 unsigned char *pend
= psizes
+ nused
* ncols
* 4;
6233 bfd_boolean is_tu_index
;
6234 struct cu_tu_set
*this_set
= NULL
;
6236 unsigned char *prow
;
6238 is_tu_index
= strcmp (section
->name
, ".debug_tu_index") == 0;
6242 warn (_("Section %s too small for offset and size tables\n"),
6249 printf (_(" Offset table\n"));
6250 printf (" slot %-16s ",
6251 is_tu_index
? _("signature") : _("dwo_id"));
6258 tu_sets
= xcmalloc (nused
, sizeof (struct cu_tu_set
));
6264 cu_sets
= xcmalloc (nused
, sizeof (struct cu_tu_set
));
6270 for (j
= 0; j
< ncols
; j
++)
6272 dw_sect
= byte_get (ppool
+ j
* 4, 4);
6273 printf (" %8s", get_DW_SECT_short_name (dw_sect
));
6277 for (i
= 0; i
< nslots
; i
++)
6279 byte_get_64 (ph
, &signature_high
, &signature_low
);
6280 row
= byte_get (pi
, 4);
6284 memcpy (&this_set
[row
- 1].signature
, ph
, sizeof (uint64_t));
6285 prow
= poffsets
+ (row
- 1) * ncols
* 4;
6287 printf (_(" [%3d] 0x%s"),
6288 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
6289 buf
, sizeof (buf
)));
6290 for (j
= 0; j
< ncols
; j
++)
6292 val
= byte_get (prow
+ j
* 4, 4);
6294 printf (" %8d", val
);
6297 dw_sect
= byte_get (ppool
+ j
* 4, 4);
6298 this_set
[row
- 1].section_offsets
[dw_sect
] = val
;
6313 printf (_(" Size table\n"));
6314 printf (" slot %-16s ",
6315 is_tu_index
? _("signature") : _("dwo_id"));
6317 for (j
= 0; j
< ncols
; j
++)
6319 val
= byte_get (ppool
+ j
* 4, 4);
6321 printf (" %8s", get_DW_SECT_short_name (val
));
6325 for (i
= 0; i
< nslots
; i
++)
6327 byte_get_64 (ph
, &signature_high
, &signature_low
);
6328 row
= byte_get (pi
, 4);
6331 prow
= psizes
+ (row
- 1) * ncols
* 4;
6333 printf (_(" [%3d] 0x%s"),
6334 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
6335 buf
, sizeof (buf
)));
6336 for (j
= 0; j
< ncols
; j
++)
6338 val
= byte_get (prow
+ j
* 4, 4);
6340 printf (" %8d", val
);
6343 dw_sect
= byte_get (ppool
+ j
* 4, 4);
6344 this_set
[row
- 1].section_sizes
[dw_sect
] = val
;
6354 else if (do_display
)
6355 printf (_(" Unsupported version\n"));
6363 /* Load the CU and TU indexes if present. This will build a list of
6364 section sets that we can use to associate a .debug_info.dwo section
6365 with its associated .debug_abbrev.dwo section in a .dwp file. */
6368 load_cu_tu_indexes (void *file
)
6370 /* If we have already loaded (or tried to load) the CU and TU indexes
6371 then do not bother to repeat the task. */
6372 if (cu_tu_indexes_read
)
6375 if (load_debug_section (dwp_cu_index
, file
))
6376 process_cu_tu_index (&debug_displays
[dwp_cu_index
].section
, 0);
6378 if (load_debug_section (dwp_tu_index
, file
))
6379 process_cu_tu_index (&debug_displays
[dwp_tu_index
].section
, 0);
6381 cu_tu_indexes_read
= 1;
6384 /* Find the set of sections that includes section SHNDX. */
6387 find_cu_tu_set (void *file
, unsigned int shndx
)
6391 load_cu_tu_indexes (file
);
6393 /* Find SHNDX in the shndx pool. */
6394 for (i
= 0; i
< shndx_pool_used
; i
++)
6395 if (shndx_pool
[i
] == shndx
)
6398 if (i
>= shndx_pool_used
)
6401 /* Now backup to find the first entry in the set. */
6402 while (i
> 0 && shndx_pool
[i
- 1] != 0)
6405 return shndx_pool
+ i
;
6408 /* Display a .debug_cu_index or .debug_tu_index section. */
6411 display_cu_index (struct dwarf_section
*section
, void *file ATTRIBUTE_UNUSED
)
6413 return process_cu_tu_index (section
, 1);
6417 display_debug_not_supported (struct dwarf_section
*section
,
6418 void *file ATTRIBUTE_UNUSED
)
6420 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
6427 cmalloc (size_t nmemb
, size_t size
)
6429 /* Check for overflow. */
6430 if (nmemb
>= ~(size_t) 0 / size
)
6433 return malloc (nmemb
* size
);
6437 xcmalloc (size_t nmemb
, size_t size
)
6439 /* Check for overflow. */
6440 if (nmemb
>= ~(size_t) 0 / size
)
6443 return xmalloc (nmemb
* size
);
6447 xcrealloc (void *ptr
, size_t nmemb
, size_t size
)
6449 /* Check for overflow. */
6450 if (nmemb
>= ~(size_t) 0 / size
)
6453 return xrealloc (ptr
, nmemb
* size
);
6457 free_debug_memory (void)
6463 for (i
= 0; i
< max
; i
++)
6464 free_debug_section ((enum dwarf_section_display_enum
) i
);
6466 if (debug_information
!= NULL
)
6468 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
)
6470 for (i
= 0; i
< num_debug_info_entries
; i
++)
6472 if (!debug_information
[i
].max_loc_offsets
)
6474 free (debug_information
[i
].loc_offsets
);
6475 free (debug_information
[i
].have_frame_base
);
6477 if (!debug_information
[i
].max_range_lists
)
6478 free (debug_information
[i
].range_lists
);
6482 free (debug_information
);
6483 debug_information
= NULL
;
6484 num_debug_info_entries
= 0;
6489 dwarf_select_sections_by_names (const char *names
)
6493 const char * option
;
6497 debug_dump_long_opts
;
6499 static const debug_dump_long_opts opts_table
[] =
6501 /* Please keep this table alpha- sorted. */
6502 { "Ranges", & do_debug_ranges
, 1 },
6503 { "abbrev", & do_debug_abbrevs
, 1 },
6504 { "addr", & do_debug_addr
, 1 },
6505 { "aranges", & do_debug_aranges
, 1 },
6506 { "cu_index", & do_debug_cu_index
, 1 },
6507 { "decodedline", & do_debug_lines
, FLAG_DEBUG_LINES_DECODED
},
6508 { "frames", & do_debug_frames
, 1 },
6509 { "frames-interp", & do_debug_frames_interp
, 1 },
6510 /* The special .gdb_index section. */
6511 { "gdb_index", & do_gdb_index
, 1 },
6512 { "info", & do_debug_info
, 1 },
6513 { "line", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
}, /* For backwards compatibility. */
6514 { "loc", & do_debug_loc
, 1 },
6515 { "macro", & do_debug_macinfo
, 1 },
6516 { "pubnames", & do_debug_pubnames
, 1 },
6517 { "pubtypes", & do_debug_pubtypes
, 1 },
6518 /* This entry is for compatability
6519 with earlier versions of readelf. */
6520 { "ranges", & do_debug_aranges
, 1 },
6521 { "rawline", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
},
6522 { "str", & do_debug_str
, 1 },
6523 /* These trace_* sections are used by Itanium VMS. */
6524 { "trace_abbrev", & do_trace_abbrevs
, 1 },
6525 { "trace_aranges", & do_trace_aranges
, 1 },
6526 { "trace_info", & do_trace_info
, 1 },
6535 const debug_dump_long_opts
* entry
;
6537 for (entry
= opts_table
; entry
->option
; entry
++)
6539 size_t len
= strlen (entry
->option
);
6541 if (strncmp (p
, entry
->option
, len
) == 0
6542 && (p
[len
] == ',' || p
[len
] == '\0'))
6544 * entry
->variable
|= entry
->val
;
6546 /* The --debug-dump=frames-interp option also
6547 enables the --debug-dump=frames option. */
6548 if (do_debug_frames_interp
)
6549 do_debug_frames
= 1;
6556 if (entry
->option
== NULL
)
6558 warn (_("Unrecognized debug option '%s'\n"), p
);
6559 p
= strchr (p
, ',');
6570 dwarf_select_sections_by_letters (const char *letters
)
6572 unsigned int lindex
= 0;
6574 while (letters
[lindex
])
6575 switch (letters
[lindex
++])
6582 do_debug_abbrevs
= 1;
6586 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
6590 do_debug_lines
|= FLAG_DEBUG_LINES_DECODED
;
6594 do_debug_pubnames
= 1;
6598 do_debug_pubtypes
= 1;
6602 do_debug_aranges
= 1;
6606 do_debug_ranges
= 1;
6610 do_debug_frames_interp
= 1;
6612 do_debug_frames
= 1;
6616 do_debug_macinfo
= 1;
6628 warn (_("Unrecognized debug option '%s'\n"), optarg
);
6634 dwarf_select_sections_all (void)
6637 do_debug_abbrevs
= 1;
6638 do_debug_lines
= FLAG_DEBUG_LINES_RAW
;
6639 do_debug_pubnames
= 1;
6640 do_debug_pubtypes
= 1;
6641 do_debug_aranges
= 1;
6642 do_debug_ranges
= 1;
6643 do_debug_frames
= 1;
6644 do_debug_macinfo
= 1;
6649 do_trace_abbrevs
= 1;
6650 do_trace_aranges
= 1;
6652 do_debug_cu_index
= 1;
6655 struct dwarf_section_display debug_displays
[] =
6657 { { ".debug_abbrev", ".zdebug_abbrev", NULL
, NULL
, 0, 0, 0 },
6658 display_debug_abbrev
, &do_debug_abbrevs
, 0 },
6659 { { ".debug_aranges", ".zdebug_aranges", NULL
, NULL
, 0, 0, 0 },
6660 display_debug_aranges
, &do_debug_aranges
, 1 },
6661 { { ".debug_frame", ".zdebug_frame", NULL
, NULL
, 0, 0, 0 },
6662 display_debug_frames
, &do_debug_frames
, 1 },
6663 { { ".debug_info", ".zdebug_info", NULL
, NULL
, 0, 0, abbrev
},
6664 display_debug_info
, &do_debug_info
, 1 },
6665 { { ".debug_line", ".zdebug_line", NULL
, NULL
, 0, 0, 0 },
6666 display_debug_lines
, &do_debug_lines
, 1 },
6667 { { ".debug_pubnames", ".zdebug_pubnames", NULL
, NULL
, 0, 0, 0 },
6668 display_debug_pubnames
, &do_debug_pubnames
, 0 },
6669 { { ".eh_frame", "", NULL
, NULL
, 0, 0, 0 },
6670 display_debug_frames
, &do_debug_frames
, 1 },
6671 { { ".debug_macinfo", ".zdebug_macinfo", NULL
, NULL
, 0, 0, 0 },
6672 display_debug_macinfo
, &do_debug_macinfo
, 0 },
6673 { { ".debug_macro", ".zdebug_macro", NULL
, NULL
, 0, 0, 0 },
6674 display_debug_macro
, &do_debug_macinfo
, 1 },
6675 { { ".debug_str", ".zdebug_str", NULL
, NULL
, 0, 0, 0 },
6676 display_debug_str
, &do_debug_str
, 0 },
6677 { { ".debug_loc", ".zdebug_loc", NULL
, NULL
, 0, 0, 0 },
6678 display_debug_loc
, &do_debug_loc
, 1 },
6679 { { ".debug_pubtypes", ".zdebug_pubtypes", NULL
, NULL
, 0, 0, 0 },
6680 display_debug_pubnames
, &do_debug_pubtypes
, 0 },
6681 { { ".debug_ranges", ".zdebug_ranges", NULL
, NULL
, 0, 0, 0 },
6682 display_debug_ranges
, &do_debug_ranges
, 1 },
6683 { { ".debug_static_func", ".zdebug_static_func", NULL
, NULL
, 0, 0, 0 },
6684 display_debug_not_supported
, NULL
, 0 },
6685 { { ".debug_static_vars", ".zdebug_static_vars", NULL
, NULL
, 0, 0, 0 },
6686 display_debug_not_supported
, NULL
, 0 },
6687 { { ".debug_types", ".zdebug_types", NULL
, NULL
, 0, 0, abbrev
},
6688 display_debug_types
, &do_debug_info
, 1 },
6689 { { ".debug_weaknames", ".zdebug_weaknames", NULL
, NULL
, 0, 0, 0 },
6690 display_debug_not_supported
, NULL
, 0 },
6691 { { ".gdb_index", "", NULL
, NULL
, 0, 0, 0 },
6692 display_gdb_index
, &do_gdb_index
, 0 },
6693 { { ".trace_info", "", NULL
, NULL
, 0, 0, trace_abbrev
},
6694 display_trace_info
, &do_trace_info
, 1 },
6695 { { ".trace_abbrev", "", NULL
, NULL
, 0, 0, 0 },
6696 display_debug_abbrev
, &do_trace_abbrevs
, 0 },
6697 { { ".trace_aranges", "", NULL
, NULL
, 0, 0, 0 },
6698 display_debug_aranges
, &do_trace_aranges
, 0 },
6699 { { ".debug_info.dwo", ".zdebug_info.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6700 display_debug_info
, &do_debug_info
, 1 },
6701 { { ".debug_abbrev.dwo", ".zdebug_abbrev.dwo", NULL
, NULL
, 0, 0, 0 },
6702 display_debug_abbrev
, &do_debug_abbrevs
, 0 },
6703 { { ".debug_types.dwo", ".zdebug_types.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6704 display_debug_types
, &do_debug_info
, 1 },
6705 { { ".debug_line.dwo", ".zdebug_line.dwo", NULL
, NULL
, 0, 0, 0 },
6706 display_debug_lines
, &do_debug_lines
, 1 },
6707 { { ".debug_loc.dwo", ".zdebug_loc.dwo", NULL
, NULL
, 0, 0, 0 },
6708 display_debug_loc
, &do_debug_loc
, 1 },
6709 { { ".debug_macro.dwo", ".zdebug_macro.dwo", NULL
, NULL
, 0, 0, 0 },
6710 display_debug_macro
, &do_debug_macinfo
, 1 },
6711 { { ".debug_macinfo.dwo", ".zdebug_macinfo.dwo", NULL
, NULL
, 0, 0, 0 },
6712 display_debug_macinfo
, &do_debug_macinfo
, 0 },
6713 { { ".debug_str.dwo", ".zdebug_str.dwo", NULL
, NULL
, 0, 0, 0 },
6714 display_debug_str
, &do_debug_str
, 1 },
6715 { { ".debug_str_offsets", ".zdebug_str_offsets", NULL
, NULL
, 0, 0, 0 },
6716 display_debug_str_offsets
, NULL
, 0 },
6717 { { ".debug_str_offsets.dwo", ".zdebug_str_offsets.dwo", NULL
, NULL
, 0, 0, 0 },
6718 display_debug_str_offsets
, NULL
, 0 },
6719 { { ".debug_addr", ".zdebug_addr", NULL
, NULL
, 0, 0, 0 },
6720 display_debug_addr
, &do_debug_addr
, 1 },
6721 { { ".debug_cu_index", "", NULL
, NULL
, 0, 0, 0 },
6722 display_cu_index
, &do_debug_cu_index
, 0 },
6723 { { ".debug_tu_index", "", NULL
, NULL
, 0, 0, 0 },
6724 display_cu_index
, &do_debug_cu_index
, 0 },