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
;
71 /* Values for do_debug_lines. */
72 #define FLAG_DEBUG_LINES_RAW 1
73 #define FLAG_DEBUG_LINES_DECODED 2
76 size_of_encoded_value (int encoding
)
78 switch (encoding
& 0x7)
81 case 0: return eh_addr_size
;
89 get_encoded_value (unsigned char *data
,
91 struct dwarf_section
*section
)
93 int size
= size_of_encoded_value (encoding
);
96 if (encoding
& DW_EH_PE_signed
)
97 val
= byte_get_signed (data
, size
);
99 val
= byte_get (data
, size
);
101 if ((encoding
& 0x70) == DW_EH_PE_pcrel
)
102 val
+= section
->address
+ (data
- section
->start
);
106 /* Print a dwarf_vma value (typically an address, offset or length) in
107 hexadecimal format, followed by a space. The length of the value (and
108 hence the precision displayed) is determined by the byte_size parameter. */
111 print_dwarf_vma (dwarf_vma val
, unsigned byte_size
)
113 static char buff
[18];
116 /* Printf does not have a way of specifiying a maximum field width for an
117 integer value, so we print the full value into a buffer and then select
118 the precision we need. */
119 #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
121 snprintf (buff
, sizeof (buff
), "%16.16llx ", val
);
123 snprintf (buff
, sizeof (buff
), "%016I64x ", val
);
126 snprintf (buff
, sizeof (buff
), "%16.16lx ", val
);
131 if (byte_size
> 0 && byte_size
<= 8)
132 offset
= 16 - 2 * byte_size
;
134 error (_("Wrong size in print_dwarf_vma"));
137 fputs (buff
+ offset
, stdout
);
140 #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
142 #define DWARF_VMA_FMT "ll"
144 #define DWARF_VMA_FMT "I64"
147 #define DWARF_VMA_FMT "l"
151 dwarf_vmatoa (const char *fmtch
, dwarf_vma value
)
153 /* As dwarf_vmatoa is used more then once in a printf call
154 for output, we are cycling through an fixed array of pointers
155 for return address. */
156 static int buf_pos
= 0;
157 static struct dwarf_vmatoa_buf
164 sprintf (fmt
, "%%%s%s", DWARF_VMA_FMT
, fmtch
);
166 ret
= buf
[buf_pos
++].place
;
167 buf_pos
%= ARRAY_SIZE (buf
);
169 snprintf (ret
, sizeof (buf
[0].place
), fmt
, value
);
174 /* Format a 64-bit value, given as two 32-bit values, in hex.
175 For reentrancy, this uses a buffer provided by the caller. */
178 dwarf_vmatoa64 (dwarf_vma hvalue
, dwarf_vma lvalue
, char *buf
,
179 unsigned int buf_len
)
184 snprintf (buf
, buf_len
, "%" DWARF_VMA_FMT
"x", lvalue
);
187 len
= snprintf (buf
, buf_len
, "%" DWARF_VMA_FMT
"x", hvalue
);
188 snprintf (buf
+ len
, buf_len
- len
,
189 "%08" DWARF_VMA_FMT
"x", lvalue
);
196 read_leb128 (unsigned char *data
, unsigned int *length_return
, int sign
)
198 dwarf_vma result
= 0;
199 unsigned int num_read
= 0;
200 unsigned int shift
= 0;
208 result
|= ((dwarf_vma
) (byte
& 0x7f)) << shift
;
215 if (length_return
!= NULL
)
216 *length_return
= num_read
;
218 if (sign
&& (shift
< 8 * sizeof (result
)) && (byte
& 0x40))
219 result
|= -1L << shift
;
224 /* Create a signed version to avoid painful typecasts. */
225 static dwarf_signed_vma
226 read_sleb128 (unsigned char *data
, unsigned int *length_return
)
228 return (dwarf_signed_vma
) read_leb128 (data
, length_return
, 1);
231 typedef struct State_Machine_Registers
239 unsigned char op_index
;
240 unsigned char end_sequence
;
241 /* This variable hold the number of the last entry seen
242 in the File Table. */
243 unsigned int last_file_entry
;
246 static SMR state_machine_regs
;
249 reset_state_machine (int is_stmt
)
251 state_machine_regs
.address
= 0;
252 state_machine_regs
.op_index
= 0;
253 state_machine_regs
.file
= 1;
254 state_machine_regs
.line
= 1;
255 state_machine_regs
.column
= 0;
256 state_machine_regs
.is_stmt
= is_stmt
;
257 state_machine_regs
.basic_block
= 0;
258 state_machine_regs
.end_sequence
= 0;
259 state_machine_regs
.last_file_entry
= 0;
262 /* Handled an extend line op.
263 Returns the number of bytes read. */
266 process_extended_line_op (unsigned char *data
, int is_stmt
)
268 unsigned char op_code
;
269 unsigned int bytes_read
;
273 unsigned char *orig_data
= data
;
275 len
= read_leb128 (data
, & bytes_read
, 0);
280 warn (_("badly formed extended line op encountered!\n"));
287 printf (_(" Extended opcode %d: "), op_code
);
291 case DW_LNE_end_sequence
:
292 printf (_("End of Sequence\n\n"));
293 reset_state_machine (is_stmt
);
296 case DW_LNE_set_address
:
297 adr
= byte_get (data
, len
- bytes_read
- 1);
298 printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr
));
299 state_machine_regs
.address
= adr
;
300 state_machine_regs
.op_index
= 0;
303 case DW_LNE_define_file
:
304 printf (_("define new File Table entry\n"));
305 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
307 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
309 data
+= strlen ((char *) data
) + 1;
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)));
314 printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data
, & bytes_read
, 0)));
317 if ((unsigned int) (data
- orig_data
) != len
)
318 printf (_(" [Bad opcode length]"));
322 case DW_LNE_set_discriminator
:
323 printf (_("set Discriminator to %s\n"),
324 dwarf_vmatoa ("u", read_leb128 (data
, & bytes_read
, 0)));
328 case DW_LNE_HP_negate_is_UV_update
:
329 printf ("DW_LNE_HP_negate_is_UV_update\n");
331 case DW_LNE_HP_push_context
:
332 printf ("DW_LNE_HP_push_context\n");
334 case DW_LNE_HP_pop_context
:
335 printf ("DW_LNE_HP_pop_context\n");
337 case DW_LNE_HP_set_file_line_column
:
338 printf ("DW_LNE_HP_set_file_line_column\n");
340 case DW_LNE_HP_set_routine_name
:
341 printf ("DW_LNE_HP_set_routine_name\n");
343 case DW_LNE_HP_set_sequence
:
344 printf ("DW_LNE_HP_set_sequence\n");
346 case DW_LNE_HP_negate_post_semantics
:
347 printf ("DW_LNE_HP_negate_post_semantics\n");
349 case DW_LNE_HP_negate_function_exit
:
350 printf ("DW_LNE_HP_negate_function_exit\n");
352 case DW_LNE_HP_negate_front_end_logical
:
353 printf ("DW_LNE_HP_negate_front_end_logical\n");
355 case DW_LNE_HP_define_proc
:
356 printf ("DW_LNE_HP_define_proc\n");
358 case DW_LNE_HP_source_file_correlation
:
360 unsigned char *edata
= data
+ len
- bytes_read
- 1;
362 printf ("DW_LNE_HP_source_file_correlation\n");
368 opc
= read_leb128 (data
, & bytes_read
, 0);
373 case DW_LNE_HP_SFC_formfeed
:
374 printf (" DW_LNE_HP_SFC_formfeed\n");
376 case DW_LNE_HP_SFC_set_listing_line
:
377 printf (" DW_LNE_HP_SFC_set_listing_line (%s)\n",
379 read_leb128 (data
, & bytes_read
, 0)));
382 case DW_LNE_HP_SFC_associate
:
383 printf (" DW_LNE_HP_SFC_associate ");
386 read_leb128 (data
, & bytes_read
, 0)));
390 read_leb128 (data
, & bytes_read
, 0)));
394 read_leb128 (data
, & bytes_read
, 0)));
398 printf (_(" UNKNOWN DW_LNE_HP_SFC opcode (%u)\n"), opc
);
408 unsigned int rlen
= len
- bytes_read
- 1;
410 if (op_code
>= DW_LNE_lo_user
411 /* The test against DW_LNW_hi_user is redundant due to
412 the limited range of the unsigned char data type used
414 /*&& op_code <= DW_LNE_hi_user*/)
415 printf (_("user defined: "));
417 printf (_("UNKNOWN: "));
418 printf (_("length %d ["), rlen
);
420 printf (" %02x", *data
++);
430 fetch_indirect_string (dwarf_vma offset
)
432 struct dwarf_section
*section
= &debug_displays
[str
].section
;
434 if (section
->start
== NULL
)
435 return _("<no .debug_str section>");
437 /* DWARF sections under Mach-O have non-zero addresses. */
438 offset
-= section
->address
;
439 if (offset
> section
->size
)
441 warn (_("DW_FORM_strp offset too big: %s\n"),
442 dwarf_vmatoa ("x", offset
));
443 return _("<offset is too big>");
446 return (const char *) section
->start
+ offset
;
450 fetch_indexed_string (dwarf_vma idx
, dwarf_vma offset_size
, int dwo
)
452 enum dwarf_section_display_enum str_sec_idx
= dwo
? str_dwo
: str
;
453 enum dwarf_section_display_enum idx_sec_idx
= dwo
? str_index_dwo
: str_index
;
454 struct dwarf_section
*index_section
= &debug_displays
[idx_sec_idx
].section
;
455 struct dwarf_section
*str_section
= &debug_displays
[str_sec_idx
].section
;
456 dwarf_vma index_offset
= idx
* offset_size
;
457 dwarf_vma str_offset
;
459 if (index_section
->start
== NULL
)
460 return (dwo
? _("<no .debug_str_offsets.dwo section>")
461 : _("<no .debug_str_offsets section>"));
463 /* DWARF sections under Mach-O have non-zero addresses. */
464 index_offset
-= index_section
->address
;
465 if (index_offset
> index_section
->size
)
467 warn (_("DW_FORM_GNU_str_index offset too big: %s\n"),
468 dwarf_vmatoa ("x", index_offset
));
469 return _("<index offset is too big>");
472 if (str_section
->start
== NULL
)
473 return (dwo
? _("<no .debug_str.dwo section>")
474 : _("<no .debug_str section>"));
476 str_offset
= byte_get (index_section
->start
+ index_offset
, offset_size
);
477 str_offset
-= str_section
->address
;
478 if (str_offset
> str_section
->size
)
480 warn (_("DW_FORM_GNU_str_index indirect offset too big: %s\n"),
481 dwarf_vmatoa ("x", str_offset
));
482 return _("<indirect index offset is too big>");
485 return (const char *) str_section
->start
+ str_offset
;
489 fetch_indexed_value (dwarf_vma offset
, dwarf_vma bytes
)
491 struct dwarf_section
*section
= &debug_displays
[debug_addr
].section
;
493 if (section
->start
== NULL
)
494 return (_("<no .debug_addr section>"));
496 if (offset
+ bytes
> section
->size
)
498 warn (_("Offset into section %s too big: %s\n"),
499 section
->name
, dwarf_vmatoa ("x", offset
));
500 return "<offset too big>";
503 return dwarf_vmatoa ("x", byte_get (section
->start
+ offset
, bytes
));
507 /* FIXME: There are better and more efficient ways to handle
508 these structures. For now though, I just want something that
509 is simple to implement. */
510 typedef struct abbrev_attr
512 unsigned long attribute
;
514 struct abbrev_attr
*next
;
518 typedef struct abbrev_entry
523 struct abbrev_attr
*first_attr
;
524 struct abbrev_attr
*last_attr
;
525 struct abbrev_entry
*next
;
529 static abbrev_entry
*first_abbrev
= NULL
;
530 static abbrev_entry
*last_abbrev
= NULL
;
537 for (abbrv
= first_abbrev
; abbrv
;)
539 abbrev_entry
*next_abbrev
= abbrv
->next
;
542 for (attr
= abbrv
->first_attr
; attr
;)
544 abbrev_attr
*next_attr
= attr
->next
;
554 last_abbrev
= first_abbrev
= NULL
;
558 add_abbrev (unsigned long number
, unsigned long tag
, int children
)
562 entry
= (abbrev_entry
*) malloc (sizeof (*entry
));
567 entry
->entry
= number
;
569 entry
->children
= children
;
570 entry
->first_attr
= NULL
;
571 entry
->last_attr
= NULL
;
574 if (first_abbrev
== NULL
)
575 first_abbrev
= entry
;
577 last_abbrev
->next
= entry
;
583 add_abbrev_attr (unsigned long attribute
, unsigned long form
)
587 attr
= (abbrev_attr
*) malloc (sizeof (*attr
));
592 attr
->attribute
= attribute
;
596 if (last_abbrev
->first_attr
== NULL
)
597 last_abbrev
->first_attr
= attr
;
599 last_abbrev
->last_attr
->next
= attr
;
601 last_abbrev
->last_attr
= attr
;
604 /* Processes the (partial) contents of a .debug_abbrev section.
605 Returns NULL if the end of the section was encountered.
606 Returns the address after the last byte read if the end of
607 an abbreviation set was found. */
609 static unsigned char *
610 process_abbrev_section (unsigned char *start
, unsigned char *end
)
612 if (first_abbrev
!= NULL
)
617 unsigned int bytes_read
;
620 unsigned long attribute
;
623 entry
= read_leb128 (start
, & bytes_read
, 0);
626 /* A single zero is supposed to end the section according
627 to the standard. If there's more, then signal that to
630 return start
== end
? NULL
: start
;
632 tag
= read_leb128 (start
, & bytes_read
, 0);
637 add_abbrev (entry
, tag
, children
);
643 attribute
= read_leb128 (start
, & bytes_read
, 0);
646 form
= read_leb128 (start
, & bytes_read
, 0);
650 add_abbrev_attr (attribute
, form
);
652 while (attribute
!= 0);
659 get_TAG_name (unsigned long tag
)
661 const char *name
= get_DW_TAG_name ((unsigned int)tag
);
665 static char buffer
[100];
667 snprintf (buffer
, sizeof (buffer
), _("Unknown TAG value: %lx"), tag
);
675 get_FORM_name (unsigned long form
)
677 const char *name
= get_DW_FORM_name (form
);
681 static char buffer
[100];
683 snprintf (buffer
, sizeof (buffer
), _("Unknown FORM value: %lx"), form
);
690 static unsigned char *
691 display_block (unsigned char *data
, dwarf_vma length
)
693 printf (_(" %s byte block: "), dwarf_vmatoa ("u", length
));
696 printf ("%lx ", (unsigned long) byte_get (data
++, 1));
702 decode_location_expression (unsigned char * data
,
703 unsigned int pointer_size
,
704 unsigned int offset_size
,
708 struct dwarf_section
* section
)
711 unsigned int bytes_read
;
713 unsigned char *end
= data
+ length
;
714 int need_frame_base
= 0;
723 printf ("DW_OP_addr: %s",
724 dwarf_vmatoa ("x", byte_get (data
, pointer_size
)));
725 data
+= pointer_size
;
728 printf ("DW_OP_deref");
731 printf ("DW_OP_const1u: %lu", (unsigned long) byte_get (data
++, 1));
734 printf ("DW_OP_const1s: %ld", (long) byte_get_signed (data
++, 1));
737 printf ("DW_OP_const2u: %lu", (unsigned long) byte_get (data
, 2));
741 printf ("DW_OP_const2s: %ld", (long) byte_get_signed (data
, 2));
745 printf ("DW_OP_const4u: %lu", (unsigned long) byte_get (data
, 4));
749 printf ("DW_OP_const4s: %ld", (long) byte_get_signed (data
, 4));
753 printf ("DW_OP_const8u: %lu %lu", (unsigned long) byte_get (data
, 4),
754 (unsigned long) byte_get (data
+ 4, 4));
758 printf ("DW_OP_const8s: %ld %ld", (long) byte_get (data
, 4),
759 (long) byte_get (data
+ 4, 4));
763 printf ("DW_OP_constu: %s",
764 dwarf_vmatoa ("u", read_leb128 (data
, &bytes_read
, 0)));
768 printf ("DW_OP_consts: %s",
769 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
)));
773 printf ("DW_OP_dup");
776 printf ("DW_OP_drop");
779 printf ("DW_OP_over");
782 printf ("DW_OP_pick: %ld", (unsigned long) byte_get (data
++, 1));
785 printf ("DW_OP_swap");
788 printf ("DW_OP_rot");
791 printf ("DW_OP_xderef");
794 printf ("DW_OP_abs");
797 printf ("DW_OP_and");
800 printf ("DW_OP_div");
803 printf ("DW_OP_minus");
806 printf ("DW_OP_mod");
809 printf ("DW_OP_mul");
812 printf ("DW_OP_neg");
815 printf ("DW_OP_not");
821 printf ("DW_OP_plus");
823 case DW_OP_plus_uconst
:
824 printf ("DW_OP_plus_uconst: %s",
825 dwarf_vmatoa ("u", read_leb128 (data
, &bytes_read
, 0)));
829 printf ("DW_OP_shl");
832 printf ("DW_OP_shr");
835 printf ("DW_OP_shra");
838 printf ("DW_OP_xor");
841 printf ("DW_OP_bra: %ld", (long) byte_get_signed (data
, 2));
863 printf ("DW_OP_skip: %ld", (long) byte_get_signed (data
, 2));
899 printf ("DW_OP_lit%d", op
- DW_OP_lit0
);
934 printf ("DW_OP_reg%d (%s)", op
- DW_OP_reg0
,
935 regname (op
- DW_OP_reg0
, 1));
970 printf ("DW_OP_breg%d (%s): %s",
972 regname (op
- DW_OP_breg0
, 1),
973 dwarf_vmatoa ("d", (dwarf_signed_vma
)
974 read_leb128 (data
, &bytes_read
, 1)));
979 uvalue
= read_leb128 (data
, &bytes_read
, 0);
981 printf ("DW_OP_regx: %s (%s)",
982 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1));
986 printf ("DW_OP_fbreg: %s",
987 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
)));
991 uvalue
= read_leb128 (data
, &bytes_read
, 0);
993 printf ("DW_OP_bregx: %s (%s) %s",
994 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1),
995 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
)));
999 printf ("DW_OP_piece: %s",
1000 dwarf_vmatoa ("u", read_leb128 (data
, &bytes_read
, 0)));
1003 case DW_OP_deref_size
:
1004 printf ("DW_OP_deref_size: %ld", (long) byte_get (data
++, 1));
1006 case DW_OP_xderef_size
:
1007 printf ("DW_OP_xderef_size: %ld", (long) byte_get (data
++, 1));
1010 printf ("DW_OP_nop");
1013 /* DWARF 3 extensions. */
1014 case DW_OP_push_object_address
:
1015 printf ("DW_OP_push_object_address");
1018 /* XXX: Strictly speaking for 64-bit DWARF3 files
1019 this ought to be an 8-byte wide computation. */
1020 printf ("DW_OP_call2: <0x%s>",
1021 dwarf_vmatoa ("x", (dwarf_signed_vma
) byte_get (data
, 2)
1026 /* XXX: Strictly speaking for 64-bit DWARF3 files
1027 this ought to be an 8-byte wide computation. */
1028 printf ("DW_OP_call4: <0x%s>",
1029 dwarf_vmatoa ("x", (dwarf_signed_vma
) byte_get (data
, 4)
1033 case DW_OP_call_ref
:
1034 /* XXX: Strictly speaking for 64-bit DWARF3 files
1035 this ought to be an 8-byte wide computation. */
1036 if (dwarf_version
== -1)
1038 printf (_("(DW_OP_call_ref in frame info)"));
1039 /* No way to tell where the next op is, so just bail. */
1040 return need_frame_base
;
1042 if (dwarf_version
== 2)
1044 printf ("DW_OP_call_ref: <0x%s>",
1045 dwarf_vmatoa ("x", byte_get (data
, pointer_size
)));
1046 data
+= pointer_size
;
1050 printf ("DW_OP_call_ref: <0x%s>",
1051 dwarf_vmatoa ("x", byte_get (data
, offset_size
)));
1052 data
+= offset_size
;
1055 case DW_OP_form_tls_address
:
1056 printf ("DW_OP_form_tls_address");
1058 case DW_OP_call_frame_cfa
:
1059 printf ("DW_OP_call_frame_cfa");
1061 case DW_OP_bit_piece
:
1062 printf ("DW_OP_bit_piece: ");
1063 printf (_("size: %s "),
1064 dwarf_vmatoa ("u", read_leb128 (data
, &bytes_read
, 0)));
1066 printf (_("offset: %s "),
1067 dwarf_vmatoa ("u", read_leb128 (data
, &bytes_read
, 0)));
1071 /* DWARF 4 extensions. */
1072 case DW_OP_stack_value
:
1073 printf ("DW_OP_stack_value");
1076 case DW_OP_implicit_value
:
1077 printf ("DW_OP_implicit_value");
1078 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1080 display_block (data
, uvalue
);
1084 /* GNU extensions. */
1085 case DW_OP_GNU_push_tls_address
:
1086 printf (_("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown"));
1088 case DW_OP_GNU_uninit
:
1089 printf ("DW_OP_GNU_uninit");
1090 /* FIXME: Is there data associated with this OP ? */
1092 case DW_OP_GNU_encoded_addr
:
1098 addr
= get_encoded_value (data
, encoding
, section
);
1099 data
+= size_of_encoded_value (encoding
);
1101 printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding
);
1102 print_dwarf_vma (addr
, pointer_size
);
1105 case DW_OP_GNU_implicit_pointer
:
1106 /* XXX: Strictly speaking for 64-bit DWARF3 files
1107 this ought to be an 8-byte wide computation. */
1108 if (dwarf_version
== -1)
1110 printf (_("(DW_OP_GNU_implicit_pointer in frame info)"));
1111 /* No way to tell where the next op is, so just bail. */
1112 return need_frame_base
;
1114 if (dwarf_version
== 2)
1116 printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s",
1117 dwarf_vmatoa ("x", byte_get (data
, pointer_size
)),
1118 dwarf_vmatoa ("d", read_sleb128 (data
+ pointer_size
,
1120 data
+= pointer_size
+ bytes_read
;
1124 printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s",
1125 dwarf_vmatoa ("x", byte_get (data
, offset_size
)),
1126 dwarf_vmatoa ("d", read_sleb128 (data
+ offset_size
,
1128 data
+= offset_size
+ bytes_read
;
1131 case DW_OP_GNU_entry_value
:
1132 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1134 printf ("DW_OP_GNU_entry_value: (");
1135 if (decode_location_expression (data
, pointer_size
, offset_size
,
1136 dwarf_version
, uvalue
,
1137 cu_offset
, section
))
1138 need_frame_base
= 1;
1142 case DW_OP_GNU_const_type
:
1143 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1145 printf ("DW_OP_GNU_const_type: <0x%s> ",
1146 dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1147 uvalue
= byte_get (data
++, 1);
1148 display_block (data
, uvalue
);
1151 case DW_OP_GNU_regval_type
:
1152 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1154 printf ("DW_OP_GNU_regval_type: %s (%s)",
1155 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1));
1156 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1158 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1160 case DW_OP_GNU_deref_type
:
1161 printf ("DW_OP_GNU_deref_type: %ld", (long) byte_get (data
++, 1));
1162 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1164 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1166 case DW_OP_GNU_convert
:
1167 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1169 printf ("DW_OP_GNU_convert <0x%s>",
1170 dwarf_vmatoa ("x", uvalue
? cu_offset
+ uvalue
: 0));
1172 case DW_OP_GNU_reinterpret
:
1173 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1175 printf ("DW_OP_GNU_reinterpret <0x%s>",
1176 dwarf_vmatoa ("x", uvalue
? cu_offset
+ uvalue
: 0));
1178 case DW_OP_GNU_parameter_ref
:
1179 printf ("DW_OP_GNU_parameter_ref: <0x%s>",
1180 dwarf_vmatoa ("x", cu_offset
+ byte_get (data
, 4)));
1183 case DW_OP_GNU_addr_index
:
1184 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1186 printf ("DW_OP_GNU_addr_index <0x%s>", dwarf_vmatoa ("x", uvalue
));
1189 /* HP extensions. */
1190 case DW_OP_HP_is_value
:
1191 printf ("DW_OP_HP_is_value");
1192 /* FIXME: Is there data associated with this OP ? */
1194 case DW_OP_HP_fltconst4
:
1195 printf ("DW_OP_HP_fltconst4");
1196 /* FIXME: Is there data associated with this OP ? */
1198 case DW_OP_HP_fltconst8
:
1199 printf ("DW_OP_HP_fltconst8");
1200 /* FIXME: Is there data associated with this OP ? */
1202 case DW_OP_HP_mod_range
:
1203 printf ("DW_OP_HP_mod_range");
1204 /* FIXME: Is there data associated with this OP ? */
1206 case DW_OP_HP_unmod_range
:
1207 printf ("DW_OP_HP_unmod_range");
1208 /* FIXME: Is there data associated with this OP ? */
1211 printf ("DW_OP_HP_tls");
1212 /* FIXME: Is there data associated with this OP ? */
1215 /* PGI (STMicroelectronics) extensions. */
1216 case DW_OP_PGI_omp_thread_num
:
1217 /* Pushes the thread number for the current thread as it would be
1218 returned by the standard OpenMP library function:
1219 omp_get_thread_num(). The "current thread" is the thread for
1220 which the expression is being evaluated. */
1221 printf ("DW_OP_PGI_omp_thread_num");
1225 if (op
>= DW_OP_lo_user
1226 && op
<= DW_OP_hi_user
)
1227 printf (_("(User defined location op)"));
1229 printf (_("(Unknown location op)"));
1230 /* No way to tell where the next op is, so just bail. */
1231 return need_frame_base
;
1234 /* Separate the ops. */
1239 return need_frame_base
;
1242 static unsigned char *
1243 read_and_display_attr_value (unsigned long attribute
,
1245 unsigned char * data
,
1246 dwarf_vma cu_offset
,
1247 dwarf_vma pointer_size
,
1248 dwarf_vma offset_size
,
1250 debug_info
* debug_info_p
,
1252 struct dwarf_section
* section
)
1254 dwarf_vma uvalue
= 0;
1255 unsigned char *block_start
= NULL
;
1256 unsigned char * orig_data
= data
;
1257 unsigned int bytes_read
;
1264 case DW_FORM_ref_addr
:
1265 if (dwarf_version
== 2)
1267 uvalue
= byte_get (data
, pointer_size
);
1268 data
+= pointer_size
;
1270 else if (dwarf_version
== 3 || dwarf_version
== 4)
1272 uvalue
= byte_get (data
, offset_size
);
1273 data
+= offset_size
;
1276 error (_("Internal error: DWARF version is not 2, 3 or 4.\n"));
1281 uvalue
= byte_get (data
, pointer_size
);
1282 data
+= pointer_size
;
1286 case DW_FORM_sec_offset
:
1287 case DW_FORM_GNU_ref_alt
:
1288 case DW_FORM_GNU_strp_alt
:
1289 uvalue
= byte_get (data
, offset_size
);
1290 data
+= offset_size
;
1293 case DW_FORM_flag_present
:
1300 uvalue
= byte_get (data
++, 1);
1305 uvalue
= byte_get (data
, 2);
1311 uvalue
= byte_get (data
, 4);
1316 uvalue
= read_leb128 (data
, & bytes_read
, 1);
1320 case DW_FORM_GNU_str_index
:
1321 uvalue
= read_leb128 (data
, & bytes_read
, 0);
1325 case DW_FORM_ref_udata
:
1327 uvalue
= read_leb128 (data
, & bytes_read
, 0);
1331 case DW_FORM_indirect
:
1332 form
= read_leb128 (data
, & bytes_read
, 0);
1335 printf (" %s", get_FORM_name (form
));
1336 return read_and_display_attr_value (attribute
, form
, data
,
1337 cu_offset
, pointer_size
,
1338 offset_size
, dwarf_version
,
1339 debug_info_p
, do_loc
,
1341 case DW_FORM_GNU_addr_index
:
1342 uvalue
= read_leb128 (data
, & bytes_read
, 0);
1349 case DW_FORM_ref_addr
:
1351 printf (" <0x%s>", dwarf_vmatoa ("x",uvalue
));
1354 case DW_FORM_GNU_ref_alt
:
1356 printf (" <alt 0x%s>", dwarf_vmatoa ("x",uvalue
));
1362 case DW_FORM_ref_udata
:
1364 printf (" <0x%s>", dwarf_vmatoa ("x", uvalue
+ cu_offset
));
1369 case DW_FORM_sec_offset
:
1371 printf (" 0x%s", dwarf_vmatoa ("x", uvalue
));
1374 case DW_FORM_flag_present
:
1381 printf (" %s", dwarf_vmatoa ("d", uvalue
));
1388 dwarf_vma high_bits
;
1391 byte_get_64 (data
, &high_bits
, &uvalue
);
1393 dwarf_vmatoa64 (high_bits
, uvalue
, buf
, sizeof (buf
)));
1395 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1396 && num_debug_info_entries
== 0)
1398 if (sizeof (uvalue
) == 8)
1399 uvalue
= byte_get (data
, 8);
1401 error (_("DW_FORM_data8 is unsupported when sizeof (dwarf_vma) != 8\n"));
1406 case DW_FORM_string
:
1408 printf (" %s", data
);
1409 data
+= strlen ((char *) data
) + 1;
1413 case DW_FORM_exprloc
:
1414 uvalue
= read_leb128 (data
, & bytes_read
, 0);
1415 block_start
= data
+ bytes_read
;
1417 data
= block_start
+ uvalue
;
1419 data
= display_block (block_start
, uvalue
);
1422 case DW_FORM_block1
:
1423 uvalue
= byte_get (data
, 1);
1424 block_start
= data
+ 1;
1426 data
= block_start
+ uvalue
;
1428 data
= display_block (block_start
, uvalue
);
1431 case DW_FORM_block2
:
1432 uvalue
= byte_get (data
, 2);
1433 block_start
= data
+ 2;
1435 data
= block_start
+ uvalue
;
1437 data
= display_block (block_start
, uvalue
);
1440 case DW_FORM_block4
:
1441 uvalue
= byte_get (data
, 4);
1442 block_start
= data
+ 4;
1444 data
= block_start
+ uvalue
;
1446 data
= display_block (block_start
, uvalue
);
1451 printf (_(" (indirect string, offset: 0x%s): %s"),
1452 dwarf_vmatoa ("x", uvalue
),
1453 fetch_indirect_string (uvalue
));
1456 case DW_FORM_GNU_str_index
:
1459 const char *suffix
= strrchr (section
->name
, '.');
1460 int dwo
= (suffix
&& strcmp (suffix
, ".dwo") == 0) ? 1 : 0;
1462 printf (_(" (indexed string: 0x%s): %s"),
1463 dwarf_vmatoa ("x", uvalue
),
1464 fetch_indexed_string (uvalue
, offset_size
, dwo
));
1468 case DW_FORM_GNU_strp_alt
:
1470 printf (_(" (alt indirect string, offset: 0x%s)"),
1471 dwarf_vmatoa ("x", uvalue
));
1474 case DW_FORM_indirect
:
1475 /* Handled above. */
1478 case DW_FORM_ref_sig8
:
1481 dwarf_vma high_bits
;
1484 byte_get_64 (data
, &high_bits
, &uvalue
);
1485 printf (" signature: 0x%s",
1486 dwarf_vmatoa64 (high_bits
, uvalue
, buf
, sizeof (buf
)));
1491 case DW_FORM_GNU_addr_index
:
1493 printf (_(" (addr_index: 0x%s): %s"),
1494 dwarf_vmatoa ("x", uvalue
),
1495 fetch_indexed_value (uvalue
* pointer_size
, pointer_size
));
1499 warn (_("Unrecognized form: %lu\n"), form
);
1503 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1504 && num_debug_info_entries
== 0
1505 && debug_info_p
!= NULL
)
1509 case DW_AT_frame_base
:
1510 have_frame_base
= 1;
1511 case DW_AT_location
:
1512 case DW_AT_string_length
:
1513 case DW_AT_return_addr
:
1514 case DW_AT_data_member_location
:
1515 case DW_AT_vtable_elem_location
:
1517 case DW_AT_static_link
:
1518 case DW_AT_use_location
:
1519 case DW_AT_GNU_call_site_value
:
1520 case DW_AT_GNU_call_site_data_value
:
1521 case DW_AT_GNU_call_site_target
:
1522 case DW_AT_GNU_call_site_target_clobbered
:
1523 if ((dwarf_version
< 4
1524 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
1525 || form
== DW_FORM_sec_offset
)
1527 /* Process location list. */
1528 unsigned int lmax
= debug_info_p
->max_loc_offsets
;
1529 unsigned int num
= debug_info_p
->num_loc_offsets
;
1531 if (lmax
== 0 || num
>= lmax
)
1534 debug_info_p
->loc_offsets
= (dwarf_vma
*)
1535 xcrealloc (debug_info_p
->loc_offsets
,
1536 lmax
, sizeof (*debug_info_p
->loc_offsets
));
1537 debug_info_p
->have_frame_base
= (int *)
1538 xcrealloc (debug_info_p
->have_frame_base
,
1539 lmax
, sizeof (*debug_info_p
->have_frame_base
));
1540 debug_info_p
->max_loc_offsets
= lmax
;
1542 debug_info_p
->loc_offsets
[num
] = uvalue
;
1543 debug_info_p
->have_frame_base
[num
] = have_frame_base
;
1544 debug_info_p
->num_loc_offsets
++;
1549 if (need_base_address
)
1550 debug_info_p
->base_address
= uvalue
;
1553 case DW_AT_GNU_addr_base
:
1554 debug_info_p
->addr_base
= uvalue
;
1557 case DW_AT_GNU_ranges_base
:
1558 debug_info_p
->ranges_base
= uvalue
;
1562 if ((dwarf_version
< 4
1563 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
1564 || form
== DW_FORM_sec_offset
)
1566 /* Process range list. */
1567 unsigned int lmax
= debug_info_p
->max_range_lists
;
1568 unsigned int num
= debug_info_p
->num_range_lists
;
1570 if (lmax
== 0 || num
>= lmax
)
1573 debug_info_p
->range_lists
= (dwarf_vma
*)
1574 xcrealloc (debug_info_p
->range_lists
,
1575 lmax
, sizeof (*debug_info_p
->range_lists
));
1576 debug_info_p
->max_range_lists
= lmax
;
1578 debug_info_p
->range_lists
[num
] = uvalue
;
1579 debug_info_p
->num_range_lists
++;
1588 if (do_loc
|| attribute
== 0)
1591 /* For some attributes we can display further information. */
1599 case DW_INL_not_inlined
:
1600 printf (_("(not inlined)"));
1602 case DW_INL_inlined
:
1603 printf (_("(inlined)"));
1605 case DW_INL_declared_not_inlined
:
1606 printf (_("(declared as inline but ignored)"));
1608 case DW_INL_declared_inlined
:
1609 printf (_("(declared as inline and inlined)"));
1612 printf (_(" (Unknown inline attribute value: %s)"),
1613 dwarf_vmatoa ("x", uvalue
));
1618 case DW_AT_language
:
1621 /* Ordered by the numeric value of these constants. */
1622 case DW_LANG_C89
: printf ("(ANSI C)"); break;
1623 case DW_LANG_C
: printf ("(non-ANSI C)"); break;
1624 case DW_LANG_Ada83
: printf ("(Ada)"); break;
1625 case DW_LANG_C_plus_plus
: printf ("(C++)"); break;
1626 case DW_LANG_Cobol74
: printf ("(Cobol 74)"); break;
1627 case DW_LANG_Cobol85
: printf ("(Cobol 85)"); break;
1628 case DW_LANG_Fortran77
: printf ("(FORTRAN 77)"); break;
1629 case DW_LANG_Fortran90
: printf ("(Fortran 90)"); break;
1630 case DW_LANG_Pascal83
: printf ("(ANSI Pascal)"); break;
1631 case DW_LANG_Modula2
: printf ("(Modula 2)"); break;
1632 /* DWARF 2.1 values. */
1633 case DW_LANG_Java
: printf ("(Java)"); break;
1634 case DW_LANG_C99
: printf ("(ANSI C99)"); break;
1635 case DW_LANG_Ada95
: printf ("(ADA 95)"); break;
1636 case DW_LANG_Fortran95
: printf ("(Fortran 95)"); break;
1637 /* DWARF 3 values. */
1638 case DW_LANG_PLI
: printf ("(PLI)"); break;
1639 case DW_LANG_ObjC
: printf ("(Objective C)"); break;
1640 case DW_LANG_ObjC_plus_plus
: printf ("(Objective C++)"); break;
1641 case DW_LANG_UPC
: printf ("(Unified Parallel C)"); break;
1642 case DW_LANG_D
: printf ("(D)"); break;
1643 /* DWARF 4 values. */
1644 case DW_LANG_Python
: printf ("(Python)"); break;
1645 /* DWARF 5 values. */
1646 case DW_LANG_Go
: printf ("(Go)"); break;
1647 /* MIPS extension. */
1648 case DW_LANG_Mips_Assembler
: printf ("(MIPS assembler)"); break;
1649 /* UPC extension. */
1650 case DW_LANG_Upc
: printf ("(Unified Parallel C)"); break;
1652 if (uvalue
>= DW_LANG_lo_user
&& uvalue
<= DW_LANG_hi_user
)
1653 printf (_("(implementation defined: %s)"),
1654 dwarf_vmatoa ("x", uvalue
));
1656 printf (_("(Unknown: %s)"), dwarf_vmatoa ("x", uvalue
));
1661 case DW_AT_encoding
:
1664 case DW_ATE_void
: printf ("(void)"); break;
1665 case DW_ATE_address
: printf ("(machine address)"); break;
1666 case DW_ATE_boolean
: printf ("(boolean)"); break;
1667 case DW_ATE_complex_float
: printf ("(complex float)"); break;
1668 case DW_ATE_float
: printf ("(float)"); break;
1669 case DW_ATE_signed
: printf ("(signed)"); break;
1670 case DW_ATE_signed_char
: printf ("(signed char)"); break;
1671 case DW_ATE_unsigned
: printf ("(unsigned)"); break;
1672 case DW_ATE_unsigned_char
: printf ("(unsigned char)"); break;
1673 /* DWARF 2.1 values: */
1674 case DW_ATE_imaginary_float
: printf ("(imaginary float)"); break;
1675 case DW_ATE_decimal_float
: printf ("(decimal float)"); break;
1676 /* DWARF 3 values: */
1677 case DW_ATE_packed_decimal
: printf ("(packed_decimal)"); break;
1678 case DW_ATE_numeric_string
: printf ("(numeric_string)"); break;
1679 case DW_ATE_edited
: printf ("(edited)"); break;
1680 case DW_ATE_signed_fixed
: printf ("(signed_fixed)"); break;
1681 case DW_ATE_unsigned_fixed
: printf ("(unsigned_fixed)"); break;
1682 /* HP extensions: */
1683 case DW_ATE_HP_float80
: printf ("(HP_float80)"); break;
1684 case DW_ATE_HP_complex_float80
: printf ("(HP_complex_float80)"); break;
1685 case DW_ATE_HP_float128
: printf ("(HP_float128)"); break;
1686 case DW_ATE_HP_complex_float128
:printf ("(HP_complex_float128)"); break;
1687 case DW_ATE_HP_floathpintel
: printf ("(HP_floathpintel)"); break;
1688 case DW_ATE_HP_imaginary_float80
: printf ("(HP_imaginary_float80)"); break;
1689 case DW_ATE_HP_imaginary_float128
: printf ("(HP_imaginary_float128)"); break;
1692 if (uvalue
>= DW_ATE_lo_user
1693 && uvalue
<= DW_ATE_hi_user
)
1694 printf (_("(user defined type)"));
1696 printf (_("(unknown type)"));
1701 case DW_AT_accessibility
:
1704 case DW_ACCESS_public
: printf ("(public)"); break;
1705 case DW_ACCESS_protected
: printf ("(protected)"); break;
1706 case DW_ACCESS_private
: printf ("(private)"); break;
1708 printf (_("(unknown accessibility)"));
1713 case DW_AT_visibility
:
1716 case DW_VIS_local
: printf ("(local)"); break;
1717 case DW_VIS_exported
: printf ("(exported)"); break;
1718 case DW_VIS_qualified
: printf ("(qualified)"); break;
1719 default: printf (_("(unknown visibility)")); break;
1723 case DW_AT_virtuality
:
1726 case DW_VIRTUALITY_none
: printf ("(none)"); break;
1727 case DW_VIRTUALITY_virtual
: printf ("(virtual)"); break;
1728 case DW_VIRTUALITY_pure_virtual
:printf ("(pure_virtual)"); break;
1729 default: printf (_("(unknown virtuality)")); break;
1733 case DW_AT_identifier_case
:
1736 case DW_ID_case_sensitive
: printf ("(case_sensitive)"); break;
1737 case DW_ID_up_case
: printf ("(up_case)"); break;
1738 case DW_ID_down_case
: printf ("(down_case)"); break;
1739 case DW_ID_case_insensitive
: printf ("(case_insensitive)"); break;
1740 default: printf (_("(unknown case)")); break;
1744 case DW_AT_calling_convention
:
1747 case DW_CC_normal
: printf ("(normal)"); break;
1748 case DW_CC_program
: printf ("(program)"); break;
1749 case DW_CC_nocall
: printf ("(nocall)"); break;
1751 if (uvalue
>= DW_CC_lo_user
1752 && uvalue
<= DW_CC_hi_user
)
1753 printf (_("(user defined)"));
1755 printf (_("(unknown convention)"));
1759 case DW_AT_ordering
:
1762 case -1: printf (_("(undefined)")); break;
1763 case 0: printf ("(row major)"); break;
1764 case 1: printf ("(column major)"); break;
1768 case DW_AT_frame_base
:
1769 have_frame_base
= 1;
1770 case DW_AT_location
:
1771 case DW_AT_string_length
:
1772 case DW_AT_return_addr
:
1773 case DW_AT_data_member_location
:
1774 case DW_AT_vtable_elem_location
:
1776 case DW_AT_static_link
:
1777 case DW_AT_use_location
:
1778 case DW_AT_GNU_call_site_value
:
1779 case DW_AT_GNU_call_site_data_value
:
1780 case DW_AT_GNU_call_site_target
:
1781 case DW_AT_GNU_call_site_target_clobbered
:
1782 if ((dwarf_version
< 4
1783 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
1784 || form
== DW_FORM_sec_offset
)
1785 printf (_("(location list)"));
1787 case DW_AT_allocated
:
1788 case DW_AT_associated
:
1789 case DW_AT_data_location
:
1791 case DW_AT_upper_bound
:
1792 case DW_AT_lower_bound
:
1795 int need_frame_base
;
1798 need_frame_base
= decode_location_expression (block_start
,
1803 cu_offset
, section
);
1805 if (need_frame_base
&& !have_frame_base
)
1806 printf (_(" [without DW_AT_frame_base]"));
1812 if (form
== DW_FORM_ref_sig8
1813 || form
== DW_FORM_GNU_ref_alt
)
1816 if (form
== DW_FORM_ref1
1817 || form
== DW_FORM_ref2
1818 || form
== DW_FORM_ref4
1819 || form
== DW_FORM_ref_udata
)
1820 uvalue
+= cu_offset
;
1822 if (uvalue
>= section
->size
)
1823 warn (_("Offset %s used as value for DW_AT_import attribute of DIE at offset %lx is too big.\n"),
1824 dwarf_vmatoa ("x", uvalue
),
1825 (unsigned long) (orig_data
- section
->start
));
1828 unsigned long abbrev_number
;
1829 abbrev_entry
* entry
;
1831 abbrev_number
= read_leb128 (section
->start
+ uvalue
, NULL
, 0);
1833 printf (_("[Abbrev Number: %ld"), abbrev_number
);
1834 /* Don't look up abbrev for DW_FORM_ref_addr, as it very often will
1835 use different abbrev table, and we don't track .debug_info chunks
1837 if (form
!= DW_FORM_ref_addr
)
1839 for (entry
= first_abbrev
; entry
!= NULL
; entry
= entry
->next
)
1840 if (entry
->entry
== abbrev_number
)
1843 printf (" (%s)", get_TAG_name (entry
->tag
));
1858 get_AT_name (unsigned long attribute
)
1862 /* One value is shared by the MIPS and HP extensions: */
1863 if (attribute
== DW_AT_MIPS_fde
)
1864 return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable";
1866 name
= get_DW_AT_name (attribute
);
1870 static char buffer
[100];
1872 snprintf (buffer
, sizeof (buffer
), _("Unknown AT value: %lx"),
1880 static unsigned char *
1881 read_and_display_attr (unsigned long attribute
,
1883 unsigned char * data
,
1884 dwarf_vma cu_offset
,
1885 dwarf_vma pointer_size
,
1886 dwarf_vma offset_size
,
1888 debug_info
* debug_info_p
,
1890 struct dwarf_section
* section
)
1893 printf (" %-18s:", get_AT_name (attribute
));
1894 data
= read_and_display_attr_value (attribute
, form
, data
, cu_offset
,
1895 pointer_size
, offset_size
,
1896 dwarf_version
, debug_info_p
,
1904 /* Process the contents of a .debug_info section. If do_loc is non-zero
1905 then we are scanning for location lists and we do not want to display
1906 anything to the user. If do_types is non-zero, we are processing
1907 a .debug_types section instead of a .debug_info section. */
1910 process_debug_info (struct dwarf_section
*section
,
1912 enum dwarf_section_display_enum abbrev_sec
,
1916 unsigned char *start
= section
->start
;
1917 unsigned char *end
= start
+ section
->size
;
1918 unsigned char *section_begin
;
1920 unsigned int num_units
= 0;
1922 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1923 && num_debug_info_entries
== 0
1928 /* First scan the section to get the number of comp units. */
1929 for (section_begin
= start
, num_units
= 0; section_begin
< end
;
1932 /* Read the first 4 bytes. For a 32-bit DWARF section, this
1933 will be the length. For a 64-bit DWARF section, it'll be
1934 the escape code 0xffffffff followed by an 8 byte length. */
1935 length
= byte_get (section_begin
, 4);
1937 if (length
== 0xffffffff)
1939 length
= byte_get (section_begin
+ 4, 8);
1940 section_begin
+= length
+ 12;
1942 else if (length
>= 0xfffffff0 && length
< 0xffffffff)
1944 warn (_("Reserved length value (0x%s) found in section %s\n"),
1945 dwarf_vmatoa ("x", length
), section
->name
);
1949 section_begin
+= length
+ 4;
1951 /* Negative values are illegal, they may even cause infinite
1952 looping. This can happen if we can't accurately apply
1953 relocations to an object file. */
1954 if ((signed long) length
<= 0)
1956 warn (_("Corrupt unit length (0x%s) found in section %s\n"),
1957 dwarf_vmatoa ("x", length
), section
->name
);
1964 error (_("No comp units in %s section ?"), section
->name
);
1968 /* Then allocate an array to hold the information. */
1969 debug_information
= (debug_info
*) cmalloc (num_units
,
1970 sizeof (* debug_information
));
1971 if (debug_information
== NULL
)
1973 error (_("Not enough memory for a debug info array of %u entries"),
1981 if (dwarf_start_die
== 0)
1982 printf (_("Contents of the %s section:\n\n"), section
->name
);
1984 load_debug_section (str
, file
);
1985 load_debug_section (str_dwo
, file
);
1986 load_debug_section (str_index
, file
);
1987 load_debug_section (str_index_dwo
, file
);
1988 load_debug_section (debug_addr
, file
);
1991 load_debug_section (abbrev_sec
, file
);
1992 if (debug_displays
[abbrev_sec
].section
.start
== NULL
)
1994 warn (_("Unable to locate %s section!\n"),
1995 debug_displays
[abbrev_sec
].section
.name
);
1999 for (section_begin
= start
, unit
= 0; start
< end
; unit
++)
2001 DWARF2_Internal_CompUnit compunit
;
2002 unsigned char *hdrptr
;
2003 unsigned char *tags
;
2004 int level
, last_level
, saved_level
;
2005 dwarf_vma cu_offset
;
2007 int initial_length_size
;
2008 dwarf_vma signature_high
= 0;
2009 dwarf_vma signature_low
= 0;
2010 dwarf_vma type_offset
= 0;
2014 compunit
.cu_length
= byte_get (hdrptr
, 4);
2017 if (compunit
.cu_length
== 0xffffffff)
2019 compunit
.cu_length
= byte_get (hdrptr
, 8);
2022 initial_length_size
= 12;
2027 initial_length_size
= 4;
2030 compunit
.cu_version
= byte_get (hdrptr
, 2);
2033 cu_offset
= start
- section_begin
;
2035 compunit
.cu_abbrev_offset
= byte_get (hdrptr
, offset_size
);
2036 hdrptr
+= offset_size
;
2038 compunit
.cu_pointer_size
= byte_get (hdrptr
, 1);
2043 byte_get_64 (hdrptr
, &signature_high
, &signature_low
);
2045 type_offset
= byte_get (hdrptr
, offset_size
);
2046 hdrptr
+= offset_size
;
2049 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2050 && num_debug_info_entries
== 0
2053 debug_information
[unit
].cu_offset
= cu_offset
;
2054 debug_information
[unit
].pointer_size
2055 = compunit
.cu_pointer_size
;
2056 debug_information
[unit
].offset_size
= offset_size
;
2057 debug_information
[unit
].dwarf_version
= compunit
.cu_version
;
2058 debug_information
[unit
].base_address
= 0;
2059 debug_information
[unit
].addr_base
= DEBUG_INFO_UNAVAILABLE
;
2060 debug_information
[unit
].ranges_base
= DEBUG_INFO_UNAVAILABLE
;
2061 debug_information
[unit
].loc_offsets
= NULL
;
2062 debug_information
[unit
].have_frame_base
= NULL
;
2063 debug_information
[unit
].max_loc_offsets
= 0;
2064 debug_information
[unit
].num_loc_offsets
= 0;
2065 debug_information
[unit
].range_lists
= NULL
;
2066 debug_information
[unit
].max_range_lists
= 0;
2067 debug_information
[unit
].num_range_lists
= 0;
2070 if (!do_loc
&& dwarf_start_die
== 0)
2072 printf (_(" Compilation Unit @ offset 0x%s:\n"),
2073 dwarf_vmatoa ("x", cu_offset
));
2074 printf (_(" Length: 0x%s (%s)\n"),
2075 dwarf_vmatoa ("x", compunit
.cu_length
),
2076 offset_size
== 8 ? "64-bit" : "32-bit");
2077 printf (_(" Version: %d\n"), compunit
.cu_version
);
2078 printf (_(" Abbrev Offset: 0x%s\n"),
2079 dwarf_vmatoa ("x", compunit
.cu_abbrev_offset
));
2080 printf (_(" Pointer Size: %d\n"), compunit
.cu_pointer_size
);
2085 printf (_(" Signature: 0x%s\n"),
2086 dwarf_vmatoa64 (signature_high
, signature_low
,
2087 buf
, sizeof (buf
)));
2088 printf (_(" Type Offset: 0x%s\n"),
2089 dwarf_vmatoa ("x", type_offset
));
2093 if (cu_offset
+ compunit
.cu_length
+ initial_length_size
2096 warn (_("Debug info is corrupted, length of CU at %s"
2097 " extends beyond end of section (length = %s)\n"),
2098 dwarf_vmatoa ("x", cu_offset
),
2099 dwarf_vmatoa ("x", compunit
.cu_length
));
2103 start
+= compunit
.cu_length
+ initial_length_size
;
2105 if (compunit
.cu_version
!= 2
2106 && compunit
.cu_version
!= 3
2107 && compunit
.cu_version
!= 4)
2109 warn (_("CU at offset %s contains corrupt or "
2110 "unsupported version number: %d.\n"),
2111 dwarf_vmatoa ("x", cu_offset
), compunit
.cu_version
);
2117 /* Process the abbrevs used by this compilation unit. DWARF
2118 sections under Mach-O have non-zero addresses. */
2119 if (compunit
.cu_abbrev_offset
>= debug_displays
[abbrev_sec
].section
.size
)
2120 warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"),
2121 (unsigned long) compunit
.cu_abbrev_offset
,
2122 (unsigned long) debug_displays
[abbrev_sec
].section
.size
);
2124 process_abbrev_section
2125 ((unsigned char *) debug_displays
[abbrev_sec
].section
.start
2126 + compunit
.cu_abbrev_offset
,
2127 (unsigned char *) debug_displays
[abbrev_sec
].section
.start
2128 + debug_displays
[abbrev_sec
].section
.size
);
2133 while (tags
< start
)
2135 unsigned int bytes_read
;
2136 unsigned long abbrev_number
;
2137 unsigned long die_offset
;
2138 abbrev_entry
*entry
;
2140 int do_printing
= 1;
2142 die_offset
= tags
- section_begin
;
2144 abbrev_number
= read_leb128 (tags
, & bytes_read
, 0);
2147 /* A null DIE marks the end of a list of siblings or it may also be
2148 a section padding. */
2149 if (abbrev_number
== 0)
2151 /* Check if it can be a section padding for the last CU. */
2152 if (level
== 0 && start
== end
)
2156 for (chk
= tags
; chk
< start
; chk
++)
2166 static unsigned num_bogus_warns
= 0;
2168 if (num_bogus_warns
< 3)
2170 warn (_("Bogus end-of-siblings marker detected at offset %lx in %s section\n"),
2171 die_offset
, section
->name
);
2173 if (num_bogus_warns
== 3)
2174 warn (_("Further warnings about bogus end-of-sibling markers suppressed\n"));
2177 if (dwarf_start_die
!= 0 && level
< saved_level
)
2184 if (dwarf_start_die
!= 0 && die_offset
< dwarf_start_die
)
2188 if (dwarf_start_die
!= 0 && die_offset
== dwarf_start_die
)
2189 saved_level
= level
;
2190 do_printing
= (dwarf_cutoff_level
== -1
2191 || level
< dwarf_cutoff_level
);
2193 printf (_(" <%d><%lx>: Abbrev Number: %lu"),
2194 level
, die_offset
, abbrev_number
);
2195 else if (dwarf_cutoff_level
== -1
2196 || last_level
< dwarf_cutoff_level
)
2197 printf (_(" <%d><%lx>: ...\n"), level
, die_offset
);
2202 /* Scan through the abbreviation list until we reach the
2204 for (entry
= first_abbrev
;
2205 entry
&& entry
->entry
!= abbrev_number
;
2206 entry
= entry
->next
)
2211 if (!do_loc
&& do_printing
)
2216 warn (_("DIE at offset %lx refers to abbreviation number %lu which does not exist\n"),
2217 die_offset
, abbrev_number
);
2221 if (!do_loc
&& do_printing
)
2222 printf (" (%s)\n", get_TAG_name (entry
->tag
));
2227 need_base_address
= 0;
2229 case DW_TAG_compile_unit
:
2230 need_base_address
= 1;
2232 case DW_TAG_entry_point
:
2233 case DW_TAG_subprogram
:
2234 need_base_address
= 0;
2235 /* Assuming that there is no DW_AT_frame_base. */
2236 have_frame_base
= 0;
2240 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
2244 if (! do_loc
&& do_printing
)
2245 /* Show the offset from where the tag was extracted. */
2246 printf (" <%lx>", (unsigned long)(tags
- section_begin
));
2248 arg
= debug_information
;
2249 if (debug_information
)
2252 tags
= read_and_display_attr (attr
->attribute
,
2255 compunit
.cu_pointer_size
,
2257 compunit
.cu_version
,
2259 do_loc
|| ! do_printing
, section
);
2262 if (entry
->children
)
2267 /* Set num_debug_info_entries here so that it can be used to check if
2268 we need to process .debug_loc and .debug_ranges sections. */
2269 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2270 && num_debug_info_entries
== 0
2272 num_debug_info_entries
= num_units
;
2280 /* Locate and scan the .debug_info section in the file and record the pointer
2281 sizes and offsets for the compilation units in it. Usually an executable
2282 will have just one pointer size, but this is not guaranteed, and so we try
2283 not to make any assumptions. Returns zero upon failure, or the number of
2284 compilation units upon success. */
2287 load_debug_info (void * file
)
2289 /* Reset the last pointer size so that we can issue correct error
2290 messages if we are displaying the contents of more than one section. */
2291 last_pointer_size
= 0;
2292 warned_about_missing_comp_units
= FALSE
;
2294 /* If we have already tried and failed to load the .debug_info
2295 section then do not bother to repear the task. */
2296 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
2299 /* If we already have the information there is nothing else to do. */
2300 if (num_debug_info_entries
> 0)
2301 return num_debug_info_entries
;
2303 if (load_debug_section (info
, file
)
2304 && process_debug_info (&debug_displays
[info
].section
, file
, abbrev
, 1, 0))
2305 return num_debug_info_entries
;
2306 else if (load_debug_section (info_dwo
, file
)
2307 && process_debug_info (&debug_displays
[info_dwo
].section
, file
,
2309 return num_debug_info_entries
;
2311 num_debug_info_entries
= DEBUG_INFO_UNAVAILABLE
;
2316 display_debug_lines_raw (struct dwarf_section
*section
,
2317 unsigned char *data
,
2320 unsigned char *start
= section
->start
;
2322 printf (_("Raw dump of debug contents of section %s:\n\n"),
2327 DWARF2_Internal_LineInfo linfo
;
2328 unsigned char *standard_opcodes
;
2329 unsigned char *end_of_sequence
;
2330 unsigned char *hdrptr
;
2331 unsigned long hdroff
;
2332 int initial_length_size
;
2337 hdroff
= hdrptr
- start
;
2339 /* Check the length of the block. */
2340 linfo
.li_length
= byte_get (hdrptr
, 4);
2343 if (linfo
.li_length
== 0xffffffff)
2345 /* This section is 64-bit DWARF 3. */
2346 linfo
.li_length
= byte_get (hdrptr
, 8);
2349 initial_length_size
= 12;
2354 initial_length_size
= 4;
2357 if (linfo
.li_length
+ initial_length_size
> section
->size
)
2360 (_("The information in section %s appears to be corrupt - the section is too small\n"),
2365 /* Check its version number. */
2366 linfo
.li_version
= byte_get (hdrptr
, 2);
2368 if (linfo
.li_version
!= 2
2369 && linfo
.li_version
!= 3
2370 && linfo
.li_version
!= 4)
2372 warn (_("Only DWARF version 2, 3 and 4 line info is currently supported.\n"));
2376 linfo
.li_prologue_length
= byte_get (hdrptr
, offset_size
);
2377 hdrptr
+= offset_size
;
2378 linfo
.li_min_insn_length
= byte_get (hdrptr
, 1);
2380 if (linfo
.li_version
>= 4)
2382 linfo
.li_max_ops_per_insn
= byte_get (hdrptr
, 1);
2384 if (linfo
.li_max_ops_per_insn
== 0)
2386 warn (_("Invalid maximum operations per insn.\n"));
2391 linfo
.li_max_ops_per_insn
= 1;
2392 linfo
.li_default_is_stmt
= byte_get (hdrptr
, 1);
2394 linfo
.li_line_base
= byte_get (hdrptr
, 1);
2396 linfo
.li_line_range
= byte_get (hdrptr
, 1);
2398 linfo
.li_opcode_base
= byte_get (hdrptr
, 1);
2401 /* Sign extend the line base field. */
2402 linfo
.li_line_base
<<= 24;
2403 linfo
.li_line_base
>>= 24;
2405 printf (_(" Offset: 0x%lx\n"), hdroff
);
2406 printf (_(" Length: %ld\n"), (long) linfo
.li_length
);
2407 printf (_(" DWARF Version: %d\n"), linfo
.li_version
);
2408 printf (_(" Prologue Length: %d\n"), linfo
.li_prologue_length
);
2409 printf (_(" Minimum Instruction Length: %d\n"), linfo
.li_min_insn_length
);
2410 if (linfo
.li_version
>= 4)
2411 printf (_(" Maximum Ops per Instruction: %d\n"), linfo
.li_max_ops_per_insn
);
2412 printf (_(" Initial value of 'is_stmt': %d\n"), linfo
.li_default_is_stmt
);
2413 printf (_(" Line Base: %d\n"), linfo
.li_line_base
);
2414 printf (_(" Line Range: %d\n"), linfo
.li_line_range
);
2415 printf (_(" Opcode Base: %d\n"), linfo
.li_opcode_base
);
2417 end_of_sequence
= data
+ linfo
.li_length
+ initial_length_size
;
2419 reset_state_machine (linfo
.li_default_is_stmt
);
2421 /* Display the contents of the Opcodes table. */
2422 standard_opcodes
= hdrptr
;
2424 printf (_("\n Opcodes:\n"));
2426 for (i
= 1; i
< linfo
.li_opcode_base
; i
++)
2427 printf (_(" Opcode %d has %d args\n"), i
, standard_opcodes
[i
- 1]);
2429 /* Display the contents of the Directory table. */
2430 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
2433 printf (_("\n The Directory Table is empty.\n"));
2436 printf (_("\n The Directory Table:\n"));
2440 printf (" %s\n", data
);
2442 data
+= strlen ((char *) data
) + 1;
2446 /* Skip the NUL at the end of the table. */
2449 /* Display the contents of the File Name table. */
2451 printf (_("\n The File Name Table is empty.\n"));
2454 printf (_("\n The File Name Table:\n"));
2455 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
2459 unsigned char *name
;
2460 unsigned int bytes_read
;
2462 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
2465 data
+= strlen ((char *) data
) + 1;
2468 dwarf_vmatoa ("u", read_leb128 (data
, & bytes_read
, 0)));
2471 dwarf_vmatoa ("u", read_leb128 (data
, & bytes_read
, 0)));
2474 dwarf_vmatoa ("u", read_leb128 (data
, & bytes_read
, 0)));
2476 printf ("%s\n", name
);
2480 /* Skip the NUL at the end of the table. */
2483 /* Now display the statements. */
2484 printf (_("\n Line Number Statements:\n"));
2486 while (data
< end_of_sequence
)
2488 unsigned char op_code
;
2489 dwarf_signed_vma adv
;
2491 unsigned int bytes_read
;
2495 if (op_code
>= linfo
.li_opcode_base
)
2497 op_code
-= linfo
.li_opcode_base
;
2498 uladv
= (op_code
/ linfo
.li_line_range
);
2499 if (linfo
.li_max_ops_per_insn
== 1)
2501 uladv
*= linfo
.li_min_insn_length
;
2502 state_machine_regs
.address
+= uladv
;
2503 printf (_(" Special opcode %d: "
2504 "advance Address by %s to 0x%s"),
2505 op_code
, dwarf_vmatoa ("u", uladv
),
2506 dwarf_vmatoa ("x", state_machine_regs
.address
));
2510 state_machine_regs
.address
2511 += ((state_machine_regs
.op_index
+ uladv
)
2512 / linfo
.li_max_ops_per_insn
)
2513 * linfo
.li_min_insn_length
;
2514 state_machine_regs
.op_index
2515 = (state_machine_regs
.op_index
+ uladv
)
2516 % linfo
.li_max_ops_per_insn
;
2517 printf (_(" Special opcode %d: "
2518 "advance Address by %s to 0x%s[%d]"),
2519 op_code
, dwarf_vmatoa ("u", uladv
),
2520 dwarf_vmatoa ("x", state_machine_regs
.address
),
2521 state_machine_regs
.op_index
);
2523 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
2524 state_machine_regs
.line
+= adv
;
2525 printf (_(" and Line by %s to %d\n"),
2526 dwarf_vmatoa ("d", adv
), state_machine_regs
.line
);
2528 else switch (op_code
)
2530 case DW_LNS_extended_op
:
2531 data
+= process_extended_line_op (data
, linfo
.li_default_is_stmt
);
2535 printf (_(" Copy\n"));
2538 case DW_LNS_advance_pc
:
2539 uladv
= read_leb128 (data
, & bytes_read
, 0);
2541 if (linfo
.li_max_ops_per_insn
== 1)
2543 uladv
*= linfo
.li_min_insn_length
;
2544 state_machine_regs
.address
+= uladv
;
2545 printf (_(" Advance PC by %s to 0x%s\n"),
2546 dwarf_vmatoa ("u", uladv
),
2547 dwarf_vmatoa ("x", state_machine_regs
.address
));
2551 state_machine_regs
.address
2552 += ((state_machine_regs
.op_index
+ uladv
)
2553 / linfo
.li_max_ops_per_insn
)
2554 * linfo
.li_min_insn_length
;
2555 state_machine_regs
.op_index
2556 = (state_machine_regs
.op_index
+ uladv
)
2557 % linfo
.li_max_ops_per_insn
;
2558 printf (_(" Advance PC by %s to 0x%s[%d]\n"),
2559 dwarf_vmatoa ("u", uladv
),
2560 dwarf_vmatoa ("x", state_machine_regs
.address
),
2561 state_machine_regs
.op_index
);
2565 case DW_LNS_advance_line
:
2566 adv
= read_sleb128 (data
, & bytes_read
);
2568 state_machine_regs
.line
+= adv
;
2569 printf (_(" Advance Line by %s to %d\n"),
2570 dwarf_vmatoa ("d", adv
),
2571 state_machine_regs
.line
);
2574 case DW_LNS_set_file
:
2575 adv
= read_leb128 (data
, & bytes_read
, 0);
2577 printf (_(" Set File Name to entry %s in the File Name Table\n"),
2578 dwarf_vmatoa ("d", adv
));
2579 state_machine_regs
.file
= adv
;
2582 case DW_LNS_set_column
:
2583 uladv
= read_leb128 (data
, & bytes_read
, 0);
2585 printf (_(" Set column to %s\n"),
2586 dwarf_vmatoa ("u", uladv
));
2587 state_machine_regs
.column
= uladv
;
2590 case DW_LNS_negate_stmt
:
2591 adv
= state_machine_regs
.is_stmt
;
2593 printf (_(" Set is_stmt to %s\n"), dwarf_vmatoa ("d", adv
));
2594 state_machine_regs
.is_stmt
= adv
;
2597 case DW_LNS_set_basic_block
:
2598 printf (_(" Set basic block\n"));
2599 state_machine_regs
.basic_block
= 1;
2602 case DW_LNS_const_add_pc
:
2603 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
2604 if (linfo
.li_max_ops_per_insn
)
2606 uladv
*= linfo
.li_min_insn_length
;
2607 state_machine_regs
.address
+= uladv
;
2608 printf (_(" Advance PC by constant %s to 0x%s\n"),
2609 dwarf_vmatoa ("u", uladv
),
2610 dwarf_vmatoa ("x", state_machine_regs
.address
));
2614 state_machine_regs
.address
2615 += ((state_machine_regs
.op_index
+ uladv
)
2616 / linfo
.li_max_ops_per_insn
)
2617 * linfo
.li_min_insn_length
;
2618 state_machine_regs
.op_index
2619 = (state_machine_regs
.op_index
+ uladv
)
2620 % linfo
.li_max_ops_per_insn
;
2621 printf (_(" Advance PC by constant %s to 0x%s[%d]\n"),
2622 dwarf_vmatoa ("u", uladv
),
2623 dwarf_vmatoa ("x", state_machine_regs
.address
),
2624 state_machine_regs
.op_index
);
2628 case DW_LNS_fixed_advance_pc
:
2629 uladv
= byte_get (data
, 2);
2631 state_machine_regs
.address
+= uladv
;
2632 state_machine_regs
.op_index
= 0;
2633 printf (_(" Advance PC by fixed size amount %s to 0x%s\n"),
2634 dwarf_vmatoa ("u", uladv
),
2635 dwarf_vmatoa ("x", state_machine_regs
.address
));
2638 case DW_LNS_set_prologue_end
:
2639 printf (_(" Set prologue_end to true\n"));
2642 case DW_LNS_set_epilogue_begin
:
2643 printf (_(" Set epilogue_begin to true\n"));
2646 case DW_LNS_set_isa
:
2647 uladv
= read_leb128 (data
, & bytes_read
, 0);
2649 printf (_(" Set ISA to %s\n"), dwarf_vmatoa ("u", uladv
));
2653 printf (_(" Unknown opcode %d with operands: "), op_code
);
2655 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
2657 printf ("0x%s%s", dwarf_vmatoa ("x", read_leb128 (data
,
2659 i
== 1 ? "" : ", ");
2674 unsigned char *name
;
2675 unsigned int directory_index
;
2676 unsigned int modification_date
;
2677 unsigned int length
;
2680 /* Output a decoded representation of the .debug_line section. */
2683 display_debug_lines_decoded (struct dwarf_section
*section
,
2684 unsigned char *data
,
2687 printf (_("Decoded dump of debug contents of section %s:\n\n"),
2692 /* This loop amounts to one iteration per compilation unit. */
2693 DWARF2_Internal_LineInfo linfo
;
2694 unsigned char *standard_opcodes
;
2695 unsigned char *end_of_sequence
;
2696 unsigned char *hdrptr
;
2697 int initial_length_size
;
2700 File_Entry
*file_table
= NULL
;
2701 unsigned int n_files
= 0;
2702 unsigned char **directory_table
= NULL
;
2703 unsigned int n_directories
= 0;
2707 /* Extract information from the Line Number Program Header.
2708 (section 6.2.4 in the Dwarf3 doc). */
2710 /* Get the length of this CU's line number information block. */
2711 linfo
.li_length
= byte_get (hdrptr
, 4);
2714 if (linfo
.li_length
== 0xffffffff)
2716 /* This section is 64-bit DWARF 3. */
2717 linfo
.li_length
= byte_get (hdrptr
, 8);
2720 initial_length_size
= 12;
2725 initial_length_size
= 4;
2728 if (linfo
.li_length
+ initial_length_size
> section
->size
)
2730 warn (_("The line info appears to be corrupt - "
2731 "the section is too small\n"));
2735 /* Get this CU's Line Number Block version number. */
2736 linfo
.li_version
= byte_get (hdrptr
, 2);
2738 if (linfo
.li_version
!= 2
2739 && linfo
.li_version
!= 3
2740 && linfo
.li_version
!= 4)
2742 warn (_("Only DWARF version 2, 3 and 4 line info is currently "
2747 linfo
.li_prologue_length
= byte_get (hdrptr
, offset_size
);
2748 hdrptr
+= offset_size
;
2749 linfo
.li_min_insn_length
= byte_get (hdrptr
, 1);
2751 if (linfo
.li_version
>= 4)
2753 linfo
.li_max_ops_per_insn
= byte_get (hdrptr
, 1);
2755 if (linfo
.li_max_ops_per_insn
== 0)
2757 warn (_("Invalid maximum operations per insn.\n"));
2762 linfo
.li_max_ops_per_insn
= 1;
2763 linfo
.li_default_is_stmt
= byte_get (hdrptr
, 1);
2765 linfo
.li_line_base
= byte_get (hdrptr
, 1);
2767 linfo
.li_line_range
= byte_get (hdrptr
, 1);
2769 linfo
.li_opcode_base
= byte_get (hdrptr
, 1);
2772 /* Sign extend the line base field. */
2773 linfo
.li_line_base
<<= 24;
2774 linfo
.li_line_base
>>= 24;
2776 /* Find the end of this CU's Line Number Information Block. */
2777 end_of_sequence
= data
+ linfo
.li_length
+ initial_length_size
;
2779 reset_state_machine (linfo
.li_default_is_stmt
);
2781 /* Save a pointer to the contents of the Opcodes table. */
2782 standard_opcodes
= hdrptr
;
2784 /* Traverse the Directory table just to count entries. */
2785 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
2788 unsigned char *ptr_directory_table
= data
;
2792 data
+= strlen ((char *) data
) + 1;
2796 /* Go through the directory table again to save the directories. */
2797 directory_table
= (unsigned char **)
2798 xmalloc (n_directories
* sizeof (unsigned char *));
2801 while (*ptr_directory_table
!= 0)
2803 directory_table
[i
] = ptr_directory_table
;
2804 ptr_directory_table
+= strlen ((char *) ptr_directory_table
) + 1;
2808 /* Skip the NUL at the end of the table. */
2811 /* Traverse the File Name table just to count the entries. */
2814 unsigned char *ptr_file_name_table
= data
;
2818 unsigned int bytes_read
;
2820 /* Skip Name, directory index, last modification time and length
2822 data
+= strlen ((char *) data
) + 1;
2823 read_leb128 (data
, & bytes_read
, 0);
2825 read_leb128 (data
, & bytes_read
, 0);
2827 read_leb128 (data
, & bytes_read
, 0);
2833 /* Go through the file table again to save the strings. */
2834 file_table
= (File_Entry
*) xmalloc (n_files
* sizeof (File_Entry
));
2837 while (*ptr_file_name_table
!= 0)
2839 unsigned int bytes_read
;
2841 file_table
[i
].name
= ptr_file_name_table
;
2842 ptr_file_name_table
+= strlen ((char *) ptr_file_name_table
) + 1;
2844 /* We are not interested in directory, time or size. */
2845 file_table
[i
].directory_index
= read_leb128 (ptr_file_name_table
,
2847 ptr_file_name_table
+= bytes_read
;
2848 file_table
[i
].modification_date
= read_leb128 (ptr_file_name_table
,
2850 ptr_file_name_table
+= bytes_read
;
2851 file_table
[i
].length
= read_leb128 (ptr_file_name_table
, & bytes_read
, 0);
2852 ptr_file_name_table
+= bytes_read
;
2857 /* Print the Compilation Unit's name and a header. */
2858 if (directory_table
== NULL
)
2860 printf (_("CU: %s:\n"), file_table
[0].name
);
2861 printf (_("File name Line number Starting address\n"));
2865 unsigned int ix
= file_table
[0].directory_index
;
2866 const char *directory
= ix
? (char *)directory_table
[ix
- 1] : ".";
2867 if (do_wide
|| strlen (directory
) < 76)
2868 printf (_("CU: %s/%s:\n"), directory
, file_table
[0].name
);
2870 printf ("%s:\n", file_table
[0].name
);
2872 printf (_("File name Line number Starting address\n"));
2876 /* Skip the NUL at the end of the table. */
2879 /* This loop iterates through the Dwarf Line Number Program. */
2880 while (data
< end_of_sequence
)
2882 unsigned char op_code
;
2884 unsigned long int uladv
;
2885 unsigned int bytes_read
;
2886 int is_special_opcode
= 0;
2890 if (op_code
>= linfo
.li_opcode_base
)
2892 op_code
-= linfo
.li_opcode_base
;
2893 uladv
= (op_code
/ linfo
.li_line_range
);
2894 if (linfo
.li_max_ops_per_insn
== 1)
2896 uladv
*= linfo
.li_min_insn_length
;
2897 state_machine_regs
.address
+= uladv
;
2901 state_machine_regs
.address
2902 += ((state_machine_regs
.op_index
+ uladv
)
2903 / linfo
.li_max_ops_per_insn
)
2904 * linfo
.li_min_insn_length
;
2905 state_machine_regs
.op_index
2906 = (state_machine_regs
.op_index
+ uladv
)
2907 % linfo
.li_max_ops_per_insn
;
2910 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
2911 state_machine_regs
.line
+= adv
;
2912 is_special_opcode
= 1;
2914 else switch (op_code
)
2916 case DW_LNS_extended_op
:
2918 unsigned int ext_op_code_len
;
2919 unsigned char ext_op_code
;
2920 unsigned char *op_code_data
= data
;
2922 ext_op_code_len
= read_leb128 (op_code_data
, &bytes_read
, 0);
2923 op_code_data
+= bytes_read
;
2925 if (ext_op_code_len
== 0)
2927 warn (_("badly formed extended line op encountered!\n"));
2930 ext_op_code_len
+= bytes_read
;
2931 ext_op_code
= *op_code_data
++;
2933 switch (ext_op_code
)
2935 case DW_LNE_end_sequence
:
2936 reset_state_machine (linfo
.li_default_is_stmt
);
2938 case DW_LNE_set_address
:
2939 state_machine_regs
.address
=
2940 byte_get (op_code_data
, ext_op_code_len
- bytes_read
- 1);
2941 state_machine_regs
.op_index
= 0;
2943 case DW_LNE_define_file
:
2945 file_table
= (File_Entry
*) xrealloc
2946 (file_table
, (n_files
+ 1) * sizeof (File_Entry
));
2948 ++state_machine_regs
.last_file_entry
;
2949 /* Source file name. */
2950 file_table
[n_files
].name
= op_code_data
;
2951 op_code_data
+= strlen ((char *) op_code_data
) + 1;
2952 /* Directory index. */
2953 file_table
[n_files
].directory_index
=
2954 read_leb128 (op_code_data
, & bytes_read
, 0);
2955 op_code_data
+= bytes_read
;
2956 /* Last modification time. */
2957 file_table
[n_files
].modification_date
=
2958 read_leb128 (op_code_data
, & bytes_read
, 0);
2959 op_code_data
+= bytes_read
;
2961 file_table
[n_files
].length
=
2962 read_leb128 (op_code_data
, & bytes_read
, 0);
2967 case DW_LNE_set_discriminator
:
2968 case DW_LNE_HP_set_sequence
:
2969 /* Simply ignored. */
2973 printf (_("UNKNOWN (%u): length %d\n"),
2974 ext_op_code
, ext_op_code_len
- bytes_read
);
2977 data
+= ext_op_code_len
;
2983 case DW_LNS_advance_pc
:
2984 uladv
= read_leb128 (data
, & bytes_read
, 0);
2986 if (linfo
.li_max_ops_per_insn
== 1)
2988 uladv
*= linfo
.li_min_insn_length
;
2989 state_machine_regs
.address
+= uladv
;
2993 state_machine_regs
.address
2994 += ((state_machine_regs
.op_index
+ uladv
)
2995 / linfo
.li_max_ops_per_insn
)
2996 * linfo
.li_min_insn_length
;
2997 state_machine_regs
.op_index
2998 = (state_machine_regs
.op_index
+ uladv
)
2999 % linfo
.li_max_ops_per_insn
;
3003 case DW_LNS_advance_line
:
3004 adv
= read_sleb128 (data
, & bytes_read
);
3006 state_machine_regs
.line
+= adv
;
3009 case DW_LNS_set_file
:
3010 adv
= read_leb128 (data
, & bytes_read
, 0);
3012 state_machine_regs
.file
= adv
;
3013 if (file_table
[state_machine_regs
.file
- 1].directory_index
== 0)
3015 /* If directory index is 0, that means current directory. */
3016 printf ("\n./%s:[++]\n",
3017 file_table
[state_machine_regs
.file
- 1].name
);
3021 /* The directory index starts counting at 1. */
3022 printf ("\n%s/%s:\n",
3023 directory_table
[file_table
[state_machine_regs
.file
- 1].directory_index
- 1],
3024 file_table
[state_machine_regs
.file
- 1].name
);
3028 case DW_LNS_set_column
:
3029 uladv
= read_leb128 (data
, & bytes_read
, 0);
3031 state_machine_regs
.column
= uladv
;
3034 case DW_LNS_negate_stmt
:
3035 adv
= state_machine_regs
.is_stmt
;
3037 state_machine_regs
.is_stmt
= adv
;
3040 case DW_LNS_set_basic_block
:
3041 state_machine_regs
.basic_block
= 1;
3044 case DW_LNS_const_add_pc
:
3045 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
3046 if (linfo
.li_max_ops_per_insn
== 1)
3048 uladv
*= linfo
.li_min_insn_length
;
3049 state_machine_regs
.address
+= uladv
;
3053 state_machine_regs
.address
3054 += ((state_machine_regs
.op_index
+ uladv
)
3055 / linfo
.li_max_ops_per_insn
)
3056 * linfo
.li_min_insn_length
;
3057 state_machine_regs
.op_index
3058 = (state_machine_regs
.op_index
+ uladv
)
3059 % linfo
.li_max_ops_per_insn
;
3063 case DW_LNS_fixed_advance_pc
:
3064 uladv
= byte_get (data
, 2);
3066 state_machine_regs
.address
+= uladv
;
3067 state_machine_regs
.op_index
= 0;
3070 case DW_LNS_set_prologue_end
:
3073 case DW_LNS_set_epilogue_begin
:
3076 case DW_LNS_set_isa
:
3077 uladv
= read_leb128 (data
, & bytes_read
, 0);
3079 printf (_(" Set ISA to %lu\n"), uladv
);
3083 printf (_(" Unknown opcode %d with operands: "), op_code
);
3085 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
3087 printf ("0x%s%s", dwarf_vmatoa ("x", read_leb128 (data
,
3089 i
== 1 ? "" : ", ");
3096 /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row
3097 to the DWARF address/line matrix. */
3098 if ((is_special_opcode
) || (op_code
== DW_LNE_end_sequence
)
3099 || (op_code
== DW_LNS_copy
))
3101 const unsigned int MAX_FILENAME_LENGTH
= 35;
3102 char *fileName
= (char *)file_table
[state_machine_regs
.file
- 1].name
;
3103 char *newFileName
= NULL
;
3104 size_t fileNameLength
= strlen (fileName
);
3106 if ((fileNameLength
> MAX_FILENAME_LENGTH
) && (!do_wide
))
3108 newFileName
= (char *) xmalloc (MAX_FILENAME_LENGTH
+ 1);
3109 /* Truncate file name */
3110 strncpy (newFileName
,
3111 fileName
+ fileNameLength
- MAX_FILENAME_LENGTH
,
3112 MAX_FILENAME_LENGTH
+ 1);
3116 newFileName
= (char *) xmalloc (fileNameLength
+ 1);
3117 strncpy (newFileName
, fileName
, fileNameLength
+ 1);
3120 if (!do_wide
|| (fileNameLength
<= MAX_FILENAME_LENGTH
))
3122 if (linfo
.li_max_ops_per_insn
== 1)
3123 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x\n",
3124 newFileName
, state_machine_regs
.line
,
3125 state_machine_regs
.address
);
3127 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x[%d]\n",
3128 newFileName
, state_machine_regs
.line
,
3129 state_machine_regs
.address
,
3130 state_machine_regs
.op_index
);
3134 if (linfo
.li_max_ops_per_insn
== 1)
3135 printf ("%s %11d %#18" DWARF_VMA_FMT
"x\n",
3136 newFileName
, state_machine_regs
.line
,
3137 state_machine_regs
.address
);
3139 printf ("%s %11d %#18" DWARF_VMA_FMT
"x[%d]\n",
3140 newFileName
, state_machine_regs
.line
,
3141 state_machine_regs
.address
,
3142 state_machine_regs
.op_index
);
3145 if (op_code
== DW_LNE_end_sequence
)
3153 free (directory_table
);
3154 directory_table
= NULL
;
3162 display_debug_lines (struct dwarf_section
*section
, void *file ATTRIBUTE_UNUSED
)
3164 unsigned char *data
= section
->start
;
3165 unsigned char *end
= data
+ section
->size
;
3167 int retValDecoded
= 1;
3169 if (do_debug_lines
== 0)
3170 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
3172 if (do_debug_lines
& FLAG_DEBUG_LINES_RAW
)
3173 retValRaw
= display_debug_lines_raw (section
, data
, end
);
3175 if (do_debug_lines
& FLAG_DEBUG_LINES_DECODED
)
3176 retValDecoded
= display_debug_lines_decoded (section
, data
, end
);
3178 if (!retValRaw
|| !retValDecoded
)
3185 find_debug_info_for_offset (unsigned long offset
)
3189 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
3192 for (i
= 0; i
< num_debug_info_entries
; i
++)
3193 if (debug_information
[i
].cu_offset
== offset
)
3194 return debug_information
+ i
;
3200 display_debug_pubnames (struct dwarf_section
*section
,
3201 void *file ATTRIBUTE_UNUSED
)
3203 DWARF2_Internal_PubNames names
;
3204 unsigned char *start
= section
->start
;
3205 unsigned char *end
= start
+ section
->size
;
3207 /* It does not matter if this load fails,
3208 we test for that later on. */
3209 load_debug_info (file
);
3211 printf (_("Contents of the %s section:\n\n"), section
->name
);
3215 unsigned char *data
;
3216 unsigned long offset
;
3217 int offset_size
, initial_length_size
;
3221 names
.pn_length
= byte_get (data
, 4);
3223 if (names
.pn_length
== 0xffffffff)
3225 names
.pn_length
= byte_get (data
, 8);
3228 initial_length_size
= 12;
3233 initial_length_size
= 4;
3236 names
.pn_version
= byte_get (data
, 2);
3239 names
.pn_offset
= byte_get (data
, offset_size
);
3240 data
+= offset_size
;
3242 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
3243 && num_debug_info_entries
> 0
3244 && find_debug_info_for_offset (names
.pn_offset
) == NULL
)
3245 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
3246 (unsigned long) names
.pn_offset
, section
->name
);
3248 names
.pn_size
= byte_get (data
, offset_size
);
3249 data
+= offset_size
;
3251 start
+= names
.pn_length
+ initial_length_size
;
3253 if (names
.pn_version
!= 2 && names
.pn_version
!= 3)
3255 static int warned
= 0;
3259 warn (_("Only DWARF 2 and 3 pubnames are currently supported\n"));
3266 printf (_(" Length: %ld\n"),
3267 (long) names
.pn_length
);
3268 printf (_(" Version: %d\n"),
3270 printf (_(" Offset into .debug_info section: 0x%lx\n"),
3271 (unsigned long) names
.pn_offset
);
3272 printf (_(" Size of area in .debug_info section: %ld\n"),
3273 (long) names
.pn_size
);
3275 printf (_("\n Offset\tName\n"));
3279 offset
= byte_get (data
, offset_size
);
3283 data
+= offset_size
;
3284 printf (" %-6lx\t%s\n", offset
, data
);
3285 data
+= strlen ((char *) data
) + 1;
3288 while (offset
!= 0);
3296 display_debug_macinfo (struct dwarf_section
*section
,
3297 void *file ATTRIBUTE_UNUSED
)
3299 unsigned char *start
= section
->start
;
3300 unsigned char *end
= start
+ section
->size
;
3301 unsigned char *curr
= start
;
3302 unsigned int bytes_read
;
3303 enum dwarf_macinfo_record_type op
;
3305 printf (_("Contents of the %s section:\n\n"), section
->name
);
3309 unsigned int lineno
;
3312 op
= (enum dwarf_macinfo_record_type
) *curr
;
3317 case DW_MACINFO_start_file
:
3319 unsigned int filenum
;
3321 lineno
= read_leb128 (curr
, & bytes_read
, 0);
3323 filenum
= read_leb128 (curr
, & bytes_read
, 0);
3326 printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"),
3331 case DW_MACINFO_end_file
:
3332 printf (_(" DW_MACINFO_end_file\n"));
3335 case DW_MACINFO_define
:
3336 lineno
= read_leb128 (curr
, & bytes_read
, 0);
3338 string
= (char *) curr
;
3339 curr
+= strlen (string
) + 1;
3340 printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"),
3344 case DW_MACINFO_undef
:
3345 lineno
= read_leb128 (curr
, & bytes_read
, 0);
3347 string
= (char *) curr
;
3348 curr
+= strlen (string
) + 1;
3349 printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"),
3353 case DW_MACINFO_vendor_ext
:
3355 unsigned int constant
;
3357 constant
= read_leb128 (curr
, & bytes_read
, 0);
3359 string
= (char *) curr
;
3360 curr
+= strlen (string
) + 1;
3361 printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"),
3371 /* Given LINE_OFFSET into the .debug_line section, attempt to return
3372 filename and dirname corresponding to file name table entry with index
3373 FILEIDX. Return NULL on failure. */
3375 static unsigned char *
3376 get_line_filename_and_dirname (dwarf_vma line_offset
, dwarf_vma fileidx
,
3377 unsigned char **dir_name
)
3379 struct dwarf_section
*section
= &debug_displays
[line
].section
;
3380 unsigned char *hdrptr
, *dirtable
, *file_name
;
3381 unsigned int offset_size
, initial_length_size
;
3382 unsigned int version
, opcode_base
, bytes_read
;
3383 dwarf_vma length
, diridx
;
3386 if (section
->start
== NULL
3387 || line_offset
>= section
->size
3391 hdrptr
= section
->start
+ line_offset
;
3392 length
= byte_get (hdrptr
, 4);
3394 if (length
== 0xffffffff)
3396 /* This section is 64-bit DWARF 3. */
3397 length
= byte_get (hdrptr
, 8);
3400 initial_length_size
= 12;
3405 initial_length_size
= 4;
3407 if (length
+ initial_length_size
> section
->size
)
3409 version
= byte_get (hdrptr
, 2);
3411 if (version
!= 2 && version
!= 3 && version
!= 4)
3413 hdrptr
+= offset_size
+ 1;/* Skip prologue_length and min_insn_length. */
3415 hdrptr
++; /* Skip max_ops_per_insn. */
3416 hdrptr
+= 3; /* Skip default_is_stmt, line_base, line_range. */
3417 opcode_base
= byte_get (hdrptr
, 1);
3418 if (opcode_base
== 0)
3421 hdrptr
+= opcode_base
- 1;
3423 /* Skip over dirname table. */
3424 while (*hdrptr
!= '\0')
3425 hdrptr
+= strlen ((char *) hdrptr
) + 1;
3426 hdrptr
++; /* Skip the NUL at the end of the table. */
3427 /* Now skip over preceding filename table entries. */
3428 for (; *hdrptr
!= '\0' && fileidx
> 1; fileidx
--)
3430 hdrptr
+= strlen ((char *) hdrptr
) + 1;
3431 read_leb128 (hdrptr
, &bytes_read
, 0);
3432 hdrptr
+= bytes_read
;
3433 read_leb128 (hdrptr
, &bytes_read
, 0);
3434 hdrptr
+= bytes_read
;
3435 read_leb128 (hdrptr
, &bytes_read
, 0);
3436 hdrptr
+= bytes_read
;
3438 if (*hdrptr
== '\0')
3441 hdrptr
+= strlen ((char *) hdrptr
) + 1;
3442 diridx
= read_leb128 (hdrptr
, &bytes_read
, 0);
3445 for (; *dirtable
!= '\0' && diridx
> 1; diridx
--)
3446 dirtable
+= strlen ((char *) dirtable
) + 1;
3447 if (*dirtable
== '\0')
3449 *dir_name
= dirtable
;
3454 display_debug_macro (struct dwarf_section
*section
,
3457 unsigned char *start
= section
->start
;
3458 unsigned char *end
= start
+ section
->size
;
3459 unsigned char *curr
= start
;
3460 unsigned char *extended_op_buf
[256];
3461 unsigned int bytes_read
;
3463 load_debug_section (str
, file
);
3464 load_debug_section (line
, file
);
3466 printf (_("Contents of the %s section:\n\n"), section
->name
);
3470 unsigned int lineno
, version
, flags
;
3471 unsigned int offset_size
= 4;
3473 dwarf_vma line_offset
= 0, sec_offset
= curr
- start
, offset
;
3474 unsigned char **extended_ops
= NULL
;
3476 version
= byte_get (curr
, 2);
3481 error (_("Only GNU extension to DWARF 4 of %s is currently supported.\n"),
3486 flags
= byte_get (curr
++, 1);
3489 printf (_(" Offset: 0x%lx\n"),
3490 (unsigned long) sec_offset
);
3491 printf (_(" Version: %d\n"), version
);
3492 printf (_(" Offset size: %d\n"), offset_size
);
3495 line_offset
= byte_get (curr
, offset_size
);
3496 curr
+= offset_size
;
3497 printf (_(" Offset into .debug_line: 0x%lx\n"),
3498 (unsigned long) line_offset
);
3502 unsigned int i
, count
= byte_get (curr
++, 1), op
;
3504 memset (extended_op_buf
, 0, sizeof (extended_op_buf
));
3505 extended_ops
= extended_op_buf
;
3508 printf (_(" Extension opcode arguments:\n"));
3509 for (i
= 0; i
< count
; i
++)
3511 op
= byte_get (curr
++, 1);
3512 extended_ops
[op
] = curr
;
3513 nargs
= read_leb128 (curr
, &bytes_read
, 0);
3516 printf (_(" DW_MACRO_GNU_%02x has no arguments\n"), op
);
3519 printf (_(" DW_MACRO_GNU_%02x arguments: "), op
);
3520 for (n
= 0; n
< nargs
; n
++)
3522 unsigned int form
= byte_get (curr
++, 1);
3523 printf ("%s%s", get_FORM_name (form
),
3524 n
== nargs
- 1 ? "\n" : ", ");
3534 case DW_FORM_block1
:
3535 case DW_FORM_block2
:
3536 case DW_FORM_block4
:
3538 case DW_FORM_string
:
3540 case DW_FORM_sec_offset
:
3543 error (_("Invalid extension opcode form %s\n"),
3544 get_FORM_name (form
));
3560 error (_(".debug_macro section not zero terminated\n"));
3564 op
= byte_get (curr
++, 1);
3570 case DW_MACRO_GNU_start_file
:
3572 unsigned int filenum
;
3573 unsigned char *file_name
= NULL
, *dir_name
= NULL
;
3575 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3577 filenum
= read_leb128 (curr
, &bytes_read
, 0);
3580 if ((flags
& 2) == 0)
3581 error (_("DW_MACRO_GNU_start_file used, but no .debug_line offset provided.\n"));
3584 = get_line_filename_and_dirname (line_offset
, filenum
,
3586 if (file_name
== NULL
)
3587 printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d\n"),
3590 printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d filename: %s%s%s\n"),
3592 dir_name
!= NULL
? (const char *) dir_name
: "",
3593 dir_name
!= NULL
? "/" : "", file_name
);
3597 case DW_MACRO_GNU_end_file
:
3598 printf (_(" DW_MACRO_GNU_end_file\n"));
3601 case DW_MACRO_GNU_define
:
3602 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3604 string
= (char *) curr
;
3605 curr
+= strlen (string
) + 1;
3606 printf (_(" DW_MACRO_GNU_define - lineno : %d macro : %s\n"),
3610 case DW_MACRO_GNU_undef
:
3611 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3613 string
= (char *) curr
;
3614 curr
+= strlen (string
) + 1;
3615 printf (_(" DW_MACRO_GNU_undef - lineno : %d macro : %s\n"),
3619 case DW_MACRO_GNU_define_indirect
:
3620 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3622 offset
= byte_get (curr
, offset_size
);
3623 curr
+= offset_size
;
3624 string
= fetch_indirect_string (offset
);
3625 printf (_(" DW_MACRO_GNU_define_indirect - lineno : %d macro : %s\n"),
3629 case DW_MACRO_GNU_undef_indirect
:
3630 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3632 offset
= byte_get (curr
, offset_size
);
3633 curr
+= offset_size
;
3634 string
= fetch_indirect_string (offset
);
3635 printf (_(" DW_MACRO_GNU_undef_indirect - lineno : %d macro : %s\n"),
3639 case DW_MACRO_GNU_transparent_include
:
3640 offset
= byte_get (curr
, offset_size
);
3641 curr
+= offset_size
;
3642 printf (_(" DW_MACRO_GNU_transparent_include - offset : 0x%lx\n"),
3643 (unsigned long) offset
);
3646 case DW_MACRO_GNU_define_indirect_alt
:
3647 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3649 offset
= byte_get (curr
, offset_size
);
3650 curr
+= offset_size
;
3651 printf (_(" DW_MACRO_GNU_define_indirect_alt - lineno : %d macro offset : 0x%lx\n"),
3652 lineno
, (unsigned long) offset
);
3655 case DW_MACRO_GNU_undef_indirect_alt
:
3656 lineno
= read_leb128 (curr
, &bytes_read
, 0);
3658 offset
= byte_get (curr
, offset_size
);
3659 curr
+= offset_size
;
3660 printf (_(" DW_MACRO_GNU_undef_indirect_alt - lineno : %d macro offset : 0x%lx\n"),
3661 lineno
, (unsigned long) offset
);
3664 case DW_MACRO_GNU_transparent_include_alt
:
3665 offset
= byte_get (curr
, offset_size
);
3666 curr
+= offset_size
;
3667 printf (_(" DW_MACRO_GNU_transparent_include_alt - offset : 0x%lx\n"),
3668 (unsigned long) offset
);
3672 if (extended_ops
== NULL
|| extended_ops
[op
] == NULL
)
3674 error (_(" Unknown macro opcode %02x seen\n"), op
);
3679 /* Skip over unhandled opcodes. */
3681 unsigned char *desc
= extended_ops
[op
];
3682 nargs
= read_leb128 (desc
, &bytes_read
, 0);
3686 printf (_(" DW_MACRO_GNU_%02x\n"), op
);
3689 printf (_(" DW_MACRO_GNU_%02x -"), op
);
3690 for (n
= 0; n
< nargs
; n
++)
3693 = read_and_display_attr_value (0, byte_get (desc
++, 1),
3694 curr
, 0, 0, offset_size
,
3695 version
, NULL
, 0, NULL
);
3712 display_debug_abbrev (struct dwarf_section
*section
,
3713 void *file ATTRIBUTE_UNUSED
)
3715 abbrev_entry
*entry
;
3716 unsigned char *start
= section
->start
;
3717 unsigned char *end
= start
+ section
->size
;
3719 printf (_("Contents of the %s section:\n\n"), section
->name
);
3723 unsigned char *last
;
3728 start
= process_abbrev_section (start
, end
);
3730 if (first_abbrev
== NULL
)
3733 printf (_(" Number TAG (0x%lx)\n"), (long) (last
- section
->start
));
3735 for (entry
= first_abbrev
; entry
; entry
= entry
->next
)
3739 printf (" %ld %s [%s]\n",
3741 get_TAG_name (entry
->tag
),
3742 entry
->children
? _("has children") : _("no children"));
3744 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
3745 printf (" %-18s %s\n",
3746 get_AT_name (attr
->attribute
),
3747 get_FORM_name (attr
->form
));
3757 /* Display a location list from a normal (ie, non-dwo) .debug_loc section. */
3760 display_loc_list (struct dwarf_section
*section
,
3761 unsigned char **start_ptr
,
3762 int debug_info_entry
,
3763 unsigned long offset
,
3764 unsigned long base_address
,
3767 unsigned char *start
= *start_ptr
;
3768 unsigned char *section_end
= section
->start
+ section
->size
;
3769 unsigned long cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
3770 unsigned int pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
3771 unsigned int offset_size
= debug_information
[debug_info_entry
].offset_size
;
3772 int dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
3776 unsigned short length
;
3777 int need_frame_base
;
3781 if (start
+ 2 * pointer_size
> section_end
)
3783 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3788 /* Note: we use sign extension here in order to be sure that we can detect
3789 the -1 escape value. Sign extension into the top 32 bits of a 32-bit
3790 address will not affect the values that we display since we always show
3791 hex values, and always the bottom 32-bits. */
3792 begin
= byte_get_signed (start
, pointer_size
);
3793 start
+= pointer_size
;
3794 end
= byte_get_signed (start
, pointer_size
);
3795 start
+= pointer_size
;
3797 printf (" %8.8lx ", offset
);
3799 if (begin
== 0 && end
== 0)
3801 printf (_("<End of list>\n"));
3805 /* Check base address specifiers. */
3806 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
3809 print_dwarf_vma (begin
, pointer_size
);
3810 print_dwarf_vma (end
, pointer_size
);
3811 printf (_("(base address)\n"));
3815 if (start
+ 2 > section_end
)
3817 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3822 length
= byte_get (start
, 2);
3825 if (start
+ length
> section_end
)
3827 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3832 print_dwarf_vma (begin
+ base_address
, pointer_size
);
3833 print_dwarf_vma (end
+ base_address
, pointer_size
);
3836 need_frame_base
= decode_location_expression (start
,
3841 cu_offset
, section
);
3844 if (need_frame_base
&& !has_frame_base
)
3845 printf (_(" [without DW_AT_frame_base]"));
3848 fputs (_(" (start == end)"), stdout
);
3849 else if (begin
> end
)
3850 fputs (_(" (start > end)"), stdout
);
3860 /* Display a location list from a .dwo section. It uses address indexes rather
3861 than embedded addresses. This code closely follows display_loc_list, but the
3862 two are sufficiently different that combining things is very ugly. */
3865 display_loc_list_dwo (struct dwarf_section
*section
,
3866 unsigned char **start_ptr
,
3867 int debug_info_entry
,
3868 unsigned long offset
,
3871 unsigned char *start
= *start_ptr
;
3872 unsigned char *section_end
= section
->start
+ section
->size
;
3873 unsigned long cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
3874 unsigned int pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
3875 unsigned int offset_size
= debug_information
[debug_info_entry
].offset_size
;
3876 int dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
3878 unsigned short length
;
3879 int need_frame_base
;
3881 unsigned int bytes_read
;
3885 printf (" %8.8lx ", offset
);
3887 if (start
+ 2 > section_end
)
3889 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3894 entry_type
= byte_get (start
, 1);
3898 case 0: /* A terminating entry. */
3899 idx
= byte_get (start
, 1);
3903 printf (_("<End of list>\n"));
3905 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3908 case 1: /* A base-address entry. */
3909 idx
= read_leb128 (start
, &bytes_read
, 0);
3910 start
+= bytes_read
;
3911 print_dwarf_vma (idx
, pointer_size
);
3912 printf (_("(base address index)\n"));
3914 case 2: /* A normal entry. */
3915 idx
= read_leb128 (start
, &bytes_read
, 0);
3916 start
+= bytes_read
;
3917 print_dwarf_vma (idx
, pointer_size
);
3918 idx
= read_leb128 (start
, &bytes_read
, 0);
3919 start
+= bytes_read
;
3920 print_dwarf_vma (idx
, pointer_size
);
3923 warn (_("Unknown location-list type 0x%x.\n"), entry_type
);
3928 if (start
+ 2 > section_end
)
3930 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3935 length
= byte_get (start
, 2);
3938 if (start
+ length
> section_end
)
3940 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3946 need_frame_base
= decode_location_expression (start
,
3951 cu_offset
, section
);
3954 if (need_frame_base
&& !has_frame_base
)
3955 printf (_(" [without DW_AT_frame_base]"));
3965 /* Sort array of indexes in ascending order of loc_offsets[idx]. */
3967 static dwarf_vma
*loc_offsets
;
3970 loc_offsets_compar (const void *ap
, const void *bp
)
3972 dwarf_vma a
= loc_offsets
[*(const unsigned int *) ap
];
3973 dwarf_vma b
= loc_offsets
[*(const unsigned int *) bp
];
3975 return (a
> b
) - (b
> a
);
3979 display_debug_loc (struct dwarf_section
*section
, void *file
)
3981 unsigned char *start
= section
->start
;
3982 unsigned long bytes
;
3983 unsigned char *section_begin
= start
;
3984 unsigned int num_loc_list
= 0;
3985 unsigned long last_offset
= 0;
3986 unsigned int first
= 0;
3990 int seen_first_offset
= 0;
3991 int locs_sorted
= 1;
3992 unsigned char *next
;
3993 unsigned int *array
= NULL
;
3994 const char *suffix
= strrchr (section
->name
, '.');
3997 if (suffix
&& strcmp (suffix
, ".dwo") == 0)
4000 bytes
= section
->size
;
4004 printf (_("\nThe %s section is empty.\n"), section
->name
);
4008 if (load_debug_info (file
) == 0)
4010 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4015 /* Check the order of location list in .debug_info section. If
4016 offsets of location lists are in the ascending order, we can
4017 use `debug_information' directly. */
4018 for (i
= 0; i
< num_debug_info_entries
; i
++)
4022 num
= debug_information
[i
].num_loc_offsets
;
4023 if (num
> num_loc_list
)
4026 /* Check if we can use `debug_information' directly. */
4027 if (locs_sorted
&& num
!= 0)
4029 if (!seen_first_offset
)
4031 /* This is the first location list. */
4032 last_offset
= debug_information
[i
].loc_offsets
[0];
4034 seen_first_offset
= 1;
4040 for (; j
< num
; j
++)
4043 debug_information
[i
].loc_offsets
[j
])
4048 last_offset
= debug_information
[i
].loc_offsets
[j
];
4053 if (!seen_first_offset
)
4054 error (_("No location lists in .debug_info section!\n"));
4056 /* DWARF sections under Mach-O have non-zero addresses. */
4057 if (debug_information
[first
].num_loc_offsets
> 0
4058 && debug_information
[first
].loc_offsets
[0] != section
->address
)
4059 warn (_("Location lists in %s section start at 0x%s\n"),
4061 dwarf_vmatoa ("x", debug_information
[first
].loc_offsets
[0]));
4064 array
= (unsigned int *) xcmalloc (num_loc_list
, sizeof (unsigned int));
4065 printf (_("Contents of the %s section:\n\n"), section
->name
);
4067 printf (_(" Offset Begin End Expression\n"));
4069 printf (_(" Offset Begin idx End idx Expression\n"));
4071 seen_first_offset
= 0;
4072 for (i
= first
; i
< num_debug_info_entries
; i
++)
4074 unsigned long offset
;
4075 unsigned long base_address
;
4080 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
4082 loc_offsets
= debug_information
[i
].loc_offsets
;
4083 qsort (array
, debug_information
[i
].num_loc_offsets
,
4084 sizeof (*array
), loc_offsets_compar
);
4087 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
4089 j
= locs_sorted
? k
: array
[k
];
4091 && debug_information
[i
].loc_offsets
[locs_sorted
4092 ? k
- 1 : array
[k
- 1]]
4093 == debug_information
[i
].loc_offsets
[j
])
4095 has_frame_base
= debug_information
[i
].have_frame_base
[j
];
4096 /* DWARF sections under Mach-O have non-zero addresses. */
4097 offset
= debug_information
[i
].loc_offsets
[j
] - section
->address
;
4098 next
= section_begin
+ offset
;
4099 base_address
= debug_information
[i
].base_address
;
4101 if (!seen_first_offset
)
4102 seen_first_offset
= 1;
4106 warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"),
4107 (unsigned long) (start
- section_begin
),
4108 (unsigned long) (next
- section_begin
));
4109 else if (start
> next
)
4110 warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"),
4111 (unsigned long) (start
- section_begin
),
4112 (unsigned long) (next
- section_begin
));
4116 if (offset
>= bytes
)
4118 warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"),
4124 display_loc_list_dwo (section
, &start
, i
, offset
, has_frame_base
);
4126 display_loc_list (section
, &start
, i
, offset
, base_address
,
4131 if (start
< section
->start
+ section
->size
)
4132 warn (_("There are %ld unused bytes at the end of section %s\n"),
4133 (long) (section
->start
+ section
->size
- start
), section
->name
);
4140 display_debug_str (struct dwarf_section
*section
,
4141 void *file ATTRIBUTE_UNUSED
)
4143 unsigned char *start
= section
->start
;
4144 unsigned long bytes
= section
->size
;
4145 dwarf_vma addr
= section
->address
;
4149 printf (_("\nThe %s section is empty.\n"), section
->name
);
4153 printf (_("Contents of the %s section:\n\n"), section
->name
);
4161 lbytes
= (bytes
> 16 ? 16 : bytes
);
4163 printf (" 0x%8.8lx ", (unsigned long) addr
);
4165 for (j
= 0; j
< 16; j
++)
4168 printf ("%2.2x", start
[j
]);
4176 for (j
= 0; j
< lbytes
; j
++)
4179 if (k
>= ' ' && k
< 0x80)
4198 display_debug_info (struct dwarf_section
*section
, void *file
)
4200 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 0);
4204 display_debug_types (struct dwarf_section
*section
, void *file
)
4206 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 1);
4210 display_trace_info (struct dwarf_section
*section
, void *file
)
4212 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 0);
4216 display_debug_aranges (struct dwarf_section
*section
,
4217 void *file ATTRIBUTE_UNUSED
)
4219 unsigned char *start
= section
->start
;
4220 unsigned char *end
= start
+ section
->size
;
4222 printf (_("Contents of the %s section:\n\n"), section
->name
);
4224 /* It does not matter if this load fails,
4225 we test for that later on. */
4226 load_debug_info (file
);
4230 unsigned char *hdrptr
;
4231 DWARF2_Internal_ARange arange
;
4232 unsigned char *addr_ranges
;
4235 unsigned char address_size
;
4238 int initial_length_size
;
4242 arange
.ar_length
= byte_get (hdrptr
, 4);
4245 if (arange
.ar_length
== 0xffffffff)
4247 arange
.ar_length
= byte_get (hdrptr
, 8);
4250 initial_length_size
= 12;
4255 initial_length_size
= 4;
4258 arange
.ar_version
= byte_get (hdrptr
, 2);
4261 arange
.ar_info_offset
= byte_get (hdrptr
, offset_size
);
4262 hdrptr
+= offset_size
;
4264 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
4265 && num_debug_info_entries
> 0
4266 && find_debug_info_for_offset (arange
.ar_info_offset
) == NULL
)
4267 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
4268 (unsigned long) arange
.ar_info_offset
, section
->name
);
4270 arange
.ar_pointer_size
= byte_get (hdrptr
, 1);
4273 arange
.ar_segment_size
= byte_get (hdrptr
, 1);
4276 if (arange
.ar_version
!= 2 && arange
.ar_version
!= 3)
4278 warn (_("Only DWARF 2 and 3 aranges are currently supported.\n"));
4282 printf (_(" Length: %ld\n"),
4283 (long) arange
.ar_length
);
4284 printf (_(" Version: %d\n"), arange
.ar_version
);
4285 printf (_(" Offset into .debug_info: 0x%lx\n"),
4286 (unsigned long) arange
.ar_info_offset
);
4287 printf (_(" Pointer Size: %d\n"), arange
.ar_pointer_size
);
4288 printf (_(" Segment Size: %d\n"), arange
.ar_segment_size
);
4290 address_size
= arange
.ar_pointer_size
+ arange
.ar_segment_size
;
4292 if (address_size
== 0)
4294 error (_("Invalid address size in %s section!\n"),
4299 /* The DWARF spec does not require that the address size be a power
4300 of two, but we do. This will have to change if we ever encounter
4301 an uneven architecture. */
4302 if ((address_size
& (address_size
- 1)) != 0)
4304 warn (_("Pointer size + Segment size is not a power of two.\n"));
4308 if (address_size
> 4)
4309 printf (_("\n Address Length\n"));
4311 printf (_("\n Address Length\n"));
4313 addr_ranges
= hdrptr
;
4315 /* Must pad to an alignment boundary that is twice the address size. */
4316 excess
= (hdrptr
- start
) % (2 * address_size
);
4318 addr_ranges
+= (2 * address_size
) - excess
;
4320 start
+= arange
.ar_length
+ initial_length_size
;
4322 while (addr_ranges
+ 2 * address_size
<= start
)
4324 address
= byte_get (addr_ranges
, address_size
);
4326 addr_ranges
+= address_size
;
4328 length
= byte_get (addr_ranges
, address_size
);
4330 addr_ranges
+= address_size
;
4333 print_dwarf_vma (address
, address_size
);
4334 print_dwarf_vma (length
, address_size
);
4344 /* Comparison function for qsort. */
4346 comp_addr_base (const void * v0
, const void * v1
)
4348 debug_info
* info0
= (debug_info
*) v0
;
4349 debug_info
* info1
= (debug_info
*) v1
;
4350 return info0
->addr_base
- info1
->addr_base
;
4353 /* Display the debug_addr section. */
4355 display_debug_addr (struct dwarf_section
*section
,
4358 debug_info
**debug_addr_info
;
4359 unsigned char *entry
;
4364 if (section
->size
== 0)
4366 printf (_("\nThe %s section is empty.\n"), section
->name
);
4370 if (load_debug_info (file
) == 0)
4372 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4377 printf (_("Contents of the %s section:\n\n"), section
->name
);
4379 debug_addr_info
= (debug_info
**) xmalloc (num_debug_info_entries
+ 1
4380 * sizeof (debug_info
*));
4383 for (i
= 0; i
< num_debug_info_entries
; i
++)
4385 if (debug_information
[i
].addr_base
!= DEBUG_INFO_UNAVAILABLE
)
4386 debug_addr_info
[count
++] = &debug_information
[i
];
4389 /* Add a sentinel to make iteration convenient. */
4390 debug_addr_info
[count
] = (debug_info
*) xmalloc (sizeof (debug_info
));
4391 debug_addr_info
[count
]->addr_base
= section
->size
;
4393 qsort (debug_addr_info
, count
, sizeof (debug_info
*), comp_addr_base
);
4394 for (i
= 0; i
< count
; i
++)
4398 printf (_(" For compilation unit at offset 0x%s:\n"),
4399 dwarf_vmatoa ("x", debug_addr_info
[i
]->cu_offset
));
4401 printf (_("\tIndex\tOffset\n"));
4402 entry
= section
->start
+ debug_addr_info
[i
]->addr_base
;
4403 end
= section
->start
+ debug_addr_info
[i
+ 1]->addr_base
;
4407 dwarf_vma base
= byte_get (entry
, debug_addr_info
[i
]->pointer_size
);
4408 printf (_("\t%d:\t%s\n"), idx
, dwarf_vmatoa ("x", base
));
4409 entry
+= debug_addr_info
[i
]->pointer_size
;
4415 free (debug_addr_info
);
4419 /* Display the .debug_str_offsets and .debug_str_offsets.dwo sections. */
4421 display_debug_str_offsets (struct dwarf_section
*section
,
4422 void *file ATTRIBUTE_UNUSED
)
4424 if (section
->size
== 0)
4426 printf (_("\nThe %s section is empty.\n"), section
->name
);
4429 /* TODO: Dump the contents. This is made somewhat difficult by not knowing
4430 what the offset size is for this section. */
4434 /* Each debug_information[x].range_lists[y] gets this representation for
4435 sorting purposes. */
4439 /* The debug_information[x].range_lists[y] value. */
4440 unsigned long ranges_offset
;
4442 /* Original debug_information to find parameters of the data. */
4443 debug_info
*debug_info_p
;
4446 /* Sort struct range_entry in ascending order of its RANGES_OFFSET. */
4449 range_entry_compar (const void *ap
, const void *bp
)
4451 const struct range_entry
*a_re
= (const struct range_entry
*) ap
;
4452 const struct range_entry
*b_re
= (const struct range_entry
*) bp
;
4453 const unsigned long a
= a_re
->ranges_offset
;
4454 const unsigned long b
= b_re
->ranges_offset
;
4456 return (a
> b
) - (b
> a
);
4460 display_debug_ranges (struct dwarf_section
*section
,
4461 void *file ATTRIBUTE_UNUSED
)
4463 unsigned char *start
= section
->start
;
4464 unsigned char *last_start
= start
;
4465 unsigned long bytes
;
4466 unsigned char *section_begin
= start
;
4467 unsigned int num_range_list
, i
;
4468 struct range_entry
*range_entries
, *range_entry_fill
;
4470 bytes
= section
->size
;
4474 printf (_("\nThe %s section is empty.\n"), section
->name
);
4478 if (load_debug_info (file
) == 0)
4480 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4486 for (i
= 0; i
< num_debug_info_entries
; i
++)
4487 num_range_list
+= debug_information
[i
].num_range_lists
;
4489 if (num_range_list
== 0)
4491 /* This can happen when the file was compiled with -gsplit-debug
4492 which removes references to range lists from the primary .o file. */
4493 printf (_("No range lists in .debug_info section.\n"));
4497 range_entries
= (struct range_entry
*)
4498 xmalloc (sizeof (*range_entries
) * num_range_list
);
4499 range_entry_fill
= range_entries
;
4501 for (i
= 0; i
< num_debug_info_entries
; i
++)
4503 debug_info
*debug_info_p
= &debug_information
[i
];
4506 for (j
= 0; j
< debug_info_p
->num_range_lists
; j
++)
4508 range_entry_fill
->ranges_offset
= debug_info_p
->range_lists
[j
];
4509 range_entry_fill
->debug_info_p
= debug_info_p
;
4514 qsort (range_entries
, num_range_list
, sizeof (*range_entries
),
4515 range_entry_compar
);
4517 /* DWARF sections under Mach-O have non-zero addresses. */
4518 if (dwarf_check
!= 0 && range_entries
[0].ranges_offset
!= section
->address
)
4519 warn (_("Range lists in %s section start at 0x%lx\n"),
4520 section
->name
, range_entries
[0].ranges_offset
);
4522 printf (_("Contents of the %s section:\n\n"), section
->name
);
4523 printf (_(" Offset Begin End\n"));
4525 for (i
= 0; i
< num_range_list
; i
++)
4527 struct range_entry
*range_entry
= &range_entries
[i
];
4528 debug_info
*debug_info_p
= range_entry
->debug_info_p
;
4529 unsigned int pointer_size
;
4530 unsigned long offset
;
4531 unsigned char *next
;
4532 unsigned long base_address
;
4534 pointer_size
= debug_info_p
->pointer_size
;
4536 /* DWARF sections under Mach-O have non-zero addresses. */
4537 offset
= range_entry
->ranges_offset
- section
->address
;
4538 next
= section_begin
+ offset
;
4539 base_address
= debug_info_p
->base_address
;
4541 if (dwarf_check
!= 0 && i
> 0)
4544 warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"),
4545 (unsigned long) (start
- section_begin
),
4546 (unsigned long) (next
- section_begin
), section
->name
);
4547 else if (start
> next
)
4549 if (next
== last_start
)
4551 warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"),
4552 (unsigned long) (start
- section_begin
),
4553 (unsigned long) (next
- section_begin
), section
->name
);
4564 /* Note: we use sign extension here in order to be sure that
4565 we can detect the -1 escape value. Sign extension into the
4566 top 32 bits of a 32-bit address will not affect the values
4567 that we display since we always show hex values, and always
4568 the bottom 32-bits. */
4569 begin
= byte_get_signed (start
, pointer_size
);
4570 start
+= pointer_size
;
4571 end
= byte_get_signed (start
, pointer_size
);
4572 start
+= pointer_size
;
4574 printf (" %8.8lx ", offset
);
4576 if (begin
== 0 && end
== 0)
4578 printf (_("<End of list>\n"));
4582 /* Check base address specifiers. */
4583 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
4586 print_dwarf_vma (begin
, pointer_size
);
4587 print_dwarf_vma (end
, pointer_size
);
4588 printf ("(base address)\n");
4592 print_dwarf_vma (begin
+ base_address
, pointer_size
);
4593 print_dwarf_vma (end
+ base_address
, pointer_size
);
4596 fputs (_("(start == end)"), stdout
);
4597 else if (begin
> end
)
4598 fputs (_("(start > end)"), stdout
);
4605 free (range_entries
);
4610 typedef struct Frame_Chunk
4612 struct Frame_Chunk
*next
;
4613 unsigned char *chunk_start
;
4615 /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
4616 short int *col_type
;
4619 unsigned int code_factor
;
4621 unsigned long pc_begin
;
4622 unsigned long pc_range
;
4626 unsigned char fde_encoding
;
4627 unsigned char cfa_exp
;
4628 unsigned char ptr_size
;
4629 unsigned char segment_size
;
4633 static const char *const *dwarf_regnames
;
4634 static unsigned int dwarf_regnames_count
;
4636 /* A marker for a col_type that means this column was never referenced
4637 in the frame info. */
4638 #define DW_CFA_unreferenced (-1)
4640 /* Return 0 if not more space is needed, 1 if more space is needed,
4641 -1 for invalid reg. */
4644 frame_need_space (Frame_Chunk
*fc
, unsigned int reg
)
4646 int prev
= fc
->ncols
;
4648 if (reg
< (unsigned int) fc
->ncols
)
4651 if (dwarf_regnames_count
4652 && reg
> dwarf_regnames_count
)
4655 fc
->ncols
= reg
+ 1;
4656 fc
->col_type
= (short int *) xcrealloc (fc
->col_type
, fc
->ncols
,
4657 sizeof (short int));
4658 fc
->col_offset
= (int *) xcrealloc (fc
->col_offset
, fc
->ncols
, sizeof (int));
4660 while (prev
< fc
->ncols
)
4662 fc
->col_type
[prev
] = DW_CFA_unreferenced
;
4663 fc
->col_offset
[prev
] = 0;
4669 static const char *const dwarf_regnames_i386
[] =
4671 "eax", "ecx", "edx", "ebx",
4672 "esp", "ebp", "esi", "edi",
4673 "eip", "eflags", NULL
,
4674 "st0", "st1", "st2", "st3",
4675 "st4", "st5", "st6", "st7",
4677 "xmm0", "xmm1", "xmm2", "xmm3",
4678 "xmm4", "xmm5", "xmm6", "xmm7",
4679 "mm0", "mm1", "mm2", "mm3",
4680 "mm4", "mm5", "mm6", "mm7",
4681 "fcw", "fsw", "mxcsr",
4682 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
4687 init_dwarf_regnames_i386 (void)
4689 dwarf_regnames
= dwarf_regnames_i386
;
4690 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_i386
);
4693 static const char *const dwarf_regnames_x86_64
[] =
4695 "rax", "rdx", "rcx", "rbx",
4696 "rsi", "rdi", "rbp", "rsp",
4697 "r8", "r9", "r10", "r11",
4698 "r12", "r13", "r14", "r15",
4700 "xmm0", "xmm1", "xmm2", "xmm3",
4701 "xmm4", "xmm5", "xmm6", "xmm7",
4702 "xmm8", "xmm9", "xmm10", "xmm11",
4703 "xmm12", "xmm13", "xmm14", "xmm15",
4704 "st0", "st1", "st2", "st3",
4705 "st4", "st5", "st6", "st7",
4706 "mm0", "mm1", "mm2", "mm3",
4707 "mm4", "mm5", "mm6", "mm7",
4709 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
4710 "fs.base", "gs.base", NULL
, NULL
,
4712 "mxcsr", "fcw", "fsw"
4716 init_dwarf_regnames_x86_64 (void)
4718 dwarf_regnames
= dwarf_regnames_x86_64
;
4719 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_x86_64
);
4723 init_dwarf_regnames (unsigned int e_machine
)
4729 init_dwarf_regnames_i386 ();
4735 init_dwarf_regnames_x86_64 ();
4744 regname (unsigned int regno
, int row
)
4746 static char reg
[64];
4748 && regno
< dwarf_regnames_count
4749 && dwarf_regnames
[regno
] != NULL
)
4752 return dwarf_regnames
[regno
];
4753 snprintf (reg
, sizeof (reg
), "r%d (%s)", regno
,
4754 dwarf_regnames
[regno
]);
4757 snprintf (reg
, sizeof (reg
), "r%d", regno
);
4762 frame_display_row (Frame_Chunk
*fc
, int *need_col_headers
, int *max_regs
)
4767 if (*max_regs
< fc
->ncols
)
4768 *max_regs
= fc
->ncols
;
4770 if (*need_col_headers
)
4772 static const char *sloc
= " LOC";
4774 *need_col_headers
= 0;
4776 printf ("%-*s CFA ", eh_addr_size
* 2, sloc
);
4778 for (r
= 0; r
< *max_regs
; r
++)
4779 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
4784 printf ("%-5s ", regname (r
, 1));
4790 printf ("%0*lx ", eh_addr_size
* 2, fc
->pc_begin
);
4792 strcpy (tmp
, "exp");
4794 sprintf (tmp
, "%s%+d", regname (fc
->cfa_reg
, 1), fc
->cfa_offset
);
4795 printf ("%-8s ", tmp
);
4797 for (r
= 0; r
< fc
->ncols
; r
++)
4799 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
4801 switch (fc
->col_type
[r
])
4803 case DW_CFA_undefined
:
4806 case DW_CFA_same_value
:
4810 sprintf (tmp
, "c%+d", fc
->col_offset
[r
]);
4812 case DW_CFA_val_offset
:
4813 sprintf (tmp
, "v%+d", fc
->col_offset
[r
]);
4815 case DW_CFA_register
:
4816 sprintf (tmp
, "%s", regname (fc
->col_offset
[r
], 0));
4818 case DW_CFA_expression
:
4819 strcpy (tmp
, "exp");
4821 case DW_CFA_val_expression
:
4822 strcpy (tmp
, "vexp");
4825 strcpy (tmp
, "n/a");
4828 printf ("%-5s ", tmp
);
4834 #define GET(N) byte_get (start, N); start += N
4835 #define LEB() read_leb128 (start, & length_return, 0); start += length_return
4836 #define SLEB() read_sleb128 (start, & length_return); start += length_return
4839 display_debug_frames (struct dwarf_section
*section
,
4840 void *file ATTRIBUTE_UNUSED
)
4842 unsigned char *start
= section
->start
;
4843 unsigned char *end
= start
+ section
->size
;
4844 unsigned char *section_start
= start
;
4845 Frame_Chunk
*chunks
= 0;
4846 Frame_Chunk
*remembered_state
= 0;
4848 int is_eh
= strcmp (section
->name
, ".eh_frame") == 0;
4849 unsigned int length_return
;
4851 const char *bad_reg
= _("bad register: ");
4852 int saved_eh_addr_size
= eh_addr_size
;
4854 printf (_("Contents of the %s section:\n"), section
->name
);
4858 unsigned char *saved_start
;
4859 unsigned char *block_end
;
4860 unsigned long length
;
4861 unsigned long cie_id
;
4864 int need_col_headers
= 1;
4865 unsigned char *augmentation_data
= NULL
;
4866 unsigned long augmentation_data_len
= 0;
4867 int encoded_ptr_size
= saved_eh_addr_size
;
4869 int initial_length_size
;
4871 saved_start
= start
;
4872 length
= byte_get (start
, 4); start
+= 4;
4876 printf ("\n%08lx ZERO terminator\n\n",
4877 (unsigned long)(saved_start
- section_start
));
4881 if (length
== 0xffffffff)
4883 length
= byte_get (start
, 8);
4886 initial_length_size
= 12;
4891 initial_length_size
= 4;
4894 block_end
= saved_start
+ length
+ initial_length_size
;
4895 if (block_end
> end
)
4897 warn ("Invalid length %#08lx in FDE at %#08lx\n",
4898 length
, (unsigned long)(saved_start
- section_start
));
4901 cie_id
= byte_get (start
, offset_size
); start
+= offset_size
;
4903 if (is_eh
? (cie_id
== 0) : (cie_id
== DW_CIE_ID
))
4907 fc
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
4908 memset (fc
, 0, sizeof (Frame_Chunk
));
4912 fc
->chunk_start
= saved_start
;
4914 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
4915 fc
->col_offset
= (int *) xmalloc (sizeof (int));
4916 frame_need_space (fc
, max_regs
- 1);
4920 fc
->augmentation
= (char *) start
;
4921 start
= (unsigned char *) strchr ((char *) start
, '\0') + 1;
4923 if (strcmp (fc
->augmentation
, "eh") == 0)
4924 start
+= eh_addr_size
;
4928 fc
->ptr_size
= GET (1);
4929 fc
->segment_size
= GET (1);
4930 eh_addr_size
= fc
->ptr_size
;
4934 fc
->ptr_size
= eh_addr_size
;
4935 fc
->segment_size
= 0;
4937 fc
->code_factor
= LEB ();
4938 fc
->data_factor
= SLEB ();
4948 if (fc
->augmentation
[0] == 'z')
4950 augmentation_data_len
= LEB ();
4951 augmentation_data
= start
;
4952 start
+= augmentation_data_len
;
4956 if (do_debug_frames_interp
)
4957 printf ("\n%08lx %08lx %08lx CIE \"%s\" cf=%d df=%d ra=%d\n",
4958 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
4959 fc
->augmentation
, fc
->code_factor
, fc
->data_factor
,
4963 printf ("\n%08lx %08lx %08lx CIE\n",
4964 (unsigned long)(saved_start
- section_start
), length
, cie_id
);
4965 printf (" Version: %d\n", version
);
4966 printf (" Augmentation: \"%s\"\n", fc
->augmentation
);
4969 printf (" Pointer Size: %u\n", fc
->ptr_size
);
4970 printf (" Segment Size: %u\n", fc
->segment_size
);
4972 printf (" Code alignment factor: %u\n", fc
->code_factor
);
4973 printf (" Data alignment factor: %d\n", fc
->data_factor
);
4974 printf (" Return address column: %d\n", fc
->ra
);
4976 if (augmentation_data_len
)
4979 printf (" Augmentation data: ");
4980 for (i
= 0; i
< augmentation_data_len
; ++i
)
4981 printf (" %02x", augmentation_data
[i
]);
4987 if (augmentation_data_len
)
4989 unsigned char *p
, *q
;
4990 p
= (unsigned char *) fc
->augmentation
+ 1;
4991 q
= augmentation_data
;
4998 q
+= 1 + size_of_encoded_value (*q
);
5000 fc
->fde_encoding
= *q
++;
5008 if (fc
->fde_encoding
)
5009 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
5012 frame_need_space (fc
, fc
->ra
);
5016 unsigned char *look_for
;
5017 static Frame_Chunk fde_fc
;
5018 unsigned long segment_selector
;
5021 memset (fc
, 0, sizeof (Frame_Chunk
));
5023 look_for
= is_eh
? start
- 4 - cie_id
: section_start
+ cie_id
;
5025 for (cie
= chunks
; cie
; cie
= cie
->next
)
5026 if (cie
->chunk_start
== look_for
)
5031 warn ("Invalid CIE pointer %#08lx in FDE at %#08lx\n",
5032 cie_id
, (unsigned long)(saved_start
- section_start
));
5034 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
5035 fc
->col_offset
= (int *) xmalloc (sizeof (int));
5036 frame_need_space (fc
, max_regs
- 1);
5038 fc
->augmentation
= "";
5039 fc
->fde_encoding
= 0;
5040 fc
->ptr_size
= eh_addr_size
;
5041 fc
->segment_size
= 0;
5045 fc
->ncols
= cie
->ncols
;
5046 fc
->col_type
= (short int *) xcmalloc (fc
->ncols
, sizeof (short int));
5047 fc
->col_offset
= (int *) xcmalloc (fc
->ncols
, sizeof (int));
5048 memcpy (fc
->col_type
, cie
->col_type
, fc
->ncols
* sizeof (short int));
5049 memcpy (fc
->col_offset
, cie
->col_offset
, fc
->ncols
* sizeof (int));
5050 fc
->augmentation
= cie
->augmentation
;
5051 fc
->ptr_size
= cie
->ptr_size
;
5052 eh_addr_size
= cie
->ptr_size
;
5053 fc
->segment_size
= cie
->segment_size
;
5054 fc
->code_factor
= cie
->code_factor
;
5055 fc
->data_factor
= cie
->data_factor
;
5056 fc
->cfa_reg
= cie
->cfa_reg
;
5057 fc
->cfa_offset
= cie
->cfa_offset
;
5059 frame_need_space (fc
, max_regs
- 1);
5060 fc
->fde_encoding
= cie
->fde_encoding
;
5063 if (fc
->fde_encoding
)
5064 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
5066 segment_selector
= 0;
5067 if (fc
->segment_size
)
5069 segment_selector
= byte_get (start
, fc
->segment_size
);
5070 start
+= fc
->segment_size
;
5072 fc
->pc_begin
= get_encoded_value (start
, fc
->fde_encoding
, section
);
5073 start
+= encoded_ptr_size
;
5074 fc
->pc_range
= byte_get (start
, encoded_ptr_size
);
5075 start
+= encoded_ptr_size
;
5077 if (cie
->augmentation
[0] == 'z')
5079 augmentation_data_len
= LEB ();
5080 augmentation_data
= start
;
5081 start
+= augmentation_data_len
;
5084 printf ("\n%08lx %08lx %08lx FDE cie=%08lx pc=",
5085 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
5086 (unsigned long)(cie
->chunk_start
- section_start
));
5087 if (fc
->segment_size
)
5088 printf ("%04lx:", segment_selector
);
5089 printf ("%08lx..%08lx\n", fc
->pc_begin
, fc
->pc_begin
+ fc
->pc_range
);
5090 if (! do_debug_frames_interp
&& augmentation_data_len
)
5094 printf (" Augmentation data: ");
5095 for (i
= 0; i
< augmentation_data_len
; ++i
)
5096 printf (" %02x", augmentation_data
[i
]);
5102 /* At this point, fc is the current chunk, cie (if any) is set, and
5103 we're about to interpret instructions for the chunk. */
5104 /* ??? At present we need to do this always, since this sizes the
5105 fc->col_type and fc->col_offset arrays, which we write into always.
5106 We should probably split the interpreted and non-interpreted bits
5107 into two different routines, since there's so much that doesn't
5108 really overlap between them. */
5109 if (1 || do_debug_frames_interp
)
5111 /* Start by making a pass over the chunk, allocating storage
5112 and taking note of what registers are used. */
5113 unsigned char *tmp
= start
;
5115 while (start
< block_end
)
5118 unsigned long reg
, temp
;
5125 /* Warning: if you add any more cases to this switch, be
5126 sure to add them to the corresponding switch below. */
5129 case DW_CFA_advance_loc
:
5133 if (frame_need_space (fc
, opa
) >= 0)
5134 fc
->col_type
[opa
] = DW_CFA_undefined
;
5136 case DW_CFA_restore
:
5137 if (frame_need_space (fc
, opa
) >= 0)
5138 fc
->col_type
[opa
] = DW_CFA_undefined
;
5140 case DW_CFA_set_loc
:
5141 start
+= encoded_ptr_size
;
5143 case DW_CFA_advance_loc1
:
5146 case DW_CFA_advance_loc2
:
5149 case DW_CFA_advance_loc4
:
5152 case DW_CFA_offset_extended
:
5153 case DW_CFA_val_offset
:
5154 reg
= LEB (); LEB ();
5155 if (frame_need_space (fc
, reg
) >= 0)
5156 fc
->col_type
[reg
] = DW_CFA_undefined
;
5158 case DW_CFA_restore_extended
:
5160 frame_need_space (fc
, reg
);
5161 if (frame_need_space (fc
, reg
) >= 0)
5162 fc
->col_type
[reg
] = DW_CFA_undefined
;
5164 case DW_CFA_undefined
:
5166 if (frame_need_space (fc
, reg
) >= 0)
5167 fc
->col_type
[reg
] = DW_CFA_undefined
;
5169 case DW_CFA_same_value
:
5171 if (frame_need_space (fc
, reg
) >= 0)
5172 fc
->col_type
[reg
] = DW_CFA_undefined
;
5174 case DW_CFA_register
:
5175 reg
= LEB (); LEB ();
5176 if (frame_need_space (fc
, reg
) >= 0)
5177 fc
->col_type
[reg
] = DW_CFA_undefined
;
5179 case DW_CFA_def_cfa
:
5182 case DW_CFA_def_cfa_register
:
5185 case DW_CFA_def_cfa_offset
:
5188 case DW_CFA_def_cfa_expression
:
5192 case DW_CFA_expression
:
5193 case DW_CFA_val_expression
:
5197 if (frame_need_space (fc
, reg
) >= 0)
5198 fc
->col_type
[reg
] = DW_CFA_undefined
;
5200 case DW_CFA_offset_extended_sf
:
5201 case DW_CFA_val_offset_sf
:
5202 reg
= LEB (); SLEB ();
5203 if (frame_need_space (fc
, reg
) >= 0)
5204 fc
->col_type
[reg
] = DW_CFA_undefined
;
5206 case DW_CFA_def_cfa_sf
:
5209 case DW_CFA_def_cfa_offset_sf
:
5212 case DW_CFA_MIPS_advance_loc8
:
5215 case DW_CFA_GNU_args_size
:
5218 case DW_CFA_GNU_negative_offset_extended
:
5219 reg
= LEB (); LEB ();
5220 if (frame_need_space (fc
, reg
) >= 0)
5221 fc
->col_type
[reg
] = DW_CFA_undefined
;
5230 /* Now we know what registers are used, make a second pass over
5231 the chunk, this time actually printing out the info. */
5233 while (start
< block_end
)
5236 unsigned long ul
, reg
, roffs
;
5239 const char *reg_prefix
= "";
5246 /* Warning: if you add any more cases to this switch, be
5247 sure to add them to the corresponding switch above. */
5250 case DW_CFA_advance_loc
:
5251 if (do_debug_frames_interp
)
5252 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5254 printf (" DW_CFA_advance_loc: %d to %08lx\n",
5255 opa
* fc
->code_factor
,
5256 fc
->pc_begin
+ opa
* fc
->code_factor
);
5257 fc
->pc_begin
+= opa
* fc
->code_factor
;
5262 if (opa
>= (unsigned int) fc
->ncols
)
5263 reg_prefix
= bad_reg
;
5264 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5265 printf (" DW_CFA_offset: %s%s at cfa%+ld\n",
5266 reg_prefix
, regname (opa
, 0),
5267 roffs
* fc
->data_factor
);
5268 if (*reg_prefix
== '\0')
5270 fc
->col_type
[opa
] = DW_CFA_offset
;
5271 fc
->col_offset
[opa
] = roffs
* fc
->data_factor
;
5275 case DW_CFA_restore
:
5276 if (opa
>= (unsigned int) cie
->ncols
5277 || opa
>= (unsigned int) fc
->ncols
)
5278 reg_prefix
= bad_reg
;
5279 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5280 printf (" DW_CFA_restore: %s%s\n",
5281 reg_prefix
, regname (opa
, 0));
5282 if (*reg_prefix
== '\0')
5284 fc
->col_type
[opa
] = cie
->col_type
[opa
];
5285 fc
->col_offset
[opa
] = cie
->col_offset
[opa
];
5286 if (do_debug_frames_interp
5287 && fc
->col_type
[opa
] == DW_CFA_unreferenced
)
5288 fc
->col_type
[opa
] = DW_CFA_undefined
;
5292 case DW_CFA_set_loc
:
5293 vma
= get_encoded_value (start
, fc
->fde_encoding
, section
);
5294 start
+= encoded_ptr_size
;
5295 if (do_debug_frames_interp
)
5296 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5298 printf (" DW_CFA_set_loc: %08lx\n", (unsigned long)vma
);
5302 case DW_CFA_advance_loc1
:
5303 ofs
= byte_get (start
, 1); start
+= 1;
5304 if (do_debug_frames_interp
)
5305 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5307 printf (" DW_CFA_advance_loc1: %ld to %08lx\n",
5308 ofs
* fc
->code_factor
,
5309 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5310 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5313 case DW_CFA_advance_loc2
:
5314 ofs
= byte_get (start
, 2); start
+= 2;
5315 if (do_debug_frames_interp
)
5316 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5318 printf (" DW_CFA_advance_loc2: %ld to %08lx\n",
5319 ofs
* fc
->code_factor
,
5320 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5321 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5324 case DW_CFA_advance_loc4
:
5325 ofs
= byte_get (start
, 4); start
+= 4;
5326 if (do_debug_frames_interp
)
5327 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5329 printf (" DW_CFA_advance_loc4: %ld to %08lx\n",
5330 ofs
* fc
->code_factor
,
5331 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5332 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5335 case DW_CFA_offset_extended
:
5338 if (reg
>= (unsigned int) fc
->ncols
)
5339 reg_prefix
= bad_reg
;
5340 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5341 printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n",
5342 reg_prefix
, regname (reg
, 0),
5343 roffs
* fc
->data_factor
);
5344 if (*reg_prefix
== '\0')
5346 fc
->col_type
[reg
] = DW_CFA_offset
;
5347 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
5351 case DW_CFA_val_offset
:
5354 if (reg
>= (unsigned int) fc
->ncols
)
5355 reg_prefix
= bad_reg
;
5356 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5357 printf (" DW_CFA_val_offset: %s%s at cfa%+ld\n",
5358 reg_prefix
, regname (reg
, 0),
5359 roffs
* fc
->data_factor
);
5360 if (*reg_prefix
== '\0')
5362 fc
->col_type
[reg
] = DW_CFA_val_offset
;
5363 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
5367 case DW_CFA_restore_extended
:
5369 if (reg
>= (unsigned int) cie
->ncols
5370 || reg
>= (unsigned int) fc
->ncols
)
5371 reg_prefix
= bad_reg
;
5372 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5373 printf (" DW_CFA_restore_extended: %s%s\n",
5374 reg_prefix
, regname (reg
, 0));
5375 if (*reg_prefix
== '\0')
5377 fc
->col_type
[reg
] = cie
->col_type
[reg
];
5378 fc
->col_offset
[reg
] = cie
->col_offset
[reg
];
5382 case DW_CFA_undefined
:
5384 if (reg
>= (unsigned int) fc
->ncols
)
5385 reg_prefix
= bad_reg
;
5386 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5387 printf (" DW_CFA_undefined: %s%s\n",
5388 reg_prefix
, regname (reg
, 0));
5389 if (*reg_prefix
== '\0')
5391 fc
->col_type
[reg
] = DW_CFA_undefined
;
5392 fc
->col_offset
[reg
] = 0;
5396 case DW_CFA_same_value
:
5398 if (reg
>= (unsigned int) fc
->ncols
)
5399 reg_prefix
= bad_reg
;
5400 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5401 printf (" DW_CFA_same_value: %s%s\n",
5402 reg_prefix
, regname (reg
, 0));
5403 if (*reg_prefix
== '\0')
5405 fc
->col_type
[reg
] = DW_CFA_same_value
;
5406 fc
->col_offset
[reg
] = 0;
5410 case DW_CFA_register
:
5413 if (reg
>= (unsigned int) fc
->ncols
)
5414 reg_prefix
= bad_reg
;
5415 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5417 printf (" DW_CFA_register: %s%s in ",
5418 reg_prefix
, regname (reg
, 0));
5419 puts (regname (roffs
, 0));
5421 if (*reg_prefix
== '\0')
5423 fc
->col_type
[reg
] = DW_CFA_register
;
5424 fc
->col_offset
[reg
] = roffs
;
5428 case DW_CFA_remember_state
:
5429 if (! do_debug_frames_interp
)
5430 printf (" DW_CFA_remember_state\n");
5431 rs
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
5432 rs
->ncols
= fc
->ncols
;
5433 rs
->col_type
= (short int *) xcmalloc (rs
->ncols
,
5434 sizeof (short int));
5435 rs
->col_offset
= (int *) xcmalloc (rs
->ncols
, sizeof (int));
5436 memcpy (rs
->col_type
, fc
->col_type
, rs
->ncols
);
5437 memcpy (rs
->col_offset
, fc
->col_offset
, rs
->ncols
* sizeof (int));
5438 rs
->next
= remembered_state
;
5439 remembered_state
= rs
;
5442 case DW_CFA_restore_state
:
5443 if (! do_debug_frames_interp
)
5444 printf (" DW_CFA_restore_state\n");
5445 rs
= remembered_state
;
5448 remembered_state
= rs
->next
;
5449 frame_need_space (fc
, rs
->ncols
- 1);
5450 memcpy (fc
->col_type
, rs
->col_type
, rs
->ncols
);
5451 memcpy (fc
->col_offset
, rs
->col_offset
,
5452 rs
->ncols
* sizeof (int));
5453 free (rs
->col_type
);
5454 free (rs
->col_offset
);
5457 else if (do_debug_frames_interp
)
5458 printf ("Mismatched DW_CFA_restore_state\n");
5461 case DW_CFA_def_cfa
:
5462 fc
->cfa_reg
= LEB ();
5463 fc
->cfa_offset
= LEB ();
5465 if (! do_debug_frames_interp
)
5466 printf (" DW_CFA_def_cfa: %s ofs %d\n",
5467 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
5470 case DW_CFA_def_cfa_register
:
5471 fc
->cfa_reg
= LEB ();
5473 if (! do_debug_frames_interp
)
5474 printf (" DW_CFA_def_cfa_register: %s\n",
5475 regname (fc
->cfa_reg
, 0));
5478 case DW_CFA_def_cfa_offset
:
5479 fc
->cfa_offset
= LEB ();
5480 if (! do_debug_frames_interp
)
5481 printf (" DW_CFA_def_cfa_offset: %d\n", fc
->cfa_offset
);
5485 if (! do_debug_frames_interp
)
5486 printf (" DW_CFA_nop\n");
5489 case DW_CFA_def_cfa_expression
:
5491 if (! do_debug_frames_interp
)
5493 printf (" DW_CFA_def_cfa_expression (");
5494 decode_location_expression (start
, eh_addr_size
, 0, -1,
5502 case DW_CFA_expression
:
5505 if (reg
>= (unsigned int) fc
->ncols
)
5506 reg_prefix
= bad_reg
;
5507 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5509 printf (" DW_CFA_expression: %s%s (",
5510 reg_prefix
, regname (reg
, 0));
5511 decode_location_expression (start
, eh_addr_size
, 0, -1,
5515 if (*reg_prefix
== '\0')
5516 fc
->col_type
[reg
] = DW_CFA_expression
;
5520 case DW_CFA_val_expression
:
5523 if (reg
>= (unsigned int) fc
->ncols
)
5524 reg_prefix
= bad_reg
;
5525 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5527 printf (" DW_CFA_val_expression: %s%s (",
5528 reg_prefix
, regname (reg
, 0));
5529 decode_location_expression (start
, eh_addr_size
, 0, -1,
5533 if (*reg_prefix
== '\0')
5534 fc
->col_type
[reg
] = DW_CFA_val_expression
;
5538 case DW_CFA_offset_extended_sf
:
5541 if (frame_need_space (fc
, reg
) < 0)
5542 reg_prefix
= bad_reg
;
5543 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5544 printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n",
5545 reg_prefix
, regname (reg
, 0),
5546 l
* fc
->data_factor
);
5547 if (*reg_prefix
== '\0')
5549 fc
->col_type
[reg
] = DW_CFA_offset
;
5550 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
5554 case DW_CFA_val_offset_sf
:
5557 if (frame_need_space (fc
, reg
) < 0)
5558 reg_prefix
= bad_reg
;
5559 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5560 printf (" DW_CFA_val_offset_sf: %s%s at cfa%+ld\n",
5561 reg_prefix
, regname (reg
, 0),
5562 l
* fc
->data_factor
);
5563 if (*reg_prefix
== '\0')
5565 fc
->col_type
[reg
] = DW_CFA_val_offset
;
5566 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
5570 case DW_CFA_def_cfa_sf
:
5571 fc
->cfa_reg
= LEB ();
5572 fc
->cfa_offset
= SLEB ();
5573 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
5575 if (! do_debug_frames_interp
)
5576 printf (" DW_CFA_def_cfa_sf: %s ofs %d\n",
5577 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
5580 case DW_CFA_def_cfa_offset_sf
:
5581 fc
->cfa_offset
= SLEB ();
5582 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
5583 if (! do_debug_frames_interp
)
5584 printf (" DW_CFA_def_cfa_offset_sf: %d\n", fc
->cfa_offset
);
5587 case DW_CFA_MIPS_advance_loc8
:
5588 ofs
= byte_get (start
, 8); start
+= 8;
5589 if (do_debug_frames_interp
)
5590 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5592 printf (" DW_CFA_MIPS_advance_loc8: %ld to %08lx\n",
5593 ofs
* fc
->code_factor
,
5594 fc
->pc_begin
+ ofs
* fc
->code_factor
);
5595 fc
->pc_begin
+= ofs
* fc
->code_factor
;
5598 case DW_CFA_GNU_window_save
:
5599 if (! do_debug_frames_interp
)
5600 printf (" DW_CFA_GNU_window_save\n");
5603 case DW_CFA_GNU_args_size
:
5605 if (! do_debug_frames_interp
)
5606 printf (" DW_CFA_GNU_args_size: %ld\n", ul
);
5609 case DW_CFA_GNU_negative_offset_extended
:
5612 if (frame_need_space (fc
, reg
) < 0)
5613 reg_prefix
= bad_reg
;
5614 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
5615 printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n",
5616 reg_prefix
, regname (reg
, 0),
5617 l
* fc
->data_factor
);
5618 if (*reg_prefix
== '\0')
5620 fc
->col_type
[reg
] = DW_CFA_offset
;
5621 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
5626 if (op
>= DW_CFA_lo_user
&& op
<= DW_CFA_hi_user
)
5627 printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op
);
5629 warn (_("unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op
);
5634 if (do_debug_frames_interp
)
5635 frame_display_row (fc
, &need_col_headers
, &max_regs
);
5638 eh_addr_size
= saved_eh_addr_size
;
5651 display_gdb_index (struct dwarf_section
*section
,
5652 void *file ATTRIBUTE_UNUSED
)
5654 unsigned char *start
= section
->start
;
5656 uint32_t cu_list_offset
, tu_list_offset
;
5657 uint32_t address_table_offset
, symbol_table_offset
, constant_pool_offset
;
5658 unsigned int cu_list_elements
, tu_list_elements
;
5659 unsigned int address_table_size
, symbol_table_slots
;
5660 unsigned char *cu_list
, *tu_list
;
5661 unsigned char *address_table
, *symbol_table
, *constant_pool
;
5664 /* The documentation for the format of this file is in gdb/dwarf2read.c. */
5666 printf (_("Contents of the %s section:\n"), section
->name
);
5668 if (section
->size
< 6 * sizeof (uint32_t))
5670 warn (_("Truncated header in the %s section.\n"), section
->name
);
5674 version
= byte_get_little_endian (start
, 4);
5675 printf (_("Version %ld\n"), (long) version
);
5677 /* Prior versions are obsolete, and future versions may not be
5678 backwards compatible. */
5682 warn (_("The address table data in version 3 may be wrong.\n"));
5685 warn (_("Version 4 does not support case insensitive lookups.\n"));
5688 warn (_("Version 5 does not include inlined functions.\n"));
5693 warn (_("Unsupported version %lu.\n"), (unsigned long) version
);
5697 cu_list_offset
= byte_get_little_endian (start
+ 4, 4);
5698 tu_list_offset
= byte_get_little_endian (start
+ 8, 4);
5699 address_table_offset
= byte_get_little_endian (start
+ 12, 4);
5700 symbol_table_offset
= byte_get_little_endian (start
+ 16, 4);
5701 constant_pool_offset
= byte_get_little_endian (start
+ 20, 4);
5703 if (cu_list_offset
> section
->size
5704 || tu_list_offset
> section
->size
5705 || address_table_offset
> section
->size
5706 || symbol_table_offset
> section
->size
5707 || constant_pool_offset
> section
->size
)
5709 warn (_("Corrupt header in the %s section.\n"), section
->name
);
5713 cu_list_elements
= (tu_list_offset
- cu_list_offset
) / 8;
5714 tu_list_elements
= (address_table_offset
- tu_list_offset
) / 8;
5715 address_table_size
= symbol_table_offset
- address_table_offset
;
5716 symbol_table_slots
= (constant_pool_offset
- symbol_table_offset
) / 8;
5718 cu_list
= start
+ cu_list_offset
;
5719 tu_list
= start
+ tu_list_offset
;
5720 address_table
= start
+ address_table_offset
;
5721 symbol_table
= start
+ symbol_table_offset
;
5722 constant_pool
= start
+ constant_pool_offset
;
5724 printf (_("\nCU table:\n"));
5725 for (i
= 0; i
< cu_list_elements
; i
+= 2)
5727 uint64_t cu_offset
= byte_get_little_endian (cu_list
+ i
* 8, 8);
5728 uint64_t cu_length
= byte_get_little_endian (cu_list
+ i
* 8 + 8, 8);
5730 printf (_("[%3u] 0x%lx - 0x%lx\n"), i
/ 2,
5731 (unsigned long) cu_offset
,
5732 (unsigned long) (cu_offset
+ cu_length
- 1));
5735 printf (_("\nTU table:\n"));
5736 for (i
= 0; i
< tu_list_elements
; i
+= 3)
5738 uint64_t tu_offset
= byte_get_little_endian (tu_list
+ i
* 8, 8);
5739 uint64_t type_offset
= byte_get_little_endian (tu_list
+ i
* 8 + 8, 8);
5740 uint64_t signature
= byte_get_little_endian (tu_list
+ i
* 8 + 16, 8);
5742 printf (_("[%3u] 0x%lx 0x%lx "), i
/ 3,
5743 (unsigned long) tu_offset
,
5744 (unsigned long) type_offset
);
5745 print_dwarf_vma (signature
, 8);
5749 printf (_("\nAddress table:\n"));
5750 for (i
= 0; i
< address_table_size
; i
+= 2 * 8 + 4)
5752 uint64_t low
= byte_get_little_endian (address_table
+ i
, 8);
5753 uint64_t high
= byte_get_little_endian (address_table
+ i
+ 8, 8);
5754 uint32_t cu_index
= byte_get_little_endian (address_table
+ i
+ 16, 4);
5756 print_dwarf_vma (low
, 8);
5757 print_dwarf_vma (high
, 8);
5758 printf (_("%lu\n"), (unsigned long) cu_index
);
5761 printf (_("\nSymbol table:\n"));
5762 for (i
= 0; i
< symbol_table_slots
; ++i
)
5764 uint32_t name_offset
= byte_get_little_endian (symbol_table
+ i
* 8, 4);
5765 uint32_t cu_vector_offset
= byte_get_little_endian (symbol_table
+ i
* 8 + 4, 4);
5766 uint32_t num_cus
, cu
;
5768 if (name_offset
!= 0
5769 || cu_vector_offset
!= 0)
5773 printf ("[%3u] %s:", i
, constant_pool
+ name_offset
);
5774 num_cus
= byte_get_little_endian (constant_pool
+ cu_vector_offset
, 4);
5775 for (j
= 0; j
< num_cus
; ++j
)
5777 cu
= byte_get_little_endian (constant_pool
+ cu_vector_offset
+ 4 + j
* 4, 4);
5778 /* Convert to TU number if it's for a type unit. */
5779 if (cu
>= cu_list_elements
/ 2)
5780 printf (" T%lu", (unsigned long) (cu
- cu_list_elements
/ 2));
5782 printf (" %lu", (unsigned long) cu
);
5792 display_debug_not_supported (struct dwarf_section
*section
,
5793 void *file ATTRIBUTE_UNUSED
)
5795 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
5802 cmalloc (size_t nmemb
, size_t size
)
5804 /* Check for overflow. */
5805 if (nmemb
>= ~(size_t) 0 / size
)
5808 return malloc (nmemb
* size
);
5812 xcmalloc (size_t nmemb
, size_t size
)
5814 /* Check for overflow. */
5815 if (nmemb
>= ~(size_t) 0 / size
)
5818 return xmalloc (nmemb
* size
);
5822 xcrealloc (void *ptr
, size_t nmemb
, size_t size
)
5824 /* Check for overflow. */
5825 if (nmemb
>= ~(size_t) 0 / size
)
5828 return xrealloc (ptr
, nmemb
* size
);
5832 free_debug_memory (void)
5838 for (i
= 0; i
< max
; i
++)
5839 free_debug_section ((enum dwarf_section_display_enum
) i
);
5841 if (debug_information
!= NULL
)
5843 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
)
5845 for (i
= 0; i
< num_debug_info_entries
; i
++)
5847 if (!debug_information
[i
].max_loc_offsets
)
5849 free (debug_information
[i
].loc_offsets
);
5850 free (debug_information
[i
].have_frame_base
);
5852 if (!debug_information
[i
].max_range_lists
)
5853 free (debug_information
[i
].range_lists
);
5857 free (debug_information
);
5858 debug_information
= NULL
;
5859 num_debug_info_entries
= 0;
5864 dwarf_select_sections_by_names (const char *names
)
5868 const char * option
;
5872 debug_dump_long_opts
;
5874 static const debug_dump_long_opts opts_table
[] =
5876 /* Please keep this table alpha- sorted. */
5877 { "Ranges", & do_debug_ranges
, 1 },
5878 { "abbrev", & do_debug_abbrevs
, 1 },
5879 { "aranges", & do_debug_aranges
, 1 },
5880 { "frames", & do_debug_frames
, 1 },
5881 { "frames-interp", & do_debug_frames_interp
, 1 },
5882 { "info", & do_debug_info
, 1 },
5883 { "line", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
}, /* For backwards compatibility. */
5884 { "rawline", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
},
5885 { "decodedline", & do_debug_lines
, FLAG_DEBUG_LINES_DECODED
},
5886 { "loc", & do_debug_loc
, 1 },
5887 { "macro", & do_debug_macinfo
, 1 },
5888 { "pubnames", & do_debug_pubnames
, 1 },
5889 { "pubtypes", & do_debug_pubtypes
, 1 },
5890 /* This entry is for compatability
5891 with earlier versions of readelf. */
5892 { "ranges", & do_debug_aranges
, 1 },
5893 { "str", & do_debug_str
, 1 },
5894 /* The special .gdb_index section. */
5895 { "gdb_index", & do_gdb_index
, 1 },
5896 /* These trace_* sections are used by Itanium VMS. */
5897 { "trace_abbrev", & do_trace_abbrevs
, 1 },
5898 { "trace_aranges", & do_trace_aranges
, 1 },
5899 { "trace_info", & do_trace_info
, 1 },
5908 const debug_dump_long_opts
* entry
;
5910 for (entry
= opts_table
; entry
->option
; entry
++)
5912 size_t len
= strlen (entry
->option
);
5914 if (strncmp (p
, entry
->option
, len
) == 0
5915 && (p
[len
] == ',' || p
[len
] == '\0'))
5917 * entry
->variable
|= entry
->val
;
5919 /* The --debug-dump=frames-interp option also
5920 enables the --debug-dump=frames option. */
5921 if (do_debug_frames_interp
)
5922 do_debug_frames
= 1;
5929 if (entry
->option
== NULL
)
5931 warn (_("Unrecognized debug option '%s'\n"), p
);
5932 p
= strchr (p
, ',');
5943 dwarf_select_sections_by_letters (const char *letters
)
5945 unsigned int lindex
= 0;
5947 while (letters
[lindex
])
5948 switch (letters
[lindex
++])
5955 do_debug_abbrevs
= 1;
5959 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
5963 do_debug_lines
|= FLAG_DEBUG_LINES_DECODED
;
5967 do_debug_pubnames
= 1;
5971 do_debug_pubtypes
= 1;
5975 do_debug_aranges
= 1;
5979 do_debug_ranges
= 1;
5983 do_debug_frames_interp
= 1;
5985 do_debug_frames
= 1;
5989 do_debug_macinfo
= 1;
6001 warn (_("Unrecognized debug option '%s'\n"), optarg
);
6007 dwarf_select_sections_all (void)
6010 do_debug_abbrevs
= 1;
6011 do_debug_lines
= FLAG_DEBUG_LINES_RAW
;
6012 do_debug_pubnames
= 1;
6013 do_debug_pubtypes
= 1;
6014 do_debug_aranges
= 1;
6015 do_debug_ranges
= 1;
6016 do_debug_frames
= 1;
6017 do_debug_macinfo
= 1;
6022 do_trace_abbrevs
= 1;
6023 do_trace_aranges
= 1;
6026 struct dwarf_section_display debug_displays
[] =
6028 { { ".debug_abbrev", ".zdebug_abbrev", NULL
, NULL
, 0, 0, abbrev
},
6029 display_debug_abbrev
, &do_debug_abbrevs
, 0 },
6030 { { ".debug_aranges", ".zdebug_aranges", NULL
, NULL
, 0, 0, abbrev
},
6031 display_debug_aranges
, &do_debug_aranges
, 1 },
6032 { { ".debug_frame", ".zdebug_frame", NULL
, NULL
, 0, 0, abbrev
},
6033 display_debug_frames
, &do_debug_frames
, 1 },
6034 { { ".debug_info", ".zdebug_info", NULL
, NULL
, 0, 0, abbrev
},
6035 display_debug_info
, &do_debug_info
, 1 },
6036 { { ".debug_line", ".zdebug_line", NULL
, NULL
, 0, 0, abbrev
},
6037 display_debug_lines
, &do_debug_lines
, 1 },
6038 { { ".debug_pubnames", ".zdebug_pubnames", NULL
, NULL
, 0, 0, abbrev
},
6039 display_debug_pubnames
, &do_debug_pubnames
, 0 },
6040 { { ".eh_frame", "", NULL
, NULL
, 0, 0, abbrev
},
6041 display_debug_frames
, &do_debug_frames
, 1 },
6042 { { ".debug_macinfo", ".zdebug_macinfo", NULL
, NULL
, 0, 0, abbrev
},
6043 display_debug_macinfo
, &do_debug_macinfo
, 0 },
6044 { { ".debug_macro", ".zdebug_macro", NULL
, NULL
, 0, 0, abbrev
},
6045 display_debug_macro
, &do_debug_macinfo
, 1 },
6046 { { ".debug_str", ".zdebug_str", NULL
, NULL
, 0, 0, abbrev
},
6047 display_debug_str
, &do_debug_str
, 0 },
6048 { { ".debug_loc", ".zdebug_loc", NULL
, NULL
, 0, 0, abbrev
},
6049 display_debug_loc
, &do_debug_loc
, 1 },
6050 { { ".debug_pubtypes", ".zdebug_pubtypes", NULL
, NULL
, 0, 0, abbrev
},
6051 display_debug_pubnames
, &do_debug_pubtypes
, 0 },
6052 { { ".debug_ranges", ".zdebug_ranges", NULL
, NULL
, 0, 0, abbrev
},
6053 display_debug_ranges
, &do_debug_ranges
, 1 },
6054 { { ".debug_static_func", ".zdebug_static_func", NULL
, NULL
, 0, 0, abbrev
},
6055 display_debug_not_supported
, NULL
, 0 },
6056 { { ".debug_static_vars", ".zdebug_static_vars", NULL
, NULL
, 0, 0, abbrev
},
6057 display_debug_not_supported
, NULL
, 0 },
6058 { { ".debug_types", ".zdebug_types", NULL
, NULL
, 0, 0, abbrev
},
6059 display_debug_types
, &do_debug_info
, 1 },
6060 { { ".debug_weaknames", ".zdebug_weaknames", NULL
, NULL
, 0, 0, abbrev
},
6061 display_debug_not_supported
, NULL
, 0 },
6062 { { ".gdb_index", "", NULL
, NULL
, 0, 0, abbrev
},
6063 display_gdb_index
, &do_gdb_index
, 0 },
6064 { { ".trace_info", "", NULL
, NULL
, 0, 0, trace_abbrev
},
6065 display_trace_info
, &do_trace_info
, 1 },
6066 { { ".trace_abbrev", "", NULL
, NULL
, 0, 0, abbrev
},
6067 display_debug_abbrev
, &do_trace_abbrevs
, 0 },
6068 { { ".trace_aranges", "", NULL
, NULL
, 0, 0, abbrev
},
6069 display_debug_aranges
, &do_trace_aranges
, 0 },
6070 { { ".debug_info.dwo", ".zdebug_info.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6071 display_debug_info
, &do_debug_info
, 1 },
6072 { { ".debug_abbrev.dwo", ".zdebug_abbrev.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6073 display_debug_abbrev
, &do_debug_abbrevs
, 0 },
6074 { { ".debug_types.dwo", ".zdebug_types.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6075 display_debug_types
, &do_debug_info
, 1 },
6076 { { ".debug_line.dwo", ".zdebug_line.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6077 display_debug_lines
, &do_debug_lines
, 1 },
6078 { { ".debug_loc.dwo", ".zdebug_loc.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
},
6079 display_debug_loc
, &do_debug_loc
, 1 },
6080 { { ".debug_macro.dwo", ".zdebug_macro.dwo",NULL
, NULL
, 0, 0, abbrev
},
6081 display_debug_macro
, &do_debug_macinfo
, 1 },
6082 { { ".debug_macinfo.dwo", ".zdebug_macinfo.dwo",NULL
, NULL
, 0, 0, abbrev
},
6083 display_debug_macinfo
, &do_debug_macinfo
, 0 },
6084 { { ".debug_str.dwo", ".zdebug_str.dwo", NULL
, NULL
, 0, 0, str_dwo
},
6085 display_debug_str
, &do_debug_str
, 1 },
6086 { { ".debug_str_offsets",".zdebug_str_offsets", NULL
, NULL
, 0, 0, abbrev
},
6087 display_debug_str_offsets
, NULL
, 0 },
6088 { { ".debug_str_offsets.dwo",".zdebug_str_offsets.dwo", NULL
, NULL
, 0, 0,
6090 display_debug_str_offsets
, NULL
, 0 },
6091 { { ".debug_addr",".zdebug_addr", NULL
, NULL
, 0, 0, debug_addr
},
6092 display_debug_addr
, NULL
, 1 },