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 #if !HAVE_DECL_STRNLEN
33 size_t strnlen (const char *, size_t);
36 static const char *regname (unsigned int regno
, int row
);
38 static int have_frame_base
;
39 static int need_base_address
;
41 static unsigned int last_pointer_size
= 0;
42 static int warned_about_missing_comp_units
= FALSE
;
44 static unsigned int num_debug_info_entries
= 0;
45 static debug_info
*debug_information
= NULL
;
46 /* Special value for num_debug_info_entries to indicate
47 that the .debug_info section could not be loaded/parsed. */
48 #define DEBUG_INFO_UNAVAILABLE (unsigned int) -1
55 int do_debug_pubnames
;
56 int do_debug_pubtypes
;
60 int do_debug_frames_interp
;
69 int do_debug_cu_index
;
72 int dwarf_cutoff_level
= -1;
73 unsigned long dwarf_start_die
;
77 /* Collection of CU/TU section sets from .debug_cu_index and .debug_tu_index
78 sections. For version 1 package files, each set is stored in SHNDX_POOL
79 as a zero-terminated list of section indexes comprising one set of debug
80 sections from a .dwo file. */
82 static int cu_tu_indexes_read
= 0;
83 static unsigned int *shndx_pool
= NULL
;
84 static unsigned int shndx_pool_size
= 0;
85 static unsigned int shndx_pool_used
= 0;
87 /* For version 2 package files, each set contains an array of section offsets
88 and an array of section sizes, giving the offset and size of the
89 contribution from a CU or TU within one of the debug sections.
90 When displaying debug info from a package file, we need to use these
91 tables to locate the corresponding contributions to each section. */
96 dwarf_vma section_offsets
[DW_SECT_MAX
];
97 size_t section_sizes
[DW_SECT_MAX
];
100 static int cu_count
= 0;
101 static int tu_count
= 0;
102 static struct cu_tu_set
*cu_sets
= NULL
;
103 static struct cu_tu_set
*tu_sets
= NULL
;
105 static void load_cu_tu_indexes (void *file
);
107 /* Values for do_debug_lines. */
108 #define FLAG_DEBUG_LINES_RAW 1
109 #define FLAG_DEBUG_LINES_DECODED 2
112 size_of_encoded_value (int encoding
)
114 switch (encoding
& 0x7)
117 case 0: return eh_addr_size
;
125 get_encoded_value (unsigned char *data
,
127 struct dwarf_section
*section
)
129 int size
= size_of_encoded_value (encoding
);
132 if (encoding
& DW_EH_PE_signed
)
133 val
= byte_get_signed (data
, size
);
135 val
= byte_get (data
, size
);
137 if ((encoding
& 0x70) == DW_EH_PE_pcrel
)
138 val
+= section
->address
+ (data
- section
->start
);
142 /* Print a dwarf_vma value (typically an address, offset or length) in
143 hexadecimal format, followed by a space. The length of the value (and
144 hence the precision displayed) is determined by the byte_size parameter. */
147 print_dwarf_vma (dwarf_vma val
, unsigned byte_size
)
149 static char buff
[18];
152 /* Printf does not have a way of specifiying a maximum field width for an
153 integer value, so we print the full value into a buffer and then select
154 the precision we need. */
155 #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
157 snprintf (buff
, sizeof (buff
), "%16.16llx ", val
);
159 snprintf (buff
, sizeof (buff
), "%016I64x ", val
);
162 snprintf (buff
, sizeof (buff
), "%16.16lx ", val
);
167 if (byte_size
> 0 && byte_size
<= 8)
168 offset
= 16 - 2 * byte_size
;
170 error (_("Wrong size in print_dwarf_vma"));
173 fputs (buff
+ offset
, stdout
);
176 #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
178 #define DWARF_VMA_FMT "ll"
180 #define DWARF_VMA_FMT "I64"
183 #define DWARF_VMA_FMT "l"
187 dwarf_vmatoa (const char *fmtch
, dwarf_vma value
)
189 /* As dwarf_vmatoa is used more then once in a printf call
190 for output, we are cycling through an fixed array of pointers
191 for return address. */
192 static int buf_pos
= 0;
193 static struct dwarf_vmatoa_buf
200 sprintf (fmt
, "%%%s%s", DWARF_VMA_FMT
, fmtch
);
202 ret
= buf
[buf_pos
++].place
;
203 buf_pos
%= ARRAY_SIZE (buf
);
205 snprintf (ret
, sizeof (buf
[0].place
), fmt
, value
);
210 /* Format a 64-bit value, given as two 32-bit values, in hex.
211 For reentrancy, this uses a buffer provided by the caller. */
214 dwarf_vmatoa64 (dwarf_vma hvalue
, dwarf_vma lvalue
, char *buf
,
215 unsigned int buf_len
)
220 snprintf (buf
, buf_len
, "%" DWARF_VMA_FMT
"x", lvalue
);
223 len
= snprintf (buf
, buf_len
, "%" DWARF_VMA_FMT
"x", hvalue
);
224 snprintf (buf
+ len
, buf_len
- len
,
225 "%08" DWARF_VMA_FMT
"x", lvalue
);
231 /* Read in a LEB128 encoded value starting at address DATA.
232 If SIGN is true, return a signed LEB128 value.
233 If LENGTH_RETURN is not NULL, return in it the number of bytes read.
234 No bytes will be read at address END or beyond. */
237 read_leb128 (unsigned char *data
,
238 unsigned int *length_return
,
240 const unsigned char * const end
)
242 dwarf_vma result
= 0;
243 unsigned int num_read
= 0;
244 unsigned int shift
= 0;
245 unsigned char byte
= 0;
252 result
|= ((dwarf_vma
) (byte
& 0x7f)) << shift
;
255 if ((byte
& 0x80) == 0)
259 if (length_return
!= NULL
)
260 *length_return
= num_read
;
262 if (sign
&& (shift
< 8 * sizeof (result
)) && (byte
& 0x40))
263 result
|= -1L << shift
;
268 /* Create a signed version to avoid painful typecasts. */
269 static inline dwarf_signed_vma
270 read_sleb128 (unsigned char * data
,
271 unsigned int * length_return
,
272 const unsigned char * const end
)
274 return (dwarf_signed_vma
) read_leb128 (data
, length_return
, TRUE
, end
);
277 static inline dwarf_vma
278 read_uleb128 (unsigned char * data
,
279 unsigned int * length_return
,
280 const unsigned char * const end
)
282 return read_leb128 (data
, length_return
, FALSE
, end
);
285 #define SAFE_BYTE_GET(VAL, PTR, AMOUNT, END) \
288 unsigned int amount = (AMOUNT); \
289 if (((PTR) + amount) >= (END)) \
292 amount = (END) - (PTR); \
297 VAL = byte_get ((PTR), amount); \
303 #define SAFE_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \
306 SAFE_BYTE_GET (VAL, PTR, AMOUNT, END); \
311 #define SAFE_SIGNED_BYTE_GET(VAL, PTR, AMOUNT, END) \
314 unsigned int amount = (AMOUNT); \
315 if (((PTR) + amount) >= (END)) \
318 amount = (END) - (PTR); \
323 VAL = byte_get_signed ((PTR), amount); \
329 #define SAFE_SIGNED_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \
332 SAFE_SIGNED_BYTE_GET (VAL, PTR, AMOUNT, END); \
337 #define SAFE_BYTE_GET64(PTR, HIGH, LOW, END) \
340 if (((PTR) + 8) <= (END)) \
342 byte_get_64 ((PTR), (HIGH), (LOW)); \
346 * (LOW) = * (HIGH) = 0; \
351 typedef struct State_Machine_Registers
359 unsigned char op_index
;
360 unsigned char end_sequence
;
361 /* This variable hold the number of the last entry seen
362 in the File Table. */
363 unsigned int last_file_entry
;
366 static SMR state_machine_regs
;
369 reset_state_machine (int is_stmt
)
371 state_machine_regs
.address
= 0;
372 state_machine_regs
.op_index
= 0;
373 state_machine_regs
.file
= 1;
374 state_machine_regs
.line
= 1;
375 state_machine_regs
.column
= 0;
376 state_machine_regs
.is_stmt
= is_stmt
;
377 state_machine_regs
.basic_block
= 0;
378 state_machine_regs
.end_sequence
= 0;
379 state_machine_regs
.last_file_entry
= 0;
382 /* Handled an extend line op.
383 Returns the number of bytes read. */
386 process_extended_line_op (unsigned char * data
,
390 unsigned char op_code
;
391 unsigned int bytes_read
;
394 unsigned char *orig_data
= data
;
397 len
= read_uleb128 (data
, & bytes_read
, end
);
400 if (len
== 0 || data
== end
)
402 warn (_("badly formed extended line op encountered!\n"));
409 printf (_(" Extended opcode %d: "), op_code
);
413 case DW_LNE_end_sequence
:
414 printf (_("End of Sequence\n\n"));
415 reset_state_machine (is_stmt
);
418 case DW_LNE_set_address
:
419 SAFE_BYTE_GET (adr
, data
, len
- bytes_read
- 1, end
);
420 printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr
));
421 state_machine_regs
.address
= adr
;
422 state_machine_regs
.op_index
= 0;
425 case DW_LNE_define_file
:
426 printf (_("define new File Table entry\n"));
427 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
428 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
431 data
+= strnlen ((char *) data
, end
- data
) + 1;
432 printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
434 printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
436 printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
438 printf ("%s\n\n", name
);
440 if (((unsigned int) (data
- orig_data
) != len
) || data
== end
)
441 warn (_("DW_LNE_define_file: Bad opcode length\n"));
444 case DW_LNE_set_discriminator
:
445 printf (_("set Discriminator to %s\n"),
446 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
450 case DW_LNE_HP_negate_is_UV_update
:
451 printf ("DW_LNE_HP_negate_is_UV_update\n");
453 case DW_LNE_HP_push_context
:
454 printf ("DW_LNE_HP_push_context\n");
456 case DW_LNE_HP_pop_context
:
457 printf ("DW_LNE_HP_pop_context\n");
459 case DW_LNE_HP_set_file_line_column
:
460 printf ("DW_LNE_HP_set_file_line_column\n");
462 case DW_LNE_HP_set_routine_name
:
463 printf ("DW_LNE_HP_set_routine_name\n");
465 case DW_LNE_HP_set_sequence
:
466 printf ("DW_LNE_HP_set_sequence\n");
468 case DW_LNE_HP_negate_post_semantics
:
469 printf ("DW_LNE_HP_negate_post_semantics\n");
471 case DW_LNE_HP_negate_function_exit
:
472 printf ("DW_LNE_HP_negate_function_exit\n");
474 case DW_LNE_HP_negate_front_end_logical
:
475 printf ("DW_LNE_HP_negate_front_end_logical\n");
477 case DW_LNE_HP_define_proc
:
478 printf ("DW_LNE_HP_define_proc\n");
480 case DW_LNE_HP_source_file_correlation
:
482 unsigned char *edata
= data
+ len
- bytes_read
- 1;
484 printf ("DW_LNE_HP_source_file_correlation\n");
490 opc
= read_uleb128 (data
, & bytes_read
, edata
);
495 case DW_LNE_HP_SFC_formfeed
:
496 printf (" DW_LNE_HP_SFC_formfeed\n");
498 case DW_LNE_HP_SFC_set_listing_line
:
499 printf (" DW_LNE_HP_SFC_set_listing_line (%s)\n",
501 read_uleb128 (data
, & bytes_read
, edata
)));
504 case DW_LNE_HP_SFC_associate
:
505 printf (" DW_LNE_HP_SFC_associate ");
508 read_uleb128 (data
, & bytes_read
, edata
)));
512 read_uleb128 (data
, & bytes_read
, edata
)));
516 read_uleb128 (data
, & bytes_read
, edata
)));
520 printf (_(" UNKNOWN DW_LNE_HP_SFC opcode (%u)\n"), opc
);
530 unsigned int rlen
= len
- bytes_read
- 1;
532 if (op_code
>= DW_LNE_lo_user
533 /* The test against DW_LNW_hi_user is redundant due to
534 the limited range of the unsigned char data type used
536 /*&& op_code <= DW_LNE_hi_user*/)
537 printf (_("user defined: "));
539 printf (_("UNKNOWN: "));
540 printf (_("length %d ["), rlen
);
542 printf (" %02x", *data
++);
551 static const unsigned char *
552 fetch_indirect_string (dwarf_vma offset
)
554 struct dwarf_section
*section
= &debug_displays
[str
].section
;
556 if (section
->start
== NULL
)
557 return (const unsigned char *) _("<no .debug_str section>");
559 /* DWARF sections under Mach-O have non-zero addresses. */
560 offset
-= section
->address
;
561 if (offset
> section
->size
)
563 warn (_("DW_FORM_strp offset too big: %s\n"),
564 dwarf_vmatoa ("x", offset
));
565 return (const unsigned char *) _("<offset is too big>");
568 return (const unsigned char *) section
->start
+ offset
;
572 fetch_indexed_string (dwarf_vma idx
, struct cu_tu_set
*this_set
,
573 dwarf_vma offset_size
, int dwo
)
575 enum dwarf_section_display_enum str_sec_idx
= dwo
? str_dwo
: str
;
576 enum dwarf_section_display_enum idx_sec_idx
= dwo
? str_index_dwo
: str_index
;
577 struct dwarf_section
*index_section
= &debug_displays
[idx_sec_idx
].section
;
578 struct dwarf_section
*str_section
= &debug_displays
[str_sec_idx
].section
;
579 dwarf_vma index_offset
= idx
* offset_size
;
580 dwarf_vma str_offset
;
582 if (index_section
->start
== NULL
)
583 return (dwo
? _("<no .debug_str_offsets.dwo section>")
584 : _("<no .debug_str_offsets section>"));
586 /* DWARF sections under Mach-O have non-zero addresses. */
587 index_offset
-= index_section
->address
;
588 if (this_set
!= NULL
)
589 index_offset
+= this_set
->section_offsets
[DW_SECT_STR_OFFSETS
];
590 if (index_offset
> index_section
->size
)
592 warn (_("DW_FORM_GNU_str_index offset too big: %s\n"),
593 dwarf_vmatoa ("x", index_offset
));
594 return _("<index offset is too big>");
597 if (str_section
->start
== NULL
)
598 return (dwo
? _("<no .debug_str.dwo section>")
599 : _("<no .debug_str section>"));
601 str_offset
= byte_get (index_section
->start
+ index_offset
, offset_size
);
602 str_offset
-= str_section
->address
;
603 if (str_offset
> str_section
->size
)
605 warn (_("DW_FORM_GNU_str_index indirect offset too big: %s\n"),
606 dwarf_vmatoa ("x", str_offset
));
607 return _("<indirect index offset is too big>");
610 return (const char *) str_section
->start
+ str_offset
;
614 fetch_indexed_value (dwarf_vma offset
, dwarf_vma bytes
)
616 struct dwarf_section
*section
= &debug_displays
[debug_addr
].section
;
618 if (section
->start
== NULL
)
619 return (_("<no .debug_addr section>"));
621 if (offset
+ bytes
> section
->size
)
623 warn (_("Offset into section %s too big: %s\n"),
624 section
->name
, dwarf_vmatoa ("x", offset
));
625 return "<offset too big>";
628 return dwarf_vmatoa ("x", byte_get (section
->start
+ offset
, bytes
));
632 /* FIXME: There are better and more efficient ways to handle
633 these structures. For now though, I just want something that
634 is simple to implement. */
635 typedef struct abbrev_attr
637 unsigned long attribute
;
639 struct abbrev_attr
*next
;
643 typedef struct abbrev_entry
648 struct abbrev_attr
*first_attr
;
649 struct abbrev_attr
*last_attr
;
650 struct abbrev_entry
*next
;
654 static abbrev_entry
*first_abbrev
= NULL
;
655 static abbrev_entry
*last_abbrev
= NULL
;
662 for (abbrv
= first_abbrev
; abbrv
;)
664 abbrev_entry
*next_abbrev
= abbrv
->next
;
667 for (attr
= abbrv
->first_attr
; attr
;)
669 abbrev_attr
*next_attr
= attr
->next
;
679 last_abbrev
= first_abbrev
= NULL
;
683 add_abbrev (unsigned long number
, unsigned long tag
, int children
)
687 entry
= (abbrev_entry
*) malloc (sizeof (*entry
));
692 entry
->entry
= number
;
694 entry
->children
= children
;
695 entry
->first_attr
= NULL
;
696 entry
->last_attr
= NULL
;
699 if (first_abbrev
== NULL
)
700 first_abbrev
= entry
;
702 last_abbrev
->next
= entry
;
708 add_abbrev_attr (unsigned long attribute
, unsigned long form
)
712 attr
= (abbrev_attr
*) malloc (sizeof (*attr
));
717 attr
->attribute
= attribute
;
721 if (last_abbrev
->first_attr
== NULL
)
722 last_abbrev
->first_attr
= attr
;
724 last_abbrev
->last_attr
->next
= attr
;
726 last_abbrev
->last_attr
= attr
;
729 /* Processes the (partial) contents of a .debug_abbrev section.
730 Returns NULL if the end of the section was encountered.
731 Returns the address after the last byte read if the end of
732 an abbreviation set was found. */
734 static unsigned char *
735 process_abbrev_section (unsigned char *start
, unsigned char *end
)
737 if (first_abbrev
!= NULL
)
742 unsigned int bytes_read
;
745 unsigned long attribute
;
748 entry
= read_uleb128 (start
, & bytes_read
, end
);
751 /* A single zero is supposed to end the section according
752 to the standard. If there's more, then signal that to
759 tag
= read_uleb128 (start
, & bytes_read
, end
);
766 add_abbrev (entry
, tag
, children
);
772 attribute
= read_uleb128 (start
, & bytes_read
, end
);
777 form
= read_uleb128 (start
, & bytes_read
, end
);
782 add_abbrev_attr (attribute
, form
);
784 while (attribute
!= 0);
787 /* Report the missing single zero which ends the section. */
788 error (_(".debug_abbrev section not zero terminated\n"));
794 get_TAG_name (unsigned long tag
)
796 const char *name
= get_DW_TAG_name ((unsigned int)tag
);
800 static char buffer
[100];
802 snprintf (buffer
, sizeof (buffer
), _("Unknown TAG value: %lx"), tag
);
810 get_FORM_name (unsigned long form
)
815 return "DW_FORM value: 0";
817 name
= get_DW_FORM_name (form
);
820 static char buffer
[100];
822 snprintf (buffer
, sizeof (buffer
), _("Unknown FORM value: %lx"), form
);
829 static unsigned char *
830 display_block (unsigned char *data
,
832 const unsigned char * const end
)
836 printf (_(" %s byte block: "), dwarf_vmatoa ("u", length
));
838 maxlen
= (dwarf_vma
) (end
- data
);
839 length
= length
> maxlen
? maxlen
: length
;
842 printf ("%lx ", (unsigned long) byte_get (data
++, 1));
848 decode_location_expression (unsigned char * data
,
849 unsigned int pointer_size
,
850 unsigned int offset_size
,
854 struct dwarf_section
* section
)
857 unsigned int bytes_read
;
859 dwarf_signed_vma svalue
;
860 unsigned char *end
= data
+ length
;
861 int need_frame_base
= 0;
870 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
871 printf ("DW_OP_addr: %s", dwarf_vmatoa ("x", uvalue
));
874 printf ("DW_OP_deref");
877 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
878 printf ("DW_OP_const1u: %lu", (unsigned long) uvalue
);
881 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 1, end
);
882 printf ("DW_OP_const1s: %ld", (long) svalue
);
885 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 2, end
);
886 printf ("DW_OP_const2u: %lu", (unsigned long) uvalue
);
889 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
890 printf ("DW_OP_const2s: %ld", (long) svalue
);
893 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
894 printf ("DW_OP_const4u: %lu", (unsigned long) uvalue
);
897 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
898 printf ("DW_OP_const4s: %ld", (long) svalue
);
901 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
902 printf ("DW_OP_const8u: %lu ", (unsigned long) uvalue
);
903 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
904 printf ("%lu", (unsigned long) uvalue
);
907 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
908 printf ("DW_OP_const8s: %ld ", (long) svalue
);
909 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
910 printf ("%ld", (long) svalue
);
913 printf ("DW_OP_constu: %s",
914 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
918 printf ("DW_OP_consts: %s",
919 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
923 printf ("DW_OP_dup");
926 printf ("DW_OP_drop");
929 printf ("DW_OP_over");
932 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
933 printf ("DW_OP_pick: %ld", (unsigned long) uvalue
);
936 printf ("DW_OP_swap");
939 printf ("DW_OP_rot");
942 printf ("DW_OP_xderef");
945 printf ("DW_OP_abs");
948 printf ("DW_OP_and");
951 printf ("DW_OP_div");
954 printf ("DW_OP_minus");
957 printf ("DW_OP_mod");
960 printf ("DW_OP_mul");
963 printf ("DW_OP_neg");
966 printf ("DW_OP_not");
972 printf ("DW_OP_plus");
974 case DW_OP_plus_uconst
:
975 printf ("DW_OP_plus_uconst: %s",
976 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
980 printf ("DW_OP_shl");
983 printf ("DW_OP_shr");
986 printf ("DW_OP_shra");
989 printf ("DW_OP_xor");
992 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
993 printf ("DW_OP_bra: %ld", (long) svalue
);
1002 printf ("DW_OP_gt");
1005 printf ("DW_OP_le");
1008 printf ("DW_OP_lt");
1011 printf ("DW_OP_ne");
1014 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
1015 printf ("DW_OP_skip: %ld", (long) svalue
);
1050 printf ("DW_OP_lit%d", op
- DW_OP_lit0
);
1085 printf ("DW_OP_reg%d (%s)", op
- DW_OP_reg0
,
1086 regname (op
- DW_OP_reg0
, 1));
1121 printf ("DW_OP_breg%d (%s): %s",
1123 regname (op
- DW_OP_breg0
, 1),
1124 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
1129 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1131 printf ("DW_OP_regx: %s (%s)",
1132 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1));
1135 need_frame_base
= 1;
1136 printf ("DW_OP_fbreg: %s",
1137 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
1141 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1143 printf ("DW_OP_bregx: %s (%s) %s",
1144 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1),
1145 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
1149 printf ("DW_OP_piece: %s",
1150 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1153 case DW_OP_deref_size
:
1154 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1155 printf ("DW_OP_deref_size: %ld", (long) uvalue
);
1157 case DW_OP_xderef_size
:
1158 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1159 printf ("DW_OP_xderef_size: %ld", (long) uvalue
);
1162 printf ("DW_OP_nop");
1165 /* DWARF 3 extensions. */
1166 case DW_OP_push_object_address
:
1167 printf ("DW_OP_push_object_address");
1170 /* XXX: Strictly speaking for 64-bit DWARF3 files
1171 this ought to be an 8-byte wide computation. */
1172 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
1173 printf ("DW_OP_call2: <0x%s>",
1174 dwarf_vmatoa ("x", svalue
+ cu_offset
));
1177 /* XXX: Strictly speaking for 64-bit DWARF3 files
1178 this ought to be an 8-byte wide computation. */
1179 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
1180 printf ("DW_OP_call4: <0x%s>",
1181 dwarf_vmatoa ("x", svalue
+ cu_offset
));
1183 case DW_OP_call_ref
:
1184 /* XXX: Strictly speaking for 64-bit DWARF3 files
1185 this ought to be an 8-byte wide computation. */
1186 if (dwarf_version
== -1)
1188 printf (_("(DW_OP_call_ref in frame info)"));
1189 /* No way to tell where the next op is, so just bail. */
1190 return need_frame_base
;
1192 if (dwarf_version
== 2)
1194 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1198 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1200 printf ("DW_OP_call_ref: <0x%s>", dwarf_vmatoa ("x", uvalue
));
1202 case DW_OP_form_tls_address
:
1203 printf ("DW_OP_form_tls_address");
1205 case DW_OP_call_frame_cfa
:
1206 printf ("DW_OP_call_frame_cfa");
1208 case DW_OP_bit_piece
:
1209 printf ("DW_OP_bit_piece: ");
1210 printf (_("size: %s "),
1211 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1213 printf (_("offset: %s "),
1214 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1218 /* DWARF 4 extensions. */
1219 case DW_OP_stack_value
:
1220 printf ("DW_OP_stack_value");
1223 case DW_OP_implicit_value
:
1224 printf ("DW_OP_implicit_value");
1225 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1227 display_block (data
, uvalue
, end
);
1231 /* GNU extensions. */
1232 case DW_OP_GNU_push_tls_address
:
1233 printf (_("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown"));
1235 case DW_OP_GNU_uninit
:
1236 printf ("DW_OP_GNU_uninit");
1237 /* FIXME: Is there data associated with this OP ? */
1239 case DW_OP_GNU_encoded_addr
:
1245 addr
= get_encoded_value (data
, encoding
, section
);
1246 data
+= size_of_encoded_value (encoding
);
1248 printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding
);
1249 print_dwarf_vma (addr
, pointer_size
);
1252 case DW_OP_GNU_implicit_pointer
:
1253 /* XXX: Strictly speaking for 64-bit DWARF3 files
1254 this ought to be an 8-byte wide computation. */
1255 if (dwarf_version
== -1)
1257 printf (_("(DW_OP_GNU_implicit_pointer in frame info)"));
1258 /* No way to tell where the next op is, so just bail. */
1259 return need_frame_base
;
1261 if (dwarf_version
== 2)
1263 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1267 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1269 printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s",
1270 dwarf_vmatoa ("x", uvalue
),
1271 dwarf_vmatoa ("d", read_sleb128 (data
,
1272 &bytes_read
, end
)));
1275 case DW_OP_GNU_entry_value
:
1276 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1278 printf ("DW_OP_GNU_entry_value: (");
1279 if (decode_location_expression (data
, pointer_size
, offset_size
,
1280 dwarf_version
, uvalue
,
1281 cu_offset
, section
))
1282 need_frame_base
= 1;
1286 case DW_OP_GNU_const_type
:
1287 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1289 printf ("DW_OP_GNU_const_type: <0x%s> ",
1290 dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1291 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1292 display_block (data
, uvalue
, end
);
1295 case DW_OP_GNU_regval_type
:
1296 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1298 printf ("DW_OP_GNU_regval_type: %s (%s)",
1299 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1));
1300 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1302 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1304 case DW_OP_GNU_deref_type
:
1305 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1306 printf ("DW_OP_GNU_deref_type: %ld", (long) uvalue
);
1307 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1309 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1311 case DW_OP_GNU_convert
:
1312 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1314 printf ("DW_OP_GNU_convert <0x%s>",
1315 dwarf_vmatoa ("x", uvalue
? cu_offset
+ uvalue
: 0));
1317 case DW_OP_GNU_reinterpret
:
1318 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1320 printf ("DW_OP_GNU_reinterpret <0x%s>",
1321 dwarf_vmatoa ("x", uvalue
? cu_offset
+ uvalue
: 0));
1323 case DW_OP_GNU_parameter_ref
:
1324 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
1325 printf ("DW_OP_GNU_parameter_ref: <0x%s>",
1326 dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1328 case DW_OP_GNU_addr_index
:
1329 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1331 printf ("DW_OP_GNU_addr_index <0x%s>", dwarf_vmatoa ("x", uvalue
));
1333 case DW_OP_GNU_const_index
:
1334 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1336 printf ("DW_OP_GNU_const_index <0x%s>", dwarf_vmatoa ("x", uvalue
));
1339 /* HP extensions. */
1340 case DW_OP_HP_is_value
:
1341 printf ("DW_OP_HP_is_value");
1342 /* FIXME: Is there data associated with this OP ? */
1344 case DW_OP_HP_fltconst4
:
1345 printf ("DW_OP_HP_fltconst4");
1346 /* FIXME: Is there data associated with this OP ? */
1348 case DW_OP_HP_fltconst8
:
1349 printf ("DW_OP_HP_fltconst8");
1350 /* FIXME: Is there data associated with this OP ? */
1352 case DW_OP_HP_mod_range
:
1353 printf ("DW_OP_HP_mod_range");
1354 /* FIXME: Is there data associated with this OP ? */
1356 case DW_OP_HP_unmod_range
:
1357 printf ("DW_OP_HP_unmod_range");
1358 /* FIXME: Is there data associated with this OP ? */
1361 printf ("DW_OP_HP_tls");
1362 /* FIXME: Is there data associated with this OP ? */
1365 /* PGI (STMicroelectronics) extensions. */
1366 case DW_OP_PGI_omp_thread_num
:
1367 /* Pushes the thread number for the current thread as it would be
1368 returned by the standard OpenMP library function:
1369 omp_get_thread_num(). The "current thread" is the thread for
1370 which the expression is being evaluated. */
1371 printf ("DW_OP_PGI_omp_thread_num");
1375 if (op
>= DW_OP_lo_user
1376 && op
<= DW_OP_hi_user
)
1377 printf (_("(User defined location op)"));
1379 printf (_("(Unknown location op)"));
1380 /* No way to tell where the next op is, so just bail. */
1381 return need_frame_base
;
1384 /* Separate the ops. */
1389 return need_frame_base
;
1392 /* Find the CU or TU set corresponding to the given CU_OFFSET.
1393 This is used for DWARF package files. */
1395 static struct cu_tu_set
*
1396 find_cu_tu_set_v2 (dwarf_vma cu_offset
, int do_types
)
1398 struct cu_tu_set
*p
;
1400 unsigned int dw_sect
;
1406 dw_sect
= DW_SECT_TYPES
;
1412 dw_sect
= DW_SECT_INFO
;
1416 if (p
->section_offsets
[dw_sect
] == cu_offset
)
1424 static unsigned char *
1425 read_and_display_attr_value (unsigned long attribute
,
1427 unsigned char * data
,
1428 unsigned char * end
,
1429 dwarf_vma cu_offset
,
1430 dwarf_vma pointer_size
,
1431 dwarf_vma offset_size
,
1433 debug_info
* debug_info_p
,
1435 struct dwarf_section
* section
,
1436 struct cu_tu_set
* this_set
)
1438 dwarf_vma uvalue
= 0;
1439 unsigned char *block_start
= NULL
;
1440 unsigned char * orig_data
= data
;
1441 unsigned int bytes_read
;
1445 warn (_("corrupt attribute\n"));
1454 case DW_FORM_ref_addr
:
1455 if (dwarf_version
== 2)
1456 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1457 else if (dwarf_version
== 3 || dwarf_version
== 4)
1458 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1460 error (_("Internal error: DWARF version is not 2, 3 or 4.\n"));
1465 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1469 case DW_FORM_sec_offset
:
1470 case DW_FORM_GNU_ref_alt
:
1471 case DW_FORM_GNU_strp_alt
:
1472 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1475 case DW_FORM_flag_present
:
1482 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1487 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 2, end
);
1492 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
1496 uvalue
= read_sleb128 (data
, & bytes_read
, end
);
1500 case DW_FORM_GNU_str_index
:
1501 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
1505 case DW_FORM_ref_udata
:
1507 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
1511 case DW_FORM_indirect
:
1512 form
= read_uleb128 (data
, & bytes_read
, end
);
1515 printf (" %s", get_FORM_name (form
));
1516 return read_and_display_attr_value (attribute
, form
, data
, end
,
1517 cu_offset
, pointer_size
,
1518 offset_size
, dwarf_version
,
1519 debug_info_p
, do_loc
,
1521 case DW_FORM_GNU_addr_index
:
1522 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
1529 case DW_FORM_ref_addr
:
1531 printf (" <0x%s>", dwarf_vmatoa ("x",uvalue
));
1534 case DW_FORM_GNU_ref_alt
:
1536 printf (" <alt 0x%s>", dwarf_vmatoa ("x",uvalue
));
1542 case DW_FORM_ref_udata
:
1544 printf (" <0x%s>", dwarf_vmatoa ("x", uvalue
+ cu_offset
));
1549 case DW_FORM_sec_offset
:
1551 printf (" 0x%s", dwarf_vmatoa ("x", uvalue
));
1554 case DW_FORM_flag_present
:
1561 printf (" %s", dwarf_vmatoa ("d", uvalue
));
1568 dwarf_vma high_bits
;
1571 SAFE_BYTE_GET64 (data
, &high_bits
, &uvalue
, end
);
1574 dwarf_vmatoa64 (high_bits
, uvalue
, buf
, sizeof (buf
)));
1577 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1578 && num_debug_info_entries
== 0)
1580 if (sizeof (uvalue
) == 8)
1581 SAFE_BYTE_GET (uvalue
, data
, 8, end
);
1583 error (_("DW_FORM_data8 is unsupported when sizeof (dwarf_vma) != 8\n"));
1589 case DW_FORM_string
:
1591 printf (" %.*s", (int) (end
- data
), data
);
1592 data
+= strnlen ((char *) data
, end
- data
) + 1;
1596 case DW_FORM_exprloc
:
1597 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
1598 block_start
= data
+ bytes_read
;
1600 data
= block_start
+ uvalue
;
1602 data
= display_block (block_start
, uvalue
, end
);
1605 case DW_FORM_block1
:
1606 SAFE_BYTE_GET (uvalue
, data
, 1, end
);
1607 block_start
= data
+ 1;
1609 data
= block_start
+ uvalue
;
1611 data
= display_block (block_start
, uvalue
, end
);
1614 case DW_FORM_block2
:
1615 SAFE_BYTE_GET (uvalue
, data
, 2, end
);
1616 block_start
= data
+ 2;
1618 data
= block_start
+ uvalue
;
1620 data
= display_block (block_start
, uvalue
, end
);
1623 case DW_FORM_block4
:
1624 SAFE_BYTE_GET (uvalue
, data
, 4, end
);
1625 block_start
= data
+ 4;
1627 data
= block_start
+ uvalue
;
1629 data
= display_block (block_start
, uvalue
, end
);
1634 printf (_(" (indirect string, offset: 0x%s): %s"),
1635 dwarf_vmatoa ("x", uvalue
),
1636 fetch_indirect_string (uvalue
));
1639 case DW_FORM_GNU_str_index
:
1642 const char *suffix
= strrchr (section
->name
, '.');
1643 int dwo
= (suffix
&& strcmp (suffix
, ".dwo") == 0) ? 1 : 0;
1645 printf (_(" (indexed string: 0x%s): %s"),
1646 dwarf_vmatoa ("x", uvalue
),
1647 fetch_indexed_string (uvalue
, this_set
, offset_size
, dwo
));
1651 case DW_FORM_GNU_strp_alt
:
1653 printf (_(" (alt indirect string, offset: 0x%s)"),
1654 dwarf_vmatoa ("x", uvalue
));
1657 case DW_FORM_indirect
:
1658 /* Handled above. */
1661 case DW_FORM_ref_sig8
:
1664 dwarf_vma high_bits
;
1667 SAFE_BYTE_GET64 (data
, &high_bits
, &uvalue
, end
);
1668 printf (" signature: 0x%s",
1669 dwarf_vmatoa64 (high_bits
, uvalue
, buf
, sizeof (buf
)));
1674 case DW_FORM_GNU_addr_index
:
1676 printf (_(" (addr_index: 0x%s): %s"),
1677 dwarf_vmatoa ("x", uvalue
),
1678 fetch_indexed_value (uvalue
* pointer_size
, pointer_size
));
1682 warn (_("Unrecognized form: %lu\n"), form
);
1686 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1687 && num_debug_info_entries
== 0
1688 && debug_info_p
!= NULL
)
1692 case DW_AT_frame_base
:
1693 have_frame_base
= 1;
1694 case DW_AT_location
:
1695 case DW_AT_string_length
:
1696 case DW_AT_return_addr
:
1697 case DW_AT_data_member_location
:
1698 case DW_AT_vtable_elem_location
:
1700 case DW_AT_static_link
:
1701 case DW_AT_use_location
:
1702 case DW_AT_GNU_call_site_value
:
1703 case DW_AT_GNU_call_site_data_value
:
1704 case DW_AT_GNU_call_site_target
:
1705 case DW_AT_GNU_call_site_target_clobbered
:
1706 if ((dwarf_version
< 4
1707 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
1708 || form
== DW_FORM_sec_offset
)
1710 /* Process location list. */
1711 unsigned int lmax
= debug_info_p
->max_loc_offsets
;
1712 unsigned int num
= debug_info_p
->num_loc_offsets
;
1714 if (lmax
== 0 || num
>= lmax
)
1717 debug_info_p
->loc_offsets
= (dwarf_vma
*)
1718 xcrealloc (debug_info_p
->loc_offsets
,
1719 lmax
, sizeof (*debug_info_p
->loc_offsets
));
1720 debug_info_p
->have_frame_base
= (int *)
1721 xcrealloc (debug_info_p
->have_frame_base
,
1722 lmax
, sizeof (*debug_info_p
->have_frame_base
));
1723 debug_info_p
->max_loc_offsets
= lmax
;
1725 if (this_set
!= NULL
)
1726 uvalue
+= this_set
->section_offsets
[DW_SECT_LOC
];
1727 debug_info_p
->loc_offsets
[num
] = uvalue
;
1728 debug_info_p
->have_frame_base
[num
] = have_frame_base
;
1729 debug_info_p
->num_loc_offsets
++;
1734 if (need_base_address
)
1735 debug_info_p
->base_address
= uvalue
;
1738 case DW_AT_GNU_addr_base
:
1739 debug_info_p
->addr_base
= uvalue
;
1742 case DW_AT_GNU_ranges_base
:
1743 debug_info_p
->ranges_base
= uvalue
;
1747 if ((dwarf_version
< 4
1748 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
1749 || form
== DW_FORM_sec_offset
)
1751 /* Process range list. */
1752 unsigned int lmax
= debug_info_p
->max_range_lists
;
1753 unsigned int num
= debug_info_p
->num_range_lists
;
1755 if (lmax
== 0 || num
>= lmax
)
1758 debug_info_p
->range_lists
= (dwarf_vma
*)
1759 xcrealloc (debug_info_p
->range_lists
,
1760 lmax
, sizeof (*debug_info_p
->range_lists
));
1761 debug_info_p
->max_range_lists
= lmax
;
1763 debug_info_p
->range_lists
[num
] = uvalue
;
1764 debug_info_p
->num_range_lists
++;
1773 if (do_loc
|| attribute
== 0)
1776 /* For some attributes we can display further information. */
1784 case DW_INL_not_inlined
:
1785 printf (_("(not inlined)"));
1787 case DW_INL_inlined
:
1788 printf (_("(inlined)"));
1790 case DW_INL_declared_not_inlined
:
1791 printf (_("(declared as inline but ignored)"));
1793 case DW_INL_declared_inlined
:
1794 printf (_("(declared as inline and inlined)"));
1797 printf (_(" (Unknown inline attribute value: %s)"),
1798 dwarf_vmatoa ("x", uvalue
));
1803 case DW_AT_language
:
1806 /* Ordered by the numeric value of these constants. */
1807 case DW_LANG_C89
: printf ("(ANSI C)"); break;
1808 case DW_LANG_C
: printf ("(non-ANSI C)"); break;
1809 case DW_LANG_Ada83
: printf ("(Ada)"); break;
1810 case DW_LANG_C_plus_plus
: printf ("(C++)"); break;
1811 case DW_LANG_Cobol74
: printf ("(Cobol 74)"); break;
1812 case DW_LANG_Cobol85
: printf ("(Cobol 85)"); break;
1813 case DW_LANG_Fortran77
: printf ("(FORTRAN 77)"); break;
1814 case DW_LANG_Fortran90
: printf ("(Fortran 90)"); break;
1815 case DW_LANG_Pascal83
: printf ("(ANSI Pascal)"); break;
1816 case DW_LANG_Modula2
: printf ("(Modula 2)"); break;
1817 /* DWARF 2.1 values. */
1818 case DW_LANG_Java
: printf ("(Java)"); break;
1819 case DW_LANG_C99
: printf ("(ANSI C99)"); break;
1820 case DW_LANG_Ada95
: printf ("(ADA 95)"); break;
1821 case DW_LANG_Fortran95
: printf ("(Fortran 95)"); break;
1822 /* DWARF 3 values. */
1823 case DW_LANG_PLI
: printf ("(PLI)"); break;
1824 case DW_LANG_ObjC
: printf ("(Objective C)"); break;
1825 case DW_LANG_ObjC_plus_plus
: printf ("(Objective C++)"); break;
1826 case DW_LANG_UPC
: printf ("(Unified Parallel C)"); break;
1827 case DW_LANG_D
: printf ("(D)"); break;
1828 /* DWARF 4 values. */
1829 case DW_LANG_Python
: printf ("(Python)"); break;
1830 /* DWARF 5 values. */
1831 case DW_LANG_Go
: printf ("(Go)"); break;
1832 /* MIPS extension. */
1833 case DW_LANG_Mips_Assembler
: printf ("(MIPS assembler)"); break;
1834 /* UPC extension. */
1835 case DW_LANG_Upc
: printf ("(Unified Parallel C)"); break;
1837 if (uvalue
>= DW_LANG_lo_user
&& uvalue
<= DW_LANG_hi_user
)
1838 printf (_("(implementation defined: %s)"),
1839 dwarf_vmatoa ("x", uvalue
));
1841 printf (_("(Unknown: %s)"), dwarf_vmatoa ("x", uvalue
));
1846 case DW_AT_encoding
:
1849 case DW_ATE_void
: printf ("(void)"); break;
1850 case DW_ATE_address
: printf ("(machine address)"); break;
1851 case DW_ATE_boolean
: printf ("(boolean)"); break;
1852 case DW_ATE_complex_float
: printf ("(complex float)"); break;
1853 case DW_ATE_float
: printf ("(float)"); break;
1854 case DW_ATE_signed
: printf ("(signed)"); break;
1855 case DW_ATE_signed_char
: printf ("(signed char)"); break;
1856 case DW_ATE_unsigned
: printf ("(unsigned)"); break;
1857 case DW_ATE_unsigned_char
: printf ("(unsigned char)"); break;
1858 /* DWARF 2.1 values: */
1859 case DW_ATE_imaginary_float
: printf ("(imaginary float)"); break;
1860 case DW_ATE_decimal_float
: printf ("(decimal float)"); break;
1861 /* DWARF 3 values: */
1862 case DW_ATE_packed_decimal
: printf ("(packed_decimal)"); break;
1863 case DW_ATE_numeric_string
: printf ("(numeric_string)"); break;
1864 case DW_ATE_edited
: printf ("(edited)"); break;
1865 case DW_ATE_signed_fixed
: printf ("(signed_fixed)"); break;
1866 case DW_ATE_unsigned_fixed
: printf ("(unsigned_fixed)"); break;
1867 /* HP extensions: */
1868 case DW_ATE_HP_float80
: printf ("(HP_float80)"); break;
1869 case DW_ATE_HP_complex_float80
: printf ("(HP_complex_float80)"); break;
1870 case DW_ATE_HP_float128
: printf ("(HP_float128)"); break;
1871 case DW_ATE_HP_complex_float128
:printf ("(HP_complex_float128)"); break;
1872 case DW_ATE_HP_floathpintel
: printf ("(HP_floathpintel)"); break;
1873 case DW_ATE_HP_imaginary_float80
: printf ("(HP_imaginary_float80)"); break;
1874 case DW_ATE_HP_imaginary_float128
: printf ("(HP_imaginary_float128)"); break;
1877 if (uvalue
>= DW_ATE_lo_user
1878 && uvalue
<= DW_ATE_hi_user
)
1879 printf (_("(user defined type)"));
1881 printf (_("(unknown type)"));
1886 case DW_AT_accessibility
:
1889 case DW_ACCESS_public
: printf ("(public)"); break;
1890 case DW_ACCESS_protected
: printf ("(protected)"); break;
1891 case DW_ACCESS_private
: printf ("(private)"); break;
1893 printf (_("(unknown accessibility)"));
1898 case DW_AT_visibility
:
1901 case DW_VIS_local
: printf ("(local)"); break;
1902 case DW_VIS_exported
: printf ("(exported)"); break;
1903 case DW_VIS_qualified
: printf ("(qualified)"); break;
1904 default: printf (_("(unknown visibility)")); break;
1908 case DW_AT_virtuality
:
1911 case DW_VIRTUALITY_none
: printf ("(none)"); break;
1912 case DW_VIRTUALITY_virtual
: printf ("(virtual)"); break;
1913 case DW_VIRTUALITY_pure_virtual
:printf ("(pure_virtual)"); break;
1914 default: printf (_("(unknown virtuality)")); break;
1918 case DW_AT_identifier_case
:
1921 case DW_ID_case_sensitive
: printf ("(case_sensitive)"); break;
1922 case DW_ID_up_case
: printf ("(up_case)"); break;
1923 case DW_ID_down_case
: printf ("(down_case)"); break;
1924 case DW_ID_case_insensitive
: printf ("(case_insensitive)"); break;
1925 default: printf (_("(unknown case)")); break;
1929 case DW_AT_calling_convention
:
1932 case DW_CC_normal
: printf ("(normal)"); break;
1933 case DW_CC_program
: printf ("(program)"); break;
1934 case DW_CC_nocall
: printf ("(nocall)"); break;
1936 if (uvalue
>= DW_CC_lo_user
1937 && uvalue
<= DW_CC_hi_user
)
1938 printf (_("(user defined)"));
1940 printf (_("(unknown convention)"));
1944 case DW_AT_ordering
:
1947 case -1: printf (_("(undefined)")); break;
1948 case 0: printf ("(row major)"); break;
1949 case 1: printf ("(column major)"); break;
1953 case DW_AT_frame_base
:
1954 have_frame_base
= 1;
1955 case DW_AT_location
:
1956 case DW_AT_string_length
:
1957 case DW_AT_return_addr
:
1958 case DW_AT_data_member_location
:
1959 case DW_AT_vtable_elem_location
:
1961 case DW_AT_static_link
:
1962 case DW_AT_use_location
:
1963 case DW_AT_GNU_call_site_value
:
1964 case DW_AT_GNU_call_site_data_value
:
1965 case DW_AT_GNU_call_site_target
:
1966 case DW_AT_GNU_call_site_target_clobbered
:
1967 if ((dwarf_version
< 4
1968 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
1969 || form
== DW_FORM_sec_offset
)
1970 printf (_("(location list)"));
1972 case DW_AT_allocated
:
1973 case DW_AT_associated
:
1974 case DW_AT_data_location
:
1976 case DW_AT_upper_bound
:
1977 case DW_AT_lower_bound
:
1980 int need_frame_base
;
1983 need_frame_base
= decode_location_expression (block_start
,
1988 cu_offset
, section
);
1990 if (need_frame_base
&& !have_frame_base
)
1991 printf (_(" [without DW_AT_frame_base]"));
1997 if (form
== DW_FORM_ref_sig8
1998 || form
== DW_FORM_GNU_ref_alt
)
2001 if (form
== DW_FORM_ref1
2002 || form
== DW_FORM_ref2
2003 || form
== DW_FORM_ref4
2004 || form
== DW_FORM_ref_udata
)
2005 uvalue
+= cu_offset
;
2007 if (uvalue
>= section
->size
)
2008 warn (_("Offset %s used as value for DW_AT_import attribute of DIE at offset %lx is too big.\n"),
2009 dwarf_vmatoa ("x", uvalue
),
2010 (unsigned long) (orig_data
- section
->start
));
2013 unsigned long abbrev_number
;
2014 abbrev_entry
* entry
;
2016 abbrev_number
= read_uleb128 (section
->start
+ uvalue
, NULL
, end
);
2018 printf (_("[Abbrev Number: %ld"), abbrev_number
);
2019 /* Don't look up abbrev for DW_FORM_ref_addr, as it very often will
2020 use different abbrev table, and we don't track .debug_info chunks
2022 if (form
!= DW_FORM_ref_addr
)
2024 for (entry
= first_abbrev
; entry
!= NULL
; entry
= entry
->next
)
2025 if (entry
->entry
== abbrev_number
)
2028 printf (" (%s)", get_TAG_name (entry
->tag
));
2043 get_AT_name (unsigned long attribute
)
2048 return "DW_AT value: 0";
2050 /* One value is shared by the MIPS and HP extensions: */
2051 if (attribute
== DW_AT_MIPS_fde
)
2052 return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable";
2054 name
= get_DW_AT_name (attribute
);
2058 static char buffer
[100];
2060 snprintf (buffer
, sizeof (buffer
), _("Unknown AT value: %lx"),
2068 static unsigned char *
2069 read_and_display_attr (unsigned long attribute
,
2071 unsigned char * data
,
2072 unsigned char * end
,
2073 dwarf_vma cu_offset
,
2074 dwarf_vma pointer_size
,
2075 dwarf_vma offset_size
,
2077 debug_info
* debug_info_p
,
2079 struct dwarf_section
* section
,
2080 struct cu_tu_set
* this_set
)
2083 printf (" %-18s:", get_AT_name (attribute
));
2084 data
= read_and_display_attr_value (attribute
, form
, data
, end
,
2085 cu_offset
, pointer_size
, offset_size
,
2086 dwarf_version
, debug_info_p
,
2087 do_loc
, section
, this_set
);
2093 /* Process the contents of a .debug_info section. If do_loc is non-zero
2094 then we are scanning for location lists and we do not want to display
2095 anything to the user. If do_types is non-zero, we are processing
2096 a .debug_types section instead of a .debug_info section. */
2099 process_debug_info (struct dwarf_section
*section
,
2101 enum dwarf_section_display_enum abbrev_sec
,
2105 unsigned char *start
= section
->start
;
2106 unsigned char *end
= start
+ section
->size
;
2107 unsigned char *section_begin
;
2109 unsigned int num_units
= 0;
2111 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2112 && num_debug_info_entries
== 0
2117 /* First scan the section to get the number of comp units. */
2118 for (section_begin
= start
, num_units
= 0; section_begin
< end
;
2121 /* Read the first 4 bytes. For a 32-bit DWARF section, this
2122 will be the length. For a 64-bit DWARF section, it'll be
2123 the escape code 0xffffffff followed by an 8 byte length. */
2124 SAFE_BYTE_GET (length
, section_begin
, 4, end
);
2126 if (length
== 0xffffffff)
2128 SAFE_BYTE_GET (length
, section_begin
+ 4, 8, end
);
2129 section_begin
+= length
+ 12;
2131 else if (length
>= 0xfffffff0 && length
< 0xffffffff)
2133 warn (_("Reserved length value (0x%s) found in section %s\n"),
2134 dwarf_vmatoa ("x", length
), section
->name
);
2138 section_begin
+= length
+ 4;
2140 /* Negative values are illegal, they may even cause infinite
2141 looping. This can happen if we can't accurately apply
2142 relocations to an object file. */
2143 if ((signed long) length
<= 0)
2145 warn (_("Corrupt unit length (0x%s) found in section %s\n"),
2146 dwarf_vmatoa ("x", length
), section
->name
);
2153 error (_("No comp units in %s section ?"), section
->name
);
2157 /* Then allocate an array to hold the information. */
2158 debug_information
= (debug_info
*) cmalloc (num_units
,
2159 sizeof (* debug_information
));
2160 if (debug_information
== NULL
)
2162 error (_("Not enough memory for a debug info array of %u entries"),
2170 if (dwarf_start_die
== 0)
2171 printf (_("Contents of the %s section:\n\n"), section
->name
);
2173 load_debug_section (str
, file
);
2174 load_debug_section (str_dwo
, file
);
2175 load_debug_section (str_index
, file
);
2176 load_debug_section (str_index_dwo
, file
);
2177 load_debug_section (debug_addr
, file
);
2180 load_debug_section (abbrev_sec
, file
);
2181 if (debug_displays
[abbrev_sec
].section
.start
== NULL
)
2183 warn (_("Unable to locate %s section!\n"),
2184 debug_displays
[abbrev_sec
].section
.name
);
2188 for (section_begin
= start
, unit
= 0; start
< end
; unit
++)
2190 DWARF2_Internal_CompUnit compunit
;
2191 unsigned char *hdrptr
;
2192 unsigned char *tags
;
2193 int level
, last_level
, saved_level
;
2194 dwarf_vma cu_offset
;
2196 int initial_length_size
;
2197 dwarf_vma signature_high
= 0;
2198 dwarf_vma signature_low
= 0;
2199 dwarf_vma type_offset
= 0;
2200 struct cu_tu_set
*this_set
;
2201 dwarf_vma abbrev_base
;
2206 SAFE_BYTE_GET_AND_INC (compunit
.cu_length
, hdrptr
, 4, end
);
2208 if (compunit
.cu_length
== 0xffffffff)
2210 SAFE_BYTE_GET_AND_INC (compunit
.cu_length
, hdrptr
, 8, end
);
2212 initial_length_size
= 12;
2217 initial_length_size
= 4;
2220 SAFE_BYTE_GET_AND_INC (compunit
.cu_version
, hdrptr
, 2, end
);
2222 cu_offset
= start
- section_begin
;
2224 this_set
= find_cu_tu_set_v2 (cu_offset
, do_types
);
2226 SAFE_BYTE_GET_AND_INC (compunit
.cu_abbrev_offset
, hdrptr
, offset_size
, end
);
2228 if (this_set
== NULL
)
2231 abbrev_size
= debug_displays
[abbrev_sec
].section
.size
;
2235 abbrev_base
= this_set
->section_offsets
[DW_SECT_ABBREV
];
2236 abbrev_size
= this_set
->section_sizes
[DW_SECT_ABBREV
];
2239 SAFE_BYTE_GET_AND_INC (compunit
.cu_pointer_size
, hdrptr
, 1, end
);
2243 SAFE_BYTE_GET64 (hdrptr
, &signature_high
, &signature_low
, end
);
2245 SAFE_BYTE_GET_AND_INC (type_offset
, hdrptr
, offset_size
, end
);
2248 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2249 && num_debug_info_entries
== 0
2252 debug_information
[unit
].cu_offset
= cu_offset
;
2253 debug_information
[unit
].pointer_size
2254 = compunit
.cu_pointer_size
;
2255 debug_information
[unit
].offset_size
= offset_size
;
2256 debug_information
[unit
].dwarf_version
= compunit
.cu_version
;
2257 debug_information
[unit
].base_address
= 0;
2258 debug_information
[unit
].addr_base
= DEBUG_INFO_UNAVAILABLE
;
2259 debug_information
[unit
].ranges_base
= DEBUG_INFO_UNAVAILABLE
;
2260 debug_information
[unit
].loc_offsets
= NULL
;
2261 debug_information
[unit
].have_frame_base
= NULL
;
2262 debug_information
[unit
].max_loc_offsets
= 0;
2263 debug_information
[unit
].num_loc_offsets
= 0;
2264 debug_information
[unit
].range_lists
= NULL
;
2265 debug_information
[unit
].max_range_lists
= 0;
2266 debug_information
[unit
].num_range_lists
= 0;
2269 if (!do_loc
&& dwarf_start_die
== 0)
2271 printf (_(" Compilation Unit @ offset 0x%s:\n"),
2272 dwarf_vmatoa ("x", cu_offset
));
2273 printf (_(" Length: 0x%s (%s)\n"),
2274 dwarf_vmatoa ("x", compunit
.cu_length
),
2275 offset_size
== 8 ? "64-bit" : "32-bit");
2276 printf (_(" Version: %d\n"), compunit
.cu_version
);
2277 printf (_(" Abbrev Offset: 0x%s\n"),
2278 dwarf_vmatoa ("x", compunit
.cu_abbrev_offset
));
2279 printf (_(" Pointer Size: %d\n"), compunit
.cu_pointer_size
);
2284 printf (_(" Signature: 0x%s\n"),
2285 dwarf_vmatoa64 (signature_high
, signature_low
,
2286 buf
, sizeof (buf
)));
2287 printf (_(" Type Offset: 0x%s\n"),
2288 dwarf_vmatoa ("x", type_offset
));
2290 if (this_set
!= NULL
)
2292 dwarf_vma
*offsets
= this_set
->section_offsets
;
2293 size_t *sizes
= this_set
->section_sizes
;
2295 printf (_(" Section contributions:\n"));
2296 printf (_(" .debug_abbrev.dwo: 0x%s 0x%s\n"),
2297 dwarf_vmatoa ("x", offsets
[DW_SECT_ABBREV
]),
2298 dwarf_vmatoa ("x", sizes
[DW_SECT_ABBREV
]));
2299 printf (_(" .debug_line.dwo: 0x%s 0x%s\n"),
2300 dwarf_vmatoa ("x", offsets
[DW_SECT_LINE
]),
2301 dwarf_vmatoa ("x", sizes
[DW_SECT_LINE
]));
2302 printf (_(" .debug_loc.dwo: 0x%s 0x%s\n"),
2303 dwarf_vmatoa ("x", offsets
[DW_SECT_LOC
]),
2304 dwarf_vmatoa ("x", sizes
[DW_SECT_LOC
]));
2305 printf (_(" .debug_str_offsets.dwo: 0x%s 0x%s\n"),
2306 dwarf_vmatoa ("x", offsets
[DW_SECT_STR_OFFSETS
]),
2307 dwarf_vmatoa ("x", sizes
[DW_SECT_STR_OFFSETS
]));
2311 if (cu_offset
+ compunit
.cu_length
+ initial_length_size
2314 warn (_("Debug info is corrupted, length of CU at %s"
2315 " extends beyond end of section (length = %s)\n"),
2316 dwarf_vmatoa ("x", cu_offset
),
2317 dwarf_vmatoa ("x", compunit
.cu_length
));
2321 start
+= compunit
.cu_length
+ initial_length_size
;
2323 if (compunit
.cu_version
!= 2
2324 && compunit
.cu_version
!= 3
2325 && compunit
.cu_version
!= 4)
2327 warn (_("CU at offset %s contains corrupt or "
2328 "unsupported version number: %d.\n"),
2329 dwarf_vmatoa ("x", cu_offset
), compunit
.cu_version
);
2335 /* Process the abbrevs used by this compilation unit. DWARF
2336 sections under Mach-O have non-zero addresses. */
2337 if (compunit
.cu_abbrev_offset
>= abbrev_size
)
2338 warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"),
2339 (unsigned long) compunit
.cu_abbrev_offset
,
2340 (unsigned long) abbrev_size
);
2342 process_abbrev_section
2343 (((unsigned char *) debug_displays
[abbrev_sec
].section
.start
2344 + abbrev_base
+ compunit
.cu_abbrev_offset
),
2345 ((unsigned char *) debug_displays
[abbrev_sec
].section
.start
2346 + abbrev_base
+ abbrev_size
));
2351 while (tags
< start
)
2353 unsigned int bytes_read
;
2354 unsigned long abbrev_number
;
2355 unsigned long die_offset
;
2356 abbrev_entry
*entry
;
2358 int do_printing
= 1;
2360 die_offset
= tags
- section_begin
;
2362 abbrev_number
= read_uleb128 (tags
, & bytes_read
, start
);
2365 /* A null DIE marks the end of a list of siblings or it may also be
2366 a section padding. */
2367 if (abbrev_number
== 0)
2369 /* Check if it can be a section padding for the last CU. */
2370 if (level
== 0 && start
== end
)
2374 for (chk
= tags
; chk
< start
; chk
++)
2381 if (!do_loc
&& die_offset
>= dwarf_start_die
2382 && (dwarf_cutoff_level
== -1
2383 || level
< dwarf_cutoff_level
))
2384 printf (_(" <%d><%lx>: Abbrev Number: 0\n"),
2390 static unsigned num_bogus_warns
= 0;
2392 if (num_bogus_warns
< 3)
2394 warn (_("Bogus end-of-siblings marker detected at offset %lx in %s section\n"),
2395 die_offset
, section
->name
);
2397 if (num_bogus_warns
== 3)
2398 warn (_("Further warnings about bogus end-of-sibling markers suppressed\n"));
2401 if (dwarf_start_die
!= 0 && level
< saved_level
)
2408 if (dwarf_start_die
!= 0 && die_offset
< dwarf_start_die
)
2412 if (dwarf_start_die
!= 0 && die_offset
== dwarf_start_die
)
2413 saved_level
= level
;
2414 do_printing
= (dwarf_cutoff_level
== -1
2415 || level
< dwarf_cutoff_level
);
2417 printf (_(" <%d><%lx>: Abbrev Number: %lu"),
2418 level
, die_offset
, abbrev_number
);
2419 else if (dwarf_cutoff_level
== -1
2420 || last_level
< dwarf_cutoff_level
)
2421 printf (_(" <%d><%lx>: ...\n"), level
, die_offset
);
2426 /* Scan through the abbreviation list until we reach the
2428 for (entry
= first_abbrev
;
2429 entry
&& entry
->entry
!= abbrev_number
;
2430 entry
= entry
->next
)
2435 if (!do_loc
&& do_printing
)
2440 warn (_("DIE at offset %lx refers to abbreviation number %lu which does not exist\n"),
2441 die_offset
, abbrev_number
);
2445 if (!do_loc
&& do_printing
)
2446 printf (" (%s)\n", get_TAG_name (entry
->tag
));
2451 need_base_address
= 0;
2453 case DW_TAG_compile_unit
:
2454 need_base_address
= 1;
2456 case DW_TAG_entry_point
:
2457 case DW_TAG_subprogram
:
2458 need_base_address
= 0;
2459 /* Assuming that there is no DW_AT_frame_base. */
2460 have_frame_base
= 0;
2464 for (attr
= entry
->first_attr
;
2465 attr
&& attr
->attribute
;
2470 if (! do_loc
&& do_printing
)
2471 /* Show the offset from where the tag was extracted. */
2472 printf (" <%lx>", (unsigned long)(tags
- section_begin
));
2474 arg
= debug_information
;
2475 if (debug_information
)
2478 tags
= read_and_display_attr (attr
->attribute
,
2483 compunit
.cu_pointer_size
,
2485 compunit
.cu_version
,
2487 do_loc
|| ! do_printing
,
2492 if (entry
->children
)
2497 /* Set num_debug_info_entries here so that it can be used to check if
2498 we need to process .debug_loc and .debug_ranges sections. */
2499 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2500 && num_debug_info_entries
== 0
2502 num_debug_info_entries
= num_units
;
2510 /* Locate and scan the .debug_info section in the file and record the pointer
2511 sizes and offsets for the compilation units in it. Usually an executable
2512 will have just one pointer size, but this is not guaranteed, and so we try
2513 not to make any assumptions. Returns zero upon failure, or the number of
2514 compilation units upon success. */
2517 load_debug_info (void * file
)
2519 /* Reset the last pointer size so that we can issue correct error
2520 messages if we are displaying the contents of more than one section. */
2521 last_pointer_size
= 0;
2522 warned_about_missing_comp_units
= FALSE
;
2524 /* If we have already tried and failed to load the .debug_info
2525 section then do not bother to repeat the task. */
2526 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
2529 /* If we already have the information there is nothing else to do. */
2530 if (num_debug_info_entries
> 0)
2531 return num_debug_info_entries
;
2533 /* If this is a DWARF package file, load the CU and TU indexes. */
2534 load_cu_tu_indexes (file
);
2536 if (load_debug_section (info
, file
)
2537 && process_debug_info (&debug_displays
[info
].section
, file
, abbrev
, 1, 0))
2538 return num_debug_info_entries
;
2539 else if (load_debug_section (info_dwo
, file
)
2540 && process_debug_info (&debug_displays
[info_dwo
].section
, file
,
2542 return num_debug_info_entries
;
2544 num_debug_info_entries
= DEBUG_INFO_UNAVAILABLE
;
2548 /* Read a DWARF .debug_line section header starting at DATA.
2549 Upon success returns an updated DATA pointer and the LINFO
2550 structure and the END_OF_SEQUENCE pointer will be filled in.
2551 Otherwise returns NULL. */
2553 static unsigned char *
2554 read_debug_line_header (struct dwarf_section
* section
,
2555 unsigned char * data
,
2556 unsigned char * end
,
2557 DWARF2_Internal_LineInfo
* linfo
,
2558 unsigned char ** end_of_sequence
)
2560 unsigned char *hdrptr
;
2561 unsigned int offset_size
;
2562 unsigned int initial_length_size
;
2564 /* Extract information from the Line Number Program Header.
2565 (section 6.2.4 in the Dwarf3 doc). */
2568 /* Get and check the length of the block. */
2569 SAFE_BYTE_GET_AND_INC (linfo
->li_length
, hdrptr
, 4, end
);
2571 if (linfo
->li_length
== 0xffffffff)
2573 /* This section is 64-bit DWARF 3. */
2574 SAFE_BYTE_GET_AND_INC (linfo
->li_length
, hdrptr
, 8, end
);
2576 initial_length_size
= 12;
2581 initial_length_size
= 4;
2584 if (linfo
->li_length
+ initial_length_size
> section
->size
)
2586 /* If the length is just a bias against the initial_length_size then
2587 this means that the field has a relocation against it which has not
2588 been applied. (Ie we are dealing with an object file, not a linked
2589 binary). Do not complain but instead assume that the rest of the
2590 section applies to this particular header. */
2591 if (linfo
->li_length
== - initial_length_size
)
2593 linfo
->li_length
= section
->size
- initial_length_size
;
2597 warn (_("The line info appears to be corrupt - "
2598 "the section is too small\n"));
2603 /* Get and check the version number. */
2604 SAFE_BYTE_GET_AND_INC (linfo
->li_version
, hdrptr
, 2, end
);
2606 if (linfo
->li_version
!= 2
2607 && linfo
->li_version
!= 3
2608 && linfo
->li_version
!= 4)
2610 warn (_("Only DWARF version 2, 3 and 4 line info is currently supported.\n"));
2614 SAFE_BYTE_GET_AND_INC (linfo
->li_prologue_length
, hdrptr
, offset_size
, end
);
2615 SAFE_BYTE_GET_AND_INC (linfo
->li_min_insn_length
, hdrptr
, 1, end
);
2617 if (linfo
->li_version
>= 4)
2619 SAFE_BYTE_GET_AND_INC (linfo
->li_max_ops_per_insn
, hdrptr
, 1, end
);
2621 if (linfo
->li_max_ops_per_insn
== 0)
2623 warn (_("Invalid maximum operations per insn.\n"));
2628 linfo
->li_max_ops_per_insn
= 1;
2630 SAFE_BYTE_GET_AND_INC (linfo
->li_default_is_stmt
, hdrptr
, 1, end
);
2631 SAFE_BYTE_GET_AND_INC (linfo
->li_line_base
, hdrptr
, 1, end
);
2632 SAFE_BYTE_GET_AND_INC (linfo
->li_line_range
, hdrptr
, 1, end
);
2633 SAFE_BYTE_GET_AND_INC (linfo
->li_opcode_base
, hdrptr
, 1, end
);
2635 /* Sign extend the line base field. */
2636 linfo
->li_line_base
<<= 24;
2637 linfo
->li_line_base
>>= 24;
2639 * end_of_sequence
= data
+ linfo
->li_length
+ initial_length_size
;
2644 display_debug_lines_raw (struct dwarf_section
*section
,
2645 unsigned char *data
,
2648 unsigned char *start
= section
->start
;
2650 printf (_("Raw dump of debug contents of section %s:\n\n"),
2655 static DWARF2_Internal_LineInfo saved_linfo
;
2656 DWARF2_Internal_LineInfo linfo
;
2657 unsigned char *standard_opcodes
;
2658 unsigned char *end_of_sequence
;
2659 unsigned int last_dir_entry
= 0;
2662 if (const_strneq (section
->name
, ".debug_line.")
2663 /* Note: the following does not apply to .debug_line.dwo sections.
2664 These are full debug_line sections. */
2665 && strcmp (section
->name
, ".debug_line.dwo") != 0)
2667 /* Sections named .debug_line.<foo> are fragments of a .debug_line
2668 section containing just the Line Number Statements. They are
2669 created by the assembler and intended to be used alongside gcc's
2670 -ffunction-sections command line option. When the linker's
2671 garbage collection decides to discard a .text.<foo> section it
2672 can then also discard the line number information in .debug_line.<foo>.
2674 Since the section is a fragment it does not have the details
2675 needed to fill out a LineInfo structure, so instead we use the
2676 details from the last full debug_line section that we processed. */
2677 end_of_sequence
= end
;
2678 standard_opcodes
= NULL
;
2679 linfo
= saved_linfo
;
2680 reset_state_machine (linfo
.li_default_is_stmt
);
2684 unsigned char * hdrptr
;
2686 if ((hdrptr
= read_debug_line_header (section
, data
, end
, & linfo
,
2687 & end_of_sequence
)) == NULL
)
2690 printf (_(" Offset: 0x%lx\n"), (long)(data
- start
));
2691 printf (_(" Length: %ld\n"), (long) linfo
.li_length
);
2692 printf (_(" DWARF Version: %d\n"), linfo
.li_version
);
2693 printf (_(" Prologue Length: %d\n"), linfo
.li_prologue_length
);
2694 printf (_(" Minimum Instruction Length: %d\n"), linfo
.li_min_insn_length
);
2695 if (linfo
.li_version
>= 4)
2696 printf (_(" Maximum Ops per Instruction: %d\n"), linfo
.li_max_ops_per_insn
);
2697 printf (_(" Initial value of 'is_stmt': %d\n"), linfo
.li_default_is_stmt
);
2698 printf (_(" Line Base: %d\n"), linfo
.li_line_base
);
2699 printf (_(" Line Range: %d\n"), linfo
.li_line_range
);
2700 printf (_(" Opcode Base: %d\n"), linfo
.li_opcode_base
);
2702 reset_state_machine (linfo
.li_default_is_stmt
);
2704 /* Display the contents of the Opcodes table. */
2705 standard_opcodes
= hdrptr
;
2707 printf (_("\n Opcodes:\n"));
2709 for (i
= 1; i
< linfo
.li_opcode_base
; i
++)
2710 printf (_(" Opcode %d has %d args\n"), i
, standard_opcodes
[i
- 1]);
2712 /* Display the contents of the Directory table. */
2713 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
2716 printf (_("\n The Directory Table is empty.\n"));
2719 printf (_("\n The Directory Table (offset 0x%lx):\n"),
2720 (long)(data
- start
));
2724 printf (" %d\t%s\n", ++last_dir_entry
, data
);
2726 data
+= strnlen ((char *) data
, end
- data
) + 1;
2730 /* Skip the NUL at the end of the table. */
2733 /* Display the contents of the File Name table. */
2735 printf (_("\n The File Name Table is empty.\n"));
2738 printf (_("\n The File Name Table (offset 0x%lx):\n"),
2739 (long)(data
- start
));
2740 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
2744 unsigned char *name
;
2745 unsigned int bytes_read
;
2747 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
2749 data
+= strnlen ((char *) data
, end
- data
) + 1;
2752 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
2755 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
2758 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
2760 printf ("%s\n", name
);
2764 warn (_("Corrupt file name table entry\n"));
2770 /* Skip the NUL at the end of the table. */
2773 saved_linfo
= linfo
;
2776 /* Now display the statements. */
2777 if (data
>= end_of_sequence
)
2778 printf (_(" No Line Number Statements.\n"));
2781 printf (_(" Line Number Statements:\n"));
2783 while (data
< end_of_sequence
)
2785 unsigned char op_code
;
2786 dwarf_signed_vma adv
;
2788 unsigned int bytes_read
;
2790 printf (" [0x%08lx]", (long)(data
- start
));
2794 if (op_code
>= linfo
.li_opcode_base
)
2796 op_code
-= linfo
.li_opcode_base
;
2797 uladv
= (op_code
/ linfo
.li_line_range
);
2798 if (linfo
.li_max_ops_per_insn
== 1)
2800 uladv
*= linfo
.li_min_insn_length
;
2801 state_machine_regs
.address
+= uladv
;
2802 printf (_(" Special opcode %d: "
2803 "advance Address by %s to 0x%s"),
2804 op_code
, dwarf_vmatoa ("u", uladv
),
2805 dwarf_vmatoa ("x", state_machine_regs
.address
));
2809 state_machine_regs
.address
2810 += ((state_machine_regs
.op_index
+ uladv
)
2811 / linfo
.li_max_ops_per_insn
)
2812 * linfo
.li_min_insn_length
;
2813 state_machine_regs
.op_index
2814 = (state_machine_regs
.op_index
+ uladv
)
2815 % linfo
.li_max_ops_per_insn
;
2816 printf (_(" Special opcode %d: "
2817 "advance Address by %s to 0x%s[%d]"),
2818 op_code
, dwarf_vmatoa ("u", uladv
),
2819 dwarf_vmatoa ("x", state_machine_regs
.address
),
2820 state_machine_regs
.op_index
);
2822 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
2823 state_machine_regs
.line
+= adv
;
2824 printf (_(" and Line by %s to %d\n"),
2825 dwarf_vmatoa ("d", adv
), state_machine_regs
.line
);
2827 else switch (op_code
)
2829 case DW_LNS_extended_op
:
2830 data
+= process_extended_line_op (data
, linfo
.li_default_is_stmt
, end
);
2834 printf (_(" Copy\n"));
2837 case DW_LNS_advance_pc
:
2838 uladv
= read_uleb128 (data
, & bytes_read
, end
);
2840 if (linfo
.li_max_ops_per_insn
== 1)
2842 uladv
*= linfo
.li_min_insn_length
;
2843 state_machine_regs
.address
+= uladv
;
2844 printf (_(" Advance PC by %s to 0x%s\n"),
2845 dwarf_vmatoa ("u", uladv
),
2846 dwarf_vmatoa ("x", state_machine_regs
.address
));
2850 state_machine_regs
.address
2851 += ((state_machine_regs
.op_index
+ uladv
)
2852 / linfo
.li_max_ops_per_insn
)
2853 * linfo
.li_min_insn_length
;
2854 state_machine_regs
.op_index
2855 = (state_machine_regs
.op_index
+ uladv
)
2856 % linfo
.li_max_ops_per_insn
;
2857 printf (_(" Advance PC by %s to 0x%s[%d]\n"),
2858 dwarf_vmatoa ("u", uladv
),
2859 dwarf_vmatoa ("x", state_machine_regs
.address
),
2860 state_machine_regs
.op_index
);
2864 case DW_LNS_advance_line
:
2865 adv
= read_sleb128 (data
, & bytes_read
, end
);
2867 state_machine_regs
.line
+= adv
;
2868 printf (_(" Advance Line by %s to %d\n"),
2869 dwarf_vmatoa ("d", adv
),
2870 state_machine_regs
.line
);
2873 case DW_LNS_set_file
:
2874 adv
= read_uleb128 (data
, & bytes_read
, end
);
2876 printf (_(" Set File Name to entry %s in the File Name Table\n"),
2877 dwarf_vmatoa ("d", adv
));
2878 state_machine_regs
.file
= adv
;
2881 case DW_LNS_set_column
:
2882 uladv
= read_uleb128 (data
, & bytes_read
, end
);
2884 printf (_(" Set column to %s\n"),
2885 dwarf_vmatoa ("u", uladv
));
2886 state_machine_regs
.column
= uladv
;
2889 case DW_LNS_negate_stmt
:
2890 adv
= state_machine_regs
.is_stmt
;
2892 printf (_(" Set is_stmt to %s\n"), dwarf_vmatoa ("d", adv
));
2893 state_machine_regs
.is_stmt
= adv
;
2896 case DW_LNS_set_basic_block
:
2897 printf (_(" Set basic block\n"));
2898 state_machine_regs
.basic_block
= 1;
2901 case DW_LNS_const_add_pc
:
2902 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
2903 if (linfo
.li_max_ops_per_insn
)
2905 uladv
*= linfo
.li_min_insn_length
;
2906 state_machine_regs
.address
+= uladv
;
2907 printf (_(" Advance PC by constant %s to 0x%s\n"),
2908 dwarf_vmatoa ("u", uladv
),
2909 dwarf_vmatoa ("x", state_machine_regs
.address
));
2913 state_machine_regs
.address
2914 += ((state_machine_regs
.op_index
+ uladv
)
2915 / linfo
.li_max_ops_per_insn
)
2916 * linfo
.li_min_insn_length
;
2917 state_machine_regs
.op_index
2918 = (state_machine_regs
.op_index
+ uladv
)
2919 % linfo
.li_max_ops_per_insn
;
2920 printf (_(" Advance PC by constant %s to 0x%s[%d]\n"),
2921 dwarf_vmatoa ("u", uladv
),
2922 dwarf_vmatoa ("x", state_machine_regs
.address
),
2923 state_machine_regs
.op_index
);
2927 case DW_LNS_fixed_advance_pc
:
2928 SAFE_BYTE_GET_AND_INC (uladv
, data
, 2, end
);
2929 state_machine_regs
.address
+= uladv
;
2930 state_machine_regs
.op_index
= 0;
2931 printf (_(" Advance PC by fixed size amount %s to 0x%s\n"),
2932 dwarf_vmatoa ("u", uladv
),
2933 dwarf_vmatoa ("x", state_machine_regs
.address
));
2936 case DW_LNS_set_prologue_end
:
2937 printf (_(" Set prologue_end to true\n"));
2940 case DW_LNS_set_epilogue_begin
:
2941 printf (_(" Set epilogue_begin to true\n"));
2944 case DW_LNS_set_isa
:
2945 uladv
= read_uleb128 (data
, & bytes_read
, end
);
2947 printf (_(" Set ISA to %s\n"), dwarf_vmatoa ("u", uladv
));
2951 printf (_(" Unknown opcode %d with operands: "), op_code
);
2953 if (standard_opcodes
!= NULL
)
2954 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
2956 printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data
,
2958 i
== 1 ? "" : ", ");
2974 unsigned char *name
;
2975 unsigned int directory_index
;
2976 unsigned int modification_date
;
2977 unsigned int length
;
2980 /* Output a decoded representation of the .debug_line section. */
2983 display_debug_lines_decoded (struct dwarf_section
*section
,
2984 unsigned char *data
,
2987 static DWARF2_Internal_LineInfo saved_linfo
;
2989 printf (_("Decoded dump of debug contents of section %s:\n\n"),
2994 /* This loop amounts to one iteration per compilation unit. */
2995 DWARF2_Internal_LineInfo linfo
;
2996 unsigned char *standard_opcodes
;
2997 unsigned char *end_of_sequence
;
2999 File_Entry
*file_table
= NULL
;
3000 unsigned int n_files
= 0;
3001 unsigned char **directory_table
= NULL
;
3002 unsigned int n_directories
= 0;
3004 if (const_strneq (section
->name
, ".debug_line.")
3005 /* Note: the following does not apply to .debug_line.dwo sections.
3006 These are full debug_line sections. */
3007 && strcmp (section
->name
, ".debug_line.dwo") != 0)
3009 /* See comment in display_debug_lines_raw(). */
3010 end_of_sequence
= end
;
3011 standard_opcodes
= NULL
;
3012 linfo
= saved_linfo
;
3013 reset_state_machine (linfo
.li_default_is_stmt
);
3017 unsigned char *hdrptr
;
3019 if ((hdrptr
= read_debug_line_header (section
, data
, end
, & linfo
,
3020 & end_of_sequence
)) == NULL
)
3023 reset_state_machine (linfo
.li_default_is_stmt
);
3025 /* Save a pointer to the contents of the Opcodes table. */
3026 standard_opcodes
= hdrptr
;
3028 /* Traverse the Directory table just to count entries. */
3029 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
3032 unsigned char *ptr_directory_table
= data
;
3036 data
+= strnlen ((char *) data
, end
- data
) + 1;
3040 /* Go through the directory table again to save the directories. */
3041 directory_table
= (unsigned char **)
3042 xmalloc (n_directories
* sizeof (unsigned char *));
3045 while (*ptr_directory_table
!= 0)
3047 directory_table
[i
] = ptr_directory_table
;
3048 ptr_directory_table
+= strnlen ((char *) ptr_directory_table
,
3049 ptr_directory_table
- end
) + 1;
3053 /* Skip the NUL at the end of the table. */
3056 /* Traverse the File Name table just to count the entries. */
3059 unsigned char *ptr_file_name_table
= data
;
3063 unsigned int bytes_read
;
3065 /* Skip Name, directory index, last modification time and length
3067 data
+= strnlen ((char *) data
, end
- data
) + 1;
3068 read_uleb128 (data
, & bytes_read
, end
);
3070 read_uleb128 (data
, & bytes_read
, end
);
3072 read_uleb128 (data
, & bytes_read
, end
);
3078 /* Go through the file table again to save the strings. */
3079 file_table
= (File_Entry
*) xmalloc (n_files
* sizeof (File_Entry
));
3082 while (*ptr_file_name_table
!= 0)
3084 unsigned int bytes_read
;
3086 file_table
[i
].name
= ptr_file_name_table
;
3087 ptr_file_name_table
+= strnlen ((char *) ptr_file_name_table
,
3088 end
- ptr_file_name_table
) + 1;
3090 /* We are not interested in directory, time or size. */
3091 file_table
[i
].directory_index
= read_uleb128 (ptr_file_name_table
,
3093 ptr_file_name_table
+= bytes_read
;
3094 file_table
[i
].modification_date
= read_uleb128 (ptr_file_name_table
,
3096 ptr_file_name_table
+= bytes_read
;
3097 file_table
[i
].length
= read_uleb128 (ptr_file_name_table
, & bytes_read
, end
);
3098 ptr_file_name_table
+= bytes_read
;
3103 /* Print the Compilation Unit's name and a header. */
3104 if (directory_table
== NULL
)
3106 printf (_("CU: %s:\n"), file_table
[0].name
);
3107 printf (_("File name Line number Starting address\n"));
3111 unsigned int ix
= file_table
[0].directory_index
;
3112 const char *directory
= ix
? (char *)directory_table
[ix
- 1] : ".";
3114 if (do_wide
|| strlen (directory
) < 76)
3115 printf (_("CU: %s/%s:\n"), directory
, file_table
[0].name
);
3117 printf ("%s:\n", file_table
[0].name
);
3119 printf (_("File name Line number Starting address\n"));
3123 /* Skip the NUL at the end of the table. */
3126 saved_linfo
= linfo
;
3129 /* This loop iterates through the Dwarf Line Number Program. */
3130 while (data
< end_of_sequence
)
3132 unsigned char op_code
;
3134 unsigned long int uladv
;
3135 unsigned int bytes_read
;
3136 int is_special_opcode
= 0;
3140 if (op_code
>= linfo
.li_opcode_base
)
3142 op_code
-= linfo
.li_opcode_base
;
3143 uladv
= (op_code
/ linfo
.li_line_range
);
3144 if (linfo
.li_max_ops_per_insn
== 1)
3146 uladv
*= linfo
.li_min_insn_length
;
3147 state_machine_regs
.address
+= uladv
;
3151 state_machine_regs
.address
3152 += ((state_machine_regs
.op_index
+ uladv
)
3153 / linfo
.li_max_ops_per_insn
)
3154 * linfo
.li_min_insn_length
;
3155 state_machine_regs
.op_index
3156 = (state_machine_regs
.op_index
+ uladv
)
3157 % linfo
.li_max_ops_per_insn
;
3160 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
3161 state_machine_regs
.line
+= adv
;
3162 is_special_opcode
= 1;
3164 else switch (op_code
)
3166 case DW_LNS_extended_op
:
3168 unsigned int ext_op_code_len
;
3169 unsigned char ext_op_code
;
3170 unsigned char *op_code_data
= data
;
3172 ext_op_code_len
= read_uleb128 (op_code_data
, &bytes_read
,
3174 op_code_data
+= bytes_read
;
3176 if (ext_op_code_len
== 0)
3178 warn (_("badly formed extended line op encountered!\n"));
3181 ext_op_code_len
+= bytes_read
;
3182 ext_op_code
= *op_code_data
++;
3184 switch (ext_op_code
)
3186 case DW_LNE_end_sequence
:
3187 reset_state_machine (linfo
.li_default_is_stmt
);
3189 case DW_LNE_set_address
:
3190 SAFE_BYTE_GET_AND_INC (state_machine_regs
.address
,
3192 ext_op_code_len
- bytes_read
- 1,
3194 state_machine_regs
.op_index
= 0;
3196 case DW_LNE_define_file
:
3198 file_table
= (File_Entry
*) xrealloc
3199 (file_table
, (n_files
+ 1) * sizeof (File_Entry
));
3201 ++state_machine_regs
.last_file_entry
;
3202 /* Source file name. */
3203 file_table
[n_files
].name
= op_code_data
;
3204 op_code_data
+= strlen ((char *) op_code_data
) + 1;
3205 /* Directory index. */
3206 file_table
[n_files
].directory_index
=
3207 read_uleb128 (op_code_data
, & bytes_read
,
3209 op_code_data
+= bytes_read
;
3210 /* Last modification time. */
3211 file_table
[n_files
].modification_date
=
3212 read_uleb128 (op_code_data
, & bytes_read
,
3214 op_code_data
+= bytes_read
;
3216 file_table
[n_files
].length
=
3217 read_uleb128 (op_code_data
, & bytes_read
,
3223 case DW_LNE_set_discriminator
:
3224 case DW_LNE_HP_set_sequence
:
3225 /* Simply ignored. */
3229 printf (_("UNKNOWN (%u): length %d\n"),
3230 ext_op_code
, ext_op_code_len
- bytes_read
);
3233 data
+= ext_op_code_len
;
3239 case DW_LNS_advance_pc
:
3240 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3242 if (linfo
.li_max_ops_per_insn
== 1)
3244 uladv
*= linfo
.li_min_insn_length
;
3245 state_machine_regs
.address
+= uladv
;
3249 state_machine_regs
.address
3250 += ((state_machine_regs
.op_index
+ uladv
)
3251 / linfo
.li_max_ops_per_insn
)
3252 * linfo
.li_min_insn_length
;
3253 state_machine_regs
.op_index
3254 = (state_machine_regs
.op_index
+ uladv
)
3255 % linfo
.li_max_ops_per_insn
;
3259 case DW_LNS_advance_line
:
3260 adv
= read_sleb128 (data
, & bytes_read
, end
);
3262 state_machine_regs
.line
+= adv
;
3265 case DW_LNS_set_file
:
3266 adv
= read_uleb128 (data
, & bytes_read
, end
);
3268 state_machine_regs
.file
= adv
;
3270 if (file_table
== NULL
)
3271 printf (_("\n [Use file table entry %d]\n"), state_machine_regs
.file
- 1);
3272 else if (file_table
[state_machine_regs
.file
- 1].directory_index
== 0)
3273 /* If directory index is 0, that means current directory. */
3274 printf ("\n./%s:[++]\n",
3275 file_table
[state_machine_regs
.file
- 1].name
);
3276 else if (directory_table
== NULL
)
3277 printf (_("\n [Use directory table entry %d]\n"),
3278 file_table
[state_machine_regs
.file
- 1].directory_index
- 1);
3280 /* The directory index starts counting at 1. */
3281 printf ("\n%s/%s:\n",
3282 directory_table
[file_table
[state_machine_regs
.file
- 1].directory_index
- 1],
3283 file_table
[state_machine_regs
.file
- 1].name
);
3286 case DW_LNS_set_column
:
3287 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3289 state_machine_regs
.column
= uladv
;
3292 case DW_LNS_negate_stmt
:
3293 adv
= state_machine_regs
.is_stmt
;
3295 state_machine_regs
.is_stmt
= adv
;
3298 case DW_LNS_set_basic_block
:
3299 state_machine_regs
.basic_block
= 1;
3302 case DW_LNS_const_add_pc
:
3303 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
3304 if (linfo
.li_max_ops_per_insn
== 1)
3306 uladv
*= linfo
.li_min_insn_length
;
3307 state_machine_regs
.address
+= uladv
;
3311 state_machine_regs
.address
3312 += ((state_machine_regs
.op_index
+ uladv
)
3313 / linfo
.li_max_ops_per_insn
)
3314 * linfo
.li_min_insn_length
;
3315 state_machine_regs
.op_index
3316 = (state_machine_regs
.op_index
+ uladv
)
3317 % linfo
.li_max_ops_per_insn
;
3321 case DW_LNS_fixed_advance_pc
:
3322 SAFE_BYTE_GET_AND_INC (uladv
, data
, 2, end
);
3323 state_machine_regs
.address
+= uladv
;
3324 state_machine_regs
.op_index
= 0;
3327 case DW_LNS_set_prologue_end
:
3330 case DW_LNS_set_epilogue_begin
:
3333 case DW_LNS_set_isa
:
3334 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3336 printf (_(" Set ISA to %lu\n"), uladv
);
3340 printf (_(" Unknown opcode %d with operands: "), op_code
);
3342 if (standard_opcodes
!= NULL
)
3343 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
3345 printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data
,
3347 i
== 1 ? "" : ", ");
3354 /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row
3355 to the DWARF address/line matrix. */
3356 if ((is_special_opcode
) || (op_code
== DW_LNE_end_sequence
)
3357 || (op_code
== DW_LNS_copy
))
3359 const unsigned int MAX_FILENAME_LENGTH
= 35;
3361 char *newFileName
= NULL
;
3362 size_t fileNameLength
;
3365 fileName
= (char *) file_table
[state_machine_regs
.file
- 1].name
;
3367 fileName
= "<unknown>";
3369 fileNameLength
= strlen (fileName
);
3371 if ((fileNameLength
> MAX_FILENAME_LENGTH
) && (!do_wide
))
3373 newFileName
= (char *) xmalloc (MAX_FILENAME_LENGTH
+ 1);
3374 /* Truncate file name */
3375 strncpy (newFileName
,
3376 fileName
+ fileNameLength
- MAX_FILENAME_LENGTH
,
3377 MAX_FILENAME_LENGTH
+ 1);
3381 newFileName
= (char *) xmalloc (fileNameLength
+ 1);
3382 strncpy (newFileName
, fileName
, fileNameLength
+ 1);
3385 if (!do_wide
|| (fileNameLength
<= MAX_FILENAME_LENGTH
))
3387 if (linfo
.li_max_ops_per_insn
== 1)
3388 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x\n",
3389 newFileName
, state_machine_regs
.line
,
3390 state_machine_regs
.address
);
3392 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x[%d]\n",
3393 newFileName
, state_machine_regs
.line
,
3394 state_machine_regs
.address
,
3395 state_machine_regs
.op_index
);
3399 if (linfo
.li_max_ops_per_insn
== 1)
3400 printf ("%s %11d %#18" DWARF_VMA_FMT
"x\n",
3401 newFileName
, state_machine_regs
.line
,
3402 state_machine_regs
.address
);
3404 printf ("%s %11d %#18" DWARF_VMA_FMT
"x[%d]\n",
3405 newFileName
, state_machine_regs
.line
,
3406 state_machine_regs
.address
,
3407 state_machine_regs
.op_index
);
3410 if (op_code
== DW_LNE_end_sequence
)
3424 if (directory_table
)
3426 free (directory_table
);
3427 directory_table
= NULL
;
3438 display_debug_lines (struct dwarf_section
*section
, void *file ATTRIBUTE_UNUSED
)
3440 unsigned char *data
= section
->start
;
3441 unsigned char *end
= data
+ section
->size
;
3443 int retValDecoded
= 1;
3445 if (do_debug_lines
== 0)
3446 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
3448 if (do_debug_lines
& FLAG_DEBUG_LINES_RAW
)
3449 retValRaw
= display_debug_lines_raw (section
, data
, end
);
3451 if (do_debug_lines
& FLAG_DEBUG_LINES_DECODED
)
3452 retValDecoded
= display_debug_lines_decoded (section
, data
, end
);
3454 if (!retValRaw
|| !retValDecoded
)
3461 find_debug_info_for_offset (unsigned long offset
)
3465 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
3468 for (i
= 0; i
< num_debug_info_entries
; i
++)
3469 if (debug_information
[i
].cu_offset
== offset
)
3470 return debug_information
+ i
;
3476 display_debug_pubnames (struct dwarf_section
*section
,
3477 void *file ATTRIBUTE_UNUSED
)
3479 DWARF2_Internal_PubNames names
;
3480 unsigned char *start
= section
->start
;
3481 unsigned char *end
= start
+ section
->size
;
3483 /* It does not matter if this load fails,
3484 we test for that later on. */
3485 load_debug_info (file
);
3487 printf (_("Contents of the %s section:\n\n"), section
->name
);
3491 unsigned char *data
;
3492 unsigned long offset
;
3493 int offset_size
, initial_length_size
;
3497 SAFE_BYTE_GET_AND_INC (names
.pn_length
, data
, 4, end
);
3498 if (names
.pn_length
== 0xffffffff)
3500 SAFE_BYTE_GET_AND_INC (names
.pn_length
, data
, 8, end
);
3502 initial_length_size
= 12;
3507 initial_length_size
= 4;
3510 SAFE_BYTE_GET_AND_INC (names
.pn_version
, data
, 2, end
);
3511 SAFE_BYTE_GET_AND_INC (names
.pn_offset
, data
, offset_size
, end
);
3513 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
3514 && num_debug_info_entries
> 0
3515 && find_debug_info_for_offset (names
.pn_offset
) == NULL
)
3516 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
3517 (unsigned long) names
.pn_offset
, section
->name
);
3519 SAFE_BYTE_GET_AND_INC (names
.pn_size
, data
, offset_size
, end
);
3521 start
+= names
.pn_length
+ initial_length_size
;
3523 if (names
.pn_version
!= 2 && names
.pn_version
!= 3)
3525 static int warned
= 0;
3529 warn (_("Only DWARF 2 and 3 pubnames are currently supported\n"));
3536 printf (_(" Length: %ld\n"),
3537 (long) names
.pn_length
);
3538 printf (_(" Version: %d\n"),
3540 printf (_(" Offset into .debug_info section: 0x%lx\n"),
3541 (unsigned long) names
.pn_offset
);
3542 printf (_(" Size of area in .debug_info section: %ld\n"),
3543 (long) names
.pn_size
);
3545 printf (_("\n Offset\tName\n"));
3549 SAFE_BYTE_GET (offset
, data
, offset_size
, end
);
3553 data
+= offset_size
;
3554 printf (" %-6lx\t%s\n", offset
, data
);
3555 data
+= strnlen ((char *) data
, end
- data
) + 1;
3558 while (offset
!= 0);
3566 display_debug_macinfo (struct dwarf_section
*section
,
3567 void *file ATTRIBUTE_UNUSED
)
3569 unsigned char *start
= section
->start
;
3570 unsigned char *end
= start
+ section
->size
;
3571 unsigned char *curr
= start
;
3572 unsigned int bytes_read
;
3573 enum dwarf_macinfo_record_type op
;
3575 printf (_("Contents of the %s section:\n\n"), section
->name
);
3579 unsigned int lineno
;
3580 const unsigned char *string
;
3582 op
= (enum dwarf_macinfo_record_type
) *curr
;
3587 case DW_MACINFO_start_file
:
3589 unsigned int filenum
;
3591 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
3593 filenum
= read_uleb128 (curr
, & bytes_read
, end
);
3596 printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"),
3601 case DW_MACINFO_end_file
:
3602 printf (_(" DW_MACINFO_end_file\n"));
3605 case DW_MACINFO_define
:
3606 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
3609 curr
+= strnlen ((char *) string
, end
- string
) + 1;
3610 printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"),
3614 case DW_MACINFO_undef
:
3615 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
3618 curr
+= strnlen ((char *) string
, end
- string
) + 1;
3619 printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"),
3623 case DW_MACINFO_vendor_ext
:
3625 unsigned int constant
;
3627 constant
= read_uleb128 (curr
, & bytes_read
, end
);
3630 curr
+= strnlen ((char *) string
, end
- string
) + 1;
3631 printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"),
3641 /* Given LINE_OFFSET into the .debug_line section, attempt to return
3642 filename and dirname corresponding to file name table entry with index
3643 FILEIDX. Return NULL on failure. */
3645 static unsigned char *
3646 get_line_filename_and_dirname (dwarf_vma line_offset
,
3648 unsigned char **dir_name
)
3650 struct dwarf_section
*section
= &debug_displays
[line
].section
;
3651 unsigned char *hdrptr
, *dirtable
, *file_name
;
3652 unsigned int offset_size
, initial_length_size
;
3653 unsigned int version
, opcode_base
, bytes_read
;
3654 dwarf_vma length
, diridx
;
3655 const unsigned char * end
;
3658 if (section
->start
== NULL
3659 || line_offset
>= section
->size
3663 hdrptr
= section
->start
+ line_offset
;
3664 end
= section
->start
+ section
->size
;
3666 SAFE_BYTE_GET_AND_INC (length
, hdrptr
, 4, end
);
3667 if (length
== 0xffffffff)
3669 /* This section is 64-bit DWARF 3. */
3670 SAFE_BYTE_GET_AND_INC (length
, hdrptr
, 8, end
);
3672 initial_length_size
= 12;
3677 initial_length_size
= 4;
3679 if (length
+ initial_length_size
> section
->size
)
3682 SAFE_BYTE_GET_AND_INC (version
, hdrptr
, 2, end
);
3683 if (version
!= 2 && version
!= 3 && version
!= 4)
3685 hdrptr
+= offset_size
+ 1;/* Skip prologue_length and min_insn_length. */
3687 hdrptr
++; /* Skip max_ops_per_insn. */
3688 hdrptr
+= 3; /* Skip default_is_stmt, line_base, line_range. */
3690 SAFE_BYTE_GET_AND_INC (opcode_base
, hdrptr
, 1, end
);
3691 if (opcode_base
== 0)
3694 hdrptr
+= opcode_base
- 1;
3696 /* Skip over dirname table. */
3697 while (*hdrptr
!= '\0')
3698 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
3699 hdrptr
++; /* Skip the NUL at the end of the table. */
3700 /* Now skip over preceding filename table entries. */
3701 for (; *hdrptr
!= '\0' && fileidx
> 1; fileidx
--)
3703 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
3704 read_uleb128 (hdrptr
, &bytes_read
, end
);
3705 hdrptr
+= bytes_read
;
3706 read_uleb128 (hdrptr
, &bytes_read
, end
);
3707 hdrptr
+= bytes_read
;
3708 read_uleb128 (hdrptr
, &bytes_read
, end
);
3709 hdrptr
+= bytes_read
;
3711 if (hdrptr
== end
|| *hdrptr
== '\0')
3714 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
3715 diridx
= read_uleb128 (hdrptr
, &bytes_read
, end
);
3718 for (; *dirtable
!= '\0' && diridx
> 1; diridx
--)
3719 dirtable
+= strnlen ((char *) dirtable
, end
- dirtable
) + 1;
3720 if (*dirtable
== '\0')
3722 *dir_name
= dirtable
;
3727 display_debug_macro (struct dwarf_section
*section
,
3730 unsigned char *start
= section
->start
;
3731 unsigned char *end
= start
+ section
->size
;
3732 unsigned char *curr
= start
;
3733 unsigned char *extended_op_buf
[256];
3734 unsigned int bytes_read
;
3736 load_debug_section (str
, file
);
3737 load_debug_section (line
, file
);
3739 printf (_("Contents of the %s section:\n\n"), section
->name
);
3743 unsigned int lineno
, version
, flags
;
3744 unsigned int offset_size
= 4;
3745 const unsigned char *string
;
3746 dwarf_vma line_offset
= 0, sec_offset
= curr
- start
, offset
;
3747 unsigned char **extended_ops
= NULL
;
3749 SAFE_BYTE_GET_AND_INC (version
, curr
, 2, end
);
3752 error (_("Only GNU extension to DWARF 4 of %s is currently supported.\n"),
3757 SAFE_BYTE_GET_AND_INC (flags
, curr
, 1, end
);
3760 printf (_(" Offset: 0x%lx\n"),
3761 (unsigned long) sec_offset
);
3762 printf (_(" Version: %d\n"), version
);
3763 printf (_(" Offset size: %d\n"), offset_size
);
3766 SAFE_BYTE_GET_AND_INC (line_offset
, curr
, offset_size
, end
);
3767 printf (_(" Offset into .debug_line: 0x%lx\n"),
3768 (unsigned long) line_offset
);
3772 unsigned int i
, count
, op
;
3775 SAFE_BYTE_GET_AND_INC (count
, curr
, 1, end
);
3777 memset (extended_op_buf
, 0, sizeof (extended_op_buf
));
3778 extended_ops
= extended_op_buf
;
3781 printf (_(" Extension opcode arguments:\n"));
3782 for (i
= 0; i
< count
; i
++)
3784 SAFE_BYTE_GET_AND_INC (op
, curr
, 1, end
);
3785 extended_ops
[op
] = curr
;
3786 nargs
= read_uleb128 (curr
, &bytes_read
, end
);
3789 printf (_(" DW_MACRO_GNU_%02x has no arguments\n"), op
);
3792 printf (_(" DW_MACRO_GNU_%02x arguments: "), op
);
3793 for (n
= 0; n
< nargs
; n
++)
3797 SAFE_BYTE_GET_AND_INC (form
, curr
, 1, end
);
3798 printf ("%s%s", get_FORM_name (form
),
3799 n
== nargs
- 1 ? "\n" : ", ");
3809 case DW_FORM_block1
:
3810 case DW_FORM_block2
:
3811 case DW_FORM_block4
:
3813 case DW_FORM_string
:
3815 case DW_FORM_sec_offset
:
3818 error (_("Invalid extension opcode form %s\n"),
3819 get_FORM_name (form
));
3835 error (_(".debug_macro section not zero terminated\n"));
3839 SAFE_BYTE_GET_AND_INC (op
, curr
, 1, end
);
3845 case DW_MACRO_GNU_start_file
:
3847 unsigned int filenum
;
3848 unsigned char *file_name
= NULL
, *dir_name
= NULL
;
3850 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3852 filenum
= read_uleb128 (curr
, &bytes_read
, end
);
3855 if ((flags
& 2) == 0)
3856 error (_("DW_MACRO_GNU_start_file used, but no .debug_line offset provided.\n"));
3859 = get_line_filename_and_dirname (line_offset
, filenum
,
3861 if (file_name
== NULL
)
3862 printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d\n"),
3865 printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d filename: %s%s%s\n"),
3867 dir_name
!= NULL
? (const char *) dir_name
: "",
3868 dir_name
!= NULL
? "/" : "", file_name
);
3872 case DW_MACRO_GNU_end_file
:
3873 printf (_(" DW_MACRO_GNU_end_file\n"));
3876 case DW_MACRO_GNU_define
:
3877 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3880 curr
+= strnlen ((char *) string
, end
- string
) + 1;
3881 printf (_(" DW_MACRO_GNU_define - lineno : %d macro : %s\n"),
3885 case DW_MACRO_GNU_undef
:
3886 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3889 curr
+= strnlen ((char *) string
, end
- string
) + 1;
3890 printf (_(" DW_MACRO_GNU_undef - lineno : %d macro : %s\n"),
3894 case DW_MACRO_GNU_define_indirect
:
3895 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3897 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
3898 string
= fetch_indirect_string (offset
);
3899 printf (_(" DW_MACRO_GNU_define_indirect - lineno : %d macro : %s\n"),
3903 case DW_MACRO_GNU_undef_indirect
:
3904 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3906 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
3907 string
= fetch_indirect_string (offset
);
3908 printf (_(" DW_MACRO_GNU_undef_indirect - lineno : %d macro : %s\n"),
3912 case DW_MACRO_GNU_transparent_include
:
3913 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
3914 printf (_(" DW_MACRO_GNU_transparent_include - offset : 0x%lx\n"),
3915 (unsigned long) offset
);
3918 case DW_MACRO_GNU_define_indirect_alt
:
3919 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3921 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
3922 printf (_(" DW_MACRO_GNU_define_indirect_alt - lineno : %d macro offset : 0x%lx\n"),
3923 lineno
, (unsigned long) offset
);
3926 case DW_MACRO_GNU_undef_indirect_alt
:
3927 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3929 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
3930 printf (_(" DW_MACRO_GNU_undef_indirect_alt - lineno : %d macro offset : 0x%lx\n"),
3931 lineno
, (unsigned long) offset
);
3934 case DW_MACRO_GNU_transparent_include_alt
:
3935 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
3936 printf (_(" DW_MACRO_GNU_transparent_include_alt - offset : 0x%lx\n"),
3937 (unsigned long) offset
);
3941 if (extended_ops
== NULL
|| extended_ops
[op
] == NULL
)
3943 error (_(" Unknown macro opcode %02x seen\n"), op
);
3948 /* Skip over unhandled opcodes. */
3950 unsigned char *desc
= extended_ops
[op
];
3951 nargs
= read_uleb128 (desc
, &bytes_read
, end
);
3955 printf (_(" DW_MACRO_GNU_%02x\n"), op
);
3958 printf (_(" DW_MACRO_GNU_%02x -"), op
);
3959 for (n
= 0; n
< nargs
; n
++)
3963 SAFE_BYTE_GET_AND_INC (val
, desc
, 1, end
);
3965 = read_and_display_attr_value (0, val
,
3966 curr
, end
, 0, 0, offset_size
,
3967 version
, NULL
, 0, NULL
,
3985 display_debug_abbrev (struct dwarf_section
*section
,
3986 void *file ATTRIBUTE_UNUSED
)
3988 abbrev_entry
*entry
;
3989 unsigned char *start
= section
->start
;
3990 unsigned char *end
= start
+ section
->size
;
3992 printf (_("Contents of the %s section:\n\n"), section
->name
);
3996 unsigned char *last
;
4001 start
= process_abbrev_section (start
, end
);
4003 if (first_abbrev
== NULL
)
4006 printf (_(" Number TAG (0x%lx)\n"), (long) (last
- section
->start
));
4008 for (entry
= first_abbrev
; entry
; entry
= entry
->next
)
4012 printf (" %ld %s [%s]\n",
4014 get_TAG_name (entry
->tag
),
4015 entry
->children
? _("has children") : _("no children"));
4017 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
4018 printf (" %-18s %s\n",
4019 get_AT_name (attr
->attribute
),
4020 get_FORM_name (attr
->form
));
4030 /* Display a location list from a normal (ie, non-dwo) .debug_loc section. */
4033 display_loc_list (struct dwarf_section
*section
,
4034 unsigned char **start_ptr
,
4035 int debug_info_entry
,
4036 unsigned long offset
,
4037 unsigned long base_address
,
4040 unsigned char *start
= *start_ptr
;
4041 unsigned char *section_end
= section
->start
+ section
->size
;
4042 unsigned long cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
4043 unsigned int pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
4044 unsigned int offset_size
= debug_information
[debug_info_entry
].offset_size
;
4045 int dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
4049 unsigned short length
;
4050 int need_frame_base
;
4054 if (start
+ 2 * pointer_size
> section_end
)
4056 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4061 printf (" %8.8lx ", offset
+ (start
- *start_ptr
));
4063 /* Note: we use sign extension here in order to be sure that we can detect
4064 the -1 escape value. Sign extension into the top 32 bits of a 32-bit
4065 address will not affect the values that we display since we always show
4066 hex values, and always the bottom 32-bits. */
4067 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, section_end
);
4068 SAFE_BYTE_GET_AND_INC (end
, start
, pointer_size
, section_end
);
4070 if (begin
== 0 && end
== 0)
4072 printf (_("<End of list>\n"));
4076 /* Check base address specifiers. */
4077 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
4080 print_dwarf_vma (begin
, pointer_size
);
4081 print_dwarf_vma (end
, pointer_size
);
4082 printf (_("(base address)\n"));
4086 if (start
+ 2 > section_end
)
4088 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4093 SAFE_BYTE_GET_AND_INC (length
, start
, 2, section_end
);
4095 if (start
+ length
> section_end
)
4097 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4102 print_dwarf_vma (begin
+ base_address
, pointer_size
);
4103 print_dwarf_vma (end
+ base_address
, pointer_size
);
4106 need_frame_base
= decode_location_expression (start
,
4111 cu_offset
, section
);
4114 if (need_frame_base
&& !has_frame_base
)
4115 printf (_(" [without DW_AT_frame_base]"));
4118 fputs (_(" (start == end)"), stdout
);
4119 else if (begin
> end
)
4120 fputs (_(" (start > end)"), stdout
);
4130 /* Print a .debug_addr table index in decimal, surrounded by square brackets,
4131 right-adjusted in a field of length LEN, and followed by a space. */
4134 print_addr_index (unsigned int idx
, unsigned int len
)
4136 static char buf
[15];
4137 snprintf (buf
, sizeof (buf
), "[%d]", idx
);
4138 printf ("%*s ", len
, buf
);
4141 /* Display a location list from a .dwo section. It uses address indexes rather
4142 than embedded addresses. This code closely follows display_loc_list, but the
4143 two are sufficiently different that combining things is very ugly. */
4146 display_loc_list_dwo (struct dwarf_section
*section
,
4147 unsigned char **start_ptr
,
4148 int debug_info_entry
,
4149 unsigned long offset
,
4152 unsigned char *start
= *start_ptr
;
4153 unsigned char *section_end
= section
->start
+ section
->size
;
4154 unsigned long cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
4155 unsigned int pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
4156 unsigned int offset_size
= debug_information
[debug_info_entry
].offset_size
;
4157 int dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
4159 unsigned short length
;
4160 int need_frame_base
;
4162 unsigned int bytes_read
;
4166 printf (" %8.8lx ", offset
+ (start
- *start_ptr
));
4168 if (start
>= section_end
)
4170 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4175 SAFE_BYTE_GET_AND_INC (entry_type
, start
, 1, section_end
);
4178 case 0: /* A terminating entry. */
4180 printf (_("<End of list>\n"));
4182 case 1: /* A base-address entry. */
4183 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
4184 start
+= bytes_read
;
4185 print_addr_index (idx
, 8);
4187 printf (_("(base address selection entry)\n"));
4189 case 2: /* A start/end entry. */
4190 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
4191 start
+= bytes_read
;
4192 print_addr_index (idx
, 8);
4193 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
4194 start
+= bytes_read
;
4195 print_addr_index (idx
, 8);
4197 case 3: /* A start/length entry. */
4198 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
4199 start
+= bytes_read
;
4200 print_addr_index (idx
, 8);
4201 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
4202 printf ("%08x ", idx
);
4204 case 4: /* An offset pair entry. */
4205 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
4206 printf ("%08x ", idx
);
4207 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
4208 printf ("%08x ", idx
);
4211 warn (_("Unknown location list entry type 0x%x.\n"), entry_type
);
4216 if (start
+ 2 > section_end
)
4218 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4223 SAFE_BYTE_GET_AND_INC (length
, start
, 2, section_end
);
4224 if (start
+ length
> section_end
)
4226 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4232 need_frame_base
= decode_location_expression (start
,
4237 cu_offset
, section
);
4240 if (need_frame_base
&& !has_frame_base
)
4241 printf (_(" [without DW_AT_frame_base]"));
4251 /* Sort array of indexes in ascending order of loc_offsets[idx]. */
4253 static dwarf_vma
*loc_offsets
;
4256 loc_offsets_compar (const void *ap
, const void *bp
)
4258 dwarf_vma a
= loc_offsets
[*(const unsigned int *) ap
];
4259 dwarf_vma b
= loc_offsets
[*(const unsigned int *) bp
];
4261 return (a
> b
) - (b
> a
);
4265 display_debug_loc (struct dwarf_section
*section
, void *file
)
4267 unsigned char *start
= section
->start
;
4268 unsigned long bytes
;
4269 unsigned char *section_begin
= start
;
4270 unsigned int num_loc_list
= 0;
4271 unsigned long last_offset
= 0;
4272 unsigned int first
= 0;
4276 int seen_first_offset
= 0;
4277 int locs_sorted
= 1;
4278 unsigned char *next
;
4279 unsigned int *array
= NULL
;
4280 const char *suffix
= strrchr (section
->name
, '.');
4283 if (suffix
&& strcmp (suffix
, ".dwo") == 0)
4286 bytes
= section
->size
;
4290 printf (_("\nThe %s section is empty.\n"), section
->name
);
4294 if (load_debug_info (file
) == 0)
4296 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4301 /* Check the order of location list in .debug_info section. If
4302 offsets of location lists are in the ascending order, we can
4303 use `debug_information' directly. */
4304 for (i
= 0; i
< num_debug_info_entries
; i
++)
4308 num
= debug_information
[i
].num_loc_offsets
;
4309 if (num
> num_loc_list
)
4312 /* Check if we can use `debug_information' directly. */
4313 if (locs_sorted
&& num
!= 0)
4315 if (!seen_first_offset
)
4317 /* This is the first location list. */
4318 last_offset
= debug_information
[i
].loc_offsets
[0];
4320 seen_first_offset
= 1;
4326 for (; j
< num
; j
++)
4329 debug_information
[i
].loc_offsets
[j
])
4334 last_offset
= debug_information
[i
].loc_offsets
[j
];
4339 if (!seen_first_offset
)
4340 error (_("No location lists in .debug_info section!\n"));
4342 /* DWARF sections under Mach-O have non-zero addresses. */
4343 if (debug_information
[first
].num_loc_offsets
> 0
4344 && debug_information
[first
].loc_offsets
[0] != section
->address
)
4345 warn (_("Location lists in %s section start at 0x%s\n"),
4347 dwarf_vmatoa ("x", debug_information
[first
].loc_offsets
[0]));
4350 array
= (unsigned int *) xcmalloc (num_loc_list
, sizeof (unsigned int));
4351 printf (_("Contents of the %s section:\n\n"), section
->name
);
4352 printf (_(" Offset Begin End Expression\n"));
4354 seen_first_offset
= 0;
4355 for (i
= first
; i
< num_debug_info_entries
; i
++)
4357 unsigned long offset
;
4358 unsigned long base_address
;
4363 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
4365 loc_offsets
= debug_information
[i
].loc_offsets
;
4366 qsort (array
, debug_information
[i
].num_loc_offsets
,
4367 sizeof (*array
), loc_offsets_compar
);
4370 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
4372 j
= locs_sorted
? k
: array
[k
];
4374 && debug_information
[i
].loc_offsets
[locs_sorted
4375 ? k
- 1 : array
[k
- 1]]
4376 == debug_information
[i
].loc_offsets
[j
])
4378 has_frame_base
= debug_information
[i
].have_frame_base
[j
];
4379 /* DWARF sections under Mach-O have non-zero addresses. */
4380 offset
= debug_information
[i
].loc_offsets
[j
] - section
->address
;
4381 next
= section_begin
+ offset
;
4382 base_address
= debug_information
[i
].base_address
;
4384 if (!seen_first_offset
)
4385 seen_first_offset
= 1;
4389 warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"),
4390 (unsigned long) (start
- section_begin
),
4391 (unsigned long) (next
- section_begin
));
4392 else if (start
> next
)
4393 warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"),
4394 (unsigned long) (start
- section_begin
),
4395 (unsigned long) (next
- section_begin
));
4399 if (offset
>= bytes
)
4401 warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"),
4407 display_loc_list_dwo (section
, &start
, i
, offset
, has_frame_base
);
4409 display_loc_list (section
, &start
, i
, offset
, base_address
,
4414 if (start
< section
->start
+ section
->size
)
4415 warn (_("There are %ld unused bytes at the end of section %s\n"),
4416 (long) (section
->start
+ section
->size
- start
), section
->name
);
4423 display_debug_str (struct dwarf_section
*section
,
4424 void *file ATTRIBUTE_UNUSED
)
4426 unsigned char *start
= section
->start
;
4427 unsigned long bytes
= section
->size
;
4428 dwarf_vma addr
= section
->address
;
4432 printf (_("\nThe %s section is empty.\n"), section
->name
);
4436 printf (_("Contents of the %s section:\n\n"), section
->name
);
4444 lbytes
= (bytes
> 16 ? 16 : bytes
);
4446 printf (" 0x%8.8lx ", (unsigned long) addr
);
4448 for (j
= 0; j
< 16; j
++)
4451 printf ("%2.2x", start
[j
]);
4459 for (j
= 0; j
< lbytes
; j
++)
4462 if (k
>= ' ' && k
< 0x80)
4481 display_debug_info (struct dwarf_section
*section
, void *file
)
4483 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 0);
4487 display_debug_types (struct dwarf_section
*section
, void *file
)
4489 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 1);
4493 display_trace_info (struct dwarf_section
*section
, void *file
)
4495 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 0);
4499 display_debug_aranges (struct dwarf_section
*section
,
4500 void *file ATTRIBUTE_UNUSED
)
4502 unsigned char *start
= section
->start
;
4503 unsigned char *end
= start
+ section
->size
;
4505 printf (_("Contents of the %s section:\n\n"), section
->name
);
4507 /* It does not matter if this load fails,
4508 we test for that later on. */
4509 load_debug_info (file
);
4513 unsigned char *hdrptr
;
4514 DWARF2_Internal_ARange arange
;
4515 unsigned char *addr_ranges
;
4518 unsigned char address_size
;
4521 int initial_length_size
;
4525 SAFE_BYTE_GET_AND_INC (arange
.ar_length
, hdrptr
, 4, end
);
4526 if (arange
.ar_length
== 0xffffffff)
4528 SAFE_BYTE_GET_AND_INC (arange
.ar_length
, hdrptr
, 8, end
);
4530 initial_length_size
= 12;
4535 initial_length_size
= 4;
4538 SAFE_BYTE_GET_AND_INC (arange
.ar_version
, hdrptr
, 2, end
);
4539 SAFE_BYTE_GET_AND_INC (arange
.ar_info_offset
, hdrptr
, offset_size
, end
);
4541 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
4542 && num_debug_info_entries
> 0
4543 && find_debug_info_for_offset (arange
.ar_info_offset
) == NULL
)
4544 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
4545 (unsigned long) arange
.ar_info_offset
, section
->name
);
4547 SAFE_BYTE_GET_AND_INC (arange
.ar_pointer_size
, hdrptr
, 1, end
);
4548 SAFE_BYTE_GET_AND_INC (arange
.ar_segment_size
, hdrptr
, 1, end
);
4550 if (arange
.ar_version
!= 2 && arange
.ar_version
!= 3)
4552 warn (_("Only DWARF 2 and 3 aranges are currently supported.\n"));
4556 printf (_(" Length: %ld\n"),
4557 (long) arange
.ar_length
);
4558 printf (_(" Version: %d\n"), arange
.ar_version
);
4559 printf (_(" Offset into .debug_info: 0x%lx\n"),
4560 (unsigned long) arange
.ar_info_offset
);
4561 printf (_(" Pointer Size: %d\n"), arange
.ar_pointer_size
);
4562 printf (_(" Segment Size: %d\n"), arange
.ar_segment_size
);
4564 address_size
= arange
.ar_pointer_size
+ arange
.ar_segment_size
;
4566 if (address_size
== 0)
4568 error (_("Invalid address size in %s section!\n"),
4573 /* The DWARF spec does not require that the address size be a power
4574 of two, but we do. This will have to change if we ever encounter
4575 an uneven architecture. */
4576 if ((address_size
& (address_size
- 1)) != 0)
4578 warn (_("Pointer size + Segment size is not a power of two.\n"));
4582 if (address_size
> 4)
4583 printf (_("\n Address Length\n"));
4585 printf (_("\n Address Length\n"));
4587 addr_ranges
= hdrptr
;
4589 /* Must pad to an alignment boundary that is twice the address size. */
4590 excess
= (hdrptr
- start
) % (2 * address_size
);
4592 addr_ranges
+= (2 * address_size
) - excess
;
4594 start
+= arange
.ar_length
+ initial_length_size
;
4596 while (addr_ranges
+ 2 * address_size
<= start
)
4598 SAFE_BYTE_GET_AND_INC (address
, addr_ranges
, address_size
, end
);
4599 SAFE_BYTE_GET_AND_INC (length
, addr_ranges
, address_size
, end
);
4602 print_dwarf_vma (address
, address_size
);
4603 print_dwarf_vma (length
, address_size
);
4613 /* Comparison function for qsort. */
4615 comp_addr_base (const void * v0
, const void * v1
)
4617 debug_info
* info0
= (debug_info
*) v0
;
4618 debug_info
* info1
= (debug_info
*) v1
;
4619 return info0
->addr_base
- info1
->addr_base
;
4622 /* Display the debug_addr section. */
4624 display_debug_addr (struct dwarf_section
*section
,
4627 debug_info
**debug_addr_info
;
4628 unsigned char *entry
;
4633 if (section
->size
== 0)
4635 printf (_("\nThe %s section is empty.\n"), section
->name
);
4639 if (load_debug_info (file
) == 0)
4641 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4646 printf (_("Contents of the %s section:\n\n"), section
->name
);
4648 debug_addr_info
= (debug_info
**) xmalloc ((num_debug_info_entries
+ 1)
4649 * sizeof (debug_info
*));
4652 for (i
= 0; i
< num_debug_info_entries
; i
++)
4654 if (debug_information
[i
].addr_base
!= DEBUG_INFO_UNAVAILABLE
)
4655 debug_addr_info
[count
++] = &debug_information
[i
];
4658 /* Add a sentinel to make iteration convenient. */
4659 debug_addr_info
[count
] = (debug_info
*) xmalloc (sizeof (debug_info
));
4660 debug_addr_info
[count
]->addr_base
= section
->size
;
4662 qsort (debug_addr_info
, count
, sizeof (debug_info
*), comp_addr_base
);
4663 for (i
= 0; i
< count
; i
++)
4666 unsigned int address_size
= debug_addr_info
[i
]->pointer_size
;
4668 printf (_(" For compilation unit at offset 0x%s:\n"),
4669 dwarf_vmatoa ("x", debug_addr_info
[i
]->cu_offset
));
4671 printf (_("\tIndex\tAddress\n"));
4672 entry
= section
->start
+ debug_addr_info
[i
]->addr_base
;
4673 end
= section
->start
+ debug_addr_info
[i
+ 1]->addr_base
;
4677 dwarf_vma base
= byte_get (entry
, address_size
);
4678 printf (_("\t%d:\t"), idx
);
4679 print_dwarf_vma (base
, address_size
);
4681 entry
+= address_size
;
4687 free (debug_addr_info
);
4691 /* Display the .debug_str_offsets and .debug_str_offsets.dwo sections. */
4693 display_debug_str_offsets (struct dwarf_section
*section
,
4694 void *file ATTRIBUTE_UNUSED
)
4696 if (section
->size
== 0)
4698 printf (_("\nThe %s section is empty.\n"), section
->name
);
4701 /* TODO: Dump the contents. This is made somewhat difficult by not knowing
4702 what the offset size is for this section. */
4706 /* Each debug_information[x].range_lists[y] gets this representation for
4707 sorting purposes. */
4711 /* The debug_information[x].range_lists[y] value. */
4712 unsigned long ranges_offset
;
4714 /* Original debug_information to find parameters of the data. */
4715 debug_info
*debug_info_p
;
4718 /* Sort struct range_entry in ascending order of its RANGES_OFFSET. */
4721 range_entry_compar (const void *ap
, const void *bp
)
4723 const struct range_entry
*a_re
= (const struct range_entry
*) ap
;
4724 const struct range_entry
*b_re
= (const struct range_entry
*) bp
;
4725 const unsigned long a
= a_re
->ranges_offset
;
4726 const unsigned long b
= b_re
->ranges_offset
;
4728 return (a
> b
) - (b
> a
);
4732 display_debug_ranges (struct dwarf_section
*section
,
4733 void *file ATTRIBUTE_UNUSED
)
4735 unsigned char *start
= section
->start
;
4736 unsigned char *last_start
= start
;
4737 unsigned long bytes
= section
->size
;
4738 unsigned char *section_begin
= start
;
4739 unsigned char *finish
= start
+ bytes
;
4740 unsigned int num_range_list
, i
;
4741 struct range_entry
*range_entries
, *range_entry_fill
;
4745 printf (_("\nThe %s section is empty.\n"), section
->name
);
4749 if (load_debug_info (file
) == 0)
4751 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4757 for (i
= 0; i
< num_debug_info_entries
; i
++)
4758 num_range_list
+= debug_information
[i
].num_range_lists
;
4760 if (num_range_list
== 0)
4762 /* This can happen when the file was compiled with -gsplit-debug
4763 which removes references to range lists from the primary .o file. */
4764 printf (_("No range lists in .debug_info section.\n"));
4768 range_entries
= (struct range_entry
*)
4769 xmalloc (sizeof (*range_entries
) * num_range_list
);
4770 range_entry_fill
= range_entries
;
4772 for (i
= 0; i
< num_debug_info_entries
; i
++)
4774 debug_info
*debug_info_p
= &debug_information
[i
];
4777 for (j
= 0; j
< debug_info_p
->num_range_lists
; j
++)
4779 range_entry_fill
->ranges_offset
= debug_info_p
->range_lists
[j
];
4780 range_entry_fill
->debug_info_p
= debug_info_p
;
4785 qsort (range_entries
, num_range_list
, sizeof (*range_entries
),
4786 range_entry_compar
);
4788 /* DWARF sections under Mach-O have non-zero addresses. */
4789 if (dwarf_check
!= 0 && range_entries
[0].ranges_offset
!= section
->address
)
4790 warn (_("Range lists in %s section start at 0x%lx\n"),
4791 section
->name
, range_entries
[0].ranges_offset
);
4793 printf (_("Contents of the %s section:\n\n"), section
->name
);
4794 printf (_(" Offset Begin End\n"));
4796 for (i
= 0; i
< num_range_list
; i
++)
4798 struct range_entry
*range_entry
= &range_entries
[i
];
4799 debug_info
*debug_info_p
= range_entry
->debug_info_p
;
4800 unsigned int pointer_size
;
4801 unsigned long offset
;
4802 unsigned char *next
;
4803 unsigned long base_address
;
4805 pointer_size
= debug_info_p
->pointer_size
;
4807 /* DWARF sections under Mach-O have non-zero addresses. */
4808 offset
= range_entry
->ranges_offset
- section
->address
;
4809 next
= section_begin
+ offset
;
4810 base_address
= debug_info_p
->base_address
;
4812 if (dwarf_check
!= 0 && i
> 0)
4815 warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"),
4816 (unsigned long) (start
- section_begin
),
4817 (unsigned long) (next
- section_begin
), section
->name
);
4818 else if (start
> next
)
4820 if (next
== last_start
)
4822 warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"),
4823 (unsigned long) (start
- section_begin
),
4824 (unsigned long) (next
- section_begin
), section
->name
);
4830 while (start
< finish
)
4835 /* Note: we use sign extension here in order to be sure that
4836 we can detect the -1 escape value. Sign extension into the
4837 top 32 bits of a 32-bit address will not affect the values
4838 that we display since we always show hex values, and always
4839 the bottom 32-bits. */
4840 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, finish
);
4841 if (start
>= finish
)
4843 SAFE_SIGNED_BYTE_GET_AND_INC (end
, start
, pointer_size
, finish
);
4845 printf (" %8.8lx ", offset
);
4847 if (begin
== 0 && end
== 0)
4849 printf (_("<End of list>\n"));
4853 /* Check base address specifiers. */
4854 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
4857 print_dwarf_vma (begin
, pointer_size
);
4858 print_dwarf_vma (end
, pointer_size
);
4859 printf ("(base address)\n");
4863 print_dwarf_vma (begin
+ base_address
, pointer_size
);
4864 print_dwarf_vma (end
+ base_address
, pointer_size
);
4867 fputs (_("(start == end)"), stdout
);
4868 else if (begin
> end
)
4869 fputs (_("(start > end)"), stdout
);
4876 free (range_entries
);
4881 typedef struct Frame_Chunk
4883 struct Frame_Chunk
*next
;
4884 unsigned char *chunk_start
;
4886 /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
4887 short int *col_type
;
4890 unsigned int code_factor
;
4892 unsigned long pc_begin
;
4893 unsigned long pc_range
;
4897 unsigned char fde_encoding
;
4898 unsigned char cfa_exp
;
4899 unsigned char ptr_size
;
4900 unsigned char segment_size
;
4904 static const char *const *dwarf_regnames
;
4905 static unsigned int dwarf_regnames_count
;
4907 /* A marker for a col_type that means this column was never referenced
4908 in the frame info. */
4909 #define DW_CFA_unreferenced (-1)
4911 /* Return 0 if not more space is needed, 1 if more space is needed,
4912 -1 for invalid reg. */
4915 frame_need_space (Frame_Chunk
*fc
, unsigned int reg
)
4917 int prev
= fc
->ncols
;
4919 if (reg
< (unsigned int) fc
->ncols
)
4922 if (dwarf_regnames_count
4923 && reg
> dwarf_regnames_count
)
4926 fc
->ncols
= reg
+ 1;
4927 fc
->col_type
= (short int *) xcrealloc (fc
->col_type
, fc
->ncols
,
4928 sizeof (short int));
4929 fc
->col_offset
= (int *) xcrealloc (fc
->col_offset
, fc
->ncols
, sizeof (int));
4931 while (prev
< fc
->ncols
)
4933 fc
->col_type
[prev
] = DW_CFA_unreferenced
;
4934 fc
->col_offset
[prev
] = 0;
4940 static const char *const dwarf_regnames_i386
[] =
4942 "eax", "ecx", "edx", "ebx",
4943 "esp", "ebp", "esi", "edi",
4944 "eip", "eflags", NULL
,
4945 "st0", "st1", "st2", "st3",
4946 "st4", "st5", "st6", "st7",
4948 "xmm0", "xmm1", "xmm2", "xmm3",
4949 "xmm4", "xmm5", "xmm6", "xmm7",
4950 "mm0", "mm1", "mm2", "mm3",
4951 "mm4", "mm5", "mm6", "mm7",
4952 "fcw", "fsw", "mxcsr",
4953 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
4958 init_dwarf_regnames_i386 (void)
4960 dwarf_regnames
= dwarf_regnames_i386
;
4961 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_i386
);
4964 static const char *const dwarf_regnames_x86_64
[] =
4966 "rax", "rdx", "rcx", "rbx",
4967 "rsi", "rdi", "rbp", "rsp",
4968 "r8", "r9", "r10", "r11",
4969 "r12", "r13", "r14", "r15",
4971 "xmm0", "xmm1", "xmm2", "xmm3",
4972 "xmm4", "xmm5", "xmm6", "xmm7",
4973 "xmm8", "xmm9", "xmm10", "xmm11",
4974 "xmm12", "xmm13", "xmm14", "xmm15",
4975 "st0", "st1", "st2", "st3",
4976 "st4", "st5", "st6", "st7",
4977 "mm0", "mm1", "mm2", "mm3",
4978 "mm4", "mm5", "mm6", "mm7",
4980 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
4981 "fs.base", "gs.base", NULL
, NULL
,
4983 "mxcsr", "fcw", "fsw"
4987 init_dwarf_regnames_x86_64 (void)
4989 dwarf_regnames
= dwarf_regnames_x86_64
;
4990 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_x86_64
);
4994 init_dwarf_regnames (unsigned int e_machine
)
5000 init_dwarf_regnames_i386 ();
5006 init_dwarf_regnames_x86_64 ();
5015 regname (unsigned int regno
, int row
)
5017 static char reg
[64];
5019 && regno
< dwarf_regnames_count
5020 && dwarf_regnames
[regno
] != NULL
)
5023 return dwarf_regnames
[regno
];
5024 snprintf (reg
, sizeof (reg
), "r%d (%s)", regno
,
5025 dwarf_regnames
[regno
]);
5028 snprintf (reg
, sizeof (reg
), "r%d", regno
);
5033 frame_display_row (Frame_Chunk
*fc
, int *need_col_headers
, int *max_regs
)
5038 if (*max_regs
< fc
->ncols
)
5039 *max_regs
= fc
->ncols
;
5041 if (*need_col_headers
)
5043 static const char *sloc
= " LOC";
5045 *need_col_headers
= 0;
5047 printf ("%-*s CFA ", eh_addr_size
* 2, sloc
);
5049 for (r
= 0; r
< *max_regs
; r
++)
5050 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
5055 printf ("%-5s ", regname (r
, 1));
5061 printf ("%0*lx ", eh_addr_size
* 2, fc
->pc_begin
);
5063 strcpy (tmp
, "exp");
5065 sprintf (tmp
, "%s%+d", regname (fc
->cfa_reg
, 1), fc
->cfa_offset
);
5066 printf ("%-8s ", tmp
);
5068 for (r
= 0; r
< fc
->ncols
; r
++)
5070 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
5072 switch (fc
->col_type
[r
])
5074 case DW_CFA_undefined
:
5077 case DW_CFA_same_value
:
5081 sprintf (tmp
, "c%+d", fc
->col_offset
[r
]);
5083 case DW_CFA_val_offset
:
5084 sprintf (tmp
, "v%+d", fc
->col_offset
[r
]);
5086 case DW_CFA_register
:
5087 sprintf (tmp
, "%s", regname (fc
->col_offset
[r
], 0));
5089 case DW_CFA_expression
:
5090 strcpy (tmp
, "exp");
5092 case DW_CFA_val_expression
:
5093 strcpy (tmp
, "vexp");
5096 strcpy (tmp
, "n/a");
5099 printf ("%-5s ", tmp
);
5105 #define GET(VAR, N) SAFE_BYTE_GET_AND_INC (VAR, start, N, end);
5106 #define LEB() read_uleb128 (start, & length_return, end); start += length_return
5107 #define SLEB() read_sleb128 (start, & length_return, end); start += length_return
5110 display_debug_frames (struct dwarf_section
*section
,
5111 void *file ATTRIBUTE_UNUSED
)
5113 unsigned char *start
= section
->start
;
5114 unsigned char *end
= start
+ section
->size
;
5115 unsigned char *section_start
= start
;
5116 Frame_Chunk
*chunks
= 0;
5117 Frame_Chunk
*remembered_state
= 0;
5119 int is_eh
= strcmp (section
->name
, ".eh_frame") == 0;
5120 unsigned int length_return
;
5122 const char *bad_reg
= _("bad register: ");
5123 int saved_eh_addr_size
= eh_addr_size
;
5125 printf (_("Contents of the %s section:\n"), section
->name
);
5129 unsigned char *saved_start
;
5130 unsigned char *block_end
;
5131 unsigned long length
;
5132 unsigned long cie_id
;
5135 int need_col_headers
= 1;
5136 unsigned char *augmentation_data
= NULL
;
5137 unsigned long augmentation_data_len
= 0;
5138 int encoded_ptr_size
= saved_eh_addr_size
;
5140 int initial_length_size
;
5142 saved_start
= start
;
5144 SAFE_BYTE_GET_AND_INC (length
, start
, 4, end
);
5147 printf ("\n%08lx ZERO terminator\n\n",
5148 (unsigned long)(saved_start
- section_start
));
5152 if (length
== 0xffffffff)
5154 SAFE_BYTE_GET_AND_INC (length
, start
, 8, end
);
5156 initial_length_size
= 12;
5161 initial_length_size
= 4;
5164 block_end
= saved_start
+ length
+ initial_length_size
;
5165 if (block_end
> end
)
5167 warn ("Invalid length %#08lx in FDE at %#08lx\n",
5168 length
, (unsigned long)(saved_start
- section_start
));
5172 SAFE_BYTE_GET_AND_INC (cie_id
, start
, offset_size
, end
);
5174 if (is_eh
? (cie_id
== 0) : (cie_id
== DW_CIE_ID
))
5178 fc
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
5179 memset (fc
, 0, sizeof (Frame_Chunk
));
5183 fc
->chunk_start
= saved_start
;
5185 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
5186 fc
->col_offset
= (int *) xmalloc (sizeof (int));
5187 frame_need_space (fc
, max_regs
- 1);
5191 fc
->augmentation
= (char *) start
;
5192 start
= (unsigned char *) strchr ((char *) start
, '\0') + 1;
5194 if (strcmp (fc
->augmentation
, "eh") == 0)
5195 start
+= eh_addr_size
;
5199 GET (fc
->ptr_size
, 1);
5200 GET (fc
->segment_size
, 1);
5201 eh_addr_size
= fc
->ptr_size
;
5205 fc
->ptr_size
= eh_addr_size
;
5206 fc
->segment_size
= 0;
5208 fc
->code_factor
= LEB ();
5209 fc
->data_factor
= SLEB ();
5219 if (fc
->augmentation
[0] == 'z')
5221 augmentation_data_len
= LEB ();
5222 augmentation_data
= start
;
5223 start
+= augmentation_data_len
;
5227 if (do_debug_frames_interp
)
5228 printf ("\n%08lx %08lx %08lx CIE \"%s\" cf=%d df=%d ra=%d\n",
5229 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
5230 fc
->augmentation
, fc
->code_factor
, fc
->data_factor
,
5234 printf ("\n%08lx %08lx %08lx CIE\n",
5235 (unsigned long)(saved_start
- section_start
), length
, cie_id
);
5236 printf (" Version: %d\n", version
);
5237 printf (" Augmentation: \"%s\"\n", fc
->augmentation
);
5240 printf (" Pointer Size: %u\n", fc
->ptr_size
);
5241 printf (" Segment Size: %u\n", fc
->segment_size
);
5243 printf (" Code alignment factor: %u\n", fc
->code_factor
);
5244 printf (" Data alignment factor: %d\n", fc
->data_factor
);
5245 printf (" Return address column: %d\n", fc
->ra
);
5247 if (augmentation_data_len
)
5250 printf (" Augmentation data: ");
5251 for (i
= 0; i
< augmentation_data_len
; ++i
)
5252 printf (" %02x", augmentation_data
[i
]);
5258 if (augmentation_data_len
)
5260 unsigned char *p
, *q
;
5261 p
= (unsigned char *) fc
->augmentation
+ 1;
5262 q
= augmentation_data
;
5269 q
+= 1 + size_of_encoded_value (*q
);
5271 fc
->fde_encoding
= *q
++;
5279 if (fc
->fde_encoding
)
5280 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
5283 frame_need_space (fc
, fc
->ra
);
5287 unsigned char *look_for
;
5288 static Frame_Chunk fde_fc
;
5289 unsigned long segment_selector
;
5292 memset (fc
, 0, sizeof (Frame_Chunk
));
5294 look_for
= is_eh
? start
- 4 - cie_id
: section_start
+ cie_id
;
5296 for (cie
= chunks
; cie
; cie
= cie
->next
)
5297 if (cie
->chunk_start
== look_for
)
5302 warn ("Invalid CIE pointer %#08lx in FDE at %#08lx\n",
5303 cie_id
, (unsigned long)(saved_start
- section_start
));
5305 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
5306 fc
->col_offset
= (int *) xmalloc (sizeof (int));
5307 frame_need_space (fc
, max_regs
- 1);
5309 fc
->augmentation
= "";
5310 fc
->fde_encoding
= 0;
5311 fc
->ptr_size
= eh_addr_size
;
5312 fc
->segment_size
= 0;
5316 fc
->ncols
= cie
->ncols
;
5317 fc
->col_type
= (short int *) xcmalloc (fc
->ncols
, sizeof (short int));
5318 fc
->col_offset
= (int *) xcmalloc (fc
->ncols
, sizeof (int));
5319 memcpy (fc
->col_type
, cie
->col_type
, fc
->ncols
* sizeof (short int));
5320 memcpy (fc
->col_offset
, cie
->col_offset
, fc
->ncols
* sizeof (int));
5321 fc
->augmentation
= cie
->augmentation
;
5322 fc
->ptr_size
= cie
->ptr_size
;
5323 eh_addr_size
= cie
->ptr_size
;
5324 fc
->segment_size
= cie
->segment_size
;
5325 fc
->code_factor
= cie
->code_factor
;
5326 fc
->data_factor
= cie
->data_factor
;
5327 fc
->cfa_reg
= cie
->cfa_reg
;
5328 fc
->cfa_offset
= cie
->cfa_offset
;
5330 frame_need_space (fc
, max_regs
- 1);
5331 fc
->fde_encoding
= cie
->fde_encoding
;
5334 if (fc
->fde_encoding
)
5335 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
5337 segment_selector
= 0;
5338 if (fc
->segment_size
)
5340 SAFE_BYTE_GET_AND_INC (segment_selector
, start
, fc
->segment_size
, end
);
5342 fc
->pc_begin
= get_encoded_value (start
, fc
->fde_encoding
, section
);
5343 start
+= encoded_ptr_size
;
5345 /* FIXME: It appears that sometimes the final pc_range value is
5346 encoded in less than encoded_ptr_size bytes. See the x86_64
5347 run of the "objcopy on compressed debug sections" test for an
5349 SAFE_BYTE_GET_AND_INC (fc
->pc_range
, start
, encoded_ptr_size
, end
);
5351 if (cie
->augmentation
[0] == 'z')
5353 augmentation_data_len
= LEB ();
5354 augmentation_data
= start
;
5355 start
+= augmentation_data_len
;
5358 printf ("\n%08lx %08lx %08lx FDE cie=%08lx pc=",
5359 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
5360 (unsigned long)(cie
->chunk_start
- section_start
));
5361 if (fc
->segment_size
)
5362 printf ("%04lx:", segment_selector
);
5363 printf ("%08lx..%08lx\n", fc
->pc_begin
, fc
->pc_begin
+ fc
->pc_range
);
5364 if (! do_debug_frames_interp
&& augmentation_data_len
)
5368 printf (" Augmentation data: ");
5369 for (i
= 0; i
< augmentation_data_len
; ++i
)
5370 printf (" %02x", augmentation_data
[i
]);
5376 /* At this point, fc is the current chunk, cie (if any) is set, and
5377 we're about to interpret instructions for the chunk. */
5378 /* ??? At present we need to do this always, since this sizes the
5379 fc->col_type and fc->col_offset arrays, which we write into always.
5380 We should probably split the interpreted and non-interpreted bits
5381 into two different routines, since there's so much that doesn't
5382 really overlap between them. */
5383 if (1 || do_debug_frames_interp
)
5385 /* Start by making a pass over the chunk, allocating storage
5386 and taking note of what registers are used. */
5387 unsigned char *tmp
= start
;
5389 while (start
< block_end
)
5392 unsigned long reg
, temp
;
5399 /* Warning: if you add any more cases to this switch, be
5400 sure to add them to the corresponding switch below. */
5403 case DW_CFA_advance_loc
:
5407 if (frame_need_space (fc
, opa
) >= 0)
5408 fc
->col_type
[opa
] = DW_CFA_undefined
;
5410 case DW_CFA_restore
:
5411 if (frame_need_space (fc
, opa
) >= 0)
5412 fc
->col_type
[opa
] = DW_CFA_undefined
;
5414 case DW_CFA_set_loc
:
5415 start
+= encoded_ptr_size
;
5417 case DW_CFA_advance_loc1
:
5420 case DW_CFA_advance_loc2
:
5423 case DW_CFA_advance_loc4
:
5426 case DW_CFA_offset_extended
:
5427 case DW_CFA_val_offset
:
5428 reg
= LEB (); LEB ();
5429 if (frame_need_space (fc
, reg
) >= 0)
5430 fc
->col_type
[reg
] = DW_CFA_undefined
;
5432 case DW_CFA_restore_extended
:
5434 frame_need_space (fc
, reg
);
5435 if (frame_need_space (fc
, reg
) >= 0)
5436 fc
->col_type
[reg
] = DW_CFA_undefined
;
5438 case DW_CFA_undefined
:
5440 if (frame_need_space (fc
, reg
) >= 0)
5441 fc
->col_type
[reg
] = DW_CFA_undefined
;
5443 case DW_CFA_same_value
:
5445 if (frame_need_space (fc
, reg
) >= 0)
5446 fc
->col_type
[reg
] = DW_CFA_undefined
;
5448 case DW_CFA_register
:
5449 reg
= LEB (); LEB ();
5450 if (frame_need_space (fc
, reg
) >= 0)
5451 fc
->col_type
[reg
] = DW_CFA_undefined
;
5453 case DW_CFA_def_cfa
:
5456 case DW_CFA_def_cfa_register
:
5459 case DW_CFA_def_cfa_offset
:
5462 case DW_CFA_def_cfa_expression
:
5466 case DW_CFA_expression
:
5467 case DW_CFA_val_expression
:
5471 if (frame_need_space (fc
, reg
) >= 0)
5472 fc
->col_type
[reg
] = DW_CFA_undefined
;
5474 case DW_CFA_offset_extended_sf
:
5475 case DW_CFA_val_offset_sf
:
5476 reg
= LEB (); SLEB ();
5477 if (frame_need_space (fc
, reg
) >= 0)
5478 fc
->col_type
[reg
] = DW_CFA_undefined
;
5480 case DW_CFA_def_cfa_sf
:
5483 case DW_CFA_def_cfa_offset_sf
:
5486 case DW_CFA_MIPS_advance_loc8
:
5489 case DW_CFA_GNU_args_size
:
5492 case DW_CFA_GNU_negative_offset_extended
:
5493 reg
= LEB (); LEB ();
5494 if (frame_need_space (fc
, reg
) >= 0)
5495 fc
->col_type
[reg
] = DW_CFA_undefined
;
5504 /* Now we know what registers are used, make a second pass over
5505 the chunk, this time actually printing out the info. */
5507 while (start
< block_end
)
5510 unsigned long ul
, reg
, roffs
;
5513 const char *reg_prefix
= "";
5520 /* Warning: if you add any more cases to this switch, be
5521 sure to add them to the corresponding switch above. */
5524 case DW_CFA_advance_loc
:
5525 if (do_debug_frames_interp
)
5526 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5528 printf (" DW_CFA_advance_loc: %d to %08lx\n",
5529 opa
* fc
->code_factor
,
5530 fc
->pc_begin
+ opa
* fc
->code_factor
);
5531 fc
->pc_begin
+= opa
* fc
->code_factor
;
5536 if (opa
>= (unsigned int) fc
->ncols
)
5537 reg_prefix
= bad_reg
;
5538 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5539 printf (" DW_CFA_offset: %s%s at cfa%+ld\n",
5540 reg_prefix
, regname (opa
, 0),
5541 roffs
* fc
->data_factor
);
5542 if (*reg_prefix
== '\0')
5544 fc
->col_type
[opa
] = DW_CFA_offset
;
5545 fc
->col_offset
[opa
] = roffs
* fc
->data_factor
;
5549 case DW_CFA_restore
:
5550 if (opa
>= (unsigned int) cie
->ncols
5551 || opa
>= (unsigned int) fc
->ncols
)
5552 reg_prefix
= bad_reg
;
5553 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5554 printf (" DW_CFA_restore: %s%s\n",
5555 reg_prefix
, regname (opa
, 0));
5556 if (*reg_prefix
== '\0')
5558 fc
->col_type
[opa
] = cie
->col_type
[opa
];
5559 fc
->col_offset
[opa
] = cie
->col_offset
[opa
];
5560 if (do_debug_frames_interp
5561 && fc
->col_type
[opa
] == DW_CFA_unreferenced
)
5562 fc
->col_type
[opa
] = DW_CFA_undefined
;
5566 case DW_CFA_set_loc
:
5567 vma
= get_encoded_value (start
, fc
->fde_encoding
, section
);
5568 start
+= encoded_ptr_size
;
5569 if (do_debug_frames_interp
)
5570 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5572 printf (" DW_CFA_set_loc: %08lx\n", (unsigned long)vma
);
5576 case DW_CFA_advance_loc1
:
5577 SAFE_BYTE_GET_AND_INC (ofs
, start
, 1, end
);
5578 if (do_debug_frames_interp
)
5579 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5581 printf (" DW_CFA_advance_loc1: %ld to %08lx\n",
5582 ofs
* fc
->code_factor
,
5583 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5584 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5587 case DW_CFA_advance_loc2
:
5588 SAFE_BYTE_GET_AND_INC (ofs
, start
, 2, end
);
5589 if (do_debug_frames_interp
)
5590 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5592 printf (" DW_CFA_advance_loc2: %ld to %08lx\n",
5593 ofs
* fc
->code_factor
,
5594 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5595 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5598 case DW_CFA_advance_loc4
:
5599 SAFE_BYTE_GET_AND_INC (ofs
, start
, 4, end
);
5600 if (do_debug_frames_interp
)
5601 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5603 printf (" DW_CFA_advance_loc4: %ld to %08lx\n",
5604 ofs
* fc
->code_factor
,
5605 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5606 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5609 case DW_CFA_offset_extended
:
5612 if (reg
>= (unsigned int) fc
->ncols
)
5613 reg_prefix
= bad_reg
;
5614 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5615 printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n",
5616 reg_prefix
, regname (reg
, 0),
5617 roffs
* fc
->data_factor
);
5618 if (*reg_prefix
== '\0')
5620 fc
->col_type
[reg
] = DW_CFA_offset
;
5621 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
5625 case DW_CFA_val_offset
:
5628 if (reg
>= (unsigned int) fc
->ncols
)
5629 reg_prefix
= bad_reg
;
5630 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5631 printf (" DW_CFA_val_offset: %s%s at cfa%+ld\n",
5632 reg_prefix
, regname (reg
, 0),
5633 roffs
* fc
->data_factor
);
5634 if (*reg_prefix
== '\0')
5636 fc
->col_type
[reg
] = DW_CFA_val_offset
;
5637 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
5641 case DW_CFA_restore_extended
:
5643 if (reg
>= (unsigned int) cie
->ncols
5644 || reg
>= (unsigned int) fc
->ncols
)
5645 reg_prefix
= bad_reg
;
5646 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5647 printf (" DW_CFA_restore_extended: %s%s\n",
5648 reg_prefix
, regname (reg
, 0));
5649 if (*reg_prefix
== '\0')
5651 fc
->col_type
[reg
] = cie
->col_type
[reg
];
5652 fc
->col_offset
[reg
] = cie
->col_offset
[reg
];
5656 case DW_CFA_undefined
:
5658 if (reg
>= (unsigned int) fc
->ncols
)
5659 reg_prefix
= bad_reg
;
5660 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5661 printf (" DW_CFA_undefined: %s%s\n",
5662 reg_prefix
, regname (reg
, 0));
5663 if (*reg_prefix
== '\0')
5665 fc
->col_type
[reg
] = DW_CFA_undefined
;
5666 fc
->col_offset
[reg
] = 0;
5670 case DW_CFA_same_value
:
5672 if (reg
>= (unsigned int) fc
->ncols
)
5673 reg_prefix
= bad_reg
;
5674 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5675 printf (" DW_CFA_same_value: %s%s\n",
5676 reg_prefix
, regname (reg
, 0));
5677 if (*reg_prefix
== '\0')
5679 fc
->col_type
[reg
] = DW_CFA_same_value
;
5680 fc
->col_offset
[reg
] = 0;
5684 case DW_CFA_register
:
5687 if (reg
>= (unsigned int) fc
->ncols
)
5688 reg_prefix
= bad_reg
;
5689 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5691 printf (" DW_CFA_register: %s%s in ",
5692 reg_prefix
, regname (reg
, 0));
5693 puts (regname (roffs
, 0));
5695 if (*reg_prefix
== '\0')
5697 fc
->col_type
[reg
] = DW_CFA_register
;
5698 fc
->col_offset
[reg
] = roffs
;
5702 case DW_CFA_remember_state
:
5703 if (! do_debug_frames_interp
)
5704 printf (" DW_CFA_remember_state\n");
5705 rs
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
5706 rs
->ncols
= fc
->ncols
;
5707 rs
->col_type
= (short int *) xcmalloc (rs
->ncols
,
5708 sizeof (short int));
5709 rs
->col_offset
= (int *) xcmalloc (rs
->ncols
, sizeof (int));
5710 memcpy (rs
->col_type
, fc
->col_type
, rs
->ncols
);
5711 memcpy (rs
->col_offset
, fc
->col_offset
, rs
->ncols
* sizeof (int));
5712 rs
->next
= remembered_state
;
5713 remembered_state
= rs
;
5716 case DW_CFA_restore_state
:
5717 if (! do_debug_frames_interp
)
5718 printf (" DW_CFA_restore_state\n");
5719 rs
= remembered_state
;
5722 remembered_state
= rs
->next
;
5723 frame_need_space (fc
, rs
->ncols
- 1);
5724 memcpy (fc
->col_type
, rs
->col_type
, rs
->ncols
);
5725 memcpy (fc
->col_offset
, rs
->col_offset
,
5726 rs
->ncols
* sizeof (int));
5727 free (rs
->col_type
);
5728 free (rs
->col_offset
);
5731 else if (do_debug_frames_interp
)
5732 printf ("Mismatched DW_CFA_restore_state\n");
5735 case DW_CFA_def_cfa
:
5736 fc
->cfa_reg
= LEB ();
5737 fc
->cfa_offset
= LEB ();
5739 if (! do_debug_frames_interp
)
5740 printf (" DW_CFA_def_cfa: %s ofs %d\n",
5741 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
5744 case DW_CFA_def_cfa_register
:
5745 fc
->cfa_reg
= LEB ();
5747 if (! do_debug_frames_interp
)
5748 printf (" DW_CFA_def_cfa_register: %s\n",
5749 regname (fc
->cfa_reg
, 0));
5752 case DW_CFA_def_cfa_offset
:
5753 fc
->cfa_offset
= LEB ();
5754 if (! do_debug_frames_interp
)
5755 printf (" DW_CFA_def_cfa_offset: %d\n", fc
->cfa_offset
);
5759 if (! do_debug_frames_interp
)
5760 printf (" DW_CFA_nop\n");
5763 case DW_CFA_def_cfa_expression
:
5765 if (! do_debug_frames_interp
)
5767 printf (" DW_CFA_def_cfa_expression (");
5768 decode_location_expression (start
, eh_addr_size
, 0, -1,
5776 case DW_CFA_expression
:
5779 if (reg
>= (unsigned int) fc
->ncols
)
5780 reg_prefix
= bad_reg
;
5781 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5783 printf (" DW_CFA_expression: %s%s (",
5784 reg_prefix
, regname (reg
, 0));
5785 decode_location_expression (start
, eh_addr_size
, 0, -1,
5789 if (*reg_prefix
== '\0')
5790 fc
->col_type
[reg
] = DW_CFA_expression
;
5794 case DW_CFA_val_expression
:
5797 if (reg
>= (unsigned int) fc
->ncols
)
5798 reg_prefix
= bad_reg
;
5799 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5801 printf (" DW_CFA_val_expression: %s%s (",
5802 reg_prefix
, regname (reg
, 0));
5803 decode_location_expression (start
, eh_addr_size
, 0, -1,
5807 if (*reg_prefix
== '\0')
5808 fc
->col_type
[reg
] = DW_CFA_val_expression
;
5812 case DW_CFA_offset_extended_sf
:
5815 if (frame_need_space (fc
, reg
) < 0)
5816 reg_prefix
= bad_reg
;
5817 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5818 printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n",
5819 reg_prefix
, regname (reg
, 0),
5820 l
* fc
->data_factor
);
5821 if (*reg_prefix
== '\0')
5823 fc
->col_type
[reg
] = DW_CFA_offset
;
5824 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
5828 case DW_CFA_val_offset_sf
:
5831 if (frame_need_space (fc
, reg
) < 0)
5832 reg_prefix
= bad_reg
;
5833 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5834 printf (" DW_CFA_val_offset_sf: %s%s at cfa%+ld\n",
5835 reg_prefix
, regname (reg
, 0),
5836 l
* fc
->data_factor
);
5837 if (*reg_prefix
== '\0')
5839 fc
->col_type
[reg
] = DW_CFA_val_offset
;
5840 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
5844 case DW_CFA_def_cfa_sf
:
5845 fc
->cfa_reg
= LEB ();
5846 fc
->cfa_offset
= SLEB ();
5847 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
5849 if (! do_debug_frames_interp
)
5850 printf (" DW_CFA_def_cfa_sf: %s ofs %d\n",
5851 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
5854 case DW_CFA_def_cfa_offset_sf
:
5855 fc
->cfa_offset
= SLEB ();
5856 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
5857 if (! do_debug_frames_interp
)
5858 printf (" DW_CFA_def_cfa_offset_sf: %d\n", fc
->cfa_offset
);
5861 case DW_CFA_MIPS_advance_loc8
:
5862 SAFE_BYTE_GET_AND_INC (ofs
, start
, 8, end
);
5863 if (do_debug_frames_interp
)
5864 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5866 printf (" DW_CFA_MIPS_advance_loc8: %ld to %08lx\n",
5867 ofs
* fc
->code_factor
,
5868 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5869 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5872 case DW_CFA_GNU_window_save
:
5873 if (! do_debug_frames_interp
)
5874 printf (" DW_CFA_GNU_window_save\n");
5877 case DW_CFA_GNU_args_size
:
5879 if (! do_debug_frames_interp
)
5880 printf (" DW_CFA_GNU_args_size: %ld\n", ul
);
5883 case DW_CFA_GNU_negative_offset_extended
:
5886 if (frame_need_space (fc
, reg
) < 0)
5887 reg_prefix
= bad_reg
;
5888 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5889 printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n",
5890 reg_prefix
, regname (reg
, 0),
5891 l
* fc
->data_factor
);
5892 if (*reg_prefix
== '\0')
5894 fc
->col_type
[reg
] = DW_CFA_offset
;
5895 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
5900 if (op
>= DW_CFA_lo_user
&& op
<= DW_CFA_hi_user
)
5901 printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op
);
5903 warn (_("unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op
);
5908 if (do_debug_frames_interp
)
5909 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5912 eh_addr_size
= saved_eh_addr_size
;
5925 display_gdb_index (struct dwarf_section
*section
,
5926 void *file ATTRIBUTE_UNUSED
)
5928 unsigned char *start
= section
->start
;
5930 uint32_t cu_list_offset
, tu_list_offset
;
5931 uint32_t address_table_offset
, symbol_table_offset
, constant_pool_offset
;
5932 unsigned int cu_list_elements
, tu_list_elements
;
5933 unsigned int address_table_size
, symbol_table_slots
;
5934 unsigned char *cu_list
, *tu_list
;
5935 unsigned char *address_table
, *symbol_table
, *constant_pool
;
5938 /* The documentation for the format of this file is in gdb/dwarf2read.c. */
5940 printf (_("Contents of the %s section:\n"), section
->name
);
5942 if (section
->size
< 6 * sizeof (uint32_t))
5944 warn (_("Truncated header in the %s section.\n"), section
->name
);
5948 version
= byte_get_little_endian (start
, 4);
5949 printf (_("Version %ld\n"), (long) version
);
5951 /* Prior versions are obsolete, and future versions may not be
5952 backwards compatible. */
5953 if (version
< 3 || version
> 8)
5955 warn (_("Unsupported version %lu.\n"), (unsigned long) version
);
5959 warn (_("The address table data in version 3 may be wrong.\n"));
5961 warn (_("Version 4 does not support case insensitive lookups.\n"));
5963 warn (_("Version 5 does not include inlined functions.\n"));
5965 warn (_("Version 6 does not include symbol attributes.\n"));
5966 /* Version 7 indices generated by Gold have bad type unit references,
5967 PR binutils/15021. But we don't know if the index was generated by
5968 Gold or not, so to avoid worrying users with gdb-generated indices
5969 we say nothing for version 7 here. */
5971 cu_list_offset
= byte_get_little_endian (start
+ 4, 4);
5972 tu_list_offset
= byte_get_little_endian (start
+ 8, 4);
5973 address_table_offset
= byte_get_little_endian (start
+ 12, 4);
5974 symbol_table_offset
= byte_get_little_endian (start
+ 16, 4);
5975 constant_pool_offset
= byte_get_little_endian (start
+ 20, 4);
5977 if (cu_list_offset
> section
->size
5978 || tu_list_offset
> section
->size
5979 || address_table_offset
> section
->size
5980 || symbol_table_offset
> section
->size
5981 || constant_pool_offset
> section
->size
)
5983 warn (_("Corrupt header in the %s section.\n"), section
->name
);
5987 cu_list_elements
= (tu_list_offset
- cu_list_offset
) / 8;
5988 tu_list_elements
= (address_table_offset
- tu_list_offset
) / 8;
5989 address_table_size
= symbol_table_offset
- address_table_offset
;
5990 symbol_table_slots
= (constant_pool_offset
- symbol_table_offset
) / 8;
5992 cu_list
= start
+ cu_list_offset
;
5993 tu_list
= start
+ tu_list_offset
;
5994 address_table
= start
+ address_table_offset
;
5995 symbol_table
= start
+ symbol_table_offset
;
5996 constant_pool
= start
+ constant_pool_offset
;
5998 printf (_("\nCU table:\n"));
5999 for (i
= 0; i
< cu_list_elements
; i
+= 2)
6001 uint64_t cu_offset
= byte_get_little_endian (cu_list
+ i
* 8, 8);
6002 uint64_t cu_length
= byte_get_little_endian (cu_list
+ i
* 8 + 8, 8);
6004 printf (_("[%3u] 0x%lx - 0x%lx\n"), i
/ 2,
6005 (unsigned long) cu_offset
,
6006 (unsigned long) (cu_offset
+ cu_length
- 1));
6009 printf (_("\nTU table:\n"));
6010 for (i
= 0; i
< tu_list_elements
; i
+= 3)
6012 uint64_t tu_offset
= byte_get_little_endian (tu_list
+ i
* 8, 8);
6013 uint64_t type_offset
= byte_get_little_endian (tu_list
+ i
* 8 + 8, 8);
6014 uint64_t signature
= byte_get_little_endian (tu_list
+ i
* 8 + 16, 8);
6016 printf (_("[%3u] 0x%lx 0x%lx "), i
/ 3,
6017 (unsigned long) tu_offset
,
6018 (unsigned long) type_offset
);
6019 print_dwarf_vma (signature
, 8);
6023 printf (_("\nAddress table:\n"));
6024 for (i
= 0; i
< address_table_size
; i
+= 2 * 8 + 4)
6026 uint64_t low
= byte_get_little_endian (address_table
+ i
, 8);
6027 uint64_t high
= byte_get_little_endian (address_table
+ i
+ 8, 8);
6028 uint32_t cu_index
= byte_get_little_endian (address_table
+ i
+ 16, 4);
6030 print_dwarf_vma (low
, 8);
6031 print_dwarf_vma (high
, 8);
6032 printf (_("%lu\n"), (unsigned long) cu_index
);
6035 printf (_("\nSymbol table:\n"));
6036 for (i
= 0; i
< symbol_table_slots
; ++i
)
6038 uint32_t name_offset
= byte_get_little_endian (symbol_table
+ i
* 8, 4);
6039 uint32_t cu_vector_offset
= byte_get_little_endian (symbol_table
+ i
* 8 + 4, 4);
6040 uint32_t num_cus
, cu
;
6042 if (name_offset
!= 0
6043 || cu_vector_offset
!= 0)
6047 printf ("[%3u] %s:", i
, constant_pool
+ name_offset
);
6048 num_cus
= byte_get_little_endian (constant_pool
+ cu_vector_offset
, 4);
6051 for (j
= 0; j
< num_cus
; ++j
)
6054 gdb_index_symbol_kind kind
;
6056 cu
= byte_get_little_endian (constant_pool
+ cu_vector_offset
+ 4 + j
* 4, 4);
6057 is_static
= GDB_INDEX_SYMBOL_STATIC_VALUE (cu
);
6058 kind
= GDB_INDEX_SYMBOL_KIND_VALUE (cu
);
6059 cu
= GDB_INDEX_CU_VALUE (cu
);
6060 /* Convert to TU number if it's for a type unit. */
6061 if (cu
>= cu_list_elements
/ 2)
6062 printf ("%cT%lu", num_cus
> 1 ? '\t' : ' ',
6063 (unsigned long) (cu
- cu_list_elements
/ 2));
6065 printf ("%c%lu", num_cus
> 1 ? '\t' : ' ', (unsigned long) cu
);
6069 case GDB_INDEX_SYMBOL_KIND_NONE
:
6070 printf (_(" [no symbol information]"));
6072 case GDB_INDEX_SYMBOL_KIND_TYPE
:
6074 ? _(" [static type]")
6075 : _(" [global type]"));
6077 case GDB_INDEX_SYMBOL_KIND_VARIABLE
:
6079 ? _(" [static variable]")
6080 : _(" [global variable]"));
6082 case GDB_INDEX_SYMBOL_KIND_FUNCTION
:
6084 ? _(" [static function]")
6085 : _(" [global function]"));
6087 case GDB_INDEX_SYMBOL_KIND_OTHER
:
6089 ? _(" [static other]")
6090 : _(" [global other]"));
6094 ? _(" [static unknown: %d]")
6095 : _(" [global unknown: %d]"),
6110 /* Pre-allocate enough space for the CU/TU sets needed. */
6113 prealloc_cu_tu_list (unsigned int nshndx
)
6115 if (shndx_pool
== NULL
)
6117 shndx_pool_size
= nshndx
;
6118 shndx_pool_used
= 0;
6119 shndx_pool
= (unsigned int *) xcmalloc (shndx_pool_size
,
6120 sizeof (unsigned int));
6124 shndx_pool_size
= shndx_pool_used
+ nshndx
;
6125 shndx_pool
= (unsigned int *) xcrealloc (shndx_pool
, shndx_pool_size
,
6126 sizeof (unsigned int));
6131 add_shndx_to_cu_tu_entry (unsigned int shndx
)
6133 if (shndx_pool_used
>= shndx_pool_size
)
6135 error (_("Internal error: out of space in the shndx pool.\n"));
6138 shndx_pool
[shndx_pool_used
++] = shndx
;
6142 end_cu_tu_entry (void)
6144 if (shndx_pool_used
>= shndx_pool_size
)
6146 error (_("Internal error: out of space in the shndx pool.\n"));
6149 shndx_pool
[shndx_pool_used
++] = 0;
6152 /* Return the short name of a DWARF section given by a DW_SECT enumerator. */
6155 get_DW_SECT_short_name (unsigned int dw_sect
)
6157 static char buf
[16];
6165 case DW_SECT_ABBREV
:
6171 case DW_SECT_STR_OFFSETS
:
6173 case DW_SECT_MACINFO
:
6181 snprintf (buf
, sizeof (buf
), "%d", dw_sect
);
6185 /* Process a CU or TU index. If DO_DISPLAY is true, print the contents.
6186 These sections are extensions for Fission.
6187 See http://gcc.gnu.org/wiki/DebugFissionDWP. */
6190 process_cu_tu_index (struct dwarf_section
*section
, int do_display
)
6192 unsigned char *phdr
= section
->start
;
6193 unsigned char *limit
= phdr
+ section
->size
;
6194 unsigned char *phash
;
6195 unsigned char *pindex
;
6196 unsigned char *ppool
;
6197 unsigned int version
;
6198 unsigned int ncols
= 0;
6200 unsigned int nslots
;
6203 dwarf_vma signature_high
;
6204 dwarf_vma signature_low
;
6207 version
= byte_get (phdr
, 4);
6209 ncols
= byte_get (phdr
+ 4, 4);
6210 nused
= byte_get (phdr
+ 8, 4);
6211 nslots
= byte_get (phdr
+ 12, 4);
6213 pindex
= phash
+ nslots
* 8;
6214 ppool
= pindex
+ nslots
* 4;
6218 printf (_("Contents of the %s section:\n\n"), section
->name
);
6219 printf (_(" Version: %d\n"), version
);
6221 printf (_(" Number of columns: %d\n"), ncols
);
6222 printf (_(" Number of used entries: %d\n"), nused
);
6223 printf (_(" Number of slots: %d\n\n"), nslots
);
6228 warn (_("Section %s too small for %d hash table entries\n"),
6229 section
->name
, nslots
);
6236 prealloc_cu_tu_list ((limit
- ppool
) / 4);
6237 for (i
= 0; i
< nslots
; i
++)
6239 unsigned char *shndx_list
;
6242 byte_get_64 (phash
, &signature_high
, &signature_low
);
6243 if (signature_high
!= 0 || signature_low
!= 0)
6245 j
= byte_get (pindex
, 4);
6246 shndx_list
= ppool
+ j
* 4;
6248 printf (_(" [%3d] Signature: 0x%s Sections: "),
6249 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
6250 buf
, sizeof (buf
)));
6253 if (shndx_list
>= limit
)
6255 warn (_("Section %s too small for shndx pool\n"),
6259 shndx
= byte_get (shndx_list
, 4);
6263 printf (" %d", shndx
);
6265 add_shndx_to_cu_tu_entry (shndx
);
6277 else if (version
== 2)
6280 unsigned int dw_sect
;
6281 unsigned char *ph
= phash
;
6282 unsigned char *pi
= pindex
;
6283 unsigned char *poffsets
= ppool
+ ncols
* 4;
6284 unsigned char *psizes
= poffsets
+ nused
* ncols
* 4;
6285 unsigned char *pend
= psizes
+ nused
* ncols
* 4;
6286 bfd_boolean is_tu_index
;
6287 struct cu_tu_set
*this_set
= NULL
;
6289 unsigned char *prow
;
6291 is_tu_index
= strcmp (section
->name
, ".debug_tu_index") == 0;
6295 warn (_("Section %s too small for offset and size tables\n"),
6302 printf (_(" Offset table\n"));
6303 printf (" slot %-16s ",
6304 is_tu_index
? _("signature") : _("dwo_id"));
6311 tu_sets
= xcmalloc (nused
, sizeof (struct cu_tu_set
));
6317 cu_sets
= xcmalloc (nused
, sizeof (struct cu_tu_set
));
6323 for (j
= 0; j
< ncols
; j
++)
6325 dw_sect
= byte_get (ppool
+ j
* 4, 4);
6326 printf (" %8s", get_DW_SECT_short_name (dw_sect
));
6330 for (i
= 0; i
< nslots
; i
++)
6332 byte_get_64 (ph
, &signature_high
, &signature_low
);
6333 row
= byte_get (pi
, 4);
6337 memcpy (&this_set
[row
- 1].signature
, ph
, sizeof (uint64_t));
6338 prow
= poffsets
+ (row
- 1) * ncols
* 4;
6340 printf (_(" [%3d] 0x%s"),
6341 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
6342 buf
, sizeof (buf
)));
6343 for (j
= 0; j
< ncols
; j
++)
6345 val
= byte_get (prow
+ j
* 4, 4);
6347 printf (" %8d", val
);
6350 dw_sect
= byte_get (ppool
+ j
* 4, 4);
6351 this_set
[row
- 1].section_offsets
[dw_sect
] = val
;
6366 printf (_(" Size table\n"));
6367 printf (" slot %-16s ",
6368 is_tu_index
? _("signature") : _("dwo_id"));
6370 for (j
= 0; j
< ncols
; j
++)
6372 val
= byte_get (ppool
+ j
* 4, 4);
6374 printf (" %8s", get_DW_SECT_short_name (val
));
6378 for (i
= 0; i
< nslots
; i
++)
6380 byte_get_64 (ph
, &signature_high
, &signature_low
);
6381 row
= byte_get (pi
, 4);
6384 prow
= psizes
+ (row
- 1) * ncols
* 4;
6386 printf (_(" [%3d] 0x%s"),
6387 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
6388 buf
, sizeof (buf
)));
6389 for (j
= 0; j
< ncols
; j
++)
6391 val
= byte_get (prow
+ j
* 4, 4);
6393 printf (" %8d", val
);
6396 dw_sect
= byte_get (ppool
+ j
* 4, 4);
6397 this_set
[row
- 1].section_sizes
[dw_sect
] = val
;
6407 else if (do_display
)
6408 printf (_(" Unsupported version\n"));
6416 /* Load the CU and TU indexes if present. This will build a list of
6417 section sets that we can use to associate a .debug_info.dwo section
6418 with its associated .debug_abbrev.dwo section in a .dwp file. */
6421 load_cu_tu_indexes (void *file
)
6423 /* If we have already loaded (or tried to load) the CU and TU indexes
6424 then do not bother to repeat the task. */
6425 if (cu_tu_indexes_read
)
6428 if (load_debug_section (dwp_cu_index
, file
))
6429 process_cu_tu_index (&debug_displays
[dwp_cu_index
].section
, 0);
6431 if (load_debug_section (dwp_tu_index
, file
))
6432 process_cu_tu_index (&debug_displays
[dwp_tu_index
].section
, 0);
6434 cu_tu_indexes_read
= 1;
6437 /* Find the set of sections that includes section SHNDX. */
6440 find_cu_tu_set (void *file
, unsigned int shndx
)
6444 load_cu_tu_indexes (file
);
6446 /* Find SHNDX in the shndx pool. */
6447 for (i
= 0; i
< shndx_pool_used
; i
++)
6448 if (shndx_pool
[i
] == shndx
)
6451 if (i
>= shndx_pool_used
)
6454 /* Now backup to find the first entry in the set. */
6455 while (i
> 0 && shndx_pool
[i
- 1] != 0)
6458 return shndx_pool
+ i
;
6461 /* Display a .debug_cu_index or .debug_tu_index section. */
6464 display_cu_index (struct dwarf_section
*section
, void *file ATTRIBUTE_UNUSED
)
6466 return process_cu_tu_index (section
, 1);
6470 display_debug_not_supported (struct dwarf_section
*section
,
6471 void *file ATTRIBUTE_UNUSED
)
6473 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
6480 cmalloc (size_t nmemb
, size_t size
)
6482 /* Check for overflow. */
6483 if (nmemb
>= ~(size_t) 0 / size
)
6486 return malloc (nmemb
* size
);
6490 xcmalloc (size_t nmemb
, size_t size
)
6492 /* Check for overflow. */
6493 if (nmemb
>= ~(size_t) 0 / size
)
6496 return xmalloc (nmemb
* size
);
6500 xcrealloc (void *ptr
, size_t nmemb
, size_t size
)
6502 /* Check for overflow. */
6503 if (nmemb
>= ~(size_t) 0 / size
)
6506 return xrealloc (ptr
, nmemb
* size
);
6510 free_debug_memory (void)
6516 for (i
= 0; i
< max
; i
++)
6517 free_debug_section ((enum dwarf_section_display_enum
) i
);
6519 if (debug_information
!= NULL
)
6521 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
)
6523 for (i
= 0; i
< num_debug_info_entries
; i
++)
6525 if (!debug_information
[i
].max_loc_offsets
)
6527 free (debug_information
[i
].loc_offsets
);
6528 free (debug_information
[i
].have_frame_base
);
6530 if (!debug_information
[i
].max_range_lists
)
6531 free (debug_information
[i
].range_lists
);
6535 free (debug_information
);
6536 debug_information
= NULL
;
6537 num_debug_info_entries
= 0;
6542 dwarf_select_sections_by_names (const char *names
)
6546 const char * option
;
6550 debug_dump_long_opts
;
6552 static const debug_dump_long_opts opts_table
[] =
6554 /* Please keep this table alpha- sorted. */
6555 { "Ranges", & do_debug_ranges
, 1 },
6556 { "abbrev", & do_debug_abbrevs
, 1 },
6557 { "addr", & do_debug_addr
, 1 },
6558 { "aranges", & do_debug_aranges
, 1 },
6559 { "cu_index", & do_debug_cu_index
, 1 },
6560 { "decodedline", & do_debug_lines
, FLAG_DEBUG_LINES_DECODED
},
6561 { "frames", & do_debug_frames
, 1 },
6562 { "frames-interp", & do_debug_frames_interp
, 1 },
6563 /* The special .gdb_index section. */
6564 { "gdb_index", & do_gdb_index
, 1 },
6565 { "info", & do_debug_info
, 1 },
6566 { "line", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
}, /* For backwards compatibility. */
6567 { "loc", & do_debug_loc
, 1 },
6568 { "macro", & do_debug_macinfo
, 1 },
6569 { "pubnames", & do_debug_pubnames
, 1 },
6570 { "pubtypes", & do_debug_pubtypes
, 1 },
6571 /* This entry is for compatability
6572 with earlier versions of readelf. */
6573 { "ranges", & do_debug_aranges
, 1 },
6574 { "rawline", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
},
6575 { "str", & do_debug_str
, 1 },
6576 /* These trace_* sections are used by Itanium VMS. */
6577 { "trace_abbrev", & do_trace_abbrevs
, 1 },
6578 { "trace_aranges", & do_trace_aranges
, 1 },
6579 { "trace_info", & do_trace_info
, 1 },
6588 const debug_dump_long_opts
* entry
;
6590 for (entry
= opts_table
; entry
->option
; entry
++)
6592 size_t len
= strlen (entry
->option
);
6594 if (strncmp (p
, entry
->option
, len
) == 0
6595 && (p
[len
] == ',' || p
[len
] == '\0'))
6597 * entry
->variable
|= entry
->val
;
6599 /* The --debug-dump=frames-interp option also
6600 enables the --debug-dump=frames option. */
6601 if (do_debug_frames_interp
)
6602 do_debug_frames
= 1;
6609 if (entry
->option
== NULL
)
6611 warn (_("Unrecognized debug option '%s'\n"), p
);
6612 p
= strchr (p
, ',');
6623 dwarf_select_sections_by_letters (const char *letters
)
6625 unsigned int lindex
= 0;
6627 while (letters
[lindex
])
6628 switch (letters
[lindex
++])
6635 do_debug_abbrevs
= 1;
6639 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
6643 do_debug_lines
|= FLAG_DEBUG_LINES_DECODED
;
6647 do_debug_pubnames
= 1;
6651 do_debug_pubtypes
= 1;
6655 do_debug_aranges
= 1;
6659 do_debug_ranges
= 1;
6663 do_debug_frames_interp
= 1;
6665 do_debug_frames
= 1;
6669 do_debug_macinfo
= 1;
6681 warn (_("Unrecognized debug option '%s'\n"), optarg
);
6687 dwarf_select_sections_all (void)
6690 do_debug_abbrevs
= 1;
6691 do_debug_lines
= FLAG_DEBUG_LINES_RAW
;
6692 do_debug_pubnames
= 1;
6693 do_debug_pubtypes
= 1;
6694 do_debug_aranges
= 1;
6695 do_debug_ranges
= 1;
6696 do_debug_frames
= 1;
6697 do_debug_macinfo
= 1;
6702 do_trace_abbrevs
= 1;
6703 do_trace_aranges
= 1;
6705 do_debug_cu_index
= 1;
6708 struct dwarf_section_display debug_displays
[] =
6710 { { ".debug_abbrev", ".zdebug_abbrev", NULL
, NULL
, 0, 0, 0 },
6711 display_debug_abbrev
, &do_debug_abbrevs
, 0 },
6712 { { ".debug_aranges", ".zdebug_aranges", NULL
, NULL
, 0, 0, 0 },
6713 display_debug_aranges
, &do_debug_aranges
, 1 },
6714 { { ".debug_frame", ".zdebug_frame", NULL
, NULL
, 0, 0, 0 },
6715 display_debug_frames
, &do_debug_frames
, 1 },
6716 { { ".debug_info", ".zdebug_info", NULL
, NULL
, 0, 0, abbrev
},
6717 display_debug_info
, &do_debug_info
, 1 },
6718 { { ".debug_line", ".zdebug_line", NULL
, NULL
, 0, 0, 0 },
6719 display_debug_lines
, &do_debug_lines
, 1 },
6720 { { ".debug_pubnames", ".zdebug_pubnames", NULL
, NULL
, 0, 0, 0 },
6721 display_debug_pubnames
, &do_debug_pubnames
, 0 },
6722 { { ".eh_frame", "", NULL
, NULL
, 0, 0, 0 },
6723 display_debug_frames
, &do_debug_frames
, 1 },
6724 { { ".debug_macinfo", ".zdebug_macinfo", NULL
, NULL
, 0, 0, 0 },
6725 display_debug_macinfo
, &do_debug_macinfo
, 0 },
6726 { { ".debug_macro", ".zdebug_macro", NULL
, NULL
, 0, 0, 0 },
6727 display_debug_macro
, &do_debug_macinfo
, 1 },
6728 { { ".debug_str", ".zdebug_str", NULL
, NULL
, 0, 0, 0 },
6729 display_debug_str
, &do_debug_str
, 0 },
6730 { { ".debug_loc", ".zdebug_loc", NULL
, NULL
, 0, 0, 0 },
6731 display_debug_loc
, &do_debug_loc
, 1 },
6732 { { ".debug_pubtypes", ".zdebug_pubtypes", NULL
, NULL
, 0, 0, 0 },
6733 display_debug_pubnames
, &do_debug_pubtypes
, 0 },
6734 { { ".debug_ranges", ".zdebug_ranges", NULL
, NULL
, 0, 0, 0 },
6735 display_debug_ranges
, &do_debug_ranges
, 1 },
6736 { { ".debug_static_func", ".zdebug_static_func", NULL
, NULL
, 0, 0, 0 },
6737 display_debug_not_supported
, NULL
, 0 },
6738 { { ".debug_static_vars", ".zdebug_static_vars", NULL
, NULL
, 0, 0, 0 },
6739 display_debug_not_supported
, NULL
, 0 },
6740 { { ".debug_types", ".zdebug_types", NULL
, NULL
, 0, 0, abbrev
},
6741 display_debug_types
, &do_debug_info
, 1 },
6742 { { ".debug_weaknames", ".zdebug_weaknames", NULL
, NULL
, 0, 0, 0 },
6743 display_debug_not_supported
, NULL
, 0 },
6744 { { ".gdb_index", "", NULL
, NULL
, 0, 0, 0 },
6745 display_gdb_index
, &do_gdb_index
, 0 },
6746 { { ".trace_info", "", NULL
, NULL
, 0, 0, trace_abbrev
},
6747 display_trace_info
, &do_trace_info
, 1 },
6748 { { ".trace_abbrev", "", NULL
, NULL
, 0, 0, 0 },
6749 display_debug_abbrev
, &do_trace_abbrevs
, 0 },
6750 { { ".trace_aranges", "", NULL
, NULL
, 0, 0, 0 },
6751 display_debug_aranges
, &do_trace_aranges
, 0 },
6752 { { ".debug_info.dwo", ".zdebug_info.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6753 display_debug_info
, &do_debug_info
, 1 },
6754 { { ".debug_abbrev.dwo", ".zdebug_abbrev.dwo", NULL
, NULL
, 0, 0, 0 },
6755 display_debug_abbrev
, &do_debug_abbrevs
, 0 },
6756 { { ".debug_types.dwo", ".zdebug_types.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6757 display_debug_types
, &do_debug_info
, 1 },
6758 { { ".debug_line.dwo", ".zdebug_line.dwo", NULL
, NULL
, 0, 0, 0 },
6759 display_debug_lines
, &do_debug_lines
, 1 },
6760 { { ".debug_loc.dwo", ".zdebug_loc.dwo", NULL
, NULL
, 0, 0, 0 },
6761 display_debug_loc
, &do_debug_loc
, 1 },
6762 { { ".debug_macro.dwo", ".zdebug_macro.dwo", NULL
, NULL
, 0, 0, 0 },
6763 display_debug_macro
, &do_debug_macinfo
, 1 },
6764 { { ".debug_macinfo.dwo", ".zdebug_macinfo.dwo", NULL
, NULL
, 0, 0, 0 },
6765 display_debug_macinfo
, &do_debug_macinfo
, 0 },
6766 { { ".debug_str.dwo", ".zdebug_str.dwo", NULL
, NULL
, 0, 0, 0 },
6767 display_debug_str
, &do_debug_str
, 1 },
6768 { { ".debug_str_offsets", ".zdebug_str_offsets", NULL
, NULL
, 0, 0, 0 },
6769 display_debug_str_offsets
, NULL
, 0 },
6770 { { ".debug_str_offsets.dwo", ".zdebug_str_offsets.dwo", NULL
, NULL
, 0, 0, 0 },
6771 display_debug_str_offsets
, NULL
, 0 },
6772 { { ".debug_addr", ".zdebug_addr", NULL
, NULL
, 0, 0, 0 },
6773 display_debug_addr
, &do_debug_addr
, 1 },
6774 { { ".debug_cu_index", "", NULL
, NULL
, 0, 0, 0 },
6775 display_cu_index
, &do_debug_cu_index
, 0 },
6776 { { ".debug_tu_index", "", NULL
, NULL
, 0, 0, 0 },
6777 display_cu_index
, &do_debug_cu_index
, 0 },