1 /* dwarf.c -- display DWARF contents of a BFD binary file
2 Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 Free Software Foundation, Inc.
5 This file is part of GNU Binutils.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
23 #include "libiberty.h"
25 #include "bfd_stdint.h"
28 #include "elf/common.h"
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;
66 int dwarf_cutoff_level = -1;
67 unsigned long dwarf_start_die;
69 /* Values for do_debug_lines. */
70 #define FLAG_DEBUG_LINES_RAW 1
71 #define FLAG_DEBUG_LINES_DECODED 2
74 size_of_encoded_value (int encoding)
76 switch (encoding & 0x7)
79 case 0: return eh_addr_size;
87 get_encoded_value (unsigned char *data,
89 struct dwarf_section *section)
91 int size = size_of_encoded_value (encoding);
94 if (encoding & DW_EH_PE_signed)
95 val = byte_get_signed (data, size);
97 val = byte_get (data, size);
99 if ((encoding & 0x70) == DW_EH_PE_pcrel)
100 val += section->address + (data - section->start);
104 /* Print a dwarf_vma value (typically an address, offset or length) in
105 hexadecimal format, followed by a space. The length of the value (and
106 hence the precision displayed) is determined by the byte_size parameter. */
109 print_dwarf_vma (dwarf_vma val, unsigned byte_size)
111 static char buff[18];
114 /* Printf does not have a way of specifiying a maximum field width for an
115 integer value, so we print the full value into a buffer and then select
116 the precision we need. */
117 #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
119 snprintf (buff, sizeof (buff), "%16.16llx ", val);
121 snprintf (buff, sizeof (buff), "%016I64x ", val);
124 snprintf (buff, sizeof (buff), "%16.16lx ", val);
129 if (byte_size > 0 && byte_size <= 8)
130 offset = 16 - 2 * byte_size;
132 error (_("Wrong size in print_dwarf_vma"));
135 fputs (buff + offset, stdout);
138 #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
140 #define DWARF_VMA_FMT "ll"
142 #define DWARF_VMA_FMT "I64"
145 #define DWARF_VMA_FMT "l"
149 dwarf_vmatoa (const char *fmtch, dwarf_vma value)
151 /* As dwarf_vmatoa is used more then once in a printf call
152 for output, we are cycling through an fixed array of pointers
153 for return address. */
154 static int buf_pos = 0;
155 static struct dwarf_vmatoa_buf
162 sprintf (fmt, "%%%s%s", DWARF_VMA_FMT, fmtch);
164 ret = buf[buf_pos++].place;
165 buf_pos %= ARRAY_SIZE (buf);
167 snprintf (ret, sizeof (buf[0].place), fmt, value);
172 /* Format a 64-bit value, given as two 32-bit values, in hex.
173 For reentrancy, this uses a buffer provided by the caller. */
176 dwarf_vmatoa64 (dwarf_vma hvalue, dwarf_vma lvalue, char *buf,
177 unsigned int buf_len)
182 snprintf (buf, buf_len, "%" DWARF_VMA_FMT "x", lvalue);
185 len = snprintf (buf, buf_len, "%" DWARF_VMA_FMT "x", hvalue);
186 snprintf (buf + len, buf_len - len,
187 "%08" DWARF_VMA_FMT "x", lvalue);
194 read_leb128 (unsigned char *data, unsigned int *length_return, int sign)
196 dwarf_vma result = 0;
197 unsigned int num_read = 0;
198 unsigned int shift = 0;
206 result |= ((dwarf_vma) (byte & 0x7f)) << shift;
213 if (length_return != NULL)
214 *length_return = num_read;
216 if (sign && (shift < 8 * sizeof (result)) && (byte & 0x40))
217 result |= -1L << shift;
222 /* Create a signed version to avoid painful typecasts. */
223 static dwarf_signed_vma
224 read_sleb128 (unsigned char *data, unsigned int *length_return)
226 return (dwarf_signed_vma) read_leb128 (data, length_return, 1);
229 typedef struct State_Machine_Registers
237 unsigned char op_index;
238 unsigned char end_sequence;
239 /* This variable hold the number of the last entry seen
240 in the File Table. */
241 unsigned int last_file_entry;
244 static SMR state_machine_regs;
247 reset_state_machine (int is_stmt)
249 state_machine_regs.address = 0;
250 state_machine_regs.op_index = 0;
251 state_machine_regs.file = 1;
252 state_machine_regs.line = 1;
253 state_machine_regs.column = 0;
254 state_machine_regs.is_stmt = is_stmt;
255 state_machine_regs.basic_block = 0;
256 state_machine_regs.end_sequence = 0;
257 state_machine_regs.last_file_entry = 0;
260 /* Handled an extend line op.
261 Returns the number of bytes read. */
264 process_extended_line_op (unsigned char *data, int is_stmt)
266 unsigned char op_code;
267 unsigned int bytes_read;
271 unsigned char *orig_data = data;
273 len = read_leb128 (data, & bytes_read, 0);
278 warn (_("badly formed extended line op encountered!\n"));
285 printf (_(" Extended opcode %d: "), op_code);
289 case DW_LNE_end_sequence:
290 printf (_("End of Sequence\n\n"));
291 reset_state_machine (is_stmt);
294 case DW_LNE_set_address:
295 adr = byte_get (data, len - bytes_read - 1);
296 printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr));
297 state_machine_regs.address = adr;
298 state_machine_regs.op_index = 0;
301 case DW_LNE_define_file:
302 printf (_("define new File Table entry\n"));
303 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
305 printf (" %d\t", ++state_machine_regs.last_file_entry);
307 data += strlen ((char *) data) + 1;
308 printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
310 printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
312 printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
315 if ((unsigned int) (data - orig_data) != len)
316 printf (_(" [Bad opcode length]"));
320 case DW_LNE_set_discriminator:
321 printf (_("set Discriminator to %s\n"),
322 dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
326 case DW_LNE_HP_negate_is_UV_update:
327 printf ("DW_LNE_HP_negate_is_UV_update\n");
329 case DW_LNE_HP_push_context:
330 printf ("DW_LNE_HP_push_context\n");
332 case DW_LNE_HP_pop_context:
333 printf ("DW_LNE_HP_pop_context\n");
335 case DW_LNE_HP_set_file_line_column:
336 printf ("DW_LNE_HP_set_file_line_column\n");
338 case DW_LNE_HP_set_routine_name:
339 printf ("DW_LNE_HP_set_routine_name\n");
341 case DW_LNE_HP_set_sequence:
342 printf ("DW_LNE_HP_set_sequence\n");
344 case DW_LNE_HP_negate_post_semantics:
345 printf ("DW_LNE_HP_negate_post_semantics\n");
347 case DW_LNE_HP_negate_function_exit:
348 printf ("DW_LNE_HP_negate_function_exit\n");
350 case DW_LNE_HP_negate_front_end_logical:
351 printf ("DW_LNE_HP_negate_front_end_logical\n");
353 case DW_LNE_HP_define_proc:
354 printf ("DW_LNE_HP_define_proc\n");
356 case DW_LNE_HP_source_file_correlation:
358 unsigned char *edata = data + len - bytes_read - 1;
360 printf ("DW_LNE_HP_source_file_correlation\n");
366 opc = read_leb128 (data, & bytes_read, 0);
371 case DW_LNE_HP_SFC_formfeed:
372 printf (" DW_LNE_HP_SFC_formfeed\n");
374 case DW_LNE_HP_SFC_set_listing_line:
375 printf (" DW_LNE_HP_SFC_set_listing_line (%s)\n",
377 read_leb128 (data, & bytes_read, 0)));
380 case DW_LNE_HP_SFC_associate:
381 printf (" DW_LNE_HP_SFC_associate ");
384 read_leb128 (data, & bytes_read, 0)));
388 read_leb128 (data, & bytes_read, 0)));
392 read_leb128 (data, & bytes_read, 0)));
396 printf (_(" UNKNOWN DW_LNE_HP_SFC opcode (%u)\n"), opc);
406 unsigned int rlen = len - bytes_read - 1;
408 if (op_code >= DW_LNE_lo_user
409 /* The test against DW_LNW_hi_user is redundant due to
410 the limited range of the unsigned char data type used
412 /*&& op_code <= DW_LNE_hi_user*/)
413 printf (_("user defined: "));
415 printf (_("UNKNOWN: "));
416 printf (_("length %d ["), rlen);
418 printf (" %02x", *data++);
428 fetch_indirect_string (dwarf_vma offset)
430 struct dwarf_section *section = &debug_displays [str].section;
432 if (section->start == NULL)
433 return _("<no .debug_str section>");
435 /* DWARF sections under Mach-O have non-zero addresses. */
436 offset -= section->address;
437 if (offset > section->size)
439 warn (_("DW_FORM_strp offset too big: %s\n"),
440 dwarf_vmatoa ("x", offset));
441 return _("<offset is too big>");
444 return (const char *) section->start + offset;
447 /* FIXME: There are better and more efficient ways to handle
448 these structures. For now though, I just want something that
449 is simple to implement. */
450 typedef struct abbrev_attr
452 unsigned long attribute;
454 struct abbrev_attr *next;
458 typedef struct abbrev_entry
463 struct abbrev_attr *first_attr;
464 struct abbrev_attr *last_attr;
465 struct abbrev_entry *next;
469 static abbrev_entry *first_abbrev = NULL;
470 static abbrev_entry *last_abbrev = NULL;
477 for (abbrv = first_abbrev; abbrv;)
479 abbrev_entry *next_abbrev = abbrv->next;
482 for (attr = abbrv->first_attr; attr;)
484 abbrev_attr *next_attr = attr->next;
494 last_abbrev = first_abbrev = NULL;
498 add_abbrev (unsigned long number, unsigned long tag, int children)
502 entry = (abbrev_entry *) malloc (sizeof (*entry));
507 entry->entry = number;
509 entry->children = children;
510 entry->first_attr = NULL;
511 entry->last_attr = NULL;
514 if (first_abbrev == NULL)
515 first_abbrev = entry;
517 last_abbrev->next = entry;
523 add_abbrev_attr (unsigned long attribute, unsigned long form)
527 attr = (abbrev_attr *) malloc (sizeof (*attr));
532 attr->attribute = attribute;
536 if (last_abbrev->first_attr == NULL)
537 last_abbrev->first_attr = attr;
539 last_abbrev->last_attr->next = attr;
541 last_abbrev->last_attr = attr;
544 /* Processes the (partial) contents of a .debug_abbrev section.
545 Returns NULL if the end of the section was encountered.
546 Returns the address after the last byte read if the end of
547 an abbreviation set was found. */
549 static unsigned char *
550 process_abbrev_section (unsigned char *start, unsigned char *end)
552 if (first_abbrev != NULL)
557 unsigned int bytes_read;
560 unsigned long attribute;
563 entry = read_leb128 (start, & bytes_read, 0);
566 /* A single zero is supposed to end the section according
567 to the standard. If there's more, then signal that to
570 return start == end ? NULL : start;
572 tag = read_leb128 (start, & bytes_read, 0);
577 add_abbrev (entry, tag, children);
583 attribute = read_leb128 (start, & bytes_read, 0);
586 form = read_leb128 (start, & bytes_read, 0);
590 add_abbrev_attr (attribute, form);
592 while (attribute != 0);
599 get_TAG_name (unsigned long tag)
601 const char *name = get_DW_TAG_name (tag);
605 static char buffer[100];
607 snprintf (buffer, sizeof (buffer), _("Unknown TAG value: %lx"), tag);
615 get_FORM_name (unsigned long form)
617 const char *name = get_DW_FORM_name (form);
621 static char buffer[100];
623 snprintf (buffer, sizeof (buffer), _("Unknown FORM value: %lx"), form);
630 static unsigned char *
631 display_block (unsigned char *data, dwarf_vma length)
633 printf (_(" %s byte block: "), dwarf_vmatoa ("u", length));
636 printf ("%lx ", (unsigned long) byte_get (data++, 1));
642 decode_location_expression (unsigned char * data,
643 unsigned int pointer_size,
644 unsigned int offset_size,
648 struct dwarf_section * section)
651 unsigned int bytes_read;
653 unsigned char *end = data + length;
654 int need_frame_base = 0;
663 printf ("DW_OP_addr: %s",
664 dwarf_vmatoa ("x", byte_get (data, pointer_size)));
665 data += pointer_size;
668 printf ("DW_OP_deref");
671 printf ("DW_OP_const1u: %lu", (unsigned long) byte_get (data++, 1));
674 printf ("DW_OP_const1s: %ld", (long) byte_get_signed (data++, 1));
677 printf ("DW_OP_const2u: %lu", (unsigned long) byte_get (data, 2));
681 printf ("DW_OP_const2s: %ld", (long) byte_get_signed (data, 2));
685 printf ("DW_OP_const4u: %lu", (unsigned long) byte_get (data, 4));
689 printf ("DW_OP_const4s: %ld", (long) byte_get_signed (data, 4));
693 printf ("DW_OP_const8u: %lu %lu", (unsigned long) byte_get (data, 4),
694 (unsigned long) byte_get (data + 4, 4));
698 printf ("DW_OP_const8s: %ld %ld", (long) byte_get (data, 4),
699 (long) byte_get (data + 4, 4));
703 printf ("DW_OP_constu: %s",
704 dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0)));
708 printf ("DW_OP_consts: %s",
709 dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read)));
713 printf ("DW_OP_dup");
716 printf ("DW_OP_drop");
719 printf ("DW_OP_over");
722 printf ("DW_OP_pick: %ld", (unsigned long) byte_get (data++, 1));
725 printf ("DW_OP_swap");
728 printf ("DW_OP_rot");
731 printf ("DW_OP_xderef");
734 printf ("DW_OP_abs");
737 printf ("DW_OP_and");
740 printf ("DW_OP_div");
743 printf ("DW_OP_minus");
746 printf ("DW_OP_mod");
749 printf ("DW_OP_mul");
752 printf ("DW_OP_neg");
755 printf ("DW_OP_not");
761 printf ("DW_OP_plus");
763 case DW_OP_plus_uconst:
764 printf ("DW_OP_plus_uconst: %s",
765 dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0)));
769 printf ("DW_OP_shl");
772 printf ("DW_OP_shr");
775 printf ("DW_OP_shra");
778 printf ("DW_OP_xor");
781 printf ("DW_OP_bra: %ld", (long) byte_get_signed (data, 2));
803 printf ("DW_OP_skip: %ld", (long) byte_get_signed (data, 2));
839 printf ("DW_OP_lit%d", op - DW_OP_lit0);
874 printf ("DW_OP_reg%d (%s)", op - DW_OP_reg0,
875 regname (op - DW_OP_reg0, 1));
910 printf ("DW_OP_breg%d (%s): %s",
912 regname (op - DW_OP_breg0, 1),
913 dwarf_vmatoa ("d", (dwarf_signed_vma)
914 read_leb128 (data, &bytes_read, 1)));
919 uvalue = read_leb128 (data, &bytes_read, 0);
921 printf ("DW_OP_regx: %s (%s)",
922 dwarf_vmatoa ("u", uvalue), regname (uvalue, 1));
926 printf ("DW_OP_fbreg: %s",
927 dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read)));
931 uvalue = read_leb128 (data, &bytes_read, 0);
933 printf ("DW_OP_bregx: %s (%s) %s",
934 dwarf_vmatoa ("u", uvalue), regname (uvalue, 1),
935 dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read)));
939 printf ("DW_OP_piece: %s",
940 dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0)));
943 case DW_OP_deref_size:
944 printf ("DW_OP_deref_size: %ld", (long) byte_get (data++, 1));
946 case DW_OP_xderef_size:
947 printf ("DW_OP_xderef_size: %ld", (long) byte_get (data++, 1));
950 printf ("DW_OP_nop");
953 /* DWARF 3 extensions. */
954 case DW_OP_push_object_address:
955 printf ("DW_OP_push_object_address");
958 /* XXX: Strictly speaking for 64-bit DWARF3 files
959 this ought to be an 8-byte wide computation. */
960 printf ("DW_OP_call2: <0x%s>",
961 dwarf_vmatoa ("x", (dwarf_signed_vma) byte_get (data, 2)
966 /* XXX: Strictly speaking for 64-bit DWARF3 files
967 this ought to be an 8-byte wide computation. */
968 printf ("DW_OP_call4: <0x%s>",
969 dwarf_vmatoa ("x", (dwarf_signed_vma) byte_get (data, 4)
974 /* XXX: Strictly speaking for 64-bit DWARF3 files
975 this ought to be an 8-byte wide computation. */
976 if (dwarf_version == -1)
978 printf (_("(DW_OP_call_ref in frame info)"));
979 /* No way to tell where the next op is, so just bail. */
980 return need_frame_base;
982 if (dwarf_version == 2)
984 printf ("DW_OP_call_ref: <0x%s>",
985 dwarf_vmatoa ("x", byte_get (data, pointer_size)));
986 data += pointer_size;
990 printf ("DW_OP_call_ref: <0x%s>",
991 dwarf_vmatoa ("x", byte_get (data, offset_size)));
995 case DW_OP_form_tls_address:
996 printf ("DW_OP_form_tls_address");
998 case DW_OP_call_frame_cfa:
999 printf ("DW_OP_call_frame_cfa");
1001 case DW_OP_bit_piece:
1002 printf ("DW_OP_bit_piece: ");
1003 printf (_("size: %s "),
1004 dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0)));
1006 printf (_("offset: %s "),
1007 dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0)));
1011 /* DWARF 4 extensions. */
1012 case DW_OP_stack_value:
1013 printf ("DW_OP_stack_value");
1016 case DW_OP_implicit_value:
1017 printf ("DW_OP_implicit_value");
1018 uvalue = read_leb128 (data, &bytes_read, 0);
1020 display_block (data, uvalue);
1024 /* GNU extensions. */
1025 case DW_OP_GNU_push_tls_address:
1026 printf (_("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown"));
1028 case DW_OP_GNU_uninit:
1029 printf ("DW_OP_GNU_uninit");
1030 /* FIXME: Is there data associated with this OP ? */
1032 case DW_OP_GNU_encoded_addr:
1038 addr = get_encoded_value (data, encoding, section);
1039 data += size_of_encoded_value (encoding);
1041 printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding);
1042 print_dwarf_vma (addr, pointer_size);
1045 case DW_OP_GNU_implicit_pointer:
1046 /* XXX: Strictly speaking for 64-bit DWARF3 files
1047 this ought to be an 8-byte wide computation. */
1048 if (dwarf_version == -1)
1050 printf (_("(DW_OP_GNU_implicit_pointer in frame info)"));
1051 /* No way to tell where the next op is, so just bail. */
1052 return need_frame_base;
1054 if (dwarf_version == 2)
1056 printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s",
1057 dwarf_vmatoa ("x", byte_get (data, pointer_size)),
1058 dwarf_vmatoa ("d", read_sleb128 (data + pointer_size,
1060 data += pointer_size + bytes_read;
1064 printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s",
1065 dwarf_vmatoa ("x", byte_get (data, offset_size)),
1066 dwarf_vmatoa ("d", read_sleb128 (data + offset_size,
1068 data += offset_size + bytes_read;
1071 case DW_OP_GNU_entry_value:
1072 uvalue = read_leb128 (data, &bytes_read, 0);
1074 printf ("DW_OP_GNU_entry_value: (");
1075 if (decode_location_expression (data, pointer_size, offset_size,
1076 dwarf_version, uvalue,
1077 cu_offset, section))
1078 need_frame_base = 1;
1082 case DW_OP_GNU_const_type:
1083 uvalue = read_leb128 (data, &bytes_read, 0);
1085 printf ("DW_OP_GNU_const_type: <0x%s> ",
1086 dwarf_vmatoa ("x", cu_offset + uvalue));
1087 uvalue = byte_get (data++, 1);
1088 display_block (data, uvalue);
1091 case DW_OP_GNU_regval_type:
1092 uvalue = read_leb128 (data, &bytes_read, 0);
1094 printf ("DW_OP_GNU_regval_type: %s (%s)",
1095 dwarf_vmatoa ("u", uvalue), regname (uvalue, 1));
1096 uvalue = read_leb128 (data, &bytes_read, 0);
1098 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue));
1100 case DW_OP_GNU_deref_type:
1101 printf ("DW_OP_GNU_deref_type: %ld", (long) byte_get (data++, 1));
1102 uvalue = read_leb128 (data, &bytes_read, 0);
1104 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue));
1106 case DW_OP_GNU_convert:
1107 uvalue = read_leb128 (data, &bytes_read, 0);
1109 printf ("DW_OP_GNU_convert <0x%s>",
1110 dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0));
1112 case DW_OP_GNU_reinterpret:
1113 uvalue = read_leb128 (data, &bytes_read, 0);
1115 printf ("DW_OP_GNU_reinterpret <0x%s>",
1116 dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0));
1118 case DW_OP_GNU_parameter_ref:
1119 printf ("DW_OP_GNU_parameter_ref: <0x%s>",
1120 dwarf_vmatoa ("x", cu_offset + byte_get (data, 4)));
1124 /* HP extensions. */
1125 case DW_OP_HP_is_value:
1126 printf ("DW_OP_HP_is_value");
1127 /* FIXME: Is there data associated with this OP ? */
1129 case DW_OP_HP_fltconst4:
1130 printf ("DW_OP_HP_fltconst4");
1131 /* FIXME: Is there data associated with this OP ? */
1133 case DW_OP_HP_fltconst8:
1134 printf ("DW_OP_HP_fltconst8");
1135 /* FIXME: Is there data associated with this OP ? */
1137 case DW_OP_HP_mod_range:
1138 printf ("DW_OP_HP_mod_range");
1139 /* FIXME: Is there data associated with this OP ? */
1141 case DW_OP_HP_unmod_range:
1142 printf ("DW_OP_HP_unmod_range");
1143 /* FIXME: Is there data associated with this OP ? */
1146 printf ("DW_OP_HP_tls");
1147 /* FIXME: Is there data associated with this OP ? */
1150 /* PGI (STMicroelectronics) extensions. */
1151 case DW_OP_PGI_omp_thread_num:
1152 /* Pushes the thread number for the current thread as it would be
1153 returned by the standard OpenMP library function:
1154 omp_get_thread_num(). The "current thread" is the thread for
1155 which the expression is being evaluated. */
1156 printf ("DW_OP_PGI_omp_thread_num");
1160 if (op >= DW_OP_lo_user
1161 && op <= DW_OP_hi_user)
1162 printf (_("(User defined location op)"));
1164 printf (_("(Unknown location op)"));
1165 /* No way to tell where the next op is, so just bail. */
1166 return need_frame_base;
1169 /* Separate the ops. */
1174 return need_frame_base;
1177 static unsigned char *
1178 read_and_display_attr_value (unsigned long attribute,
1180 unsigned char * data,
1181 dwarf_vma cu_offset,
1182 dwarf_vma pointer_size,
1183 dwarf_vma offset_size,
1185 debug_info * debug_info_p,
1187 struct dwarf_section * section)
1189 dwarf_vma uvalue = 0;
1190 unsigned char *block_start = NULL;
1191 unsigned char * orig_data = data;
1192 unsigned int bytes_read;
1199 case DW_FORM_ref_addr:
1200 if (dwarf_version == 2)
1202 uvalue = byte_get (data, pointer_size);
1203 data += pointer_size;
1205 else if (dwarf_version == 3 || dwarf_version == 4)
1207 uvalue = byte_get (data, offset_size);
1208 data += offset_size;
1211 error (_("Internal error: DWARF version is not 2, 3 or 4.\n"));
1216 uvalue = byte_get (data, pointer_size);
1217 data += pointer_size;
1221 case DW_FORM_sec_offset:
1222 uvalue = byte_get (data, offset_size);
1223 data += offset_size;
1226 case DW_FORM_flag_present:
1233 uvalue = byte_get (data++, 1);
1238 uvalue = byte_get (data, 2);
1244 uvalue = byte_get (data, 4);
1249 uvalue = read_leb128 (data, & bytes_read, 1);
1253 case DW_FORM_ref_udata:
1255 uvalue = read_leb128 (data, & bytes_read, 0);
1259 case DW_FORM_indirect:
1260 form = read_leb128 (data, & bytes_read, 0);
1263 printf (" %s", get_FORM_name (form));
1264 return read_and_display_attr_value (attribute, form, data,
1265 cu_offset, pointer_size,
1266 offset_size, dwarf_version,
1267 debug_info_p, do_loc,
1273 case DW_FORM_ref_addr:
1275 printf (" <0x%s>", dwarf_vmatoa ("x",uvalue));
1281 case DW_FORM_ref_udata:
1283 printf (" <0x%s>", dwarf_vmatoa ("x", uvalue + cu_offset));
1288 case DW_FORM_sec_offset:
1290 printf (" 0x%s", dwarf_vmatoa ("x", uvalue));
1293 case DW_FORM_flag_present:
1300 printf (" %s", dwarf_vmatoa ("d", uvalue));
1307 dwarf_vma high_bits;
1310 byte_get_64 (data, &high_bits, &uvalue);
1312 dwarf_vmatoa64 (high_bits, uvalue, buf, sizeof (buf)));
1314 if ((do_loc || do_debug_loc || do_debug_ranges)
1315 && num_debug_info_entries == 0)
1317 if (sizeof (uvalue) == 8)
1318 uvalue = byte_get (data, 8);
1320 error (_("DW_FORM_data8 is unsupported when sizeof (dwarf_vma) != 8\n"));
1325 case DW_FORM_string:
1327 printf (" %s", data);
1328 data += strlen ((char *) data) + 1;
1332 case DW_FORM_exprloc:
1333 uvalue = read_leb128 (data, & bytes_read, 0);
1334 block_start = data + bytes_read;
1336 data = block_start + uvalue;
1338 data = display_block (block_start, uvalue);
1341 case DW_FORM_block1:
1342 uvalue = byte_get (data, 1);
1343 block_start = data + 1;
1345 data = block_start + uvalue;
1347 data = display_block (block_start, uvalue);
1350 case DW_FORM_block2:
1351 uvalue = byte_get (data, 2);
1352 block_start = data + 2;
1354 data = block_start + uvalue;
1356 data = display_block (block_start, uvalue);
1359 case DW_FORM_block4:
1360 uvalue = byte_get (data, 4);
1361 block_start = data + 4;
1363 data = block_start + uvalue;
1365 data = display_block (block_start, uvalue);
1370 printf (_(" (indirect string, offset: 0x%s): %s"),
1371 dwarf_vmatoa ("x", uvalue),
1372 fetch_indirect_string (uvalue));
1375 case DW_FORM_indirect:
1376 /* Handled above. */
1379 case DW_FORM_ref_sig8:
1382 dwarf_vma high_bits;
1385 byte_get_64 (data, &high_bits, &uvalue);
1386 printf (" signature: 0x%s",
1387 dwarf_vmatoa64 (high_bits, uvalue, buf, sizeof (buf)));
1393 warn (_("Unrecognized form: %lu\n"), form);
1397 if ((do_loc || do_debug_loc || do_debug_ranges)
1398 && num_debug_info_entries == 0
1399 && debug_info_p != NULL)
1403 case DW_AT_frame_base:
1404 have_frame_base = 1;
1405 case DW_AT_location:
1406 case DW_AT_string_length:
1407 case DW_AT_return_addr:
1408 case DW_AT_data_member_location:
1409 case DW_AT_vtable_elem_location:
1411 case DW_AT_static_link:
1412 case DW_AT_use_location:
1413 case DW_AT_GNU_call_site_value:
1414 case DW_AT_GNU_call_site_data_value:
1415 case DW_AT_GNU_call_site_target:
1416 case DW_AT_GNU_call_site_target_clobbered:
1417 if ((dwarf_version < 4
1418 && (form == DW_FORM_data4 || form == DW_FORM_data8))
1419 || form == DW_FORM_sec_offset)
1421 /* Process location list. */
1422 unsigned int lmax = debug_info_p->max_loc_offsets;
1423 unsigned int num = debug_info_p->num_loc_offsets;
1425 if (lmax == 0 || num >= lmax)
1428 debug_info_p->loc_offsets = (dwarf_vma *)
1429 xcrealloc (debug_info_p->loc_offsets,
1430 lmax, sizeof (*debug_info_p->loc_offsets));
1431 debug_info_p->have_frame_base = (int *)
1432 xcrealloc (debug_info_p->have_frame_base,
1433 lmax, sizeof (*debug_info_p->have_frame_base));
1434 debug_info_p->max_loc_offsets = lmax;
1436 debug_info_p->loc_offsets [num] = uvalue;
1437 debug_info_p->have_frame_base [num] = have_frame_base;
1438 debug_info_p->num_loc_offsets++;
1443 if (need_base_address)
1444 debug_info_p->base_address = uvalue;
1448 if ((dwarf_version < 4
1449 && (form == DW_FORM_data4 || form == DW_FORM_data8))
1450 || form == DW_FORM_sec_offset)
1452 /* Process range list. */
1453 unsigned int lmax = debug_info_p->max_range_lists;
1454 unsigned int num = debug_info_p->num_range_lists;
1456 if (lmax == 0 || num >= lmax)
1459 debug_info_p->range_lists = (dwarf_vma *)
1460 xcrealloc (debug_info_p->range_lists,
1461 lmax, sizeof (*debug_info_p->range_lists));
1462 debug_info_p->max_range_lists = lmax;
1464 debug_info_p->range_lists [num] = uvalue;
1465 debug_info_p->num_range_lists++;
1474 if (do_loc || attribute == 0)
1477 /* For some attributes we can display further information. */
1485 case DW_INL_not_inlined:
1486 printf (_("(not inlined)"));
1488 case DW_INL_inlined:
1489 printf (_("(inlined)"));
1491 case DW_INL_declared_not_inlined:
1492 printf (_("(declared as inline but ignored)"));
1494 case DW_INL_declared_inlined:
1495 printf (_("(declared as inline and inlined)"));
1498 printf (_(" (Unknown inline attribute value: %s)"),
1499 dwarf_vmatoa ("x", uvalue));
1504 case DW_AT_language:
1507 /* Ordered by the numeric value of these constants. */
1508 case DW_LANG_C89: printf ("(ANSI C)"); break;
1509 case DW_LANG_C: printf ("(non-ANSI C)"); break;
1510 case DW_LANG_Ada83: printf ("(Ada)"); break;
1511 case DW_LANG_C_plus_plus: printf ("(C++)"); break;
1512 case DW_LANG_Cobol74: printf ("(Cobol 74)"); break;
1513 case DW_LANG_Cobol85: printf ("(Cobol 85)"); break;
1514 case DW_LANG_Fortran77: printf ("(FORTRAN 77)"); break;
1515 case DW_LANG_Fortran90: printf ("(Fortran 90)"); break;
1516 case DW_LANG_Pascal83: printf ("(ANSI Pascal)"); break;
1517 case DW_LANG_Modula2: printf ("(Modula 2)"); break;
1518 /* DWARF 2.1 values. */
1519 case DW_LANG_Java: printf ("(Java)"); break;
1520 case DW_LANG_C99: printf ("(ANSI C99)"); break;
1521 case DW_LANG_Ada95: printf ("(ADA 95)"); break;
1522 case DW_LANG_Fortran95: printf ("(Fortran 95)"); break;
1523 /* DWARF 3 values. */
1524 case DW_LANG_PLI: printf ("(PLI)"); break;
1525 case DW_LANG_ObjC: printf ("(Objective C)"); break;
1526 case DW_LANG_ObjC_plus_plus: printf ("(Objective C++)"); break;
1527 case DW_LANG_UPC: printf ("(Unified Parallel C)"); break;
1528 case DW_LANG_D: printf ("(D)"); break;
1529 /* DWARF 4 values. */
1530 case DW_LANG_Python: printf ("(Python)"); break;
1531 /* DWARF 5 values. */
1532 case DW_LANG_Go: printf ("(Go)"); break;
1533 /* MIPS extension. */
1534 case DW_LANG_Mips_Assembler: printf ("(MIPS assembler)"); break;
1535 /* UPC extension. */
1536 case DW_LANG_Upc: printf ("(Unified Parallel C)"); break;
1538 if (uvalue >= DW_LANG_lo_user && uvalue <= DW_LANG_hi_user)
1539 printf (_("(implementation defined: %s)"),
1540 dwarf_vmatoa ("x", uvalue));
1542 printf (_("(Unknown: %s)"), dwarf_vmatoa ("x", uvalue));
1547 case DW_AT_encoding:
1550 case DW_ATE_void: printf ("(void)"); break;
1551 case DW_ATE_address: printf ("(machine address)"); break;
1552 case DW_ATE_boolean: printf ("(boolean)"); break;
1553 case DW_ATE_complex_float: printf ("(complex float)"); break;
1554 case DW_ATE_float: printf ("(float)"); break;
1555 case DW_ATE_signed: printf ("(signed)"); break;
1556 case DW_ATE_signed_char: printf ("(signed char)"); break;
1557 case DW_ATE_unsigned: printf ("(unsigned)"); break;
1558 case DW_ATE_unsigned_char: printf ("(unsigned char)"); break;
1559 /* DWARF 2.1 values: */
1560 case DW_ATE_imaginary_float: printf ("(imaginary float)"); break;
1561 case DW_ATE_decimal_float: printf ("(decimal float)"); break;
1562 /* DWARF 3 values: */
1563 case DW_ATE_packed_decimal: printf ("(packed_decimal)"); break;
1564 case DW_ATE_numeric_string: printf ("(numeric_string)"); break;
1565 case DW_ATE_edited: printf ("(edited)"); break;
1566 case DW_ATE_signed_fixed: printf ("(signed_fixed)"); break;
1567 case DW_ATE_unsigned_fixed: printf ("(unsigned_fixed)"); break;
1568 /* HP extensions: */
1569 case DW_ATE_HP_float80: printf ("(HP_float80)"); break;
1570 case DW_ATE_HP_complex_float80: printf ("(HP_complex_float80)"); break;
1571 case DW_ATE_HP_float128: printf ("(HP_float128)"); break;
1572 case DW_ATE_HP_complex_float128:printf ("(HP_complex_float128)"); break;
1573 case DW_ATE_HP_floathpintel: printf ("(HP_floathpintel)"); break;
1574 case DW_ATE_HP_imaginary_float80: printf ("(HP_imaginary_float80)"); break;
1575 case DW_ATE_HP_imaginary_float128: printf ("(HP_imaginary_float128)"); break;
1578 if (uvalue >= DW_ATE_lo_user
1579 && uvalue <= DW_ATE_hi_user)
1580 printf (_("(user defined type)"));
1582 printf (_("(unknown type)"));
1587 case DW_AT_accessibility:
1590 case DW_ACCESS_public: printf ("(public)"); break;
1591 case DW_ACCESS_protected: printf ("(protected)"); break;
1592 case DW_ACCESS_private: printf ("(private)"); break;
1594 printf (_("(unknown accessibility)"));
1599 case DW_AT_visibility:
1602 case DW_VIS_local: printf ("(local)"); break;
1603 case DW_VIS_exported: printf ("(exported)"); break;
1604 case DW_VIS_qualified: printf ("(qualified)"); break;
1605 default: printf (_("(unknown visibility)")); break;
1609 case DW_AT_virtuality:
1612 case DW_VIRTUALITY_none: printf ("(none)"); break;
1613 case DW_VIRTUALITY_virtual: printf ("(virtual)"); break;
1614 case DW_VIRTUALITY_pure_virtual:printf ("(pure_virtual)"); break;
1615 default: printf (_("(unknown virtuality)")); break;
1619 case DW_AT_identifier_case:
1622 case DW_ID_case_sensitive: printf ("(case_sensitive)"); break;
1623 case DW_ID_up_case: printf ("(up_case)"); break;
1624 case DW_ID_down_case: printf ("(down_case)"); break;
1625 case DW_ID_case_insensitive: printf ("(case_insensitive)"); break;
1626 default: printf (_("(unknown case)")); break;
1630 case DW_AT_calling_convention:
1633 case DW_CC_normal: printf ("(normal)"); break;
1634 case DW_CC_program: printf ("(program)"); break;
1635 case DW_CC_nocall: printf ("(nocall)"); break;
1637 if (uvalue >= DW_CC_lo_user
1638 && uvalue <= DW_CC_hi_user)
1639 printf (_("(user defined)"));
1641 printf (_("(unknown convention)"));
1645 case DW_AT_ordering:
1648 case -1: printf (_("(undefined)")); break;
1649 case 0: printf ("(row major)"); break;
1650 case 1: printf ("(column major)"); break;
1654 case DW_AT_frame_base:
1655 have_frame_base = 1;
1656 case DW_AT_location:
1657 case DW_AT_string_length:
1658 case DW_AT_return_addr:
1659 case DW_AT_data_member_location:
1660 case DW_AT_vtable_elem_location:
1662 case DW_AT_static_link:
1663 case DW_AT_use_location:
1664 case DW_AT_GNU_call_site_value:
1665 case DW_AT_GNU_call_site_data_value:
1666 case DW_AT_GNU_call_site_target:
1667 case DW_AT_GNU_call_site_target_clobbered:
1668 if ((dwarf_version < 4
1669 && (form == DW_FORM_data4 || form == DW_FORM_data8))
1670 || form == DW_FORM_sec_offset)
1671 printf (_("(location list)"));
1673 case DW_AT_allocated:
1674 case DW_AT_associated:
1675 case DW_AT_data_location:
1677 case DW_AT_upper_bound:
1678 case DW_AT_lower_bound:
1681 int need_frame_base;
1684 need_frame_base = decode_location_expression (block_start,
1689 cu_offset, section);
1691 if (need_frame_base && !have_frame_base)
1692 printf (_(" [without DW_AT_frame_base]"));
1698 if (form == DW_FORM_ref_sig8)
1701 if (form == DW_FORM_ref1
1702 || form == DW_FORM_ref2
1703 || form == DW_FORM_ref4
1704 || form == DW_FORM_ref_udata)
1705 uvalue += cu_offset;
1707 if (uvalue >= section->size)
1708 warn (_("Offset %s used as value for DW_AT_import attribute of DIE at offset %lx is too big.\n"),
1709 dwarf_vmatoa ("x", uvalue),
1710 (unsigned long) (orig_data - section->start));
1713 unsigned long abbrev_number;
1714 abbrev_entry * entry;
1716 abbrev_number = read_leb128 (section->start + uvalue, NULL, 0);
1718 printf (_("[Abbrev Number: %ld"), abbrev_number);
1719 for (entry = first_abbrev; entry != NULL; entry = entry->next)
1720 if (entry->entry == abbrev_number)
1723 printf (" (%s)", get_TAG_name (entry->tag));
1737 get_AT_name (unsigned long attribute)
1741 /* One value is shared by the MIPS and HP extensions: */
1742 if (attribute == DW_AT_MIPS_fde)
1743 return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable";
1745 name = get_DW_AT_name (attribute);
1749 static char buffer[100];
1751 snprintf (buffer, sizeof (buffer), _("Unknown AT value: %lx"),
1759 static unsigned char *
1760 read_and_display_attr (unsigned long attribute,
1762 unsigned char * data,
1763 dwarf_vma cu_offset,
1764 dwarf_vma pointer_size,
1765 dwarf_vma offset_size,
1767 debug_info * debug_info_p,
1769 struct dwarf_section * section)
1772 printf (" %-18s:", get_AT_name (attribute));
1773 data = read_and_display_attr_value (attribute, form, data, cu_offset,
1774 pointer_size, offset_size,
1775 dwarf_version, debug_info_p,
1783 /* Process the contents of a .debug_info section. If do_loc is non-zero
1784 then we are scanning for location lists and we do not want to display
1785 anything to the user. If do_types is non-zero, we are processing
1786 a .debug_types section instead of a .debug_info section. */
1789 process_debug_info (struct dwarf_section *section,
1791 enum dwarf_section_display_enum abbrev_sec,
1795 unsigned char *start = section->start;
1796 unsigned char *end = start + section->size;
1797 unsigned char *section_begin;
1799 unsigned int num_units = 0;
1801 if ((do_loc || do_debug_loc || do_debug_ranges)
1802 && num_debug_info_entries == 0
1807 /* First scan the section to get the number of comp units. */
1808 for (section_begin = start, num_units = 0; section_begin < end;
1811 /* Read the first 4 bytes. For a 32-bit DWARF section, this
1812 will be the length. For a 64-bit DWARF section, it'll be
1813 the escape code 0xffffffff followed by an 8 byte length. */
1814 length = byte_get (section_begin, 4);
1816 if (length == 0xffffffff)
1818 length = byte_get (section_begin + 4, 8);
1819 section_begin += length + 12;
1821 else if (length >= 0xfffffff0 && length < 0xffffffff)
1823 warn (_("Reserved length value (0x%s) found in section %s\n"),
1824 dwarf_vmatoa ("x", length), section->name);
1828 section_begin += length + 4;
1830 /* Negative values are illegal, they may even cause infinite
1831 looping. This can happen if we can't accurately apply
1832 relocations to an object file. */
1833 if ((signed long) length <= 0)
1835 warn (_("Corrupt unit length (0x%s) found in section %s\n"),
1836 dwarf_vmatoa ("x", length), section->name);
1843 error (_("No comp units in %s section ?"), section->name);
1847 /* Then allocate an array to hold the information. */
1848 debug_information = (debug_info *) cmalloc (num_units,
1849 sizeof (* debug_information));
1850 if (debug_information == NULL)
1852 error (_("Not enough memory for a debug info array of %u entries"),
1860 if (dwarf_start_die == 0)
1861 printf (_("Contents of the %s section:\n\n"), section->name);
1863 load_debug_section (str, file);
1866 load_debug_section (abbrev_sec, file);
1867 if (debug_displays [abbrev_sec].section.start == NULL)
1869 warn (_("Unable to locate %s section!\n"),
1870 debug_displays [abbrev_sec].section.name);
1874 for (section_begin = start, unit = 0; start < end; unit++)
1876 DWARF2_Internal_CompUnit compunit;
1877 unsigned char *hdrptr;
1878 unsigned char *tags;
1879 int level, last_level, saved_level;
1880 dwarf_vma cu_offset;
1882 int initial_length_size;
1883 dwarf_vma signature_high = 0;
1884 dwarf_vma signature_low = 0;
1885 dwarf_vma type_offset = 0;
1889 compunit.cu_length = byte_get (hdrptr, 4);
1892 if (compunit.cu_length == 0xffffffff)
1894 compunit.cu_length = byte_get (hdrptr, 8);
1897 initial_length_size = 12;
1902 initial_length_size = 4;
1905 compunit.cu_version = byte_get (hdrptr, 2);
1908 cu_offset = start - section_begin;
1910 compunit.cu_abbrev_offset = byte_get (hdrptr, offset_size);
1911 hdrptr += offset_size;
1913 compunit.cu_pointer_size = byte_get (hdrptr, 1);
1918 byte_get_64 (hdrptr, &signature_high, &signature_low);
1920 type_offset = byte_get (hdrptr, offset_size);
1921 hdrptr += offset_size;
1924 if ((do_loc || do_debug_loc || do_debug_ranges)
1925 && num_debug_info_entries == 0
1928 debug_information [unit].cu_offset = cu_offset;
1929 debug_information [unit].pointer_size
1930 = compunit.cu_pointer_size;
1931 debug_information [unit].offset_size = offset_size;
1932 debug_information [unit].dwarf_version = compunit.cu_version;
1933 debug_information [unit].base_address = 0;
1934 debug_information [unit].loc_offsets = NULL;
1935 debug_information [unit].have_frame_base = NULL;
1936 debug_information [unit].max_loc_offsets = 0;
1937 debug_information [unit].num_loc_offsets = 0;
1938 debug_information [unit].range_lists = NULL;
1939 debug_information [unit].max_range_lists= 0;
1940 debug_information [unit].num_range_lists = 0;
1943 if (!do_loc && dwarf_start_die == 0)
1945 printf (_(" Compilation Unit @ offset 0x%s:\n"),
1946 dwarf_vmatoa ("x", cu_offset));
1947 printf (_(" Length: 0x%s (%s)\n"),
1948 dwarf_vmatoa ("x", compunit.cu_length),
1949 offset_size == 8 ? "64-bit" : "32-bit");
1950 printf (_(" Version: %d\n"), compunit.cu_version);
1951 printf (_(" Abbrev Offset: %s\n"),
1952 dwarf_vmatoa ("d", compunit.cu_abbrev_offset));
1953 printf (_(" Pointer Size: %d\n"), compunit.cu_pointer_size);
1958 printf (_(" Signature: 0x%s\n"),
1959 dwarf_vmatoa64 (signature_high, signature_low,
1960 buf, sizeof (buf)));
1961 printf (_(" Type Offset: 0x%s\n"),
1962 dwarf_vmatoa ("x", type_offset));
1966 if (cu_offset + compunit.cu_length + initial_length_size
1969 warn (_("Debug info is corrupted, length of CU at %s"
1970 " extends beyond end of section (length = %s)\n"),
1971 dwarf_vmatoa ("x", cu_offset),
1972 dwarf_vmatoa ("x", compunit.cu_length));
1976 start += compunit.cu_length + initial_length_size;
1978 if (compunit.cu_version != 2
1979 && compunit.cu_version != 3
1980 && compunit.cu_version != 4)
1982 warn (_("CU at offset %s contains corrupt or "
1983 "unsupported version number: %d.\n"),
1984 dwarf_vmatoa ("x", cu_offset), compunit.cu_version);
1990 /* Process the abbrevs used by this compilation unit. DWARF
1991 sections under Mach-O have non-zero addresses. */
1992 if (compunit.cu_abbrev_offset >= debug_displays [abbrev_sec].section.size)
1993 warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"),
1994 (unsigned long) compunit.cu_abbrev_offset,
1995 (unsigned long) debug_displays [abbrev_sec].section.size);
1997 process_abbrev_section
1998 ((unsigned char *) debug_displays [abbrev_sec].section.start
1999 + compunit.cu_abbrev_offset,
2000 (unsigned char *) debug_displays [abbrev_sec].section.start
2001 + debug_displays [abbrev_sec].section.size);
2006 while (tags < start)
2008 unsigned int bytes_read;
2009 unsigned long abbrev_number;
2010 unsigned long die_offset;
2011 abbrev_entry *entry;
2013 int do_printing = 1;
2015 die_offset = tags - section_begin;
2017 abbrev_number = read_leb128 (tags, & bytes_read, 0);
2020 /* A null DIE marks the end of a list of siblings or it may also be
2021 a section padding. */
2022 if (abbrev_number == 0)
2024 /* Check if it can be a section padding for the last CU. */
2025 if (level == 0 && start == end)
2029 for (chk = tags; chk < start; chk++)
2039 static unsigned num_bogus_warns = 0;
2041 if (num_bogus_warns < 3)
2043 warn (_("Bogus end-of-siblings marker detected at offset %lx in .debug_info section\n"),
2046 if (num_bogus_warns == 3)
2047 warn (_("Further warnings about bogus end-of-sibling markers suppressed\n"));
2050 if (dwarf_start_die != 0 && level < saved_level)
2057 if (dwarf_start_die != 0 && die_offset < dwarf_start_die)
2061 if (dwarf_start_die != 0 && die_offset == dwarf_start_die)
2062 saved_level = level;
2063 do_printing = (dwarf_cutoff_level == -1
2064 || level < dwarf_cutoff_level);
2066 printf (_(" <%d><%lx>: Abbrev Number: %lu"),
2067 level, die_offset, abbrev_number);
2068 else if (dwarf_cutoff_level == -1
2069 || last_level < dwarf_cutoff_level)
2070 printf (_(" <%d><%lx>: ...\n"), level, die_offset);
2075 /* Scan through the abbreviation list until we reach the
2077 for (entry = first_abbrev;
2078 entry && entry->entry != abbrev_number;
2079 entry = entry->next)
2084 if (!do_loc && do_printing)
2089 warn (_("DIE at offset %lx refers to abbreviation number %lu which does not exist\n"),
2090 die_offset, abbrev_number);
2094 if (!do_loc && do_printing)
2095 printf (" (%s)\n", get_TAG_name (entry->tag));
2100 need_base_address = 0;
2102 case DW_TAG_compile_unit:
2103 need_base_address = 1;
2105 case DW_TAG_entry_point:
2106 case DW_TAG_subprogram:
2107 need_base_address = 0;
2108 /* Assuming that there is no DW_AT_frame_base. */
2109 have_frame_base = 0;
2113 for (attr = entry->first_attr; attr; attr = attr->next)
2117 if (! do_loc && do_printing)
2118 /* Show the offset from where the tag was extracted. */
2119 printf (" <%lx>", (unsigned long)(tags - section_begin));
2121 arg = debug_information;
2122 if (debug_information)
2125 tags = read_and_display_attr (attr->attribute,
2128 compunit.cu_pointer_size,
2130 compunit.cu_version,
2132 do_loc || ! do_printing, section);
2135 if (entry->children)
2140 /* Set num_debug_info_entries here so that it can be used to check if
2141 we need to process .debug_loc and .debug_ranges sections. */
2142 if ((do_loc || do_debug_loc || do_debug_ranges)
2143 && num_debug_info_entries == 0
2145 num_debug_info_entries = num_units;
2153 /* Locate and scan the .debug_info section in the file and record the pointer
2154 sizes and offsets for the compilation units in it. Usually an executable
2155 will have just one pointer size, but this is not guaranteed, and so we try
2156 not to make any assumptions. Returns zero upon failure, or the number of
2157 compilation units upon success. */
2160 load_debug_info (void * file)
2162 /* Reset the last pointer size so that we can issue correct error
2163 messages if we are displaying the contents of more than one section. */
2164 last_pointer_size = 0;
2165 warned_about_missing_comp_units = FALSE;
2167 /* If we have already tried and failed to load the .debug_info
2168 section then do not bother to repear the task. */
2169 if (num_debug_info_entries == DEBUG_INFO_UNAVAILABLE)
2172 /* If we already have the information there is nothing else to do. */
2173 if (num_debug_info_entries > 0)
2174 return num_debug_info_entries;
2176 if (load_debug_section (info, file)
2177 && process_debug_info (&debug_displays [info].section, file, abbrev, 1, 0))
2178 return num_debug_info_entries;
2180 num_debug_info_entries = DEBUG_INFO_UNAVAILABLE;
2185 display_debug_lines_raw (struct dwarf_section *section,
2186 unsigned char *data,
2189 unsigned char *start = section->start;
2191 printf (_("Raw dump of debug contents of section %s:\n\n"),
2196 DWARF2_Internal_LineInfo linfo;
2197 unsigned char *standard_opcodes;
2198 unsigned char *end_of_sequence;
2199 unsigned char *hdrptr;
2200 unsigned long hdroff;
2201 int initial_length_size;
2206 hdroff = hdrptr - start;
2208 /* Check the length of the block. */
2209 linfo.li_length = byte_get (hdrptr, 4);
2212 if (linfo.li_length == 0xffffffff)
2214 /* This section is 64-bit DWARF 3. */
2215 linfo.li_length = byte_get (hdrptr, 8);
2218 initial_length_size = 12;
2223 initial_length_size = 4;
2226 if (linfo.li_length + initial_length_size > section->size)
2229 (_("The information in section %s appears to be corrupt - the section is too small\n"),
2234 /* Check its version number. */
2235 linfo.li_version = byte_get (hdrptr, 2);
2237 if (linfo.li_version != 2
2238 && linfo.li_version != 3
2239 && linfo.li_version != 4)
2241 warn (_("Only DWARF version 2, 3 and 4 line info is currently supported.\n"));
2245 linfo.li_prologue_length = byte_get (hdrptr, offset_size);
2246 hdrptr += offset_size;
2247 linfo.li_min_insn_length = byte_get (hdrptr, 1);
2249 if (linfo.li_version >= 4)
2251 linfo.li_max_ops_per_insn = byte_get (hdrptr, 1);
2253 if (linfo.li_max_ops_per_insn == 0)
2255 warn (_("Invalid maximum operations per insn.\n"));
2260 linfo.li_max_ops_per_insn = 1;
2261 linfo.li_default_is_stmt = byte_get (hdrptr, 1);
2263 linfo.li_line_base = byte_get (hdrptr, 1);
2265 linfo.li_line_range = byte_get (hdrptr, 1);
2267 linfo.li_opcode_base = byte_get (hdrptr, 1);
2270 /* Sign extend the line base field. */
2271 linfo.li_line_base <<= 24;
2272 linfo.li_line_base >>= 24;
2274 printf (_(" Offset: 0x%lx\n"), hdroff);
2275 printf (_(" Length: %ld\n"), (long) linfo.li_length);
2276 printf (_(" DWARF Version: %d\n"), linfo.li_version);
2277 printf (_(" Prologue Length: %d\n"), linfo.li_prologue_length);
2278 printf (_(" Minimum Instruction Length: %d\n"), linfo.li_min_insn_length);
2279 if (linfo.li_version >= 4)
2280 printf (_(" Maximum Ops per Instruction: %d\n"), linfo.li_max_ops_per_insn);
2281 printf (_(" Initial value of 'is_stmt': %d\n"), linfo.li_default_is_stmt);
2282 printf (_(" Line Base: %d\n"), linfo.li_line_base);
2283 printf (_(" Line Range: %d\n"), linfo.li_line_range);
2284 printf (_(" Opcode Base: %d\n"), linfo.li_opcode_base);
2286 end_of_sequence = data + linfo.li_length + initial_length_size;
2288 reset_state_machine (linfo.li_default_is_stmt);
2290 /* Display the contents of the Opcodes table. */
2291 standard_opcodes = hdrptr;
2293 printf (_("\n Opcodes:\n"));
2295 for (i = 1; i < linfo.li_opcode_base; i++)
2296 printf (_(" Opcode %d has %d args\n"), i, standard_opcodes[i - 1]);
2298 /* Display the contents of the Directory table. */
2299 data = standard_opcodes + linfo.li_opcode_base - 1;
2302 printf (_("\n The Directory Table is empty.\n"));
2305 printf (_("\n The Directory Table:\n"));
2309 printf (" %s\n", data);
2311 data += strlen ((char *) data) + 1;
2315 /* Skip the NUL at the end of the table. */
2318 /* Display the contents of the File Name table. */
2320 printf (_("\n The File Name Table is empty.\n"));
2323 printf (_("\n The File Name Table:\n"));
2324 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
2328 unsigned char *name;
2329 unsigned int bytes_read;
2331 printf (" %d\t", ++state_machine_regs.last_file_entry);
2334 data += strlen ((char *) data) + 1;
2337 dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
2340 dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
2343 dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
2345 printf ("%s\n", name);
2349 /* Skip the NUL at the end of the table. */
2352 /* Now display the statements. */
2353 printf (_("\n Line Number Statements:\n"));
2355 while (data < end_of_sequence)
2357 unsigned char op_code;
2358 dwarf_signed_vma adv;
2360 unsigned int bytes_read;
2364 if (op_code >= linfo.li_opcode_base)
2366 op_code -= linfo.li_opcode_base;
2367 uladv = (op_code / linfo.li_line_range);
2368 if (linfo.li_max_ops_per_insn == 1)
2370 uladv *= linfo.li_min_insn_length;
2371 state_machine_regs.address += uladv;
2372 printf (_(" Special opcode %d: "
2373 "advance Address by %s to 0x%s"),
2374 op_code, dwarf_vmatoa ("u", uladv),
2375 dwarf_vmatoa ("x", state_machine_regs.address));
2379 state_machine_regs.address
2380 += ((state_machine_regs.op_index + uladv)
2381 / linfo.li_max_ops_per_insn)
2382 * linfo.li_min_insn_length;
2383 state_machine_regs.op_index
2384 = (state_machine_regs.op_index + uladv)
2385 % linfo.li_max_ops_per_insn;
2386 printf (_(" Special opcode %d: "
2387 "advance Address by %s to 0x%s[%d]"),
2388 op_code, dwarf_vmatoa ("u", uladv),
2389 dwarf_vmatoa ("x", state_machine_regs.address),
2390 state_machine_regs.op_index);
2392 adv = (op_code % linfo.li_line_range) + linfo.li_line_base;
2393 state_machine_regs.line += adv;
2394 printf (_(" and Line by %s to %d\n"),
2395 dwarf_vmatoa ("d", adv), state_machine_regs.line);
2397 else switch (op_code)
2399 case DW_LNS_extended_op:
2400 data += process_extended_line_op (data, linfo.li_default_is_stmt);
2404 printf (_(" Copy\n"));
2407 case DW_LNS_advance_pc:
2408 uladv = read_leb128 (data, & bytes_read, 0);
2410 if (linfo.li_max_ops_per_insn == 1)
2412 uladv *= linfo.li_min_insn_length;
2413 state_machine_regs.address += uladv;
2414 printf (_(" Advance PC by %s to 0x%s\n"),
2415 dwarf_vmatoa ("u", uladv),
2416 dwarf_vmatoa ("x", state_machine_regs.address));
2420 state_machine_regs.address
2421 += ((state_machine_regs.op_index + uladv)
2422 / linfo.li_max_ops_per_insn)
2423 * linfo.li_min_insn_length;
2424 state_machine_regs.op_index
2425 = (state_machine_regs.op_index + uladv)
2426 % linfo.li_max_ops_per_insn;
2427 printf (_(" Advance PC by %s to 0x%s[%d]\n"),
2428 dwarf_vmatoa ("u", uladv),
2429 dwarf_vmatoa ("x", state_machine_regs.address),
2430 state_machine_regs.op_index);
2434 case DW_LNS_advance_line:
2435 adv = read_sleb128 (data, & bytes_read);
2437 state_machine_regs.line += adv;
2438 printf (_(" Advance Line by %s to %d\n"),
2439 dwarf_vmatoa ("d", adv),
2440 state_machine_regs.line);
2443 case DW_LNS_set_file:
2444 adv = read_leb128 (data, & bytes_read, 0);
2446 printf (_(" Set File Name to entry %s in the File Name Table\n"),
2447 dwarf_vmatoa ("d", adv));
2448 state_machine_regs.file = adv;
2451 case DW_LNS_set_column:
2452 uladv = read_leb128 (data, & bytes_read, 0);
2454 printf (_(" Set column to %s\n"),
2455 dwarf_vmatoa ("u", uladv));
2456 state_machine_regs.column = uladv;
2459 case DW_LNS_negate_stmt:
2460 adv = state_machine_regs.is_stmt;
2462 printf (_(" Set is_stmt to %s\n"), dwarf_vmatoa ("d", adv));
2463 state_machine_regs.is_stmt = adv;
2466 case DW_LNS_set_basic_block:
2467 printf (_(" Set basic block\n"));
2468 state_machine_regs.basic_block = 1;
2471 case DW_LNS_const_add_pc:
2472 uladv = ((255 - linfo.li_opcode_base) / linfo.li_line_range);
2473 if (linfo.li_max_ops_per_insn)
2475 uladv *= linfo.li_min_insn_length;
2476 state_machine_regs.address += uladv;
2477 printf (_(" Advance PC by constant %s to 0x%s\n"),
2478 dwarf_vmatoa ("u", uladv),
2479 dwarf_vmatoa ("x", state_machine_regs.address));
2483 state_machine_regs.address
2484 += ((state_machine_regs.op_index + uladv)
2485 / linfo.li_max_ops_per_insn)
2486 * linfo.li_min_insn_length;
2487 state_machine_regs.op_index
2488 = (state_machine_regs.op_index + uladv)
2489 % linfo.li_max_ops_per_insn;
2490 printf (_(" Advance PC by constant %s to 0x%s[%d]\n"),
2491 dwarf_vmatoa ("u", uladv),
2492 dwarf_vmatoa ("x", state_machine_regs.address),
2493 state_machine_regs.op_index);
2497 case DW_LNS_fixed_advance_pc:
2498 uladv = byte_get (data, 2);
2500 state_machine_regs.address += uladv;
2501 state_machine_regs.op_index = 0;
2502 printf (_(" Advance PC by fixed size amount %s to 0x%s\n"),
2503 dwarf_vmatoa ("u", uladv),
2504 dwarf_vmatoa ("x", state_machine_regs.address));
2507 case DW_LNS_set_prologue_end:
2508 printf (_(" Set prologue_end to true\n"));
2511 case DW_LNS_set_epilogue_begin:
2512 printf (_(" Set epilogue_begin to true\n"));
2515 case DW_LNS_set_isa:
2516 uladv = read_leb128 (data, & bytes_read, 0);
2518 printf (_(" Set ISA to %s\n"), dwarf_vmatoa ("u", uladv));
2522 printf (_(" Unknown opcode %d with operands: "), op_code);
2524 for (i = standard_opcodes[op_code - 1]; i > 0 ; --i)
2526 printf ("0x%s%s", dwarf_vmatoa ("x", read_leb128 (data,
2528 i == 1 ? "" : ", ");
2543 unsigned char *name;
2544 unsigned int directory_index;
2545 unsigned int modification_date;
2546 unsigned int length;
2549 /* Output a decoded representation of the .debug_line section. */
2552 display_debug_lines_decoded (struct dwarf_section *section,
2553 unsigned char *data,
2556 printf (_("Decoded dump of debug contents of section %s:\n\n"),
2561 /* This loop amounts to one iteration per compilation unit. */
2562 DWARF2_Internal_LineInfo linfo;
2563 unsigned char *standard_opcodes;
2564 unsigned char *end_of_sequence;
2565 unsigned char *hdrptr;
2566 int initial_length_size;
2569 File_Entry *file_table = NULL;
2570 unsigned int n_files = 0;
2571 unsigned char **directory_table = NULL;
2572 unsigned int n_directories = 0;
2576 /* Extract information from the Line Number Program Header.
2577 (section 6.2.4 in the Dwarf3 doc). */
2579 /* Get the length of this CU's line number information block. */
2580 linfo.li_length = byte_get (hdrptr, 4);
2583 if (linfo.li_length == 0xffffffff)
2585 /* This section is 64-bit DWARF 3. */
2586 linfo.li_length = byte_get (hdrptr, 8);
2589 initial_length_size = 12;
2594 initial_length_size = 4;
2597 if (linfo.li_length + initial_length_size > section->size)
2599 warn (_("The line info appears to be corrupt - "
2600 "the section is too small\n"));
2604 /* Get this CU's Line Number Block version number. */
2605 linfo.li_version = byte_get (hdrptr, 2);
2607 if (linfo.li_version != 2
2608 && linfo.li_version != 3
2609 && linfo.li_version != 4)
2611 warn (_("Only DWARF version 2, 3 and 4 line info is currently "
2616 linfo.li_prologue_length = byte_get (hdrptr, offset_size);
2617 hdrptr += offset_size;
2618 linfo.li_min_insn_length = byte_get (hdrptr, 1);
2620 if (linfo.li_version >= 4)
2622 linfo.li_max_ops_per_insn = byte_get (hdrptr, 1);
2624 if (linfo.li_max_ops_per_insn == 0)
2626 warn (_("Invalid maximum operations per insn.\n"));
2631 linfo.li_max_ops_per_insn = 1;
2632 linfo.li_default_is_stmt = byte_get (hdrptr, 1);
2634 linfo.li_line_base = byte_get (hdrptr, 1);
2636 linfo.li_line_range = byte_get (hdrptr, 1);
2638 linfo.li_opcode_base = byte_get (hdrptr, 1);
2641 /* Sign extend the line base field. */
2642 linfo.li_line_base <<= 24;
2643 linfo.li_line_base >>= 24;
2645 /* Find the end of this CU's Line Number Information Block. */
2646 end_of_sequence = data + linfo.li_length + initial_length_size;
2648 reset_state_machine (linfo.li_default_is_stmt);
2650 /* Save a pointer to the contents of the Opcodes table. */
2651 standard_opcodes = hdrptr;
2653 /* Traverse the Directory table just to count entries. */
2654 data = standard_opcodes + linfo.li_opcode_base - 1;
2657 unsigned char *ptr_directory_table = data;
2661 data += strlen ((char *) data) + 1;
2665 /* Go through the directory table again to save the directories. */
2666 directory_table = (unsigned char **)
2667 xmalloc (n_directories * sizeof (unsigned char *));
2670 while (*ptr_directory_table != 0)
2672 directory_table[i] = ptr_directory_table;
2673 ptr_directory_table += strlen ((char *) ptr_directory_table) + 1;
2677 /* Skip the NUL at the end of the table. */
2680 /* Traverse the File Name table just to count the entries. */
2683 unsigned char *ptr_file_name_table = data;
2687 unsigned int bytes_read;
2689 /* Skip Name, directory index, last modification time and length
2691 data += strlen ((char *) data) + 1;
2692 read_leb128 (data, & bytes_read, 0);
2694 read_leb128 (data, & bytes_read, 0);
2696 read_leb128 (data, & bytes_read, 0);
2702 /* Go through the file table again to save the strings. */
2703 file_table = (File_Entry *) xmalloc (n_files * sizeof (File_Entry));
2706 while (*ptr_file_name_table != 0)
2708 unsigned int bytes_read;
2710 file_table[i].name = ptr_file_name_table;
2711 ptr_file_name_table += strlen ((char *) ptr_file_name_table) + 1;
2713 /* We are not interested in directory, time or size. */
2714 file_table[i].directory_index = read_leb128 (ptr_file_name_table,
2716 ptr_file_name_table += bytes_read;
2717 file_table[i].modification_date = read_leb128 (ptr_file_name_table,
2719 ptr_file_name_table += bytes_read;
2720 file_table[i].length = read_leb128 (ptr_file_name_table, & bytes_read, 0);
2721 ptr_file_name_table += bytes_read;
2726 /* Print the Compilation Unit's name and a header. */
2727 if (directory_table == NULL)
2729 printf (_("CU: %s:\n"), file_table[0].name);
2730 printf (_("File name Line number Starting address\n"));
2734 unsigned int ix = file_table[0].directory_index;
2735 const char *directory = ix ? (char *)directory_table[ix - 1] : ".";
2736 if (do_wide || strlen (directory) < 76)
2737 printf (_("CU: %s/%s:\n"), directory, file_table[0].name);
2739 printf ("%s:\n", file_table[0].name);
2741 printf (_("File name Line number Starting address\n"));
2745 /* Skip the NUL at the end of the table. */
2748 /* This loop iterates through the Dwarf Line Number Program. */
2749 while (data < end_of_sequence)
2751 unsigned char op_code;
2753 unsigned long int uladv;
2754 unsigned int bytes_read;
2755 int is_special_opcode = 0;
2759 if (op_code >= linfo.li_opcode_base)
2761 op_code -= linfo.li_opcode_base;
2762 uladv = (op_code / linfo.li_line_range);
2763 if (linfo.li_max_ops_per_insn == 1)
2765 uladv *= linfo.li_min_insn_length;
2766 state_machine_regs.address += uladv;
2770 state_machine_regs.address
2771 += ((state_machine_regs.op_index + uladv)
2772 / linfo.li_max_ops_per_insn)
2773 * linfo.li_min_insn_length;
2774 state_machine_regs.op_index
2775 = (state_machine_regs.op_index + uladv)
2776 % linfo.li_max_ops_per_insn;
2779 adv = (op_code % linfo.li_line_range) + linfo.li_line_base;
2780 state_machine_regs.line += adv;
2781 is_special_opcode = 1;
2783 else switch (op_code)
2785 case DW_LNS_extended_op:
2787 unsigned int ext_op_code_len;
2788 unsigned char ext_op_code;
2789 unsigned char *op_code_data = data;
2791 ext_op_code_len = read_leb128 (op_code_data, &bytes_read, 0);
2792 op_code_data += bytes_read;
2794 if (ext_op_code_len == 0)
2796 warn (_("badly formed extended line op encountered!\n"));
2799 ext_op_code_len += bytes_read;
2800 ext_op_code = *op_code_data++;
2802 switch (ext_op_code)
2804 case DW_LNE_end_sequence:
2805 reset_state_machine (linfo.li_default_is_stmt);
2807 case DW_LNE_set_address:
2808 state_machine_regs.address =
2809 byte_get (op_code_data, ext_op_code_len - bytes_read - 1);
2810 state_machine_regs.op_index = 0;
2812 case DW_LNE_define_file:
2814 file_table = (File_Entry *) xrealloc
2815 (file_table, (n_files + 1) * sizeof (File_Entry));
2817 ++state_machine_regs.last_file_entry;
2818 /* Source file name. */
2819 file_table[n_files].name = op_code_data;
2820 op_code_data += strlen ((char *) op_code_data) + 1;
2821 /* Directory index. */
2822 file_table[n_files].directory_index =
2823 read_leb128 (op_code_data, & bytes_read, 0);
2824 op_code_data += bytes_read;
2825 /* Last modification time. */
2826 file_table[n_files].modification_date =
2827 read_leb128 (op_code_data, & bytes_read, 0);
2828 op_code_data += bytes_read;
2830 file_table[n_files].length =
2831 read_leb128 (op_code_data, & bytes_read, 0);
2836 case DW_LNE_set_discriminator:
2837 case DW_LNE_HP_set_sequence:
2838 /* Simply ignored. */
2842 printf (_("UNKNOWN (%u): length %d\n"),
2843 ext_op_code, ext_op_code_len - bytes_read);
2846 data += ext_op_code_len;
2852 case DW_LNS_advance_pc:
2853 uladv = read_leb128 (data, & bytes_read, 0);
2855 if (linfo.li_max_ops_per_insn == 1)
2857 uladv *= linfo.li_min_insn_length;
2858 state_machine_regs.address += uladv;
2862 state_machine_regs.address
2863 += ((state_machine_regs.op_index + uladv)
2864 / linfo.li_max_ops_per_insn)
2865 * linfo.li_min_insn_length;
2866 state_machine_regs.op_index
2867 = (state_machine_regs.op_index + uladv)
2868 % linfo.li_max_ops_per_insn;
2872 case DW_LNS_advance_line:
2873 adv = read_sleb128 (data, & bytes_read);
2875 state_machine_regs.line += adv;
2878 case DW_LNS_set_file:
2879 adv = read_leb128 (data, & bytes_read, 0);
2881 state_machine_regs.file = adv;
2882 if (file_table[state_machine_regs.file - 1].directory_index == 0)
2884 /* If directory index is 0, that means current directory. */
2885 printf ("\n./%s:[++]\n",
2886 file_table[state_machine_regs.file - 1].name);
2890 /* The directory index starts counting at 1. */
2891 printf ("\n%s/%s:\n",
2892 directory_table[file_table[state_machine_regs.file - 1].directory_index - 1],
2893 file_table[state_machine_regs.file - 1].name);
2897 case DW_LNS_set_column:
2898 uladv = read_leb128 (data, & bytes_read, 0);
2900 state_machine_regs.column = uladv;
2903 case DW_LNS_negate_stmt:
2904 adv = state_machine_regs.is_stmt;
2906 state_machine_regs.is_stmt = adv;
2909 case DW_LNS_set_basic_block:
2910 state_machine_regs.basic_block = 1;
2913 case DW_LNS_const_add_pc:
2914 uladv = ((255 - linfo.li_opcode_base) / linfo.li_line_range);
2915 if (linfo.li_max_ops_per_insn == 1)
2917 uladv *= linfo.li_min_insn_length;
2918 state_machine_regs.address += uladv;
2922 state_machine_regs.address
2923 += ((state_machine_regs.op_index + uladv)
2924 / linfo.li_max_ops_per_insn)
2925 * linfo.li_min_insn_length;
2926 state_machine_regs.op_index
2927 = (state_machine_regs.op_index + uladv)
2928 % linfo.li_max_ops_per_insn;
2932 case DW_LNS_fixed_advance_pc:
2933 uladv = byte_get (data, 2);
2935 state_machine_regs.address += uladv;
2936 state_machine_regs.op_index = 0;
2939 case DW_LNS_set_prologue_end:
2942 case DW_LNS_set_epilogue_begin:
2945 case DW_LNS_set_isa:
2946 uladv = read_leb128 (data, & bytes_read, 0);
2948 printf (_(" Set ISA to %lu\n"), uladv);
2952 printf (_(" Unknown opcode %d with operands: "), op_code);
2954 for (i = standard_opcodes[op_code - 1]; i > 0 ; --i)
2956 printf ("0x%s%s", dwarf_vmatoa ("x", read_leb128 (data,
2958 i == 1 ? "" : ", ");
2965 /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row
2966 to the DWARF address/line matrix. */
2967 if ((is_special_opcode) || (op_code == DW_LNE_end_sequence)
2968 || (op_code == DW_LNS_copy))
2970 const unsigned int MAX_FILENAME_LENGTH = 35;
2971 char *fileName = (char *)file_table[state_machine_regs.file - 1].name;
2972 char *newFileName = NULL;
2973 size_t fileNameLength = strlen (fileName);
2975 if ((fileNameLength > MAX_FILENAME_LENGTH) && (!do_wide))
2977 newFileName = (char *) xmalloc (MAX_FILENAME_LENGTH + 1);
2978 /* Truncate file name */
2979 strncpy (newFileName,
2980 fileName + fileNameLength - MAX_FILENAME_LENGTH,
2981 MAX_FILENAME_LENGTH + 1);
2985 newFileName = (char *) xmalloc (fileNameLength + 1);
2986 strncpy (newFileName, fileName, fileNameLength + 1);
2989 if (!do_wide || (fileNameLength <= MAX_FILENAME_LENGTH))
2991 if (linfo.li_max_ops_per_insn == 1)
2992 printf ("%-35s %11d %#18" DWARF_VMA_FMT "x\n",
2993 newFileName, state_machine_regs.line,
2994 state_machine_regs.address);
2996 printf ("%-35s %11d %#18" DWARF_VMA_FMT "x[%d]\n",
2997 newFileName, state_machine_regs.line,
2998 state_machine_regs.address,
2999 state_machine_regs.op_index);
3003 if (linfo.li_max_ops_per_insn == 1)
3004 printf ("%s %11d %#18" DWARF_VMA_FMT "x\n",
3005 newFileName, state_machine_regs.line,
3006 state_machine_regs.address);
3008 printf ("%s %11d %#18" DWARF_VMA_FMT "x[%d]\n",
3009 newFileName, state_machine_regs.line,
3010 state_machine_regs.address,
3011 state_machine_regs.op_index);
3014 if (op_code == DW_LNE_end_sequence)
3022 free (directory_table);
3023 directory_table = NULL;
3031 display_debug_lines (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED)
3033 unsigned char *data = section->start;
3034 unsigned char *end = data + section->size;
3036 int retValDecoded = 1;
3038 if (do_debug_lines == 0)
3039 do_debug_lines |= FLAG_DEBUG_LINES_RAW;
3041 if (do_debug_lines & FLAG_DEBUG_LINES_RAW)
3042 retValRaw = display_debug_lines_raw (section, data, end);
3044 if (do_debug_lines & FLAG_DEBUG_LINES_DECODED)
3045 retValDecoded = display_debug_lines_decoded (section, data, end);
3047 if (!retValRaw || !retValDecoded)
3054 find_debug_info_for_offset (unsigned long offset)
3058 if (num_debug_info_entries == DEBUG_INFO_UNAVAILABLE)
3061 for (i = 0; i < num_debug_info_entries; i++)
3062 if (debug_information[i].cu_offset == offset)
3063 return debug_information + i;
3069 display_debug_pubnames (struct dwarf_section *section,
3070 void *file ATTRIBUTE_UNUSED)
3072 DWARF2_Internal_PubNames names;
3073 unsigned char *start = section->start;
3074 unsigned char *end = start + section->size;
3076 /* It does not matter if this load fails,
3077 we test for that later on. */
3078 load_debug_info (file);
3080 printf (_("Contents of the %s section:\n\n"), section->name);
3084 unsigned char *data;
3085 unsigned long offset;
3086 int offset_size, initial_length_size;
3090 names.pn_length = byte_get (data, 4);
3092 if (names.pn_length == 0xffffffff)
3094 names.pn_length = byte_get (data, 8);
3097 initial_length_size = 12;
3102 initial_length_size = 4;
3105 names.pn_version = byte_get (data, 2);
3108 names.pn_offset = byte_get (data, offset_size);
3109 data += offset_size;
3111 if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE
3112 && num_debug_info_entries > 0
3113 && find_debug_info_for_offset (names.pn_offset) == NULL)
3114 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
3115 (unsigned long) names.pn_offset, section->name);
3117 names.pn_size = byte_get (data, offset_size);
3118 data += offset_size;
3120 start += names.pn_length + initial_length_size;
3122 if (names.pn_version != 2 && names.pn_version != 3)
3124 static int warned = 0;
3128 warn (_("Only DWARF 2 and 3 pubnames are currently supported\n"));
3135 printf (_(" Length: %ld\n"),
3136 (long) names.pn_length);
3137 printf (_(" Version: %d\n"),
3139 printf (_(" Offset into .debug_info section: 0x%lx\n"),
3140 (unsigned long) names.pn_offset);
3141 printf (_(" Size of area in .debug_info section: %ld\n"),
3142 (long) names.pn_size);
3144 printf (_("\n Offset\tName\n"));
3148 offset = byte_get (data, offset_size);
3152 data += offset_size;
3153 printf (" %-6lx\t%s\n", offset, data);
3154 data += strlen ((char *) data) + 1;
3157 while (offset != 0);
3165 display_debug_macinfo (struct dwarf_section *section,
3166 void *file ATTRIBUTE_UNUSED)
3168 unsigned char *start = section->start;
3169 unsigned char *end = start + section->size;
3170 unsigned char *curr = start;
3171 unsigned int bytes_read;
3172 enum dwarf_macinfo_record_type op;
3174 printf (_("Contents of the %s section:\n\n"), section->name);
3178 unsigned int lineno;
3181 op = (enum dwarf_macinfo_record_type) *curr;
3186 case DW_MACINFO_start_file:
3188 unsigned int filenum;
3190 lineno = read_leb128 (curr, & bytes_read, 0);
3192 filenum = read_leb128 (curr, & bytes_read, 0);
3195 printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"),
3200 case DW_MACINFO_end_file:
3201 printf (_(" DW_MACINFO_end_file\n"));
3204 case DW_MACINFO_define:
3205 lineno = read_leb128 (curr, & bytes_read, 0);
3207 string = (char *) curr;
3208 curr += strlen (string) + 1;
3209 printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"),
3213 case DW_MACINFO_undef:
3214 lineno = read_leb128 (curr, & bytes_read, 0);
3216 string = (char *) curr;
3217 curr += strlen (string) + 1;
3218 printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"),
3222 case DW_MACINFO_vendor_ext:
3224 unsigned int constant;
3226 constant = read_leb128 (curr, & bytes_read, 0);
3228 string = (char *) curr;
3229 curr += strlen (string) + 1;
3230 printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"),
3240 /* Given LINE_OFFSET into the .debug_line section, attempt to return
3241 filename and dirname corresponding to file name table entry with index
3242 FILEIDX. Return NULL on failure. */
3244 static unsigned char *
3245 get_line_filename_and_dirname (dwarf_vma line_offset, dwarf_vma fileidx,
3246 unsigned char **dir_name)
3248 struct dwarf_section *section = &debug_displays [line].section;
3249 unsigned char *hdrptr, *dirtable, *file_name;
3250 unsigned int offset_size, initial_length_size;
3251 unsigned int version, opcode_base, bytes_read;
3252 dwarf_vma length, diridx;
3255 if (section->start == NULL
3256 || line_offset >= section->size
3260 hdrptr = section->start + line_offset;
3261 length = byte_get (hdrptr, 4);
3263 if (length == 0xffffffff)
3265 /* This section is 64-bit DWARF 3. */
3266 length = byte_get (hdrptr, 8);
3269 initial_length_size = 12;
3274 initial_length_size = 4;
3276 if (length + initial_length_size > section->size)
3278 version = byte_get (hdrptr, 2);
3280 if (version != 2 && version != 3 && version != 4)
3282 hdrptr += offset_size + 1;/* Skip prologue_length and min_insn_length. */
3284 hdrptr++; /* Skip max_ops_per_insn. */
3285 hdrptr += 3; /* Skip default_is_stmt, line_base, line_range. */
3286 opcode_base = byte_get (hdrptr, 1);
3287 if (opcode_base == 0)
3290 hdrptr += opcode_base - 1;
3292 /* Skip over dirname table. */
3293 while (*hdrptr != '\0')
3294 hdrptr += strlen ((char *) hdrptr) + 1;
3295 hdrptr++; /* Skip the NUL at the end of the table. */
3296 /* Now skip over preceding filename table entries. */
3297 for (; *hdrptr != '\0' && fileidx > 1; fileidx--)
3299 hdrptr += strlen ((char *) hdrptr) + 1;
3300 read_leb128 (hdrptr, &bytes_read, 0);
3301 hdrptr += bytes_read;
3302 read_leb128 (hdrptr, &bytes_read, 0);
3303 hdrptr += bytes_read;
3304 read_leb128 (hdrptr, &bytes_read, 0);
3305 hdrptr += bytes_read;
3307 if (*hdrptr == '\0')
3310 hdrptr += strlen ((char *) hdrptr) + 1;
3311 diridx = read_leb128 (hdrptr, &bytes_read, 0);
3314 for (; *dirtable != '\0' && diridx > 1; diridx--)
3315 dirtable += strlen ((char *) dirtable) + 1;
3316 if (*dirtable == '\0')
3318 *dir_name = dirtable;
3323 display_debug_macro (struct dwarf_section *section,
3326 unsigned char *start = section->start;
3327 unsigned char *end = start + section->size;
3328 unsigned char *curr = start;
3329 unsigned char *extended_op_buf[256];
3330 unsigned int bytes_read;
3332 load_debug_section (str, file);
3333 load_debug_section (line, file);
3335 printf (_("Contents of the %s section:\n\n"), section->name);
3339 unsigned int lineno, version, flags;
3340 unsigned int offset_size = 4;
3342 dwarf_vma line_offset = 0, sec_offset = curr - start, offset;
3343 unsigned char **extended_ops = NULL;
3345 version = byte_get (curr, 2);
3350 error (_("Only GNU extension to DWARF 4 of %s is currently supported.\n"),
3355 flags = byte_get (curr++, 1);
3358 printf (_(" Offset: 0x%lx\n"),
3359 (unsigned long) sec_offset);
3360 printf (_(" Version: %d\n"), version);
3361 printf (_(" Offset size: %d\n"), offset_size);
3364 line_offset = byte_get (curr, offset_size);
3365 curr += offset_size;
3366 printf (_(" Offset into .debug_line: 0x%lx\n"),
3367 (unsigned long) line_offset);
3371 unsigned int i, count = byte_get (curr++, 1), op;
3373 memset (extended_op_buf, 0, sizeof (extended_op_buf));
3374 extended_ops = extended_op_buf;
3377 printf (_(" Extension opcode arguments:\n"));
3378 for (i = 0; i < count; i++)
3380 op = byte_get (curr++, 1);
3381 extended_ops[op] = curr;
3382 nargs = read_leb128 (curr, &bytes_read, 0);
3385 printf (_(" DW_MACRO_GNU_%02x has no arguments\n"), op);
3388 printf (_(" DW_MACRO_GNU_%02x arguments: "), op);
3389 for (n = 0; n < nargs; n++)
3391 unsigned int form = byte_get (curr++, 1);
3392 printf ("%s%s", get_FORM_name (form),
3393 n == nargs - 1 ? "\n" : ", ");
3403 case DW_FORM_block1:
3404 case DW_FORM_block2:
3405 case DW_FORM_block4:
3407 case DW_FORM_string:
3409 case DW_FORM_sec_offset:
3412 error (_("Invalid extension opcode form %s\n"),
3413 get_FORM_name (form));
3429 error (_(".debug_macro section not zero terminated\n"));
3433 op = byte_get (curr++, 1);
3439 case DW_MACRO_GNU_start_file:
3441 unsigned int filenum;
3442 unsigned char *file_name = NULL, *dir_name = NULL;
3444 lineno = read_leb128 (curr, &bytes_read, 0);
3446 filenum = read_leb128 (curr, &bytes_read, 0);
3449 if ((flags & 2) == 0)
3450 error (_("DW_MACRO_GNU_start_file used, but no .debug_line offset provided.\n"));
3453 = get_line_filename_and_dirname (line_offset, filenum,
3455 if (file_name == NULL)
3456 printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d\n"),
3459 printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d filename: %s%s%s\n"),
3461 dir_name != NULL ? (const char *) dir_name : "",
3462 dir_name != NULL ? "/" : "", file_name);
3466 case DW_MACRO_GNU_end_file:
3467 printf (_(" DW_MACRO_GNU_end_file\n"));
3470 case DW_MACRO_GNU_define:
3471 lineno = read_leb128 (curr, &bytes_read, 0);
3473 string = (char *) curr;
3474 curr += strlen (string) + 1;
3475 printf (_(" DW_MACRO_GNU_define - lineno : %d macro : %s\n"),
3479 case DW_MACRO_GNU_undef:
3480 lineno = read_leb128 (curr, &bytes_read, 0);
3482 string = (char *) curr;
3483 curr += strlen (string) + 1;
3484 printf (_(" DW_MACRO_GNU_undef - lineno : %d macro : %s\n"),
3488 case DW_MACRO_GNU_define_indirect:
3489 lineno = read_leb128 (curr, &bytes_read, 0);
3491 offset = byte_get (curr, offset_size);
3492 curr += offset_size;
3493 string = fetch_indirect_string (offset);
3494 printf (_(" DW_MACRO_GNU_define_indirect - lineno : %d macro : %s\n"),
3498 case DW_MACRO_GNU_undef_indirect:
3499 lineno = read_leb128 (curr, &bytes_read, 0);
3501 offset = byte_get (curr, offset_size);
3502 curr += offset_size;
3503 string = fetch_indirect_string (offset);
3504 printf (_(" DW_MACRO_GNU_undef_indirect - lineno : %d macro : %s\n"),
3508 case DW_MACRO_GNU_transparent_include:
3509 offset = byte_get (curr, offset_size);
3510 curr += offset_size;
3511 printf (_(" DW_MACRO_GNU_transparent_include - offset : 0x%lx\n"),
3512 (unsigned long) offset);
3516 if (extended_ops == NULL || extended_ops[op] == NULL)
3518 error (_(" Unknown macro opcode %02x seen\n"), op);
3523 /* Skip over unhandled opcodes. */
3525 unsigned char *desc = extended_ops[op];
3526 nargs = read_leb128 (desc, &bytes_read, 0);
3530 printf (_(" DW_MACRO_GNU_%02x\n"), op);
3533 printf (_(" DW_MACRO_GNU_%02x -"), op);
3534 for (n = 0; n < nargs; n++)
3537 = read_and_display_attr_value (0, byte_get (desc++, 1),
3538 curr, 0, 0, offset_size,
3539 version, NULL, 0, NULL);
3556 display_debug_abbrev (struct dwarf_section *section,
3557 void *file ATTRIBUTE_UNUSED)
3559 abbrev_entry *entry;
3560 unsigned char *start = section->start;
3561 unsigned char *end = start + section->size;
3563 printf (_("Contents of the %s section:\n\n"), section->name);
3569 start = process_abbrev_section (start, end);
3571 if (first_abbrev == NULL)
3574 printf (_(" Number TAG\n"));
3576 for (entry = first_abbrev; entry; entry = entry->next)
3580 printf (" %ld %s [%s]\n",
3582 get_TAG_name (entry->tag),
3583 entry->children ? _("has children") : _("no children"));
3585 for (attr = entry->first_attr; attr; attr = attr->next)
3586 printf (" %-18s %s\n",
3587 get_AT_name (attr->attribute),
3588 get_FORM_name (attr->form));
3598 /* Sort array of indexes in ascending order of loc_offsets[idx]. */
3600 static dwarf_vma *loc_offsets;
3603 loc_offsets_compar (const void *ap, const void *bp)
3605 dwarf_vma a = loc_offsets[*(const unsigned int *) ap];
3606 dwarf_vma b = loc_offsets[*(const unsigned int *) bp];
3608 return (a > b) - (b > a);
3612 display_debug_loc (struct dwarf_section *section, void *file)
3614 unsigned char *start = section->start;
3615 unsigned char *section_end;
3616 unsigned long bytes;
3617 unsigned char *section_begin = start;
3618 unsigned int num_loc_list = 0;
3619 unsigned long last_offset = 0;
3620 unsigned int first = 0;
3624 int seen_first_offset = 0;
3625 int locs_sorted = 1;
3626 unsigned char *next;
3627 unsigned int *array = NULL;
3629 bytes = section->size;
3630 section_end = start + bytes;
3634 printf (_("\nThe %s section is empty.\n"), section->name);
3638 if (load_debug_info (file) == 0)
3640 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
3645 /* Check the order of location list in .debug_info section. If
3646 offsets of location lists are in the ascending order, we can
3647 use `debug_information' directly. */
3648 for (i = 0; i < num_debug_info_entries; i++)
3652 num = debug_information [i].num_loc_offsets;
3653 if (num > num_loc_list)
3656 /* Check if we can use `debug_information' directly. */
3657 if (locs_sorted && num != 0)
3659 if (!seen_first_offset)
3661 /* This is the first location list. */
3662 last_offset = debug_information [i].loc_offsets [0];
3664 seen_first_offset = 1;
3670 for (; j < num; j++)
3673 debug_information [i].loc_offsets [j])
3678 last_offset = debug_information [i].loc_offsets [j];
3683 if (!seen_first_offset)
3684 error (_("No location lists in .debug_info section!\n"));
3686 /* DWARF sections under Mach-O have non-zero addresses. */
3687 if (debug_information [first].num_loc_offsets > 0
3688 && debug_information [first].loc_offsets [0] != section->address)
3689 warn (_("Location lists in %s section start at 0x%s\n"),
3691 dwarf_vmatoa ("x", debug_information [first].loc_offsets [0]));
3694 array = (unsigned int *) xcmalloc (num_loc_list, sizeof (unsigned int));
3695 printf (_("Contents of the %s section:\n\n"), section->name);
3696 printf (_(" Offset Begin End Expression\n"));
3698 seen_first_offset = 0;
3699 for (i = first; i < num_debug_info_entries; i++)
3703 unsigned short length;
3704 unsigned long offset;
3705 unsigned int pointer_size;
3706 unsigned int offset_size;
3708 unsigned long cu_offset;
3709 unsigned long base_address;
3710 int need_frame_base;
3713 pointer_size = debug_information [i].pointer_size;
3714 cu_offset = debug_information [i].cu_offset;
3715 offset_size = debug_information [i].offset_size;
3716 dwarf_version = debug_information [i].dwarf_version;
3719 for (k = 0; k < debug_information [i].num_loc_offsets; k++)
3721 loc_offsets = debug_information [i].loc_offsets;
3722 qsort (array, debug_information [i].num_loc_offsets,
3723 sizeof (*array), loc_offsets_compar);
3726 for (k = 0; k < debug_information [i].num_loc_offsets; k++)
3728 j = locs_sorted ? k : array[k];
3730 && debug_information [i].loc_offsets [locs_sorted
3731 ? k - 1 : array [k - 1]]
3732 == debug_information [i].loc_offsets [j])
3734 has_frame_base = debug_information [i].have_frame_base [j];
3735 /* DWARF sections under Mach-O have non-zero addresses. */
3736 offset = debug_information [i].loc_offsets [j] - section->address;
3737 next = section_begin + offset;
3738 base_address = debug_information [i].base_address;
3740 if (!seen_first_offset)
3741 seen_first_offset = 1;
3745 warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"),
3746 (unsigned long) (start - section_begin),
3747 (unsigned long) (next - section_begin));
3748 else if (start > next)
3749 warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"),
3750 (unsigned long) (start - section_begin),
3751 (unsigned long) (next - section_begin));
3755 if (offset >= bytes)
3757 warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"),
3764 if (start + 2 * pointer_size > section_end)
3766 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3771 /* Note: we use sign extension here in order to be sure that
3772 we can detect the -1 escape value. Sign extension into the
3773 top 32 bits of a 32-bit address will not affect the values
3774 that we display since we always show hex values, and always
3775 the bottom 32-bits. */
3776 begin = byte_get_signed (start, pointer_size);
3777 start += pointer_size;
3778 end = byte_get_signed (start, pointer_size);
3779 start += pointer_size;
3781 printf (" %8.8lx ", offset);
3783 if (begin == 0 && end == 0)
3785 printf (_("<End of list>\n"));
3789 /* Check base address specifiers. */
3790 if (begin == (dwarf_vma) -1 && end != (dwarf_vma) -1)
3793 print_dwarf_vma (begin, pointer_size);
3794 print_dwarf_vma (end, pointer_size);
3795 printf (_("(base address)\n"));
3799 if (start + 2 > section_end)
3801 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3806 length = byte_get (start, 2);
3809 if (start + length > section_end)
3811 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3816 print_dwarf_vma (begin + base_address, pointer_size);
3817 print_dwarf_vma (end + base_address, pointer_size);
3820 need_frame_base = decode_location_expression (start,
3825 cu_offset, section);
3828 if (need_frame_base && !has_frame_base)
3829 printf (_(" [without DW_AT_frame_base]"));
3832 fputs (_(" (start == end)"), stdout);
3833 else if (begin > end)
3834 fputs (_(" (start > end)"), stdout);
3843 if (start < section_end)
3844 warn (_("There are %ld unused bytes at the end of section %s\n"),
3845 (long) (section_end - start), section->name);
3852 display_debug_str (struct dwarf_section *section,
3853 void *file ATTRIBUTE_UNUSED)
3855 unsigned char *start = section->start;
3856 unsigned long bytes = section->size;
3857 dwarf_vma addr = section->address;
3861 printf (_("\nThe %s section is empty.\n"), section->name);
3865 printf (_("Contents of the %s section:\n\n"), section->name);
3873 lbytes = (bytes > 16 ? 16 : bytes);
3875 printf (" 0x%8.8lx ", (unsigned long) addr);
3877 for (j = 0; j < 16; j++)
3880 printf ("%2.2x", start[j]);
3888 for (j = 0; j < lbytes; j++)
3891 if (k >= ' ' && k < 0x80)
3910 display_debug_info (struct dwarf_section *section, void *file)
3912 return process_debug_info (section, file, abbrev, 0, 0);
3916 display_debug_types (struct dwarf_section *section, void *file)
3918 return process_debug_info (section, file, abbrev, 0, 1);
3922 display_trace_info (struct dwarf_section *section, void *file)
3924 return process_debug_info (section, file, trace_abbrev, 0, 0);
3928 display_debug_aranges (struct dwarf_section *section,
3929 void *file ATTRIBUTE_UNUSED)
3931 unsigned char *start = section->start;
3932 unsigned char *end = start + section->size;
3934 printf (_("Contents of the %s section:\n\n"), section->name);
3936 /* It does not matter if this load fails,
3937 we test for that later on. */
3938 load_debug_info (file);
3942 unsigned char *hdrptr;
3943 DWARF2_Internal_ARange arange;
3944 unsigned char *addr_ranges;
3947 unsigned char address_size;
3950 int initial_length_size;
3954 arange.ar_length = byte_get (hdrptr, 4);
3957 if (arange.ar_length == 0xffffffff)
3959 arange.ar_length = byte_get (hdrptr, 8);
3962 initial_length_size = 12;
3967 initial_length_size = 4;
3970 arange.ar_version = byte_get (hdrptr, 2);
3973 arange.ar_info_offset = byte_get (hdrptr, offset_size);
3974 hdrptr += offset_size;
3976 if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE
3977 && num_debug_info_entries > 0
3978 && find_debug_info_for_offset (arange.ar_info_offset) == NULL)
3979 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
3980 (unsigned long) arange.ar_info_offset, section->name);
3982 arange.ar_pointer_size = byte_get (hdrptr, 1);
3985 arange.ar_segment_size = byte_get (hdrptr, 1);
3988 if (arange.ar_version != 2 && arange.ar_version != 3)
3990 warn (_("Only DWARF 2 and 3 aranges are currently supported.\n"));
3994 printf (_(" Length: %ld\n"),
3995 (long) arange.ar_length);
3996 printf (_(" Version: %d\n"), arange.ar_version);
3997 printf (_(" Offset into .debug_info: 0x%lx\n"),
3998 (unsigned long) arange.ar_info_offset);
3999 printf (_(" Pointer Size: %d\n"), arange.ar_pointer_size);
4000 printf (_(" Segment Size: %d\n"), arange.ar_segment_size);
4002 address_size = arange.ar_pointer_size + arange.ar_segment_size;
4004 if (address_size == 0)
4006 error (_("Invalid address size in %s section!\n"),
4011 /* The DWARF spec does not require that the address size be a power
4012 of two, but we do. This will have to change if we ever encounter
4013 an uneven architecture. */
4014 if ((address_size & (address_size - 1)) != 0)
4016 warn (_("Pointer size + Segment size is not a power of two.\n"));
4020 if (address_size > 4)
4021 printf (_("\n Address Length\n"));
4023 printf (_("\n Address Length\n"));
4025 addr_ranges = hdrptr;
4027 /* Must pad to an alignment boundary that is twice the address size. */
4028 excess = (hdrptr - start) % (2 * address_size);
4030 addr_ranges += (2 * address_size) - excess;
4032 start += arange.ar_length + initial_length_size;
4034 while (addr_ranges + 2 * address_size <= start)
4036 address = byte_get (addr_ranges, address_size);
4038 addr_ranges += address_size;
4040 length = byte_get (addr_ranges, address_size);
4042 addr_ranges += address_size;
4045 print_dwarf_vma (address, address_size);
4046 print_dwarf_vma (length, address_size);
4056 /* Each debug_information[x].range_lists[y] gets this representation for
4057 sorting purposes. */
4061 /* The debug_information[x].range_lists[y] value. */
4062 unsigned long ranges_offset;
4064 /* Original debug_information to find parameters of the data. */
4065 debug_info *debug_info_p;
4068 /* Sort struct range_entry in ascending order of its RANGES_OFFSET. */
4071 range_entry_compar (const void *ap, const void *bp)
4073 const struct range_entry *a_re = (const struct range_entry *) ap;
4074 const struct range_entry *b_re = (const struct range_entry *) bp;
4075 const unsigned long a = a_re->ranges_offset;
4076 const unsigned long b = b_re->ranges_offset;
4078 return (a > b) - (b > a);
4082 display_debug_ranges (struct dwarf_section *section,
4083 void *file ATTRIBUTE_UNUSED)
4085 unsigned char *start = section->start;
4086 unsigned long bytes;
4087 unsigned char *section_begin = start;
4088 unsigned int num_range_list, i;
4089 struct range_entry *range_entries, *range_entry_fill;
4091 bytes = section->size;
4095 printf (_("\nThe %s section is empty.\n"), section->name);
4099 if (load_debug_info (file) == 0)
4101 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4107 for (i = 0; i < num_debug_info_entries; i++)
4108 num_range_list += debug_information [i].num_range_lists;
4110 if (num_range_list == 0)
4111 error (_("No range lists in .debug_info section!\n"));
4113 range_entries = (struct range_entry *)
4114 xmalloc (sizeof (*range_entries) * num_range_list);
4115 range_entry_fill = range_entries;
4117 for (i = 0; i < num_debug_info_entries; i++)
4119 debug_info *debug_info_p = &debug_information[i];
4122 for (j = 0; j < debug_info_p->num_range_lists; j++)
4124 range_entry_fill->ranges_offset = debug_info_p->range_lists[j];
4125 range_entry_fill->debug_info_p = debug_info_p;
4130 qsort (range_entries, num_range_list, sizeof (*range_entries),
4131 range_entry_compar);
4133 /* DWARF sections under Mach-O have non-zero addresses. */
4134 if (range_entries[0].ranges_offset != section->address)
4135 warn (_("Range lists in %s section start at 0x%lx\n"),
4136 section->name, range_entries[0].ranges_offset);
4138 printf (_("Contents of the %s section:\n\n"), section->name);
4139 printf (_(" Offset Begin End\n"));
4141 for (i = 0; i < num_range_list; i++)
4143 struct range_entry *range_entry = &range_entries[i];
4144 debug_info *debug_info_p = range_entry->debug_info_p;
4145 unsigned int pointer_size;
4146 unsigned long offset;
4147 unsigned char *next;
4148 unsigned long base_address;
4150 pointer_size = debug_info_p->pointer_size;
4152 /* DWARF sections under Mach-O have non-zero addresses. */
4153 offset = range_entry->ranges_offset - section->address;
4154 next = section_begin + offset;
4155 base_address = debug_info_p->base_address;
4160 warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"),
4161 (unsigned long) (start - section_begin),
4162 (unsigned long) (next - section_begin), section->name);
4163 else if (start > next)
4164 warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"),
4165 (unsigned long) (start - section_begin),
4166 (unsigned long) (next - section_begin), section->name);
4175 /* Note: we use sign extension here in order to be sure that
4176 we can detect the -1 escape value. Sign extension into the
4177 top 32 bits of a 32-bit address will not affect the values
4178 that we display since we always show hex values, and always
4179 the bottom 32-bits. */
4180 begin = byte_get_signed (start, pointer_size);
4181 start += pointer_size;
4182 end = byte_get_signed (start, pointer_size);
4183 start += pointer_size;
4185 printf (" %8.8lx ", offset);
4187 if (begin == 0 && end == 0)
4189 printf (_("<End of list>\n"));
4193 /* Check base address specifiers. */
4194 if (begin == (dwarf_vma) -1 && end != (dwarf_vma) -1)
4197 print_dwarf_vma (begin, pointer_size);
4198 print_dwarf_vma (end, pointer_size);
4199 printf ("(base address)\n");
4203 print_dwarf_vma (begin + base_address, pointer_size);
4204 print_dwarf_vma (end + base_address, pointer_size);
4207 fputs (_("(start == end)"), stdout);
4208 else if (begin > end)
4209 fputs (_("(start > end)"), stdout);
4216 free (range_entries);
4221 typedef struct Frame_Chunk
4223 struct Frame_Chunk *next;
4224 unsigned char *chunk_start;
4226 /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
4227 short int *col_type;
4230 unsigned int code_factor;
4232 unsigned long pc_begin;
4233 unsigned long pc_range;
4237 unsigned char fde_encoding;
4238 unsigned char cfa_exp;
4239 unsigned char ptr_size;
4240 unsigned char segment_size;
4244 static const char *const *dwarf_regnames;
4245 static unsigned int dwarf_regnames_count;
4247 /* A marker for a col_type that means this column was never referenced
4248 in the frame info. */
4249 #define DW_CFA_unreferenced (-1)
4251 /* Return 0 if not more space is needed, 1 if more space is needed,
4252 -1 for invalid reg. */
4255 frame_need_space (Frame_Chunk *fc, unsigned int reg)
4257 int prev = fc->ncols;
4259 if (reg < (unsigned int) fc->ncols)
4262 if (dwarf_regnames_count
4263 && reg > dwarf_regnames_count)
4266 fc->ncols = reg + 1;
4267 fc->col_type = (short int *) xcrealloc (fc->col_type, fc->ncols,
4268 sizeof (short int));
4269 fc->col_offset = (int *) xcrealloc (fc->col_offset, fc->ncols, sizeof (int));
4271 while (prev < fc->ncols)
4273 fc->col_type[prev] = DW_CFA_unreferenced;
4274 fc->col_offset[prev] = 0;
4280 static const char *const dwarf_regnames_i386[] =
4282 "eax", "ecx", "edx", "ebx",
4283 "esp", "ebp", "esi", "edi",
4284 "eip", "eflags", NULL,
4285 "st0", "st1", "st2", "st3",
4286 "st4", "st5", "st6", "st7",
4288 "xmm0", "xmm1", "xmm2", "xmm3",
4289 "xmm4", "xmm5", "xmm6", "xmm7",
4290 "mm0", "mm1", "mm2", "mm3",
4291 "mm4", "mm5", "mm6", "mm7",
4292 "fcw", "fsw", "mxcsr",
4293 "es", "cs", "ss", "ds", "fs", "gs", NULL, NULL,
4298 init_dwarf_regnames_i386 (void)
4300 dwarf_regnames = dwarf_regnames_i386;
4301 dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_i386);
4304 static const char *const dwarf_regnames_x86_64[] =
4306 "rax", "rdx", "rcx", "rbx",
4307 "rsi", "rdi", "rbp", "rsp",
4308 "r8", "r9", "r10", "r11",
4309 "r12", "r13", "r14", "r15",
4311 "xmm0", "xmm1", "xmm2", "xmm3",
4312 "xmm4", "xmm5", "xmm6", "xmm7",
4313 "xmm8", "xmm9", "xmm10", "xmm11",
4314 "xmm12", "xmm13", "xmm14", "xmm15",
4315 "st0", "st1", "st2", "st3",
4316 "st4", "st5", "st6", "st7",
4317 "mm0", "mm1", "mm2", "mm3",
4318 "mm4", "mm5", "mm6", "mm7",
4320 "es", "cs", "ss", "ds", "fs", "gs", NULL, NULL,
4321 "fs.base", "gs.base", NULL, NULL,
4323 "mxcsr", "fcw", "fsw"
4327 init_dwarf_regnames_x86_64 (void)
4329 dwarf_regnames = dwarf_regnames_x86_64;
4330 dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_x86_64);
4334 init_dwarf_regnames (unsigned int e_machine)
4340 init_dwarf_regnames_i386 ();
4346 init_dwarf_regnames_x86_64 ();
4355 regname (unsigned int regno, int row)
4357 static char reg[64];
4359 && regno < dwarf_regnames_count
4360 && dwarf_regnames [regno] != NULL)
4363 return dwarf_regnames [regno];
4364 snprintf (reg, sizeof (reg), "r%d (%s)", regno,
4365 dwarf_regnames [regno]);
4368 snprintf (reg, sizeof (reg), "r%d", regno);
4373 frame_display_row (Frame_Chunk *fc, int *need_col_headers, int *max_regs)
4378 if (*max_regs < fc->ncols)
4379 *max_regs = fc->ncols;
4381 if (*need_col_headers)
4383 static const char *sloc = " LOC";
4385 *need_col_headers = 0;
4387 printf ("%-*s CFA ", eh_addr_size * 2, sloc);
4389 for (r = 0; r < *max_regs; r++)
4390 if (fc->col_type[r] != DW_CFA_unreferenced)
4395 printf ("%-5s ", regname (r, 1));
4401 printf ("%0*lx ", eh_addr_size * 2, fc->pc_begin);
4403 strcpy (tmp, "exp");
4405 sprintf (tmp, "%s%+d", regname (fc->cfa_reg, 1), fc->cfa_offset);
4406 printf ("%-8s ", tmp);
4408 for (r = 0; r < fc->ncols; r++)
4410 if (fc->col_type[r] != DW_CFA_unreferenced)
4412 switch (fc->col_type[r])
4414 case DW_CFA_undefined:
4417 case DW_CFA_same_value:
4421 sprintf (tmp, "c%+d", fc->col_offset[r]);
4423 case DW_CFA_val_offset:
4424 sprintf (tmp, "v%+d", fc->col_offset[r]);
4426 case DW_CFA_register:
4427 sprintf (tmp, "%s", regname (fc->col_offset[r], 0));
4429 case DW_CFA_expression:
4430 strcpy (tmp, "exp");
4432 case DW_CFA_val_expression:
4433 strcpy (tmp, "vexp");
4436 strcpy (tmp, "n/a");
4439 printf ("%-5s ", tmp);
4445 #define GET(N) byte_get (start, N); start += N
4446 #define LEB() read_leb128 (start, & length_return, 0); start += length_return
4447 #define SLEB() read_sleb128 (start, & length_return); start += length_return
4450 display_debug_frames (struct dwarf_section *section,
4451 void *file ATTRIBUTE_UNUSED)
4453 unsigned char *start = section->start;
4454 unsigned char *end = start + section->size;
4455 unsigned char *section_start = start;
4456 Frame_Chunk *chunks = 0;
4457 Frame_Chunk *remembered_state = 0;
4459 int is_eh = strcmp (section->name, ".eh_frame") == 0;
4460 unsigned int length_return;
4462 const char *bad_reg = _("bad register: ");
4463 int saved_eh_addr_size = eh_addr_size;
4465 printf (_("Contents of the %s section:\n"), section->name);
4469 unsigned char *saved_start;
4470 unsigned char *block_end;
4471 unsigned long length;
4472 unsigned long cie_id;
4475 int need_col_headers = 1;
4476 unsigned char *augmentation_data = NULL;
4477 unsigned long augmentation_data_len = 0;
4478 int encoded_ptr_size = saved_eh_addr_size;
4480 int initial_length_size;
4482 saved_start = start;
4483 length = byte_get (start, 4); start += 4;
4487 printf ("\n%08lx ZERO terminator\n\n",
4488 (unsigned long)(saved_start - section_start));
4492 if (length == 0xffffffff)
4494 length = byte_get (start, 8);
4497 initial_length_size = 12;
4502 initial_length_size = 4;
4505 block_end = saved_start + length + initial_length_size;
4506 if (block_end > end)
4508 warn ("Invalid length %#08lx in FDE at %#08lx\n",
4509 length, (unsigned long)(saved_start - section_start));
4512 cie_id = byte_get (start, offset_size); start += offset_size;
4514 if (is_eh ? (cie_id == 0) : (cie_id == DW_CIE_ID))
4518 fc = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk));
4519 memset (fc, 0, sizeof (Frame_Chunk));
4523 fc->chunk_start = saved_start;
4525 fc->col_type = (short int *) xmalloc (sizeof (short int));
4526 fc->col_offset = (int *) xmalloc (sizeof (int));
4527 frame_need_space (fc, max_regs - 1);
4531 fc->augmentation = (char *) start;
4532 start = (unsigned char *) strchr ((char *) start, '\0') + 1;
4534 if (strcmp (fc->augmentation, "eh") == 0)
4535 start += eh_addr_size;
4539 fc->ptr_size = GET (1);
4540 fc->segment_size = GET (1);
4541 eh_addr_size = fc->ptr_size;
4545 fc->ptr_size = eh_addr_size;
4546 fc->segment_size = 0;
4548 fc->code_factor = LEB ();
4549 fc->data_factor = SLEB ();
4559 if (fc->augmentation[0] == 'z')
4561 augmentation_data_len = LEB ();
4562 augmentation_data = start;
4563 start += augmentation_data_len;
4567 if (do_debug_frames_interp)
4568 printf ("\n%08lx %08lx %08lx CIE \"%s\" cf=%d df=%d ra=%d\n",
4569 (unsigned long)(saved_start - section_start), length, cie_id,
4570 fc->augmentation, fc->code_factor, fc->data_factor,
4574 printf ("\n%08lx %08lx %08lx CIE\n",
4575 (unsigned long)(saved_start - section_start), length, cie_id);
4576 printf (" Version: %d\n", version);
4577 printf (" Augmentation: \"%s\"\n", fc->augmentation);
4580 printf (" Pointer Size: %u\n", fc->ptr_size);
4581 printf (" Segment Size: %u\n", fc->segment_size);
4583 printf (" Code alignment factor: %u\n", fc->code_factor);
4584 printf (" Data alignment factor: %d\n", fc->data_factor);
4585 printf (" Return address column: %d\n", fc->ra);
4587 if (augmentation_data_len)
4590 printf (" Augmentation data: ");
4591 for (i = 0; i < augmentation_data_len; ++i)
4592 printf (" %02x", augmentation_data[i]);
4598 if (augmentation_data_len)
4600 unsigned char *p, *q;
4601 p = (unsigned char *) fc->augmentation + 1;
4602 q = augmentation_data;
4609 q += 1 + size_of_encoded_value (*q);
4611 fc->fde_encoding = *q++;
4619 if (fc->fde_encoding)
4620 encoded_ptr_size = size_of_encoded_value (fc->fde_encoding);
4623 frame_need_space (fc, fc->ra);
4627 unsigned char *look_for;
4628 static Frame_Chunk fde_fc;
4629 unsigned long segment_selector;
4632 memset (fc, 0, sizeof (Frame_Chunk));
4634 look_for = is_eh ? start - 4 - cie_id : section_start + cie_id;
4636 for (cie = chunks; cie ; cie = cie->next)
4637 if (cie->chunk_start == look_for)
4642 warn ("Invalid CIE pointer %#08lx in FDE at %#08lx\n",
4643 cie_id, (unsigned long)(saved_start - section_start));
4645 fc->col_type = (short int *) xmalloc (sizeof (short int));
4646 fc->col_offset = (int *) xmalloc (sizeof (int));
4647 frame_need_space (fc, max_regs - 1);
4649 fc->augmentation = "";
4650 fc->fde_encoding = 0;
4651 fc->ptr_size = eh_addr_size;
4652 fc->segment_size = 0;
4656 fc->ncols = cie->ncols;
4657 fc->col_type = (short int *) xcmalloc (fc->ncols, sizeof (short int));
4658 fc->col_offset = (int *) xcmalloc (fc->ncols, sizeof (int));
4659 memcpy (fc->col_type, cie->col_type, fc->ncols * sizeof (short int));
4660 memcpy (fc->col_offset, cie->col_offset, fc->ncols * sizeof (int));
4661 fc->augmentation = cie->augmentation;
4662 fc->ptr_size = cie->ptr_size;
4663 eh_addr_size = cie->ptr_size;
4664 fc->segment_size = cie->segment_size;
4665 fc->code_factor = cie->code_factor;
4666 fc->data_factor = cie->data_factor;
4667 fc->cfa_reg = cie->cfa_reg;
4668 fc->cfa_offset = cie->cfa_offset;
4670 frame_need_space (fc, max_regs - 1);
4671 fc->fde_encoding = cie->fde_encoding;
4674 if (fc->fde_encoding)
4675 encoded_ptr_size = size_of_encoded_value (fc->fde_encoding);
4677 segment_selector = 0;
4678 if (fc->segment_size)
4680 segment_selector = byte_get (start, fc->segment_size);
4681 start += fc->segment_size;
4683 fc->pc_begin = get_encoded_value (start, fc->fde_encoding, section);
4684 start += encoded_ptr_size;
4685 fc->pc_range = byte_get (start, encoded_ptr_size);
4686 start += encoded_ptr_size;
4688 if (cie->augmentation[0] == 'z')
4690 augmentation_data_len = LEB ();
4691 augmentation_data = start;
4692 start += augmentation_data_len;
4695 printf ("\n%08lx %08lx %08lx FDE cie=%08lx pc=",
4696 (unsigned long)(saved_start - section_start), length, cie_id,
4697 (unsigned long)(cie->chunk_start - section_start));
4698 if (fc->segment_size)
4699 printf ("%04lx:", segment_selector);
4700 printf ("%08lx..%08lx\n", fc->pc_begin, fc->pc_begin + fc->pc_range);
4701 if (! do_debug_frames_interp && augmentation_data_len)
4705 printf (" Augmentation data: ");
4706 for (i = 0; i < augmentation_data_len; ++i)
4707 printf (" %02x", augmentation_data[i]);
4713 /* At this point, fc is the current chunk, cie (if any) is set, and
4714 we're about to interpret instructions for the chunk. */
4715 /* ??? At present we need to do this always, since this sizes the
4716 fc->col_type and fc->col_offset arrays, which we write into always.
4717 We should probably split the interpreted and non-interpreted bits
4718 into two different routines, since there's so much that doesn't
4719 really overlap between them. */
4720 if (1 || do_debug_frames_interp)
4722 /* Start by making a pass over the chunk, allocating storage
4723 and taking note of what registers are used. */
4724 unsigned char *tmp = start;
4726 while (start < block_end)
4729 unsigned long reg, temp;
4736 /* Warning: if you add any more cases to this switch, be
4737 sure to add them to the corresponding switch below. */
4740 case DW_CFA_advance_loc:
4744 if (frame_need_space (fc, opa) >= 0)
4745 fc->col_type[opa] = DW_CFA_undefined;
4747 case DW_CFA_restore:
4748 if (frame_need_space (fc, opa) >= 0)
4749 fc->col_type[opa] = DW_CFA_undefined;
4751 case DW_CFA_set_loc:
4752 start += encoded_ptr_size;
4754 case DW_CFA_advance_loc1:
4757 case DW_CFA_advance_loc2:
4760 case DW_CFA_advance_loc4:
4763 case DW_CFA_offset_extended:
4764 case DW_CFA_val_offset:
4765 reg = LEB (); LEB ();
4766 if (frame_need_space (fc, reg) >= 0)
4767 fc->col_type[reg] = DW_CFA_undefined;
4769 case DW_CFA_restore_extended:
4771 frame_need_space (fc, reg);
4772 if (frame_need_space (fc, reg) >= 0)
4773 fc->col_type[reg] = DW_CFA_undefined;
4775 case DW_CFA_undefined:
4777 if (frame_need_space (fc, reg) >= 0)
4778 fc->col_type[reg] = DW_CFA_undefined;
4780 case DW_CFA_same_value:
4782 if (frame_need_space (fc, reg) >= 0)
4783 fc->col_type[reg] = DW_CFA_undefined;
4785 case DW_CFA_register:
4786 reg = LEB (); LEB ();
4787 if (frame_need_space (fc, reg) >= 0)
4788 fc->col_type[reg] = DW_CFA_undefined;
4790 case DW_CFA_def_cfa:
4793 case DW_CFA_def_cfa_register:
4796 case DW_CFA_def_cfa_offset:
4799 case DW_CFA_def_cfa_expression:
4803 case DW_CFA_expression:
4804 case DW_CFA_val_expression:
4808 if (frame_need_space (fc, reg) >= 0)
4809 fc->col_type[reg] = DW_CFA_undefined;
4811 case DW_CFA_offset_extended_sf:
4812 case DW_CFA_val_offset_sf:
4813 reg = LEB (); SLEB ();
4814 if (frame_need_space (fc, reg) >= 0)
4815 fc->col_type[reg] = DW_CFA_undefined;
4817 case DW_CFA_def_cfa_sf:
4820 case DW_CFA_def_cfa_offset_sf:
4823 case DW_CFA_MIPS_advance_loc8:
4826 case DW_CFA_GNU_args_size:
4829 case DW_CFA_GNU_negative_offset_extended:
4830 reg = LEB (); LEB ();
4831 if (frame_need_space (fc, reg) >= 0)
4832 fc->col_type[reg] = DW_CFA_undefined;
4841 /* Now we know what registers are used, make a second pass over
4842 the chunk, this time actually printing out the info. */
4844 while (start < block_end)
4847 unsigned long ul, reg, roffs;
4850 const char *reg_prefix = "";
4857 /* Warning: if you add any more cases to this switch, be
4858 sure to add them to the corresponding switch above. */
4861 case DW_CFA_advance_loc:
4862 if (do_debug_frames_interp)
4863 frame_display_row (fc, &need_col_headers, &max_regs);
4865 printf (" DW_CFA_advance_loc: %d to %08lx\n",
4866 opa * fc->code_factor,
4867 fc->pc_begin + opa * fc->code_factor);
4868 fc->pc_begin += opa * fc->code_factor;
4873 if (opa >= (unsigned int) fc->ncols)
4874 reg_prefix = bad_reg;
4875 if (! do_debug_frames_interp || *reg_prefix != '\0')
4876 printf (" DW_CFA_offset: %s%s at cfa%+ld\n",
4877 reg_prefix, regname (opa, 0),
4878 roffs * fc->data_factor);
4879 if (*reg_prefix == '\0')
4881 fc->col_type[opa] = DW_CFA_offset;
4882 fc->col_offset[opa] = roffs * fc->data_factor;
4886 case DW_CFA_restore:
4887 if (opa >= (unsigned int) cie->ncols
4888 || opa >= (unsigned int) fc->ncols)
4889 reg_prefix = bad_reg;
4890 if (! do_debug_frames_interp || *reg_prefix != '\0')
4891 printf (" DW_CFA_restore: %s%s\n",
4892 reg_prefix, regname (opa, 0));
4893 if (*reg_prefix == '\0')
4895 fc->col_type[opa] = cie->col_type[opa];
4896 fc->col_offset[opa] = cie->col_offset[opa];
4897 if (do_debug_frames_interp
4898 && fc->col_type[opa] == DW_CFA_unreferenced)
4899 fc->col_type[opa] = DW_CFA_undefined;
4903 case DW_CFA_set_loc:
4904 vma = get_encoded_value (start, fc->fde_encoding, section);
4905 start += encoded_ptr_size;
4906 if (do_debug_frames_interp)
4907 frame_display_row (fc, &need_col_headers, &max_regs);
4909 printf (" DW_CFA_set_loc: %08lx\n", (unsigned long)vma);
4913 case DW_CFA_advance_loc1:
4914 ofs = byte_get (start, 1); start += 1;
4915 if (do_debug_frames_interp)
4916 frame_display_row (fc, &need_col_headers, &max_regs);
4918 printf (" DW_CFA_advance_loc1: %ld to %08lx\n",
4919 ofs * fc->code_factor,
4920 fc->pc_begin + ofs * fc->code_factor);
4921 fc->pc_begin += ofs * fc->code_factor;
4924 case DW_CFA_advance_loc2:
4925 ofs = byte_get (start, 2); start += 2;
4926 if (do_debug_frames_interp)
4927 frame_display_row (fc, &need_col_headers, &max_regs);
4929 printf (" DW_CFA_advance_loc2: %ld to %08lx\n",
4930 ofs * fc->code_factor,
4931 fc->pc_begin + ofs * fc->code_factor);
4932 fc->pc_begin += ofs * fc->code_factor;
4935 case DW_CFA_advance_loc4:
4936 ofs = byte_get (start, 4); start += 4;
4937 if (do_debug_frames_interp)
4938 frame_display_row (fc, &need_col_headers, &max_regs);
4940 printf (" DW_CFA_advance_loc4: %ld to %08lx\n",
4941 ofs * fc->code_factor,
4942 fc->pc_begin + ofs * fc->code_factor);
4943 fc->pc_begin += ofs * fc->code_factor;
4946 case DW_CFA_offset_extended:
4949 if (reg >= (unsigned int) fc->ncols)
4950 reg_prefix = bad_reg;
4951 if (! do_debug_frames_interp || *reg_prefix != '\0')
4952 printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n",
4953 reg_prefix, regname (reg, 0),
4954 roffs * fc->data_factor);
4955 if (*reg_prefix == '\0')
4957 fc->col_type[reg] = DW_CFA_offset;
4958 fc->col_offset[reg] = roffs * fc->data_factor;
4962 case DW_CFA_val_offset:
4965 if (reg >= (unsigned int) fc->ncols)
4966 reg_prefix = bad_reg;
4967 if (! do_debug_frames_interp || *reg_prefix != '\0')
4968 printf (" DW_CFA_val_offset: %s%s at cfa%+ld\n",
4969 reg_prefix, regname (reg, 0),
4970 roffs * fc->data_factor);
4971 if (*reg_prefix == '\0')
4973 fc->col_type[reg] = DW_CFA_val_offset;
4974 fc->col_offset[reg] = roffs * fc->data_factor;
4978 case DW_CFA_restore_extended:
4980 if (reg >= (unsigned int) cie->ncols
4981 || reg >= (unsigned int) fc->ncols)
4982 reg_prefix = bad_reg;
4983 if (! do_debug_frames_interp || *reg_prefix != '\0')
4984 printf (" DW_CFA_restore_extended: %s%s\n",
4985 reg_prefix, regname (reg, 0));
4986 if (*reg_prefix == '\0')
4988 fc->col_type[reg] = cie->col_type[reg];
4989 fc->col_offset[reg] = cie->col_offset[reg];
4993 case DW_CFA_undefined:
4995 if (reg >= (unsigned int) fc->ncols)
4996 reg_prefix = bad_reg;
4997 if (! do_debug_frames_interp || *reg_prefix != '\0')
4998 printf (" DW_CFA_undefined: %s%s\n",
4999 reg_prefix, regname (reg, 0));
5000 if (*reg_prefix == '\0')
5002 fc->col_type[reg] = DW_CFA_undefined;
5003 fc->col_offset[reg] = 0;
5007 case DW_CFA_same_value:
5009 if (reg >= (unsigned int) fc->ncols)
5010 reg_prefix = bad_reg;
5011 if (! do_debug_frames_interp || *reg_prefix != '\0')
5012 printf (" DW_CFA_same_value: %s%s\n",
5013 reg_prefix, regname (reg, 0));
5014 if (*reg_prefix == '\0')
5016 fc->col_type[reg] = DW_CFA_same_value;
5017 fc->col_offset[reg] = 0;
5021 case DW_CFA_register:
5024 if (reg >= (unsigned int) fc->ncols)
5025 reg_prefix = bad_reg;
5026 if (! do_debug_frames_interp || *reg_prefix != '\0')
5028 printf (" DW_CFA_register: %s%s in ",
5029 reg_prefix, regname (reg, 0));
5030 puts (regname (roffs, 0));
5032 if (*reg_prefix == '\0')
5034 fc->col_type[reg] = DW_CFA_register;
5035 fc->col_offset[reg] = roffs;
5039 case DW_CFA_remember_state:
5040 if (! do_debug_frames_interp)
5041 printf (" DW_CFA_remember_state\n");
5042 rs = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk));
5043 rs->ncols = fc->ncols;
5044 rs->col_type = (short int *) xcmalloc (rs->ncols,
5045 sizeof (short int));
5046 rs->col_offset = (int *) xcmalloc (rs->ncols, sizeof (int));
5047 memcpy (rs->col_type, fc->col_type, rs->ncols);
5048 memcpy (rs->col_offset, fc->col_offset, rs->ncols * sizeof (int));
5049 rs->next = remembered_state;
5050 remembered_state = rs;
5053 case DW_CFA_restore_state:
5054 if (! do_debug_frames_interp)
5055 printf (" DW_CFA_restore_state\n");
5056 rs = remembered_state;
5059 remembered_state = rs->next;
5060 frame_need_space (fc, rs->ncols - 1);
5061 memcpy (fc->col_type, rs->col_type, rs->ncols);
5062 memcpy (fc->col_offset, rs->col_offset,
5063 rs->ncols * sizeof (int));
5064 free (rs->col_type);
5065 free (rs->col_offset);
5068 else if (do_debug_frames_interp)
5069 printf ("Mismatched DW_CFA_restore_state\n");
5072 case DW_CFA_def_cfa:
5073 fc->cfa_reg = LEB ();
5074 fc->cfa_offset = LEB ();
5076 if (! do_debug_frames_interp)
5077 printf (" DW_CFA_def_cfa: %s ofs %d\n",
5078 regname (fc->cfa_reg, 0), fc->cfa_offset);
5081 case DW_CFA_def_cfa_register:
5082 fc->cfa_reg = LEB ();
5084 if (! do_debug_frames_interp)
5085 printf (" DW_CFA_def_cfa_register: %s\n",
5086 regname (fc->cfa_reg, 0));
5089 case DW_CFA_def_cfa_offset:
5090 fc->cfa_offset = LEB ();
5091 if (! do_debug_frames_interp)
5092 printf (" DW_CFA_def_cfa_offset: %d\n", fc->cfa_offset);
5096 if (! do_debug_frames_interp)
5097 printf (" DW_CFA_nop\n");
5100 case DW_CFA_def_cfa_expression:
5102 if (! do_debug_frames_interp)
5104 printf (" DW_CFA_def_cfa_expression (");
5105 decode_location_expression (start, eh_addr_size, 0, -1,
5113 case DW_CFA_expression:
5116 if (reg >= (unsigned int) fc->ncols)
5117 reg_prefix = bad_reg;
5118 if (! do_debug_frames_interp || *reg_prefix != '\0')
5120 printf (" DW_CFA_expression: %s%s (",
5121 reg_prefix, regname (reg, 0));
5122 decode_location_expression (start, eh_addr_size, 0, -1,
5126 if (*reg_prefix == '\0')
5127 fc->col_type[reg] = DW_CFA_expression;
5131 case DW_CFA_val_expression:
5134 if (reg >= (unsigned int) fc->ncols)
5135 reg_prefix = bad_reg;
5136 if (! do_debug_frames_interp || *reg_prefix != '\0')
5138 printf (" DW_CFA_val_expression: %s%s (",
5139 reg_prefix, regname (reg, 0));
5140 decode_location_expression (start, eh_addr_size, 0, -1,
5144 if (*reg_prefix == '\0')
5145 fc->col_type[reg] = DW_CFA_val_expression;
5149 case DW_CFA_offset_extended_sf:
5152 if (frame_need_space (fc, reg) < 0)
5153 reg_prefix = bad_reg;
5154 if (! do_debug_frames_interp || *reg_prefix != '\0')
5155 printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n",
5156 reg_prefix, regname (reg, 0),
5157 l * fc->data_factor);
5158 if (*reg_prefix == '\0')
5160 fc->col_type[reg] = DW_CFA_offset;
5161 fc->col_offset[reg] = l * fc->data_factor;
5165 case DW_CFA_val_offset_sf:
5168 if (frame_need_space (fc, reg) < 0)
5169 reg_prefix = bad_reg;
5170 if (! do_debug_frames_interp || *reg_prefix != '\0')
5171 printf (" DW_CFA_val_offset_sf: %s%s at cfa%+ld\n",
5172 reg_prefix, regname (reg, 0),
5173 l * fc->data_factor);
5174 if (*reg_prefix == '\0')
5176 fc->col_type[reg] = DW_CFA_val_offset;
5177 fc->col_offset[reg] = l * fc->data_factor;
5181 case DW_CFA_def_cfa_sf:
5182 fc->cfa_reg = LEB ();
5183 fc->cfa_offset = SLEB ();
5184 fc->cfa_offset = fc->cfa_offset * fc->data_factor;
5186 if (! do_debug_frames_interp)
5187 printf (" DW_CFA_def_cfa_sf: %s ofs %d\n",
5188 regname (fc->cfa_reg, 0), fc->cfa_offset);
5191 case DW_CFA_def_cfa_offset_sf:
5192 fc->cfa_offset = SLEB ();
5193 fc->cfa_offset = fc->cfa_offset * fc->data_factor;
5194 if (! do_debug_frames_interp)
5195 printf (" DW_CFA_def_cfa_offset_sf: %d\n", fc->cfa_offset);
5198 case DW_CFA_MIPS_advance_loc8:
5199 ofs = byte_get (start, 8); start += 8;
5200 if (do_debug_frames_interp)
5201 frame_display_row (fc, &need_col_headers, &max_regs);
5203 printf (" DW_CFA_MIPS_advance_loc8: %ld to %08lx\n",
5204 ofs * fc->code_factor,
5205 fc->pc_begin + ofs * fc->code_factor);
5206 fc->pc_begin += ofs * fc->code_factor;
5209 case DW_CFA_GNU_window_save:
5210 if (! do_debug_frames_interp)
5211 printf (" DW_CFA_GNU_window_save\n");
5214 case DW_CFA_GNU_args_size:
5216 if (! do_debug_frames_interp)
5217 printf (" DW_CFA_GNU_args_size: %ld\n", ul);
5220 case DW_CFA_GNU_negative_offset_extended:
5223 if (frame_need_space (fc, reg) < 0)
5224 reg_prefix = bad_reg;
5225 if (! do_debug_frames_interp || *reg_prefix != '\0')
5226 printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n",
5227 reg_prefix, regname (reg, 0),
5228 l * fc->data_factor);
5229 if (*reg_prefix == '\0')
5231 fc->col_type[reg] = DW_CFA_offset;
5232 fc->col_offset[reg] = l * fc->data_factor;
5237 if (op >= DW_CFA_lo_user && op <= DW_CFA_hi_user)
5238 printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op);
5240 warn (_("unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op);
5245 if (do_debug_frames_interp)
5246 frame_display_row (fc, &need_col_headers, &max_regs);
5249 eh_addr_size = saved_eh_addr_size;
5262 display_gdb_index (struct dwarf_section *section,
5263 void *file ATTRIBUTE_UNUSED)
5265 unsigned char *start = section->start;
5267 uint32_t cu_list_offset, tu_list_offset;
5268 uint32_t address_table_offset, symbol_table_offset, constant_pool_offset;
5269 unsigned int cu_list_elements, tu_list_elements;
5270 unsigned int address_table_size, symbol_table_slots;
5271 unsigned char *cu_list, *tu_list;
5272 unsigned char *address_table, *symbol_table, *constant_pool;
5275 /* The documentation for the format of this file is in gdb/dwarf2read.c. */
5277 printf (_("Contents of the %s section:\n"), section->name);
5279 if (section->size < 6 * sizeof (uint32_t))
5281 warn (_("Truncated header in the %s section.\n"), section->name);
5285 version = byte_get_little_endian (start, 4);
5286 printf (_("Version %ld\n"), (long) version);
5288 /* Prior versions are obsolete, and future versions may not be
5289 backwards compatible. */
5293 warn (_("The address table data in version 3 may be wrong.\n"));
5296 warn (_("Version 4 does not support case insensitive lookups.\n"));
5299 warn (_("Version 5 does not include inlined functions.\n"));
5304 warn (_("Unsupported version %lu.\n"), (unsigned long) version);
5308 cu_list_offset = byte_get_little_endian (start + 4, 4);
5309 tu_list_offset = byte_get_little_endian (start + 8, 4);
5310 address_table_offset = byte_get_little_endian (start + 12, 4);
5311 symbol_table_offset = byte_get_little_endian (start + 16, 4);
5312 constant_pool_offset = byte_get_little_endian (start + 20, 4);
5314 if (cu_list_offset > section->size
5315 || tu_list_offset > section->size
5316 || address_table_offset > section->size
5317 || symbol_table_offset > section->size
5318 || constant_pool_offset > section->size)
5320 warn (_("Corrupt header in the %s section.\n"), section->name);
5324 cu_list_elements = (tu_list_offset - cu_list_offset) / 8;
5325 tu_list_elements = (address_table_offset - tu_list_offset) / 8;
5326 address_table_size = symbol_table_offset - address_table_offset;
5327 symbol_table_slots = (constant_pool_offset - symbol_table_offset) / 8;
5329 cu_list = start + cu_list_offset;
5330 tu_list = start + tu_list_offset;
5331 address_table = start + address_table_offset;
5332 symbol_table = start + symbol_table_offset;
5333 constant_pool = start + constant_pool_offset;
5335 printf (_("\nCU table:\n"));
5336 for (i = 0; i < cu_list_elements; i += 2)
5338 uint64_t cu_offset = byte_get_little_endian (cu_list + i * 8, 8);
5339 uint64_t cu_length = byte_get_little_endian (cu_list + i * 8 + 8, 8);
5341 printf (_("[%3u] 0x%lx - 0x%lx\n"), i / 2,
5342 (unsigned long) cu_offset,
5343 (unsigned long) (cu_offset + cu_length - 1));
5346 printf (_("\nTU table:\n"));
5347 for (i = 0; i < tu_list_elements; i += 3)
5349 uint64_t tu_offset = byte_get_little_endian (tu_list + i * 8, 8);
5350 uint64_t type_offset = byte_get_little_endian (tu_list + i * 8 + 8, 8);
5351 uint64_t signature = byte_get_little_endian (tu_list + i * 8 + 16, 8);
5353 printf (_("[%3u] 0x%lx 0x%lx "), i / 3,
5354 (unsigned long) tu_offset,
5355 (unsigned long) type_offset);
5356 print_dwarf_vma (signature, 8);
5360 printf (_("\nAddress table:\n"));
5361 for (i = 0; i < address_table_size; i += 2 * 8 + 4)
5363 uint64_t low = byte_get_little_endian (address_table + i, 8);
5364 uint64_t high = byte_get_little_endian (address_table + i + 8, 8);
5365 uint32_t cu_index = byte_get_little_endian (address_table + i + 16, 4);
5367 print_dwarf_vma (low, 8);
5368 print_dwarf_vma (high, 8);
5369 printf (_("%lu\n"), (unsigned long) cu_index);
5372 printf (_("\nSymbol table:\n"));
5373 for (i = 0; i < symbol_table_slots; ++i)
5375 uint32_t name_offset = byte_get_little_endian (symbol_table + i * 8, 4);
5376 uint32_t cu_vector_offset = byte_get_little_endian (symbol_table + i * 8 + 4, 4);
5377 uint32_t num_cus, cu;
5379 if (name_offset != 0
5380 || cu_vector_offset != 0)
5384 printf ("[%3u] %s:", i, constant_pool + name_offset);
5385 num_cus = byte_get_little_endian (constant_pool + cu_vector_offset, 4);
5386 for (j = 0; j < num_cus; ++j)
5388 cu = byte_get_little_endian (constant_pool + cu_vector_offset + 4 + j * 4, 4);
5389 /* Convert to TU number if it's for a type unit. */
5390 if (cu >= cu_list_elements / 2)
5391 printf (" T%lu", (unsigned long) (cu - cu_list_elements / 2));
5393 printf (" %lu", (unsigned long) cu);
5403 display_debug_not_supported (struct dwarf_section *section,
5404 void *file ATTRIBUTE_UNUSED)
5406 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
5413 cmalloc (size_t nmemb, size_t size)
5415 /* Check for overflow. */
5416 if (nmemb >= ~(size_t) 0 / size)
5419 return malloc (nmemb * size);
5423 xcmalloc (size_t nmemb, size_t size)
5425 /* Check for overflow. */
5426 if (nmemb >= ~(size_t) 0 / size)
5429 return xmalloc (nmemb * size);
5433 xcrealloc (void *ptr, size_t nmemb, size_t size)
5435 /* Check for overflow. */
5436 if (nmemb >= ~(size_t) 0 / size)
5439 return xrealloc (ptr, nmemb * size);
5443 free_debug_memory (void)
5449 for (i = 0; i < max; i++)
5450 free_debug_section ((enum dwarf_section_display_enum) i);
5452 if (debug_information != NULL)
5454 if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE)
5456 for (i = 0; i < num_debug_info_entries; i++)
5458 if (!debug_information [i].max_loc_offsets)
5460 free (debug_information [i].loc_offsets);
5461 free (debug_information [i].have_frame_base);
5463 if (!debug_information [i].max_range_lists)
5464 free (debug_information [i].range_lists);
5468 free (debug_information);
5469 debug_information = NULL;
5470 num_debug_info_entries = 0;
5475 dwarf_select_sections_by_names (const char *names)
5479 const char * option;
5483 debug_dump_long_opts;
5485 static const debug_dump_long_opts opts_table [] =
5487 /* Please keep this table alpha- sorted. */
5488 { "Ranges", & do_debug_ranges, 1 },
5489 { "abbrev", & do_debug_abbrevs, 1 },
5490 { "aranges", & do_debug_aranges, 1 },
5491 { "frames", & do_debug_frames, 1 },
5492 { "frames-interp", & do_debug_frames_interp, 1 },
5493 { "info", & do_debug_info, 1 },
5494 { "line", & do_debug_lines, FLAG_DEBUG_LINES_RAW }, /* For backwards compatibility. */
5495 { "rawline", & do_debug_lines, FLAG_DEBUG_LINES_RAW },
5496 { "decodedline", & do_debug_lines, FLAG_DEBUG_LINES_DECODED },
5497 { "loc", & do_debug_loc, 1 },
5498 { "macro", & do_debug_macinfo, 1 },
5499 { "pubnames", & do_debug_pubnames, 1 },
5500 { "pubtypes", & do_debug_pubtypes, 1 },
5501 /* This entry is for compatability
5502 with earlier versions of readelf. */
5503 { "ranges", & do_debug_aranges, 1 },
5504 { "str", & do_debug_str, 1 },
5505 /* The special .gdb_index section. */
5506 { "gdb_index", & do_gdb_index, 1 },
5507 /* These trace_* sections are used by Itanium VMS. */
5508 { "trace_abbrev", & do_trace_abbrevs, 1 },
5509 { "trace_aranges", & do_trace_aranges, 1 },
5510 { "trace_info", & do_trace_info, 1 },
5519 const debug_dump_long_opts * entry;
5521 for (entry = opts_table; entry->option; entry++)
5523 size_t len = strlen (entry->option);
5525 if (strncmp (p, entry->option, len) == 0
5526 && (p[len] == ',' || p[len] == '\0'))
5528 * entry->variable |= entry->val;
5530 /* The --debug-dump=frames-interp option also
5531 enables the --debug-dump=frames option. */
5532 if (do_debug_frames_interp)
5533 do_debug_frames = 1;
5540 if (entry->option == NULL)
5542 warn (_("Unrecognized debug option '%s'\n"), p);
5543 p = strchr (p, ',');
5554 dwarf_select_sections_by_letters (const char *letters)
5556 unsigned int lindex = 0;
5558 while (letters[lindex])
5559 switch (letters[lindex++])
5566 do_debug_abbrevs = 1;
5570 do_debug_lines |= FLAG_DEBUG_LINES_RAW;
5574 do_debug_lines |= FLAG_DEBUG_LINES_DECODED;
5578 do_debug_pubnames = 1;
5582 do_debug_pubtypes = 1;
5586 do_debug_aranges = 1;
5590 do_debug_ranges = 1;
5594 do_debug_frames_interp = 1;
5596 do_debug_frames = 1;
5600 do_debug_macinfo = 1;
5612 warn (_("Unrecognized debug option '%s'\n"), optarg);
5618 dwarf_select_sections_all (void)
5621 do_debug_abbrevs = 1;
5622 do_debug_lines = FLAG_DEBUG_LINES_RAW;
5623 do_debug_pubnames = 1;
5624 do_debug_pubtypes = 1;
5625 do_debug_aranges = 1;
5626 do_debug_ranges = 1;
5627 do_debug_frames = 1;
5628 do_debug_macinfo = 1;
5633 do_trace_abbrevs = 1;
5634 do_trace_aranges = 1;
5637 struct dwarf_section_display debug_displays[] =
5639 { { ".debug_abbrev", ".zdebug_abbrev", NULL, NULL, 0, 0 },
5640 display_debug_abbrev, &do_debug_abbrevs, 0 },
5641 { { ".debug_aranges", ".zdebug_aranges", NULL, NULL, 0, 0 },
5642 display_debug_aranges, &do_debug_aranges, 1 },
5643 { { ".debug_frame", ".zdebug_frame", NULL, NULL, 0, 0 },
5644 display_debug_frames, &do_debug_frames, 1 },
5645 { { ".debug_info", ".zdebug_info", NULL, NULL, 0, 0 },
5646 display_debug_info, &do_debug_info, 1 },
5647 { { ".debug_line", ".zdebug_line", NULL, NULL, 0, 0 },
5648 display_debug_lines, &do_debug_lines, 1 },
5649 { { ".debug_pubnames", ".zdebug_pubnames", NULL, NULL, 0, 0 },
5650 display_debug_pubnames, &do_debug_pubnames, 0 },
5651 { { ".eh_frame", "", NULL, NULL, 0, 0 },
5652 display_debug_frames, &do_debug_frames, 1 },
5653 { { ".debug_macinfo", ".zdebug_macinfo", NULL, NULL, 0, 0 },
5654 display_debug_macinfo, &do_debug_macinfo, 0 },
5655 { { ".debug_macro", ".zdebug_macro", NULL, NULL, 0, 0 },
5656 display_debug_macro, &do_debug_macinfo, 1 },
5657 { { ".debug_str", ".zdebug_str", NULL, NULL, 0, 0 },
5658 display_debug_str, &do_debug_str, 0 },
5659 { { ".debug_loc", ".zdebug_loc", NULL, NULL, 0, 0 },
5660 display_debug_loc, &do_debug_loc, 1 },
5661 { { ".debug_pubtypes", ".zdebug_pubtypes", NULL, NULL, 0, 0 },
5662 display_debug_pubnames, &do_debug_pubtypes, 0 },
5663 { { ".debug_ranges", ".zdebug_ranges", NULL, NULL, 0, 0 },
5664 display_debug_ranges, &do_debug_ranges, 1 },
5665 { { ".debug_static_func", ".zdebug_static_func", NULL, NULL, 0, 0 },
5666 display_debug_not_supported, NULL, 0 },
5667 { { ".debug_static_vars", ".zdebug_static_vars", NULL, NULL, 0, 0 },
5668 display_debug_not_supported, NULL, 0 },
5669 { { ".debug_types", ".zdebug_types", NULL, NULL, 0, 0 },
5670 display_debug_types, &do_debug_info, 1 },
5671 { { ".debug_weaknames", ".zdebug_weaknames", NULL, NULL, 0, 0 },
5672 display_debug_not_supported, NULL, 0 },
5673 { { ".gdb_index", "", NULL, NULL, 0, 0 },
5674 display_gdb_index, &do_gdb_index, 0 },
5675 { { ".trace_info", "", NULL, NULL, 0, 0 },
5676 display_trace_info, &do_trace_info, 1 },
5677 { { ".trace_abbrev", "", NULL, NULL, 0, 0 },
5678 display_debug_abbrev, &do_trace_abbrevs, 0 },
5679 { { ".trace_aranges", "", NULL, NULL, 0, 0 },
5680 display_debug_aranges, &do_trace_aranges, 0 }