1 /* dwarf.c -- display DWARF contents of a BFD binary file
2 Copyright (C) 2005-2014 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
22 #include "libiberty.h"
24 #include "bfd_stdint.h"
27 #include "elf/common.h"
30 #include "gdb/gdb-index.h"
32 static const char *regname (unsigned int regno, int row);
34 static int have_frame_base;
35 static int need_base_address;
37 static unsigned int last_pointer_size = 0;
38 static int warned_about_missing_comp_units = FALSE;
40 static unsigned int num_debug_info_entries = 0;
41 static debug_info *debug_information = NULL;
42 /* Special value for num_debug_info_entries to indicate
43 that the .debug_info section could not be loaded/parsed. */
44 #define DEBUG_INFO_UNAVAILABLE (unsigned int) -1
51 int do_debug_pubnames;
52 int do_debug_pubtypes;
56 int do_debug_frames_interp;
65 int do_debug_cu_index;
68 int dwarf_cutoff_level = -1;
69 unsigned long dwarf_start_die;
73 /* Collection of CU/TU section sets from .debug_cu_index and .debug_tu_index
74 sections. For version 1 package files, each set is stored in SHNDX_POOL
75 as a zero-terminated list of section indexes comprising one set of debug
76 sections from a .dwo file. */
78 static int cu_tu_indexes_read = 0;
79 static unsigned int *shndx_pool = NULL;
80 static unsigned int shndx_pool_size = 0;
81 static unsigned int shndx_pool_used = 0;
83 /* For version 2 package files, each set contains an array of section offsets
84 and an array of section sizes, giving the offset and size of the
85 contribution from a CU or TU within one of the debug sections.
86 When displaying debug info from a package file, we need to use these
87 tables to locate the corresponding contributions to each section. */
92 dwarf_vma section_offsets[DW_SECT_MAX];
93 size_t section_sizes[DW_SECT_MAX];
96 static int cu_count = 0;
97 static int tu_count = 0;
98 static struct cu_tu_set *cu_sets = NULL;
99 static struct cu_tu_set *tu_sets = NULL;
101 static void load_cu_tu_indexes (void *file);
103 /* Values for do_debug_lines. */
104 #define FLAG_DEBUG_LINES_RAW 1
105 #define FLAG_DEBUG_LINES_DECODED 2
108 size_of_encoded_value (int encoding)
110 switch (encoding & 0x7)
113 case 0: return eh_addr_size;
121 get_encoded_value (unsigned char **pdata,
123 struct dwarf_section *section,
126 unsigned char * data = * pdata;
127 int size = size_of_encoded_value (encoding);
130 if (data + size >= end)
132 warn (_("Encoded value extends past end of section\n"));
137 if (encoding & DW_EH_PE_signed)
138 val = byte_get_signed (data, size);
140 val = byte_get (data, size);
142 if ((encoding & 0x70) == DW_EH_PE_pcrel)
143 val += section->address + (data - section->start);
145 * pdata = data + size;
149 #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
151 #define DWARF_VMA_FMT "ll"
152 #define DWARF_VMA_FMT_LONG "%16.16llx"
154 #define DWARF_VMA_FMT "I64"
155 #define DWARF_VMA_FMT_LONG "%016I64x"
158 #define DWARF_VMA_FMT "l"
159 #define DWARF_VMA_FMT_LONG "%16.16lx"
162 /* Convert a dwarf vma value into a string. Returns a pointer to a static
163 buffer containing the converted VALUE. The value is converted according
164 to the printf formating character FMTCH. If NUM_BYTES is non-zero then
165 it specifies the maximum number of bytes to be displayed in the converted
166 value and FMTCH is ignored - hex is always used. */
169 dwarf_vmatoa_1 (const char *fmtch, dwarf_vma value, unsigned num_bytes)
171 /* As dwarf_vmatoa is used more then once in a printf call
172 for output, we are cycling through an fixed array of pointers
173 for return address. */
174 static int buf_pos = 0;
175 static struct dwarf_vmatoa_buf
181 ret = buf[buf_pos++].place;
182 buf_pos %= ARRAY_SIZE (buf);
186 /* Printf does not have a way of specifiying a maximum field width for an
187 integer value, so we print the full value into a buffer and then select
188 the precision we need. */
189 snprintf (ret, sizeof (buf[0].place), DWARF_VMA_FMT_LONG, value);
192 return ret + (16 - 2 * num_bytes);
198 sprintf (fmt, "%%%s%s", DWARF_VMA_FMT, fmtch);
199 snprintf (ret, sizeof (buf[0].place), fmt, value);
204 static inline const char *
205 dwarf_vmatoa (const char * fmtch, dwarf_vma value)
207 return dwarf_vmatoa_1 (fmtch, value, 0);
210 /* Print a dwarf_vma value (typically an address, offset or length) in
211 hexadecimal format, followed by a space. The length of the VALUE (and
212 hence the precision displayed) is determined by the NUM_BYTES parameter. */
215 print_dwarf_vma (dwarf_vma value, unsigned num_bytes)
217 printf ("%s ", dwarf_vmatoa_1 (NULL, value, num_bytes));
220 /* Format a 64-bit value, given as two 32-bit values, in hex.
221 For reentrancy, this uses a buffer provided by the caller. */
224 dwarf_vmatoa64 (dwarf_vma hvalue, dwarf_vma lvalue, char *buf,
225 unsigned int buf_len)
230 snprintf (buf, buf_len, "%" DWARF_VMA_FMT "x", lvalue);
233 len = snprintf (buf, buf_len, "%" DWARF_VMA_FMT "x", hvalue);
234 snprintf (buf + len, buf_len - len,
235 "%08" DWARF_VMA_FMT "x", lvalue);
241 /* Read in a LEB128 encoded value starting at address DATA.
242 If SIGN is true, return a signed LEB128 value.
243 If LENGTH_RETURN is not NULL, return in it the number of bytes read.
244 No bytes will be read at address END or beyond. */
247 read_leb128 (unsigned char *data,
248 unsigned int *length_return,
250 const unsigned char * const end)
252 dwarf_vma result = 0;
253 unsigned int num_read = 0;
254 unsigned int shift = 0;
255 unsigned char byte = 0;
262 result |= ((dwarf_vma) (byte & 0x7f)) << shift;
265 if ((byte & 0x80) == 0)
269 if (length_return != NULL)
270 *length_return = num_read;
272 if (sign && (shift < 8 * sizeof (result)) && (byte & 0x40))
273 result |= (dwarf_vma) -1 << shift;
278 /* Create a signed version to avoid painful typecasts. */
279 static inline dwarf_signed_vma
280 read_sleb128 (unsigned char * data,
281 unsigned int * length_return,
282 const unsigned char * const end)
284 return (dwarf_signed_vma) read_leb128 (data, length_return, TRUE, end);
287 static inline dwarf_vma
288 read_uleb128 (unsigned char * data,
289 unsigned int * length_return,
290 const unsigned char * const end)
292 return read_leb128 (data, length_return, FALSE, end);
295 #define SAFE_BYTE_GET(VAL, PTR, AMOUNT, END) \
298 int dummy [sizeof (VAL) < (AMOUNT) ? -1 : 1] ATTRIBUTE_UNUSED ; \
299 unsigned int amount = (AMOUNT); \
300 if (((PTR) + amount) >= (END)) \
303 amount = (END) - (PTR); \
308 VAL = byte_get ((PTR), amount); \
314 #define SAFE_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \
317 SAFE_BYTE_GET (VAL, PTR, AMOUNT, END); \
322 #define SAFE_SIGNED_BYTE_GET(VAL, PTR, AMOUNT, END) \
325 unsigned int amount = (AMOUNT); \
326 if (((PTR) + amount) >= (END)) \
329 amount = (END) - (PTR); \
334 VAL = byte_get_signed ((PTR), amount); \
340 #define SAFE_SIGNED_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \
343 SAFE_SIGNED_BYTE_GET (VAL, PTR, AMOUNT, END); \
348 #define SAFE_BYTE_GET64(PTR, HIGH, LOW, END) \
351 if (((PTR) + 8) <= (END)) \
353 byte_get_64 ((PTR), (HIGH), (LOW)); \
357 * (LOW) = * (HIGH) = 0; \
362 typedef struct State_Machine_Registers
370 unsigned char op_index;
371 unsigned char end_sequence;
372 /* This variable hold the number of the last entry seen
373 in the File Table. */
374 unsigned int last_file_entry;
377 static SMR state_machine_regs;
380 reset_state_machine (int is_stmt)
382 state_machine_regs.address = 0;
383 state_machine_regs.op_index = 0;
384 state_machine_regs.file = 1;
385 state_machine_regs.line = 1;
386 state_machine_regs.column = 0;
387 state_machine_regs.is_stmt = is_stmt;
388 state_machine_regs.basic_block = 0;
389 state_machine_regs.end_sequence = 0;
390 state_machine_regs.last_file_entry = 0;
393 /* Handled an extend line op.
394 Returns the number of bytes read. */
397 process_extended_line_op (unsigned char * data,
401 unsigned char op_code;
402 unsigned int bytes_read;
405 unsigned char *orig_data = data;
408 len = read_uleb128 (data, & bytes_read, end);
411 if (len == 0 || data == end)
413 warn (_("Badly formed extended line op encountered!\n"));
420 printf (_(" Extended opcode %d: "), op_code);
424 case DW_LNE_end_sequence:
425 printf (_("End of Sequence\n\n"));
426 reset_state_machine (is_stmt);
429 case DW_LNE_set_address:
430 SAFE_BYTE_GET (adr, data, len - bytes_read - 1, end);
431 printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr));
432 state_machine_regs.address = adr;
433 state_machine_regs.op_index = 0;
436 case DW_LNE_define_file:
437 printf (_("define new File Table entry\n"));
438 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
439 printf (" %d\t", ++state_machine_regs.last_file_entry);
442 data += strnlen ((char *) data, end - data) + 1;
443 printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end)));
445 printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end)));
447 printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end)));
449 printf ("%s\n\n", name);
451 if (((unsigned int) (data - orig_data) != len) || data == end)
452 warn (_("DW_LNE_define_file: Bad opcode length\n"));
455 case DW_LNE_set_discriminator:
456 printf (_("set Discriminator to %s\n"),
457 dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end)));
461 case DW_LNE_HP_negate_is_UV_update:
462 printf ("DW_LNE_HP_negate_is_UV_update\n");
464 case DW_LNE_HP_push_context:
465 printf ("DW_LNE_HP_push_context\n");
467 case DW_LNE_HP_pop_context:
468 printf ("DW_LNE_HP_pop_context\n");
470 case DW_LNE_HP_set_file_line_column:
471 printf ("DW_LNE_HP_set_file_line_column\n");
473 case DW_LNE_HP_set_routine_name:
474 printf ("DW_LNE_HP_set_routine_name\n");
476 case DW_LNE_HP_set_sequence:
477 printf ("DW_LNE_HP_set_sequence\n");
479 case DW_LNE_HP_negate_post_semantics:
480 printf ("DW_LNE_HP_negate_post_semantics\n");
482 case DW_LNE_HP_negate_function_exit:
483 printf ("DW_LNE_HP_negate_function_exit\n");
485 case DW_LNE_HP_negate_front_end_logical:
486 printf ("DW_LNE_HP_negate_front_end_logical\n");
488 case DW_LNE_HP_define_proc:
489 printf ("DW_LNE_HP_define_proc\n");
491 case DW_LNE_HP_source_file_correlation:
493 unsigned char *edata = data + len - bytes_read - 1;
495 printf ("DW_LNE_HP_source_file_correlation\n");
501 opc = read_uleb128 (data, & bytes_read, edata);
506 case DW_LNE_HP_SFC_formfeed:
507 printf (" DW_LNE_HP_SFC_formfeed\n");
509 case DW_LNE_HP_SFC_set_listing_line:
510 printf (" DW_LNE_HP_SFC_set_listing_line (%s)\n",
512 read_uleb128 (data, & bytes_read, edata)));
515 case DW_LNE_HP_SFC_associate:
516 printf (" DW_LNE_HP_SFC_associate ");
519 read_uleb128 (data, & bytes_read, edata)));
523 read_uleb128 (data, & bytes_read, edata)));
527 read_uleb128 (data, & bytes_read, edata)));
531 printf (_(" UNKNOWN DW_LNE_HP_SFC opcode (%u)\n"), opc);
541 unsigned int rlen = len - bytes_read - 1;
543 if (op_code >= DW_LNE_lo_user
544 /* The test against DW_LNW_hi_user is redundant due to
545 the limited range of the unsigned char data type used
547 /*&& op_code <= DW_LNE_hi_user*/)
548 printf (_("user defined: "));
550 printf (_("UNKNOWN: "));
551 printf (_("length %d ["), rlen);
553 printf (" %02x", *data++);
562 static const unsigned char *
563 fetch_indirect_string (dwarf_vma offset)
565 struct dwarf_section *section = &debug_displays [str].section;
567 if (section->start == NULL)
568 return (const unsigned char *) _("<no .debug_str section>");
570 if (offset > section->size)
572 warn (_("DW_FORM_strp offset too big: %s\n"),
573 dwarf_vmatoa ("x", offset));
574 return (const unsigned char *) _("<offset is too big>");
577 return (const unsigned char *) section->start + offset;
581 fetch_indexed_string (dwarf_vma idx, struct cu_tu_set *this_set,
582 dwarf_vma offset_size, int dwo)
584 enum dwarf_section_display_enum str_sec_idx = dwo ? str_dwo : str;
585 enum dwarf_section_display_enum idx_sec_idx = dwo ? str_index_dwo : str_index;
586 struct dwarf_section *index_section = &debug_displays [idx_sec_idx].section;
587 struct dwarf_section *str_section = &debug_displays [str_sec_idx].section;
588 dwarf_vma index_offset = idx * offset_size;
589 dwarf_vma str_offset;
591 if (index_section->start == NULL)
592 return (dwo ? _("<no .debug_str_offsets.dwo section>")
593 : _("<no .debug_str_offsets section>"));
595 if (this_set != NULL)
596 index_offset += this_set->section_offsets [DW_SECT_STR_OFFSETS];
597 if (index_offset > index_section->size)
599 warn (_("DW_FORM_GNU_str_index offset too big: %s\n"),
600 dwarf_vmatoa ("x", index_offset));
601 return _("<index offset is too big>");
604 if (str_section->start == NULL)
605 return (dwo ? _("<no .debug_str.dwo section>")
606 : _("<no .debug_str section>"));
608 str_offset = byte_get (index_section->start + index_offset, offset_size);
609 str_offset -= str_section->address;
610 if (str_offset > str_section->size)
612 warn (_("DW_FORM_GNU_str_index indirect offset too big: %s\n"),
613 dwarf_vmatoa ("x", str_offset));
614 return _("<indirect index offset is too big>");
617 return (const char *) str_section->start + str_offset;
621 fetch_indexed_value (dwarf_vma offset, dwarf_vma bytes)
623 struct dwarf_section *section = &debug_displays [debug_addr].section;
625 if (section->start == NULL)
626 return (_("<no .debug_addr section>"));
628 if (offset + bytes > section->size)
630 warn (_("Offset into section %s too big: %s\n"),
631 section->name, dwarf_vmatoa ("x", offset));
632 return "<offset too big>";
635 return dwarf_vmatoa ("x", byte_get (section->start + offset, bytes));
639 /* FIXME: There are better and more efficient ways to handle
640 these structures. For now though, I just want something that
641 is simple to implement. */
642 typedef struct abbrev_attr
644 unsigned long attribute;
646 struct abbrev_attr *next;
650 typedef struct abbrev_entry
655 struct abbrev_attr *first_attr;
656 struct abbrev_attr *last_attr;
657 struct abbrev_entry *next;
661 static abbrev_entry *first_abbrev = NULL;
662 static abbrev_entry *last_abbrev = NULL;
669 for (abbrv = first_abbrev; abbrv;)
671 abbrev_entry *next_abbrev = abbrv->next;
674 for (attr = abbrv->first_attr; attr;)
676 abbrev_attr *next_attr = attr->next;
686 last_abbrev = first_abbrev = NULL;
690 add_abbrev (unsigned long number, unsigned long tag, int children)
694 entry = (abbrev_entry *) malloc (sizeof (*entry));
699 entry->entry = number;
701 entry->children = children;
702 entry->first_attr = NULL;
703 entry->last_attr = NULL;
706 if (first_abbrev == NULL)
707 first_abbrev = entry;
709 last_abbrev->next = entry;
715 add_abbrev_attr (unsigned long attribute, unsigned long form)
719 attr = (abbrev_attr *) malloc (sizeof (*attr));
724 attr->attribute = attribute;
728 if (last_abbrev->first_attr == NULL)
729 last_abbrev->first_attr = attr;
731 last_abbrev->last_attr->next = attr;
733 last_abbrev->last_attr = attr;
736 /* Processes the (partial) contents of a .debug_abbrev section.
737 Returns NULL if the end of the section was encountered.
738 Returns the address after the last byte read if the end of
739 an abbreviation set was found. */
741 static unsigned char *
742 process_abbrev_section (unsigned char *start, unsigned char *end)
744 if (first_abbrev != NULL)
749 unsigned int bytes_read;
752 unsigned long attribute;
755 entry = read_uleb128 (start, & bytes_read, end);
758 /* A single zero is supposed to end the section according
759 to the standard. If there's more, then signal that to
766 tag = read_uleb128 (start, & bytes_read, end);
773 add_abbrev (entry, tag, children);
779 attribute = read_uleb128 (start, & bytes_read, end);
784 form = read_uleb128 (start, & bytes_read, end);
789 add_abbrev_attr (attribute, form);
791 while (attribute != 0);
794 /* Report the missing single zero which ends the section. */
795 error (_(".debug_abbrev section not zero terminated\n"));
801 get_TAG_name (unsigned long tag)
803 const char *name = get_DW_TAG_name ((unsigned int)tag);
807 static char buffer[100];
809 snprintf (buffer, sizeof (buffer), _("Unknown TAG value: %lx"), tag);
817 get_FORM_name (unsigned long form)
822 return "DW_FORM value: 0";
824 name = get_DW_FORM_name (form);
827 static char buffer[100];
829 snprintf (buffer, sizeof (buffer), _("Unknown FORM value: %lx"), form);
836 static unsigned char *
837 display_block (unsigned char *data,
839 const unsigned char * const end)
843 printf (_(" %s byte block: "), dwarf_vmatoa ("u", length));
845 maxlen = (dwarf_vma) (end - data);
846 length = length > maxlen ? maxlen : length;
849 printf ("%lx ", (unsigned long) byte_get (data++, 1));
855 decode_location_expression (unsigned char * data,
856 unsigned int pointer_size,
857 unsigned int offset_size,
861 struct dwarf_section * section)
864 unsigned int bytes_read;
866 dwarf_signed_vma svalue;
867 unsigned char *end = data + length;
868 int need_frame_base = 0;
877 SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end);
878 printf ("DW_OP_addr: %s", dwarf_vmatoa ("x", uvalue));
881 printf ("DW_OP_deref");
884 SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end);
885 printf ("DW_OP_const1u: %lu", (unsigned long) uvalue);
888 SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 1, end);
889 printf ("DW_OP_const1s: %ld", (long) svalue);
892 SAFE_BYTE_GET_AND_INC (uvalue, data, 2, end);
893 printf ("DW_OP_const2u: %lu", (unsigned long) uvalue);
896 SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end);
897 printf ("DW_OP_const2s: %ld", (long) svalue);
900 SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end);
901 printf ("DW_OP_const4u: %lu", (unsigned long) uvalue);
904 SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end);
905 printf ("DW_OP_const4s: %ld", (long) svalue);
908 SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end);
909 printf ("DW_OP_const8u: %lu ", (unsigned long) uvalue);
910 SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end);
911 printf ("%lu", (unsigned long) uvalue);
914 SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end);
915 printf ("DW_OP_const8s: %ld ", (long) svalue);
916 SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end);
917 printf ("%ld", (long) svalue);
920 printf ("DW_OP_constu: %s",
921 dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end)));
925 printf ("DW_OP_consts: %s",
926 dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end)));
930 printf ("DW_OP_dup");
933 printf ("DW_OP_drop");
936 printf ("DW_OP_over");
939 SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end);
940 printf ("DW_OP_pick: %ld", (unsigned long) uvalue);
943 printf ("DW_OP_swap");
946 printf ("DW_OP_rot");
949 printf ("DW_OP_xderef");
952 printf ("DW_OP_abs");
955 printf ("DW_OP_and");
958 printf ("DW_OP_div");
961 printf ("DW_OP_minus");
964 printf ("DW_OP_mod");
967 printf ("DW_OP_mul");
970 printf ("DW_OP_neg");
973 printf ("DW_OP_not");
979 printf ("DW_OP_plus");
981 case DW_OP_plus_uconst:
982 printf ("DW_OP_plus_uconst: %s",
983 dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end)));
987 printf ("DW_OP_shl");
990 printf ("DW_OP_shr");
993 printf ("DW_OP_shra");
996 printf ("DW_OP_xor");
999 SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end);
1000 printf ("DW_OP_bra: %ld", (long) svalue);
1003 printf ("DW_OP_eq");
1006 printf ("DW_OP_ge");
1009 printf ("DW_OP_gt");
1012 printf ("DW_OP_le");
1015 printf ("DW_OP_lt");
1018 printf ("DW_OP_ne");
1021 SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end);
1022 printf ("DW_OP_skip: %ld", (long) svalue);
1057 printf ("DW_OP_lit%d", op - DW_OP_lit0);
1092 printf ("DW_OP_reg%d (%s)", op - DW_OP_reg0,
1093 regname (op - DW_OP_reg0, 1));
1128 printf ("DW_OP_breg%d (%s): %s",
1130 regname (op - DW_OP_breg0, 1),
1131 dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end)));
1136 uvalue = read_uleb128 (data, &bytes_read, end);
1138 printf ("DW_OP_regx: %s (%s)",
1139 dwarf_vmatoa ("u", uvalue), regname (uvalue, 1));
1142 need_frame_base = 1;
1143 printf ("DW_OP_fbreg: %s",
1144 dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end)));
1148 uvalue = read_uleb128 (data, &bytes_read, end);
1150 printf ("DW_OP_bregx: %s (%s) %s",
1151 dwarf_vmatoa ("u", uvalue), regname (uvalue, 1),
1152 dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end)));
1156 printf ("DW_OP_piece: %s",
1157 dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end)));
1160 case DW_OP_deref_size:
1161 SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end);
1162 printf ("DW_OP_deref_size: %ld", (long) uvalue);
1164 case DW_OP_xderef_size:
1165 SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end);
1166 printf ("DW_OP_xderef_size: %ld", (long) uvalue);
1169 printf ("DW_OP_nop");
1172 /* DWARF 3 extensions. */
1173 case DW_OP_push_object_address:
1174 printf ("DW_OP_push_object_address");
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, 2, end);
1180 printf ("DW_OP_call2: <0x%s>",
1181 dwarf_vmatoa ("x", svalue + cu_offset));
1184 /* XXX: Strictly speaking for 64-bit DWARF3 files
1185 this ought to be an 8-byte wide computation. */
1186 SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end);
1187 printf ("DW_OP_call4: <0x%s>",
1188 dwarf_vmatoa ("x", svalue + cu_offset));
1190 case DW_OP_call_ref:
1191 /* XXX: Strictly speaking for 64-bit DWARF3 files
1192 this ought to be an 8-byte wide computation. */
1193 if (dwarf_version == -1)
1195 printf (_("(DW_OP_call_ref in frame info)"));
1196 /* No way to tell where the next op is, so just bail. */
1197 return need_frame_base;
1199 if (dwarf_version == 2)
1201 SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end);
1205 SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end);
1207 printf ("DW_OP_call_ref: <0x%s>", dwarf_vmatoa ("x", uvalue));
1209 case DW_OP_form_tls_address:
1210 printf ("DW_OP_form_tls_address");
1212 case DW_OP_call_frame_cfa:
1213 printf ("DW_OP_call_frame_cfa");
1215 case DW_OP_bit_piece:
1216 printf ("DW_OP_bit_piece: ");
1217 printf (_("size: %s "),
1218 dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end)));
1220 printf (_("offset: %s "),
1221 dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end)));
1225 /* DWARF 4 extensions. */
1226 case DW_OP_stack_value:
1227 printf ("DW_OP_stack_value");
1230 case DW_OP_implicit_value:
1231 printf ("DW_OP_implicit_value");
1232 uvalue = read_uleb128 (data, &bytes_read, end);
1234 display_block (data, uvalue, end);
1238 /* GNU extensions. */
1239 case DW_OP_GNU_push_tls_address:
1240 printf (_("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown"));
1242 case DW_OP_GNU_uninit:
1243 printf ("DW_OP_GNU_uninit");
1244 /* FIXME: Is there data associated with this OP ? */
1246 case DW_OP_GNU_encoded_addr:
1252 addr = get_encoded_value (&data, encoding, section, end);
1254 printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding);
1255 print_dwarf_vma (addr, pointer_size);
1258 case DW_OP_GNU_implicit_pointer:
1259 /* XXX: Strictly speaking for 64-bit DWARF3 files
1260 this ought to be an 8-byte wide computation. */
1261 if (dwarf_version == -1)
1263 printf (_("(DW_OP_GNU_implicit_pointer in frame info)"));
1264 /* No way to tell where the next op is, so just bail. */
1265 return need_frame_base;
1267 if (dwarf_version == 2)
1269 SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end);
1273 SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end);
1275 printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s",
1276 dwarf_vmatoa ("x", uvalue),
1277 dwarf_vmatoa ("d", read_sleb128 (data,
1278 &bytes_read, end)));
1281 case DW_OP_GNU_entry_value:
1282 uvalue = read_uleb128 (data, &bytes_read, end);
1284 printf ("DW_OP_GNU_entry_value: (");
1285 if (decode_location_expression (data, pointer_size, offset_size,
1286 dwarf_version, uvalue,
1287 cu_offset, section))
1288 need_frame_base = 1;
1292 case DW_OP_GNU_const_type:
1293 uvalue = read_uleb128 (data, &bytes_read, end);
1295 printf ("DW_OP_GNU_const_type: <0x%s> ",
1296 dwarf_vmatoa ("x", cu_offset + uvalue));
1297 SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end);
1298 display_block (data, uvalue, end);
1301 case DW_OP_GNU_regval_type:
1302 uvalue = read_uleb128 (data, &bytes_read, end);
1304 printf ("DW_OP_GNU_regval_type: %s (%s)",
1305 dwarf_vmatoa ("u", uvalue), regname (uvalue, 1));
1306 uvalue = read_uleb128 (data, &bytes_read, end);
1308 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue));
1310 case DW_OP_GNU_deref_type:
1311 SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end);
1312 printf ("DW_OP_GNU_deref_type: %ld", (long) uvalue);
1313 uvalue = read_uleb128 (data, &bytes_read, end);
1315 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue));
1317 case DW_OP_GNU_convert:
1318 uvalue = read_uleb128 (data, &bytes_read, end);
1320 printf ("DW_OP_GNU_convert <0x%s>",
1321 dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0));
1323 case DW_OP_GNU_reinterpret:
1324 uvalue = read_uleb128 (data, &bytes_read, end);
1326 printf ("DW_OP_GNU_reinterpret <0x%s>",
1327 dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0));
1329 case DW_OP_GNU_parameter_ref:
1330 SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end);
1331 printf ("DW_OP_GNU_parameter_ref: <0x%s>",
1332 dwarf_vmatoa ("x", cu_offset + uvalue));
1334 case DW_OP_GNU_addr_index:
1335 uvalue = read_uleb128 (data, &bytes_read, end);
1337 printf ("DW_OP_GNU_addr_index <0x%s>", dwarf_vmatoa ("x", uvalue));
1339 case DW_OP_GNU_const_index:
1340 uvalue = read_uleb128 (data, &bytes_read, end);
1342 printf ("DW_OP_GNU_const_index <0x%s>", dwarf_vmatoa ("x", uvalue));
1345 /* HP extensions. */
1346 case DW_OP_HP_is_value:
1347 printf ("DW_OP_HP_is_value");
1348 /* FIXME: Is there data associated with this OP ? */
1350 case DW_OP_HP_fltconst4:
1351 printf ("DW_OP_HP_fltconst4");
1352 /* FIXME: Is there data associated with this OP ? */
1354 case DW_OP_HP_fltconst8:
1355 printf ("DW_OP_HP_fltconst8");
1356 /* FIXME: Is there data associated with this OP ? */
1358 case DW_OP_HP_mod_range:
1359 printf ("DW_OP_HP_mod_range");
1360 /* FIXME: Is there data associated with this OP ? */
1362 case DW_OP_HP_unmod_range:
1363 printf ("DW_OP_HP_unmod_range");
1364 /* FIXME: Is there data associated with this OP ? */
1367 printf ("DW_OP_HP_tls");
1368 /* FIXME: Is there data associated with this OP ? */
1371 /* PGI (STMicroelectronics) extensions. */
1372 case DW_OP_PGI_omp_thread_num:
1373 /* Pushes the thread number for the current thread as it would be
1374 returned by the standard OpenMP library function:
1375 omp_get_thread_num(). The "current thread" is the thread for
1376 which the expression is being evaluated. */
1377 printf ("DW_OP_PGI_omp_thread_num");
1381 if (op >= DW_OP_lo_user
1382 && op <= DW_OP_hi_user)
1383 printf (_("(User defined location op)"));
1385 printf (_("(Unknown location op)"));
1386 /* No way to tell where the next op is, so just bail. */
1387 return need_frame_base;
1390 /* Separate the ops. */
1395 return need_frame_base;
1398 /* Find the CU or TU set corresponding to the given CU_OFFSET.
1399 This is used for DWARF package files. */
1401 static struct cu_tu_set *
1402 find_cu_tu_set_v2 (dwarf_vma cu_offset, int do_types)
1404 struct cu_tu_set *p;
1406 unsigned int dw_sect;
1412 dw_sect = DW_SECT_TYPES;
1418 dw_sect = DW_SECT_INFO;
1422 if (p->section_offsets [dw_sect] == cu_offset)
1430 /* Add INC to HIGH_BITS:LOW_BITS. */
1432 add64 (dwarf_vma * high_bits, dwarf_vma * low_bits, dwarf_vma inc)
1434 dwarf_vma tmp = * low_bits;
1438 /* FIXME: There is probably a better way of handling this:
1440 We need to cope with dwarf_vma being a 32-bit or 64-bit
1441 type. Plus regardless of its size LOW_BITS is meant to
1442 only hold 32-bits, so if there is overflow or wrap around
1443 we must propagate into HIGH_BITS. */
1444 if (tmp < * low_bits)
1448 else if (sizeof (tmp) > 8
1458 static unsigned char *
1459 read_and_display_attr_value (unsigned long attribute,
1461 unsigned char * data,
1462 unsigned char * end,
1463 dwarf_vma cu_offset,
1464 dwarf_vma pointer_size,
1465 dwarf_vma offset_size,
1467 debug_info * debug_info_p,
1469 struct dwarf_section * section,
1470 struct cu_tu_set * this_set)
1472 dwarf_vma uvalue = 0;
1473 unsigned char *block_start = NULL;
1474 unsigned char * orig_data = data;
1475 unsigned int bytes_read;
1477 if (data > end || (data == end && form != DW_FORM_flag_present))
1479 warn (_("Corrupt attribute\n"));
1488 case DW_FORM_ref_addr:
1489 if (dwarf_version == 2)
1490 SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end);
1491 else if (dwarf_version == 3 || dwarf_version == 4)
1492 SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end);
1494 error (_("Internal error: DWARF version is not 2, 3 or 4.\n"));
1499 SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end);
1503 case DW_FORM_sec_offset:
1504 case DW_FORM_GNU_ref_alt:
1505 case DW_FORM_GNU_strp_alt:
1506 SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end);
1509 case DW_FORM_flag_present:
1516 SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end);
1521 SAFE_BYTE_GET_AND_INC (uvalue, data, 2, end);
1526 SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end);
1530 uvalue = read_sleb128 (data, & bytes_read, end);
1534 case DW_FORM_GNU_str_index:
1535 uvalue = read_uleb128 (data, & bytes_read, end);
1539 case DW_FORM_ref_udata:
1541 uvalue = read_uleb128 (data, & bytes_read, end);
1545 case DW_FORM_indirect:
1546 form = read_uleb128 (data, & bytes_read, end);
1549 printf (" %s", get_FORM_name (form));
1550 return read_and_display_attr_value (attribute, form, data, end,
1551 cu_offset, pointer_size,
1552 offset_size, dwarf_version,
1553 debug_info_p, do_loc,
1555 case DW_FORM_GNU_addr_index:
1556 uvalue = read_uleb128 (data, & bytes_read, end);
1563 case DW_FORM_ref_addr:
1565 printf (" <0x%s>", dwarf_vmatoa ("x",uvalue));
1568 case DW_FORM_GNU_ref_alt:
1570 printf (" <alt 0x%s>", dwarf_vmatoa ("x",uvalue));
1576 case DW_FORM_ref_udata:
1578 printf (" <0x%s>", dwarf_vmatoa ("x", uvalue + cu_offset));
1583 case DW_FORM_sec_offset:
1585 printf (" 0x%s", dwarf_vmatoa ("x", uvalue));
1588 case DW_FORM_flag_present:
1595 printf (" %s", dwarf_vmatoa ("d", uvalue));
1602 dwarf_vma high_bits;
1606 SAFE_BYTE_GET64 (data, &high_bits, &uvalue, end);
1608 if (form == DW_FORM_ref8)
1609 add64 (& high_bits, & utmp, cu_offset);
1611 dwarf_vmatoa64 (high_bits, utmp, buf, sizeof (buf)));
1614 if ((do_loc || do_debug_loc || do_debug_ranges)
1615 && num_debug_info_entries == 0)
1617 if (sizeof (uvalue) == 8)
1618 SAFE_BYTE_GET (uvalue, data, 8, end);
1620 error (_("DW_FORM_data8 is unsupported when sizeof (dwarf_vma) != 8\n"));
1626 case DW_FORM_string:
1628 printf (" %.*s", (int) (end - data), data);
1629 data += strnlen ((char *) data, end - data) + 1;
1633 case DW_FORM_exprloc:
1634 uvalue = read_uleb128 (data, & bytes_read, end);
1635 block_start = data + bytes_read;
1636 /* PR 17512: file: 008-103549-0.001:0.1. */
1637 if (block_start + uvalue > end)
1639 warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue);
1640 uvalue = end - block_start;
1643 data = block_start + uvalue;
1645 data = display_block (block_start, uvalue, end);
1648 case DW_FORM_block1:
1649 SAFE_BYTE_GET (uvalue, data, 1, end);
1650 block_start = data + 1;
1651 if (block_start + uvalue > end)
1653 warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue);
1654 uvalue = end - block_start;
1657 data = block_start + uvalue;
1659 data = display_block (block_start, uvalue, end);
1662 case DW_FORM_block2:
1663 SAFE_BYTE_GET (uvalue, data, 2, end);
1664 block_start = data + 2;
1665 if (block_start + uvalue > end)
1667 warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue);
1668 uvalue = end - block_start;
1671 data = block_start + uvalue;
1673 data = display_block (block_start, uvalue, end);
1676 case DW_FORM_block4:
1677 SAFE_BYTE_GET (uvalue, data, 4, end);
1678 block_start = data + 4;
1679 if (block_start + uvalue > end)
1681 warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue);
1682 uvalue = end - block_start;
1685 data = block_start + uvalue;
1687 data = display_block (block_start, uvalue, end);
1692 printf (_(" (indirect string, offset: 0x%s): %s"),
1693 dwarf_vmatoa ("x", uvalue),
1694 fetch_indirect_string (uvalue));
1697 case DW_FORM_GNU_str_index:
1700 const char *suffix = strrchr (section->name, '.');
1701 int dwo = (suffix && strcmp (suffix, ".dwo") == 0) ? 1 : 0;
1703 printf (_(" (indexed string: 0x%s): %s"),
1704 dwarf_vmatoa ("x", uvalue),
1705 fetch_indexed_string (uvalue, this_set, offset_size, dwo));
1709 case DW_FORM_GNU_strp_alt:
1711 printf (_(" (alt indirect string, offset: 0x%s)"),
1712 dwarf_vmatoa ("x", uvalue));
1715 case DW_FORM_indirect:
1716 /* Handled above. */
1719 case DW_FORM_ref_sig8:
1722 dwarf_vma high_bits;
1725 SAFE_BYTE_GET64 (data, &high_bits, &uvalue, end);
1726 printf (" signature: 0x%s",
1727 dwarf_vmatoa64 (high_bits, uvalue, buf, sizeof (buf)));
1732 case DW_FORM_GNU_addr_index:
1734 printf (_(" (addr_index: 0x%s): %s"),
1735 dwarf_vmatoa ("x", uvalue),
1736 fetch_indexed_value (uvalue * pointer_size, pointer_size));
1740 warn (_("Unrecognized form: %lu\n"), form);
1744 if ((do_loc || do_debug_loc || do_debug_ranges)
1745 && num_debug_info_entries == 0
1746 && debug_info_p != NULL)
1750 case DW_AT_frame_base:
1751 have_frame_base = 1;
1752 case DW_AT_location:
1753 case DW_AT_string_length:
1754 case DW_AT_return_addr:
1755 case DW_AT_data_member_location:
1756 case DW_AT_vtable_elem_location:
1758 case DW_AT_static_link:
1759 case DW_AT_use_location:
1760 case DW_AT_GNU_call_site_value:
1761 case DW_AT_GNU_call_site_data_value:
1762 case DW_AT_GNU_call_site_target:
1763 case DW_AT_GNU_call_site_target_clobbered:
1764 if ((dwarf_version < 4
1765 && (form == DW_FORM_data4 || form == DW_FORM_data8))
1766 || form == DW_FORM_sec_offset)
1768 /* Process location list. */
1769 unsigned int lmax = debug_info_p->max_loc_offsets;
1770 unsigned int num = debug_info_p->num_loc_offsets;
1772 if (lmax == 0 || num >= lmax)
1775 debug_info_p->loc_offsets = (dwarf_vma *)
1776 xcrealloc (debug_info_p->loc_offsets,
1777 lmax, sizeof (*debug_info_p->loc_offsets));
1778 debug_info_p->have_frame_base = (int *)
1779 xcrealloc (debug_info_p->have_frame_base,
1780 lmax, sizeof (*debug_info_p->have_frame_base));
1781 debug_info_p->max_loc_offsets = lmax;
1783 if (this_set != NULL)
1784 uvalue += this_set->section_offsets [DW_SECT_LOC];
1785 debug_info_p->loc_offsets [num] = uvalue;
1786 debug_info_p->have_frame_base [num] = have_frame_base;
1787 debug_info_p->num_loc_offsets++;
1792 if (need_base_address)
1793 debug_info_p->base_address = uvalue;
1796 case DW_AT_GNU_addr_base:
1797 debug_info_p->addr_base = uvalue;
1800 case DW_AT_GNU_ranges_base:
1801 debug_info_p->ranges_base = uvalue;
1805 if ((dwarf_version < 4
1806 && (form == DW_FORM_data4 || form == DW_FORM_data8))
1807 || form == DW_FORM_sec_offset)
1809 /* Process range list. */
1810 unsigned int lmax = debug_info_p->max_range_lists;
1811 unsigned int num = debug_info_p->num_range_lists;
1813 if (lmax == 0 || num >= lmax)
1816 debug_info_p->range_lists = (dwarf_vma *)
1817 xcrealloc (debug_info_p->range_lists,
1818 lmax, sizeof (*debug_info_p->range_lists));
1819 debug_info_p->max_range_lists = lmax;
1821 debug_info_p->range_lists [num] = uvalue;
1822 debug_info_p->num_range_lists++;
1831 if (do_loc || attribute == 0)
1834 /* For some attributes we can display further information. */
1841 case DW_INL_not_inlined:
1842 printf (_("(not inlined)"));
1844 case DW_INL_inlined:
1845 printf (_("(inlined)"));
1847 case DW_INL_declared_not_inlined:
1848 printf (_("(declared as inline but ignored)"));
1850 case DW_INL_declared_inlined:
1851 printf (_("(declared as inline and inlined)"));
1854 printf (_(" (Unknown inline attribute value: %s)"),
1855 dwarf_vmatoa ("x", uvalue));
1860 case DW_AT_language:
1864 /* Ordered by the numeric value of these constants. */
1865 case DW_LANG_C89: printf ("(ANSI C)"); break;
1866 case DW_LANG_C: printf ("(non-ANSI C)"); break;
1867 case DW_LANG_Ada83: printf ("(Ada)"); break;
1868 case DW_LANG_C_plus_plus: printf ("(C++)"); break;
1869 case DW_LANG_Cobol74: printf ("(Cobol 74)"); break;
1870 case DW_LANG_Cobol85: printf ("(Cobol 85)"); break;
1871 case DW_LANG_Fortran77: printf ("(FORTRAN 77)"); break;
1872 case DW_LANG_Fortran90: printf ("(Fortran 90)"); break;
1873 case DW_LANG_Pascal83: printf ("(ANSI Pascal)"); break;
1874 case DW_LANG_Modula2: printf ("(Modula 2)"); break;
1875 /* DWARF 2.1 values. */
1876 case DW_LANG_Java: printf ("(Java)"); break;
1877 case DW_LANG_C99: printf ("(ANSI C99)"); break;
1878 case DW_LANG_Ada95: printf ("(ADA 95)"); break;
1879 case DW_LANG_Fortran95: printf ("(Fortran 95)"); break;
1880 /* DWARF 3 values. */
1881 case DW_LANG_PLI: printf ("(PLI)"); break;
1882 case DW_LANG_ObjC: printf ("(Objective C)"); break;
1883 case DW_LANG_ObjC_plus_plus: printf ("(Objective C++)"); break;
1884 case DW_LANG_UPC: printf ("(Unified Parallel C)"); break;
1885 case DW_LANG_D: printf ("(D)"); break;
1886 /* DWARF 4 values. */
1887 case DW_LANG_Python: printf ("(Python)"); break;
1888 /* DWARF 5 values. */
1889 case DW_LANG_Go: printf ("(Go)"); break;
1890 /* MIPS extension. */
1891 case DW_LANG_Mips_Assembler: printf ("(MIPS assembler)"); break;
1892 /* UPC extension. */
1893 case DW_LANG_Upc: printf ("(Unified Parallel C)"); break;
1895 if (uvalue >= DW_LANG_lo_user && uvalue <= DW_LANG_hi_user)
1896 printf (_("(implementation defined: %s)"),
1897 dwarf_vmatoa ("x", uvalue));
1899 printf (_("(Unknown: %s)"), dwarf_vmatoa ("x", uvalue));
1904 case DW_AT_encoding:
1908 case DW_ATE_void: printf ("(void)"); break;
1909 case DW_ATE_address: printf ("(machine address)"); break;
1910 case DW_ATE_boolean: printf ("(boolean)"); break;
1911 case DW_ATE_complex_float: printf ("(complex float)"); break;
1912 case DW_ATE_float: printf ("(float)"); break;
1913 case DW_ATE_signed: printf ("(signed)"); break;
1914 case DW_ATE_signed_char: printf ("(signed char)"); break;
1915 case DW_ATE_unsigned: printf ("(unsigned)"); break;
1916 case DW_ATE_unsigned_char: printf ("(unsigned char)"); break;
1917 /* DWARF 2.1 values: */
1918 case DW_ATE_imaginary_float: printf ("(imaginary float)"); break;
1919 case DW_ATE_decimal_float: printf ("(decimal float)"); break;
1920 /* DWARF 3 values: */
1921 case DW_ATE_packed_decimal: printf ("(packed_decimal)"); break;
1922 case DW_ATE_numeric_string: printf ("(numeric_string)"); break;
1923 case DW_ATE_edited: printf ("(edited)"); break;
1924 case DW_ATE_signed_fixed: printf ("(signed_fixed)"); break;
1925 case DW_ATE_unsigned_fixed: printf ("(unsigned_fixed)"); break;
1926 /* HP extensions: */
1927 case DW_ATE_HP_float80: printf ("(HP_float80)"); break;
1928 case DW_ATE_HP_complex_float80: printf ("(HP_complex_float80)"); break;
1929 case DW_ATE_HP_float128: printf ("(HP_float128)"); break;
1930 case DW_ATE_HP_complex_float128:printf ("(HP_complex_float128)"); break;
1931 case DW_ATE_HP_floathpintel: printf ("(HP_floathpintel)"); break;
1932 case DW_ATE_HP_imaginary_float80: printf ("(HP_imaginary_float80)"); break;
1933 case DW_ATE_HP_imaginary_float128: printf ("(HP_imaginary_float128)"); break;
1936 if (uvalue >= DW_ATE_lo_user
1937 && uvalue <= DW_ATE_hi_user)
1938 printf (_("(user defined type)"));
1940 printf (_("(unknown type)"));
1945 case DW_AT_accessibility:
1949 case DW_ACCESS_public: printf ("(public)"); break;
1950 case DW_ACCESS_protected: printf ("(protected)"); break;
1951 case DW_ACCESS_private: printf ("(private)"); break;
1953 printf (_("(unknown accessibility)"));
1958 case DW_AT_visibility:
1962 case DW_VIS_local: printf ("(local)"); break;
1963 case DW_VIS_exported: printf ("(exported)"); break;
1964 case DW_VIS_qualified: printf ("(qualified)"); break;
1965 default: printf (_("(unknown visibility)")); break;
1969 case DW_AT_virtuality:
1973 case DW_VIRTUALITY_none: printf ("(none)"); break;
1974 case DW_VIRTUALITY_virtual: printf ("(virtual)"); break;
1975 case DW_VIRTUALITY_pure_virtual:printf ("(pure_virtual)"); break;
1976 default: printf (_("(unknown virtuality)")); break;
1980 case DW_AT_identifier_case:
1984 case DW_ID_case_sensitive: printf ("(case_sensitive)"); break;
1985 case DW_ID_up_case: printf ("(up_case)"); break;
1986 case DW_ID_down_case: printf ("(down_case)"); break;
1987 case DW_ID_case_insensitive: printf ("(case_insensitive)"); break;
1988 default: printf (_("(unknown case)")); break;
1992 case DW_AT_calling_convention:
1996 case DW_CC_normal: printf ("(normal)"); break;
1997 case DW_CC_program: printf ("(program)"); break;
1998 case DW_CC_nocall: printf ("(nocall)"); break;
2000 if (uvalue >= DW_CC_lo_user
2001 && uvalue <= DW_CC_hi_user)
2002 printf (_("(user defined)"));
2004 printf (_("(unknown convention)"));
2008 case DW_AT_ordering:
2012 case -1: printf (_("(undefined)")); break;
2013 case 0: printf ("(row major)"); break;
2014 case 1: printf ("(column major)"); break;
2018 case DW_AT_frame_base:
2019 have_frame_base = 1;
2020 case DW_AT_location:
2021 case DW_AT_string_length:
2022 case DW_AT_return_addr:
2023 case DW_AT_data_member_location:
2024 case DW_AT_vtable_elem_location:
2026 case DW_AT_static_link:
2027 case DW_AT_use_location:
2028 case DW_AT_GNU_call_site_value:
2029 case DW_AT_GNU_call_site_data_value:
2030 case DW_AT_GNU_call_site_target:
2031 case DW_AT_GNU_call_site_target_clobbered:
2032 if ((dwarf_version < 4
2033 && (form == DW_FORM_data4 || form == DW_FORM_data8))
2034 || form == DW_FORM_sec_offset)
2035 printf (_(" (location list)"));
2037 case DW_AT_allocated:
2038 case DW_AT_associated:
2039 case DW_AT_data_location:
2041 case DW_AT_upper_bound:
2042 case DW_AT_lower_bound:
2045 int need_frame_base;
2048 need_frame_base = decode_location_expression (block_start,
2053 cu_offset, section);
2055 if (need_frame_base && !have_frame_base)
2056 printf (_(" [without DW_AT_frame_base]"));
2062 if (form == DW_FORM_ref_sig8
2063 || form == DW_FORM_GNU_ref_alt)
2066 if (form == DW_FORM_ref1
2067 || form == DW_FORM_ref2
2068 || form == DW_FORM_ref4
2069 || form == DW_FORM_ref_udata)
2070 uvalue += cu_offset;
2072 if (uvalue >= section->size)
2073 warn (_("Offset %s used as value for DW_AT_import attribute of DIE at offset %lx is too big.\n"),
2074 dwarf_vmatoa ("x", uvalue),
2075 (unsigned long) (orig_data - section->start));
2078 unsigned long abbrev_number;
2079 abbrev_entry * entry;
2081 abbrev_number = read_uleb128 (section->start + uvalue, NULL, end);
2083 printf (_("\t[Abbrev Number: %ld"), abbrev_number);
2084 /* Don't look up abbrev for DW_FORM_ref_addr, as it very often will
2085 use different abbrev table, and we don't track .debug_info chunks
2087 if (form != DW_FORM_ref_addr)
2089 for (entry = first_abbrev; entry != NULL; entry = entry->next)
2090 if (entry->entry == abbrev_number)
2093 printf (" (%s)", get_TAG_name (entry->tag));
2108 get_AT_name (unsigned long attribute)
2113 return "DW_AT value: 0";
2115 /* One value is shared by the MIPS and HP extensions: */
2116 if (attribute == DW_AT_MIPS_fde)
2117 return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable";
2119 name = get_DW_AT_name (attribute);
2123 static char buffer[100];
2125 snprintf (buffer, sizeof (buffer), _("Unknown AT value: %lx"),
2133 static unsigned char *
2134 read_and_display_attr (unsigned long attribute,
2136 unsigned char * data,
2137 unsigned char * end,
2138 dwarf_vma cu_offset,
2139 dwarf_vma pointer_size,
2140 dwarf_vma offset_size,
2142 debug_info * debug_info_p,
2144 struct dwarf_section * section,
2145 struct cu_tu_set * this_set)
2148 printf (" %-18s:", get_AT_name (attribute));
2149 data = read_and_display_attr_value (attribute, form, data, end,
2150 cu_offset, pointer_size, offset_size,
2151 dwarf_version, debug_info_p,
2152 do_loc, section, this_set);
2158 /* Process the contents of a .debug_info section. If do_loc is non-zero
2159 then we are scanning for location lists and we do not want to display
2160 anything to the user. If do_types is non-zero, we are processing
2161 a .debug_types section instead of a .debug_info section. */
2164 process_debug_info (struct dwarf_section *section,
2166 enum dwarf_section_display_enum abbrev_sec,
2170 unsigned char *start = section->start;
2171 unsigned char *end = start + section->size;
2172 unsigned char *section_begin;
2174 unsigned int num_units = 0;
2176 if ((do_loc || do_debug_loc || do_debug_ranges)
2177 && num_debug_info_entries == 0
2182 /* First scan the section to get the number of comp units. */
2183 for (section_begin = start, num_units = 0; section_begin < end;
2186 /* Read the first 4 bytes. For a 32-bit DWARF section, this
2187 will be the length. For a 64-bit DWARF section, it'll be
2188 the escape code 0xffffffff followed by an 8 byte length. */
2189 SAFE_BYTE_GET (length, section_begin, 4, end);
2191 if (length == 0xffffffff)
2193 SAFE_BYTE_GET (length, section_begin + 4, 8, end);
2194 section_begin += length + 12;
2196 else if (length >= 0xfffffff0 && length < 0xffffffff)
2198 warn (_("Reserved length value (0x%s) found in section %s\n"),
2199 dwarf_vmatoa ("x", length), section->name);
2203 section_begin += length + 4;
2205 /* Negative values are illegal, they may even cause infinite
2206 looping. This can happen if we can't accurately apply
2207 relocations to an object file. */
2208 if ((signed long) length <= 0)
2210 warn (_("Corrupt unit length (0x%s) found in section %s\n"),
2211 dwarf_vmatoa ("x", length), section->name);
2218 error (_("No comp units in %s section ?\n"), section->name);
2222 /* Then allocate an array to hold the information. */
2223 debug_information = (debug_info *) cmalloc (num_units,
2224 sizeof (* debug_information));
2225 if (debug_information == NULL)
2227 error (_("Not enough memory for a debug info array of %u entries\n"),
2235 if (dwarf_start_die == 0)
2236 printf (_("Contents of the %s section:\n\n"), section->name);
2238 load_debug_section (str, file);
2239 load_debug_section (str_dwo, file);
2240 load_debug_section (str_index, file);
2241 load_debug_section (str_index_dwo, file);
2242 load_debug_section (debug_addr, file);
2245 load_debug_section (abbrev_sec, file);
2246 if (debug_displays [abbrev_sec].section.start == NULL)
2248 warn (_("Unable to locate %s section!\n"),
2249 debug_displays [abbrev_sec].section.name);
2253 for (section_begin = start, unit = 0; start < end; unit++)
2255 DWARF2_Internal_CompUnit compunit;
2256 unsigned char *hdrptr;
2257 unsigned char *tags;
2258 int level, last_level, saved_level;
2259 dwarf_vma cu_offset;
2260 unsigned int offset_size;
2261 int initial_length_size;
2262 dwarf_vma signature_high = 0;
2263 dwarf_vma signature_low = 0;
2264 dwarf_vma type_offset = 0;
2265 struct cu_tu_set *this_set;
2266 dwarf_vma abbrev_base;
2271 SAFE_BYTE_GET_AND_INC (compunit.cu_length, hdrptr, 4, end);
2273 if (compunit.cu_length == 0xffffffff)
2275 SAFE_BYTE_GET_AND_INC (compunit.cu_length, hdrptr, 8, end);
2277 initial_length_size = 12;
2282 initial_length_size = 4;
2285 SAFE_BYTE_GET_AND_INC (compunit.cu_version, hdrptr, 2, end);
2287 cu_offset = start - section_begin;
2289 this_set = find_cu_tu_set_v2 (cu_offset, do_types);
2291 SAFE_BYTE_GET_AND_INC (compunit.cu_abbrev_offset, hdrptr, offset_size, end);
2293 if (this_set == NULL)
2296 abbrev_size = debug_displays [abbrev_sec].section.size;
2300 abbrev_base = this_set->section_offsets [DW_SECT_ABBREV];
2301 abbrev_size = this_set->section_sizes [DW_SECT_ABBREV];
2304 SAFE_BYTE_GET_AND_INC (compunit.cu_pointer_size, hdrptr, 1, end);
2305 /* PR 17512: file: 001-108546-0.001:0.1. */
2306 if (compunit.cu_pointer_size < 2 || compunit.cu_pointer_size > 8)
2308 warn (_("Invalid pointer size (%d) in compunit header, using %d instead\n"),
2309 compunit.cu_pointer_size, offset_size);
2310 compunit.cu_pointer_size = offset_size;
2315 SAFE_BYTE_GET64 (hdrptr, &signature_high, &signature_low, end);
2317 SAFE_BYTE_GET_AND_INC (type_offset, hdrptr, offset_size, end);
2320 if ((do_loc || do_debug_loc || do_debug_ranges)
2321 && num_debug_info_entries == 0
2324 debug_information [unit].cu_offset = cu_offset;
2325 debug_information [unit].pointer_size
2326 = compunit.cu_pointer_size;
2327 debug_information [unit].offset_size = offset_size;
2328 debug_information [unit].dwarf_version = compunit.cu_version;
2329 debug_information [unit].base_address = 0;
2330 debug_information [unit].addr_base = DEBUG_INFO_UNAVAILABLE;
2331 debug_information [unit].ranges_base = DEBUG_INFO_UNAVAILABLE;
2332 debug_information [unit].loc_offsets = NULL;
2333 debug_information [unit].have_frame_base = NULL;
2334 debug_information [unit].max_loc_offsets = 0;
2335 debug_information [unit].num_loc_offsets = 0;
2336 debug_information [unit].range_lists = NULL;
2337 debug_information [unit].max_range_lists= 0;
2338 debug_information [unit].num_range_lists = 0;
2341 if (!do_loc && dwarf_start_die == 0)
2343 printf (_(" Compilation Unit @ offset 0x%s:\n"),
2344 dwarf_vmatoa ("x", cu_offset));
2345 printf (_(" Length: 0x%s (%s)\n"),
2346 dwarf_vmatoa ("x", compunit.cu_length),
2347 offset_size == 8 ? "64-bit" : "32-bit");
2348 printf (_(" Version: %d\n"), compunit.cu_version);
2349 printf (_(" Abbrev Offset: 0x%s\n"),
2350 dwarf_vmatoa ("x", compunit.cu_abbrev_offset));
2351 printf (_(" Pointer Size: %d\n"), compunit.cu_pointer_size);
2356 printf (_(" Signature: 0x%s\n"),
2357 dwarf_vmatoa64 (signature_high, signature_low,
2358 buf, sizeof (buf)));
2359 printf (_(" Type Offset: 0x%s\n"),
2360 dwarf_vmatoa ("x", type_offset));
2362 if (this_set != NULL)
2364 dwarf_vma *offsets = this_set->section_offsets;
2365 size_t *sizes = this_set->section_sizes;
2367 printf (_(" Section contributions:\n"));
2368 printf (_(" .debug_abbrev.dwo: 0x%s 0x%s\n"),
2369 dwarf_vmatoa ("x", offsets [DW_SECT_ABBREV]),
2370 dwarf_vmatoa ("x", sizes [DW_SECT_ABBREV]));
2371 printf (_(" .debug_line.dwo: 0x%s 0x%s\n"),
2372 dwarf_vmatoa ("x", offsets [DW_SECT_LINE]),
2373 dwarf_vmatoa ("x", sizes [DW_SECT_LINE]));
2374 printf (_(" .debug_loc.dwo: 0x%s 0x%s\n"),
2375 dwarf_vmatoa ("x", offsets [DW_SECT_LOC]),
2376 dwarf_vmatoa ("x", sizes [DW_SECT_LOC]));
2377 printf (_(" .debug_str_offsets.dwo: 0x%s 0x%s\n"),
2378 dwarf_vmatoa ("x", offsets [DW_SECT_STR_OFFSETS]),
2379 dwarf_vmatoa ("x", sizes [DW_SECT_STR_OFFSETS]));
2383 if (cu_offset + compunit.cu_length + initial_length_size
2386 warn (_("Debug info is corrupted, length of CU at %s"
2387 " extends beyond end of section (length = %s)\n"),
2388 dwarf_vmatoa ("x", cu_offset),
2389 dwarf_vmatoa ("x", compunit.cu_length));
2393 start += compunit.cu_length + initial_length_size;
2395 if (compunit.cu_version != 2
2396 && compunit.cu_version != 3
2397 && compunit.cu_version != 4)
2399 warn (_("CU at offset %s contains corrupt or "
2400 "unsupported version number: %d.\n"),
2401 dwarf_vmatoa ("x", cu_offset), compunit.cu_version);
2407 /* Process the abbrevs used by this compilation unit. */
2408 if (compunit.cu_abbrev_offset >= abbrev_size)
2409 warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"),
2410 (unsigned long) compunit.cu_abbrev_offset,
2411 (unsigned long) abbrev_size);
2413 process_abbrev_section
2414 (((unsigned char *) debug_displays [abbrev_sec].section.start
2415 + abbrev_base + compunit.cu_abbrev_offset),
2416 ((unsigned char *) debug_displays [abbrev_sec].section.start
2417 + abbrev_base + abbrev_size));
2422 while (tags < start)
2424 unsigned int bytes_read;
2425 unsigned long abbrev_number;
2426 unsigned long die_offset;
2427 abbrev_entry *entry;
2429 int do_printing = 1;
2431 die_offset = tags - section_begin;
2433 abbrev_number = read_uleb128 (tags, & bytes_read, start);
2436 /* A null DIE marks the end of a list of siblings or it may also be
2437 a section padding. */
2438 if (abbrev_number == 0)
2440 /* Check if it can be a section padding for the last CU. */
2441 if (level == 0 && start == end)
2445 for (chk = tags; chk < start; chk++)
2452 if (!do_loc && die_offset >= dwarf_start_die
2453 && (dwarf_cutoff_level == -1
2454 || level < dwarf_cutoff_level))
2455 printf (_(" <%d><%lx>: Abbrev Number: 0\n"),
2461 static unsigned num_bogus_warns = 0;
2463 if (num_bogus_warns < 3)
2465 warn (_("Bogus end-of-siblings marker detected at offset %lx in %s section\n"),
2466 die_offset, section->name);
2468 if (num_bogus_warns == 3)
2469 warn (_("Further warnings about bogus end-of-sibling markers suppressed\n"));
2472 if (dwarf_start_die != 0 && level < saved_level)
2479 if (dwarf_start_die != 0 && die_offset < dwarf_start_die)
2483 if (dwarf_start_die != 0 && die_offset == dwarf_start_die)
2484 saved_level = level;
2485 do_printing = (dwarf_cutoff_level == -1
2486 || level < dwarf_cutoff_level);
2488 printf (_(" <%d><%lx>: Abbrev Number: %lu"),
2489 level, die_offset, abbrev_number);
2490 else if (dwarf_cutoff_level == -1
2491 || last_level < dwarf_cutoff_level)
2492 printf (_(" <%d><%lx>: ...\n"), level, die_offset);
2497 /* Scan through the abbreviation list until we reach the
2499 for (entry = first_abbrev;
2500 entry && entry->entry != abbrev_number;
2501 entry = entry->next)
2506 if (!do_loc && do_printing)
2511 warn (_("DIE at offset %lx refers to abbreviation number %lu which does not exist\n"),
2512 die_offset, abbrev_number);
2516 if (!do_loc && do_printing)
2517 printf (" (%s)\n", get_TAG_name (entry->tag));
2522 need_base_address = 0;
2524 case DW_TAG_compile_unit:
2525 need_base_address = 1;
2527 case DW_TAG_entry_point:
2528 case DW_TAG_subprogram:
2529 need_base_address = 0;
2530 /* Assuming that there is no DW_AT_frame_base. */
2531 have_frame_base = 0;
2535 for (attr = entry->first_attr;
2536 attr && attr->attribute;
2541 if (! do_loc && do_printing)
2542 /* Show the offset from where the tag was extracted. */
2543 printf (" <%lx>", (unsigned long)(tags - section_begin));
2545 arg = debug_information;
2546 if (debug_information)
2549 tags = read_and_display_attr (attr->attribute,
2554 compunit.cu_pointer_size,
2556 compunit.cu_version,
2558 do_loc || ! do_printing,
2563 if (entry->children)
2568 /* Set num_debug_info_entries here so that it can be used to check if
2569 we need to process .debug_loc and .debug_ranges sections. */
2570 if ((do_loc || do_debug_loc || do_debug_ranges)
2571 && num_debug_info_entries == 0
2573 num_debug_info_entries = num_units;
2581 /* Locate and scan the .debug_info section in the file and record the pointer
2582 sizes and offsets for the compilation units in it. Usually an executable
2583 will have just one pointer size, but this is not guaranteed, and so we try
2584 not to make any assumptions. Returns zero upon failure, or the number of
2585 compilation units upon success. */
2588 load_debug_info (void * file)
2590 /* Reset the last pointer size so that we can issue correct error
2591 messages if we are displaying the contents of more than one section. */
2592 last_pointer_size = 0;
2593 warned_about_missing_comp_units = FALSE;
2595 /* If we have already tried and failed to load the .debug_info
2596 section then do not bother to repeat the task. */
2597 if (num_debug_info_entries == DEBUG_INFO_UNAVAILABLE)
2600 /* If we already have the information there is nothing else to do. */
2601 if (num_debug_info_entries > 0)
2602 return num_debug_info_entries;
2604 /* If this is a DWARF package file, load the CU and TU indexes. */
2605 load_cu_tu_indexes (file);
2607 if (load_debug_section (info, file)
2608 && process_debug_info (&debug_displays [info].section, file, abbrev, 1, 0))
2609 return num_debug_info_entries;
2610 else if (load_debug_section (info_dwo, file)
2611 && process_debug_info (&debug_displays [info_dwo].section, file,
2613 return num_debug_info_entries;
2615 num_debug_info_entries = DEBUG_INFO_UNAVAILABLE;
2619 /* Read a DWARF .debug_line section header starting at DATA.
2620 Upon success returns an updated DATA pointer and the LINFO
2621 structure and the END_OF_SEQUENCE pointer will be filled in.
2622 Otherwise returns NULL. */
2624 static unsigned char *
2625 read_debug_line_header (struct dwarf_section * section,
2626 unsigned char * data,
2627 unsigned char * end,
2628 DWARF2_Internal_LineInfo * linfo,
2629 unsigned char ** end_of_sequence)
2631 unsigned char *hdrptr;
2632 unsigned int offset_size;
2633 unsigned int initial_length_size;
2635 /* Extract information from the Line Number Program Header.
2636 (section 6.2.4 in the Dwarf3 doc). */
2639 /* Get and check the length of the block. */
2640 SAFE_BYTE_GET_AND_INC (linfo->li_length, hdrptr, 4, end);
2642 if (linfo->li_length == 0xffffffff)
2644 /* This section is 64-bit DWARF 3. */
2645 SAFE_BYTE_GET_AND_INC (linfo->li_length, hdrptr, 8, end);
2647 initial_length_size = 12;
2652 initial_length_size = 4;
2655 if (linfo->li_length + initial_length_size > section->size)
2657 /* If the length is just a bias against the initial_length_size then
2658 this means that the field has a relocation against it which has not
2659 been applied. (Ie we are dealing with an object file, not a linked
2660 binary). Do not complain but instead assume that the rest of the
2661 section applies to this particular header. */
2662 if (linfo->li_length == - initial_length_size)
2664 linfo->li_length = section->size - initial_length_size;
2668 warn (_("The line info appears to be corrupt - the section is too small\n"));
2673 /* Get and check the version number. */
2674 SAFE_BYTE_GET_AND_INC (linfo->li_version, hdrptr, 2, end);
2676 if (linfo->li_version != 2
2677 && linfo->li_version != 3
2678 && linfo->li_version != 4)
2680 warn (_("Only DWARF version 2, 3 and 4 line info is currently supported.\n"));
2684 SAFE_BYTE_GET_AND_INC (linfo->li_prologue_length, hdrptr, offset_size, end);
2685 SAFE_BYTE_GET_AND_INC (linfo->li_min_insn_length, hdrptr, 1, end);
2687 if (linfo->li_version >= 4)
2689 SAFE_BYTE_GET_AND_INC (linfo->li_max_ops_per_insn, hdrptr, 1, end);
2691 if (linfo->li_max_ops_per_insn == 0)
2693 warn (_("Invalid maximum operations per insn.\n"));
2698 linfo->li_max_ops_per_insn = 1;
2700 SAFE_BYTE_GET_AND_INC (linfo->li_default_is_stmt, hdrptr, 1, end);
2701 SAFE_SIGNED_BYTE_GET_AND_INC (linfo->li_line_base, hdrptr, 1, end);
2702 SAFE_BYTE_GET_AND_INC (linfo->li_line_range, hdrptr, 1, end);
2703 SAFE_BYTE_GET_AND_INC (linfo->li_opcode_base, hdrptr, 1, end);
2705 * end_of_sequence = data + linfo->li_length + initial_length_size;
2710 display_debug_lines_raw (struct dwarf_section *section,
2711 unsigned char *data,
2714 unsigned char *start = section->start;
2716 printf (_("Raw dump of debug contents of section %s:\n\n"),
2721 static DWARF2_Internal_LineInfo saved_linfo;
2722 DWARF2_Internal_LineInfo linfo;
2723 unsigned char *standard_opcodes;
2724 unsigned char *end_of_sequence;
2725 unsigned int last_dir_entry = 0;
2728 if (const_strneq (section->name, ".debug_line.")
2729 /* Note: the following does not apply to .debug_line.dwo sections.
2730 These are full debug_line sections. */
2731 && strcmp (section->name, ".debug_line.dwo") != 0)
2733 /* Sections named .debug_line.<foo> are fragments of a .debug_line
2734 section containing just the Line Number Statements. They are
2735 created by the assembler and intended to be used alongside gcc's
2736 -ffunction-sections command line option. When the linker's
2737 garbage collection decides to discard a .text.<foo> section it
2738 can then also discard the line number information in .debug_line.<foo>.
2740 Since the section is a fragment it does not have the details
2741 needed to fill out a LineInfo structure, so instead we use the
2742 details from the last full debug_line section that we processed. */
2743 end_of_sequence = end;
2744 standard_opcodes = NULL;
2745 linfo = saved_linfo;
2746 reset_state_machine (linfo.li_default_is_stmt);
2750 unsigned char * hdrptr;
2752 if ((hdrptr = read_debug_line_header (section, data, end, & linfo,
2753 & end_of_sequence)) == NULL)
2756 printf (_(" Offset: 0x%lx\n"), (long)(data - start));
2757 printf (_(" Length: %ld\n"), (long) linfo.li_length);
2758 printf (_(" DWARF Version: %d\n"), linfo.li_version);
2759 printf (_(" Prologue Length: %d\n"), linfo.li_prologue_length);
2760 printf (_(" Minimum Instruction Length: %d\n"), linfo.li_min_insn_length);
2761 if (linfo.li_version >= 4)
2762 printf (_(" Maximum Ops per Instruction: %d\n"), linfo.li_max_ops_per_insn);
2763 printf (_(" Initial value of 'is_stmt': %d\n"), linfo.li_default_is_stmt);
2764 printf (_(" Line Base: %d\n"), linfo.li_line_base);
2765 printf (_(" Line Range: %d\n"), linfo.li_line_range);
2766 printf (_(" Opcode Base: %d\n"), linfo.li_opcode_base);
2768 reset_state_machine (linfo.li_default_is_stmt);
2770 /* Display the contents of the Opcodes table. */
2771 standard_opcodes = hdrptr;
2773 printf (_("\n Opcodes:\n"));
2775 for (i = 1; i < linfo.li_opcode_base; i++)
2776 printf (_(" Opcode %d has %d args\n"), i, standard_opcodes[i - 1]);
2778 /* Display the contents of the Directory table. */
2779 data = standard_opcodes + linfo.li_opcode_base - 1;
2782 printf (_("\n The Directory Table is empty.\n"));
2785 printf (_("\n The Directory Table (offset 0x%lx):\n"),
2786 (long)(data - start));
2790 printf (" %d\t%s\n", ++last_dir_entry, data);
2792 data += strnlen ((char *) data, end - data) + 1;
2796 /* Skip the NUL at the end of the table. */
2799 /* Display the contents of the File Name table. */
2801 printf (_("\n The File Name Table is empty.\n"));
2804 printf (_("\n The File Name Table (offset 0x%lx):\n"),
2805 (long)(data - start));
2806 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
2810 unsigned char *name;
2811 unsigned int bytes_read;
2813 printf (" %d\t", ++state_machine_regs.last_file_entry);
2815 data += strnlen ((char *) data, end - data) + 1;
2818 dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end)));
2821 dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end)));
2824 dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end)));
2826 printf ("%s\n", name);
2830 warn (_("Corrupt file name table entry\n"));
2836 /* Skip the NUL at the end of the table. */
2839 saved_linfo = linfo;
2842 /* Now display the statements. */
2843 if (data >= end_of_sequence)
2844 printf (_(" No Line Number Statements.\n"));
2847 printf (_(" Line Number Statements:\n"));
2849 while (data < end_of_sequence)
2851 unsigned char op_code;
2852 dwarf_signed_vma adv;
2854 unsigned int bytes_read;
2856 printf (" [0x%08lx]", (long)(data - start));
2860 if (op_code >= linfo.li_opcode_base)
2862 op_code -= linfo.li_opcode_base;
2863 uladv = (op_code / linfo.li_line_range);
2864 if (linfo.li_max_ops_per_insn == 1)
2866 uladv *= linfo.li_min_insn_length;
2867 state_machine_regs.address += uladv;
2868 printf (_(" Special opcode %d: "
2869 "advance Address by %s to 0x%s"),
2870 op_code, dwarf_vmatoa ("u", uladv),
2871 dwarf_vmatoa ("x", state_machine_regs.address));
2875 state_machine_regs.address
2876 += ((state_machine_regs.op_index + uladv)
2877 / linfo.li_max_ops_per_insn)
2878 * linfo.li_min_insn_length;
2879 state_machine_regs.op_index
2880 = (state_machine_regs.op_index + uladv)
2881 % linfo.li_max_ops_per_insn;
2882 printf (_(" Special opcode %d: "
2883 "advance Address by %s to 0x%s[%d]"),
2884 op_code, dwarf_vmatoa ("u", uladv),
2885 dwarf_vmatoa ("x", state_machine_regs.address),
2886 state_machine_regs.op_index);
2888 adv = (op_code % linfo.li_line_range) + linfo.li_line_base;
2889 state_machine_regs.line += adv;
2890 printf (_(" and Line by %s to %d\n"),
2891 dwarf_vmatoa ("d", adv), state_machine_regs.line);
2893 else switch (op_code)
2895 case DW_LNS_extended_op:
2896 data += process_extended_line_op (data, linfo.li_default_is_stmt, end);
2900 printf (_(" Copy\n"));
2903 case DW_LNS_advance_pc:
2904 uladv = read_uleb128 (data, & bytes_read, end);
2906 if (linfo.li_max_ops_per_insn == 1)
2908 uladv *= linfo.li_min_insn_length;
2909 state_machine_regs.address += uladv;
2910 printf (_(" Advance PC by %s to 0x%s\n"),
2911 dwarf_vmatoa ("u", uladv),
2912 dwarf_vmatoa ("x", state_machine_regs.address));
2916 state_machine_regs.address
2917 += ((state_machine_regs.op_index + uladv)
2918 / linfo.li_max_ops_per_insn)
2919 * linfo.li_min_insn_length;
2920 state_machine_regs.op_index
2921 = (state_machine_regs.op_index + uladv)
2922 % linfo.li_max_ops_per_insn;
2923 printf (_(" Advance PC by %s to 0x%s[%d]\n"),
2924 dwarf_vmatoa ("u", uladv),
2925 dwarf_vmatoa ("x", state_machine_regs.address),
2926 state_machine_regs.op_index);
2930 case DW_LNS_advance_line:
2931 adv = read_sleb128 (data, & bytes_read, end);
2933 state_machine_regs.line += adv;
2934 printf (_(" Advance Line by %s to %d\n"),
2935 dwarf_vmatoa ("d", adv),
2936 state_machine_regs.line);
2939 case DW_LNS_set_file:
2940 adv = read_uleb128 (data, & bytes_read, end);
2942 printf (_(" Set File Name to entry %s in the File Name Table\n"),
2943 dwarf_vmatoa ("d", adv));
2944 state_machine_regs.file = adv;
2947 case DW_LNS_set_column:
2948 uladv = read_uleb128 (data, & bytes_read, end);
2950 printf (_(" Set column to %s\n"),
2951 dwarf_vmatoa ("u", uladv));
2952 state_machine_regs.column = uladv;
2955 case DW_LNS_negate_stmt:
2956 adv = state_machine_regs.is_stmt;
2958 printf (_(" Set is_stmt to %s\n"), dwarf_vmatoa ("d", adv));
2959 state_machine_regs.is_stmt = adv;
2962 case DW_LNS_set_basic_block:
2963 printf (_(" Set basic block\n"));
2964 state_machine_regs.basic_block = 1;
2967 case DW_LNS_const_add_pc:
2968 uladv = ((255 - linfo.li_opcode_base) / linfo.li_line_range);
2969 if (linfo.li_max_ops_per_insn)
2971 uladv *= linfo.li_min_insn_length;
2972 state_machine_regs.address += uladv;
2973 printf (_(" Advance PC by constant %s to 0x%s\n"),
2974 dwarf_vmatoa ("u", uladv),
2975 dwarf_vmatoa ("x", state_machine_regs.address));
2979 state_machine_regs.address
2980 += ((state_machine_regs.op_index + uladv)
2981 / linfo.li_max_ops_per_insn)
2982 * linfo.li_min_insn_length;
2983 state_machine_regs.op_index
2984 = (state_machine_regs.op_index + uladv)
2985 % linfo.li_max_ops_per_insn;
2986 printf (_(" Advance PC by constant %s to 0x%s[%d]\n"),
2987 dwarf_vmatoa ("u", uladv),
2988 dwarf_vmatoa ("x", state_machine_regs.address),
2989 state_machine_regs.op_index);
2993 case DW_LNS_fixed_advance_pc:
2994 SAFE_BYTE_GET_AND_INC (uladv, data, 2, end);
2995 state_machine_regs.address += uladv;
2996 state_machine_regs.op_index = 0;
2997 printf (_(" Advance PC by fixed size amount %s to 0x%s\n"),
2998 dwarf_vmatoa ("u", uladv),
2999 dwarf_vmatoa ("x", state_machine_regs.address));
3002 case DW_LNS_set_prologue_end:
3003 printf (_(" Set prologue_end to true\n"));
3006 case DW_LNS_set_epilogue_begin:
3007 printf (_(" Set epilogue_begin to true\n"));
3010 case DW_LNS_set_isa:
3011 uladv = read_uleb128 (data, & bytes_read, end);
3013 printf (_(" Set ISA to %s\n"), dwarf_vmatoa ("u", uladv));
3017 printf (_(" Unknown opcode %d with operands: "), op_code);
3019 if (standard_opcodes != NULL)
3020 for (i = standard_opcodes[op_code - 1]; i > 0 ; --i)
3022 printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data,
3024 i == 1 ? "" : ", ");
3040 unsigned char *name;
3041 unsigned int directory_index;
3042 unsigned int modification_date;
3043 unsigned int length;
3046 /* Output a decoded representation of the .debug_line section. */
3049 display_debug_lines_decoded (struct dwarf_section *section,
3050 unsigned char *data,
3053 static DWARF2_Internal_LineInfo saved_linfo;
3055 printf (_("Decoded dump of debug contents of section %s:\n\n"),
3060 /* This loop amounts to one iteration per compilation unit. */
3061 DWARF2_Internal_LineInfo linfo;
3062 unsigned char *standard_opcodes;
3063 unsigned char *end_of_sequence;
3065 File_Entry *file_table = NULL;
3066 unsigned int n_files = 0;
3067 unsigned char **directory_table = NULL;
3068 unsigned int n_directories = 0;
3070 if (const_strneq (section->name, ".debug_line.")
3071 /* Note: the following does not apply to .debug_line.dwo sections.
3072 These are full debug_line sections. */
3073 && strcmp (section->name, ".debug_line.dwo") != 0)
3075 /* See comment in display_debug_lines_raw(). */
3076 end_of_sequence = end;
3077 standard_opcodes = NULL;
3078 linfo = saved_linfo;
3079 reset_state_machine (linfo.li_default_is_stmt);
3083 unsigned char *hdrptr;
3085 if ((hdrptr = read_debug_line_header (section, data, end, & linfo,
3086 & end_of_sequence)) == NULL)
3089 reset_state_machine (linfo.li_default_is_stmt);
3091 /* Save a pointer to the contents of the Opcodes table. */
3092 standard_opcodes = hdrptr;
3094 /* Traverse the Directory table just to count entries. */
3095 data = standard_opcodes + linfo.li_opcode_base - 1;
3098 unsigned char *ptr_directory_table = data;
3102 data += strnlen ((char *) data, end - data) + 1;
3106 /* Go through the directory table again to save the directories. */
3107 directory_table = (unsigned char **)
3108 xmalloc (n_directories * sizeof (unsigned char *));
3111 while (*ptr_directory_table != 0)
3113 directory_table[i] = ptr_directory_table;
3114 ptr_directory_table += strnlen ((char *) ptr_directory_table,
3115 ptr_directory_table - end) + 1;
3119 /* Skip the NUL at the end of the table. */
3122 /* Traverse the File Name table just to count the entries. */
3125 unsigned char *ptr_file_name_table = data;
3129 unsigned int bytes_read;
3131 /* Skip Name, directory index, last modification time and length
3133 data += strnlen ((char *) data, end - data) + 1;
3134 read_uleb128 (data, & bytes_read, end);
3136 read_uleb128 (data, & bytes_read, end);
3138 read_uleb128 (data, & bytes_read, end);
3144 /* Go through the file table again to save the strings. */
3145 file_table = (File_Entry *) xmalloc (n_files * sizeof (File_Entry));
3148 while (*ptr_file_name_table != 0)
3150 unsigned int bytes_read;
3152 file_table[i].name = ptr_file_name_table;
3153 ptr_file_name_table += strnlen ((char *) ptr_file_name_table,
3154 end - ptr_file_name_table) + 1;
3156 /* We are not interested in directory, time or size. */
3157 file_table[i].directory_index = read_uleb128 (ptr_file_name_table,
3159 ptr_file_name_table += bytes_read;
3160 file_table[i].modification_date = read_uleb128 (ptr_file_name_table,
3162 ptr_file_name_table += bytes_read;
3163 file_table[i].length = read_uleb128 (ptr_file_name_table, & bytes_read, end);
3164 ptr_file_name_table += bytes_read;
3169 /* Print the Compilation Unit's name and a header. */
3170 if (directory_table == NULL)
3172 printf (_("CU: %s:\n"), file_table[0].name);
3173 printf (_("File name Line number Starting address\n"));
3177 unsigned int ix = file_table[0].directory_index;
3178 const char *directory = ix ? (char *)directory_table[ix - 1] : ".";
3180 if (do_wide || strlen (directory) < 76)
3181 printf (_("CU: %s/%s:\n"), directory, file_table[0].name);
3183 printf ("%s:\n", file_table[0].name);
3185 printf (_("File name Line number Starting address\n"));
3189 /* Skip the NUL at the end of the table. */
3192 saved_linfo = linfo;
3195 /* This loop iterates through the Dwarf Line Number Program. */
3196 while (data < end_of_sequence)
3198 unsigned char op_code;
3200 unsigned long int uladv;
3201 unsigned int bytes_read;
3202 int is_special_opcode = 0;
3206 if (op_code >= linfo.li_opcode_base)
3208 op_code -= linfo.li_opcode_base;
3209 uladv = (op_code / linfo.li_line_range);
3210 if (linfo.li_max_ops_per_insn == 1)
3212 uladv *= linfo.li_min_insn_length;
3213 state_machine_regs.address += uladv;
3217 state_machine_regs.address
3218 += ((state_machine_regs.op_index + uladv)
3219 / linfo.li_max_ops_per_insn)
3220 * linfo.li_min_insn_length;
3221 state_machine_regs.op_index
3222 = (state_machine_regs.op_index + uladv)
3223 % linfo.li_max_ops_per_insn;
3226 adv = (op_code % linfo.li_line_range) + linfo.li_line_base;
3227 state_machine_regs.line += adv;
3228 is_special_opcode = 1;
3230 else switch (op_code)
3232 case DW_LNS_extended_op:
3234 unsigned int ext_op_code_len;
3235 unsigned char ext_op_code;
3236 unsigned char *op_code_data = data;
3238 ext_op_code_len = read_uleb128 (op_code_data, &bytes_read,
3240 op_code_data += bytes_read;
3242 if (ext_op_code_len == 0)
3244 warn (_("Badly formed extended line op encountered!\n"));
3247 ext_op_code_len += bytes_read;
3248 ext_op_code = *op_code_data++;
3250 switch (ext_op_code)
3252 case DW_LNE_end_sequence:
3253 reset_state_machine (linfo.li_default_is_stmt);
3255 case DW_LNE_set_address:
3256 SAFE_BYTE_GET_AND_INC (state_machine_regs.address,
3258 ext_op_code_len - bytes_read - 1,
3260 state_machine_regs.op_index = 0;
3262 case DW_LNE_define_file:
3264 file_table = (File_Entry *) xrealloc
3265 (file_table, (n_files + 1) * sizeof (File_Entry));
3267 ++state_machine_regs.last_file_entry;
3268 /* Source file name. */
3269 file_table[n_files].name = op_code_data;
3270 op_code_data += strlen ((char *) op_code_data) + 1;
3271 /* Directory index. */
3272 file_table[n_files].directory_index =
3273 read_uleb128 (op_code_data, & bytes_read,
3275 op_code_data += bytes_read;
3276 /* Last modification time. */
3277 file_table[n_files].modification_date =
3278 read_uleb128 (op_code_data, & bytes_read,
3280 op_code_data += bytes_read;
3282 file_table[n_files].length =
3283 read_uleb128 (op_code_data, & bytes_read,
3289 case DW_LNE_set_discriminator:
3290 case DW_LNE_HP_set_sequence:
3291 /* Simply ignored. */
3295 printf (_("UNKNOWN (%u): length %d\n"),
3296 ext_op_code, ext_op_code_len - bytes_read);
3299 data += ext_op_code_len;
3305 case DW_LNS_advance_pc:
3306 uladv = read_uleb128 (data, & bytes_read, end);
3308 if (linfo.li_max_ops_per_insn == 1)
3310 uladv *= linfo.li_min_insn_length;
3311 state_machine_regs.address += uladv;
3315 state_machine_regs.address
3316 += ((state_machine_regs.op_index + uladv)
3317 / linfo.li_max_ops_per_insn)
3318 * linfo.li_min_insn_length;
3319 state_machine_regs.op_index
3320 = (state_machine_regs.op_index + uladv)
3321 % linfo.li_max_ops_per_insn;
3325 case DW_LNS_advance_line:
3326 adv = read_sleb128 (data, & bytes_read, end);
3328 state_machine_regs.line += adv;
3331 case DW_LNS_set_file:
3332 adv = read_uleb128 (data, & bytes_read, end);
3334 state_machine_regs.file = adv;
3336 if (file_table == NULL)
3337 printf (_("\n [Use file table entry %d]\n"), state_machine_regs.file - 1);
3338 else if (file_table[state_machine_regs.file - 1].directory_index == 0)
3339 /* If directory index is 0, that means current directory. */
3340 printf ("\n./%s:[++]\n",
3341 file_table[state_machine_regs.file - 1].name);
3342 else if (directory_table == NULL)
3343 printf (_("\n [Use directory table entry %d]\n"),
3344 file_table[state_machine_regs.file - 1].directory_index - 1);
3346 /* The directory index starts counting at 1. */
3347 printf ("\n%s/%s:\n",
3348 directory_table[file_table[state_machine_regs.file - 1].directory_index - 1],
3349 file_table[state_machine_regs.file - 1].name);
3352 case DW_LNS_set_column:
3353 uladv = read_uleb128 (data, & bytes_read, end);
3355 state_machine_regs.column = uladv;
3358 case DW_LNS_negate_stmt:
3359 adv = state_machine_regs.is_stmt;
3361 state_machine_regs.is_stmt = adv;
3364 case DW_LNS_set_basic_block:
3365 state_machine_regs.basic_block = 1;
3368 case DW_LNS_const_add_pc:
3369 uladv = ((255 - linfo.li_opcode_base) / linfo.li_line_range);
3370 if (linfo.li_max_ops_per_insn == 1)
3372 uladv *= linfo.li_min_insn_length;
3373 state_machine_regs.address += uladv;
3377 state_machine_regs.address
3378 += ((state_machine_regs.op_index + uladv)
3379 / linfo.li_max_ops_per_insn)
3380 * linfo.li_min_insn_length;
3381 state_machine_regs.op_index
3382 = (state_machine_regs.op_index + uladv)
3383 % linfo.li_max_ops_per_insn;
3387 case DW_LNS_fixed_advance_pc:
3388 SAFE_BYTE_GET_AND_INC (uladv, data, 2, end);
3389 state_machine_regs.address += uladv;
3390 state_machine_regs.op_index = 0;
3393 case DW_LNS_set_prologue_end:
3396 case DW_LNS_set_epilogue_begin:
3399 case DW_LNS_set_isa:
3400 uladv = read_uleb128 (data, & bytes_read, end);
3402 printf (_(" Set ISA to %lu\n"), uladv);
3406 printf (_(" Unknown opcode %d with operands: "), op_code);
3408 if (standard_opcodes != NULL)
3409 for (i = standard_opcodes[op_code - 1]; i > 0 ; --i)
3411 printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data,
3413 i == 1 ? "" : ", ");
3420 /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row
3421 to the DWARF address/line matrix. */
3422 if ((is_special_opcode) || (op_code == DW_LNE_end_sequence)
3423 || (op_code == DW_LNS_copy))
3425 const unsigned int MAX_FILENAME_LENGTH = 35;
3427 char *newFileName = NULL;
3428 size_t fileNameLength;
3431 fileName = (char *) file_table[state_machine_regs.file - 1].name;
3433 fileName = "<unknown>";
3435 fileNameLength = strlen (fileName);
3437 if ((fileNameLength > MAX_FILENAME_LENGTH) && (!do_wide))
3439 newFileName = (char *) xmalloc (MAX_FILENAME_LENGTH + 1);
3440 /* Truncate file name */
3441 strncpy (newFileName,
3442 fileName + fileNameLength - MAX_FILENAME_LENGTH,
3443 MAX_FILENAME_LENGTH + 1);
3447 newFileName = (char *) xmalloc (fileNameLength + 1);
3448 strncpy (newFileName, fileName, fileNameLength + 1);
3451 if (!do_wide || (fileNameLength <= MAX_FILENAME_LENGTH))
3453 if (linfo.li_max_ops_per_insn == 1)
3454 printf ("%-35s %11d %#18" DWARF_VMA_FMT "x\n",
3455 newFileName, state_machine_regs.line,
3456 state_machine_regs.address);
3458 printf ("%-35s %11d %#18" DWARF_VMA_FMT "x[%d]\n",
3459 newFileName, state_machine_regs.line,
3460 state_machine_regs.address,
3461 state_machine_regs.op_index);
3465 if (linfo.li_max_ops_per_insn == 1)
3466 printf ("%s %11d %#18" DWARF_VMA_FMT "x\n",
3467 newFileName, state_machine_regs.line,
3468 state_machine_regs.address);
3470 printf ("%s %11d %#18" DWARF_VMA_FMT "x[%d]\n",
3471 newFileName, state_machine_regs.line,
3472 state_machine_regs.address,
3473 state_machine_regs.op_index);
3476 if (op_code == DW_LNE_end_sequence)
3490 if (directory_table)
3492 free (directory_table);
3493 directory_table = NULL;
3504 display_debug_lines (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED)
3506 unsigned char *data = section->start;
3507 unsigned char *end = data + section->size;
3509 int retValDecoded = 1;
3511 if (do_debug_lines == 0)
3512 do_debug_lines |= FLAG_DEBUG_LINES_RAW;
3514 if (do_debug_lines & FLAG_DEBUG_LINES_RAW)
3515 retValRaw = display_debug_lines_raw (section, data, end);
3517 if (do_debug_lines & FLAG_DEBUG_LINES_DECODED)
3518 retValDecoded = display_debug_lines_decoded (section, data, end);
3520 if (!retValRaw || !retValDecoded)
3527 find_debug_info_for_offset (unsigned long offset)
3531 if (num_debug_info_entries == DEBUG_INFO_UNAVAILABLE)
3534 for (i = 0; i < num_debug_info_entries; i++)
3535 if (debug_information[i].cu_offset == offset)
3536 return debug_information + i;
3542 get_gdb_index_symbol_kind_name (gdb_index_symbol_kind kind)
3544 /* See gdb/gdb-index.h. */
3545 static const char * const kinds[] =
3557 return _ (kinds[kind]);
3561 display_debug_pubnames_worker (struct dwarf_section *section,
3562 void *file ATTRIBUTE_UNUSED,
3565 DWARF2_Internal_PubNames names;
3566 unsigned char *start = section->start;
3567 unsigned char *end = start + section->size;
3569 /* It does not matter if this load fails,
3570 we test for that later on. */
3571 load_debug_info (file);
3573 printf (_("Contents of the %s section:\n\n"), section->name);
3577 unsigned char *data;
3578 unsigned long offset;
3579 unsigned int offset_size, initial_length_size;
3583 SAFE_BYTE_GET_AND_INC (names.pn_length, data, 4, end);
3584 if (names.pn_length == 0xffffffff)
3586 SAFE_BYTE_GET_AND_INC (names.pn_length, data, 8, end);
3588 initial_length_size = 12;
3593 initial_length_size = 4;
3596 SAFE_BYTE_GET_AND_INC (names.pn_version, data, 2, end);
3597 SAFE_BYTE_GET_AND_INC (names.pn_offset, data, offset_size, end);
3599 if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE
3600 && num_debug_info_entries > 0
3601 && find_debug_info_for_offset (names.pn_offset) == NULL)
3602 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
3603 (unsigned long) names.pn_offset, section->name);
3605 SAFE_BYTE_GET_AND_INC (names.pn_size, data, offset_size, end);
3607 start += names.pn_length + initial_length_size;
3609 if (names.pn_version != 2 && names.pn_version != 3)
3611 static int warned = 0;
3615 warn (_("Only DWARF 2 and 3 pubnames are currently supported\n"));
3622 printf (_(" Length: %ld\n"),
3623 (long) names.pn_length);
3624 printf (_(" Version: %d\n"),
3626 printf (_(" Offset into .debug_info section: 0x%lx\n"),
3627 (unsigned long) names.pn_offset);
3628 printf (_(" Size of area in .debug_info section: %ld\n"),
3629 (long) names.pn_size);
3632 printf (_("\n Offset Kind Name\n"));
3634 printf (_("\n Offset\tName\n"));
3638 bfd_size_type maxprint;
3640 SAFE_BYTE_GET (offset, data, offset_size, end);
3644 data += offset_size;
3647 maxprint = (end - data) - 1;
3651 unsigned int kind_data;
3652 gdb_index_symbol_kind kind;
3653 const char *kind_name;
3656 SAFE_BYTE_GET (kind_data, data, 1, end);
3659 /* GCC computes the kind as the upper byte in the CU index
3660 word, and then right shifts it by the CU index size.
3661 Left shift KIND to where the gdb-index.h accessor macros
3663 kind_data <<= GDB_INDEX_CU_BITSIZE;
3664 kind = GDB_INDEX_SYMBOL_KIND_VALUE (kind_data);
3665 kind_name = get_gdb_index_symbol_kind_name (kind);
3666 is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (kind_data);
3667 printf (" %-6lx %s,%-10s %.*s\n",
3668 offset, is_static ? _("s") : _("g"),
3669 kind_name, (int) maxprint, data);
3672 printf (" %-6lx\t%.*s\n", offset, (int) maxprint, data);
3674 data += strnlen ((char *) data, maxprint) + 1;
3679 while (offset != 0);
3687 display_debug_pubnames (struct dwarf_section *section, void *file)
3689 return display_debug_pubnames_worker (section, file, 0);
3693 display_debug_gnu_pubnames (struct dwarf_section *section, void *file)
3695 return display_debug_pubnames_worker (section, file, 1);
3699 display_debug_macinfo (struct dwarf_section *section,
3700 void *file ATTRIBUTE_UNUSED)
3702 unsigned char *start = section->start;
3703 unsigned char *end = start + section->size;
3704 unsigned char *curr = start;
3705 unsigned int bytes_read;
3706 enum dwarf_macinfo_record_type op;
3708 printf (_("Contents of the %s section:\n\n"), section->name);
3712 unsigned int lineno;
3713 const unsigned char *string;
3715 op = (enum dwarf_macinfo_record_type) *curr;
3720 case DW_MACINFO_start_file:
3722 unsigned int filenum;
3724 lineno = read_uleb128 (curr, & bytes_read, end);
3726 filenum = read_uleb128 (curr, & bytes_read, end);
3729 printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"),
3734 case DW_MACINFO_end_file:
3735 printf (_(" DW_MACINFO_end_file\n"));
3738 case DW_MACINFO_define:
3739 lineno = read_uleb128 (curr, & bytes_read, end);
3742 curr += strnlen ((char *) string, end - string) + 1;
3743 printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"),
3747 case DW_MACINFO_undef:
3748 lineno = read_uleb128 (curr, & bytes_read, end);
3751 curr += strnlen ((char *) string, end - string) + 1;
3752 printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"),
3756 case DW_MACINFO_vendor_ext:
3758 unsigned int constant;
3760 constant = read_uleb128 (curr, & bytes_read, end);
3763 curr += strnlen ((char *) string, end - string) + 1;
3764 printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"),
3774 /* Given LINE_OFFSET into the .debug_line section, attempt to return
3775 filename and dirname corresponding to file name table entry with index
3776 FILEIDX. Return NULL on failure. */
3778 static unsigned char *
3779 get_line_filename_and_dirname (dwarf_vma line_offset,
3781 unsigned char **dir_name)
3783 struct dwarf_section *section = &debug_displays [line].section;
3784 unsigned char *hdrptr, *dirtable, *file_name;
3785 unsigned int offset_size, initial_length_size;
3786 unsigned int version, opcode_base, bytes_read;
3787 dwarf_vma length, diridx;
3788 const unsigned char * end;
3791 if (section->start == NULL
3792 || line_offset >= section->size
3796 hdrptr = section->start + line_offset;
3797 end = section->start + section->size;
3799 SAFE_BYTE_GET_AND_INC (length, hdrptr, 4, end);
3800 if (length == 0xffffffff)
3802 /* This section is 64-bit DWARF 3. */
3803 SAFE_BYTE_GET_AND_INC (length, hdrptr, 8, end);
3805 initial_length_size = 12;
3810 initial_length_size = 4;
3812 if (length + initial_length_size > section->size)
3815 SAFE_BYTE_GET_AND_INC (version, hdrptr, 2, end);
3816 if (version != 2 && version != 3 && version != 4)
3818 hdrptr += offset_size + 1;/* Skip prologue_length and min_insn_length. */
3820 hdrptr++; /* Skip max_ops_per_insn. */
3821 hdrptr += 3; /* Skip default_is_stmt, line_base, line_range. */
3823 SAFE_BYTE_GET_AND_INC (opcode_base, hdrptr, 1, end);
3824 if (opcode_base == 0)
3827 hdrptr += opcode_base - 1;
3829 /* Skip over dirname table. */
3830 while (*hdrptr != '\0')
3831 hdrptr += strnlen ((char *) hdrptr, end - hdrptr) + 1;
3832 hdrptr++; /* Skip the NUL at the end of the table. */
3833 /* Now skip over preceding filename table entries. */
3834 for (; *hdrptr != '\0' && fileidx > 1; fileidx--)
3836 hdrptr += strnlen ((char *) hdrptr, end - hdrptr) + 1;
3837 read_uleb128 (hdrptr, &bytes_read, end);
3838 hdrptr += bytes_read;
3839 read_uleb128 (hdrptr, &bytes_read, end);
3840 hdrptr += bytes_read;
3841 read_uleb128 (hdrptr, &bytes_read, end);
3842 hdrptr += bytes_read;
3844 if (hdrptr == end || *hdrptr == '\0')
3847 hdrptr += strnlen ((char *) hdrptr, end - hdrptr) + 1;
3848 diridx = read_uleb128 (hdrptr, &bytes_read, end);
3851 for (; *dirtable != '\0' && diridx > 1; diridx--)
3852 dirtable += strnlen ((char *) dirtable, end - dirtable) + 1;
3853 if (*dirtable == '\0')
3855 *dir_name = dirtable;
3860 display_debug_macro (struct dwarf_section *section,
3863 unsigned char *start = section->start;
3864 unsigned char *end = start + section->size;
3865 unsigned char *curr = start;
3866 unsigned char *extended_op_buf[256];
3867 unsigned int bytes_read;
3869 load_debug_section (str, file);
3870 load_debug_section (line, file);
3872 printf (_("Contents of the %s section:\n\n"), section->name);
3876 unsigned int lineno, version, flags;
3877 unsigned int offset_size = 4;
3878 const unsigned char *string;
3879 dwarf_vma line_offset = 0, sec_offset = curr - start, offset;
3880 unsigned char **extended_ops = NULL;
3882 SAFE_BYTE_GET_AND_INC (version, curr, 2, end);
3885 error (_("Only GNU extension to DWARF 4 of %s is currently supported.\n"),
3890 SAFE_BYTE_GET_AND_INC (flags, curr, 1, end);
3893 printf (_(" Offset: 0x%lx\n"),
3894 (unsigned long) sec_offset);
3895 printf (_(" Version: %d\n"), version);
3896 printf (_(" Offset size: %d\n"), offset_size);
3899 SAFE_BYTE_GET_AND_INC (line_offset, curr, offset_size, end);
3900 printf (_(" Offset into .debug_line: 0x%lx\n"),
3901 (unsigned long) line_offset);
3905 unsigned int i, count, op;
3908 SAFE_BYTE_GET_AND_INC (count, curr, 1, end);
3910 memset (extended_op_buf, 0, sizeof (extended_op_buf));
3911 extended_ops = extended_op_buf;
3914 printf (_(" Extension opcode arguments:\n"));
3915 for (i = 0; i < count; i++)
3917 SAFE_BYTE_GET_AND_INC (op, curr, 1, end);
3918 extended_ops[op] = curr;
3919 nargs = read_uleb128 (curr, &bytes_read, end);
3922 printf (_(" DW_MACRO_GNU_%02x has no arguments\n"), op);
3925 printf (_(" DW_MACRO_GNU_%02x arguments: "), op);
3926 for (n = 0; n < nargs; n++)
3930 SAFE_BYTE_GET_AND_INC (form, curr, 1, end);
3931 printf ("%s%s", get_FORM_name (form),
3932 n == nargs - 1 ? "\n" : ", ");
3942 case DW_FORM_block1:
3943 case DW_FORM_block2:
3944 case DW_FORM_block4:
3946 case DW_FORM_string:
3948 case DW_FORM_sec_offset:
3951 error (_("Invalid extension opcode form %s\n"),
3952 get_FORM_name (form));
3968 error (_(".debug_macro section not zero terminated\n"));
3972 SAFE_BYTE_GET_AND_INC (op, curr, 1, end);
3978 case DW_MACRO_GNU_start_file:
3980 unsigned int filenum;
3981 unsigned char *file_name = NULL, *dir_name = NULL;
3983 lineno = read_uleb128 (curr, &bytes_read, end);
3985 filenum = read_uleb128 (curr, &bytes_read, end);
3988 if ((flags & 2) == 0)
3989 error (_("DW_MACRO_GNU_start_file used, but no .debug_line offset provided.\n"));
3992 = get_line_filename_and_dirname (line_offset, filenum,
3994 if (file_name == NULL)
3995 printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d\n"),
3998 printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d filename: %s%s%s\n"),
4000 dir_name != NULL ? (const char *) dir_name : "",
4001 dir_name != NULL ? "/" : "", file_name);
4005 case DW_MACRO_GNU_end_file:
4006 printf (_(" DW_MACRO_GNU_end_file\n"));
4009 case DW_MACRO_GNU_define:
4010 lineno = read_uleb128 (curr, &bytes_read, end);
4013 curr += strnlen ((char *) string, end - string) + 1;
4014 printf (_(" DW_MACRO_GNU_define - lineno : %d macro : %s\n"),
4018 case DW_MACRO_GNU_undef:
4019 lineno = read_uleb128 (curr, &bytes_read, end);
4022 curr += strnlen ((char *) string, end - string) + 1;
4023 printf (_(" DW_MACRO_GNU_undef - lineno : %d macro : %s\n"),
4027 case DW_MACRO_GNU_define_indirect:
4028 lineno = read_uleb128 (curr, &bytes_read, end);
4030 SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end);
4031 string = fetch_indirect_string (offset);
4032 printf (_(" DW_MACRO_GNU_define_indirect - lineno : %d macro : %s\n"),
4036 case DW_MACRO_GNU_undef_indirect:
4037 lineno = read_uleb128 (curr, &bytes_read, end);
4039 SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end);
4040 string = fetch_indirect_string (offset);
4041 printf (_(" DW_MACRO_GNU_undef_indirect - lineno : %d macro : %s\n"),
4045 case DW_MACRO_GNU_transparent_include:
4046 SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end);
4047 printf (_(" DW_MACRO_GNU_transparent_include - offset : 0x%lx\n"),
4048 (unsigned long) offset);
4051 case DW_MACRO_GNU_define_indirect_alt:
4052 lineno = read_uleb128 (curr, &bytes_read, end);
4054 SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end);
4055 printf (_(" DW_MACRO_GNU_define_indirect_alt - lineno : %d macro offset : 0x%lx\n"),
4056 lineno, (unsigned long) offset);
4059 case DW_MACRO_GNU_undef_indirect_alt:
4060 lineno = read_uleb128 (curr, &bytes_read, end);
4062 SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end);
4063 printf (_(" DW_MACRO_GNU_undef_indirect_alt - lineno : %d macro offset : 0x%lx\n"),
4064 lineno, (unsigned long) offset);
4067 case DW_MACRO_GNU_transparent_include_alt:
4068 SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end);
4069 printf (_(" DW_MACRO_GNU_transparent_include_alt - offset : 0x%lx\n"),
4070 (unsigned long) offset);
4074 if (extended_ops == NULL || extended_ops[op] == NULL)
4076 error (_(" Unknown macro opcode %02x seen\n"), op);
4081 /* Skip over unhandled opcodes. */
4083 unsigned char *desc = extended_ops[op];
4084 nargs = read_uleb128 (desc, &bytes_read, end);
4088 printf (_(" DW_MACRO_GNU_%02x\n"), op);
4091 printf (_(" DW_MACRO_GNU_%02x -"), op);
4092 for (n = 0; n < nargs; n++)
4096 SAFE_BYTE_GET_AND_INC (val, desc, 1, end);
4098 = read_and_display_attr_value (0, val,
4099 curr, end, 0, 0, offset_size,
4100 version, NULL, 0, NULL,
4118 display_debug_abbrev (struct dwarf_section *section,
4119 void *file ATTRIBUTE_UNUSED)
4121 abbrev_entry *entry;
4122 unsigned char *start = section->start;
4123 unsigned char *end = start + section->size;
4125 printf (_("Contents of the %s section:\n\n"), section->name);
4129 unsigned char *last;
4134 start = process_abbrev_section (start, end);
4136 if (first_abbrev == NULL)
4139 printf (_(" Number TAG (0x%lx)\n"), (long) (last - section->start));
4141 for (entry = first_abbrev; entry; entry = entry->next)
4145 printf (" %ld %s [%s]\n",
4147 get_TAG_name (entry->tag),
4148 entry->children ? _("has children") : _("no children"));
4150 for (attr = entry->first_attr; attr; attr = attr->next)
4151 printf (" %-18s %s\n",
4152 get_AT_name (attr->attribute),
4153 get_FORM_name (attr->form));
4163 /* Display a location list from a normal (ie, non-dwo) .debug_loc section. */
4166 display_loc_list (struct dwarf_section *section,
4167 unsigned char **start_ptr,
4168 int debug_info_entry,
4169 unsigned long offset,
4170 unsigned long base_address,
4173 unsigned char *start = *start_ptr;
4174 unsigned char *section_end = section->start + section->size;
4175 unsigned long cu_offset = debug_information [debug_info_entry].cu_offset;
4176 unsigned int pointer_size = debug_information [debug_info_entry].pointer_size;
4177 unsigned int offset_size = debug_information [debug_info_entry].offset_size;
4178 int dwarf_version = debug_information [debug_info_entry].dwarf_version;
4182 unsigned short length;
4183 int need_frame_base;
4185 if (pointer_size < 2 || pointer_size > 8)
4187 warn (_("Invalid pointer size (%d) in debug info for entry %d\n"),
4188 pointer_size, debug_info_entry);
4194 if (start + 2 * pointer_size > section_end)
4196 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4201 printf (" %8.8lx ", offset + (start - *start_ptr));
4203 /* Note: we use sign extension here in order to be sure that we can detect
4204 the -1 escape value. Sign extension into the top 32 bits of a 32-bit
4205 address will not affect the values that we display since we always show
4206 hex values, and always the bottom 32-bits. */
4207 SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, section_end);
4208 SAFE_BYTE_GET_AND_INC (end, start, pointer_size, section_end);
4210 if (begin == 0 && end == 0)
4212 printf (_("<End of list>\n"));
4216 /* Check base address specifiers. */
4217 if (begin == (dwarf_vma) -1 && end != (dwarf_vma) -1)
4220 print_dwarf_vma (begin, pointer_size);
4221 print_dwarf_vma (end, pointer_size);
4222 printf (_("(base address)\n"));
4226 if (start + 2 > section_end)
4228 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4233 SAFE_BYTE_GET_AND_INC (length, start, 2, section_end);
4235 if (start + length > section_end)
4237 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4242 print_dwarf_vma (begin + base_address, pointer_size);
4243 print_dwarf_vma (end + base_address, pointer_size);
4246 need_frame_base = decode_location_expression (start,
4251 cu_offset, section);
4254 if (need_frame_base && !has_frame_base)
4255 printf (_(" [without DW_AT_frame_base]"));
4258 fputs (_(" (start == end)"), stdout);
4259 else if (begin > end)
4260 fputs (_(" (start > end)"), stdout);
4270 /* Print a .debug_addr table index in decimal, surrounded by square brackets,
4271 right-adjusted in a field of length LEN, and followed by a space. */
4274 print_addr_index (unsigned int idx, unsigned int len)
4276 static char buf[15];
4277 snprintf (buf, sizeof (buf), "[%d]", idx);
4278 printf ("%*s ", len, buf);
4281 /* Display a location list from a .dwo section. It uses address indexes rather
4282 than embedded addresses. This code closely follows display_loc_list, but the
4283 two are sufficiently different that combining things is very ugly. */
4286 display_loc_list_dwo (struct dwarf_section *section,
4287 unsigned char **start_ptr,
4288 int debug_info_entry,
4289 unsigned long offset,
4292 unsigned char *start = *start_ptr;
4293 unsigned char *section_end = section->start + section->size;
4294 unsigned long cu_offset = debug_information [debug_info_entry].cu_offset;
4295 unsigned int pointer_size = debug_information [debug_info_entry].pointer_size;
4296 unsigned int offset_size = debug_information [debug_info_entry].offset_size;
4297 int dwarf_version = debug_information [debug_info_entry].dwarf_version;
4299 unsigned short length;
4300 int need_frame_base;
4302 unsigned int bytes_read;
4304 if (pointer_size < 2 || pointer_size > 8)
4306 warn (_("Invalid pointer size (%d) in debug info for entry %d\n"),
4307 pointer_size, debug_info_entry);
4313 printf (" %8.8lx ", offset + (start - *start_ptr));
4315 if (start >= section_end)
4317 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4322 SAFE_BYTE_GET_AND_INC (entry_type, start, 1, section_end);
4325 case 0: /* A terminating entry. */
4327 printf (_("<End of list>\n"));
4329 case 1: /* A base-address entry. */
4330 idx = read_uleb128 (start, &bytes_read, section_end);
4331 start += bytes_read;
4332 print_addr_index (idx, 8);
4334 printf (_("(base address selection entry)\n"));
4336 case 2: /* A start/end entry. */
4337 idx = read_uleb128 (start, &bytes_read, section_end);
4338 start += bytes_read;
4339 print_addr_index (idx, 8);
4340 idx = read_uleb128 (start, &bytes_read, section_end);
4341 start += bytes_read;
4342 print_addr_index (idx, 8);
4344 case 3: /* A start/length entry. */
4345 idx = read_uleb128 (start, &bytes_read, section_end);
4346 start += bytes_read;
4347 print_addr_index (idx, 8);
4348 SAFE_BYTE_GET_AND_INC (idx, start, 4, section_end);
4349 printf ("%08x ", idx);
4351 case 4: /* An offset pair entry. */
4352 SAFE_BYTE_GET_AND_INC (idx, start, 4, section_end);
4353 printf ("%08x ", idx);
4354 SAFE_BYTE_GET_AND_INC (idx, start, 4, section_end);
4355 printf ("%08x ", idx);
4358 warn (_("Unknown location list entry type 0x%x.\n"), entry_type);
4363 if (start + 2 > section_end)
4365 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4370 SAFE_BYTE_GET_AND_INC (length, start, 2, section_end);
4371 if (start + length > section_end)
4373 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4379 need_frame_base = decode_location_expression (start,
4384 cu_offset, section);
4387 if (need_frame_base && !has_frame_base)
4388 printf (_(" [without DW_AT_frame_base]"));
4398 /* Sort array of indexes in ascending order of loc_offsets[idx]. */
4400 static dwarf_vma *loc_offsets;
4403 loc_offsets_compar (const void *ap, const void *bp)
4405 dwarf_vma a = loc_offsets[*(const unsigned int *) ap];
4406 dwarf_vma b = loc_offsets[*(const unsigned int *) bp];
4408 return (a > b) - (b > a);
4412 display_debug_loc (struct dwarf_section *section, void *file)
4414 unsigned char *start = section->start;
4415 unsigned long bytes;
4416 unsigned char *section_begin = start;
4417 unsigned int num_loc_list = 0;
4418 unsigned long last_offset = 0;
4419 unsigned int first = 0;
4423 int seen_first_offset = 0;
4424 int locs_sorted = 1;
4425 unsigned char *next;
4426 unsigned int *array = NULL;
4427 const char *suffix = strrchr (section->name, '.');
4430 if (suffix && strcmp (suffix, ".dwo") == 0)
4433 bytes = section->size;
4437 printf (_("\nThe %s section is empty.\n"), section->name);
4441 if (load_debug_info (file) == 0)
4443 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4448 /* Check the order of location list in .debug_info section. If
4449 offsets of location lists are in the ascending order, we can
4450 use `debug_information' directly. */
4451 for (i = 0; i < num_debug_info_entries; i++)
4455 num = debug_information [i].num_loc_offsets;
4456 if (num > num_loc_list)
4459 /* Check if we can use `debug_information' directly. */
4460 if (locs_sorted && num != 0)
4462 if (!seen_first_offset)
4464 /* This is the first location list. */
4465 last_offset = debug_information [i].loc_offsets [0];
4467 seen_first_offset = 1;
4473 for (; j < num; j++)
4476 debug_information [i].loc_offsets [j])
4481 last_offset = debug_information [i].loc_offsets [j];
4486 if (!seen_first_offset)
4487 error (_("No location lists in .debug_info section!\n"));
4489 if (debug_information [first].num_loc_offsets > 0
4490 && debug_information [first].loc_offsets [0] != 0)
4491 warn (_("Location lists in %s section start at 0x%s\n"),
4493 dwarf_vmatoa ("x", debug_information [first].loc_offsets [0]));
4496 array = (unsigned int *) xcmalloc (num_loc_list, sizeof (unsigned int));
4497 printf (_("Contents of the %s section:\n\n"), section->name);
4498 printf (_(" Offset Begin End Expression\n"));
4500 seen_first_offset = 0;
4501 for (i = first; i < num_debug_info_entries; i++)
4503 unsigned long offset;
4504 unsigned long base_address;
4509 for (k = 0; k < debug_information [i].num_loc_offsets; k++)
4511 loc_offsets = debug_information [i].loc_offsets;
4512 qsort (array, debug_information [i].num_loc_offsets,
4513 sizeof (*array), loc_offsets_compar);
4516 for (k = 0; k < debug_information [i].num_loc_offsets; k++)
4518 j = locs_sorted ? k : array[k];
4520 && debug_information [i].loc_offsets [locs_sorted
4521 ? k - 1 : array [k - 1]]
4522 == debug_information [i].loc_offsets [j])
4524 has_frame_base = debug_information [i].have_frame_base [j];
4525 offset = debug_information [i].loc_offsets [j];
4526 next = section_begin + offset;
4527 base_address = debug_information [i].base_address;
4529 if (!seen_first_offset)
4530 seen_first_offset = 1;
4534 warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"),
4535 (unsigned long) (start - section_begin),
4536 (unsigned long) (next - section_begin));
4537 else if (start > next)
4538 warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"),
4539 (unsigned long) (start - section_begin),
4540 (unsigned long) (next - section_begin));
4544 if (offset >= bytes)
4546 warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"),
4552 display_loc_list_dwo (section, &start, i, offset, has_frame_base);
4554 display_loc_list (section, &start, i, offset, base_address,
4559 if (start < section->start + section->size)
4560 warn (_("There are %ld unused bytes at the end of section %s\n"),
4561 (long) (section->start + section->size - start), section->name);
4568 display_debug_str (struct dwarf_section *section,
4569 void *file ATTRIBUTE_UNUSED)
4571 unsigned char *start = section->start;
4572 unsigned long bytes = section->size;
4573 dwarf_vma addr = section->address;
4577 printf (_("\nThe %s section is empty.\n"), section->name);
4581 printf (_("Contents of the %s section:\n\n"), section->name);
4589 lbytes = (bytes > 16 ? 16 : bytes);
4591 printf (" 0x%8.8lx ", (unsigned long) addr);
4593 for (j = 0; j < 16; j++)
4596 printf ("%2.2x", start[j]);
4604 for (j = 0; j < lbytes; j++)
4607 if (k >= ' ' && k < 0x80)
4626 display_debug_info (struct dwarf_section *section, void *file)
4628 return process_debug_info (section, file, section->abbrev_sec, 0, 0);
4632 display_debug_types (struct dwarf_section *section, void *file)
4634 return process_debug_info (section, file, section->abbrev_sec, 0, 1);
4638 display_trace_info (struct dwarf_section *section, void *file)
4640 return process_debug_info (section, file, section->abbrev_sec, 0, 0);
4644 display_debug_aranges (struct dwarf_section *section,
4645 void *file ATTRIBUTE_UNUSED)
4647 unsigned char *start = section->start;
4648 unsigned char *end = start + section->size;
4650 printf (_("Contents of the %s section:\n\n"), section->name);
4652 /* It does not matter if this load fails,
4653 we test for that later on. */
4654 load_debug_info (file);
4658 unsigned char *hdrptr;
4659 DWARF2_Internal_ARange arange;
4660 unsigned char *addr_ranges;
4663 unsigned char address_size;
4665 unsigned int offset_size;
4666 unsigned int initial_length_size;
4670 SAFE_BYTE_GET_AND_INC (arange.ar_length, hdrptr, 4, end);
4671 if (arange.ar_length == 0xffffffff)
4673 SAFE_BYTE_GET_AND_INC (arange.ar_length, hdrptr, 8, end);
4675 initial_length_size = 12;
4680 initial_length_size = 4;
4683 SAFE_BYTE_GET_AND_INC (arange.ar_version, hdrptr, 2, end);
4684 SAFE_BYTE_GET_AND_INC (arange.ar_info_offset, hdrptr, offset_size, end);
4686 if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE
4687 && num_debug_info_entries > 0
4688 && find_debug_info_for_offset (arange.ar_info_offset) == NULL)
4689 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
4690 (unsigned long) arange.ar_info_offset, section->name);
4692 SAFE_BYTE_GET_AND_INC (arange.ar_pointer_size, hdrptr, 1, end);
4693 SAFE_BYTE_GET_AND_INC (arange.ar_segment_size, hdrptr, 1, end);
4695 if (arange.ar_version != 2 && arange.ar_version != 3)
4697 warn (_("Only DWARF 2 and 3 aranges are currently supported.\n"));
4701 printf (_(" Length: %ld\n"),
4702 (long) arange.ar_length);
4703 printf (_(" Version: %d\n"), arange.ar_version);
4704 printf (_(" Offset into .debug_info: 0x%lx\n"),
4705 (unsigned long) arange.ar_info_offset);
4706 printf (_(" Pointer Size: %d\n"), arange.ar_pointer_size);
4707 printf (_(" Segment Size: %d\n"), arange.ar_segment_size);
4709 address_size = arange.ar_pointer_size + arange.ar_segment_size;
4711 /* PR 17512: file: 001-108546-0.001:0.1. */
4712 if (address_size == 0 || address_size > 8)
4714 error (_("Invalid address size in %s section!\n"),
4719 /* The DWARF spec does not require that the address size be a power
4720 of two, but we do. This will have to change if we ever encounter
4721 an uneven architecture. */
4722 if ((address_size & (address_size - 1)) != 0)
4724 warn (_("Pointer size + Segment size is not a power of two.\n"));
4728 if (address_size > 4)
4729 printf (_("\n Address Length\n"));
4731 printf (_("\n Address Length\n"));
4733 addr_ranges = hdrptr;
4735 /* Must pad to an alignment boundary that is twice the address size. */
4736 excess = (hdrptr - start) % (2 * address_size);
4738 addr_ranges += (2 * address_size) - excess;
4740 start += arange.ar_length + initial_length_size;
4742 while (addr_ranges + 2 * address_size <= start)
4744 SAFE_BYTE_GET_AND_INC (address, addr_ranges, address_size, end);
4745 SAFE_BYTE_GET_AND_INC (length, addr_ranges, address_size, end);
4748 print_dwarf_vma (address, address_size);
4749 print_dwarf_vma (length, address_size);
4759 /* Comparison function for qsort. */
4761 comp_addr_base (const void * v0, const void * v1)
4763 debug_info * info0 = (debug_info *) v0;
4764 debug_info * info1 = (debug_info *) v1;
4765 return info0->addr_base - info1->addr_base;
4768 /* Display the debug_addr section. */
4770 display_debug_addr (struct dwarf_section *section,
4773 debug_info **debug_addr_info;
4774 unsigned char *entry;
4779 if (section->size == 0)
4781 printf (_("\nThe %s section is empty.\n"), section->name);
4785 if (load_debug_info (file) == 0)
4787 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4792 printf (_("Contents of the %s section:\n\n"), section->name);
4794 debug_addr_info = (debug_info **) xmalloc ((num_debug_info_entries + 1)
4795 * sizeof (debug_info *));
4798 for (i = 0; i < num_debug_info_entries; i++)
4800 if (debug_information [i].addr_base != DEBUG_INFO_UNAVAILABLE)
4801 debug_addr_info [count++] = &debug_information [i];
4804 /* Add a sentinel to make iteration convenient. */
4805 debug_addr_info [count] = (debug_info *) xmalloc (sizeof (debug_info));
4806 debug_addr_info [count]->addr_base = section->size;
4808 qsort (debug_addr_info, count, sizeof (debug_info *), comp_addr_base);
4809 for (i = 0; i < count; i++)
4812 unsigned int address_size = debug_addr_info [i]->pointer_size;
4814 printf (_(" For compilation unit at offset 0x%s:\n"),
4815 dwarf_vmatoa ("x", debug_addr_info [i]->cu_offset));
4817 printf (_("\tIndex\tAddress\n"));
4818 entry = section->start + debug_addr_info [i]->addr_base;
4819 end = section->start + debug_addr_info [i + 1]->addr_base;
4823 dwarf_vma base = byte_get (entry, address_size);
4824 printf (_("\t%d:\t"), idx);
4825 print_dwarf_vma (base, address_size);
4827 entry += address_size;
4833 free (debug_addr_info);
4837 /* Display the .debug_str_offsets and .debug_str_offsets.dwo sections. */
4839 display_debug_str_offsets (struct dwarf_section *section,
4840 void *file ATTRIBUTE_UNUSED)
4842 if (section->size == 0)
4844 printf (_("\nThe %s section is empty.\n"), section->name);
4847 /* TODO: Dump the contents. This is made somewhat difficult by not knowing
4848 what the offset size is for this section. */
4852 /* Each debug_information[x].range_lists[y] gets this representation for
4853 sorting purposes. */
4857 /* The debug_information[x].range_lists[y] value. */
4858 unsigned long ranges_offset;
4860 /* Original debug_information to find parameters of the data. */
4861 debug_info *debug_info_p;
4864 /* Sort struct range_entry in ascending order of its RANGES_OFFSET. */
4867 range_entry_compar (const void *ap, const void *bp)
4869 const struct range_entry *a_re = (const struct range_entry *) ap;
4870 const struct range_entry *b_re = (const struct range_entry *) bp;
4871 const unsigned long a = a_re->ranges_offset;
4872 const unsigned long b = b_re->ranges_offset;
4874 return (a > b) - (b > a);
4878 display_debug_ranges (struct dwarf_section *section,
4879 void *file ATTRIBUTE_UNUSED)
4881 unsigned char *start = section->start;
4882 unsigned char *last_start = start;
4883 unsigned long bytes = section->size;
4884 unsigned char *section_begin = start;
4885 unsigned char *finish = start + bytes;
4886 unsigned int num_range_list, i;
4887 struct range_entry *range_entries, *range_entry_fill;
4891 printf (_("\nThe %s section is empty.\n"), section->name);
4895 if (load_debug_info (file) == 0)
4897 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4903 for (i = 0; i < num_debug_info_entries; i++)
4904 num_range_list += debug_information [i].num_range_lists;
4906 if (num_range_list == 0)
4908 /* This can happen when the file was compiled with -gsplit-debug
4909 which removes references to range lists from the primary .o file. */
4910 printf (_("No range lists in .debug_info section.\n"));
4914 range_entries = (struct range_entry *)
4915 xmalloc (sizeof (*range_entries) * num_range_list);
4916 range_entry_fill = range_entries;
4918 for (i = 0; i < num_debug_info_entries; i++)
4920 debug_info *debug_info_p = &debug_information[i];
4923 for (j = 0; j < debug_info_p->num_range_lists; j++)
4925 range_entry_fill->ranges_offset = debug_info_p->range_lists[j];
4926 range_entry_fill->debug_info_p = debug_info_p;
4931 qsort (range_entries, num_range_list, sizeof (*range_entries),
4932 range_entry_compar);
4934 if (dwarf_check != 0 && range_entries[0].ranges_offset != 0)
4935 warn (_("Range lists in %s section start at 0x%lx\n"),
4936 section->name, range_entries[0].ranges_offset);
4938 printf (_("Contents of the %s section:\n\n"), section->name);
4939 printf (_(" Offset Begin End\n"));
4941 for (i = 0; i < num_range_list; i++)
4943 struct range_entry *range_entry = &range_entries[i];
4944 debug_info *debug_info_p = range_entry->debug_info_p;
4945 unsigned int pointer_size;
4946 unsigned long offset;
4947 unsigned char *next;
4948 unsigned long base_address;
4950 pointer_size = debug_info_p->pointer_size;
4951 offset = range_entry->ranges_offset;
4952 next = section_begin + offset;
4953 base_address = debug_info_p->base_address;
4955 /* PR 17512: file: 001-101485-0.001:0.1. */
4956 if (pointer_size < 2 || pointer_size > 8)
4958 warn (_("Corrupt pointer size (%d) in debug entry at offset %8.8lx\n"),
4959 pointer_size, offset);
4963 if (dwarf_check != 0 && i > 0)
4966 warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"),
4967 (unsigned long) (start - section_begin),
4968 (unsigned long) (next - section_begin), section->name);
4969 else if (start > next)
4971 if (next == last_start)
4973 warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"),
4974 (unsigned long) (start - section_begin),
4975 (unsigned long) (next - section_begin), section->name);
4981 while (start < finish)
4986 /* Note: we use sign extension here in order to be sure that
4987 we can detect the -1 escape value. Sign extension into the
4988 top 32 bits of a 32-bit address will not affect the values
4989 that we display since we always show hex values, and always
4990 the bottom 32-bits. */
4991 SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish);
4992 if (start >= finish)
4994 SAFE_SIGNED_BYTE_GET_AND_INC (end, start, pointer_size, finish);
4996 printf (" %8.8lx ", offset);
4998 if (begin == 0 && end == 0)
5000 printf (_("<End of list>\n"));
5004 /* Check base address specifiers. */
5005 if (begin == (dwarf_vma) -1 && end != (dwarf_vma) -1)
5008 print_dwarf_vma (begin, pointer_size);
5009 print_dwarf_vma (end, pointer_size);
5010 printf ("(base address)\n");
5014 print_dwarf_vma (begin + base_address, pointer_size);
5015 print_dwarf_vma (end + base_address, pointer_size);
5018 fputs (_("(start == end)"), stdout);
5019 else if (begin > end)
5020 fputs (_("(start > end)"), stdout);
5027 free (range_entries);
5032 typedef struct Frame_Chunk
5034 struct Frame_Chunk *next;
5035 unsigned char *chunk_start;
5037 /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
5038 short int *col_type;
5041 unsigned int code_factor;
5048 unsigned char fde_encoding;
5049 unsigned char cfa_exp;
5050 unsigned char ptr_size;
5051 unsigned char segment_size;
5055 static const char *const *dwarf_regnames;
5056 static unsigned int dwarf_regnames_count;
5058 /* A marker for a col_type that means this column was never referenced
5059 in the frame info. */
5060 #define DW_CFA_unreferenced (-1)
5062 /* Return 0 if not more space is needed, 1 if more space is needed,
5063 -1 for invalid reg. */
5066 frame_need_space (Frame_Chunk *fc, unsigned int reg)
5068 int prev = fc->ncols;
5070 if (reg < (unsigned int) fc->ncols)
5073 if (dwarf_regnames_count
5074 && reg > dwarf_regnames_count)
5077 fc->ncols = reg + 1;
5078 fc->col_type = (short int *) xcrealloc (fc->col_type, fc->ncols,
5079 sizeof (short int));
5080 fc->col_offset = (int *) xcrealloc (fc->col_offset, fc->ncols, sizeof (int));
5081 /* PR 17512: file:002-10025-0.005. */
5082 if (fc->col_type == NULL || fc->col_offset == NULL)
5084 error (_("Out of memory allocating %u columns in dwarf frame arrays\n"),
5090 while (prev < fc->ncols)
5092 fc->col_type[prev] = DW_CFA_unreferenced;
5093 fc->col_offset[prev] = 0;
5099 static const char *const dwarf_regnames_i386[] =
5101 "eax", "ecx", "edx", "ebx", /* 0 - 3 */
5102 "esp", "ebp", "esi", "edi", /* 4 - 7 */
5103 "eip", "eflags", NULL, /* 8 - 10 */
5104 "st0", "st1", "st2", "st3", /* 11 - 14 */
5105 "st4", "st5", "st6", "st7", /* 15 - 18 */
5106 NULL, NULL, /* 19 - 20 */
5107 "xmm0", "xmm1", "xmm2", "xmm3", /* 21 - 24 */
5108 "xmm4", "xmm5", "xmm6", "xmm7", /* 25 - 28 */
5109 "mm0", "mm1", "mm2", "mm3", /* 29 - 32 */
5110 "mm4", "mm5", "mm6", "mm7", /* 33 - 36 */
5111 "fcw", "fsw", "mxcsr", /* 37 - 39 */
5112 "es", "cs", "ss", "ds", "fs", "gs", NULL, NULL, /* 40 - 47 */
5113 "tr", "ldtr", /* 48 - 49 */
5114 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 50 - 57 */
5115 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 58 - 65 */
5116 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 66 - 73 */
5117 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 74 - 81 */
5118 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 82 - 89 */
5119 NULL, NULL, NULL, /* 90 - 92 */
5120 "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7" /* 93 - 100 */
5124 init_dwarf_regnames_i386 (void)
5126 dwarf_regnames = dwarf_regnames_i386;
5127 dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_i386);
5130 static const char *const dwarf_regnames_x86_64[] =
5132 "rax", "rdx", "rcx", "rbx",
5133 "rsi", "rdi", "rbp", "rsp",
5134 "r8", "r9", "r10", "r11",
5135 "r12", "r13", "r14", "r15",
5137 "xmm0", "xmm1", "xmm2", "xmm3",
5138 "xmm4", "xmm5", "xmm6", "xmm7",
5139 "xmm8", "xmm9", "xmm10", "xmm11",
5140 "xmm12", "xmm13", "xmm14", "xmm15",
5141 "st0", "st1", "st2", "st3",
5142 "st4", "st5", "st6", "st7",
5143 "mm0", "mm1", "mm2", "mm3",
5144 "mm4", "mm5", "mm6", "mm7",
5146 "es", "cs", "ss", "ds", "fs", "gs", NULL, NULL,
5147 "fs.base", "gs.base", NULL, NULL,
5149 "mxcsr", "fcw", "fsw",
5150 "xmm16", "xmm17", "xmm18", "xmm19",
5151 "xmm20", "xmm21", "xmm22", "xmm23",
5152 "xmm24", "xmm25", "xmm26", "xmm27",
5153 "xmm28", "xmm29", "xmm30", "xmm31",
5154 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 83 - 90 */
5155 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 91 - 98 */
5156 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 99 - 106 */
5157 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 107 - 114 */
5158 NULL, NULL, NULL, /* 115 - 117 */
5159 "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7"
5163 init_dwarf_regnames_x86_64 (void)
5165 dwarf_regnames = dwarf_regnames_x86_64;
5166 dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_x86_64);
5169 static const char *const dwarf_regnames_aarch64[] =
5171 "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7",
5172 "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15",
5173 "x16", "x17", "x18", "x19", "x20", "x21", "x22", "x23",
5174 "x24", "x25", "x26", "x27", "x28", "x29", "x30", "sp",
5175 NULL, "elr", NULL, NULL, NULL, NULL, NULL, NULL,
5176 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
5177 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
5178 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
5179 "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7",
5180 "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15",
5181 "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23",
5182 "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
5186 init_dwarf_regnames_aarch64 (void)
5188 dwarf_regnames = dwarf_regnames_aarch64;
5189 dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_aarch64);
5193 init_dwarf_regnames (unsigned int e_machine)
5199 init_dwarf_regnames_i386 ();
5205 init_dwarf_regnames_x86_64 ();
5209 init_dwarf_regnames_aarch64 ();
5218 regname (unsigned int regno, int row)
5220 static char reg[64];
5222 && regno < dwarf_regnames_count
5223 && dwarf_regnames [regno] != NULL)
5226 return dwarf_regnames [regno];
5227 snprintf (reg, sizeof (reg), "r%d (%s)", regno,
5228 dwarf_regnames [regno]);
5231 snprintf (reg, sizeof (reg), "r%d", regno);
5236 frame_display_row (Frame_Chunk *fc, int *need_col_headers, int *max_regs)
5241 if (*max_regs < fc->ncols)
5242 *max_regs = fc->ncols;
5244 if (*need_col_headers)
5246 static const char *sloc = " LOC";
5248 *need_col_headers = 0;
5250 printf ("%-*s CFA ", eh_addr_size * 2, sloc);
5252 for (r = 0; r < *max_regs; r++)
5253 if (fc->col_type[r] != DW_CFA_unreferenced)
5258 printf ("%-5s ", regname (r, 1));
5264 print_dwarf_vma (fc->pc_begin, eh_addr_size);
5266 strcpy (tmp, "exp");
5268 sprintf (tmp, "%s%+d", regname (fc->cfa_reg, 1), fc->cfa_offset);
5269 printf ("%-8s ", tmp);
5271 for (r = 0; r < fc->ncols; r++)
5273 if (fc->col_type[r] != DW_CFA_unreferenced)
5275 switch (fc->col_type[r])
5277 case DW_CFA_undefined:
5280 case DW_CFA_same_value:
5284 sprintf (tmp, "c%+d", fc->col_offset[r]);
5286 case DW_CFA_val_offset:
5287 sprintf (tmp, "v%+d", fc->col_offset[r]);
5289 case DW_CFA_register:
5290 sprintf (tmp, "%s", regname (fc->col_offset[r], 0));
5292 case DW_CFA_expression:
5293 strcpy (tmp, "exp");
5295 case DW_CFA_val_expression:
5296 strcpy (tmp, "vexp");
5299 strcpy (tmp, "n/a");
5302 printf ("%-5s ", tmp);
5308 #define GET(VAR, N) SAFE_BYTE_GET_AND_INC (VAR, start, N, end)
5309 #define LEB() read_uleb128 (start, & length_return, end); start += length_return
5310 #define SLEB() read_sleb128 (start, & length_return, end); start += length_return
5312 static unsigned char *
5313 read_cie (unsigned char *start, unsigned char *end,
5314 Frame_Chunk **p_cie, int *p_version,
5315 unsigned long *p_aug_len, unsigned char **p_aug)
5319 unsigned int length_return;
5320 unsigned char *augmentation_data = NULL;
5321 unsigned long augmentation_data_len = 0;
5324 /* PR 17512: file: 001-228113-0.004. */
5328 fc = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk));
5329 memset (fc, 0, sizeof (Frame_Chunk));
5331 fc->col_type = (short int *) xmalloc (sizeof (short int));
5332 fc->col_offset = (int *) xmalloc (sizeof (int));
5336 fc->augmentation = (char *) start;
5337 /* PR 17512: file: 001-228113-0.004.
5338 Skip past augmentation name, but avoid running off the end of the data. */
5340 if (* start ++ == '\0')
5344 warn (_("No terminator for augmentation name\n"));
5348 if (strcmp (fc->augmentation, "eh") == 0)
5349 start += eh_addr_size;
5353 GET (fc->ptr_size, 1);
5354 GET (fc->segment_size, 1);
5355 eh_addr_size = fc->ptr_size;
5359 fc->ptr_size = eh_addr_size;
5360 fc->segment_size = 0;
5362 fc->code_factor = LEB ();
5363 fc->data_factor = SLEB ();
5373 if (fc->augmentation[0] == 'z')
5375 augmentation_data_len = LEB ();
5376 augmentation_data = start;
5377 start += augmentation_data_len;
5380 if (augmentation_data_len)
5382 unsigned char *p, *q;
5383 p = (unsigned char *) fc->augmentation + 1;
5384 q = augmentation_data;
5391 q += 1 + size_of_encoded_value (*q);
5393 fc->fde_encoding = *q++;
5404 *p_version = version;
5407 *p_aug_len = augmentation_data_len;
5408 *p_aug = augmentation_data;
5414 display_debug_frames (struct dwarf_section *section,
5415 void *file ATTRIBUTE_UNUSED)
5417 unsigned char *start = section->start;
5418 unsigned char *end = start + section->size;
5419 unsigned char *section_start = start;
5420 Frame_Chunk *chunks = 0, *forward_refs = 0;
5421 Frame_Chunk *remembered_state = 0;
5423 int is_eh = strcmp (section->name, ".eh_frame") == 0;
5424 unsigned int length_return;
5426 const char *bad_reg = _("bad register: ");
5427 int saved_eh_addr_size = eh_addr_size;
5429 printf (_("Contents of the %s section:\n"), section->name);
5433 unsigned char *saved_start;
5434 unsigned char *block_end;
5439 int need_col_headers = 1;
5440 unsigned char *augmentation_data = NULL;
5441 unsigned long augmentation_data_len = 0;
5442 unsigned int encoded_ptr_size = saved_eh_addr_size;
5443 unsigned int offset_size;
5444 unsigned int initial_length_size;
5446 saved_start = start;
5448 SAFE_BYTE_GET_AND_INC (length, start, 4, end);
5452 printf ("\n%08lx ZERO terminator\n\n",
5453 (unsigned long)(saved_start - section_start));
5457 if (length == 0xffffffff)
5459 SAFE_BYTE_GET_AND_INC (length, start, 8, end);
5461 initial_length_size = 12;
5466 initial_length_size = 4;
5469 block_end = saved_start + length + initial_length_size;
5470 if (block_end > end || block_end < start)
5472 warn ("Invalid length 0x%s in FDE at %#08lx\n",
5473 dwarf_vmatoa_1 (NULL, length, offset_size),
5474 (unsigned long) (saved_start - section_start));
5478 SAFE_BYTE_GET_AND_INC (cie_id, start, offset_size, end);
5480 if (is_eh ? (cie_id == 0) : ((offset_size == 4 && cie_id == DW_CIE_ID)
5481 || (offset_size == 8 && cie_id == DW64_CIE_ID)))
5486 start = read_cie (start, end, &cie, &version,
5487 &augmentation_data_len, &augmentation_data);
5488 /* PR 17512: file: 027-135133-0.005. */
5494 fc->chunk_start = saved_start;
5495 mreg = max_regs - 1;
5498 frame_need_space (fc, mreg);
5499 if (fc->fde_encoding)
5500 encoded_ptr_size = size_of_encoded_value (fc->fde_encoding);
5502 printf ("\n%08lx ", (unsigned long) (saved_start - section_start));
5503 print_dwarf_vma (length, fc->ptr_size);
5504 print_dwarf_vma (cie_id, offset_size);
5506 if (do_debug_frames_interp)
5508 printf ("CIE \"%s\" cf=%d df=%d ra=%d\n", fc->augmentation,
5509 fc->code_factor, fc->data_factor, fc->ra);
5514 printf (" Version: %d\n", version);
5515 printf (" Augmentation: \"%s\"\n", fc->augmentation);
5518 printf (" Pointer Size: %u\n", fc->ptr_size);
5519 printf (" Segment Size: %u\n", fc->segment_size);
5521 printf (" Code alignment factor: %u\n", fc->code_factor);
5522 printf (" Data alignment factor: %d\n", fc->data_factor);
5523 printf (" Return address column: %d\n", fc->ra);
5525 if (augmentation_data_len)
5528 printf (" Augmentation data: ");
5529 for (i = 0; i < augmentation_data_len; ++i)
5530 printf (" %02x", augmentation_data[i]);
5538 unsigned char *look_for;
5539 static Frame_Chunk fde_fc;
5540 unsigned long segment_selector;
5544 dwarf_vma sign = (dwarf_vma) 1 << (offset_size * 8 - 1);
5545 look_for = start - 4 - ((cie_id ^ sign) - sign);
5548 look_for = section_start + cie_id;
5550 if (look_for <= saved_start)
5552 for (cie = chunks; cie ; cie = cie->next)
5553 if (cie->chunk_start == look_for)
5558 for (cie = forward_refs; cie ; cie = cie->next)
5559 if (cie->chunk_start == look_for)
5563 unsigned int off_size;
5564 unsigned char *cie_scan;
5566 cie_scan = look_for;
5568 SAFE_BYTE_GET_AND_INC (length, cie_scan, 4, end);
5569 if (length == 0xffffffff)
5571 SAFE_BYTE_GET_AND_INC (length, cie_scan, 8, end);
5578 SAFE_BYTE_GET_AND_INC (c_id, cie_scan, off_size, end);
5581 : ((off_size == 4 && c_id == DW_CIE_ID)
5582 || (off_size == 8 && c_id == DW64_CIE_ID)))
5587 read_cie (cie_scan, end, &cie, &version,
5588 &augmentation_data_len, &augmentation_data);
5589 cie->next = forward_refs;
5591 cie->chunk_start = look_for;
5592 mreg = max_regs - 1;
5595 frame_need_space (cie, mreg);
5596 if (cie->fde_encoding)
5598 = size_of_encoded_value (cie->fde_encoding);
5605 memset (fc, 0, sizeof (Frame_Chunk));
5609 warn ("Invalid CIE pointer 0x%s in FDE at %#08lx\n",
5610 dwarf_vmatoa_1 (NULL, cie_id, offset_size),
5611 (unsigned long) (saved_start - section_start));
5613 fc->col_type = (short int *) xmalloc (sizeof (short int));
5614 fc->col_offset = (int *) xmalloc (sizeof (int));
5615 frame_need_space (fc, max_regs - 1);
5617 fc->augmentation = "";
5618 fc->fde_encoding = 0;
5619 fc->ptr_size = eh_addr_size;
5620 fc->segment_size = 0;
5624 fc->ncols = cie->ncols;
5625 fc->col_type = (short int *) xcmalloc (fc->ncols, sizeof (short int));
5626 fc->col_offset = (int *) xcmalloc (fc->ncols, sizeof (int));
5627 memcpy (fc->col_type, cie->col_type, fc->ncols * sizeof (short int));
5628 memcpy (fc->col_offset, cie->col_offset, fc->ncols * sizeof (int));
5629 fc->augmentation = cie->augmentation;
5630 fc->ptr_size = cie->ptr_size;
5631 eh_addr_size = cie->ptr_size;
5632 fc->segment_size = cie->segment_size;
5633 fc->code_factor = cie->code_factor;
5634 fc->data_factor = cie->data_factor;
5635 fc->cfa_reg = cie->cfa_reg;
5636 fc->cfa_offset = cie->cfa_offset;
5638 frame_need_space (fc, max_regs - 1);
5639 fc->fde_encoding = cie->fde_encoding;
5642 if (fc->fde_encoding)
5643 encoded_ptr_size = size_of_encoded_value (fc->fde_encoding);
5645 segment_selector = 0;
5646 if (fc->segment_size)
5647 SAFE_BYTE_GET_AND_INC (segment_selector, start, fc->segment_size, end);
5649 fc->pc_begin = get_encoded_value (&start, fc->fde_encoding, section, end);
5651 /* FIXME: It appears that sometimes the final pc_range value is
5652 encoded in less than encoded_ptr_size bytes. See the x86_64
5653 run of the "objcopy on compressed debug sections" test for an
5655 SAFE_BYTE_GET_AND_INC (fc->pc_range, start, encoded_ptr_size, end);
5657 if (cie->augmentation[0] == 'z')
5659 augmentation_data_len = LEB ();
5660 augmentation_data = start;
5661 start += augmentation_data_len;
5664 printf ("\n%08lx %s %s FDE cie=%08lx pc=",
5665 (unsigned long)(saved_start - section_start),
5666 dwarf_vmatoa_1 (NULL, length, fc->ptr_size),
5667 dwarf_vmatoa_1 (NULL, cie_id, offset_size),
5668 (unsigned long)(cie->chunk_start - section_start));
5670 if (fc->segment_size)
5671 printf ("%04lx:", segment_selector);
5674 dwarf_vmatoa_1 (NULL, fc->pc_begin, fc->ptr_size),
5675 dwarf_vmatoa_1 (NULL, fc->pc_begin + fc->pc_range, fc->ptr_size));
5677 if (! do_debug_frames_interp && augmentation_data_len)
5681 printf (" Augmentation data: ");
5682 for (i = 0; i < augmentation_data_len; ++i)
5683 printf (" %02x", augmentation_data[i]);
5689 /* At this point, fc is the current chunk, cie (if any) is set, and
5690 we're about to interpret instructions for the chunk. */
5691 /* ??? At present we need to do this always, since this sizes the
5692 fc->col_type and fc->col_offset arrays, which we write into always.
5693 We should probably split the interpreted and non-interpreted bits
5694 into two different routines, since there's so much that doesn't
5695 really overlap between them. */
5696 if (1 || do_debug_frames_interp)
5698 /* Start by making a pass over the chunk, allocating storage
5699 and taking note of what registers are used. */
5700 unsigned char *tmp = start;
5702 while (start < block_end)
5704 unsigned int reg, op, opa;
5712 /* Warning: if you add any more cases to this switch, be
5713 sure to add them to the corresponding switch below. */
5716 case DW_CFA_advance_loc:
5720 if (frame_need_space (fc, opa) >= 0)
5721 fc->col_type[opa] = DW_CFA_undefined;
5723 case DW_CFA_restore:
5724 if (frame_need_space (fc, opa) >= 0)
5725 fc->col_type[opa] = DW_CFA_undefined;
5727 case DW_CFA_set_loc:
5728 start += encoded_ptr_size;
5730 case DW_CFA_advance_loc1:
5733 case DW_CFA_advance_loc2:
5736 case DW_CFA_advance_loc4:
5739 case DW_CFA_offset_extended:
5740 case DW_CFA_val_offset:
5741 reg = LEB (); LEB ();
5742 if (frame_need_space (fc, reg) >= 0)
5743 fc->col_type[reg] = DW_CFA_undefined;
5745 case DW_CFA_restore_extended:
5747 frame_need_space (fc, reg);
5748 if (frame_need_space (fc, reg) >= 0)
5749 fc->col_type[reg] = DW_CFA_undefined;
5751 case DW_CFA_undefined:
5753 if (frame_need_space (fc, reg) >= 0)
5754 fc->col_type[reg] = DW_CFA_undefined;
5756 case DW_CFA_same_value:
5758 if (frame_need_space (fc, reg) >= 0)
5759 fc->col_type[reg] = DW_CFA_undefined;
5761 case DW_CFA_register:
5762 reg = LEB (); LEB ();
5763 if (frame_need_space (fc, reg) >= 0)
5764 fc->col_type[reg] = DW_CFA_undefined;
5766 case DW_CFA_def_cfa:
5769 case DW_CFA_def_cfa_register:
5772 case DW_CFA_def_cfa_offset:
5775 case DW_CFA_def_cfa_expression:
5777 if (start + temp < start)
5779 warn (_("Corrupt CFA_def expression value: %lu\n"), temp);
5785 case DW_CFA_expression:
5786 case DW_CFA_val_expression:
5789 if (start + temp < start)
5791 /* PR 17512: file:306-192417-0.005. */
5792 warn (_("Corrupt CFA expression value: %lu\n"), temp);
5797 if (frame_need_space (fc, reg) >= 0)
5798 fc->col_type[reg] = DW_CFA_undefined;
5800 case DW_CFA_offset_extended_sf:
5801 case DW_CFA_val_offset_sf:
5802 reg = LEB (); SLEB ();
5803 if (frame_need_space (fc, reg) >= 0)
5804 fc->col_type[reg] = DW_CFA_undefined;
5806 case DW_CFA_def_cfa_sf:
5809 case DW_CFA_def_cfa_offset_sf:
5812 case DW_CFA_MIPS_advance_loc8:
5815 case DW_CFA_GNU_args_size:
5818 case DW_CFA_GNU_negative_offset_extended:
5819 reg = LEB (); LEB ();
5820 if (frame_need_space (fc, reg) >= 0)
5821 fc->col_type[reg] = DW_CFA_undefined;
5830 /* Now we know what registers are used, make a second pass over
5831 the chunk, this time actually printing out the info. */
5833 while (start < block_end)
5836 unsigned long ul, reg, roffs;
5840 const char *reg_prefix = "";
5847 /* Warning: if you add any more cases to this switch, be
5848 sure to add them to the corresponding switch above. */
5851 case DW_CFA_advance_loc:
5852 if (do_debug_frames_interp)
5853 frame_display_row (fc, &need_col_headers, &max_regs);
5855 printf (" DW_CFA_advance_loc: %d to %s\n",
5856 opa * fc->code_factor,
5857 dwarf_vmatoa_1 (NULL,
5858 fc->pc_begin + opa * fc->code_factor,
5860 fc->pc_begin += opa * fc->code_factor;
5865 if (opa >= (unsigned int) fc->ncols)
5866 reg_prefix = bad_reg;
5867 if (! do_debug_frames_interp || *reg_prefix != '\0')
5868 printf (" DW_CFA_offset: %s%s at cfa%+ld\n",
5869 reg_prefix, regname (opa, 0),
5870 roffs * fc->data_factor);
5871 if (*reg_prefix == '\0')
5873 fc->col_type[opa] = DW_CFA_offset;
5874 fc->col_offset[opa] = roffs * fc->data_factor;
5878 case DW_CFA_restore:
5879 if (opa >= (unsigned int) cie->ncols
5880 || opa >= (unsigned int) fc->ncols)
5881 reg_prefix = bad_reg;
5882 if (! do_debug_frames_interp || *reg_prefix != '\0')
5883 printf (" DW_CFA_restore: %s%s\n",
5884 reg_prefix, regname (opa, 0));
5885 if (*reg_prefix == '\0')
5887 fc->col_type[opa] = cie->col_type[opa];
5888 fc->col_offset[opa] = cie->col_offset[opa];
5889 if (do_debug_frames_interp
5890 && fc->col_type[opa] == DW_CFA_unreferenced)
5891 fc->col_type[opa] = DW_CFA_undefined;
5895 case DW_CFA_set_loc:
5896 vma = get_encoded_value (&start, fc->fde_encoding, section, end);
5897 if (do_debug_frames_interp)
5898 frame_display_row (fc, &need_col_headers, &max_regs);
5900 printf (" DW_CFA_set_loc: %s\n",
5901 dwarf_vmatoa_1 (NULL, vma, fc->ptr_size));
5905 case DW_CFA_advance_loc1:
5906 SAFE_BYTE_GET_AND_INC (ofs, start, 1, end);
5907 if (do_debug_frames_interp)
5908 frame_display_row (fc, &need_col_headers, &max_regs);
5910 printf (" DW_CFA_advance_loc1: %ld to %s\n",
5911 (unsigned long) (ofs * fc->code_factor),
5912 dwarf_vmatoa_1 (NULL,
5913 fc->pc_begin + ofs * fc->code_factor,
5915 fc->pc_begin += ofs * fc->code_factor;
5918 case DW_CFA_advance_loc2:
5919 SAFE_BYTE_GET_AND_INC (ofs, start, 2, end);
5920 if (do_debug_frames_interp)
5921 frame_display_row (fc, &need_col_headers, &max_regs);
5923 printf (" DW_CFA_advance_loc2: %ld to %s\n",
5924 (unsigned long) (ofs * fc->code_factor),
5925 dwarf_vmatoa_1 (NULL,
5926 fc->pc_begin + ofs * fc->code_factor,
5928 fc->pc_begin += ofs * fc->code_factor;
5931 case DW_CFA_advance_loc4:
5932 SAFE_BYTE_GET_AND_INC (ofs, start, 4, end);
5933 if (do_debug_frames_interp)
5934 frame_display_row (fc, &need_col_headers, &max_regs);
5936 printf (" DW_CFA_advance_loc4: %ld to %s\n",
5937 (unsigned long) (ofs * fc->code_factor),
5938 dwarf_vmatoa_1 (NULL,
5939 fc->pc_begin + ofs * fc->code_factor,
5941 fc->pc_begin += ofs * fc->code_factor;
5944 case DW_CFA_offset_extended:
5947 if (reg >= (unsigned int) fc->ncols)
5948 reg_prefix = bad_reg;
5949 if (! do_debug_frames_interp || *reg_prefix != '\0')
5950 printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n",
5951 reg_prefix, regname (reg, 0),
5952 roffs * fc->data_factor);
5953 if (*reg_prefix == '\0')
5955 fc->col_type[reg] = DW_CFA_offset;
5956 fc->col_offset[reg] = roffs * fc->data_factor;
5960 case DW_CFA_val_offset:
5963 if (reg >= (unsigned int) fc->ncols)
5964 reg_prefix = bad_reg;
5965 if (! do_debug_frames_interp || *reg_prefix != '\0')
5966 printf (" DW_CFA_val_offset: %s%s at cfa%+ld\n",
5967 reg_prefix, regname (reg, 0),
5968 roffs * fc->data_factor);
5969 if (*reg_prefix == '\0')
5971 fc->col_type[reg] = DW_CFA_val_offset;
5972 fc->col_offset[reg] = roffs * fc->data_factor;
5976 case DW_CFA_restore_extended:
5978 if (reg >= (unsigned int) cie->ncols
5979 || reg >= (unsigned int) fc->ncols)
5980 reg_prefix = bad_reg;
5981 if (! do_debug_frames_interp || *reg_prefix != '\0')
5982 printf (" DW_CFA_restore_extended: %s%s\n",
5983 reg_prefix, regname (reg, 0));
5984 if (*reg_prefix == '\0')
5986 fc->col_type[reg] = cie->col_type[reg];
5987 fc->col_offset[reg] = cie->col_offset[reg];
5991 case DW_CFA_undefined:
5993 if (reg >= (unsigned int) fc->ncols)
5994 reg_prefix = bad_reg;
5995 if (! do_debug_frames_interp || *reg_prefix != '\0')
5996 printf (" DW_CFA_undefined: %s%s\n",
5997 reg_prefix, regname (reg, 0));
5998 if (*reg_prefix == '\0')
6000 fc->col_type[reg] = DW_CFA_undefined;
6001 fc->col_offset[reg] = 0;
6005 case DW_CFA_same_value:
6007 if (reg >= (unsigned int) fc->ncols)
6008 reg_prefix = bad_reg;
6009 if (! do_debug_frames_interp || *reg_prefix != '\0')
6010 printf (" DW_CFA_same_value: %s%s\n",
6011 reg_prefix, regname (reg, 0));
6012 if (*reg_prefix == '\0')
6014 fc->col_type[reg] = DW_CFA_same_value;
6015 fc->col_offset[reg] = 0;
6019 case DW_CFA_register:
6022 if (reg >= (unsigned int) fc->ncols)
6023 reg_prefix = bad_reg;
6024 if (! do_debug_frames_interp || *reg_prefix != '\0')
6026 printf (" DW_CFA_register: %s%s in ",
6027 reg_prefix, regname (reg, 0));
6028 puts (regname (roffs, 0));
6030 if (*reg_prefix == '\0')
6032 fc->col_type[reg] = DW_CFA_register;
6033 fc->col_offset[reg] = roffs;
6037 case DW_CFA_remember_state:
6038 if (! do_debug_frames_interp)
6039 printf (" DW_CFA_remember_state\n");
6040 rs = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk));
6041 rs->cfa_offset = fc->cfa_offset;
6042 rs->cfa_reg = fc->cfa_reg;
6044 rs->cfa_exp = fc->cfa_exp;
6045 rs->ncols = fc->ncols;
6046 rs->col_type = (short int *) xcmalloc (rs->ncols,
6047 sizeof (* rs->col_type));
6048 rs->col_offset = (int *) xcmalloc (rs->ncols, sizeof (* rs->col_offset));
6049 memcpy (rs->col_type, fc->col_type, rs->ncols * sizeof (* fc->col_type));
6050 memcpy (rs->col_offset, fc->col_offset, rs->ncols * sizeof (* fc->col_offset));
6051 rs->next = remembered_state;
6052 remembered_state = rs;
6055 case DW_CFA_restore_state:
6056 if (! do_debug_frames_interp)
6057 printf (" DW_CFA_restore_state\n");
6058 rs = remembered_state;
6061 remembered_state = rs->next;
6062 fc->cfa_offset = rs->cfa_offset;
6063 fc->cfa_reg = rs->cfa_reg;
6065 fc->cfa_exp = rs->cfa_exp;
6066 frame_need_space (fc, rs->ncols - 1);
6067 memcpy (fc->col_type, rs->col_type, rs->ncols * sizeof (* rs->col_type));
6068 memcpy (fc->col_offset, rs->col_offset,
6069 rs->ncols * sizeof (* rs->col_offset));
6070 free (rs->col_type);
6071 free (rs->col_offset);
6074 else if (do_debug_frames_interp)
6075 printf ("Mismatched DW_CFA_restore_state\n");
6078 case DW_CFA_def_cfa:
6079 fc->cfa_reg = LEB ();
6080 fc->cfa_offset = LEB ();
6082 if (! do_debug_frames_interp)
6083 printf (" DW_CFA_def_cfa: %s ofs %d\n",
6084 regname (fc->cfa_reg, 0), fc->cfa_offset);
6087 case DW_CFA_def_cfa_register:
6088 fc->cfa_reg = LEB ();
6090 if (! do_debug_frames_interp)
6091 printf (" DW_CFA_def_cfa_register: %s\n",
6092 regname (fc->cfa_reg, 0));
6095 case DW_CFA_def_cfa_offset:
6096 fc->cfa_offset = LEB ();
6097 if (! do_debug_frames_interp)
6098 printf (" DW_CFA_def_cfa_offset: %d\n", fc->cfa_offset);
6102 if (! do_debug_frames_interp)
6103 printf (" DW_CFA_nop\n");
6106 case DW_CFA_def_cfa_expression:
6108 if (! do_debug_frames_interp)
6110 printf (" DW_CFA_def_cfa_expression (");
6111 decode_location_expression (start, eh_addr_size, 0, -1,
6119 case DW_CFA_expression:
6122 if (reg >= (unsigned int) fc->ncols)
6123 reg_prefix = bad_reg;
6124 if (! do_debug_frames_interp || *reg_prefix != '\0')
6126 printf (" DW_CFA_expression: %s%s (",
6127 reg_prefix, regname (reg, 0));
6128 decode_location_expression (start, eh_addr_size, 0, -1,
6132 if (*reg_prefix == '\0')
6133 fc->col_type[reg] = DW_CFA_expression;
6137 case DW_CFA_val_expression:
6140 if (reg >= (unsigned int) fc->ncols)
6141 reg_prefix = bad_reg;
6142 if (! do_debug_frames_interp || *reg_prefix != '\0')
6144 printf (" DW_CFA_val_expression: %s%s (",
6145 reg_prefix, regname (reg, 0));
6146 decode_location_expression (start, eh_addr_size, 0, -1,
6150 if (*reg_prefix == '\0')
6151 fc->col_type[reg] = DW_CFA_val_expression;
6155 case DW_CFA_offset_extended_sf:
6158 if (frame_need_space (fc, reg) < 0)
6159 reg_prefix = bad_reg;
6160 if (! do_debug_frames_interp || *reg_prefix != '\0')
6161 printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n",
6162 reg_prefix, regname (reg, 0),
6163 l * fc->data_factor);
6164 if (*reg_prefix == '\0')
6166 fc->col_type[reg] = DW_CFA_offset;
6167 fc->col_offset[reg] = l * fc->data_factor;
6171 case DW_CFA_val_offset_sf:
6174 if (frame_need_space (fc, reg) < 0)
6175 reg_prefix = bad_reg;
6176 if (! do_debug_frames_interp || *reg_prefix != '\0')
6177 printf (" DW_CFA_val_offset_sf: %s%s at cfa%+ld\n",
6178 reg_prefix, regname (reg, 0),
6179 l * fc->data_factor);
6180 if (*reg_prefix == '\0')
6182 fc->col_type[reg] = DW_CFA_val_offset;
6183 fc->col_offset[reg] = l * fc->data_factor;
6187 case DW_CFA_def_cfa_sf:
6188 fc->cfa_reg = LEB ();
6189 fc->cfa_offset = SLEB ();
6190 fc->cfa_offset = fc->cfa_offset * fc->data_factor;
6192 if (! do_debug_frames_interp)
6193 printf (" DW_CFA_def_cfa_sf: %s ofs %d\n",
6194 regname (fc->cfa_reg, 0), fc->cfa_offset);
6197 case DW_CFA_def_cfa_offset_sf:
6198 fc->cfa_offset = SLEB ();
6199 fc->cfa_offset = fc->cfa_offset * fc->data_factor;
6200 if (! do_debug_frames_interp)
6201 printf (" DW_CFA_def_cfa_offset_sf: %d\n", fc->cfa_offset);
6204 case DW_CFA_MIPS_advance_loc8:
6205 SAFE_BYTE_GET_AND_INC (ofs, start, 8, end);
6206 if (do_debug_frames_interp)
6207 frame_display_row (fc, &need_col_headers, &max_regs);
6209 printf (" DW_CFA_MIPS_advance_loc8: %ld to %s\n",
6210 (unsigned long) (ofs * fc->code_factor),
6211 dwarf_vmatoa_1 (NULL,
6212 fc->pc_begin + ofs * fc->code_factor,
6214 fc->pc_begin += ofs * fc->code_factor;
6217 case DW_CFA_GNU_window_save:
6218 if (! do_debug_frames_interp)
6219 printf (" DW_CFA_GNU_window_save\n");
6222 case DW_CFA_GNU_args_size:
6224 if (! do_debug_frames_interp)
6225 printf (" DW_CFA_GNU_args_size: %ld\n", ul);
6228 case DW_CFA_GNU_negative_offset_extended:
6231 if (frame_need_space (fc, reg) < 0)
6232 reg_prefix = bad_reg;
6233 if (! do_debug_frames_interp || *reg_prefix != '\0')
6234 printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n",
6235 reg_prefix, regname (reg, 0),
6236 l * fc->data_factor);
6237 if (*reg_prefix == '\0')
6239 fc->col_type[reg] = DW_CFA_offset;
6240 fc->col_offset[reg] = l * fc->data_factor;
6245 if (op >= DW_CFA_lo_user && op <= DW_CFA_hi_user)
6246 printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op);
6248 warn (_("Unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op);
6253 if (do_debug_frames_interp)
6254 frame_display_row (fc, &need_col_headers, &max_regs);
6257 eh_addr_size = saved_eh_addr_size;
6270 display_gdb_index (struct dwarf_section *section,
6271 void *file ATTRIBUTE_UNUSED)
6273 unsigned char *start = section->start;
6275 uint32_t cu_list_offset, tu_list_offset;
6276 uint32_t address_table_offset, symbol_table_offset, constant_pool_offset;
6277 unsigned int cu_list_elements, tu_list_elements;
6278 unsigned int address_table_size, symbol_table_slots;
6279 unsigned char *cu_list, *tu_list;
6280 unsigned char *address_table, *symbol_table, *constant_pool;
6283 /* The documentation for the format of this file is in gdb/dwarf2read.c. */
6285 printf (_("Contents of the %s section:\n"), section->name);
6287 if (section->size < 6 * sizeof (uint32_t))
6289 warn (_("Truncated header in the %s section.\n"), section->name);
6293 version = byte_get_little_endian (start, 4);
6294 printf (_("Version %ld\n"), (long) version);
6296 /* Prior versions are obsolete, and future versions may not be
6297 backwards compatible. */
6298 if (version < 3 || version > 8)
6300 warn (_("Unsupported version %lu.\n"), (unsigned long) version);
6304 warn (_("The address table data in version 3 may be wrong.\n"));
6306 warn (_("Version 4 does not support case insensitive lookups.\n"));
6308 warn (_("Version 5 does not include inlined functions.\n"));
6310 warn (_("Version 6 does not include symbol attributes.\n"));
6311 /* Version 7 indices generated by Gold have bad type unit references,
6312 PR binutils/15021. But we don't know if the index was generated by
6313 Gold or not, so to avoid worrying users with gdb-generated indices
6314 we say nothing for version 7 here. */
6316 cu_list_offset = byte_get_little_endian (start + 4, 4);
6317 tu_list_offset = byte_get_little_endian (start + 8, 4);
6318 address_table_offset = byte_get_little_endian (start + 12, 4);
6319 symbol_table_offset = byte_get_little_endian (start + 16, 4);
6320 constant_pool_offset = byte_get_little_endian (start + 20, 4);
6322 if (cu_list_offset > section->size
6323 || tu_list_offset > section->size
6324 || address_table_offset > section->size
6325 || symbol_table_offset > section->size
6326 || constant_pool_offset > section->size)
6328 warn (_("Corrupt header in the %s section.\n"), section->name);
6332 cu_list_elements = (tu_list_offset - cu_list_offset) / 8;
6333 tu_list_elements = (address_table_offset - tu_list_offset) / 8;
6334 address_table_size = symbol_table_offset - address_table_offset;
6335 symbol_table_slots = (constant_pool_offset - symbol_table_offset) / 8;
6337 cu_list = start + cu_list_offset;
6338 tu_list = start + tu_list_offset;
6339 address_table = start + address_table_offset;
6340 symbol_table = start + symbol_table_offset;
6341 constant_pool = start + constant_pool_offset;
6343 printf (_("\nCU table:\n"));
6344 for (i = 0; i < cu_list_elements; i += 2)
6346 uint64_t cu_offset = byte_get_little_endian (cu_list + i * 8, 8);
6347 uint64_t cu_length = byte_get_little_endian (cu_list + i * 8 + 8, 8);
6349 printf (_("[%3u] 0x%lx - 0x%lx\n"), i / 2,
6350 (unsigned long) cu_offset,
6351 (unsigned long) (cu_offset + cu_length - 1));
6354 printf (_("\nTU table:\n"));
6355 for (i = 0; i < tu_list_elements; i += 3)
6357 uint64_t tu_offset = byte_get_little_endian (tu_list + i * 8, 8);
6358 uint64_t type_offset = byte_get_little_endian (tu_list + i * 8 + 8, 8);
6359 uint64_t signature = byte_get_little_endian (tu_list + i * 8 + 16, 8);
6361 printf (_("[%3u] 0x%lx 0x%lx "), i / 3,
6362 (unsigned long) tu_offset,
6363 (unsigned long) type_offset);
6364 print_dwarf_vma (signature, 8);
6368 printf (_("\nAddress table:\n"));
6369 for (i = 0; i < address_table_size; i += 2 * 8 + 4)
6371 uint64_t low = byte_get_little_endian (address_table + i, 8);
6372 uint64_t high = byte_get_little_endian (address_table + i + 8, 8);
6373 uint32_t cu_index = byte_get_little_endian (address_table + i + 16, 4);
6375 print_dwarf_vma (low, 8);
6376 print_dwarf_vma (high, 8);
6377 printf (_("%lu\n"), (unsigned long) cu_index);
6380 printf (_("\nSymbol table:\n"));
6381 for (i = 0; i < symbol_table_slots; ++i)
6383 uint32_t name_offset = byte_get_little_endian (symbol_table + i * 8, 4);
6384 uint32_t cu_vector_offset = byte_get_little_endian (symbol_table + i * 8 + 4, 4);
6385 uint32_t num_cus, cu;
6387 if (name_offset != 0
6388 || cu_vector_offset != 0)
6392 printf ("[%3u] %s:", i, constant_pool + name_offset);
6393 num_cus = byte_get_little_endian (constant_pool + cu_vector_offset, 4);
6396 for (j = 0; j < num_cus; ++j)
6399 gdb_index_symbol_kind kind;
6401 cu = byte_get_little_endian (constant_pool + cu_vector_offset + 4 + j * 4, 4);
6402 is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu);
6403 kind = GDB_INDEX_SYMBOL_KIND_VALUE (cu);
6404 cu = GDB_INDEX_CU_VALUE (cu);
6405 /* Convert to TU number if it's for a type unit. */
6406 if (cu >= cu_list_elements / 2)
6407 printf ("%cT%lu", num_cus > 1 ? '\t' : ' ',
6408 (unsigned long) (cu - cu_list_elements / 2));
6410 printf ("%c%lu", num_cus > 1 ? '\t' : ' ', (unsigned long) cu);
6412 printf (" [%s, %s]",
6413 is_static ? _("static") : _("global"),
6414 get_gdb_index_symbol_kind_name (kind));
6426 /* Pre-allocate enough space for the CU/TU sets needed. */
6429 prealloc_cu_tu_list (unsigned int nshndx)
6431 if (shndx_pool == NULL)
6433 shndx_pool_size = nshndx;
6434 shndx_pool_used = 0;
6435 shndx_pool = (unsigned int *) xcmalloc (shndx_pool_size,
6436 sizeof (unsigned int));
6440 shndx_pool_size = shndx_pool_used + nshndx;
6441 shndx_pool = (unsigned int *) xcrealloc (shndx_pool, shndx_pool_size,
6442 sizeof (unsigned int));
6447 add_shndx_to_cu_tu_entry (unsigned int shndx)
6449 if (shndx_pool_used >= shndx_pool_size)
6451 error (_("Internal error: out of space in the shndx pool.\n"));
6454 shndx_pool [shndx_pool_used++] = shndx;
6458 end_cu_tu_entry (void)
6460 if (shndx_pool_used >= shndx_pool_size)
6462 error (_("Internal error: out of space in the shndx pool.\n"));
6465 shndx_pool [shndx_pool_used++] = 0;
6468 /* Return the short name of a DWARF section given by a DW_SECT enumerator. */
6471 get_DW_SECT_short_name (unsigned int dw_sect)
6473 static char buf[16];
6481 case DW_SECT_ABBREV:
6487 case DW_SECT_STR_OFFSETS:
6489 case DW_SECT_MACINFO:
6497 snprintf (buf, sizeof (buf), "%d", dw_sect);
6501 /* Process a CU or TU index. If DO_DISPLAY is true, print the contents.
6502 These sections are extensions for Fission.
6503 See http://gcc.gnu.org/wiki/DebugFissionDWP. */
6506 process_cu_tu_index (struct dwarf_section *section, int do_display)
6508 unsigned char *phdr = section->start;
6509 unsigned char *limit = phdr + section->size;
6510 unsigned char *phash;
6511 unsigned char *pindex;
6512 unsigned char *ppool;
6513 unsigned int version;
6514 unsigned int ncols = 0;
6516 unsigned int nslots;
6519 dwarf_vma signature_high;
6520 dwarf_vma signature_low;
6523 version = byte_get (phdr, 4);
6525 ncols = byte_get (phdr + 4, 4);
6526 nused = byte_get (phdr + 8, 4);
6527 nslots = byte_get (phdr + 12, 4);
6529 pindex = phash + nslots * 8;
6530 ppool = pindex + nslots * 4;
6534 printf (_("Contents of the %s section:\n\n"), section->name);
6535 printf (_(" Version: %d\n"), version);
6537 printf (_(" Number of columns: %d\n"), ncols);
6538 printf (_(" Number of used entries: %d\n"), nused);
6539 printf (_(" Number of slots: %d\n\n"), nslots);
6544 warn (_("Section %s too small for %d hash table entries\n"),
6545 section->name, nslots);
6552 prealloc_cu_tu_list ((limit - ppool) / 4);
6553 for (i = 0; i < nslots; i++)
6555 unsigned char *shndx_list;
6558 byte_get_64 (phash, &signature_high, &signature_low);
6559 if (signature_high != 0 || signature_low != 0)
6561 j = byte_get (pindex, 4);
6562 shndx_list = ppool + j * 4;
6564 printf (_(" [%3d] Signature: 0x%s Sections: "),
6565 i, dwarf_vmatoa64 (signature_high, signature_low,
6566 buf, sizeof (buf)));
6569 if (shndx_list >= limit)
6571 warn (_("Section %s too small for shndx pool\n"),
6575 shndx = byte_get (shndx_list, 4);
6579 printf (" %d", shndx);
6581 add_shndx_to_cu_tu_entry (shndx);
6593 else if (version == 2)
6596 unsigned int dw_sect;
6597 unsigned char *ph = phash;
6598 unsigned char *pi = pindex;
6599 unsigned char *poffsets = ppool + ncols * 4;
6600 unsigned char *psizes = poffsets + nused * ncols * 4;
6601 unsigned char *pend = psizes + nused * ncols * 4;
6602 bfd_boolean is_tu_index;
6603 struct cu_tu_set *this_set = NULL;
6605 unsigned char *prow;
6607 is_tu_index = strcmp (section->name, ".debug_tu_index") == 0;
6611 warn (_("Section %s too small for offset and size tables\n"),
6618 printf (_(" Offset table\n"));
6619 printf (" slot %-16s ",
6620 is_tu_index ? _("signature") : _("dwo_id"));
6627 tu_sets = xcmalloc (nused, sizeof (struct cu_tu_set));
6633 cu_sets = xcmalloc (nused, sizeof (struct cu_tu_set));
6639 for (j = 0; j < ncols; j++)
6641 dw_sect = byte_get (ppool + j * 4, 4);
6642 printf (" %8s", get_DW_SECT_short_name (dw_sect));
6646 for (i = 0; i < nslots; i++)
6648 byte_get_64 (ph, &signature_high, &signature_low);
6649 row = byte_get (pi, 4);
6653 memcpy (&this_set[row - 1].signature, ph, sizeof (uint64_t));
6654 prow = poffsets + (row - 1) * ncols * 4;
6656 printf (_(" [%3d] 0x%s"),
6657 i, dwarf_vmatoa64 (signature_high, signature_low,
6658 buf, sizeof (buf)));
6659 for (j = 0; j < ncols; j++)
6661 val = byte_get (prow + j * 4, 4);
6663 printf (" %8d", val);
6666 dw_sect = byte_get (ppool + j * 4, 4);
6667 this_set [row - 1].section_offsets [dw_sect] = val;
6682 printf (_(" Size table\n"));
6683 printf (" slot %-16s ",
6684 is_tu_index ? _("signature") : _("dwo_id"));
6686 for (j = 0; j < ncols; j++)
6688 val = byte_get (ppool + j * 4, 4);
6690 printf (" %8s", get_DW_SECT_short_name (val));
6694 for (i = 0; i < nslots; i++)
6696 byte_get_64 (ph, &signature_high, &signature_low);
6697 row = byte_get (pi, 4);
6700 prow = psizes + (row - 1) * ncols * 4;
6702 printf (_(" [%3d] 0x%s"),
6703 i, dwarf_vmatoa64 (signature_high, signature_low,
6704 buf, sizeof (buf)));
6705 for (j = 0; j < ncols; j++)
6707 val = byte_get (prow + j * 4, 4);
6709 printf (" %8d", val);
6712 dw_sect = byte_get (ppool + j * 4, 4);
6713 this_set [row - 1].section_sizes [dw_sect] = val;
6723 else if (do_display)
6724 printf (_(" Unsupported version\n"));
6732 /* Load the CU and TU indexes if present. This will build a list of
6733 section sets that we can use to associate a .debug_info.dwo section
6734 with its associated .debug_abbrev.dwo section in a .dwp file. */
6737 load_cu_tu_indexes (void *file)
6739 /* If we have already loaded (or tried to load) the CU and TU indexes
6740 then do not bother to repeat the task. */
6741 if (cu_tu_indexes_read)
6744 if (load_debug_section (dwp_cu_index, file))
6745 process_cu_tu_index (&debug_displays [dwp_cu_index].section, 0);
6747 if (load_debug_section (dwp_tu_index, file))
6748 process_cu_tu_index (&debug_displays [dwp_tu_index].section, 0);
6750 cu_tu_indexes_read = 1;
6753 /* Find the set of sections that includes section SHNDX. */
6756 find_cu_tu_set (void *file, unsigned int shndx)
6760 load_cu_tu_indexes (file);
6762 /* Find SHNDX in the shndx pool. */
6763 for (i = 0; i < shndx_pool_used; i++)
6764 if (shndx_pool [i] == shndx)
6767 if (i >= shndx_pool_used)
6770 /* Now backup to find the first entry in the set. */
6771 while (i > 0 && shndx_pool [i - 1] != 0)
6774 return shndx_pool + i;
6777 /* Display a .debug_cu_index or .debug_tu_index section. */
6780 display_cu_index (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED)
6782 return process_cu_tu_index (section, 1);
6786 display_debug_not_supported (struct dwarf_section *section,
6787 void *file ATTRIBUTE_UNUSED)
6789 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
6796 cmalloc (size_t nmemb, size_t size)
6798 /* Check for overflow. */
6799 if (nmemb >= ~(size_t) 0 / size)
6802 return malloc (nmemb * size);
6806 xcmalloc (size_t nmemb, size_t size)
6808 /* Check for overflow. */
6809 if (nmemb >= ~(size_t) 0 / size)
6812 return xmalloc (nmemb * size);
6816 xcrealloc (void *ptr, size_t nmemb, size_t size)
6818 /* Check for overflow. */
6819 if (nmemb >= ~(size_t) 0 / size)
6822 return xrealloc (ptr, nmemb * size);
6826 free_debug_memory (void)
6832 for (i = 0; i < max; i++)
6833 free_debug_section ((enum dwarf_section_display_enum) i);
6835 if (debug_information != NULL)
6837 if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE)
6839 for (i = 0; i < num_debug_info_entries; i++)
6841 if (!debug_information [i].max_loc_offsets)
6843 free (debug_information [i].loc_offsets);
6844 free (debug_information [i].have_frame_base);
6846 if (!debug_information [i].max_range_lists)
6847 free (debug_information [i].range_lists);
6851 free (debug_information);
6852 debug_information = NULL;
6853 num_debug_info_entries = 0;
6858 dwarf_select_sections_by_names (const char *names)
6862 const char * option;
6866 debug_dump_long_opts;
6868 static const debug_dump_long_opts opts_table [] =
6870 /* Please keep this table alpha- sorted. */
6871 { "Ranges", & do_debug_ranges, 1 },
6872 { "abbrev", & do_debug_abbrevs, 1 },
6873 { "addr", & do_debug_addr, 1 },
6874 { "aranges", & do_debug_aranges, 1 },
6875 { "cu_index", & do_debug_cu_index, 1 },
6876 { "decodedline", & do_debug_lines, FLAG_DEBUG_LINES_DECODED },
6877 { "frames", & do_debug_frames, 1 },
6878 { "frames-interp", & do_debug_frames_interp, 1 },
6879 /* The special .gdb_index section. */
6880 { "gdb_index", & do_gdb_index, 1 },
6881 { "info", & do_debug_info, 1 },
6882 { "line", & do_debug_lines, FLAG_DEBUG_LINES_RAW }, /* For backwards compatibility. */
6883 { "loc", & do_debug_loc, 1 },
6884 { "macro", & do_debug_macinfo, 1 },
6885 { "pubnames", & do_debug_pubnames, 1 },
6886 { "pubtypes", & do_debug_pubtypes, 1 },
6887 /* This entry is for compatability
6888 with earlier versions of readelf. */
6889 { "ranges", & do_debug_aranges, 1 },
6890 { "rawline", & do_debug_lines, FLAG_DEBUG_LINES_RAW },
6891 { "str", & do_debug_str, 1 },
6892 /* These trace_* sections are used by Itanium VMS. */
6893 { "trace_abbrev", & do_trace_abbrevs, 1 },
6894 { "trace_aranges", & do_trace_aranges, 1 },
6895 { "trace_info", & do_trace_info, 1 },
6904 const debug_dump_long_opts * entry;
6906 for (entry = opts_table; entry->option; entry++)
6908 size_t len = strlen (entry->option);
6910 if (strncmp (p, entry->option, len) == 0
6911 && (p[len] == ',' || p[len] == '\0'))
6913 * entry->variable |= entry->val;
6915 /* The --debug-dump=frames-interp option also
6916 enables the --debug-dump=frames option. */
6917 if (do_debug_frames_interp)
6918 do_debug_frames = 1;
6925 if (entry->option == NULL)
6927 warn (_("Unrecognized debug option '%s'\n"), p);
6928 p = strchr (p, ',');
6939 dwarf_select_sections_by_letters (const char *letters)
6941 unsigned int lindex = 0;
6943 while (letters[lindex])
6944 switch (letters[lindex++])
6951 do_debug_abbrevs = 1;
6955 do_debug_lines |= FLAG_DEBUG_LINES_RAW;
6959 do_debug_lines |= FLAG_DEBUG_LINES_DECODED;
6963 do_debug_pubnames = 1;
6967 do_debug_pubtypes = 1;
6971 do_debug_aranges = 1;
6975 do_debug_ranges = 1;
6979 do_debug_frames_interp = 1;
6981 do_debug_frames = 1;
6985 do_debug_macinfo = 1;
6997 warn (_("Unrecognized debug option '%s'\n"), optarg);
7003 dwarf_select_sections_all (void)
7006 do_debug_abbrevs = 1;
7007 do_debug_lines = FLAG_DEBUG_LINES_RAW;
7008 do_debug_pubnames = 1;
7009 do_debug_pubtypes = 1;
7010 do_debug_aranges = 1;
7011 do_debug_ranges = 1;
7012 do_debug_frames = 1;
7013 do_debug_macinfo = 1;
7018 do_trace_abbrevs = 1;
7019 do_trace_aranges = 1;
7021 do_debug_cu_index = 1;
7024 struct dwarf_section_display debug_displays[] =
7026 { { ".debug_abbrev", ".zdebug_abbrev", NULL, NULL, 0, 0, 0 },
7027 display_debug_abbrev, &do_debug_abbrevs, 0 },
7028 { { ".debug_aranges", ".zdebug_aranges", NULL, NULL, 0, 0, 0 },
7029 display_debug_aranges, &do_debug_aranges, 1 },
7030 { { ".debug_frame", ".zdebug_frame", NULL, NULL, 0, 0, 0 },
7031 display_debug_frames, &do_debug_frames, 1 },
7032 { { ".debug_info", ".zdebug_info", NULL, NULL, 0, 0, abbrev },
7033 display_debug_info, &do_debug_info, 1 },
7034 { { ".debug_line", ".zdebug_line", NULL, NULL, 0, 0, 0 },
7035 display_debug_lines, &do_debug_lines, 1 },
7036 { { ".debug_pubnames", ".zdebug_pubnames", NULL, NULL, 0, 0, 0 },
7037 display_debug_pubnames, &do_debug_pubnames, 0 },
7038 { { ".debug_gnu_pubnames", ".zdebug_gnu_pubnames", NULL, NULL, 0, 0, 0 },
7039 display_debug_gnu_pubnames, &do_debug_pubnames, 0 },
7040 { { ".eh_frame", "", NULL, NULL, 0, 0, 0 },
7041 display_debug_frames, &do_debug_frames, 1 },
7042 { { ".debug_macinfo", ".zdebug_macinfo", NULL, NULL, 0, 0, 0 },
7043 display_debug_macinfo, &do_debug_macinfo, 0 },
7044 { { ".debug_macro", ".zdebug_macro", NULL, NULL, 0, 0, 0 },
7045 display_debug_macro, &do_debug_macinfo, 1 },
7046 { { ".debug_str", ".zdebug_str", NULL, NULL, 0, 0, 0 },
7047 display_debug_str, &do_debug_str, 0 },
7048 { { ".debug_loc", ".zdebug_loc", NULL, NULL, 0, 0, 0 },
7049 display_debug_loc, &do_debug_loc, 1 },
7050 { { ".debug_pubtypes", ".zdebug_pubtypes", NULL, NULL, 0, 0, 0 },
7051 display_debug_pubnames, &do_debug_pubtypes, 0 },
7052 { { ".debug_gnu_pubtypes", ".zdebug_gnu_pubtypes", NULL, NULL, 0, 0, 0 },
7053 display_debug_gnu_pubnames, &do_debug_pubtypes, 0 },
7054 { { ".debug_ranges", ".zdebug_ranges", NULL, NULL, 0, 0, 0 },
7055 display_debug_ranges, &do_debug_ranges, 1 },
7056 { { ".debug_static_func", ".zdebug_static_func", NULL, NULL, 0, 0, 0 },
7057 display_debug_not_supported, NULL, 0 },
7058 { { ".debug_static_vars", ".zdebug_static_vars", NULL, NULL, 0, 0, 0 },
7059 display_debug_not_supported, NULL, 0 },
7060 { { ".debug_types", ".zdebug_types", NULL, NULL, 0, 0, abbrev },
7061 display_debug_types, &do_debug_info, 1 },
7062 { { ".debug_weaknames", ".zdebug_weaknames", NULL, NULL, 0, 0, 0 },
7063 display_debug_not_supported, NULL, 0 },
7064 { { ".gdb_index", "", NULL, NULL, 0, 0, 0 },
7065 display_gdb_index, &do_gdb_index, 0 },
7066 { { ".trace_info", "", NULL, NULL, 0, 0, trace_abbrev },
7067 display_trace_info, &do_trace_info, 1 },
7068 { { ".trace_abbrev", "", NULL, NULL, 0, 0, 0 },
7069 display_debug_abbrev, &do_trace_abbrevs, 0 },
7070 { { ".trace_aranges", "", NULL, NULL, 0, 0, 0 },
7071 display_debug_aranges, &do_trace_aranges, 0 },
7072 { { ".debug_info.dwo", ".zdebug_info.dwo", NULL, NULL, 0, 0, abbrev_dwo },
7073 display_debug_info, &do_debug_info, 1 },
7074 { { ".debug_abbrev.dwo", ".zdebug_abbrev.dwo", NULL, NULL, 0, 0, 0 },
7075 display_debug_abbrev, &do_debug_abbrevs, 0 },
7076 { { ".debug_types.dwo", ".zdebug_types.dwo", NULL, NULL, 0, 0, abbrev_dwo },
7077 display_debug_types, &do_debug_info, 1 },
7078 { { ".debug_line.dwo", ".zdebug_line.dwo", NULL, NULL, 0, 0, 0 },
7079 display_debug_lines, &do_debug_lines, 1 },
7080 { { ".debug_loc.dwo", ".zdebug_loc.dwo", NULL, NULL, 0, 0, 0 },
7081 display_debug_loc, &do_debug_loc, 1 },
7082 { { ".debug_macro.dwo", ".zdebug_macro.dwo", NULL, NULL, 0, 0, 0 },
7083 display_debug_macro, &do_debug_macinfo, 1 },
7084 { { ".debug_macinfo.dwo", ".zdebug_macinfo.dwo", NULL, NULL, 0, 0, 0 },
7085 display_debug_macinfo, &do_debug_macinfo, 0 },
7086 { { ".debug_str.dwo", ".zdebug_str.dwo", NULL, NULL, 0, 0, 0 },
7087 display_debug_str, &do_debug_str, 1 },
7088 { { ".debug_str_offsets", ".zdebug_str_offsets", NULL, NULL, 0, 0, 0 },
7089 display_debug_str_offsets, NULL, 0 },
7090 { { ".debug_str_offsets.dwo", ".zdebug_str_offsets.dwo", NULL, NULL, 0, 0, 0 },
7091 display_debug_str_offsets, NULL, 0 },
7092 { { ".debug_addr", ".zdebug_addr", NULL, NULL, 0, 0, 0 },
7093 display_debug_addr, &do_debug_addr, 1 },
7094 { { ".debug_cu_index", "", NULL, NULL, 0, 0, 0 },
7095 display_cu_index, &do_debug_cu_index, 0 },
7096 { { ".debug_tu_index", "", NULL, NULL, 0, 0, 0 },
7097 display_cu_index, &do_debug_cu_index, 0 },