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
;
2661 if (const_strneq (section
->name
, ".debug_line.")
2662 /* Note: the following does not apply to .debug_line.dwo sections.
2663 These are full debug_line sections. */
2664 && strcmp (section
->name
, ".debug_line.dwo") != 0)
2666 /* Sections named .debug_line.<foo> are fragments of a .debug_line
2667 section containing just the Line Number Statements. They are
2668 created by the assembler and intended to be used alongside gcc's
2669 -ffunction-sections command line option. When the linker's
2670 garbage collection decides to discard a .text.<foo> section it
2671 can then also discard the line number information in .debug_line.<foo>.
2673 Since the section is a fragment it does not have the details
2674 needed to fill out a LineInfo structure, so instead we use the
2675 details from the last full debug_line section that we processed. */
2676 end_of_sequence
= end
;
2677 standard_opcodes
= NULL
;
2678 linfo
= saved_linfo
;
2679 reset_state_machine (linfo
.li_default_is_stmt
);
2683 unsigned char * hdrptr
;
2685 if ((hdrptr
= read_debug_line_header (section
, data
, end
, & linfo
,
2686 & end_of_sequence
)) == NULL
)
2689 printf (_(" Offset: 0x%lx\n"), (long)(data
- start
));
2690 printf (_(" Length: %ld\n"), (long) linfo
.li_length
);
2691 printf (_(" DWARF Version: %d\n"), linfo
.li_version
);
2692 printf (_(" Prologue Length: %d\n"), linfo
.li_prologue_length
);
2693 printf (_(" Minimum Instruction Length: %d\n"), linfo
.li_min_insn_length
);
2694 if (linfo
.li_version
>= 4)
2695 printf (_(" Maximum Ops per Instruction: %d\n"), linfo
.li_max_ops_per_insn
);
2696 printf (_(" Initial value of 'is_stmt': %d\n"), linfo
.li_default_is_stmt
);
2697 printf (_(" Line Base: %d\n"), linfo
.li_line_base
);
2698 printf (_(" Line Range: %d\n"), linfo
.li_line_range
);
2699 printf (_(" Opcode Base: %d\n"), linfo
.li_opcode_base
);
2701 reset_state_machine (linfo
.li_default_is_stmt
);
2703 /* Display the contents of the Opcodes table. */
2704 standard_opcodes
= hdrptr
;
2706 printf (_("\n Opcodes:\n"));
2708 for (i
= 1; i
< linfo
.li_opcode_base
; i
++)
2709 printf (_(" Opcode %d has %d args\n"), i
, standard_opcodes
[i
- 1]);
2711 /* Display the contents of the Directory table. */
2712 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
2715 printf (_("\n The Directory Table is empty.\n"));
2718 printf (_("\n The Directory Table:\n"));
2722 printf (" %s\n", data
);
2724 data
+= strnlen ((char *) data
, end
- data
) + 1;
2728 /* Skip the NUL at the end of the table. */
2731 /* Display the contents of the File Name table. */
2733 printf (_("\n The File Name Table is empty.\n"));
2736 printf (_("\n The File Name Table:\n"));
2737 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
2741 unsigned char *name
;
2742 unsigned int bytes_read
;
2744 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
2746 data
+= strnlen ((char *) data
, end
- data
) + 1;
2749 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
2752 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
2755 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
2757 printf ("%s\n", name
);
2761 warn (_("Corrupt file name table entry\n"));
2767 /* Skip the NUL at the end of the table. */
2770 saved_linfo
= linfo
;
2773 /* Now display the statements. */
2774 if (data
>= end_of_sequence
)
2775 printf (_(" No Line Number Statements.\n"));
2778 printf (_(" Line Number Statements:\n"));
2780 while (data
< end_of_sequence
)
2782 unsigned char op_code
;
2783 dwarf_signed_vma adv
;
2785 unsigned int bytes_read
;
2789 if (op_code
>= linfo
.li_opcode_base
)
2791 op_code
-= linfo
.li_opcode_base
;
2792 uladv
= (op_code
/ linfo
.li_line_range
);
2793 if (linfo
.li_max_ops_per_insn
== 1)
2795 uladv
*= linfo
.li_min_insn_length
;
2796 state_machine_regs
.address
+= uladv
;
2797 printf (_(" Special opcode %d: "
2798 "advance Address by %s to 0x%s"),
2799 op_code
, dwarf_vmatoa ("u", uladv
),
2800 dwarf_vmatoa ("x", state_machine_regs
.address
));
2804 state_machine_regs
.address
2805 += ((state_machine_regs
.op_index
+ uladv
)
2806 / linfo
.li_max_ops_per_insn
)
2807 * linfo
.li_min_insn_length
;
2808 state_machine_regs
.op_index
2809 = (state_machine_regs
.op_index
+ uladv
)
2810 % linfo
.li_max_ops_per_insn
;
2811 printf (_(" Special opcode %d: "
2812 "advance Address by %s to 0x%s[%d]"),
2813 op_code
, dwarf_vmatoa ("u", uladv
),
2814 dwarf_vmatoa ("x", state_machine_regs
.address
),
2815 state_machine_regs
.op_index
);
2817 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
2818 state_machine_regs
.line
+= adv
;
2819 printf (_(" and Line by %s to %d\n"),
2820 dwarf_vmatoa ("d", adv
), state_machine_regs
.line
);
2822 else switch (op_code
)
2824 case DW_LNS_extended_op
:
2825 data
+= process_extended_line_op (data
, linfo
.li_default_is_stmt
, end
);
2829 printf (_(" Copy\n"));
2832 case DW_LNS_advance_pc
:
2833 uladv
= read_uleb128 (data
, & bytes_read
, end
);
2835 if (linfo
.li_max_ops_per_insn
== 1)
2837 uladv
*= linfo
.li_min_insn_length
;
2838 state_machine_regs
.address
+= uladv
;
2839 printf (_(" Advance PC by %s to 0x%s\n"),
2840 dwarf_vmatoa ("u", uladv
),
2841 dwarf_vmatoa ("x", state_machine_regs
.address
));
2845 state_machine_regs
.address
2846 += ((state_machine_regs
.op_index
+ uladv
)
2847 / linfo
.li_max_ops_per_insn
)
2848 * linfo
.li_min_insn_length
;
2849 state_machine_regs
.op_index
2850 = (state_machine_regs
.op_index
+ uladv
)
2851 % linfo
.li_max_ops_per_insn
;
2852 printf (_(" Advance PC by %s to 0x%s[%d]\n"),
2853 dwarf_vmatoa ("u", uladv
),
2854 dwarf_vmatoa ("x", state_machine_regs
.address
),
2855 state_machine_regs
.op_index
);
2859 case DW_LNS_advance_line
:
2860 adv
= read_sleb128 (data
, & bytes_read
, end
);
2862 state_machine_regs
.line
+= adv
;
2863 printf (_(" Advance Line by %s to %d\n"),
2864 dwarf_vmatoa ("d", adv
),
2865 state_machine_regs
.line
);
2868 case DW_LNS_set_file
:
2869 adv
= read_uleb128 (data
, & bytes_read
, end
);
2871 printf (_(" Set File Name to entry %s in the File Name Table\n"),
2872 dwarf_vmatoa ("d", adv
));
2873 state_machine_regs
.file
= adv
;
2876 case DW_LNS_set_column
:
2877 uladv
= read_uleb128 (data
, & bytes_read
, end
);
2879 printf (_(" Set column to %s\n"),
2880 dwarf_vmatoa ("u", uladv
));
2881 state_machine_regs
.column
= uladv
;
2884 case DW_LNS_negate_stmt
:
2885 adv
= state_machine_regs
.is_stmt
;
2887 printf (_(" Set is_stmt to %s\n"), dwarf_vmatoa ("d", adv
));
2888 state_machine_regs
.is_stmt
= adv
;
2891 case DW_LNS_set_basic_block
:
2892 printf (_(" Set basic block\n"));
2893 state_machine_regs
.basic_block
= 1;
2896 case DW_LNS_const_add_pc
:
2897 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
2898 if (linfo
.li_max_ops_per_insn
)
2900 uladv
*= linfo
.li_min_insn_length
;
2901 state_machine_regs
.address
+= uladv
;
2902 printf (_(" Advance PC by constant %s to 0x%s\n"),
2903 dwarf_vmatoa ("u", uladv
),
2904 dwarf_vmatoa ("x", state_machine_regs
.address
));
2908 state_machine_regs
.address
2909 += ((state_machine_regs
.op_index
+ uladv
)
2910 / linfo
.li_max_ops_per_insn
)
2911 * linfo
.li_min_insn_length
;
2912 state_machine_regs
.op_index
2913 = (state_machine_regs
.op_index
+ uladv
)
2914 % linfo
.li_max_ops_per_insn
;
2915 printf (_(" Advance PC by constant %s to 0x%s[%d]\n"),
2916 dwarf_vmatoa ("u", uladv
),
2917 dwarf_vmatoa ("x", state_machine_regs
.address
),
2918 state_machine_regs
.op_index
);
2922 case DW_LNS_fixed_advance_pc
:
2923 SAFE_BYTE_GET_AND_INC (uladv
, data
, 2, end
);
2924 state_machine_regs
.address
+= uladv
;
2925 state_machine_regs
.op_index
= 0;
2926 printf (_(" Advance PC by fixed size amount %s to 0x%s\n"),
2927 dwarf_vmatoa ("u", uladv
),
2928 dwarf_vmatoa ("x", state_machine_regs
.address
));
2931 case DW_LNS_set_prologue_end
:
2932 printf (_(" Set prologue_end to true\n"));
2935 case DW_LNS_set_epilogue_begin
:
2936 printf (_(" Set epilogue_begin to true\n"));
2939 case DW_LNS_set_isa
:
2940 uladv
= read_uleb128 (data
, & bytes_read
, end
);
2942 printf (_(" Set ISA to %s\n"), dwarf_vmatoa ("u", uladv
));
2946 printf (_(" Unknown opcode %d with operands: "), op_code
);
2948 if (standard_opcodes
!= NULL
)
2949 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
2951 printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data
,
2953 i
== 1 ? "" : ", ");
2969 unsigned char *name
;
2970 unsigned int directory_index
;
2971 unsigned int modification_date
;
2972 unsigned int length
;
2975 /* Output a decoded representation of the .debug_line section. */
2978 display_debug_lines_decoded (struct dwarf_section
*section
,
2979 unsigned char *data
,
2982 static DWARF2_Internal_LineInfo saved_linfo
;
2984 printf (_("Decoded dump of debug contents of section %s:\n\n"),
2989 /* This loop amounts to one iteration per compilation unit. */
2990 DWARF2_Internal_LineInfo linfo
;
2991 unsigned char *standard_opcodes
;
2992 unsigned char *end_of_sequence
;
2994 File_Entry
*file_table
= NULL
;
2995 unsigned int n_files
= 0;
2996 unsigned char **directory_table
= NULL
;
2997 unsigned int n_directories
= 0;
2999 if (const_strneq (section
->name
, ".debug_line.")
3000 /* Note: the following does not apply to .debug_line.dwo sections.
3001 These are full debug_line sections. */
3002 && strcmp (section
->name
, ".debug_line.dwo") != 0)
3004 /* See comment in display_debug_lines_raw(). */
3005 end_of_sequence
= end
;
3006 standard_opcodes
= NULL
;
3007 linfo
= saved_linfo
;
3008 reset_state_machine (linfo
.li_default_is_stmt
);
3012 unsigned char *hdrptr
;
3014 if ((hdrptr
= read_debug_line_header (section
, data
, end
, & linfo
,
3015 & end_of_sequence
)) == NULL
)
3018 reset_state_machine (linfo
.li_default_is_stmt
);
3020 /* Save a pointer to the contents of the Opcodes table. */
3021 standard_opcodes
= hdrptr
;
3023 /* Traverse the Directory table just to count entries. */
3024 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
3027 unsigned char *ptr_directory_table
= data
;
3031 data
+= strnlen ((char *) data
, end
- data
) + 1;
3035 /* Go through the directory table again to save the directories. */
3036 directory_table
= (unsigned char **)
3037 xmalloc (n_directories
* sizeof (unsigned char *));
3040 while (*ptr_directory_table
!= 0)
3042 directory_table
[i
] = ptr_directory_table
;
3043 ptr_directory_table
+= strnlen ((char *) ptr_directory_table
,
3044 ptr_directory_table
- end
) + 1;
3048 /* Skip the NUL at the end of the table. */
3051 /* Traverse the File Name table just to count the entries. */
3054 unsigned char *ptr_file_name_table
= data
;
3058 unsigned int bytes_read
;
3060 /* Skip Name, directory index, last modification time and length
3062 data
+= strnlen ((char *) data
, end
- data
) + 1;
3063 read_uleb128 (data
, & bytes_read
, end
);
3065 read_uleb128 (data
, & bytes_read
, end
);
3067 read_uleb128 (data
, & bytes_read
, end
);
3073 /* Go through the file table again to save the strings. */
3074 file_table
= (File_Entry
*) xmalloc (n_files
* sizeof (File_Entry
));
3077 while (*ptr_file_name_table
!= 0)
3079 unsigned int bytes_read
;
3081 file_table
[i
].name
= ptr_file_name_table
;
3082 ptr_file_name_table
+= strnlen ((char *) ptr_file_name_table
,
3083 end
- ptr_file_name_table
) + 1;
3085 /* We are not interested in directory, time or size. */
3086 file_table
[i
].directory_index
= read_uleb128 (ptr_file_name_table
,
3088 ptr_file_name_table
+= bytes_read
;
3089 file_table
[i
].modification_date
= read_uleb128 (ptr_file_name_table
,
3091 ptr_file_name_table
+= bytes_read
;
3092 file_table
[i
].length
= read_uleb128 (ptr_file_name_table
, & bytes_read
, end
);
3093 ptr_file_name_table
+= bytes_read
;
3098 /* Print the Compilation Unit's name and a header. */
3099 if (directory_table
== NULL
)
3101 printf (_("CU: %s:\n"), file_table
[0].name
);
3102 printf (_("File name Line number Starting address\n"));
3106 unsigned int ix
= file_table
[0].directory_index
;
3107 const char *directory
= ix
? (char *)directory_table
[ix
- 1] : ".";
3109 if (do_wide
|| strlen (directory
) < 76)
3110 printf (_("CU: %s/%s:\n"), directory
, file_table
[0].name
);
3112 printf ("%s:\n", file_table
[0].name
);
3114 printf (_("File name Line number Starting address\n"));
3118 /* Skip the NUL at the end of the table. */
3121 saved_linfo
= linfo
;
3124 /* This loop iterates through the Dwarf Line Number Program. */
3125 while (data
< end_of_sequence
)
3127 unsigned char op_code
;
3129 unsigned long int uladv
;
3130 unsigned int bytes_read
;
3131 int is_special_opcode
= 0;
3135 if (op_code
>= linfo
.li_opcode_base
)
3137 op_code
-= linfo
.li_opcode_base
;
3138 uladv
= (op_code
/ linfo
.li_line_range
);
3139 if (linfo
.li_max_ops_per_insn
== 1)
3141 uladv
*= linfo
.li_min_insn_length
;
3142 state_machine_regs
.address
+= uladv
;
3146 state_machine_regs
.address
3147 += ((state_machine_regs
.op_index
+ uladv
)
3148 / linfo
.li_max_ops_per_insn
)
3149 * linfo
.li_min_insn_length
;
3150 state_machine_regs
.op_index
3151 = (state_machine_regs
.op_index
+ uladv
)
3152 % linfo
.li_max_ops_per_insn
;
3155 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
3156 state_machine_regs
.line
+= adv
;
3157 is_special_opcode
= 1;
3159 else switch (op_code
)
3161 case DW_LNS_extended_op
:
3163 unsigned int ext_op_code_len
;
3164 unsigned char ext_op_code
;
3165 unsigned char *op_code_data
= data
;
3167 ext_op_code_len
= read_uleb128 (op_code_data
, &bytes_read
,
3169 op_code_data
+= bytes_read
;
3171 if (ext_op_code_len
== 0)
3173 warn (_("badly formed extended line op encountered!\n"));
3176 ext_op_code_len
+= bytes_read
;
3177 ext_op_code
= *op_code_data
++;
3179 switch (ext_op_code
)
3181 case DW_LNE_end_sequence
:
3182 reset_state_machine (linfo
.li_default_is_stmt
);
3184 case DW_LNE_set_address
:
3185 SAFE_BYTE_GET_AND_INC (state_machine_regs
.address
,
3187 ext_op_code_len
- bytes_read
- 1,
3189 state_machine_regs
.op_index
= 0;
3191 case DW_LNE_define_file
:
3193 file_table
= (File_Entry
*) xrealloc
3194 (file_table
, (n_files
+ 1) * sizeof (File_Entry
));
3196 ++state_machine_regs
.last_file_entry
;
3197 /* Source file name. */
3198 file_table
[n_files
].name
= op_code_data
;
3199 op_code_data
+= strlen ((char *) op_code_data
) + 1;
3200 /* Directory index. */
3201 file_table
[n_files
].directory_index
=
3202 read_uleb128 (op_code_data
, & bytes_read
,
3204 op_code_data
+= bytes_read
;
3205 /* Last modification time. */
3206 file_table
[n_files
].modification_date
=
3207 read_uleb128 (op_code_data
, & bytes_read
,
3209 op_code_data
+= bytes_read
;
3211 file_table
[n_files
].length
=
3212 read_uleb128 (op_code_data
, & bytes_read
,
3218 case DW_LNE_set_discriminator
:
3219 case DW_LNE_HP_set_sequence
:
3220 /* Simply ignored. */
3224 printf (_("UNKNOWN (%u): length %d\n"),
3225 ext_op_code
, ext_op_code_len
- bytes_read
);
3228 data
+= ext_op_code_len
;
3234 case DW_LNS_advance_pc
:
3235 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3237 if (linfo
.li_max_ops_per_insn
== 1)
3239 uladv
*= linfo
.li_min_insn_length
;
3240 state_machine_regs
.address
+= uladv
;
3244 state_machine_regs
.address
3245 += ((state_machine_regs
.op_index
+ uladv
)
3246 / linfo
.li_max_ops_per_insn
)
3247 * linfo
.li_min_insn_length
;
3248 state_machine_regs
.op_index
3249 = (state_machine_regs
.op_index
+ uladv
)
3250 % linfo
.li_max_ops_per_insn
;
3254 case DW_LNS_advance_line
:
3255 adv
= read_sleb128 (data
, & bytes_read
, end
);
3257 state_machine_regs
.line
+= adv
;
3260 case DW_LNS_set_file
:
3261 adv
= read_uleb128 (data
, & bytes_read
, end
);
3263 state_machine_regs
.file
= adv
;
3265 if (file_table
== NULL
)
3266 printf (_("\n [Use file table entry %d]\n"), state_machine_regs
.file
- 1);
3267 else if (file_table
[state_machine_regs
.file
- 1].directory_index
== 0)
3268 /* If directory index is 0, that means current directory. */
3269 printf ("\n./%s:[++]\n",
3270 file_table
[state_machine_regs
.file
- 1].name
);
3271 else if (directory_table
== NULL
)
3272 printf (_("\n [Use directory table entry %d]\n"),
3273 file_table
[state_machine_regs
.file
- 1].directory_index
- 1);
3275 /* The directory index starts counting at 1. */
3276 printf ("\n%s/%s:\n",
3277 directory_table
[file_table
[state_machine_regs
.file
- 1].directory_index
- 1],
3278 file_table
[state_machine_regs
.file
- 1].name
);
3281 case DW_LNS_set_column
:
3282 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3284 state_machine_regs
.column
= uladv
;
3287 case DW_LNS_negate_stmt
:
3288 adv
= state_machine_regs
.is_stmt
;
3290 state_machine_regs
.is_stmt
= adv
;
3293 case DW_LNS_set_basic_block
:
3294 state_machine_regs
.basic_block
= 1;
3297 case DW_LNS_const_add_pc
:
3298 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
3299 if (linfo
.li_max_ops_per_insn
== 1)
3301 uladv
*= linfo
.li_min_insn_length
;
3302 state_machine_regs
.address
+= uladv
;
3306 state_machine_regs
.address
3307 += ((state_machine_regs
.op_index
+ uladv
)
3308 / linfo
.li_max_ops_per_insn
)
3309 * linfo
.li_min_insn_length
;
3310 state_machine_regs
.op_index
3311 = (state_machine_regs
.op_index
+ uladv
)
3312 % linfo
.li_max_ops_per_insn
;
3316 case DW_LNS_fixed_advance_pc
:
3317 SAFE_BYTE_GET_AND_INC (uladv
, data
, 2, end
);
3318 state_machine_regs
.address
+= uladv
;
3319 state_machine_regs
.op_index
= 0;
3322 case DW_LNS_set_prologue_end
:
3325 case DW_LNS_set_epilogue_begin
:
3328 case DW_LNS_set_isa
:
3329 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3331 printf (_(" Set ISA to %lu\n"), uladv
);
3335 printf (_(" Unknown opcode %d with operands: "), op_code
);
3337 if (standard_opcodes
!= NULL
)
3338 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
3340 printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data
,
3342 i
== 1 ? "" : ", ");
3349 /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row
3350 to the DWARF address/line matrix. */
3351 if ((is_special_opcode
) || (op_code
== DW_LNE_end_sequence
)
3352 || (op_code
== DW_LNS_copy
))
3354 const unsigned int MAX_FILENAME_LENGTH
= 35;
3356 char *newFileName
= NULL
;
3357 size_t fileNameLength
;
3360 fileName
= (char *) file_table
[state_machine_regs
.file
- 1].name
;
3362 fileName
= "<unknown>";
3364 fileNameLength
= strlen (fileName
);
3366 if ((fileNameLength
> MAX_FILENAME_LENGTH
) && (!do_wide
))
3368 newFileName
= (char *) xmalloc (MAX_FILENAME_LENGTH
+ 1);
3369 /* Truncate file name */
3370 strncpy (newFileName
,
3371 fileName
+ fileNameLength
- MAX_FILENAME_LENGTH
,
3372 MAX_FILENAME_LENGTH
+ 1);
3376 newFileName
= (char *) xmalloc (fileNameLength
+ 1);
3377 strncpy (newFileName
, fileName
, fileNameLength
+ 1);
3380 if (!do_wide
|| (fileNameLength
<= MAX_FILENAME_LENGTH
))
3382 if (linfo
.li_max_ops_per_insn
== 1)
3383 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x\n",
3384 newFileName
, state_machine_regs
.line
,
3385 state_machine_regs
.address
);
3387 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x[%d]\n",
3388 newFileName
, state_machine_regs
.line
,
3389 state_machine_regs
.address
,
3390 state_machine_regs
.op_index
);
3394 if (linfo
.li_max_ops_per_insn
== 1)
3395 printf ("%s %11d %#18" DWARF_VMA_FMT
"x\n",
3396 newFileName
, state_machine_regs
.line
,
3397 state_machine_regs
.address
);
3399 printf ("%s %11d %#18" DWARF_VMA_FMT
"x[%d]\n",
3400 newFileName
, state_machine_regs
.line
,
3401 state_machine_regs
.address
,
3402 state_machine_regs
.op_index
);
3405 if (op_code
== DW_LNE_end_sequence
)
3419 if (directory_table
)
3421 free (directory_table
);
3422 directory_table
= NULL
;
3433 display_debug_lines (struct dwarf_section
*section
, void *file ATTRIBUTE_UNUSED
)
3435 unsigned char *data
= section
->start
;
3436 unsigned char *end
= data
+ section
->size
;
3438 int retValDecoded
= 1;
3440 if (do_debug_lines
== 0)
3441 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
3443 if (do_debug_lines
& FLAG_DEBUG_LINES_RAW
)
3444 retValRaw
= display_debug_lines_raw (section
, data
, end
);
3446 if (do_debug_lines
& FLAG_DEBUG_LINES_DECODED
)
3447 retValDecoded
= display_debug_lines_decoded (section
, data
, end
);
3449 if (!retValRaw
|| !retValDecoded
)
3456 find_debug_info_for_offset (unsigned long offset
)
3460 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
3463 for (i
= 0; i
< num_debug_info_entries
; i
++)
3464 if (debug_information
[i
].cu_offset
== offset
)
3465 return debug_information
+ i
;
3471 display_debug_pubnames (struct dwarf_section
*section
,
3472 void *file ATTRIBUTE_UNUSED
)
3474 DWARF2_Internal_PubNames names
;
3475 unsigned char *start
= section
->start
;
3476 unsigned char *end
= start
+ section
->size
;
3478 /* It does not matter if this load fails,
3479 we test for that later on. */
3480 load_debug_info (file
);
3482 printf (_("Contents of the %s section:\n\n"), section
->name
);
3486 unsigned char *data
;
3487 unsigned long offset
;
3488 int offset_size
, initial_length_size
;
3492 SAFE_BYTE_GET_AND_INC (names
.pn_length
, data
, 4, end
);
3493 if (names
.pn_length
== 0xffffffff)
3495 SAFE_BYTE_GET_AND_INC (names
.pn_length
, data
, 8, end
);
3497 initial_length_size
= 12;
3502 initial_length_size
= 4;
3505 SAFE_BYTE_GET_AND_INC (names
.pn_version
, data
, 2, end
);
3506 SAFE_BYTE_GET_AND_INC (names
.pn_offset
, data
, offset_size
, end
);
3508 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
3509 && num_debug_info_entries
> 0
3510 && find_debug_info_for_offset (names
.pn_offset
) == NULL
)
3511 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
3512 (unsigned long) names
.pn_offset
, section
->name
);
3514 SAFE_BYTE_GET_AND_INC (names
.pn_size
, data
, offset_size
, end
);
3516 start
+= names
.pn_length
+ initial_length_size
;
3518 if (names
.pn_version
!= 2 && names
.pn_version
!= 3)
3520 static int warned
= 0;
3524 warn (_("Only DWARF 2 and 3 pubnames are currently supported\n"));
3531 printf (_(" Length: %ld\n"),
3532 (long) names
.pn_length
);
3533 printf (_(" Version: %d\n"),
3535 printf (_(" Offset into .debug_info section: 0x%lx\n"),
3536 (unsigned long) names
.pn_offset
);
3537 printf (_(" Size of area in .debug_info section: %ld\n"),
3538 (long) names
.pn_size
);
3540 printf (_("\n Offset\tName\n"));
3544 SAFE_BYTE_GET (offset
, data
, offset_size
, end
);
3548 data
+= offset_size
;
3549 printf (" %-6lx\t%s\n", offset
, data
);
3550 data
+= strnlen ((char *) data
, end
- data
) + 1;
3553 while (offset
!= 0);
3561 display_debug_macinfo (struct dwarf_section
*section
,
3562 void *file ATTRIBUTE_UNUSED
)
3564 unsigned char *start
= section
->start
;
3565 unsigned char *end
= start
+ section
->size
;
3566 unsigned char *curr
= start
;
3567 unsigned int bytes_read
;
3568 enum dwarf_macinfo_record_type op
;
3570 printf (_("Contents of the %s section:\n\n"), section
->name
);
3574 unsigned int lineno
;
3575 const unsigned char *string
;
3577 op
= (enum dwarf_macinfo_record_type
) *curr
;
3582 case DW_MACINFO_start_file
:
3584 unsigned int filenum
;
3586 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
3588 filenum
= read_uleb128 (curr
, & bytes_read
, end
);
3591 printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"),
3596 case DW_MACINFO_end_file
:
3597 printf (_(" DW_MACINFO_end_file\n"));
3600 case DW_MACINFO_define
:
3601 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
3604 curr
+= strnlen ((char *) string
, end
- string
) + 1;
3605 printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"),
3609 case DW_MACINFO_undef
:
3610 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
3613 curr
+= strnlen ((char *) string
, end
- string
) + 1;
3614 printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"),
3618 case DW_MACINFO_vendor_ext
:
3620 unsigned int constant
;
3622 constant
= read_uleb128 (curr
, & bytes_read
, end
);
3625 curr
+= strnlen ((char *) string
, end
- string
) + 1;
3626 printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"),
3636 /* Given LINE_OFFSET into the .debug_line section, attempt to return
3637 filename and dirname corresponding to file name table entry with index
3638 FILEIDX. Return NULL on failure. */
3640 static unsigned char *
3641 get_line_filename_and_dirname (dwarf_vma line_offset
,
3643 unsigned char **dir_name
)
3645 struct dwarf_section
*section
= &debug_displays
[line
].section
;
3646 unsigned char *hdrptr
, *dirtable
, *file_name
;
3647 unsigned int offset_size
, initial_length_size
;
3648 unsigned int version
, opcode_base
, bytes_read
;
3649 dwarf_vma length
, diridx
;
3650 const unsigned char * end
;
3653 if (section
->start
== NULL
3654 || line_offset
>= section
->size
3658 hdrptr
= section
->start
+ line_offset
;
3659 end
= section
->start
+ section
->size
;
3661 SAFE_BYTE_GET_AND_INC (length
, hdrptr
, 4, end
);
3662 if (length
== 0xffffffff)
3664 /* This section is 64-bit DWARF 3. */
3665 SAFE_BYTE_GET_AND_INC (length
, hdrptr
, 8, end
);
3667 initial_length_size
= 12;
3672 initial_length_size
= 4;
3674 if (length
+ initial_length_size
> section
->size
)
3677 SAFE_BYTE_GET_AND_INC (version
, hdrptr
, 2, end
);
3678 if (version
!= 2 && version
!= 3 && version
!= 4)
3680 hdrptr
+= offset_size
+ 1;/* Skip prologue_length and min_insn_length. */
3682 hdrptr
++; /* Skip max_ops_per_insn. */
3683 hdrptr
+= 3; /* Skip default_is_stmt, line_base, line_range. */
3685 SAFE_BYTE_GET_AND_INC (opcode_base
, hdrptr
, 1, end
);
3686 if (opcode_base
== 0)
3689 hdrptr
+= opcode_base
- 1;
3691 /* Skip over dirname table. */
3692 while (*hdrptr
!= '\0')
3693 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
3694 hdrptr
++; /* Skip the NUL at the end of the table. */
3695 /* Now skip over preceding filename table entries. */
3696 for (; *hdrptr
!= '\0' && fileidx
> 1; fileidx
--)
3698 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
3699 read_uleb128 (hdrptr
, &bytes_read
, end
);
3700 hdrptr
+= bytes_read
;
3701 read_uleb128 (hdrptr
, &bytes_read
, end
);
3702 hdrptr
+= bytes_read
;
3703 read_uleb128 (hdrptr
, &bytes_read
, end
);
3704 hdrptr
+= bytes_read
;
3706 if (hdrptr
== end
|| *hdrptr
== '\0')
3709 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
3710 diridx
= read_uleb128 (hdrptr
, &bytes_read
, end
);
3713 for (; *dirtable
!= '\0' && diridx
> 1; diridx
--)
3714 dirtable
+= strnlen ((char *) dirtable
, end
- dirtable
) + 1;
3715 if (*dirtable
== '\0')
3717 *dir_name
= dirtable
;
3722 display_debug_macro (struct dwarf_section
*section
,
3725 unsigned char *start
= section
->start
;
3726 unsigned char *end
= start
+ section
->size
;
3727 unsigned char *curr
= start
;
3728 unsigned char *extended_op_buf
[256];
3729 unsigned int bytes_read
;
3731 load_debug_section (str
, file
);
3732 load_debug_section (line
, file
);
3734 printf (_("Contents of the %s section:\n\n"), section
->name
);
3738 unsigned int lineno
, version
, flags
;
3739 unsigned int offset_size
= 4;
3740 const unsigned char *string
;
3741 dwarf_vma line_offset
= 0, sec_offset
= curr
- start
, offset
;
3742 unsigned char **extended_ops
= NULL
;
3744 SAFE_BYTE_GET_AND_INC (version
, curr
, 2, end
);
3747 error (_("Only GNU extension to DWARF 4 of %s is currently supported.\n"),
3752 SAFE_BYTE_GET_AND_INC (flags
, curr
, 1, end
);
3755 printf (_(" Offset: 0x%lx\n"),
3756 (unsigned long) sec_offset
);
3757 printf (_(" Version: %d\n"), version
);
3758 printf (_(" Offset size: %d\n"), offset_size
);
3761 SAFE_BYTE_GET_AND_INC (line_offset
, curr
, offset_size
, end
);
3762 printf (_(" Offset into .debug_line: 0x%lx\n"),
3763 (unsigned long) line_offset
);
3767 unsigned int i
, count
, op
;
3770 SAFE_BYTE_GET_AND_INC (count
, curr
, 1, end
);
3772 memset (extended_op_buf
, 0, sizeof (extended_op_buf
));
3773 extended_ops
= extended_op_buf
;
3776 printf (_(" Extension opcode arguments:\n"));
3777 for (i
= 0; i
< count
; i
++)
3779 SAFE_BYTE_GET_AND_INC (op
, curr
, 1, end
);
3780 extended_ops
[op
] = curr
;
3781 nargs
= read_uleb128 (curr
, &bytes_read
, end
);
3784 printf (_(" DW_MACRO_GNU_%02x has no arguments\n"), op
);
3787 printf (_(" DW_MACRO_GNU_%02x arguments: "), op
);
3788 for (n
= 0; n
< nargs
; n
++)
3792 SAFE_BYTE_GET_AND_INC (form
, curr
, 1, end
);
3793 printf ("%s%s", get_FORM_name (form
),
3794 n
== nargs
- 1 ? "\n" : ", ");
3804 case DW_FORM_block1
:
3805 case DW_FORM_block2
:
3806 case DW_FORM_block4
:
3808 case DW_FORM_string
:
3810 case DW_FORM_sec_offset
:
3813 error (_("Invalid extension opcode form %s\n"),
3814 get_FORM_name (form
));
3830 error (_(".debug_macro section not zero terminated\n"));
3834 SAFE_BYTE_GET_AND_INC (op
, curr
, 1, end
);
3840 case DW_MACRO_GNU_start_file
:
3842 unsigned int filenum
;
3843 unsigned char *file_name
= NULL
, *dir_name
= NULL
;
3845 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3847 filenum
= read_uleb128 (curr
, &bytes_read
, end
);
3850 if ((flags
& 2) == 0)
3851 error (_("DW_MACRO_GNU_start_file used, but no .debug_line offset provided.\n"));
3854 = get_line_filename_and_dirname (line_offset
, filenum
,
3856 if (file_name
== NULL
)
3857 printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d\n"),
3860 printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d filename: %s%s%s\n"),
3862 dir_name
!= NULL
? (const char *) dir_name
: "",
3863 dir_name
!= NULL
? "/" : "", file_name
);
3867 case DW_MACRO_GNU_end_file
:
3868 printf (_(" DW_MACRO_GNU_end_file\n"));
3871 case DW_MACRO_GNU_define
:
3872 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3875 curr
+= strnlen ((char *) string
, end
- string
) + 1;
3876 printf (_(" DW_MACRO_GNU_define - lineno : %d macro : %s\n"),
3880 case DW_MACRO_GNU_undef
:
3881 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3884 curr
+= strnlen ((char *) string
, end
- string
) + 1;
3885 printf (_(" DW_MACRO_GNU_undef - lineno : %d macro : %s\n"),
3889 case DW_MACRO_GNU_define_indirect
:
3890 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3892 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
3893 string
= fetch_indirect_string (offset
);
3894 printf (_(" DW_MACRO_GNU_define_indirect - lineno : %d macro : %s\n"),
3898 case DW_MACRO_GNU_undef_indirect
:
3899 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3901 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
3902 string
= fetch_indirect_string (offset
);
3903 printf (_(" DW_MACRO_GNU_undef_indirect - lineno : %d macro : %s\n"),
3907 case DW_MACRO_GNU_transparent_include
:
3908 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
3909 printf (_(" DW_MACRO_GNU_transparent_include - offset : 0x%lx\n"),
3910 (unsigned long) offset
);
3913 case DW_MACRO_GNU_define_indirect_alt
:
3914 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3916 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
3917 printf (_(" DW_MACRO_GNU_define_indirect_alt - lineno : %d macro offset : 0x%lx\n"),
3918 lineno
, (unsigned long) offset
);
3921 case DW_MACRO_GNU_undef_indirect_alt
:
3922 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
3924 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
3925 printf (_(" DW_MACRO_GNU_undef_indirect_alt - lineno : %d macro offset : 0x%lx\n"),
3926 lineno
, (unsigned long) offset
);
3929 case DW_MACRO_GNU_transparent_include_alt
:
3930 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
3931 printf (_(" DW_MACRO_GNU_transparent_include_alt - offset : 0x%lx\n"),
3932 (unsigned long) offset
);
3936 if (extended_ops
== NULL
|| extended_ops
[op
] == NULL
)
3938 error (_(" Unknown macro opcode %02x seen\n"), op
);
3943 /* Skip over unhandled opcodes. */
3945 unsigned char *desc
= extended_ops
[op
];
3946 nargs
= read_uleb128 (desc
, &bytes_read
, end
);
3950 printf (_(" DW_MACRO_GNU_%02x\n"), op
);
3953 printf (_(" DW_MACRO_GNU_%02x -"), op
);
3954 for (n
= 0; n
< nargs
; n
++)
3958 SAFE_BYTE_GET_AND_INC (val
, desc
, 1, end
);
3960 = read_and_display_attr_value (0, val
,
3961 curr
, end
, 0, 0, offset_size
,
3962 version
, NULL
, 0, NULL
,
3980 display_debug_abbrev (struct dwarf_section
*section
,
3981 void *file ATTRIBUTE_UNUSED
)
3983 abbrev_entry
*entry
;
3984 unsigned char *start
= section
->start
;
3985 unsigned char *end
= start
+ section
->size
;
3987 printf (_("Contents of the %s section:\n\n"), section
->name
);
3991 unsigned char *last
;
3996 start
= process_abbrev_section (start
, end
);
3998 if (first_abbrev
== NULL
)
4001 printf (_(" Number TAG (0x%lx)\n"), (long) (last
- section
->start
));
4003 for (entry
= first_abbrev
; entry
; entry
= entry
->next
)
4007 printf (" %ld %s [%s]\n",
4009 get_TAG_name (entry
->tag
),
4010 entry
->children
? _("has children") : _("no children"));
4012 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
4013 printf (" %-18s %s\n",
4014 get_AT_name (attr
->attribute
),
4015 get_FORM_name (attr
->form
));
4025 /* Display a location list from a normal (ie, non-dwo) .debug_loc section. */
4028 display_loc_list (struct dwarf_section
*section
,
4029 unsigned char **start_ptr
,
4030 int debug_info_entry
,
4031 unsigned long offset
,
4032 unsigned long base_address
,
4035 unsigned char *start
= *start_ptr
;
4036 unsigned char *section_end
= section
->start
+ section
->size
;
4037 unsigned long cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
4038 unsigned int pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
4039 unsigned int offset_size
= debug_information
[debug_info_entry
].offset_size
;
4040 int dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
4044 unsigned short length
;
4045 int need_frame_base
;
4049 if (start
+ 2 * pointer_size
> section_end
)
4051 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4056 printf (" %8.8lx ", offset
+ (start
- *start_ptr
));
4058 /* Note: we use sign extension here in order to be sure that we can detect
4059 the -1 escape value. Sign extension into the top 32 bits of a 32-bit
4060 address will not affect the values that we display since we always show
4061 hex values, and always the bottom 32-bits. */
4062 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, section_end
);
4063 SAFE_BYTE_GET_AND_INC (end
, start
, pointer_size
, section_end
);
4065 if (begin
== 0 && end
== 0)
4067 printf (_("<End of list>\n"));
4071 /* Check base address specifiers. */
4072 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
4075 print_dwarf_vma (begin
, pointer_size
);
4076 print_dwarf_vma (end
, pointer_size
);
4077 printf (_("(base address)\n"));
4081 if (start
+ 2 > section_end
)
4083 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4088 SAFE_BYTE_GET_AND_INC (length
, start
, 2, section_end
);
4090 if (start
+ length
> section_end
)
4092 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4097 print_dwarf_vma (begin
+ base_address
, pointer_size
);
4098 print_dwarf_vma (end
+ base_address
, pointer_size
);
4101 need_frame_base
= decode_location_expression (start
,
4106 cu_offset
, section
);
4109 if (need_frame_base
&& !has_frame_base
)
4110 printf (_(" [without DW_AT_frame_base]"));
4113 fputs (_(" (start == end)"), stdout
);
4114 else if (begin
> end
)
4115 fputs (_(" (start > end)"), stdout
);
4125 /* Print a .debug_addr table index in decimal, surrounded by square brackets,
4126 right-adjusted in a field of length LEN, and followed by a space. */
4129 print_addr_index (unsigned int idx
, unsigned int len
)
4131 static char buf
[15];
4132 snprintf (buf
, sizeof (buf
), "[%d]", idx
);
4133 printf ("%*s ", len
, buf
);
4136 /* Display a location list from a .dwo section. It uses address indexes rather
4137 than embedded addresses. This code closely follows display_loc_list, but the
4138 two are sufficiently different that combining things is very ugly. */
4141 display_loc_list_dwo (struct dwarf_section
*section
,
4142 unsigned char **start_ptr
,
4143 int debug_info_entry
,
4144 unsigned long offset
,
4147 unsigned char *start
= *start_ptr
;
4148 unsigned char *section_end
= section
->start
+ section
->size
;
4149 unsigned long cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
4150 unsigned int pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
4151 unsigned int offset_size
= debug_information
[debug_info_entry
].offset_size
;
4152 int dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
4154 unsigned short length
;
4155 int need_frame_base
;
4157 unsigned int bytes_read
;
4161 printf (" %8.8lx ", offset
+ (start
- *start_ptr
));
4163 if (start
>= section_end
)
4165 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4170 SAFE_BYTE_GET_AND_INC (entry_type
, start
, 1, section_end
);
4173 case 0: /* A terminating entry. */
4175 printf (_("<End of list>\n"));
4177 case 1: /* A base-address entry. */
4178 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
4179 start
+= bytes_read
;
4180 print_addr_index (idx
, 8);
4182 printf (_("(base address selection entry)\n"));
4184 case 2: /* A start/end entry. */
4185 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
4186 start
+= bytes_read
;
4187 print_addr_index (idx
, 8);
4188 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
4189 start
+= bytes_read
;
4190 print_addr_index (idx
, 8);
4192 case 3: /* A start/length entry. */
4193 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
4194 start
+= bytes_read
;
4195 print_addr_index (idx
, 8);
4196 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
4197 printf ("%08x ", idx
);
4199 case 4: /* An offset pair entry. */
4200 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
4201 printf ("%08x ", idx
);
4202 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
4203 printf ("%08x ", idx
);
4206 warn (_("Unknown location list entry type 0x%x.\n"), entry_type
);
4211 if (start
+ 2 > section_end
)
4213 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4218 SAFE_BYTE_GET_AND_INC (length
, start
, 2, section_end
);
4219 if (start
+ length
> section_end
)
4221 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4227 need_frame_base
= decode_location_expression (start
,
4232 cu_offset
, section
);
4235 if (need_frame_base
&& !has_frame_base
)
4236 printf (_(" [without DW_AT_frame_base]"));
4246 /* Sort array of indexes in ascending order of loc_offsets[idx]. */
4248 static dwarf_vma
*loc_offsets
;
4251 loc_offsets_compar (const void *ap
, const void *bp
)
4253 dwarf_vma a
= loc_offsets
[*(const unsigned int *) ap
];
4254 dwarf_vma b
= loc_offsets
[*(const unsigned int *) bp
];
4256 return (a
> b
) - (b
> a
);
4260 display_debug_loc (struct dwarf_section
*section
, void *file
)
4262 unsigned char *start
= section
->start
;
4263 unsigned long bytes
;
4264 unsigned char *section_begin
= start
;
4265 unsigned int num_loc_list
= 0;
4266 unsigned long last_offset
= 0;
4267 unsigned int first
= 0;
4271 int seen_first_offset
= 0;
4272 int locs_sorted
= 1;
4273 unsigned char *next
;
4274 unsigned int *array
= NULL
;
4275 const char *suffix
= strrchr (section
->name
, '.');
4278 if (suffix
&& strcmp (suffix
, ".dwo") == 0)
4281 bytes
= section
->size
;
4285 printf (_("\nThe %s section is empty.\n"), section
->name
);
4289 if (load_debug_info (file
) == 0)
4291 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4296 /* Check the order of location list in .debug_info section. If
4297 offsets of location lists are in the ascending order, we can
4298 use `debug_information' directly. */
4299 for (i
= 0; i
< num_debug_info_entries
; i
++)
4303 num
= debug_information
[i
].num_loc_offsets
;
4304 if (num
> num_loc_list
)
4307 /* Check if we can use `debug_information' directly. */
4308 if (locs_sorted
&& num
!= 0)
4310 if (!seen_first_offset
)
4312 /* This is the first location list. */
4313 last_offset
= debug_information
[i
].loc_offsets
[0];
4315 seen_first_offset
= 1;
4321 for (; j
< num
; j
++)
4324 debug_information
[i
].loc_offsets
[j
])
4329 last_offset
= debug_information
[i
].loc_offsets
[j
];
4334 if (!seen_first_offset
)
4335 error (_("No location lists in .debug_info section!\n"));
4337 /* DWARF sections under Mach-O have non-zero addresses. */
4338 if (debug_information
[first
].num_loc_offsets
> 0
4339 && debug_information
[first
].loc_offsets
[0] != section
->address
)
4340 warn (_("Location lists in %s section start at 0x%s\n"),
4342 dwarf_vmatoa ("x", debug_information
[first
].loc_offsets
[0]));
4345 array
= (unsigned int *) xcmalloc (num_loc_list
, sizeof (unsigned int));
4346 printf (_("Contents of the %s section:\n\n"), section
->name
);
4347 printf (_(" Offset Begin End Expression\n"));
4349 seen_first_offset
= 0;
4350 for (i
= first
; i
< num_debug_info_entries
; i
++)
4352 unsigned long offset
;
4353 unsigned long base_address
;
4358 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
4360 loc_offsets
= debug_information
[i
].loc_offsets
;
4361 qsort (array
, debug_information
[i
].num_loc_offsets
,
4362 sizeof (*array
), loc_offsets_compar
);
4365 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
4367 j
= locs_sorted
? k
: array
[k
];
4369 && debug_information
[i
].loc_offsets
[locs_sorted
4370 ? k
- 1 : array
[k
- 1]]
4371 == debug_information
[i
].loc_offsets
[j
])
4373 has_frame_base
= debug_information
[i
].have_frame_base
[j
];
4374 /* DWARF sections under Mach-O have non-zero addresses. */
4375 offset
= debug_information
[i
].loc_offsets
[j
] - section
->address
;
4376 next
= section_begin
+ offset
;
4377 base_address
= debug_information
[i
].base_address
;
4379 if (!seen_first_offset
)
4380 seen_first_offset
= 1;
4384 warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"),
4385 (unsigned long) (start
- section_begin
),
4386 (unsigned long) (next
- section_begin
));
4387 else if (start
> next
)
4388 warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"),
4389 (unsigned long) (start
- section_begin
),
4390 (unsigned long) (next
- section_begin
));
4394 if (offset
>= bytes
)
4396 warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"),
4402 display_loc_list_dwo (section
, &start
, i
, offset
, has_frame_base
);
4404 display_loc_list (section
, &start
, i
, offset
, base_address
,
4409 if (start
< section
->start
+ section
->size
)
4410 warn (_("There are %ld unused bytes at the end of section %s\n"),
4411 (long) (section
->start
+ section
->size
- start
), section
->name
);
4418 display_debug_str (struct dwarf_section
*section
,
4419 void *file ATTRIBUTE_UNUSED
)
4421 unsigned char *start
= section
->start
;
4422 unsigned long bytes
= section
->size
;
4423 dwarf_vma addr
= section
->address
;
4427 printf (_("\nThe %s section is empty.\n"), section
->name
);
4431 printf (_("Contents of the %s section:\n\n"), section
->name
);
4439 lbytes
= (bytes
> 16 ? 16 : bytes
);
4441 printf (" 0x%8.8lx ", (unsigned long) addr
);
4443 for (j
= 0; j
< 16; j
++)
4446 printf ("%2.2x", start
[j
]);
4454 for (j
= 0; j
< lbytes
; j
++)
4457 if (k
>= ' ' && k
< 0x80)
4476 display_debug_info (struct dwarf_section
*section
, void *file
)
4478 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 0);
4482 display_debug_types (struct dwarf_section
*section
, void *file
)
4484 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 1);
4488 display_trace_info (struct dwarf_section
*section
, void *file
)
4490 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 0);
4494 display_debug_aranges (struct dwarf_section
*section
,
4495 void *file ATTRIBUTE_UNUSED
)
4497 unsigned char *start
= section
->start
;
4498 unsigned char *end
= start
+ section
->size
;
4500 printf (_("Contents of the %s section:\n\n"), section
->name
);
4502 /* It does not matter if this load fails,
4503 we test for that later on. */
4504 load_debug_info (file
);
4508 unsigned char *hdrptr
;
4509 DWARF2_Internal_ARange arange
;
4510 unsigned char *addr_ranges
;
4513 unsigned char address_size
;
4516 int initial_length_size
;
4520 SAFE_BYTE_GET_AND_INC (arange
.ar_length
, hdrptr
, 4, end
);
4521 if (arange
.ar_length
== 0xffffffff)
4523 SAFE_BYTE_GET_AND_INC (arange
.ar_length
, hdrptr
, 8, end
);
4525 initial_length_size
= 12;
4530 initial_length_size
= 4;
4533 SAFE_BYTE_GET_AND_INC (arange
.ar_version
, hdrptr
, 2, end
);
4534 SAFE_BYTE_GET_AND_INC (arange
.ar_info_offset
, hdrptr
, offset_size
, end
);
4536 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
4537 && num_debug_info_entries
> 0
4538 && find_debug_info_for_offset (arange
.ar_info_offset
) == NULL
)
4539 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
4540 (unsigned long) arange
.ar_info_offset
, section
->name
);
4542 SAFE_BYTE_GET_AND_INC (arange
.ar_pointer_size
, hdrptr
, 1, end
);
4543 SAFE_BYTE_GET_AND_INC (arange
.ar_segment_size
, hdrptr
, 1, end
);
4545 if (arange
.ar_version
!= 2 && arange
.ar_version
!= 3)
4547 warn (_("Only DWARF 2 and 3 aranges are currently supported.\n"));
4551 printf (_(" Length: %ld\n"),
4552 (long) arange
.ar_length
);
4553 printf (_(" Version: %d\n"), arange
.ar_version
);
4554 printf (_(" Offset into .debug_info: 0x%lx\n"),
4555 (unsigned long) arange
.ar_info_offset
);
4556 printf (_(" Pointer Size: %d\n"), arange
.ar_pointer_size
);
4557 printf (_(" Segment Size: %d\n"), arange
.ar_segment_size
);
4559 address_size
= arange
.ar_pointer_size
+ arange
.ar_segment_size
;
4561 if (address_size
== 0)
4563 error (_("Invalid address size in %s section!\n"),
4568 /* The DWARF spec does not require that the address size be a power
4569 of two, but we do. This will have to change if we ever encounter
4570 an uneven architecture. */
4571 if ((address_size
& (address_size
- 1)) != 0)
4573 warn (_("Pointer size + Segment size is not a power of two.\n"));
4577 if (address_size
> 4)
4578 printf (_("\n Address Length\n"));
4580 printf (_("\n Address Length\n"));
4582 addr_ranges
= hdrptr
;
4584 /* Must pad to an alignment boundary that is twice the address size. */
4585 excess
= (hdrptr
- start
) % (2 * address_size
);
4587 addr_ranges
+= (2 * address_size
) - excess
;
4589 start
+= arange
.ar_length
+ initial_length_size
;
4591 while (addr_ranges
+ 2 * address_size
<= start
)
4593 SAFE_BYTE_GET_AND_INC (address
, addr_ranges
, address_size
, end
);
4594 SAFE_BYTE_GET_AND_INC (length
, addr_ranges
, address_size
, end
);
4597 print_dwarf_vma (address
, address_size
);
4598 print_dwarf_vma (length
, address_size
);
4608 /* Comparison function for qsort. */
4610 comp_addr_base (const void * v0
, const void * v1
)
4612 debug_info
* info0
= (debug_info
*) v0
;
4613 debug_info
* info1
= (debug_info
*) v1
;
4614 return info0
->addr_base
- info1
->addr_base
;
4617 /* Display the debug_addr section. */
4619 display_debug_addr (struct dwarf_section
*section
,
4622 debug_info
**debug_addr_info
;
4623 unsigned char *entry
;
4628 if (section
->size
== 0)
4630 printf (_("\nThe %s section is empty.\n"), section
->name
);
4634 if (load_debug_info (file
) == 0)
4636 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4641 printf (_("Contents of the %s section:\n\n"), section
->name
);
4643 debug_addr_info
= (debug_info
**) xmalloc ((num_debug_info_entries
+ 1)
4644 * sizeof (debug_info
*));
4647 for (i
= 0; i
< num_debug_info_entries
; i
++)
4649 if (debug_information
[i
].addr_base
!= DEBUG_INFO_UNAVAILABLE
)
4650 debug_addr_info
[count
++] = &debug_information
[i
];
4653 /* Add a sentinel to make iteration convenient. */
4654 debug_addr_info
[count
] = (debug_info
*) xmalloc (sizeof (debug_info
));
4655 debug_addr_info
[count
]->addr_base
= section
->size
;
4657 qsort (debug_addr_info
, count
, sizeof (debug_info
*), comp_addr_base
);
4658 for (i
= 0; i
< count
; i
++)
4661 unsigned int address_size
= debug_addr_info
[i
]->pointer_size
;
4663 printf (_(" For compilation unit at offset 0x%s:\n"),
4664 dwarf_vmatoa ("x", debug_addr_info
[i
]->cu_offset
));
4666 printf (_("\tIndex\tAddress\n"));
4667 entry
= section
->start
+ debug_addr_info
[i
]->addr_base
;
4668 end
= section
->start
+ debug_addr_info
[i
+ 1]->addr_base
;
4672 dwarf_vma base
= byte_get (entry
, address_size
);
4673 printf (_("\t%d:\t"), idx
);
4674 print_dwarf_vma (base
, address_size
);
4676 entry
+= address_size
;
4682 free (debug_addr_info
);
4686 /* Display the .debug_str_offsets and .debug_str_offsets.dwo sections. */
4688 display_debug_str_offsets (struct dwarf_section
*section
,
4689 void *file ATTRIBUTE_UNUSED
)
4691 if (section
->size
== 0)
4693 printf (_("\nThe %s section is empty.\n"), section
->name
);
4696 /* TODO: Dump the contents. This is made somewhat difficult by not knowing
4697 what the offset size is for this section. */
4701 /* Each debug_information[x].range_lists[y] gets this representation for
4702 sorting purposes. */
4706 /* The debug_information[x].range_lists[y] value. */
4707 unsigned long ranges_offset
;
4709 /* Original debug_information to find parameters of the data. */
4710 debug_info
*debug_info_p
;
4713 /* Sort struct range_entry in ascending order of its RANGES_OFFSET. */
4716 range_entry_compar (const void *ap
, const void *bp
)
4718 const struct range_entry
*a_re
= (const struct range_entry
*) ap
;
4719 const struct range_entry
*b_re
= (const struct range_entry
*) bp
;
4720 const unsigned long a
= a_re
->ranges_offset
;
4721 const unsigned long b
= b_re
->ranges_offset
;
4723 return (a
> b
) - (b
> a
);
4727 display_debug_ranges (struct dwarf_section
*section
,
4728 void *file ATTRIBUTE_UNUSED
)
4730 unsigned char *start
= section
->start
;
4731 unsigned char *last_start
= start
;
4732 unsigned long bytes
= section
->size
;
4733 unsigned char *section_begin
= start
;
4734 unsigned char *finish
= start
+ bytes
;
4735 unsigned int num_range_list
, i
;
4736 struct range_entry
*range_entries
, *range_entry_fill
;
4740 printf (_("\nThe %s section is empty.\n"), section
->name
);
4744 if (load_debug_info (file
) == 0)
4746 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4752 for (i
= 0; i
< num_debug_info_entries
; i
++)
4753 num_range_list
+= debug_information
[i
].num_range_lists
;
4755 if (num_range_list
== 0)
4757 /* This can happen when the file was compiled with -gsplit-debug
4758 which removes references to range lists from the primary .o file. */
4759 printf (_("No range lists in .debug_info section.\n"));
4763 range_entries
= (struct range_entry
*)
4764 xmalloc (sizeof (*range_entries
) * num_range_list
);
4765 range_entry_fill
= range_entries
;
4767 for (i
= 0; i
< num_debug_info_entries
; i
++)
4769 debug_info
*debug_info_p
= &debug_information
[i
];
4772 for (j
= 0; j
< debug_info_p
->num_range_lists
; j
++)
4774 range_entry_fill
->ranges_offset
= debug_info_p
->range_lists
[j
];
4775 range_entry_fill
->debug_info_p
= debug_info_p
;
4780 qsort (range_entries
, num_range_list
, sizeof (*range_entries
),
4781 range_entry_compar
);
4783 /* DWARF sections under Mach-O have non-zero addresses. */
4784 if (dwarf_check
!= 0 && range_entries
[0].ranges_offset
!= section
->address
)
4785 warn (_("Range lists in %s section start at 0x%lx\n"),
4786 section
->name
, range_entries
[0].ranges_offset
);
4788 printf (_("Contents of the %s section:\n\n"), section
->name
);
4789 printf (_(" Offset Begin End\n"));
4791 for (i
= 0; i
< num_range_list
; i
++)
4793 struct range_entry
*range_entry
= &range_entries
[i
];
4794 debug_info
*debug_info_p
= range_entry
->debug_info_p
;
4795 unsigned int pointer_size
;
4796 unsigned long offset
;
4797 unsigned char *next
;
4798 unsigned long base_address
;
4800 pointer_size
= debug_info_p
->pointer_size
;
4802 /* DWARF sections under Mach-O have non-zero addresses. */
4803 offset
= range_entry
->ranges_offset
- section
->address
;
4804 next
= section_begin
+ offset
;
4805 base_address
= debug_info_p
->base_address
;
4807 if (dwarf_check
!= 0 && i
> 0)
4810 warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"),
4811 (unsigned long) (start
- section_begin
),
4812 (unsigned long) (next
- section_begin
), section
->name
);
4813 else if (start
> next
)
4815 if (next
== last_start
)
4817 warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"),
4818 (unsigned long) (start
- section_begin
),
4819 (unsigned long) (next
- section_begin
), section
->name
);
4825 while (start
< finish
)
4830 /* Note: we use sign extension here in order to be sure that
4831 we can detect the -1 escape value. Sign extension into the
4832 top 32 bits of a 32-bit address will not affect the values
4833 that we display since we always show hex values, and always
4834 the bottom 32-bits. */
4835 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, finish
);
4836 if (start
>= finish
)
4838 SAFE_SIGNED_BYTE_GET_AND_INC (end
, start
, pointer_size
, finish
);
4840 printf (" %8.8lx ", offset
);
4842 if (begin
== 0 && end
== 0)
4844 printf (_("<End of list>\n"));
4848 /* Check base address specifiers. */
4849 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
4852 print_dwarf_vma (begin
, pointer_size
);
4853 print_dwarf_vma (end
, pointer_size
);
4854 printf ("(base address)\n");
4858 print_dwarf_vma (begin
+ base_address
, pointer_size
);
4859 print_dwarf_vma (end
+ base_address
, pointer_size
);
4862 fputs (_("(start == end)"), stdout
);
4863 else if (begin
> end
)
4864 fputs (_("(start > end)"), stdout
);
4871 free (range_entries
);
4876 typedef struct Frame_Chunk
4878 struct Frame_Chunk
*next
;
4879 unsigned char *chunk_start
;
4881 /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
4882 short int *col_type
;
4885 unsigned int code_factor
;
4887 unsigned long pc_begin
;
4888 unsigned long pc_range
;
4892 unsigned char fde_encoding
;
4893 unsigned char cfa_exp
;
4894 unsigned char ptr_size
;
4895 unsigned char segment_size
;
4899 static const char *const *dwarf_regnames
;
4900 static unsigned int dwarf_regnames_count
;
4902 /* A marker for a col_type that means this column was never referenced
4903 in the frame info. */
4904 #define DW_CFA_unreferenced (-1)
4906 /* Return 0 if not more space is needed, 1 if more space is needed,
4907 -1 for invalid reg. */
4910 frame_need_space (Frame_Chunk
*fc
, unsigned int reg
)
4912 int prev
= fc
->ncols
;
4914 if (reg
< (unsigned int) fc
->ncols
)
4917 if (dwarf_regnames_count
4918 && reg
> dwarf_regnames_count
)
4921 fc
->ncols
= reg
+ 1;
4922 fc
->col_type
= (short int *) xcrealloc (fc
->col_type
, fc
->ncols
,
4923 sizeof (short int));
4924 fc
->col_offset
= (int *) xcrealloc (fc
->col_offset
, fc
->ncols
, sizeof (int));
4926 while (prev
< fc
->ncols
)
4928 fc
->col_type
[prev
] = DW_CFA_unreferenced
;
4929 fc
->col_offset
[prev
] = 0;
4935 static const char *const dwarf_regnames_i386
[] =
4937 "eax", "ecx", "edx", "ebx",
4938 "esp", "ebp", "esi", "edi",
4939 "eip", "eflags", NULL
,
4940 "st0", "st1", "st2", "st3",
4941 "st4", "st5", "st6", "st7",
4943 "xmm0", "xmm1", "xmm2", "xmm3",
4944 "xmm4", "xmm5", "xmm6", "xmm7",
4945 "mm0", "mm1", "mm2", "mm3",
4946 "mm4", "mm5", "mm6", "mm7",
4947 "fcw", "fsw", "mxcsr",
4948 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
4953 init_dwarf_regnames_i386 (void)
4955 dwarf_regnames
= dwarf_regnames_i386
;
4956 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_i386
);
4959 static const char *const dwarf_regnames_x86_64
[] =
4961 "rax", "rdx", "rcx", "rbx",
4962 "rsi", "rdi", "rbp", "rsp",
4963 "r8", "r9", "r10", "r11",
4964 "r12", "r13", "r14", "r15",
4966 "xmm0", "xmm1", "xmm2", "xmm3",
4967 "xmm4", "xmm5", "xmm6", "xmm7",
4968 "xmm8", "xmm9", "xmm10", "xmm11",
4969 "xmm12", "xmm13", "xmm14", "xmm15",
4970 "st0", "st1", "st2", "st3",
4971 "st4", "st5", "st6", "st7",
4972 "mm0", "mm1", "mm2", "mm3",
4973 "mm4", "mm5", "mm6", "mm7",
4975 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
4976 "fs.base", "gs.base", NULL
, NULL
,
4978 "mxcsr", "fcw", "fsw"
4982 init_dwarf_regnames_x86_64 (void)
4984 dwarf_regnames
= dwarf_regnames_x86_64
;
4985 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_x86_64
);
4989 init_dwarf_regnames (unsigned int e_machine
)
4995 init_dwarf_regnames_i386 ();
5001 init_dwarf_regnames_x86_64 ();
5010 regname (unsigned int regno
, int row
)
5012 static char reg
[64];
5014 && regno
< dwarf_regnames_count
5015 && dwarf_regnames
[regno
] != NULL
)
5018 return dwarf_regnames
[regno
];
5019 snprintf (reg
, sizeof (reg
), "r%d (%s)", regno
,
5020 dwarf_regnames
[regno
]);
5023 snprintf (reg
, sizeof (reg
), "r%d", regno
);
5028 frame_display_row (Frame_Chunk
*fc
, int *need_col_headers
, int *max_regs
)
5033 if (*max_regs
< fc
->ncols
)
5034 *max_regs
= fc
->ncols
;
5036 if (*need_col_headers
)
5038 static const char *sloc
= " LOC";
5040 *need_col_headers
= 0;
5042 printf ("%-*s CFA ", eh_addr_size
* 2, sloc
);
5044 for (r
= 0; r
< *max_regs
; r
++)
5045 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
5050 printf ("%-5s ", regname (r
, 1));
5056 printf ("%0*lx ", eh_addr_size
* 2, fc
->pc_begin
);
5058 strcpy (tmp
, "exp");
5060 sprintf (tmp
, "%s%+d", regname (fc
->cfa_reg
, 1), fc
->cfa_offset
);
5061 printf ("%-8s ", tmp
);
5063 for (r
= 0; r
< fc
->ncols
; r
++)
5065 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
5067 switch (fc
->col_type
[r
])
5069 case DW_CFA_undefined
:
5072 case DW_CFA_same_value
:
5076 sprintf (tmp
, "c%+d", fc
->col_offset
[r
]);
5078 case DW_CFA_val_offset
:
5079 sprintf (tmp
, "v%+d", fc
->col_offset
[r
]);
5081 case DW_CFA_register
:
5082 sprintf (tmp
, "%s", regname (fc
->col_offset
[r
], 0));
5084 case DW_CFA_expression
:
5085 strcpy (tmp
, "exp");
5087 case DW_CFA_val_expression
:
5088 strcpy (tmp
, "vexp");
5091 strcpy (tmp
, "n/a");
5094 printf ("%-5s ", tmp
);
5100 #define GET(VAR, N) SAFE_BYTE_GET_AND_INC (VAR, start, N, end);
5101 #define LEB() read_uleb128 (start, & length_return, end); start += length_return
5102 #define SLEB() read_sleb128 (start, & length_return, end); start += length_return
5105 display_debug_frames (struct dwarf_section
*section
,
5106 void *file ATTRIBUTE_UNUSED
)
5108 unsigned char *start
= section
->start
;
5109 unsigned char *end
= start
+ section
->size
;
5110 unsigned char *section_start
= start
;
5111 Frame_Chunk
*chunks
= 0;
5112 Frame_Chunk
*remembered_state
= 0;
5114 int is_eh
= strcmp (section
->name
, ".eh_frame") == 0;
5115 unsigned int length_return
;
5117 const char *bad_reg
= _("bad register: ");
5118 int saved_eh_addr_size
= eh_addr_size
;
5120 printf (_("Contents of the %s section:\n"), section
->name
);
5124 unsigned char *saved_start
;
5125 unsigned char *block_end
;
5126 unsigned long length
;
5127 unsigned long cie_id
;
5130 int need_col_headers
= 1;
5131 unsigned char *augmentation_data
= NULL
;
5132 unsigned long augmentation_data_len
= 0;
5133 int encoded_ptr_size
= saved_eh_addr_size
;
5135 int initial_length_size
;
5137 saved_start
= start
;
5139 SAFE_BYTE_GET_AND_INC (length
, start
, 4, end
);
5142 printf ("\n%08lx ZERO terminator\n\n",
5143 (unsigned long)(saved_start
- section_start
));
5147 if (length
== 0xffffffff)
5149 SAFE_BYTE_GET_AND_INC (length
, start
, 8, end
);
5151 initial_length_size
= 12;
5156 initial_length_size
= 4;
5159 block_end
= saved_start
+ length
+ initial_length_size
;
5160 if (block_end
> end
)
5162 warn ("Invalid length %#08lx in FDE at %#08lx\n",
5163 length
, (unsigned long)(saved_start
- section_start
));
5167 SAFE_BYTE_GET_AND_INC (cie_id
, start
, offset_size
, end
);
5169 if (is_eh
? (cie_id
== 0) : (cie_id
== DW_CIE_ID
))
5173 fc
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
5174 memset (fc
, 0, sizeof (Frame_Chunk
));
5178 fc
->chunk_start
= saved_start
;
5180 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
5181 fc
->col_offset
= (int *) xmalloc (sizeof (int));
5182 frame_need_space (fc
, max_regs
- 1);
5186 fc
->augmentation
= (char *) start
;
5187 start
= (unsigned char *) strchr ((char *) start
, '\0') + 1;
5189 if (strcmp (fc
->augmentation
, "eh") == 0)
5190 start
+= eh_addr_size
;
5194 GET (fc
->ptr_size
, 1);
5195 GET (fc
->segment_size
, 1);
5196 eh_addr_size
= fc
->ptr_size
;
5200 fc
->ptr_size
= eh_addr_size
;
5201 fc
->segment_size
= 0;
5203 fc
->code_factor
= LEB ();
5204 fc
->data_factor
= SLEB ();
5214 if (fc
->augmentation
[0] == 'z')
5216 augmentation_data_len
= LEB ();
5217 augmentation_data
= start
;
5218 start
+= augmentation_data_len
;
5222 if (do_debug_frames_interp
)
5223 printf ("\n%08lx %08lx %08lx CIE \"%s\" cf=%d df=%d ra=%d\n",
5224 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
5225 fc
->augmentation
, fc
->code_factor
, fc
->data_factor
,
5229 printf ("\n%08lx %08lx %08lx CIE\n",
5230 (unsigned long)(saved_start
- section_start
), length
, cie_id
);
5231 printf (" Version: %d\n", version
);
5232 printf (" Augmentation: \"%s\"\n", fc
->augmentation
);
5235 printf (" Pointer Size: %u\n", fc
->ptr_size
);
5236 printf (" Segment Size: %u\n", fc
->segment_size
);
5238 printf (" Code alignment factor: %u\n", fc
->code_factor
);
5239 printf (" Data alignment factor: %d\n", fc
->data_factor
);
5240 printf (" Return address column: %d\n", fc
->ra
);
5242 if (augmentation_data_len
)
5245 printf (" Augmentation data: ");
5246 for (i
= 0; i
< augmentation_data_len
; ++i
)
5247 printf (" %02x", augmentation_data
[i
]);
5253 if (augmentation_data_len
)
5255 unsigned char *p
, *q
;
5256 p
= (unsigned char *) fc
->augmentation
+ 1;
5257 q
= augmentation_data
;
5264 q
+= 1 + size_of_encoded_value (*q
);
5266 fc
->fde_encoding
= *q
++;
5274 if (fc
->fde_encoding
)
5275 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
5278 frame_need_space (fc
, fc
->ra
);
5282 unsigned char *look_for
;
5283 static Frame_Chunk fde_fc
;
5284 unsigned long segment_selector
;
5287 memset (fc
, 0, sizeof (Frame_Chunk
));
5289 look_for
= is_eh
? start
- 4 - cie_id
: section_start
+ cie_id
;
5291 for (cie
= chunks
; cie
; cie
= cie
->next
)
5292 if (cie
->chunk_start
== look_for
)
5297 warn ("Invalid CIE pointer %#08lx in FDE at %#08lx\n",
5298 cie_id
, (unsigned long)(saved_start
- section_start
));
5300 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
5301 fc
->col_offset
= (int *) xmalloc (sizeof (int));
5302 frame_need_space (fc
, max_regs
- 1);
5304 fc
->augmentation
= "";
5305 fc
->fde_encoding
= 0;
5306 fc
->ptr_size
= eh_addr_size
;
5307 fc
->segment_size
= 0;
5311 fc
->ncols
= cie
->ncols
;
5312 fc
->col_type
= (short int *) xcmalloc (fc
->ncols
, sizeof (short int));
5313 fc
->col_offset
= (int *) xcmalloc (fc
->ncols
, sizeof (int));
5314 memcpy (fc
->col_type
, cie
->col_type
, fc
->ncols
* sizeof (short int));
5315 memcpy (fc
->col_offset
, cie
->col_offset
, fc
->ncols
* sizeof (int));
5316 fc
->augmentation
= cie
->augmentation
;
5317 fc
->ptr_size
= cie
->ptr_size
;
5318 eh_addr_size
= cie
->ptr_size
;
5319 fc
->segment_size
= cie
->segment_size
;
5320 fc
->code_factor
= cie
->code_factor
;
5321 fc
->data_factor
= cie
->data_factor
;
5322 fc
->cfa_reg
= cie
->cfa_reg
;
5323 fc
->cfa_offset
= cie
->cfa_offset
;
5325 frame_need_space (fc
, max_regs
- 1);
5326 fc
->fde_encoding
= cie
->fde_encoding
;
5329 if (fc
->fde_encoding
)
5330 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
5332 segment_selector
= 0;
5333 if (fc
->segment_size
)
5335 SAFE_BYTE_GET_AND_INC (segment_selector
, start
, fc
->segment_size
, end
);
5337 fc
->pc_begin
= get_encoded_value (start
, fc
->fde_encoding
, section
);
5338 start
+= encoded_ptr_size
;
5340 /* FIXME: It appears that sometimes the final pc_range value is
5341 encoded in less than encoded_ptr_size bytes. See the x86_64
5342 run of the "objcopy on compressed debug sections" test for an
5344 SAFE_BYTE_GET_AND_INC (fc
->pc_range
, start
, encoded_ptr_size
, end
);
5346 if (cie
->augmentation
[0] == 'z')
5348 augmentation_data_len
= LEB ();
5349 augmentation_data
= start
;
5350 start
+= augmentation_data_len
;
5353 printf ("\n%08lx %08lx %08lx FDE cie=%08lx pc=",
5354 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
5355 (unsigned long)(cie
->chunk_start
- section_start
));
5356 if (fc
->segment_size
)
5357 printf ("%04lx:", segment_selector
);
5358 printf ("%08lx..%08lx\n", fc
->pc_begin
, fc
->pc_begin
+ fc
->pc_range
);
5359 if (! do_debug_frames_interp
&& augmentation_data_len
)
5363 printf (" Augmentation data: ");
5364 for (i
= 0; i
< augmentation_data_len
; ++i
)
5365 printf (" %02x", augmentation_data
[i
]);
5371 /* At this point, fc is the current chunk, cie (if any) is set, and
5372 we're about to interpret instructions for the chunk. */
5373 /* ??? At present we need to do this always, since this sizes the
5374 fc->col_type and fc->col_offset arrays, which we write into always.
5375 We should probably split the interpreted and non-interpreted bits
5376 into two different routines, since there's so much that doesn't
5377 really overlap between them. */
5378 if (1 || do_debug_frames_interp
)
5380 /* Start by making a pass over the chunk, allocating storage
5381 and taking note of what registers are used. */
5382 unsigned char *tmp
= start
;
5384 while (start
< block_end
)
5387 unsigned long reg
, temp
;
5394 /* Warning: if you add any more cases to this switch, be
5395 sure to add them to the corresponding switch below. */
5398 case DW_CFA_advance_loc
:
5402 if (frame_need_space (fc
, opa
) >= 0)
5403 fc
->col_type
[opa
] = DW_CFA_undefined
;
5405 case DW_CFA_restore
:
5406 if (frame_need_space (fc
, opa
) >= 0)
5407 fc
->col_type
[opa
] = DW_CFA_undefined
;
5409 case DW_CFA_set_loc
:
5410 start
+= encoded_ptr_size
;
5412 case DW_CFA_advance_loc1
:
5415 case DW_CFA_advance_loc2
:
5418 case DW_CFA_advance_loc4
:
5421 case DW_CFA_offset_extended
:
5422 case DW_CFA_val_offset
:
5423 reg
= LEB (); LEB ();
5424 if (frame_need_space (fc
, reg
) >= 0)
5425 fc
->col_type
[reg
] = DW_CFA_undefined
;
5427 case DW_CFA_restore_extended
:
5429 frame_need_space (fc
, reg
);
5430 if (frame_need_space (fc
, reg
) >= 0)
5431 fc
->col_type
[reg
] = DW_CFA_undefined
;
5433 case DW_CFA_undefined
:
5435 if (frame_need_space (fc
, reg
) >= 0)
5436 fc
->col_type
[reg
] = DW_CFA_undefined
;
5438 case DW_CFA_same_value
:
5440 if (frame_need_space (fc
, reg
) >= 0)
5441 fc
->col_type
[reg
] = DW_CFA_undefined
;
5443 case DW_CFA_register
:
5444 reg
= LEB (); LEB ();
5445 if (frame_need_space (fc
, reg
) >= 0)
5446 fc
->col_type
[reg
] = DW_CFA_undefined
;
5448 case DW_CFA_def_cfa
:
5451 case DW_CFA_def_cfa_register
:
5454 case DW_CFA_def_cfa_offset
:
5457 case DW_CFA_def_cfa_expression
:
5461 case DW_CFA_expression
:
5462 case DW_CFA_val_expression
:
5466 if (frame_need_space (fc
, reg
) >= 0)
5467 fc
->col_type
[reg
] = DW_CFA_undefined
;
5469 case DW_CFA_offset_extended_sf
:
5470 case DW_CFA_val_offset_sf
:
5471 reg
= LEB (); SLEB ();
5472 if (frame_need_space (fc
, reg
) >= 0)
5473 fc
->col_type
[reg
] = DW_CFA_undefined
;
5475 case DW_CFA_def_cfa_sf
:
5478 case DW_CFA_def_cfa_offset_sf
:
5481 case DW_CFA_MIPS_advance_loc8
:
5484 case DW_CFA_GNU_args_size
:
5487 case DW_CFA_GNU_negative_offset_extended
:
5488 reg
= LEB (); LEB ();
5489 if (frame_need_space (fc
, reg
) >= 0)
5490 fc
->col_type
[reg
] = DW_CFA_undefined
;
5499 /* Now we know what registers are used, make a second pass over
5500 the chunk, this time actually printing out the info. */
5502 while (start
< block_end
)
5505 unsigned long ul
, reg
, roffs
;
5508 const char *reg_prefix
= "";
5515 /* Warning: if you add any more cases to this switch, be
5516 sure to add them to the corresponding switch above. */
5519 case DW_CFA_advance_loc
:
5520 if (do_debug_frames_interp
)
5521 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5523 printf (" DW_CFA_advance_loc: %d to %08lx\n",
5524 opa
* fc
->code_factor
,
5525 fc
->pc_begin
+ opa
* fc
->code_factor
);
5526 fc
->pc_begin
+= opa
* fc
->code_factor
;
5531 if (opa
>= (unsigned int) fc
->ncols
)
5532 reg_prefix
= bad_reg
;
5533 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5534 printf (" DW_CFA_offset: %s%s at cfa%+ld\n",
5535 reg_prefix
, regname (opa
, 0),
5536 roffs
* fc
->data_factor
);
5537 if (*reg_prefix
== '\0')
5539 fc
->col_type
[opa
] = DW_CFA_offset
;
5540 fc
->col_offset
[opa
] = roffs
* fc
->data_factor
;
5544 case DW_CFA_restore
:
5545 if (opa
>= (unsigned int) cie
->ncols
5546 || opa
>= (unsigned int) fc
->ncols
)
5547 reg_prefix
= bad_reg
;
5548 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5549 printf (" DW_CFA_restore: %s%s\n",
5550 reg_prefix
, regname (opa
, 0));
5551 if (*reg_prefix
== '\0')
5553 fc
->col_type
[opa
] = cie
->col_type
[opa
];
5554 fc
->col_offset
[opa
] = cie
->col_offset
[opa
];
5555 if (do_debug_frames_interp
5556 && fc
->col_type
[opa
] == DW_CFA_unreferenced
)
5557 fc
->col_type
[opa
] = DW_CFA_undefined
;
5561 case DW_CFA_set_loc
:
5562 vma
= get_encoded_value (start
, fc
->fde_encoding
, section
);
5563 start
+= encoded_ptr_size
;
5564 if (do_debug_frames_interp
)
5565 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5567 printf (" DW_CFA_set_loc: %08lx\n", (unsigned long)vma
);
5571 case DW_CFA_advance_loc1
:
5572 SAFE_BYTE_GET_AND_INC (ofs
, start
, 1, end
);
5573 if (do_debug_frames_interp
)
5574 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5576 printf (" DW_CFA_advance_loc1: %ld to %08lx\n",
5577 ofs
* fc
->code_factor
,
5578 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5579 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5582 case DW_CFA_advance_loc2
:
5583 SAFE_BYTE_GET_AND_INC (ofs
, start
, 2, end
);
5584 if (do_debug_frames_interp
)
5585 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5587 printf (" DW_CFA_advance_loc2: %ld to %08lx\n",
5588 ofs
* fc
->code_factor
,
5589 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5590 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5593 case DW_CFA_advance_loc4
:
5594 SAFE_BYTE_GET_AND_INC (ofs
, start
, 4, end
);
5595 if (do_debug_frames_interp
)
5596 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5598 printf (" DW_CFA_advance_loc4: %ld to %08lx\n",
5599 ofs
* fc
->code_factor
,
5600 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5601 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5604 case DW_CFA_offset_extended
:
5607 if (reg
>= (unsigned int) fc
->ncols
)
5608 reg_prefix
= bad_reg
;
5609 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5610 printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n",
5611 reg_prefix
, regname (reg
, 0),
5612 roffs
* fc
->data_factor
);
5613 if (*reg_prefix
== '\0')
5615 fc
->col_type
[reg
] = DW_CFA_offset
;
5616 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
5620 case DW_CFA_val_offset
:
5623 if (reg
>= (unsigned int) fc
->ncols
)
5624 reg_prefix
= bad_reg
;
5625 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5626 printf (" DW_CFA_val_offset: %s%s at cfa%+ld\n",
5627 reg_prefix
, regname (reg
, 0),
5628 roffs
* fc
->data_factor
);
5629 if (*reg_prefix
== '\0')
5631 fc
->col_type
[reg
] = DW_CFA_val_offset
;
5632 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
5636 case DW_CFA_restore_extended
:
5638 if (reg
>= (unsigned int) cie
->ncols
5639 || reg
>= (unsigned int) fc
->ncols
)
5640 reg_prefix
= bad_reg
;
5641 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5642 printf (" DW_CFA_restore_extended: %s%s\n",
5643 reg_prefix
, regname (reg
, 0));
5644 if (*reg_prefix
== '\0')
5646 fc
->col_type
[reg
] = cie
->col_type
[reg
];
5647 fc
->col_offset
[reg
] = cie
->col_offset
[reg
];
5651 case DW_CFA_undefined
:
5653 if (reg
>= (unsigned int) fc
->ncols
)
5654 reg_prefix
= bad_reg
;
5655 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5656 printf (" DW_CFA_undefined: %s%s\n",
5657 reg_prefix
, regname (reg
, 0));
5658 if (*reg_prefix
== '\0')
5660 fc
->col_type
[reg
] = DW_CFA_undefined
;
5661 fc
->col_offset
[reg
] = 0;
5665 case DW_CFA_same_value
:
5667 if (reg
>= (unsigned int) fc
->ncols
)
5668 reg_prefix
= bad_reg
;
5669 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5670 printf (" DW_CFA_same_value: %s%s\n",
5671 reg_prefix
, regname (reg
, 0));
5672 if (*reg_prefix
== '\0')
5674 fc
->col_type
[reg
] = DW_CFA_same_value
;
5675 fc
->col_offset
[reg
] = 0;
5679 case DW_CFA_register
:
5682 if (reg
>= (unsigned int) fc
->ncols
)
5683 reg_prefix
= bad_reg
;
5684 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5686 printf (" DW_CFA_register: %s%s in ",
5687 reg_prefix
, regname (reg
, 0));
5688 puts (regname (roffs
, 0));
5690 if (*reg_prefix
== '\0')
5692 fc
->col_type
[reg
] = DW_CFA_register
;
5693 fc
->col_offset
[reg
] = roffs
;
5697 case DW_CFA_remember_state
:
5698 if (! do_debug_frames_interp
)
5699 printf (" DW_CFA_remember_state\n");
5700 rs
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
5701 rs
->ncols
= fc
->ncols
;
5702 rs
->col_type
= (short int *) xcmalloc (rs
->ncols
,
5703 sizeof (short int));
5704 rs
->col_offset
= (int *) xcmalloc (rs
->ncols
, sizeof (int));
5705 memcpy (rs
->col_type
, fc
->col_type
, rs
->ncols
);
5706 memcpy (rs
->col_offset
, fc
->col_offset
, rs
->ncols
* sizeof (int));
5707 rs
->next
= remembered_state
;
5708 remembered_state
= rs
;
5711 case DW_CFA_restore_state
:
5712 if (! do_debug_frames_interp
)
5713 printf (" DW_CFA_restore_state\n");
5714 rs
= remembered_state
;
5717 remembered_state
= rs
->next
;
5718 frame_need_space (fc
, rs
->ncols
- 1);
5719 memcpy (fc
->col_type
, rs
->col_type
, rs
->ncols
);
5720 memcpy (fc
->col_offset
, rs
->col_offset
,
5721 rs
->ncols
* sizeof (int));
5722 free (rs
->col_type
);
5723 free (rs
->col_offset
);
5726 else if (do_debug_frames_interp
)
5727 printf ("Mismatched DW_CFA_restore_state\n");
5730 case DW_CFA_def_cfa
:
5731 fc
->cfa_reg
= LEB ();
5732 fc
->cfa_offset
= LEB ();
5734 if (! do_debug_frames_interp
)
5735 printf (" DW_CFA_def_cfa: %s ofs %d\n",
5736 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
5739 case DW_CFA_def_cfa_register
:
5740 fc
->cfa_reg
= LEB ();
5742 if (! do_debug_frames_interp
)
5743 printf (" DW_CFA_def_cfa_register: %s\n",
5744 regname (fc
->cfa_reg
, 0));
5747 case DW_CFA_def_cfa_offset
:
5748 fc
->cfa_offset
= LEB ();
5749 if (! do_debug_frames_interp
)
5750 printf (" DW_CFA_def_cfa_offset: %d\n", fc
->cfa_offset
);
5754 if (! do_debug_frames_interp
)
5755 printf (" DW_CFA_nop\n");
5758 case DW_CFA_def_cfa_expression
:
5760 if (! do_debug_frames_interp
)
5762 printf (" DW_CFA_def_cfa_expression (");
5763 decode_location_expression (start
, eh_addr_size
, 0, -1,
5771 case DW_CFA_expression
:
5774 if (reg
>= (unsigned int) fc
->ncols
)
5775 reg_prefix
= bad_reg
;
5776 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5778 printf (" DW_CFA_expression: %s%s (",
5779 reg_prefix
, regname (reg
, 0));
5780 decode_location_expression (start
, eh_addr_size
, 0, -1,
5784 if (*reg_prefix
== '\0')
5785 fc
->col_type
[reg
] = DW_CFA_expression
;
5789 case DW_CFA_val_expression
:
5792 if (reg
>= (unsigned int) fc
->ncols
)
5793 reg_prefix
= bad_reg
;
5794 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5796 printf (" DW_CFA_val_expression: %s%s (",
5797 reg_prefix
, regname (reg
, 0));
5798 decode_location_expression (start
, eh_addr_size
, 0, -1,
5802 if (*reg_prefix
== '\0')
5803 fc
->col_type
[reg
] = DW_CFA_val_expression
;
5807 case DW_CFA_offset_extended_sf
:
5810 if (frame_need_space (fc
, reg
) < 0)
5811 reg_prefix
= bad_reg
;
5812 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5813 printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n",
5814 reg_prefix
, regname (reg
, 0),
5815 l
* fc
->data_factor
);
5816 if (*reg_prefix
== '\0')
5818 fc
->col_type
[reg
] = DW_CFA_offset
;
5819 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
5823 case DW_CFA_val_offset_sf
:
5826 if (frame_need_space (fc
, reg
) < 0)
5827 reg_prefix
= bad_reg
;
5828 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5829 printf (" DW_CFA_val_offset_sf: %s%s at cfa%+ld\n",
5830 reg_prefix
, regname (reg
, 0),
5831 l
* fc
->data_factor
);
5832 if (*reg_prefix
== '\0')
5834 fc
->col_type
[reg
] = DW_CFA_val_offset
;
5835 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
5839 case DW_CFA_def_cfa_sf
:
5840 fc
->cfa_reg
= LEB ();
5841 fc
->cfa_offset
= SLEB ();
5842 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
5844 if (! do_debug_frames_interp
)
5845 printf (" DW_CFA_def_cfa_sf: %s ofs %d\n",
5846 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
5849 case DW_CFA_def_cfa_offset_sf
:
5850 fc
->cfa_offset
= SLEB ();
5851 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
5852 if (! do_debug_frames_interp
)
5853 printf (" DW_CFA_def_cfa_offset_sf: %d\n", fc
->cfa_offset
);
5856 case DW_CFA_MIPS_advance_loc8
:
5857 SAFE_BYTE_GET_AND_INC (ofs
, start
, 8, end
);
5858 if (do_debug_frames_interp
)
5859 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5861 printf (" DW_CFA_MIPS_advance_loc8: %ld to %08lx\n",
5862 ofs
* fc
->code_factor
,
5863 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5864 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5867 case DW_CFA_GNU_window_save
:
5868 if (! do_debug_frames_interp
)
5869 printf (" DW_CFA_GNU_window_save\n");
5872 case DW_CFA_GNU_args_size
:
5874 if (! do_debug_frames_interp
)
5875 printf (" DW_CFA_GNU_args_size: %ld\n", ul
);
5878 case DW_CFA_GNU_negative_offset_extended
:
5881 if (frame_need_space (fc
, reg
) < 0)
5882 reg_prefix
= bad_reg
;
5883 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5884 printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n",
5885 reg_prefix
, regname (reg
, 0),
5886 l
* fc
->data_factor
);
5887 if (*reg_prefix
== '\0')
5889 fc
->col_type
[reg
] = DW_CFA_offset
;
5890 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
5895 if (op
>= DW_CFA_lo_user
&& op
<= DW_CFA_hi_user
)
5896 printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op
);
5898 warn (_("unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op
);
5903 if (do_debug_frames_interp
)
5904 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5907 eh_addr_size
= saved_eh_addr_size
;
5920 display_gdb_index (struct dwarf_section
*section
,
5921 void *file ATTRIBUTE_UNUSED
)
5923 unsigned char *start
= section
->start
;
5925 uint32_t cu_list_offset
, tu_list_offset
;
5926 uint32_t address_table_offset
, symbol_table_offset
, constant_pool_offset
;
5927 unsigned int cu_list_elements
, tu_list_elements
;
5928 unsigned int address_table_size
, symbol_table_slots
;
5929 unsigned char *cu_list
, *tu_list
;
5930 unsigned char *address_table
, *symbol_table
, *constant_pool
;
5933 /* The documentation for the format of this file is in gdb/dwarf2read.c. */
5935 printf (_("Contents of the %s section:\n"), section
->name
);
5937 if (section
->size
< 6 * sizeof (uint32_t))
5939 warn (_("Truncated header in the %s section.\n"), section
->name
);
5943 version
= byte_get_little_endian (start
, 4);
5944 printf (_("Version %ld\n"), (long) version
);
5946 /* Prior versions are obsolete, and future versions may not be
5947 backwards compatible. */
5948 if (version
< 3 || version
> 8)
5950 warn (_("Unsupported version %lu.\n"), (unsigned long) version
);
5954 warn (_("The address table data in version 3 may be wrong.\n"));
5956 warn (_("Version 4 does not support case insensitive lookups.\n"));
5958 warn (_("Version 5 does not include inlined functions.\n"));
5960 warn (_("Version 6 does not include symbol attributes.\n"));
5961 /* Version 7 indices generated by Gold have bad type unit references,
5962 PR binutils/15021. But we don't know if the index was generated by
5963 Gold or not, so to avoid worrying users with gdb-generated indices
5964 we say nothing for version 7 here. */
5966 cu_list_offset
= byte_get_little_endian (start
+ 4, 4);
5967 tu_list_offset
= byte_get_little_endian (start
+ 8, 4);
5968 address_table_offset
= byte_get_little_endian (start
+ 12, 4);
5969 symbol_table_offset
= byte_get_little_endian (start
+ 16, 4);
5970 constant_pool_offset
= byte_get_little_endian (start
+ 20, 4);
5972 if (cu_list_offset
> section
->size
5973 || tu_list_offset
> section
->size
5974 || address_table_offset
> section
->size
5975 || symbol_table_offset
> section
->size
5976 || constant_pool_offset
> section
->size
)
5978 warn (_("Corrupt header in the %s section.\n"), section
->name
);
5982 cu_list_elements
= (tu_list_offset
- cu_list_offset
) / 8;
5983 tu_list_elements
= (address_table_offset
- tu_list_offset
) / 8;
5984 address_table_size
= symbol_table_offset
- address_table_offset
;
5985 symbol_table_slots
= (constant_pool_offset
- symbol_table_offset
) / 8;
5987 cu_list
= start
+ cu_list_offset
;
5988 tu_list
= start
+ tu_list_offset
;
5989 address_table
= start
+ address_table_offset
;
5990 symbol_table
= start
+ symbol_table_offset
;
5991 constant_pool
= start
+ constant_pool_offset
;
5993 printf (_("\nCU table:\n"));
5994 for (i
= 0; i
< cu_list_elements
; i
+= 2)
5996 uint64_t cu_offset
= byte_get_little_endian (cu_list
+ i
* 8, 8);
5997 uint64_t cu_length
= byte_get_little_endian (cu_list
+ i
* 8 + 8, 8);
5999 printf (_("[%3u] 0x%lx - 0x%lx\n"), i
/ 2,
6000 (unsigned long) cu_offset
,
6001 (unsigned long) (cu_offset
+ cu_length
- 1));
6004 printf (_("\nTU table:\n"));
6005 for (i
= 0; i
< tu_list_elements
; i
+= 3)
6007 uint64_t tu_offset
= byte_get_little_endian (tu_list
+ i
* 8, 8);
6008 uint64_t type_offset
= byte_get_little_endian (tu_list
+ i
* 8 + 8, 8);
6009 uint64_t signature
= byte_get_little_endian (tu_list
+ i
* 8 + 16, 8);
6011 printf (_("[%3u] 0x%lx 0x%lx "), i
/ 3,
6012 (unsigned long) tu_offset
,
6013 (unsigned long) type_offset
);
6014 print_dwarf_vma (signature
, 8);
6018 printf (_("\nAddress table:\n"));
6019 for (i
= 0; i
< address_table_size
; i
+= 2 * 8 + 4)
6021 uint64_t low
= byte_get_little_endian (address_table
+ i
, 8);
6022 uint64_t high
= byte_get_little_endian (address_table
+ i
+ 8, 8);
6023 uint32_t cu_index
= byte_get_little_endian (address_table
+ i
+ 16, 4);
6025 print_dwarf_vma (low
, 8);
6026 print_dwarf_vma (high
, 8);
6027 printf (_("%lu\n"), (unsigned long) cu_index
);
6030 printf (_("\nSymbol table:\n"));
6031 for (i
= 0; i
< symbol_table_slots
; ++i
)
6033 uint32_t name_offset
= byte_get_little_endian (symbol_table
+ i
* 8, 4);
6034 uint32_t cu_vector_offset
= byte_get_little_endian (symbol_table
+ i
* 8 + 4, 4);
6035 uint32_t num_cus
, cu
;
6037 if (name_offset
!= 0
6038 || cu_vector_offset
!= 0)
6042 printf ("[%3u] %s:", i
, constant_pool
+ name_offset
);
6043 num_cus
= byte_get_little_endian (constant_pool
+ cu_vector_offset
, 4);
6046 for (j
= 0; j
< num_cus
; ++j
)
6049 gdb_index_symbol_kind kind
;
6051 cu
= byte_get_little_endian (constant_pool
+ cu_vector_offset
+ 4 + j
* 4, 4);
6052 is_static
= GDB_INDEX_SYMBOL_STATIC_VALUE (cu
);
6053 kind
= GDB_INDEX_SYMBOL_KIND_VALUE (cu
);
6054 cu
= GDB_INDEX_CU_VALUE (cu
);
6055 /* Convert to TU number if it's for a type unit. */
6056 if (cu
>= cu_list_elements
/ 2)
6057 printf ("%cT%lu", num_cus
> 1 ? '\t' : ' ',
6058 (unsigned long) (cu
- cu_list_elements
/ 2));
6060 printf ("%c%lu", num_cus
> 1 ? '\t' : ' ', (unsigned long) cu
);
6064 case GDB_INDEX_SYMBOL_KIND_NONE
:
6065 printf (_(" [no symbol information]"));
6067 case GDB_INDEX_SYMBOL_KIND_TYPE
:
6069 ? _(" [static type]")
6070 : _(" [global type]"));
6072 case GDB_INDEX_SYMBOL_KIND_VARIABLE
:
6074 ? _(" [static variable]")
6075 : _(" [global variable]"));
6077 case GDB_INDEX_SYMBOL_KIND_FUNCTION
:
6079 ? _(" [static function]")
6080 : _(" [global function]"));
6082 case GDB_INDEX_SYMBOL_KIND_OTHER
:
6084 ? _(" [static other]")
6085 : _(" [global other]"));
6089 ? _(" [static unknown: %d]")
6090 : _(" [global unknown: %d]"),
6105 /* Pre-allocate enough space for the CU/TU sets needed. */
6108 prealloc_cu_tu_list (unsigned int nshndx
)
6110 if (shndx_pool
== NULL
)
6112 shndx_pool_size
= nshndx
;
6113 shndx_pool_used
= 0;
6114 shndx_pool
= (unsigned int *) xcmalloc (shndx_pool_size
,
6115 sizeof (unsigned int));
6119 shndx_pool_size
= shndx_pool_used
+ nshndx
;
6120 shndx_pool
= (unsigned int *) xcrealloc (shndx_pool
, shndx_pool_size
,
6121 sizeof (unsigned int));
6126 add_shndx_to_cu_tu_entry (unsigned int shndx
)
6128 if (shndx_pool_used
>= shndx_pool_size
)
6130 error (_("Internal error: out of space in the shndx pool.\n"));
6133 shndx_pool
[shndx_pool_used
++] = shndx
;
6137 end_cu_tu_entry (void)
6139 if (shndx_pool_used
>= shndx_pool_size
)
6141 error (_("Internal error: out of space in the shndx pool.\n"));
6144 shndx_pool
[shndx_pool_used
++] = 0;
6147 /* Return the short name of a DWARF section given by a DW_SECT enumerator. */
6150 get_DW_SECT_short_name (unsigned int dw_sect
)
6152 static char buf
[16];
6160 case DW_SECT_ABBREV
:
6166 case DW_SECT_STR_OFFSETS
:
6168 case DW_SECT_MACINFO
:
6176 snprintf (buf
, sizeof (buf
), "%d", dw_sect
);
6180 /* Process a CU or TU index. If DO_DISPLAY is true, print the contents.
6181 These sections are extensions for Fission.
6182 See http://gcc.gnu.org/wiki/DebugFissionDWP. */
6185 process_cu_tu_index (struct dwarf_section
*section
, int do_display
)
6187 unsigned char *phdr
= section
->start
;
6188 unsigned char *limit
= phdr
+ section
->size
;
6189 unsigned char *phash
;
6190 unsigned char *pindex
;
6191 unsigned char *ppool
;
6192 unsigned int version
;
6193 unsigned int ncols
= 0;
6195 unsigned int nslots
;
6198 dwarf_vma signature_high
;
6199 dwarf_vma signature_low
;
6202 version
= byte_get (phdr
, 4);
6204 ncols
= byte_get (phdr
+ 4, 4);
6205 nused
= byte_get (phdr
+ 8, 4);
6206 nslots
= byte_get (phdr
+ 12, 4);
6208 pindex
= phash
+ nslots
* 8;
6209 ppool
= pindex
+ nslots
* 4;
6213 printf (_("Contents of the %s section:\n\n"), section
->name
);
6214 printf (_(" Version: %d\n"), version
);
6216 printf (_(" Number of columns: %d\n"), ncols
);
6217 printf (_(" Number of used entries: %d\n"), nused
);
6218 printf (_(" Number of slots: %d\n\n"), nslots
);
6223 warn (_("Section %s too small for %d hash table entries\n"),
6224 section
->name
, nslots
);
6231 prealloc_cu_tu_list ((limit
- ppool
) / 4);
6232 for (i
= 0; i
< nslots
; i
++)
6234 unsigned char *shndx_list
;
6237 byte_get_64 (phash
, &signature_high
, &signature_low
);
6238 if (signature_high
!= 0 || signature_low
!= 0)
6240 j
= byte_get (pindex
, 4);
6241 shndx_list
= ppool
+ j
* 4;
6243 printf (_(" [%3d] Signature: 0x%s Sections: "),
6244 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
6245 buf
, sizeof (buf
)));
6248 if (shndx_list
>= limit
)
6250 warn (_("Section %s too small for shndx pool\n"),
6254 shndx
= byte_get (shndx_list
, 4);
6258 printf (" %d", shndx
);
6260 add_shndx_to_cu_tu_entry (shndx
);
6272 else if (version
== 2)
6275 unsigned int dw_sect
;
6276 unsigned char *ph
= phash
;
6277 unsigned char *pi
= pindex
;
6278 unsigned char *poffsets
= ppool
+ ncols
* 4;
6279 unsigned char *psizes
= poffsets
+ nused
* ncols
* 4;
6280 unsigned char *pend
= psizes
+ nused
* ncols
* 4;
6281 bfd_boolean is_tu_index
;
6282 struct cu_tu_set
*this_set
= NULL
;
6284 unsigned char *prow
;
6286 is_tu_index
= strcmp (section
->name
, ".debug_tu_index") == 0;
6290 warn (_("Section %s too small for offset and size tables\n"),
6297 printf (_(" Offset table\n"));
6298 printf (" slot %-16s ",
6299 is_tu_index
? _("signature") : _("dwo_id"));
6306 tu_sets
= xcmalloc (nused
, sizeof (struct cu_tu_set
));
6312 cu_sets
= xcmalloc (nused
, sizeof (struct cu_tu_set
));
6318 for (j
= 0; j
< ncols
; j
++)
6320 dw_sect
= byte_get (ppool
+ j
* 4, 4);
6321 printf (" %8s", get_DW_SECT_short_name (dw_sect
));
6325 for (i
= 0; i
< nslots
; i
++)
6327 byte_get_64 (ph
, &signature_high
, &signature_low
);
6328 row
= byte_get (pi
, 4);
6332 memcpy (&this_set
[row
- 1].signature
, ph
, sizeof (uint64_t));
6333 prow
= poffsets
+ (row
- 1) * ncols
* 4;
6335 printf (_(" [%3d] 0x%s"),
6336 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
6337 buf
, sizeof (buf
)));
6338 for (j
= 0; j
< ncols
; j
++)
6340 val
= byte_get (prow
+ j
* 4, 4);
6342 printf (" %8d", val
);
6345 dw_sect
= byte_get (ppool
+ j
* 4, 4);
6346 this_set
[row
- 1].section_offsets
[dw_sect
] = val
;
6361 printf (_(" Size table\n"));
6362 printf (" slot %-16s ",
6363 is_tu_index
? _("signature") : _("dwo_id"));
6365 for (j
= 0; j
< ncols
; j
++)
6367 val
= byte_get (ppool
+ j
* 4, 4);
6369 printf (" %8s", get_DW_SECT_short_name (val
));
6373 for (i
= 0; i
< nslots
; i
++)
6375 byte_get_64 (ph
, &signature_high
, &signature_low
);
6376 row
= byte_get (pi
, 4);
6379 prow
= psizes
+ (row
- 1) * ncols
* 4;
6381 printf (_(" [%3d] 0x%s"),
6382 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
6383 buf
, sizeof (buf
)));
6384 for (j
= 0; j
< ncols
; j
++)
6386 val
= byte_get (prow
+ j
* 4, 4);
6388 printf (" %8d", val
);
6391 dw_sect
= byte_get (ppool
+ j
* 4, 4);
6392 this_set
[row
- 1].section_sizes
[dw_sect
] = val
;
6402 else if (do_display
)
6403 printf (_(" Unsupported version\n"));
6411 /* Load the CU and TU indexes if present. This will build a list of
6412 section sets that we can use to associate a .debug_info.dwo section
6413 with its associated .debug_abbrev.dwo section in a .dwp file. */
6416 load_cu_tu_indexes (void *file
)
6418 /* If we have already loaded (or tried to load) the CU and TU indexes
6419 then do not bother to repeat the task. */
6420 if (cu_tu_indexes_read
)
6423 if (load_debug_section (dwp_cu_index
, file
))
6424 process_cu_tu_index (&debug_displays
[dwp_cu_index
].section
, 0);
6426 if (load_debug_section (dwp_tu_index
, file
))
6427 process_cu_tu_index (&debug_displays
[dwp_tu_index
].section
, 0);
6429 cu_tu_indexes_read
= 1;
6432 /* Find the set of sections that includes section SHNDX. */
6435 find_cu_tu_set (void *file
, unsigned int shndx
)
6439 load_cu_tu_indexes (file
);
6441 /* Find SHNDX in the shndx pool. */
6442 for (i
= 0; i
< shndx_pool_used
; i
++)
6443 if (shndx_pool
[i
] == shndx
)
6446 if (i
>= shndx_pool_used
)
6449 /* Now backup to find the first entry in the set. */
6450 while (i
> 0 && shndx_pool
[i
- 1] != 0)
6453 return shndx_pool
+ i
;
6456 /* Display a .debug_cu_index or .debug_tu_index section. */
6459 display_cu_index (struct dwarf_section
*section
, void *file ATTRIBUTE_UNUSED
)
6461 return process_cu_tu_index (section
, 1);
6465 display_debug_not_supported (struct dwarf_section
*section
,
6466 void *file ATTRIBUTE_UNUSED
)
6468 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
6475 cmalloc (size_t nmemb
, size_t size
)
6477 /* Check for overflow. */
6478 if (nmemb
>= ~(size_t) 0 / size
)
6481 return malloc (nmemb
* size
);
6485 xcmalloc (size_t nmemb
, size_t size
)
6487 /* Check for overflow. */
6488 if (nmemb
>= ~(size_t) 0 / size
)
6491 return xmalloc (nmemb
* size
);
6495 xcrealloc (void *ptr
, size_t nmemb
, size_t size
)
6497 /* Check for overflow. */
6498 if (nmemb
>= ~(size_t) 0 / size
)
6501 return xrealloc (ptr
, nmemb
* size
);
6505 free_debug_memory (void)
6511 for (i
= 0; i
< max
; i
++)
6512 free_debug_section ((enum dwarf_section_display_enum
) i
);
6514 if (debug_information
!= NULL
)
6516 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
)
6518 for (i
= 0; i
< num_debug_info_entries
; i
++)
6520 if (!debug_information
[i
].max_loc_offsets
)
6522 free (debug_information
[i
].loc_offsets
);
6523 free (debug_information
[i
].have_frame_base
);
6525 if (!debug_information
[i
].max_range_lists
)
6526 free (debug_information
[i
].range_lists
);
6530 free (debug_information
);
6531 debug_information
= NULL
;
6532 num_debug_info_entries
= 0;
6537 dwarf_select_sections_by_names (const char *names
)
6541 const char * option
;
6545 debug_dump_long_opts
;
6547 static const debug_dump_long_opts opts_table
[] =
6549 /* Please keep this table alpha- sorted. */
6550 { "Ranges", & do_debug_ranges
, 1 },
6551 { "abbrev", & do_debug_abbrevs
, 1 },
6552 { "addr", & do_debug_addr
, 1 },
6553 { "aranges", & do_debug_aranges
, 1 },
6554 { "cu_index", & do_debug_cu_index
, 1 },
6555 { "decodedline", & do_debug_lines
, FLAG_DEBUG_LINES_DECODED
},
6556 { "frames", & do_debug_frames
, 1 },
6557 { "frames-interp", & do_debug_frames_interp
, 1 },
6558 /* The special .gdb_index section. */
6559 { "gdb_index", & do_gdb_index
, 1 },
6560 { "info", & do_debug_info
, 1 },
6561 { "line", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
}, /* For backwards compatibility. */
6562 { "loc", & do_debug_loc
, 1 },
6563 { "macro", & do_debug_macinfo
, 1 },
6564 { "pubnames", & do_debug_pubnames
, 1 },
6565 { "pubtypes", & do_debug_pubtypes
, 1 },
6566 /* This entry is for compatability
6567 with earlier versions of readelf. */
6568 { "ranges", & do_debug_aranges
, 1 },
6569 { "rawline", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
},
6570 { "str", & do_debug_str
, 1 },
6571 /* These trace_* sections are used by Itanium VMS. */
6572 { "trace_abbrev", & do_trace_abbrevs
, 1 },
6573 { "trace_aranges", & do_trace_aranges
, 1 },
6574 { "trace_info", & do_trace_info
, 1 },
6583 const debug_dump_long_opts
* entry
;
6585 for (entry
= opts_table
; entry
->option
; entry
++)
6587 size_t len
= strlen (entry
->option
);
6589 if (strncmp (p
, entry
->option
, len
) == 0
6590 && (p
[len
] == ',' || p
[len
] == '\0'))
6592 * entry
->variable
|= entry
->val
;
6594 /* The --debug-dump=frames-interp option also
6595 enables the --debug-dump=frames option. */
6596 if (do_debug_frames_interp
)
6597 do_debug_frames
= 1;
6604 if (entry
->option
== NULL
)
6606 warn (_("Unrecognized debug option '%s'\n"), p
);
6607 p
= strchr (p
, ',');
6618 dwarf_select_sections_by_letters (const char *letters
)
6620 unsigned int lindex
= 0;
6622 while (letters
[lindex
])
6623 switch (letters
[lindex
++])
6630 do_debug_abbrevs
= 1;
6634 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
6638 do_debug_lines
|= FLAG_DEBUG_LINES_DECODED
;
6642 do_debug_pubnames
= 1;
6646 do_debug_pubtypes
= 1;
6650 do_debug_aranges
= 1;
6654 do_debug_ranges
= 1;
6658 do_debug_frames_interp
= 1;
6660 do_debug_frames
= 1;
6664 do_debug_macinfo
= 1;
6676 warn (_("Unrecognized debug option '%s'\n"), optarg
);
6682 dwarf_select_sections_all (void)
6685 do_debug_abbrevs
= 1;
6686 do_debug_lines
= FLAG_DEBUG_LINES_RAW
;
6687 do_debug_pubnames
= 1;
6688 do_debug_pubtypes
= 1;
6689 do_debug_aranges
= 1;
6690 do_debug_ranges
= 1;
6691 do_debug_frames
= 1;
6692 do_debug_macinfo
= 1;
6697 do_trace_abbrevs
= 1;
6698 do_trace_aranges
= 1;
6700 do_debug_cu_index
= 1;
6703 struct dwarf_section_display debug_displays
[] =
6705 { { ".debug_abbrev", ".zdebug_abbrev", NULL
, NULL
, 0, 0, 0 },
6706 display_debug_abbrev
, &do_debug_abbrevs
, 0 },
6707 { { ".debug_aranges", ".zdebug_aranges", NULL
, NULL
, 0, 0, 0 },
6708 display_debug_aranges
, &do_debug_aranges
, 1 },
6709 { { ".debug_frame", ".zdebug_frame", NULL
, NULL
, 0, 0, 0 },
6710 display_debug_frames
, &do_debug_frames
, 1 },
6711 { { ".debug_info", ".zdebug_info", NULL
, NULL
, 0, 0, abbrev
},
6712 display_debug_info
, &do_debug_info
, 1 },
6713 { { ".debug_line", ".zdebug_line", NULL
, NULL
, 0, 0, 0 },
6714 display_debug_lines
, &do_debug_lines
, 1 },
6715 { { ".debug_pubnames", ".zdebug_pubnames", NULL
, NULL
, 0, 0, 0 },
6716 display_debug_pubnames
, &do_debug_pubnames
, 0 },
6717 { { ".eh_frame", "", NULL
, NULL
, 0, 0, 0 },
6718 display_debug_frames
, &do_debug_frames
, 1 },
6719 { { ".debug_macinfo", ".zdebug_macinfo", NULL
, NULL
, 0, 0, 0 },
6720 display_debug_macinfo
, &do_debug_macinfo
, 0 },
6721 { { ".debug_macro", ".zdebug_macro", NULL
, NULL
, 0, 0, 0 },
6722 display_debug_macro
, &do_debug_macinfo
, 1 },
6723 { { ".debug_str", ".zdebug_str", NULL
, NULL
, 0, 0, 0 },
6724 display_debug_str
, &do_debug_str
, 0 },
6725 { { ".debug_loc", ".zdebug_loc", NULL
, NULL
, 0, 0, 0 },
6726 display_debug_loc
, &do_debug_loc
, 1 },
6727 { { ".debug_pubtypes", ".zdebug_pubtypes", NULL
, NULL
, 0, 0, 0 },
6728 display_debug_pubnames
, &do_debug_pubtypes
, 0 },
6729 { { ".debug_ranges", ".zdebug_ranges", NULL
, NULL
, 0, 0, 0 },
6730 display_debug_ranges
, &do_debug_ranges
, 1 },
6731 { { ".debug_static_func", ".zdebug_static_func", NULL
, NULL
, 0, 0, 0 },
6732 display_debug_not_supported
, NULL
, 0 },
6733 { { ".debug_static_vars", ".zdebug_static_vars", NULL
, NULL
, 0, 0, 0 },
6734 display_debug_not_supported
, NULL
, 0 },
6735 { { ".debug_types", ".zdebug_types", NULL
, NULL
, 0, 0, abbrev
},
6736 display_debug_types
, &do_debug_info
, 1 },
6737 { { ".debug_weaknames", ".zdebug_weaknames", NULL
, NULL
, 0, 0, 0 },
6738 display_debug_not_supported
, NULL
, 0 },
6739 { { ".gdb_index", "", NULL
, NULL
, 0, 0, 0 },
6740 display_gdb_index
, &do_gdb_index
, 0 },
6741 { { ".trace_info", "", NULL
, NULL
, 0, 0, trace_abbrev
},
6742 display_trace_info
, &do_trace_info
, 1 },
6743 { { ".trace_abbrev", "", NULL
, NULL
, 0, 0, 0 },
6744 display_debug_abbrev
, &do_trace_abbrevs
, 0 },
6745 { { ".trace_aranges", "", NULL
, NULL
, 0, 0, 0 },
6746 display_debug_aranges
, &do_trace_aranges
, 0 },
6747 { { ".debug_info.dwo", ".zdebug_info.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6748 display_debug_info
, &do_debug_info
, 1 },
6749 { { ".debug_abbrev.dwo", ".zdebug_abbrev.dwo", NULL
, NULL
, 0, 0, 0 },
6750 display_debug_abbrev
, &do_debug_abbrevs
, 0 },
6751 { { ".debug_types.dwo", ".zdebug_types.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6752 display_debug_types
, &do_debug_info
, 1 },
6753 { { ".debug_line.dwo", ".zdebug_line.dwo", NULL
, NULL
, 0, 0, 0 },
6754 display_debug_lines
, &do_debug_lines
, 1 },
6755 { { ".debug_loc.dwo", ".zdebug_loc.dwo", NULL
, NULL
, 0, 0, 0 },
6756 display_debug_loc
, &do_debug_loc
, 1 },
6757 { { ".debug_macro.dwo", ".zdebug_macro.dwo", NULL
, NULL
, 0, 0, 0 },
6758 display_debug_macro
, &do_debug_macinfo
, 1 },
6759 { { ".debug_macinfo.dwo", ".zdebug_macinfo.dwo", NULL
, NULL
, 0, 0, 0 },
6760 display_debug_macinfo
, &do_debug_macinfo
, 0 },
6761 { { ".debug_str.dwo", ".zdebug_str.dwo", NULL
, NULL
, 0, 0, 0 },
6762 display_debug_str
, &do_debug_str
, 1 },
6763 { { ".debug_str_offsets", ".zdebug_str_offsets", NULL
, NULL
, 0, 0, 0 },
6764 display_debug_str_offsets
, NULL
, 0 },
6765 { { ".debug_str_offsets.dwo", ".zdebug_str_offsets.dwo", NULL
, NULL
, 0, 0, 0 },
6766 display_debug_str_offsets
, NULL
, 0 },
6767 { { ".debug_addr", ".zdebug_addr", NULL
, NULL
, 0, 0, 0 },
6768 display_debug_addr
, &do_debug_addr
, 1 },
6769 { { ".debug_cu_index", "", NULL
, NULL
, 0, 0, 0 },
6770 display_cu_index
, &do_debug_cu_index
, 0 },
6771 { { ".debug_tu_index", "", NULL
, NULL
, 0, 0, 0 },
6772 display_cu_index
, &do_debug_cu_index
, 0 },