1 /* dwarf.c -- display DWARF contents of a BFD binary file
2 Copyright (C) 2005-2015 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
22 #include "libiberty.h"
24 #include "bfd_stdint.h"
27 #include "elf/common.h"
30 #include "gdb/gdb-index.h"
32 static const char *regname (unsigned int regno
, int row
);
34 static int have_frame_base
;
35 static int need_base_address
;
37 static unsigned int last_pointer_size
= 0;
38 static int warned_about_missing_comp_units
= FALSE
;
40 static unsigned int num_debug_info_entries
= 0;
41 static unsigned int alloc_num_debug_info_entries
= 0;
42 static debug_info
*debug_information
= NULL
;
43 /* Special value for num_debug_info_entries to indicate
44 that the .debug_info section could not be loaded/parsed. */
45 #define DEBUG_INFO_UNAVAILABLE (unsigned int) -1
52 int do_debug_pubnames
;
53 int do_debug_pubtypes
;
57 int do_debug_frames_interp
;
66 int do_debug_cu_index
;
69 int dwarf_cutoff_level
= -1;
70 unsigned long dwarf_start_die
;
74 /* Collection of CU/TU section sets from .debug_cu_index and .debug_tu_index
75 sections. For version 1 package files, each set is stored in SHNDX_POOL
76 as a zero-terminated list of section indexes comprising one set of debug
77 sections from a .dwo file. */
79 static int cu_tu_indexes_read
= 0;
80 static unsigned int *shndx_pool
= NULL
;
81 static unsigned int shndx_pool_size
= 0;
82 static unsigned int shndx_pool_used
= 0;
84 /* For version 2 package files, each set contains an array of section offsets
85 and an array of section sizes, giving the offset and size of the
86 contribution from a CU or TU within one of the debug sections.
87 When displaying debug info from a package file, we need to use these
88 tables to locate the corresponding contributions to each section. */
93 dwarf_vma section_offsets
[DW_SECT_MAX
];
94 size_t section_sizes
[DW_SECT_MAX
];
97 static int cu_count
= 0;
98 static int tu_count
= 0;
99 static struct cu_tu_set
*cu_sets
= NULL
;
100 static struct cu_tu_set
*tu_sets
= NULL
;
102 static void load_cu_tu_indexes (void *file
);
104 /* Values for do_debug_lines. */
105 #define FLAG_DEBUG_LINES_RAW 1
106 #define FLAG_DEBUG_LINES_DECODED 2
109 size_of_encoded_value (int encoding
)
111 switch (encoding
& 0x7)
114 case 0: return eh_addr_size
;
122 get_encoded_value (unsigned char **pdata
,
124 struct dwarf_section
*section
,
127 unsigned char * data
= * pdata
;
128 unsigned int size
= size_of_encoded_value (encoding
);
131 if (data
+ size
>= end
)
133 warn (_("Encoded value extends past end of section\n"));
138 /* PR 17512: file: 002-829853-0.004. */
141 warn (_("Encoded size of %d is too large to read\n"), size
);
146 /* PR 17512: file: 1085-5603-0.004. */
149 warn (_("Encoded size of 0 is too small to read\n"));
154 if (encoding
& DW_EH_PE_signed
)
155 val
= byte_get_signed (data
, size
);
157 val
= byte_get (data
, size
);
159 if ((encoding
& 0x70) == DW_EH_PE_pcrel
)
160 val
+= section
->address
+ (data
- section
->start
);
162 * pdata
= data
+ size
;
166 #if defined HAVE_LONG_LONG && SIZEOF_LONG_LONG > SIZEOF_LONG
168 # define DWARF_VMA_FMT "ll"
169 # define DWARF_VMA_FMT_LONG "%16.16llx"
171 # define DWARF_VMA_FMT "I64"
172 # define DWARF_VMA_FMT_LONG "%016I64x"
175 # define DWARF_VMA_FMT "l"
176 # define DWARF_VMA_FMT_LONG "%16.16lx"
179 /* Convert a dwarf vma value into a string. Returns a pointer to a static
180 buffer containing the converted VALUE. The value is converted according
181 to the printf formating character FMTCH. If NUM_BYTES is non-zero then
182 it specifies the maximum number of bytes to be displayed in the converted
183 value and FMTCH is ignored - hex is always used. */
186 dwarf_vmatoa_1 (const char *fmtch
, dwarf_vma value
, unsigned num_bytes
)
188 /* As dwarf_vmatoa is used more then once in a printf call
189 for output, we are cycling through an fixed array of pointers
190 for return address. */
191 static int buf_pos
= 0;
192 static struct dwarf_vmatoa_buf
198 ret
= buf
[buf_pos
++].place
;
199 buf_pos
%= ARRAY_SIZE (buf
);
203 /* Printf does not have a way of specifiying a maximum field width for an
204 integer value, so we print the full value into a buffer and then select
205 the precision we need. */
206 snprintf (ret
, sizeof (buf
[0].place
), DWARF_VMA_FMT_LONG
, value
);
209 return ret
+ (16 - 2 * num_bytes
);
215 sprintf (fmt
, "%%%s%s", DWARF_VMA_FMT
, fmtch
);
216 snprintf (ret
, sizeof (buf
[0].place
), fmt
, value
);
221 static inline const char *
222 dwarf_vmatoa (const char * fmtch
, dwarf_vma value
)
224 return dwarf_vmatoa_1 (fmtch
, value
, 0);
227 /* Print a dwarf_vma value (typically an address, offset or length) in
228 hexadecimal format, followed by a space. The length of the VALUE (and
229 hence the precision displayed) is determined by the NUM_BYTES parameter. */
232 print_dwarf_vma (dwarf_vma value
, unsigned num_bytes
)
234 printf ("%s ", dwarf_vmatoa_1 (NULL
, value
, num_bytes
));
237 /* Format a 64-bit value, given as two 32-bit values, in hex.
238 For reentrancy, this uses a buffer provided by the caller. */
241 dwarf_vmatoa64 (dwarf_vma hvalue
, dwarf_vma lvalue
, char *buf
,
242 unsigned int buf_len
)
247 snprintf (buf
, buf_len
, "%" DWARF_VMA_FMT
"x", lvalue
);
250 len
= snprintf (buf
, buf_len
, "%" DWARF_VMA_FMT
"x", hvalue
);
251 snprintf (buf
+ len
, buf_len
- len
,
252 "%08" DWARF_VMA_FMT
"x", lvalue
);
258 /* Read in a LEB128 encoded value starting at address DATA.
259 If SIGN is true, return a signed LEB128 value.
260 If LENGTH_RETURN is not NULL, return in it the number of bytes read.
261 No bytes will be read at address END or beyond. */
264 read_leb128 (unsigned char *data
,
265 unsigned int *length_return
,
267 const unsigned char * const end
)
269 dwarf_vma result
= 0;
270 unsigned int num_read
= 0;
271 unsigned int shift
= 0;
272 unsigned char byte
= 0;
279 result
|= ((dwarf_vma
) (byte
& 0x7f)) << shift
;
282 if ((byte
& 0x80) == 0)
286 if (length_return
!= NULL
)
287 *length_return
= num_read
;
289 if (sign
&& (shift
< 8 * sizeof (result
)) && (byte
& 0x40))
290 result
|= (dwarf_vma
) -1 << shift
;
295 /* Create a signed version to avoid painful typecasts. */
296 static inline dwarf_signed_vma
297 read_sleb128 (unsigned char * data
,
298 unsigned int * length_return
,
299 const unsigned char * const end
)
301 return (dwarf_signed_vma
) read_leb128 (data
, length_return
, TRUE
, end
);
304 static inline dwarf_vma
305 read_uleb128 (unsigned char * data
,
306 unsigned int * length_return
,
307 const unsigned char * const end
)
309 return read_leb128 (data
, length_return
, FALSE
, end
);
312 #define SAFE_BYTE_GET(VAL, PTR, AMOUNT, END) \
315 int dummy [sizeof (VAL) < (AMOUNT) ? -1 : 1] ATTRIBUTE_UNUSED ; \
316 unsigned int amount = (AMOUNT); \
317 if (((PTR) + amount) >= (END)) \
320 amount = (END) - (PTR); \
324 if (amount == 0 || amount > 8) \
327 VAL = byte_get ((PTR), amount); \
331 #define SAFE_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \
334 SAFE_BYTE_GET (VAL, PTR, AMOUNT, END); \
339 #define SAFE_SIGNED_BYTE_GET(VAL, PTR, AMOUNT, END) \
342 unsigned int amount = (AMOUNT); \
343 if (((PTR) + amount) >= (END)) \
346 amount = (END) - (PTR); \
351 VAL = byte_get_signed ((PTR), amount); \
357 #define SAFE_SIGNED_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \
360 SAFE_SIGNED_BYTE_GET (VAL, PTR, AMOUNT, END); \
365 #define SAFE_BYTE_GET64(PTR, HIGH, LOW, END) \
368 if (((PTR) + 8) <= (END)) \
370 byte_get_64 ((PTR), (HIGH), (LOW)); \
374 * (LOW) = * (HIGH) = 0; \
379 typedef struct State_Machine_Registers
387 unsigned char op_index
;
388 unsigned char end_sequence
;
389 /* This variable hold the number of the last entry seen
390 in the File Table. */
391 unsigned int last_file_entry
;
394 static SMR state_machine_regs
;
397 reset_state_machine (int is_stmt
)
399 state_machine_regs
.address
= 0;
400 state_machine_regs
.op_index
= 0;
401 state_machine_regs
.file
= 1;
402 state_machine_regs
.line
= 1;
403 state_machine_regs
.column
= 0;
404 state_machine_regs
.is_stmt
= is_stmt
;
405 state_machine_regs
.basic_block
= 0;
406 state_machine_regs
.end_sequence
= 0;
407 state_machine_regs
.last_file_entry
= 0;
410 /* Handled an extend line op.
411 Returns the number of bytes read. */
414 process_extended_line_op (unsigned char * data
,
418 unsigned char op_code
;
419 unsigned int bytes_read
;
422 unsigned char *orig_data
= data
;
425 len
= read_uleb128 (data
, & bytes_read
, end
);
428 if (len
== 0 || data
== end
|| len
> (uintptr_t) (end
- data
))
430 warn (_("Badly formed extended line op encountered!\n"));
437 printf (_(" Extended opcode %d: "), op_code
);
441 case DW_LNE_end_sequence
:
442 printf (_("End of Sequence\n\n"));
443 reset_state_machine (is_stmt
);
446 case DW_LNE_set_address
:
447 /* PR 17512: file: 002-100480-0.004. */
448 if (len
- bytes_read
- 1 > 8)
449 warn (_("Length (%d) of DW_LNE_set_address op is too long\n"),
450 len
- bytes_read
- 1);
451 SAFE_BYTE_GET (adr
, data
, len
- bytes_read
- 1, end
);
452 printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr
));
453 state_machine_regs
.address
= adr
;
454 state_machine_regs
.op_index
= 0;
457 case DW_LNE_define_file
:
458 printf (_("define new File Table entry\n"));
459 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
460 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
463 data
+= strnlen ((char *) data
, end
- data
) + 1;
464 printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
466 printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
468 printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
470 printf ("%s\n\n", name
);
472 if (((unsigned int) (data
- orig_data
) != len
) || data
== end
)
473 warn (_("DW_LNE_define_file: Bad opcode length\n"));
476 case DW_LNE_set_discriminator
:
477 printf (_("set Discriminator to %s\n"),
478 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
482 case DW_LNE_HP_negate_is_UV_update
:
483 printf ("DW_LNE_HP_negate_is_UV_update\n");
485 case DW_LNE_HP_push_context
:
486 printf ("DW_LNE_HP_push_context\n");
488 case DW_LNE_HP_pop_context
:
489 printf ("DW_LNE_HP_pop_context\n");
491 case DW_LNE_HP_set_file_line_column
:
492 printf ("DW_LNE_HP_set_file_line_column\n");
494 case DW_LNE_HP_set_routine_name
:
495 printf ("DW_LNE_HP_set_routine_name\n");
497 case DW_LNE_HP_set_sequence
:
498 printf ("DW_LNE_HP_set_sequence\n");
500 case DW_LNE_HP_negate_post_semantics
:
501 printf ("DW_LNE_HP_negate_post_semantics\n");
503 case DW_LNE_HP_negate_function_exit
:
504 printf ("DW_LNE_HP_negate_function_exit\n");
506 case DW_LNE_HP_negate_front_end_logical
:
507 printf ("DW_LNE_HP_negate_front_end_logical\n");
509 case DW_LNE_HP_define_proc
:
510 printf ("DW_LNE_HP_define_proc\n");
512 case DW_LNE_HP_source_file_correlation
:
514 unsigned char *edata
= data
+ len
- bytes_read
- 1;
516 printf ("DW_LNE_HP_source_file_correlation\n");
522 opc
= read_uleb128 (data
, & bytes_read
, edata
);
527 case DW_LNE_HP_SFC_formfeed
:
528 printf (" DW_LNE_HP_SFC_formfeed\n");
530 case DW_LNE_HP_SFC_set_listing_line
:
531 printf (" DW_LNE_HP_SFC_set_listing_line (%s)\n",
533 read_uleb128 (data
, & bytes_read
, edata
)));
536 case DW_LNE_HP_SFC_associate
:
537 printf (" DW_LNE_HP_SFC_associate ");
540 read_uleb128 (data
, & bytes_read
, edata
)));
544 read_uleb128 (data
, & bytes_read
, edata
)));
548 read_uleb128 (data
, & bytes_read
, edata
)));
552 printf (_(" UNKNOWN DW_LNE_HP_SFC opcode (%u)\n"), opc
);
562 unsigned int rlen
= len
- bytes_read
- 1;
564 if (op_code
>= DW_LNE_lo_user
565 /* The test against DW_LNW_hi_user is redundant due to
566 the limited range of the unsigned char data type used
568 /*&& op_code <= DW_LNE_hi_user*/)
569 printf (_("user defined: "));
571 printf (_("UNKNOWN: "));
572 printf (_("length %d ["), rlen
);
574 printf (" %02x", *data
++);
583 static const unsigned char *
584 fetch_indirect_string (dwarf_vma offset
)
586 struct dwarf_section
*section
= &debug_displays
[str
].section
;
588 if (section
->start
== NULL
)
589 return (const unsigned char *) _("<no .debug_str section>");
591 if (offset
> section
->size
)
593 warn (_("DW_FORM_strp offset too big: %s\n"),
594 dwarf_vmatoa ("x", offset
));
595 return (const unsigned char *) _("<offset is too big>");
598 return (const unsigned char *) section
->start
+ offset
;
602 fetch_indexed_string (dwarf_vma idx
, struct cu_tu_set
*this_set
,
603 dwarf_vma offset_size
, int dwo
)
605 enum dwarf_section_display_enum str_sec_idx
= dwo
? str_dwo
: str
;
606 enum dwarf_section_display_enum idx_sec_idx
= dwo
? str_index_dwo
: str_index
;
607 struct dwarf_section
*index_section
= &debug_displays
[idx_sec_idx
].section
;
608 struct dwarf_section
*str_section
= &debug_displays
[str_sec_idx
].section
;
609 dwarf_vma index_offset
= idx
* offset_size
;
610 dwarf_vma str_offset
;
612 if (index_section
->start
== NULL
)
613 return (dwo
? _("<no .debug_str_offsets.dwo section>")
614 : _("<no .debug_str_offsets section>"));
616 if (this_set
!= NULL
)
617 index_offset
+= this_set
->section_offsets
[DW_SECT_STR_OFFSETS
];
618 if (index_offset
> index_section
->size
)
620 warn (_("DW_FORM_GNU_str_index offset too big: %s\n"),
621 dwarf_vmatoa ("x", index_offset
));
622 return _("<index offset is too big>");
625 if (str_section
->start
== NULL
)
626 return (dwo
? _("<no .debug_str.dwo section>")
627 : _("<no .debug_str section>"));
629 str_offset
= byte_get (index_section
->start
+ index_offset
, offset_size
);
630 str_offset
-= str_section
->address
;
631 if (str_offset
> str_section
->size
)
633 warn (_("DW_FORM_GNU_str_index indirect offset too big: %s\n"),
634 dwarf_vmatoa ("x", str_offset
));
635 return _("<indirect index offset is too big>");
638 return (const char *) str_section
->start
+ str_offset
;
642 fetch_indexed_value (dwarf_vma offset
, dwarf_vma bytes
)
644 struct dwarf_section
*section
= &debug_displays
[debug_addr
].section
;
646 if (section
->start
== NULL
)
647 return (_("<no .debug_addr section>"));
649 if (offset
+ bytes
> section
->size
)
651 warn (_("Offset into section %s too big: %s\n"),
652 section
->name
, dwarf_vmatoa ("x", offset
));
653 return "<offset too big>";
656 return dwarf_vmatoa ("x", byte_get (section
->start
+ offset
, bytes
));
660 /* FIXME: There are better and more efficient ways to handle
661 these structures. For now though, I just want something that
662 is simple to implement. */
663 typedef struct abbrev_attr
665 unsigned long attribute
;
667 struct abbrev_attr
*next
;
671 typedef struct abbrev_entry
676 struct abbrev_attr
*first_attr
;
677 struct abbrev_attr
*last_attr
;
678 struct abbrev_entry
*next
;
682 static abbrev_entry
*first_abbrev
= NULL
;
683 static abbrev_entry
*last_abbrev
= NULL
;
690 for (abbrv
= first_abbrev
; abbrv
;)
692 abbrev_entry
*next_abbrev
= abbrv
->next
;
695 for (attr
= abbrv
->first_attr
; attr
;)
697 abbrev_attr
*next_attr
= attr
->next
;
707 last_abbrev
= first_abbrev
= NULL
;
711 add_abbrev (unsigned long number
, unsigned long tag
, int children
)
715 entry
= (abbrev_entry
*) malloc (sizeof (*entry
));
720 entry
->entry
= number
;
722 entry
->children
= children
;
723 entry
->first_attr
= NULL
;
724 entry
->last_attr
= NULL
;
727 if (first_abbrev
== NULL
)
728 first_abbrev
= entry
;
730 last_abbrev
->next
= entry
;
736 add_abbrev_attr (unsigned long attribute
, unsigned long form
)
740 attr
= (abbrev_attr
*) malloc (sizeof (*attr
));
745 attr
->attribute
= attribute
;
749 if (last_abbrev
->first_attr
== NULL
)
750 last_abbrev
->first_attr
= attr
;
752 last_abbrev
->last_attr
->next
= attr
;
754 last_abbrev
->last_attr
= attr
;
757 /* Processes the (partial) contents of a .debug_abbrev section.
758 Returns NULL if the end of the section was encountered.
759 Returns the address after the last byte read if the end of
760 an abbreviation set was found. */
762 static unsigned char *
763 process_abbrev_section (unsigned char *start
, unsigned char *end
)
765 if (first_abbrev
!= NULL
)
770 unsigned int bytes_read
;
773 unsigned long attribute
;
776 entry
= read_uleb128 (start
, & bytes_read
, end
);
779 /* A single zero is supposed to end the section according
780 to the standard. If there's more, then signal that to
787 tag
= read_uleb128 (start
, & bytes_read
, end
);
794 add_abbrev (entry
, tag
, children
);
800 attribute
= read_uleb128 (start
, & bytes_read
, end
);
805 form
= read_uleb128 (start
, & bytes_read
, end
);
810 add_abbrev_attr (attribute
, form
);
812 while (attribute
!= 0);
815 /* Report the missing single zero which ends the section. */
816 error (_(".debug_abbrev section not zero terminated\n"));
822 get_TAG_name (unsigned long tag
)
824 const char *name
= get_DW_TAG_name ((unsigned int)tag
);
828 static char buffer
[100];
830 snprintf (buffer
, sizeof (buffer
), _("Unknown TAG value: %lx"), tag
);
838 get_FORM_name (unsigned long form
)
843 return "DW_FORM value: 0";
845 name
= get_DW_FORM_name (form
);
848 static char buffer
[100];
850 snprintf (buffer
, sizeof (buffer
), _("Unknown FORM value: %lx"), form
);
857 static unsigned char *
858 display_block (unsigned char *data
,
860 const unsigned char * const end
)
864 printf (_(" %s byte block: "), dwarf_vmatoa ("u", length
));
866 return (unsigned char *) end
;
868 maxlen
= (dwarf_vma
) (end
- data
);
869 length
= length
> maxlen
? maxlen
: length
;
872 printf ("%lx ", (unsigned long) byte_get (data
++, 1));
878 decode_location_expression (unsigned char * data
,
879 unsigned int pointer_size
,
880 unsigned int offset_size
,
884 struct dwarf_section
* section
)
887 unsigned int bytes_read
;
889 dwarf_signed_vma svalue
;
890 unsigned char *end
= data
+ length
;
891 int need_frame_base
= 0;
900 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
901 printf ("DW_OP_addr: %s", dwarf_vmatoa ("x", uvalue
));
904 printf ("DW_OP_deref");
907 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
908 printf ("DW_OP_const1u: %lu", (unsigned long) uvalue
);
911 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 1, end
);
912 printf ("DW_OP_const1s: %ld", (long) svalue
);
915 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 2, end
);
916 printf ("DW_OP_const2u: %lu", (unsigned long) uvalue
);
919 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
920 printf ("DW_OP_const2s: %ld", (long) svalue
);
923 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
924 printf ("DW_OP_const4u: %lu", (unsigned long) uvalue
);
927 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
928 printf ("DW_OP_const4s: %ld", (long) svalue
);
931 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
932 printf ("DW_OP_const8u: %lu ", (unsigned long) uvalue
);
933 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
934 printf ("%lu", (unsigned long) uvalue
);
937 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
938 printf ("DW_OP_const8s: %ld ", (long) svalue
);
939 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
940 printf ("%ld", (long) svalue
);
943 printf ("DW_OP_constu: %s",
944 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
948 printf ("DW_OP_consts: %s",
949 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
953 printf ("DW_OP_dup");
956 printf ("DW_OP_drop");
959 printf ("DW_OP_over");
962 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
963 printf ("DW_OP_pick: %ld", (unsigned long) uvalue
);
966 printf ("DW_OP_swap");
969 printf ("DW_OP_rot");
972 printf ("DW_OP_xderef");
975 printf ("DW_OP_abs");
978 printf ("DW_OP_and");
981 printf ("DW_OP_div");
984 printf ("DW_OP_minus");
987 printf ("DW_OP_mod");
990 printf ("DW_OP_mul");
993 printf ("DW_OP_neg");
996 printf ("DW_OP_not");
1002 printf ("DW_OP_plus");
1004 case DW_OP_plus_uconst
:
1005 printf ("DW_OP_plus_uconst: %s",
1006 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1010 printf ("DW_OP_shl");
1013 printf ("DW_OP_shr");
1016 printf ("DW_OP_shra");
1019 printf ("DW_OP_xor");
1022 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
1023 printf ("DW_OP_bra: %ld", (long) svalue
);
1026 printf ("DW_OP_eq");
1029 printf ("DW_OP_ge");
1032 printf ("DW_OP_gt");
1035 printf ("DW_OP_le");
1038 printf ("DW_OP_lt");
1041 printf ("DW_OP_ne");
1044 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
1045 printf ("DW_OP_skip: %ld", (long) svalue
);
1080 printf ("DW_OP_lit%d", op
- DW_OP_lit0
);
1115 printf ("DW_OP_reg%d (%s)", op
- DW_OP_reg0
,
1116 regname (op
- DW_OP_reg0
, 1));
1151 printf ("DW_OP_breg%d (%s): %s",
1153 regname (op
- DW_OP_breg0
, 1),
1154 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
1159 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1161 printf ("DW_OP_regx: %s (%s)",
1162 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1));
1165 need_frame_base
= 1;
1166 printf ("DW_OP_fbreg: %s",
1167 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
1171 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1173 printf ("DW_OP_bregx: %s (%s) %s",
1174 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1),
1175 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
1179 printf ("DW_OP_piece: %s",
1180 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1183 case DW_OP_deref_size
:
1184 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1185 printf ("DW_OP_deref_size: %ld", (long) uvalue
);
1187 case DW_OP_xderef_size
:
1188 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1189 printf ("DW_OP_xderef_size: %ld", (long) uvalue
);
1192 printf ("DW_OP_nop");
1195 /* DWARF 3 extensions. */
1196 case DW_OP_push_object_address
:
1197 printf ("DW_OP_push_object_address");
1200 /* XXX: Strictly speaking for 64-bit DWARF3 files
1201 this ought to be an 8-byte wide computation. */
1202 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
1203 printf ("DW_OP_call2: <0x%s>",
1204 dwarf_vmatoa ("x", svalue
+ cu_offset
));
1207 /* XXX: Strictly speaking for 64-bit DWARF3 files
1208 this ought to be an 8-byte wide computation. */
1209 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
1210 printf ("DW_OP_call4: <0x%s>",
1211 dwarf_vmatoa ("x", svalue
+ cu_offset
));
1213 case DW_OP_call_ref
:
1214 /* XXX: Strictly speaking for 64-bit DWARF3 files
1215 this ought to be an 8-byte wide computation. */
1216 if (dwarf_version
== -1)
1218 printf (_("(DW_OP_call_ref in frame info)"));
1219 /* No way to tell where the next op is, so just bail. */
1220 return need_frame_base
;
1222 if (dwarf_version
== 2)
1224 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1228 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1230 printf ("DW_OP_call_ref: <0x%s>", dwarf_vmatoa ("x", uvalue
));
1232 case DW_OP_form_tls_address
:
1233 printf ("DW_OP_form_tls_address");
1235 case DW_OP_call_frame_cfa
:
1236 printf ("DW_OP_call_frame_cfa");
1238 case DW_OP_bit_piece
:
1239 printf ("DW_OP_bit_piece: ");
1240 printf (_("size: %s "),
1241 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1243 printf (_("offset: %s "),
1244 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1248 /* DWARF 4 extensions. */
1249 case DW_OP_stack_value
:
1250 printf ("DW_OP_stack_value");
1253 case DW_OP_implicit_value
:
1254 printf ("DW_OP_implicit_value");
1255 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1257 data
= display_block (data
, uvalue
, end
);
1260 /* GNU extensions. */
1261 case DW_OP_GNU_push_tls_address
:
1262 printf (_("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown"));
1264 case DW_OP_GNU_uninit
:
1265 printf ("DW_OP_GNU_uninit");
1266 /* FIXME: Is there data associated with this OP ? */
1268 case DW_OP_GNU_encoded_addr
:
1275 addr
= get_encoded_value (&data
, encoding
, section
, end
);
1277 printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding
);
1278 print_dwarf_vma (addr
, pointer_size
);
1281 case DW_OP_GNU_implicit_pointer
:
1282 /* XXX: Strictly speaking for 64-bit DWARF3 files
1283 this ought to be an 8-byte wide computation. */
1284 if (dwarf_version
== -1)
1286 printf (_("(DW_OP_GNU_implicit_pointer in frame info)"));
1287 /* No way to tell where the next op is, so just bail. */
1288 return need_frame_base
;
1290 if (dwarf_version
== 2)
1292 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1296 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1298 printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s",
1299 dwarf_vmatoa ("x", uvalue
),
1300 dwarf_vmatoa ("d", read_sleb128 (data
,
1301 &bytes_read
, end
)));
1304 case DW_OP_GNU_entry_value
:
1305 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1307 /* PR 17531: file: 0cc9cd00. */
1308 if (uvalue
> (dwarf_vma
) (end
- data
))
1309 uvalue
= end
- data
;
1310 printf ("DW_OP_GNU_entry_value: (");
1311 if (decode_location_expression (data
, pointer_size
, offset_size
,
1312 dwarf_version
, uvalue
,
1313 cu_offset
, section
))
1314 need_frame_base
= 1;
1320 case DW_OP_GNU_const_type
:
1321 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1323 printf ("DW_OP_GNU_const_type: <0x%s> ",
1324 dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1325 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1326 data
= display_block (data
, uvalue
, end
);
1328 case DW_OP_GNU_regval_type
:
1329 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1331 printf ("DW_OP_GNU_regval_type: %s (%s)",
1332 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1));
1333 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1335 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1337 case DW_OP_GNU_deref_type
:
1338 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1339 printf ("DW_OP_GNU_deref_type: %ld", (long) uvalue
);
1340 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1342 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1344 case DW_OP_GNU_convert
:
1345 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1347 printf ("DW_OP_GNU_convert <0x%s>",
1348 dwarf_vmatoa ("x", uvalue
? cu_offset
+ uvalue
: 0));
1350 case DW_OP_GNU_reinterpret
:
1351 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1353 printf ("DW_OP_GNU_reinterpret <0x%s>",
1354 dwarf_vmatoa ("x", uvalue
? cu_offset
+ uvalue
: 0));
1356 case DW_OP_GNU_parameter_ref
:
1357 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
1358 printf ("DW_OP_GNU_parameter_ref: <0x%s>",
1359 dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1361 case DW_OP_GNU_addr_index
:
1362 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1364 printf ("DW_OP_GNU_addr_index <0x%s>", dwarf_vmatoa ("x", uvalue
));
1366 case DW_OP_GNU_const_index
:
1367 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1369 printf ("DW_OP_GNU_const_index <0x%s>", dwarf_vmatoa ("x", uvalue
));
1372 /* HP extensions. */
1373 case DW_OP_HP_is_value
:
1374 printf ("DW_OP_HP_is_value");
1375 /* FIXME: Is there data associated with this OP ? */
1377 case DW_OP_HP_fltconst4
:
1378 printf ("DW_OP_HP_fltconst4");
1379 /* FIXME: Is there data associated with this OP ? */
1381 case DW_OP_HP_fltconst8
:
1382 printf ("DW_OP_HP_fltconst8");
1383 /* FIXME: Is there data associated with this OP ? */
1385 case DW_OP_HP_mod_range
:
1386 printf ("DW_OP_HP_mod_range");
1387 /* FIXME: Is there data associated with this OP ? */
1389 case DW_OP_HP_unmod_range
:
1390 printf ("DW_OP_HP_unmod_range");
1391 /* FIXME: Is there data associated with this OP ? */
1394 printf ("DW_OP_HP_tls");
1395 /* FIXME: Is there data associated with this OP ? */
1398 /* PGI (STMicroelectronics) extensions. */
1399 case DW_OP_PGI_omp_thread_num
:
1400 /* Pushes the thread number for the current thread as it would be
1401 returned by the standard OpenMP library function:
1402 omp_get_thread_num(). The "current thread" is the thread for
1403 which the expression is being evaluated. */
1404 printf ("DW_OP_PGI_omp_thread_num");
1408 if (op
>= DW_OP_lo_user
1409 && op
<= DW_OP_hi_user
)
1410 printf (_("(User defined location op)"));
1412 printf (_("(Unknown location op)"));
1413 /* No way to tell where the next op is, so just bail. */
1414 return need_frame_base
;
1417 /* Separate the ops. */
1422 return need_frame_base
;
1425 /* Find the CU or TU set corresponding to the given CU_OFFSET.
1426 This is used for DWARF package files. */
1428 static struct cu_tu_set
*
1429 find_cu_tu_set_v2 (dwarf_vma cu_offset
, int do_types
)
1431 struct cu_tu_set
*p
;
1433 unsigned int dw_sect
;
1439 dw_sect
= DW_SECT_TYPES
;
1445 dw_sect
= DW_SECT_INFO
;
1449 if (p
->section_offsets
[dw_sect
] == cu_offset
)
1457 /* Add INC to HIGH_BITS:LOW_BITS. */
1459 add64 (dwarf_vma
* high_bits
, dwarf_vma
* low_bits
, dwarf_vma inc
)
1461 dwarf_vma tmp
= * low_bits
;
1465 /* FIXME: There is probably a better way of handling this:
1467 We need to cope with dwarf_vma being a 32-bit or 64-bit
1468 type. Plus regardless of its size LOW_BITS is meant to
1469 only hold 32-bits, so if there is overflow or wrap around
1470 we must propagate into HIGH_BITS. */
1471 if (tmp
< * low_bits
)
1475 else if (sizeof (tmp
) > 8
1485 static unsigned char *
1486 read_and_display_attr_value (unsigned long attribute
,
1488 unsigned char * data
,
1489 unsigned char * end
,
1490 dwarf_vma cu_offset
,
1491 dwarf_vma pointer_size
,
1492 dwarf_vma offset_size
,
1494 debug_info
* debug_info_p
,
1496 struct dwarf_section
* section
,
1497 struct cu_tu_set
* this_set
)
1499 dwarf_vma uvalue
= 0;
1500 unsigned char *block_start
= NULL
;
1501 unsigned char * orig_data
= data
;
1502 unsigned int bytes_read
;
1504 if (data
> end
|| (data
== end
&& form
!= DW_FORM_flag_present
))
1506 warn (_("Corrupt attribute\n"));
1515 case DW_FORM_ref_addr
:
1516 if (dwarf_version
== 2)
1517 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1518 else if (dwarf_version
== 3 || dwarf_version
== 4)
1519 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1521 error (_("Internal error: DWARF version is not 2, 3 or 4.\n"));
1526 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1530 case DW_FORM_sec_offset
:
1531 case DW_FORM_GNU_ref_alt
:
1532 case DW_FORM_GNU_strp_alt
:
1533 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1536 case DW_FORM_flag_present
:
1543 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1548 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 2, end
);
1553 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
1557 uvalue
= read_sleb128 (data
, & bytes_read
, end
);
1561 case DW_FORM_GNU_str_index
:
1562 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
1566 case DW_FORM_ref_udata
:
1568 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
1572 case DW_FORM_indirect
:
1573 form
= read_uleb128 (data
, & bytes_read
, end
);
1576 printf (" %s", get_FORM_name (form
));
1577 return read_and_display_attr_value (attribute
, form
, data
, end
,
1578 cu_offset
, pointer_size
,
1579 offset_size
, dwarf_version
,
1580 debug_info_p
, do_loc
,
1582 case DW_FORM_GNU_addr_index
:
1583 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
1590 case DW_FORM_ref_addr
:
1592 printf (" <0x%s>", dwarf_vmatoa ("x",uvalue
));
1595 case DW_FORM_GNU_ref_alt
:
1597 printf (" <alt 0x%s>", dwarf_vmatoa ("x",uvalue
));
1603 case DW_FORM_ref_udata
:
1605 printf (" <0x%s>", dwarf_vmatoa ("x", uvalue
+ cu_offset
));
1610 case DW_FORM_sec_offset
:
1612 printf (" 0x%s", dwarf_vmatoa ("x", uvalue
));
1615 case DW_FORM_flag_present
:
1622 printf (" %s", dwarf_vmatoa ("d", uvalue
));
1629 dwarf_vma high_bits
;
1633 SAFE_BYTE_GET64 (data
, &high_bits
, &uvalue
, end
);
1635 if (form
== DW_FORM_ref8
)
1636 add64 (& high_bits
, & utmp
, cu_offset
);
1638 dwarf_vmatoa64 (high_bits
, utmp
, buf
, sizeof (buf
)));
1641 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1642 && num_debug_info_entries
== 0)
1644 if (sizeof (uvalue
) == 8)
1645 SAFE_BYTE_GET (uvalue
, data
, 8, end
);
1647 error (_("DW_FORM_data8 is unsupported when sizeof (dwarf_vma) != 8\n"));
1653 case DW_FORM_string
:
1655 printf (" %.*s", (int) (end
- data
), data
);
1656 data
+= strnlen ((char *) data
, end
- data
) + 1;
1660 case DW_FORM_exprloc
:
1661 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
1662 block_start
= data
+ bytes_read
;
1663 if (block_start
>= end
)
1665 warn (_("Block ends prematurely\n"));
1669 /* PR 17512: file: 008-103549-0.001:0.1. */
1670 if (block_start
+ uvalue
> end
)
1672 warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue
);
1673 uvalue
= end
- block_start
;
1676 data
= block_start
+ uvalue
;
1678 data
= display_block (block_start
, uvalue
, end
);
1681 case DW_FORM_block1
:
1682 SAFE_BYTE_GET (uvalue
, data
, 1, end
);
1683 block_start
= data
+ 1;
1684 if (block_start
>= end
)
1686 warn (_("Block ends prematurely\n"));
1690 if (block_start
+ uvalue
> end
)
1692 warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue
);
1693 uvalue
= end
- block_start
;
1696 data
= block_start
+ uvalue
;
1698 data
= display_block (block_start
, uvalue
, end
);
1701 case DW_FORM_block2
:
1702 SAFE_BYTE_GET (uvalue
, data
, 2, end
);
1703 block_start
= data
+ 2;
1704 if (block_start
>= end
)
1706 warn (_("Block ends prematurely\n"));
1710 if (block_start
+ uvalue
> end
)
1712 warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue
);
1713 uvalue
= end
- block_start
;
1716 data
= block_start
+ uvalue
;
1718 data
= display_block (block_start
, uvalue
, end
);
1721 case DW_FORM_block4
:
1722 SAFE_BYTE_GET (uvalue
, data
, 4, end
);
1723 block_start
= data
+ 4;
1724 /* PR 17512: file: 3371-3907-0.004. */
1725 if (block_start
>= end
)
1727 warn (_("Block ends prematurely\n"));
1731 if (block_start
+ uvalue
> end
)
1733 warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue
);
1734 uvalue
= end
- block_start
;
1737 data
= block_start
+ uvalue
;
1739 data
= display_block (block_start
, uvalue
, end
);
1744 printf (_(" (indirect string, offset: 0x%s): %s"),
1745 dwarf_vmatoa ("x", uvalue
),
1746 fetch_indirect_string (uvalue
));
1749 case DW_FORM_GNU_str_index
:
1752 const char *suffix
= strrchr (section
->name
, '.');
1753 int dwo
= (suffix
&& strcmp (suffix
, ".dwo") == 0) ? 1 : 0;
1755 printf (_(" (indexed string: 0x%s): %s"),
1756 dwarf_vmatoa ("x", uvalue
),
1757 fetch_indexed_string (uvalue
, this_set
, offset_size
, dwo
));
1761 case DW_FORM_GNU_strp_alt
:
1763 printf (_(" (alt indirect string, offset: 0x%s)"),
1764 dwarf_vmatoa ("x", uvalue
));
1767 case DW_FORM_indirect
:
1768 /* Handled above. */
1771 case DW_FORM_ref_sig8
:
1774 dwarf_vma high_bits
;
1777 SAFE_BYTE_GET64 (data
, &high_bits
, &uvalue
, end
);
1778 printf (" signature: 0x%s",
1779 dwarf_vmatoa64 (high_bits
, uvalue
, buf
, sizeof (buf
)));
1784 case DW_FORM_GNU_addr_index
:
1786 printf (_(" (addr_index: 0x%s): %s"),
1787 dwarf_vmatoa ("x", uvalue
),
1788 fetch_indexed_value (uvalue
* pointer_size
, pointer_size
));
1792 warn (_("Unrecognized form: %lu\n"), form
);
1796 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1797 && num_debug_info_entries
== 0
1798 && debug_info_p
!= NULL
)
1802 case DW_AT_frame_base
:
1803 have_frame_base
= 1;
1804 case DW_AT_location
:
1805 case DW_AT_string_length
:
1806 case DW_AT_return_addr
:
1807 case DW_AT_data_member_location
:
1808 case DW_AT_vtable_elem_location
:
1810 case DW_AT_static_link
:
1811 case DW_AT_use_location
:
1812 case DW_AT_GNU_call_site_value
:
1813 case DW_AT_GNU_call_site_data_value
:
1814 case DW_AT_GNU_call_site_target
:
1815 case DW_AT_GNU_call_site_target_clobbered
:
1816 if ((dwarf_version
< 4
1817 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
1818 || form
== DW_FORM_sec_offset
)
1820 /* Process location list. */
1821 unsigned int lmax
= debug_info_p
->max_loc_offsets
;
1822 unsigned int num
= debug_info_p
->num_loc_offsets
;
1824 if (lmax
== 0 || num
>= lmax
)
1827 debug_info_p
->loc_offsets
= (dwarf_vma
*)
1828 xcrealloc (debug_info_p
->loc_offsets
,
1829 lmax
, sizeof (*debug_info_p
->loc_offsets
));
1830 debug_info_p
->have_frame_base
= (int *)
1831 xcrealloc (debug_info_p
->have_frame_base
,
1832 lmax
, sizeof (*debug_info_p
->have_frame_base
));
1833 debug_info_p
->max_loc_offsets
= lmax
;
1835 if (this_set
!= NULL
)
1836 uvalue
+= this_set
->section_offsets
[DW_SECT_LOC
];
1837 debug_info_p
->loc_offsets
[num
] = uvalue
;
1838 debug_info_p
->have_frame_base
[num
] = have_frame_base
;
1839 debug_info_p
->num_loc_offsets
++;
1844 if (need_base_address
)
1845 debug_info_p
->base_address
= uvalue
;
1848 case DW_AT_GNU_addr_base
:
1849 debug_info_p
->addr_base
= uvalue
;
1852 case DW_AT_GNU_ranges_base
:
1853 debug_info_p
->ranges_base
= uvalue
;
1857 if ((dwarf_version
< 4
1858 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
1859 || form
== DW_FORM_sec_offset
)
1861 /* Process range list. */
1862 unsigned int lmax
= debug_info_p
->max_range_lists
;
1863 unsigned int num
= debug_info_p
->num_range_lists
;
1865 if (lmax
== 0 || num
>= lmax
)
1868 debug_info_p
->range_lists
= (dwarf_vma
*)
1869 xcrealloc (debug_info_p
->range_lists
,
1870 lmax
, sizeof (*debug_info_p
->range_lists
));
1871 debug_info_p
->max_range_lists
= lmax
;
1873 debug_info_p
->range_lists
[num
] = uvalue
;
1874 debug_info_p
->num_range_lists
++;
1883 if (do_loc
|| attribute
== 0)
1886 /* For some attributes we can display further information. */
1893 case DW_INL_not_inlined
:
1894 printf (_("(not inlined)"));
1896 case DW_INL_inlined
:
1897 printf (_("(inlined)"));
1899 case DW_INL_declared_not_inlined
:
1900 printf (_("(declared as inline but ignored)"));
1902 case DW_INL_declared_inlined
:
1903 printf (_("(declared as inline and inlined)"));
1906 printf (_(" (Unknown inline attribute value: %s)"),
1907 dwarf_vmatoa ("x", uvalue
));
1912 case DW_AT_language
:
1916 /* Ordered by the numeric value of these constants. */
1917 case DW_LANG_C89
: printf ("(ANSI C)"); break;
1918 case DW_LANG_C
: printf ("(non-ANSI C)"); break;
1919 case DW_LANG_Ada83
: printf ("(Ada)"); break;
1920 case DW_LANG_C_plus_plus
: printf ("(C++)"); break;
1921 case DW_LANG_Cobol74
: printf ("(Cobol 74)"); break;
1922 case DW_LANG_Cobol85
: printf ("(Cobol 85)"); break;
1923 case DW_LANG_Fortran77
: printf ("(FORTRAN 77)"); break;
1924 case DW_LANG_Fortran90
: printf ("(Fortran 90)"); break;
1925 case DW_LANG_Pascal83
: printf ("(ANSI Pascal)"); break;
1926 case DW_LANG_Modula2
: printf ("(Modula 2)"); break;
1927 /* DWARF 2.1 values. */
1928 case DW_LANG_Java
: printf ("(Java)"); break;
1929 case DW_LANG_C99
: printf ("(ANSI C99)"); break;
1930 case DW_LANG_Ada95
: printf ("(ADA 95)"); break;
1931 case DW_LANG_Fortran95
: printf ("(Fortran 95)"); break;
1932 /* DWARF 3 values. */
1933 case DW_LANG_PLI
: printf ("(PLI)"); break;
1934 case DW_LANG_ObjC
: printf ("(Objective C)"); break;
1935 case DW_LANG_ObjC_plus_plus
: printf ("(Objective C++)"); break;
1936 case DW_LANG_UPC
: printf ("(Unified Parallel C)"); break;
1937 case DW_LANG_D
: printf ("(D)"); break;
1938 /* DWARF 4 values. */
1939 case DW_LANG_Python
: printf ("(Python)"); break;
1940 /* DWARF 5 values. */
1941 case DW_LANG_Go
: printf ("(Go)"); break;
1942 case DW_LANG_C_plus_plus_11
: printf ("(C++11)"); break;
1943 case DW_LANG_C11
: printf ("(C11)"); break;
1944 case DW_LANG_C_plus_plus_14
: printf ("(C++14)"); break;
1945 /* MIPS extension. */
1946 case DW_LANG_Mips_Assembler
: printf ("(MIPS assembler)"); break;
1947 /* UPC extension. */
1948 case DW_LANG_Upc
: printf ("(Unified Parallel C)"); break;
1950 if (uvalue
>= DW_LANG_lo_user
&& uvalue
<= DW_LANG_hi_user
)
1951 printf (_("(implementation defined: %s)"),
1952 dwarf_vmatoa ("x", uvalue
));
1954 printf (_("(Unknown: %s)"), dwarf_vmatoa ("x", uvalue
));
1959 case DW_AT_encoding
:
1963 case DW_ATE_void
: printf ("(void)"); break;
1964 case DW_ATE_address
: printf ("(machine address)"); break;
1965 case DW_ATE_boolean
: printf ("(boolean)"); break;
1966 case DW_ATE_complex_float
: printf ("(complex float)"); break;
1967 case DW_ATE_float
: printf ("(float)"); break;
1968 case DW_ATE_signed
: printf ("(signed)"); break;
1969 case DW_ATE_signed_char
: printf ("(signed char)"); break;
1970 case DW_ATE_unsigned
: printf ("(unsigned)"); break;
1971 case DW_ATE_unsigned_char
: printf ("(unsigned char)"); break;
1972 /* DWARF 2.1 values: */
1973 case DW_ATE_imaginary_float
: printf ("(imaginary float)"); break;
1974 case DW_ATE_decimal_float
: printf ("(decimal float)"); break;
1975 /* DWARF 3 values: */
1976 case DW_ATE_packed_decimal
: printf ("(packed_decimal)"); break;
1977 case DW_ATE_numeric_string
: printf ("(numeric_string)"); break;
1978 case DW_ATE_edited
: printf ("(edited)"); break;
1979 case DW_ATE_signed_fixed
: printf ("(signed_fixed)"); break;
1980 case DW_ATE_unsigned_fixed
: printf ("(unsigned_fixed)"); break;
1981 /* HP extensions: */
1982 case DW_ATE_HP_float80
: printf ("(HP_float80)"); break;
1983 case DW_ATE_HP_complex_float80
: printf ("(HP_complex_float80)"); break;
1984 case DW_ATE_HP_float128
: printf ("(HP_float128)"); break;
1985 case DW_ATE_HP_complex_float128
:printf ("(HP_complex_float128)"); break;
1986 case DW_ATE_HP_floathpintel
: printf ("(HP_floathpintel)"); break;
1987 case DW_ATE_HP_imaginary_float80
: printf ("(HP_imaginary_float80)"); break;
1988 case DW_ATE_HP_imaginary_float128
: printf ("(HP_imaginary_float128)"); break;
1991 if (uvalue
>= DW_ATE_lo_user
1992 && uvalue
<= DW_ATE_hi_user
)
1993 printf (_("(user defined type)"));
1995 printf (_("(unknown type)"));
2000 case DW_AT_accessibility
:
2004 case DW_ACCESS_public
: printf ("(public)"); break;
2005 case DW_ACCESS_protected
: printf ("(protected)"); break;
2006 case DW_ACCESS_private
: printf ("(private)"); break;
2008 printf (_("(unknown accessibility)"));
2013 case DW_AT_visibility
:
2017 case DW_VIS_local
: printf ("(local)"); break;
2018 case DW_VIS_exported
: printf ("(exported)"); break;
2019 case DW_VIS_qualified
: printf ("(qualified)"); break;
2020 default: printf (_("(unknown visibility)")); break;
2024 case DW_AT_virtuality
:
2028 case DW_VIRTUALITY_none
: printf ("(none)"); break;
2029 case DW_VIRTUALITY_virtual
: printf ("(virtual)"); break;
2030 case DW_VIRTUALITY_pure_virtual
:printf ("(pure_virtual)"); break;
2031 default: printf (_("(unknown virtuality)")); break;
2035 case DW_AT_identifier_case
:
2039 case DW_ID_case_sensitive
: printf ("(case_sensitive)"); break;
2040 case DW_ID_up_case
: printf ("(up_case)"); break;
2041 case DW_ID_down_case
: printf ("(down_case)"); break;
2042 case DW_ID_case_insensitive
: printf ("(case_insensitive)"); break;
2043 default: printf (_("(unknown case)")); break;
2047 case DW_AT_calling_convention
:
2051 case DW_CC_normal
: printf ("(normal)"); break;
2052 case DW_CC_program
: printf ("(program)"); break;
2053 case DW_CC_nocall
: printf ("(nocall)"); break;
2055 if (uvalue
>= DW_CC_lo_user
2056 && uvalue
<= DW_CC_hi_user
)
2057 printf (_("(user defined)"));
2059 printf (_("(unknown convention)"));
2063 case DW_AT_ordering
:
2067 case -1: printf (_("(undefined)")); break;
2068 case 0: printf ("(row major)"); break;
2069 case 1: printf ("(column major)"); break;
2073 case DW_AT_frame_base
:
2074 have_frame_base
= 1;
2075 case DW_AT_location
:
2076 case DW_AT_string_length
:
2077 case DW_AT_return_addr
:
2078 case DW_AT_data_member_location
:
2079 case DW_AT_vtable_elem_location
:
2081 case DW_AT_static_link
:
2082 case DW_AT_use_location
:
2083 case DW_AT_GNU_call_site_value
:
2084 case DW_AT_GNU_call_site_data_value
:
2085 case DW_AT_GNU_call_site_target
:
2086 case DW_AT_GNU_call_site_target_clobbered
:
2087 if ((dwarf_version
< 4
2088 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
2089 || form
== DW_FORM_sec_offset
)
2090 printf (_(" (location list)"));
2092 case DW_AT_allocated
:
2093 case DW_AT_associated
:
2094 case DW_AT_data_location
:
2096 case DW_AT_upper_bound
:
2097 case DW_AT_lower_bound
:
2100 int need_frame_base
;
2103 need_frame_base
= decode_location_expression (block_start
,
2108 cu_offset
, section
);
2110 if (need_frame_base
&& !have_frame_base
)
2111 printf (_(" [without DW_AT_frame_base]"));
2117 if (form
== DW_FORM_ref_sig8
2118 || form
== DW_FORM_GNU_ref_alt
)
2121 if (form
== DW_FORM_ref1
2122 || form
== DW_FORM_ref2
2123 || form
== DW_FORM_ref4
2124 || form
== DW_FORM_ref_udata
)
2125 uvalue
+= cu_offset
;
2127 if (uvalue
>= section
->size
)
2128 warn (_("Offset %s used as value for DW_AT_import attribute of DIE at offset %lx is too big.\n"),
2129 dwarf_vmatoa ("x", uvalue
),
2130 (unsigned long) (orig_data
- section
->start
));
2133 unsigned long abbrev_number
;
2134 abbrev_entry
* entry
;
2136 abbrev_number
= read_uleb128 (section
->start
+ uvalue
, NULL
, end
);
2138 printf (_("\t[Abbrev Number: %ld"), abbrev_number
);
2139 /* Don't look up abbrev for DW_FORM_ref_addr, as it very often will
2140 use different abbrev table, and we don't track .debug_info chunks
2142 if (form
!= DW_FORM_ref_addr
)
2144 for (entry
= first_abbrev
; entry
!= NULL
; entry
= entry
->next
)
2145 if (entry
->entry
== abbrev_number
)
2148 printf (" (%s)", get_TAG_name (entry
->tag
));
2163 get_AT_name (unsigned long attribute
)
2168 return "DW_AT value: 0";
2170 /* One value is shared by the MIPS and HP extensions: */
2171 if (attribute
== DW_AT_MIPS_fde
)
2172 return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable";
2174 name
= get_DW_AT_name (attribute
);
2178 static char buffer
[100];
2180 snprintf (buffer
, sizeof (buffer
), _("Unknown AT value: %lx"),
2188 static unsigned char *
2189 read_and_display_attr (unsigned long attribute
,
2191 unsigned char * data
,
2192 unsigned char * end
,
2193 dwarf_vma cu_offset
,
2194 dwarf_vma pointer_size
,
2195 dwarf_vma offset_size
,
2197 debug_info
* debug_info_p
,
2199 struct dwarf_section
* section
,
2200 struct cu_tu_set
* this_set
)
2203 printf (" %-18s:", get_AT_name (attribute
));
2204 data
= read_and_display_attr_value (attribute
, form
, data
, end
,
2205 cu_offset
, pointer_size
, offset_size
,
2206 dwarf_version
, debug_info_p
,
2207 do_loc
, section
, this_set
);
2213 /* Process the contents of a .debug_info section. If do_loc is non-zero
2214 then we are scanning for location lists and we do not want to display
2215 anything to the user. If do_types is non-zero, we are processing
2216 a .debug_types section instead of a .debug_info section. */
2219 process_debug_info (struct dwarf_section
*section
,
2221 enum dwarf_section_display_enum abbrev_sec
,
2225 unsigned char *start
= section
->start
;
2226 unsigned char *end
= start
+ section
->size
;
2227 unsigned char *section_begin
;
2229 unsigned int num_units
= 0;
2231 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2232 && num_debug_info_entries
== 0
2237 /* First scan the section to get the number of comp units. */
2238 for (section_begin
= start
, num_units
= 0; section_begin
< end
;
2241 /* Read the first 4 bytes. For a 32-bit DWARF section, this
2242 will be the length. For a 64-bit DWARF section, it'll be
2243 the escape code 0xffffffff followed by an 8 byte length. */
2244 SAFE_BYTE_GET (length
, section_begin
, 4, end
);
2246 if (length
== 0xffffffff)
2248 SAFE_BYTE_GET (length
, section_begin
+ 4, 8, end
);
2249 section_begin
+= length
+ 12;
2251 else if (length
>= 0xfffffff0 && length
< 0xffffffff)
2253 warn (_("Reserved length value (0x%s) found in section %s\n"),
2254 dwarf_vmatoa ("x", length
), section
->name
);
2258 section_begin
+= length
+ 4;
2260 /* Negative values are illegal, they may even cause infinite
2261 looping. This can happen if we can't accurately apply
2262 relocations to an object file. */
2263 if ((signed long) length
<= 0)
2265 warn (_("Corrupt unit length (0x%s) found in section %s\n"),
2266 dwarf_vmatoa ("x", length
), section
->name
);
2273 error (_("No comp units in %s section ?\n"), section
->name
);
2277 /* Then allocate an array to hold the information. */
2278 debug_information
= (debug_info
*) cmalloc (num_units
,
2279 sizeof (* debug_information
));
2280 if (debug_information
== NULL
)
2282 error (_("Not enough memory for a debug info array of %u entries\n"),
2284 alloc_num_debug_info_entries
= num_debug_info_entries
= 0;
2287 alloc_num_debug_info_entries
= num_units
;
2292 if (dwarf_start_die
== 0)
2293 printf (_("Contents of the %s section:\n\n"), section
->name
);
2295 load_debug_section (str
, file
);
2296 load_debug_section (str_dwo
, file
);
2297 load_debug_section (str_index
, file
);
2298 load_debug_section (str_index_dwo
, file
);
2299 load_debug_section (debug_addr
, file
);
2302 load_debug_section (abbrev_sec
, file
);
2303 if (debug_displays
[abbrev_sec
].section
.start
== NULL
)
2305 warn (_("Unable to locate %s section!\n"),
2306 debug_displays
[abbrev_sec
].section
.name
);
2310 for (section_begin
= start
, unit
= 0; start
< end
; unit
++)
2312 DWARF2_Internal_CompUnit compunit
;
2313 unsigned char *hdrptr
;
2314 unsigned char *tags
;
2315 int level
, last_level
, saved_level
;
2316 dwarf_vma cu_offset
;
2317 unsigned int offset_size
;
2318 int initial_length_size
;
2319 dwarf_vma signature_high
= 0;
2320 dwarf_vma signature_low
= 0;
2321 dwarf_vma type_offset
= 0;
2322 struct cu_tu_set
*this_set
;
2323 dwarf_vma abbrev_base
;
2328 SAFE_BYTE_GET_AND_INC (compunit
.cu_length
, hdrptr
, 4, end
);
2330 if (compunit
.cu_length
== 0xffffffff)
2332 SAFE_BYTE_GET_AND_INC (compunit
.cu_length
, hdrptr
, 8, end
);
2334 initial_length_size
= 12;
2339 initial_length_size
= 4;
2342 SAFE_BYTE_GET_AND_INC (compunit
.cu_version
, hdrptr
, 2, end
);
2344 cu_offset
= start
- section_begin
;
2346 this_set
= find_cu_tu_set_v2 (cu_offset
, do_types
);
2348 SAFE_BYTE_GET_AND_INC (compunit
.cu_abbrev_offset
, hdrptr
, offset_size
, end
);
2350 if (this_set
== NULL
)
2353 abbrev_size
= debug_displays
[abbrev_sec
].section
.size
;
2357 abbrev_base
= this_set
->section_offsets
[DW_SECT_ABBREV
];
2358 abbrev_size
= this_set
->section_sizes
[DW_SECT_ABBREV
];
2361 SAFE_BYTE_GET_AND_INC (compunit
.cu_pointer_size
, hdrptr
, 1, end
);
2362 /* PR 17512: file: 001-108546-0.001:0.1. */
2363 if (compunit
.cu_pointer_size
< 2 || compunit
.cu_pointer_size
> 8)
2365 warn (_("Invalid pointer size (%d) in compunit header, using %d instead\n"),
2366 compunit
.cu_pointer_size
, offset_size
);
2367 compunit
.cu_pointer_size
= offset_size
;
2372 SAFE_BYTE_GET64 (hdrptr
, &signature_high
, &signature_low
, end
);
2374 SAFE_BYTE_GET_AND_INC (type_offset
, hdrptr
, offset_size
, end
);
2377 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2378 && num_debug_info_entries
== 0
2381 debug_information
[unit
].cu_offset
= cu_offset
;
2382 debug_information
[unit
].pointer_size
2383 = compunit
.cu_pointer_size
;
2384 debug_information
[unit
].offset_size
= offset_size
;
2385 debug_information
[unit
].dwarf_version
= compunit
.cu_version
;
2386 debug_information
[unit
].base_address
= 0;
2387 debug_information
[unit
].addr_base
= DEBUG_INFO_UNAVAILABLE
;
2388 debug_information
[unit
].ranges_base
= DEBUG_INFO_UNAVAILABLE
;
2389 debug_information
[unit
].loc_offsets
= NULL
;
2390 debug_information
[unit
].have_frame_base
= NULL
;
2391 debug_information
[unit
].max_loc_offsets
= 0;
2392 debug_information
[unit
].num_loc_offsets
= 0;
2393 debug_information
[unit
].range_lists
= NULL
;
2394 debug_information
[unit
].max_range_lists
= 0;
2395 debug_information
[unit
].num_range_lists
= 0;
2398 if (!do_loc
&& dwarf_start_die
== 0)
2400 printf (_(" Compilation Unit @ offset 0x%s:\n"),
2401 dwarf_vmatoa ("x", cu_offset
));
2402 printf (_(" Length: 0x%s (%s)\n"),
2403 dwarf_vmatoa ("x", compunit
.cu_length
),
2404 offset_size
== 8 ? "64-bit" : "32-bit");
2405 printf (_(" Version: %d\n"), compunit
.cu_version
);
2406 printf (_(" Abbrev Offset: 0x%s\n"),
2407 dwarf_vmatoa ("x", compunit
.cu_abbrev_offset
));
2408 printf (_(" Pointer Size: %d\n"), compunit
.cu_pointer_size
);
2413 printf (_(" Signature: 0x%s\n"),
2414 dwarf_vmatoa64 (signature_high
, signature_low
,
2415 buf
, sizeof (buf
)));
2416 printf (_(" Type Offset: 0x%s\n"),
2417 dwarf_vmatoa ("x", type_offset
));
2419 if (this_set
!= NULL
)
2421 dwarf_vma
*offsets
= this_set
->section_offsets
;
2422 size_t *sizes
= this_set
->section_sizes
;
2424 printf (_(" Section contributions:\n"));
2425 printf (_(" .debug_abbrev.dwo: 0x%s 0x%s\n"),
2426 dwarf_vmatoa ("x", offsets
[DW_SECT_ABBREV
]),
2427 dwarf_vmatoa ("x", sizes
[DW_SECT_ABBREV
]));
2428 printf (_(" .debug_line.dwo: 0x%s 0x%s\n"),
2429 dwarf_vmatoa ("x", offsets
[DW_SECT_LINE
]),
2430 dwarf_vmatoa ("x", sizes
[DW_SECT_LINE
]));
2431 printf (_(" .debug_loc.dwo: 0x%s 0x%s\n"),
2432 dwarf_vmatoa ("x", offsets
[DW_SECT_LOC
]),
2433 dwarf_vmatoa ("x", sizes
[DW_SECT_LOC
]));
2434 printf (_(" .debug_str_offsets.dwo: 0x%s 0x%s\n"),
2435 dwarf_vmatoa ("x", offsets
[DW_SECT_STR_OFFSETS
]),
2436 dwarf_vmatoa ("x", sizes
[DW_SECT_STR_OFFSETS
]));
2440 if (cu_offset
+ compunit
.cu_length
+ initial_length_size
2443 warn (_("Debug info is corrupted, length of CU at %s"
2444 " extends beyond end of section (length = %s)\n"),
2445 dwarf_vmatoa ("x", cu_offset
),
2446 dwarf_vmatoa ("x", compunit
.cu_length
));
2450 start
+= compunit
.cu_length
+ initial_length_size
;
2452 if (compunit
.cu_version
!= 2
2453 && compunit
.cu_version
!= 3
2454 && compunit
.cu_version
!= 4)
2456 warn (_("CU at offset %s contains corrupt or "
2457 "unsupported version number: %d.\n"),
2458 dwarf_vmatoa ("x", cu_offset
), compunit
.cu_version
);
2464 /* Process the abbrevs used by this compilation unit. */
2465 if (compunit
.cu_abbrev_offset
>= abbrev_size
)
2466 warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"),
2467 (unsigned long) compunit
.cu_abbrev_offset
,
2468 (unsigned long) abbrev_size
);
2469 /* PR 17531: file:4bcd9ce9. */
2470 else if ((abbrev_base
+ abbrev_size
)
2471 > debug_displays
[abbrev_sec
].section
.size
)
2472 warn (_("Debug info is corrupted, abbrev size (%lx) is larger than abbrev section size (%lx)\n"),
2473 (unsigned long) abbrev_base
+ abbrev_size
,
2474 (unsigned long) debug_displays
[abbrev_sec
].section
.size
);
2476 process_abbrev_section
2477 (((unsigned char *) debug_displays
[abbrev_sec
].section
.start
2478 + abbrev_base
+ compunit
.cu_abbrev_offset
),
2479 ((unsigned char *) debug_displays
[abbrev_sec
].section
.start
2480 + abbrev_base
+ abbrev_size
));
2485 while (tags
< start
)
2487 unsigned int bytes_read
;
2488 unsigned long abbrev_number
;
2489 unsigned long die_offset
;
2490 abbrev_entry
*entry
;
2492 int do_printing
= 1;
2494 die_offset
= tags
- section_begin
;
2496 abbrev_number
= read_uleb128 (tags
, & bytes_read
, start
);
2499 /* A null DIE marks the end of a list of siblings or it may also be
2500 a section padding. */
2501 if (abbrev_number
== 0)
2503 /* Check if it can be a section padding for the last CU. */
2504 if (level
== 0 && start
== end
)
2508 for (chk
= tags
; chk
< start
; chk
++)
2515 if (!do_loc
&& die_offset
>= dwarf_start_die
2516 && (dwarf_cutoff_level
== -1
2517 || level
< dwarf_cutoff_level
))
2518 printf (_(" <%d><%lx>: Abbrev Number: 0\n"),
2524 static unsigned num_bogus_warns
= 0;
2526 if (num_bogus_warns
< 3)
2528 warn (_("Bogus end-of-siblings marker detected at offset %lx in %s section\n"),
2529 die_offset
, section
->name
);
2531 if (num_bogus_warns
== 3)
2532 warn (_("Further warnings about bogus end-of-sibling markers suppressed\n"));
2535 if (dwarf_start_die
!= 0 && level
< saved_level
)
2542 if (dwarf_start_die
!= 0 && die_offset
< dwarf_start_die
)
2546 if (dwarf_start_die
!= 0 && die_offset
== dwarf_start_die
)
2547 saved_level
= level
;
2548 do_printing
= (dwarf_cutoff_level
== -1
2549 || level
< dwarf_cutoff_level
);
2551 printf (_(" <%d><%lx>: Abbrev Number: %lu"),
2552 level
, die_offset
, abbrev_number
);
2553 else if (dwarf_cutoff_level
== -1
2554 || last_level
< dwarf_cutoff_level
)
2555 printf (_(" <%d><%lx>: ...\n"), level
, die_offset
);
2560 /* Scan through the abbreviation list until we reach the
2562 for (entry
= first_abbrev
;
2563 entry
&& entry
->entry
!= abbrev_number
;
2564 entry
= entry
->next
)
2569 if (!do_loc
&& do_printing
)
2574 warn (_("DIE at offset %lx refers to abbreviation number %lu which does not exist\n"),
2575 die_offset
, abbrev_number
);
2579 if (!do_loc
&& do_printing
)
2580 printf (" (%s)\n", get_TAG_name (entry
->tag
));
2585 need_base_address
= 0;
2587 case DW_TAG_compile_unit
:
2588 need_base_address
= 1;
2590 case DW_TAG_entry_point
:
2591 case DW_TAG_subprogram
:
2592 need_base_address
= 0;
2593 /* Assuming that there is no DW_AT_frame_base. */
2594 have_frame_base
= 0;
2598 for (attr
= entry
->first_attr
;
2599 attr
&& attr
->attribute
;
2604 if (! do_loc
&& do_printing
)
2605 /* Show the offset from where the tag was extracted. */
2606 printf (" <%lx>", (unsigned long)(tags
- section_begin
));
2608 if (debug_information
&& unit
< alloc_num_debug_info_entries
)
2609 arg
= debug_information
+ unit
;
2613 tags
= read_and_display_attr (attr
->attribute
,
2618 compunit
.cu_pointer_size
,
2620 compunit
.cu_version
,
2622 do_loc
|| ! do_printing
,
2627 if (entry
->children
)
2632 /* Set num_debug_info_entries here so that it can be used to check if
2633 we need to process .debug_loc and .debug_ranges sections. */
2634 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2635 && num_debug_info_entries
== 0
2638 if (num_units
> alloc_num_debug_info_entries
)
2639 num_debug_info_entries
= alloc_num_debug_info_entries
;
2641 num_debug_info_entries
= num_units
;
2650 /* Locate and scan the .debug_info section in the file and record the pointer
2651 sizes and offsets for the compilation units in it. Usually an executable
2652 will have just one pointer size, but this is not guaranteed, and so we try
2653 not to make any assumptions. Returns zero upon failure, or the number of
2654 compilation units upon success. */
2657 load_debug_info (void * file
)
2659 /* Reset the last pointer size so that we can issue correct error
2660 messages if we are displaying the contents of more than one section. */
2661 last_pointer_size
= 0;
2662 warned_about_missing_comp_units
= FALSE
;
2664 /* If we have already tried and failed to load the .debug_info
2665 section then do not bother to repeat the task. */
2666 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
2669 /* If we already have the information there is nothing else to do. */
2670 if (num_debug_info_entries
> 0)
2671 return num_debug_info_entries
;
2673 /* If this is a DWARF package file, load the CU and TU indexes. */
2674 load_cu_tu_indexes (file
);
2676 if (load_debug_section (info
, file
)
2677 && process_debug_info (&debug_displays
[info
].section
, file
, abbrev
, 1, 0))
2678 return num_debug_info_entries
;
2680 if (load_debug_section (info_dwo
, file
)
2681 && process_debug_info (&debug_displays
[info_dwo
].section
, file
,
2683 return num_debug_info_entries
;
2685 num_debug_info_entries
= DEBUG_INFO_UNAVAILABLE
;
2689 /* Read a DWARF .debug_line section header starting at DATA.
2690 Upon success returns an updated DATA pointer and the LINFO
2691 structure and the END_OF_SEQUENCE pointer will be filled in.
2692 Otherwise returns NULL. */
2694 static unsigned char *
2695 read_debug_line_header (struct dwarf_section
* section
,
2696 unsigned char * data
,
2697 unsigned char * end
,
2698 DWARF2_Internal_LineInfo
* linfo
,
2699 unsigned char ** end_of_sequence
)
2701 unsigned char *hdrptr
;
2702 unsigned int offset_size
;
2703 unsigned int initial_length_size
;
2705 /* Extract information from the Line Number Program Header.
2706 (section 6.2.4 in the Dwarf3 doc). */
2709 /* Get and check the length of the block. */
2710 SAFE_BYTE_GET_AND_INC (linfo
->li_length
, hdrptr
, 4, end
);
2712 if (linfo
->li_length
== 0xffffffff)
2714 /* This section is 64-bit DWARF 3. */
2715 SAFE_BYTE_GET_AND_INC (linfo
->li_length
, hdrptr
, 8, end
);
2717 initial_length_size
= 12;
2722 initial_length_size
= 4;
2725 if (linfo
->li_length
+ initial_length_size
> section
->size
)
2727 /* If the length is just a bias against the initial_length_size then
2728 this means that the field has a relocation against it which has not
2729 been applied. (Ie we are dealing with an object file, not a linked
2730 binary). Do not complain but instead assume that the rest of the
2731 section applies to this particular header. */
2732 if (linfo
->li_length
== - initial_length_size
)
2734 linfo
->li_length
= section
->size
- initial_length_size
;
2738 warn (_("The line info appears to be corrupt - the section is too small\n"));
2743 /* Get and check the version number. */
2744 SAFE_BYTE_GET_AND_INC (linfo
->li_version
, hdrptr
, 2, end
);
2746 if (linfo
->li_version
!= 2
2747 && linfo
->li_version
!= 3
2748 && linfo
->li_version
!= 4)
2750 warn (_("Only DWARF version 2, 3 and 4 line info is currently supported.\n"));
2754 SAFE_BYTE_GET_AND_INC (linfo
->li_prologue_length
, hdrptr
, offset_size
, end
);
2755 SAFE_BYTE_GET_AND_INC (linfo
->li_min_insn_length
, hdrptr
, 1, end
);
2757 if (linfo
->li_version
>= 4)
2759 SAFE_BYTE_GET_AND_INC (linfo
->li_max_ops_per_insn
, hdrptr
, 1, end
);
2761 if (linfo
->li_max_ops_per_insn
== 0)
2763 warn (_("Invalid maximum operations per insn.\n"));
2768 linfo
->li_max_ops_per_insn
= 1;
2770 SAFE_BYTE_GET_AND_INC (linfo
->li_default_is_stmt
, hdrptr
, 1, end
);
2771 SAFE_SIGNED_BYTE_GET_AND_INC (linfo
->li_line_base
, hdrptr
, 1, end
);
2772 SAFE_BYTE_GET_AND_INC (linfo
->li_line_range
, hdrptr
, 1, end
);
2773 SAFE_BYTE_GET_AND_INC (linfo
->li_opcode_base
, hdrptr
, 1, end
);
2775 * end_of_sequence
= data
+ linfo
->li_length
+ initial_length_size
;
2776 /* PR 17512: file:002-117414-0.004. */
2777 if (* end_of_sequence
> end
)
2779 warn (_("Line length %s extends beyond end of section\n"),
2780 dwarf_vmatoa ("u", linfo
->li_length
));
2781 * end_of_sequence
= end
;
2789 display_debug_lines_raw (struct dwarf_section
*section
,
2790 unsigned char *data
,
2793 unsigned char *start
= section
->start
;
2795 printf (_("Raw dump of debug contents of section %s:\n\n"),
2800 static DWARF2_Internal_LineInfo saved_linfo
;
2801 DWARF2_Internal_LineInfo linfo
;
2802 unsigned char *standard_opcodes
;
2803 unsigned char *end_of_sequence
;
2804 unsigned int last_dir_entry
= 0;
2807 if (const_strneq (section
->name
, ".debug_line.")
2808 /* Note: the following does not apply to .debug_line.dwo sections.
2809 These are full debug_line sections. */
2810 && strcmp (section
->name
, ".debug_line.dwo") != 0)
2812 /* Sections named .debug_line.<foo> are fragments of a .debug_line
2813 section containing just the Line Number Statements. They are
2814 created by the assembler and intended to be used alongside gcc's
2815 -ffunction-sections command line option. When the linker's
2816 garbage collection decides to discard a .text.<foo> section it
2817 can then also discard the line number information in .debug_line.<foo>.
2819 Since the section is a fragment it does not have the details
2820 needed to fill out a LineInfo structure, so instead we use the
2821 details from the last full debug_line section that we processed. */
2822 end_of_sequence
= end
;
2823 standard_opcodes
= NULL
;
2824 linfo
= saved_linfo
;
2825 /* PR 17531: file: 0522b371. */
2826 if (linfo
.li_line_range
== 0)
2828 warn (_("Partial .debug_line. section encountered without a prior full .debug_line section\n"));
2831 reset_state_machine (linfo
.li_default_is_stmt
);
2835 unsigned char * hdrptr
;
2837 if ((hdrptr
= read_debug_line_header (section
, data
, end
, & linfo
,
2838 & end_of_sequence
)) == NULL
)
2841 printf (_(" Offset: 0x%lx\n"), (long)(data
- start
));
2842 printf (_(" Length: %ld\n"), (long) linfo
.li_length
);
2843 printf (_(" DWARF Version: %d\n"), linfo
.li_version
);
2844 printf (_(" Prologue Length: %d\n"), linfo
.li_prologue_length
);
2845 printf (_(" Minimum Instruction Length: %d\n"), linfo
.li_min_insn_length
);
2846 if (linfo
.li_version
>= 4)
2847 printf (_(" Maximum Ops per Instruction: %d\n"), linfo
.li_max_ops_per_insn
);
2848 printf (_(" Initial value of 'is_stmt': %d\n"), linfo
.li_default_is_stmt
);
2849 printf (_(" Line Base: %d\n"), linfo
.li_line_base
);
2850 printf (_(" Line Range: %d\n"), linfo
.li_line_range
);
2851 printf (_(" Opcode Base: %d\n"), linfo
.li_opcode_base
);
2853 /* PR 17512: file: 1665-6428-0.004. */
2854 if (linfo
.li_line_range
== 0)
2856 warn (_("Line range of 0 is invalid, using 1 instead\n"));
2857 linfo
.li_line_range
= 1;
2860 reset_state_machine (linfo
.li_default_is_stmt
);
2862 /* Display the contents of the Opcodes table. */
2863 standard_opcodes
= hdrptr
;
2865 /* PR 17512: file: 002-417945-0.004. */
2866 if (standard_opcodes
+ linfo
.li_opcode_base
>= end
)
2868 warn (_("Line Base extends beyond end of section\n"));
2872 printf (_("\n Opcodes:\n"));
2874 for (i
= 1; i
< linfo
.li_opcode_base
; i
++)
2875 printf (_(" Opcode %d has %d args\n"), i
, standard_opcodes
[i
- 1]);
2877 /* Display the contents of the Directory table. */
2878 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
2881 printf (_("\n The Directory Table is empty.\n"));
2884 printf (_("\n The Directory Table (offset 0x%lx):\n"),
2885 (long)(data
- start
));
2887 while (data
< end
&& *data
!= 0)
2889 printf (" %d\t%.*s\n", ++last_dir_entry
, (int) (end
- data
), data
);
2891 data
+= strnlen ((char *) data
, end
- data
) + 1;
2894 /* PR 17512: file: 002-132094-0.004. */
2895 if (data
>= end
- 1)
2899 /* Skip the NUL at the end of the table. */
2902 /* Display the contents of the File Name table. */
2904 printf (_("\n The File Name Table is empty.\n"));
2907 printf (_("\n The File Name Table (offset 0x%lx):\n"),
2908 (long)(data
- start
));
2909 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
2911 while (data
< end
&& *data
!= 0)
2913 unsigned char *name
;
2914 unsigned int bytes_read
;
2916 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
2918 data
+= strnlen ((char *) data
, end
- data
) + 1;
2921 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
2924 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
2927 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
2929 printf ("%.*s\n", (int)(end
- name
), name
);
2933 warn (_("Corrupt file name table entry\n"));
2939 /* Skip the NUL at the end of the table. */
2942 saved_linfo
= linfo
;
2945 /* Now display the statements. */
2946 if (data
>= end_of_sequence
)
2947 printf (_(" No Line Number Statements.\n"));
2950 printf (_(" Line Number Statements:\n"));
2952 while (data
< end_of_sequence
)
2954 unsigned char op_code
;
2955 dwarf_signed_vma adv
;
2957 unsigned int bytes_read
;
2959 printf (" [0x%08lx]", (long)(data
- start
));
2963 if (op_code
>= linfo
.li_opcode_base
)
2965 op_code
-= linfo
.li_opcode_base
;
2966 uladv
= (op_code
/ linfo
.li_line_range
);
2967 if (linfo
.li_max_ops_per_insn
== 1)
2969 uladv
*= linfo
.li_min_insn_length
;
2970 state_machine_regs
.address
+= uladv
;
2971 printf (_(" Special opcode %d: "
2972 "advance Address by %s to 0x%s"),
2973 op_code
, dwarf_vmatoa ("u", uladv
),
2974 dwarf_vmatoa ("x", state_machine_regs
.address
));
2978 state_machine_regs
.address
2979 += ((state_machine_regs
.op_index
+ uladv
)
2980 / linfo
.li_max_ops_per_insn
)
2981 * linfo
.li_min_insn_length
;
2982 state_machine_regs
.op_index
2983 = (state_machine_regs
.op_index
+ uladv
)
2984 % linfo
.li_max_ops_per_insn
;
2985 printf (_(" Special opcode %d: "
2986 "advance Address by %s to 0x%s[%d]"),
2987 op_code
, dwarf_vmatoa ("u", uladv
),
2988 dwarf_vmatoa ("x", state_machine_regs
.address
),
2989 state_machine_regs
.op_index
);
2991 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
2992 state_machine_regs
.line
+= adv
;
2993 printf (_(" and Line by %s to %d\n"),
2994 dwarf_vmatoa ("d", adv
), state_machine_regs
.line
);
2996 else switch (op_code
)
2998 case DW_LNS_extended_op
:
2999 data
+= process_extended_line_op (data
, linfo
.li_default_is_stmt
, end
);
3003 printf (_(" Copy\n"));
3006 case DW_LNS_advance_pc
:
3007 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3009 if (linfo
.li_max_ops_per_insn
== 1)
3011 uladv
*= linfo
.li_min_insn_length
;
3012 state_machine_regs
.address
+= uladv
;
3013 printf (_(" Advance PC by %s to 0x%s\n"),
3014 dwarf_vmatoa ("u", uladv
),
3015 dwarf_vmatoa ("x", state_machine_regs
.address
));
3019 state_machine_regs
.address
3020 += ((state_machine_regs
.op_index
+ uladv
)
3021 / linfo
.li_max_ops_per_insn
)
3022 * linfo
.li_min_insn_length
;
3023 state_machine_regs
.op_index
3024 = (state_machine_regs
.op_index
+ uladv
)
3025 % linfo
.li_max_ops_per_insn
;
3026 printf (_(" Advance PC by %s to 0x%s[%d]\n"),
3027 dwarf_vmatoa ("u", uladv
),
3028 dwarf_vmatoa ("x", state_machine_regs
.address
),
3029 state_machine_regs
.op_index
);
3033 case DW_LNS_advance_line
:
3034 adv
= read_sleb128 (data
, & bytes_read
, end
);
3036 state_machine_regs
.line
+= adv
;
3037 printf (_(" Advance Line by %s to %d\n"),
3038 dwarf_vmatoa ("d", adv
),
3039 state_machine_regs
.line
);
3042 case DW_LNS_set_file
:
3043 adv
= read_uleb128 (data
, & bytes_read
, end
);
3045 printf (_(" Set File Name to entry %s in the File Name Table\n"),
3046 dwarf_vmatoa ("d", adv
));
3047 state_machine_regs
.file
= adv
;
3050 case DW_LNS_set_column
:
3051 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3053 printf (_(" Set column to %s\n"),
3054 dwarf_vmatoa ("u", uladv
));
3055 state_machine_regs
.column
= uladv
;
3058 case DW_LNS_negate_stmt
:
3059 adv
= state_machine_regs
.is_stmt
;
3061 printf (_(" Set is_stmt to %s\n"), dwarf_vmatoa ("d", adv
));
3062 state_machine_regs
.is_stmt
= adv
;
3065 case DW_LNS_set_basic_block
:
3066 printf (_(" Set basic block\n"));
3067 state_machine_regs
.basic_block
= 1;
3070 case DW_LNS_const_add_pc
:
3071 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
3072 if (linfo
.li_max_ops_per_insn
)
3074 uladv
*= linfo
.li_min_insn_length
;
3075 state_machine_regs
.address
+= uladv
;
3076 printf (_(" Advance PC by constant %s to 0x%s\n"),
3077 dwarf_vmatoa ("u", uladv
),
3078 dwarf_vmatoa ("x", state_machine_regs
.address
));
3082 state_machine_regs
.address
3083 += ((state_machine_regs
.op_index
+ uladv
)
3084 / linfo
.li_max_ops_per_insn
)
3085 * linfo
.li_min_insn_length
;
3086 state_machine_regs
.op_index
3087 = (state_machine_regs
.op_index
+ uladv
)
3088 % linfo
.li_max_ops_per_insn
;
3089 printf (_(" Advance PC by constant %s to 0x%s[%d]\n"),
3090 dwarf_vmatoa ("u", uladv
),
3091 dwarf_vmatoa ("x", state_machine_regs
.address
),
3092 state_machine_regs
.op_index
);
3096 case DW_LNS_fixed_advance_pc
:
3097 SAFE_BYTE_GET_AND_INC (uladv
, data
, 2, end
);
3098 state_machine_regs
.address
+= uladv
;
3099 state_machine_regs
.op_index
= 0;
3100 printf (_(" Advance PC by fixed size amount %s to 0x%s\n"),
3101 dwarf_vmatoa ("u", uladv
),
3102 dwarf_vmatoa ("x", state_machine_regs
.address
));
3105 case DW_LNS_set_prologue_end
:
3106 printf (_(" Set prologue_end to true\n"));
3109 case DW_LNS_set_epilogue_begin
:
3110 printf (_(" Set epilogue_begin to true\n"));
3113 case DW_LNS_set_isa
:
3114 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3116 printf (_(" Set ISA to %s\n"), dwarf_vmatoa ("u", uladv
));
3120 printf (_(" Unknown opcode %d with operands: "), op_code
);
3122 if (standard_opcodes
!= NULL
)
3123 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
3125 printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data
,
3127 i
== 1 ? "" : ", ");
3143 unsigned char *name
;
3144 unsigned int directory_index
;
3145 unsigned int modification_date
;
3146 unsigned int length
;
3149 /* Output a decoded representation of the .debug_line section. */
3152 display_debug_lines_decoded (struct dwarf_section
*section
,
3153 unsigned char *data
,
3156 static DWARF2_Internal_LineInfo saved_linfo
;
3158 printf (_("Decoded dump of debug contents of section %s:\n\n"),
3163 /* This loop amounts to one iteration per compilation unit. */
3164 DWARF2_Internal_LineInfo linfo
;
3165 unsigned char *standard_opcodes
;
3166 unsigned char *end_of_sequence
;
3168 File_Entry
*file_table
= NULL
;
3169 unsigned int n_files
= 0;
3170 unsigned char **directory_table
= NULL
;
3171 unsigned int n_directories
= 0;
3173 if (const_strneq (section
->name
, ".debug_line.")
3174 /* Note: the following does not apply to .debug_line.dwo sections.
3175 These are full debug_line sections. */
3176 && strcmp (section
->name
, ".debug_line.dwo") != 0)
3178 /* See comment in display_debug_lines_raw(). */
3179 end_of_sequence
= end
;
3180 standard_opcodes
= NULL
;
3181 linfo
= saved_linfo
;
3182 /* PR 17531: file: 0522b371. */
3183 if (linfo
.li_line_range
== 0)
3185 warn (_("Partial .debug_line. section encountered without a prior full .debug_line section\n"));
3188 reset_state_machine (linfo
.li_default_is_stmt
);
3192 unsigned char *hdrptr
;
3194 if ((hdrptr
= read_debug_line_header (section
, data
, end
, & linfo
,
3195 & end_of_sequence
)) == NULL
)
3198 /* PR 17531: file: 0522b371. */
3199 if (linfo
.li_line_range
== 0)
3201 warn (_("Line range of 0 is invalid, using 1 instead\n"));
3202 linfo
.li_line_range
= 1;
3204 reset_state_machine (linfo
.li_default_is_stmt
);
3206 /* Save a pointer to the contents of the Opcodes table. */
3207 standard_opcodes
= hdrptr
;
3209 /* Traverse the Directory table just to count entries. */
3210 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
3213 unsigned char *ptr_directory_table
= data
;
3217 data
+= strnlen ((char *) data
, end
- data
) + 1;
3221 /* Go through the directory table again to save the directories. */
3222 directory_table
= (unsigned char **)
3223 xmalloc (n_directories
* sizeof (unsigned char *));
3226 while (*ptr_directory_table
!= 0)
3228 directory_table
[i
] = ptr_directory_table
;
3229 ptr_directory_table
+= strnlen ((char *) ptr_directory_table
,
3230 ptr_directory_table
- end
) + 1;
3234 /* Skip the NUL at the end of the table. */
3237 /* Traverse the File Name table just to count the entries. */
3240 unsigned char *ptr_file_name_table
= data
;
3244 unsigned int bytes_read
;
3246 /* Skip Name, directory index, last modification time and length
3248 data
+= strnlen ((char *) data
, end
- data
) + 1;
3249 read_uleb128 (data
, & bytes_read
, end
);
3251 read_uleb128 (data
, & bytes_read
, end
);
3253 read_uleb128 (data
, & bytes_read
, end
);
3259 /* Go through the file table again to save the strings. */
3260 file_table
= (File_Entry
*) xmalloc (n_files
* sizeof (File_Entry
));
3263 while (*ptr_file_name_table
!= 0)
3265 unsigned int bytes_read
;
3267 file_table
[i
].name
= ptr_file_name_table
;
3268 ptr_file_name_table
+= strnlen ((char *) ptr_file_name_table
,
3269 end
- ptr_file_name_table
) + 1;
3271 /* We are not interested in directory, time or size. */
3272 file_table
[i
].directory_index
= read_uleb128 (ptr_file_name_table
,
3274 ptr_file_name_table
+= bytes_read
;
3275 file_table
[i
].modification_date
= read_uleb128 (ptr_file_name_table
,
3277 ptr_file_name_table
+= bytes_read
;
3278 file_table
[i
].length
= read_uleb128 (ptr_file_name_table
, & bytes_read
, end
);
3279 ptr_file_name_table
+= bytes_read
;
3284 /* Print the Compilation Unit's name and a header. */
3285 if (directory_table
== NULL
)
3287 printf (_("CU: %s:\n"), file_table
[0].name
);
3288 printf (_("File name Line number Starting address\n"));
3292 unsigned int ix
= file_table
[0].directory_index
;
3293 const char *directory
= ix
? (char *)directory_table
[ix
- 1] : ".";
3295 if (do_wide
|| strlen (directory
) < 76)
3296 printf (_("CU: %s/%s:\n"), directory
, file_table
[0].name
);
3298 printf ("%s:\n", file_table
[0].name
);
3300 printf (_("File name Line number Starting address\n"));
3304 /* Skip the NUL at the end of the table. */
3307 saved_linfo
= linfo
;
3310 /* This loop iterates through the Dwarf Line Number Program. */
3311 while (data
< end_of_sequence
)
3313 unsigned char op_code
;
3315 unsigned long int uladv
;
3316 unsigned int bytes_read
;
3317 int is_special_opcode
= 0;
3321 if (op_code
>= linfo
.li_opcode_base
)
3323 op_code
-= linfo
.li_opcode_base
;
3324 uladv
= (op_code
/ linfo
.li_line_range
);
3325 if (linfo
.li_max_ops_per_insn
== 1)
3327 uladv
*= linfo
.li_min_insn_length
;
3328 state_machine_regs
.address
+= uladv
;
3332 state_machine_regs
.address
3333 += ((state_machine_regs
.op_index
+ uladv
)
3334 / linfo
.li_max_ops_per_insn
)
3335 * linfo
.li_min_insn_length
;
3336 state_machine_regs
.op_index
3337 = (state_machine_regs
.op_index
+ uladv
)
3338 % linfo
.li_max_ops_per_insn
;
3341 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
3342 state_machine_regs
.line
+= adv
;
3343 is_special_opcode
= 1;
3345 else switch (op_code
)
3347 case DW_LNS_extended_op
:
3349 unsigned int ext_op_code_len
;
3350 unsigned char ext_op_code
;
3351 unsigned char *op_code_data
= data
;
3353 ext_op_code_len
= read_uleb128 (op_code_data
, &bytes_read
,
3355 op_code_data
+= bytes_read
;
3357 if (ext_op_code_len
== 0)
3359 warn (_("Badly formed extended line op encountered!\n"));
3362 ext_op_code_len
+= bytes_read
;
3363 ext_op_code
= *op_code_data
++;
3365 switch (ext_op_code
)
3367 case DW_LNE_end_sequence
:
3368 reset_state_machine (linfo
.li_default_is_stmt
);
3370 case DW_LNE_set_address
:
3371 SAFE_BYTE_GET_AND_INC (state_machine_regs
.address
,
3373 ext_op_code_len
- bytes_read
- 1,
3375 state_machine_regs
.op_index
= 0;
3377 case DW_LNE_define_file
:
3379 file_table
= (File_Entry
*) xrealloc
3380 (file_table
, (n_files
+ 1) * sizeof (File_Entry
));
3382 ++state_machine_regs
.last_file_entry
;
3383 /* Source file name. */
3384 file_table
[n_files
].name
= op_code_data
;
3385 op_code_data
+= strlen ((char *) op_code_data
) + 1;
3386 /* Directory index. */
3387 file_table
[n_files
].directory_index
=
3388 read_uleb128 (op_code_data
, & bytes_read
,
3390 op_code_data
+= bytes_read
;
3391 /* Last modification time. */
3392 file_table
[n_files
].modification_date
=
3393 read_uleb128 (op_code_data
, & bytes_read
,
3395 op_code_data
+= bytes_read
;
3397 file_table
[n_files
].length
=
3398 read_uleb128 (op_code_data
, & bytes_read
,
3404 case DW_LNE_set_discriminator
:
3405 case DW_LNE_HP_set_sequence
:
3406 /* Simply ignored. */
3410 printf (_("UNKNOWN (%u): length %d\n"),
3411 ext_op_code
, ext_op_code_len
- bytes_read
);
3414 data
+= ext_op_code_len
;
3420 case DW_LNS_advance_pc
:
3421 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3423 if (linfo
.li_max_ops_per_insn
== 1)
3425 uladv
*= linfo
.li_min_insn_length
;
3426 state_machine_regs
.address
+= uladv
;
3430 state_machine_regs
.address
3431 += ((state_machine_regs
.op_index
+ uladv
)
3432 / linfo
.li_max_ops_per_insn
)
3433 * linfo
.li_min_insn_length
;
3434 state_machine_regs
.op_index
3435 = (state_machine_regs
.op_index
+ uladv
)
3436 % linfo
.li_max_ops_per_insn
;
3440 case DW_LNS_advance_line
:
3441 adv
= read_sleb128 (data
, & bytes_read
, end
);
3443 state_machine_regs
.line
+= adv
;
3446 case DW_LNS_set_file
:
3447 adv
= read_uleb128 (data
, & bytes_read
, end
);
3449 state_machine_regs
.file
= adv
;
3451 if (file_table
== NULL
)
3452 printf (_("\n [Use file table entry %d]\n"), state_machine_regs
.file
- 1);
3453 else if (file_table
[state_machine_regs
.file
- 1].directory_index
== 0)
3454 /* If directory index is 0, that means current directory. */
3455 printf ("\n./%s:[++]\n",
3456 file_table
[state_machine_regs
.file
- 1].name
);
3457 else if (directory_table
== NULL
)
3458 printf (_("\n [Use directory table entry %d]\n"),
3459 file_table
[state_machine_regs
.file
- 1].directory_index
- 1);
3461 /* The directory index starts counting at 1. */
3462 printf ("\n%s/%s:\n",
3463 directory_table
[file_table
[state_machine_regs
.file
- 1].directory_index
- 1],
3464 file_table
[state_machine_regs
.file
- 1].name
);
3467 case DW_LNS_set_column
:
3468 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3470 state_machine_regs
.column
= uladv
;
3473 case DW_LNS_negate_stmt
:
3474 adv
= state_machine_regs
.is_stmt
;
3476 state_machine_regs
.is_stmt
= adv
;
3479 case DW_LNS_set_basic_block
:
3480 state_machine_regs
.basic_block
= 1;
3483 case DW_LNS_const_add_pc
:
3484 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
3485 if (linfo
.li_max_ops_per_insn
== 1)
3487 uladv
*= linfo
.li_min_insn_length
;
3488 state_machine_regs
.address
+= uladv
;
3492 state_machine_regs
.address
3493 += ((state_machine_regs
.op_index
+ uladv
)
3494 / linfo
.li_max_ops_per_insn
)
3495 * linfo
.li_min_insn_length
;
3496 state_machine_regs
.op_index
3497 = (state_machine_regs
.op_index
+ uladv
)
3498 % linfo
.li_max_ops_per_insn
;
3502 case DW_LNS_fixed_advance_pc
:
3503 SAFE_BYTE_GET_AND_INC (uladv
, data
, 2, end
);
3504 state_machine_regs
.address
+= uladv
;
3505 state_machine_regs
.op_index
= 0;
3508 case DW_LNS_set_prologue_end
:
3511 case DW_LNS_set_epilogue_begin
:
3514 case DW_LNS_set_isa
:
3515 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3517 printf (_(" Set ISA to %lu\n"), uladv
);
3521 printf (_(" Unknown opcode %d with operands: "), op_code
);
3523 if (standard_opcodes
!= NULL
)
3524 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
3526 printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data
,
3528 i
== 1 ? "" : ", ");
3535 /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row
3536 to the DWARF address/line matrix. */
3537 if ((is_special_opcode
) || (op_code
== DW_LNE_end_sequence
)
3538 || (op_code
== DW_LNS_copy
))
3540 const unsigned int MAX_FILENAME_LENGTH
= 35;
3542 char *newFileName
= NULL
;
3543 size_t fileNameLength
;
3546 fileName
= (char *) file_table
[state_machine_regs
.file
- 1].name
;
3548 fileName
= "<unknown>";
3550 fileNameLength
= strlen (fileName
);
3552 if ((fileNameLength
> MAX_FILENAME_LENGTH
) && (!do_wide
))
3554 newFileName
= (char *) xmalloc (MAX_FILENAME_LENGTH
+ 1);
3555 /* Truncate file name */
3556 strncpy (newFileName
,
3557 fileName
+ fileNameLength
- MAX_FILENAME_LENGTH
,
3558 MAX_FILENAME_LENGTH
+ 1);
3562 newFileName
= (char *) xmalloc (fileNameLength
+ 1);
3563 strncpy (newFileName
, fileName
, fileNameLength
+ 1);
3566 if (!do_wide
|| (fileNameLength
<= MAX_FILENAME_LENGTH
))
3568 if (linfo
.li_max_ops_per_insn
== 1)
3569 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x\n",
3570 newFileName
, state_machine_regs
.line
,
3571 state_machine_regs
.address
);
3573 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x[%d]\n",
3574 newFileName
, state_machine_regs
.line
,
3575 state_machine_regs
.address
,
3576 state_machine_regs
.op_index
);
3580 if (linfo
.li_max_ops_per_insn
== 1)
3581 printf ("%s %11d %#18" DWARF_VMA_FMT
"x\n",
3582 newFileName
, state_machine_regs
.line
,
3583 state_machine_regs
.address
);
3585 printf ("%s %11d %#18" DWARF_VMA_FMT
"x[%d]\n",
3586 newFileName
, state_machine_regs
.line
,
3587 state_machine_regs
.address
,
3588 state_machine_regs
.op_index
);
3591 if (op_code
== DW_LNE_end_sequence
)
3605 if (directory_table
)
3607 free (directory_table
);
3608 directory_table
= NULL
;
3619 display_debug_lines (struct dwarf_section
*section
, void *file ATTRIBUTE_UNUSED
)
3621 unsigned char *data
= section
->start
;
3622 unsigned char *end
= data
+ section
->size
;
3624 int retValDecoded
= 1;
3626 if (do_debug_lines
== 0)
3627 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
3629 if (do_debug_lines
& FLAG_DEBUG_LINES_RAW
)
3630 retValRaw
= display_debug_lines_raw (section
, data
, end
);
3632 if (do_debug_lines
& FLAG_DEBUG_LINES_DECODED
)
3633 retValDecoded
= display_debug_lines_decoded (section
, data
, end
);
3635 if (!retValRaw
|| !retValDecoded
)
3642 find_debug_info_for_offset (unsigned long offset
)
3646 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
3649 for (i
= 0; i
< num_debug_info_entries
; i
++)
3650 if (debug_information
[i
].cu_offset
== offset
)
3651 return debug_information
+ i
;
3657 get_gdb_index_symbol_kind_name (gdb_index_symbol_kind kind
)
3659 /* See gdb/gdb-index.h. */
3660 static const char * const kinds
[] =
3672 return _ (kinds
[kind
]);
3676 display_debug_pubnames_worker (struct dwarf_section
*section
,
3677 void *file ATTRIBUTE_UNUSED
,
3680 DWARF2_Internal_PubNames names
;
3681 unsigned char *start
= section
->start
;
3682 unsigned char *end
= start
+ section
->size
;
3684 /* It does not matter if this load fails,
3685 we test for that later on. */
3686 load_debug_info (file
);
3688 printf (_("Contents of the %s section:\n\n"), section
->name
);
3692 unsigned char *data
;
3693 unsigned long offset
;
3694 unsigned int offset_size
, initial_length_size
;
3698 SAFE_BYTE_GET_AND_INC (names
.pn_length
, data
, 4, end
);
3699 if (names
.pn_length
== 0xffffffff)
3701 SAFE_BYTE_GET_AND_INC (names
.pn_length
, data
, 8, end
);
3703 initial_length_size
= 12;
3708 initial_length_size
= 4;
3711 SAFE_BYTE_GET_AND_INC (names
.pn_version
, data
, 2, end
);
3712 SAFE_BYTE_GET_AND_INC (names
.pn_offset
, data
, offset_size
, end
);
3714 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
3715 && num_debug_info_entries
> 0
3716 && find_debug_info_for_offset (names
.pn_offset
) == NULL
)
3717 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
3718 (unsigned long) names
.pn_offset
, section
->name
);
3720 SAFE_BYTE_GET_AND_INC (names
.pn_size
, data
, offset_size
, end
);
3722 /* PR 17531: file: 7615b6b2. */
3723 if ((dwarf_signed_vma
) names
.pn_length
< 0)
3725 warn (_("Negative length for public name: 0x%lx\n"), (long) names
.pn_length
);
3729 start
+= names
.pn_length
+ initial_length_size
;
3731 printf (_(" Length: %ld\n"),
3732 (long) names
.pn_length
);
3733 printf (_(" Version: %d\n"),
3735 printf (_(" Offset into .debug_info section: 0x%lx\n"),
3736 (unsigned long) names
.pn_offset
);
3737 printf (_(" Size of area in .debug_info section: %ld\n"),
3738 (long) names
.pn_size
);
3740 if (names
.pn_version
!= 2 && names
.pn_version
!= 3)
3742 static int warned
= 0;
3746 warn (_("Only DWARF 2 and 3 pubnames are currently supported\n"));
3754 printf (_("\n Offset Kind Name\n"));
3756 printf (_("\n Offset\tName\n"));
3760 bfd_size_type maxprint
;
3762 SAFE_BYTE_GET (offset
, data
, offset_size
, end
);
3766 data
+= offset_size
;
3769 maxprint
= (end
- data
) - 1;
3773 unsigned int kind_data
;
3774 gdb_index_symbol_kind kind
;
3775 const char *kind_name
;
3778 SAFE_BYTE_GET (kind_data
, data
, 1, end
);
3781 /* GCC computes the kind as the upper byte in the CU index
3782 word, and then right shifts it by the CU index size.
3783 Left shift KIND to where the gdb-index.h accessor macros
3785 kind_data
<<= GDB_INDEX_CU_BITSIZE
;
3786 kind
= GDB_INDEX_SYMBOL_KIND_VALUE (kind_data
);
3787 kind_name
= get_gdb_index_symbol_kind_name (kind
);
3788 is_static
= GDB_INDEX_SYMBOL_STATIC_VALUE (kind_data
);
3789 printf (" %-6lx %s,%-10s %.*s\n",
3790 offset
, is_static
? _("s") : _("g"),
3791 kind_name
, (int) maxprint
, data
);
3794 printf (" %-6lx\t%.*s\n", offset
, (int) maxprint
, data
);
3796 data
+= strnlen ((char *) data
, maxprint
) + 1;
3801 while (offset
!= 0);
3809 display_debug_pubnames (struct dwarf_section
*section
, void *file
)
3811 return display_debug_pubnames_worker (section
, file
, 0);
3815 display_debug_gnu_pubnames (struct dwarf_section
*section
, void *file
)
3817 return display_debug_pubnames_worker (section
, file
, 1);
3821 display_debug_macinfo (struct dwarf_section
*section
,
3822 void *file ATTRIBUTE_UNUSED
)
3824 unsigned char *start
= section
->start
;
3825 unsigned char *end
= start
+ section
->size
;
3826 unsigned char *curr
= start
;
3827 unsigned int bytes_read
;
3828 enum dwarf_macinfo_record_type op
;
3830 printf (_("Contents of the %s section:\n\n"), section
->name
);
3834 unsigned int lineno
;
3835 const unsigned char *string
;
3837 op
= (enum dwarf_macinfo_record_type
) *curr
;
3842 case DW_MACINFO_start_file
:
3844 unsigned int filenum
;
3846 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
3848 filenum
= read_uleb128 (curr
, & bytes_read
, end
);
3851 printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"),
3856 case DW_MACINFO_end_file
:
3857 printf (_(" DW_MACINFO_end_file\n"));
3860 case DW_MACINFO_define
:
3861 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
3864 curr
+= strnlen ((char *) string
, end
- string
) + 1;
3865 printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"),
3869 case DW_MACINFO_undef
:
3870 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
3873 curr
+= strnlen ((char *) string
, end
- string
) + 1;
3874 printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"),
3878 case DW_MACINFO_vendor_ext
:
3880 unsigned int constant
;
3882 constant
= read_uleb128 (curr
, & bytes_read
, end
);
3885 curr
+= strnlen ((char *) string
, end
- string
) + 1;
3886 printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"),
3896 /* Given LINE_OFFSET into the .debug_line section, attempt to return
3897 filename and dirname corresponding to file name table entry with index
3898 FILEIDX. Return NULL on failure. */
3900 static unsigned char *
3901 get_line_filename_and_dirname (dwarf_vma line_offset
,
3903 unsigned char **dir_name
)
3905 struct dwarf_section
*section
= &debug_displays
[line
].section
;
3906 unsigned char *hdrptr
, *dirtable
, *file_name
;
3907 unsigned int offset_size
, initial_length_size
;
3908 unsigned int version
, opcode_base
, bytes_read
;
3909 dwarf_vma length
, diridx
;
3910 const unsigned char * end
;
3913 if (section
->start
== NULL
3914 || line_offset
>= section
->size
3918 hdrptr
= section
->start
+ line_offset
;
3919 end
= section
->start
+ section
->size
;
3921 SAFE_BYTE_GET_AND_INC (length
, hdrptr
, 4, end
);
3922 if (length
== 0xffffffff)
3924 /* This section is 64-bit DWARF 3. */
3925 SAFE_BYTE_GET_AND_INC (length
, hdrptr
, 8, end
);
3927 initial_length_size
= 12;
3932 initial_length_size
= 4;
3934 if (length
+ initial_length_size
> section
->size
)
3937 SAFE_BYTE_GET_AND_INC (version
, hdrptr
, 2, end
);
3938 if (version
!= 2 && version
!= 3 && version
!= 4)
3940 hdrptr
+= offset_size
+ 1;/* Skip prologue_length and min_insn_length. */
3942 hdrptr
++; /* Skip max_ops_per_insn. */
3943 hdrptr
+= 3; /* Skip default_is_stmt, line_base, line_range. */
3945 SAFE_BYTE_GET_AND_INC (opcode_base
, hdrptr
, 1, end
);
3946 if (opcode_base
== 0)
3949 hdrptr
+= opcode_base
- 1;
3951 /* Skip over dirname table. */
3952 while (*hdrptr
!= '\0')
3953 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
3954 hdrptr
++; /* Skip the NUL at the end of the table. */
3955 /* Now skip over preceding filename table entries. */
3956 for (; *hdrptr
!= '\0' && fileidx
> 1; fileidx
--)
3958 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
3959 read_uleb128 (hdrptr
, &bytes_read
, end
);
3960 hdrptr
+= bytes_read
;
3961 read_uleb128 (hdrptr
, &bytes_read
, end
);
3962 hdrptr
+= bytes_read
;
3963 read_uleb128 (hdrptr
, &bytes_read
, end
);
3964 hdrptr
+= bytes_read
;
3966 if (hdrptr
== end
|| *hdrptr
== '\0')
3969 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
3970 diridx
= read_uleb128 (hdrptr
, &bytes_read
, end
);
3973 for (; *dirtable
!= '\0' && diridx
> 1; diridx
--)
3974 dirtable
+= strnlen ((char *) dirtable
, end
- dirtable
) + 1;
3975 if (*dirtable
== '\0')
3977 *dir_name
= dirtable
;
3982 display_debug_macro (struct dwarf_section
*section
,
3985 unsigned char *start
= section
->start
;
3986 unsigned char *end
= start
+ section
->size
;
3987 unsigned char *curr
= start
;
3988 unsigned char *extended_op_buf
[256];
3989 unsigned int bytes_read
;
3991 load_debug_section (str
, file
);
3992 load_debug_section (line
, file
);
3994 printf (_("Contents of the %s section:\n\n"), section
->name
);
3998 unsigned int lineno
, version
, flags
;
3999 unsigned int offset_size
= 4;
4000 const unsigned char *string
;
4001 dwarf_vma line_offset
= 0, sec_offset
= curr
- start
, offset
;
4002 unsigned char **extended_ops
= NULL
;
4004 SAFE_BYTE_GET_AND_INC (version
, curr
, 2, end
);
4007 error (_("Only GNU extension to DWARF 4 of %s is currently supported.\n"),
4012 SAFE_BYTE_GET_AND_INC (flags
, curr
, 1, end
);
4015 printf (_(" Offset: 0x%lx\n"),
4016 (unsigned long) sec_offset
);
4017 printf (_(" Version: %d\n"), version
);
4018 printf (_(" Offset size: %d\n"), offset_size
);
4021 SAFE_BYTE_GET_AND_INC (line_offset
, curr
, offset_size
, end
);
4022 printf (_(" Offset into .debug_line: 0x%lx\n"),
4023 (unsigned long) line_offset
);
4027 unsigned int i
, count
, op
;
4030 SAFE_BYTE_GET_AND_INC (count
, curr
, 1, end
);
4032 memset (extended_op_buf
, 0, sizeof (extended_op_buf
));
4033 extended_ops
= extended_op_buf
;
4036 printf (_(" Extension opcode arguments:\n"));
4037 for (i
= 0; i
< count
; i
++)
4039 SAFE_BYTE_GET_AND_INC (op
, curr
, 1, end
);
4040 extended_ops
[op
] = curr
;
4041 nargs
= read_uleb128 (curr
, &bytes_read
, end
);
4044 printf (_(" DW_MACRO_GNU_%02x has no arguments\n"), op
);
4047 printf (_(" DW_MACRO_GNU_%02x arguments: "), op
);
4048 for (n
= 0; n
< nargs
; n
++)
4052 SAFE_BYTE_GET_AND_INC (form
, curr
, 1, end
);
4053 printf ("%s%s", get_FORM_name (form
),
4054 n
== nargs
- 1 ? "\n" : ", ");
4064 case DW_FORM_block1
:
4065 case DW_FORM_block2
:
4066 case DW_FORM_block4
:
4068 case DW_FORM_string
:
4070 case DW_FORM_sec_offset
:
4073 error (_("Invalid extension opcode form %s\n"),
4074 get_FORM_name (form
));
4090 error (_(".debug_macro section not zero terminated\n"));
4094 SAFE_BYTE_GET_AND_INC (op
, curr
, 1, end
);
4100 case DW_MACRO_GNU_start_file
:
4102 unsigned int filenum
;
4103 unsigned char *file_name
= NULL
, *dir_name
= NULL
;
4105 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4107 filenum
= read_uleb128 (curr
, &bytes_read
, end
);
4110 if ((flags
& 2) == 0)
4111 error (_("DW_MACRO_GNU_start_file used, but no .debug_line offset provided.\n"));
4114 = get_line_filename_and_dirname (line_offset
, filenum
,
4116 if (file_name
== NULL
)
4117 printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d\n"),
4120 printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d filename: %s%s%s\n"),
4122 dir_name
!= NULL
? (const char *) dir_name
: "",
4123 dir_name
!= NULL
? "/" : "", file_name
);
4127 case DW_MACRO_GNU_end_file
:
4128 printf (_(" DW_MACRO_GNU_end_file\n"));
4131 case DW_MACRO_GNU_define
:
4132 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4135 curr
+= strnlen ((char *) string
, end
- string
) + 1;
4136 printf (_(" DW_MACRO_GNU_define - lineno : %d macro : %s\n"),
4140 case DW_MACRO_GNU_undef
:
4141 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4144 curr
+= strnlen ((char *) string
, end
- string
) + 1;
4145 printf (_(" DW_MACRO_GNU_undef - lineno : %d macro : %s\n"),
4149 case DW_MACRO_GNU_define_indirect
:
4150 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4152 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
4153 string
= fetch_indirect_string (offset
);
4154 printf (_(" DW_MACRO_GNU_define_indirect - lineno : %d macro : %s\n"),
4158 case DW_MACRO_GNU_undef_indirect
:
4159 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4161 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
4162 string
= fetch_indirect_string (offset
);
4163 printf (_(" DW_MACRO_GNU_undef_indirect - lineno : %d macro : %s\n"),
4167 case DW_MACRO_GNU_transparent_include
:
4168 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
4169 printf (_(" DW_MACRO_GNU_transparent_include - offset : 0x%lx\n"),
4170 (unsigned long) offset
);
4173 case DW_MACRO_GNU_define_indirect_alt
:
4174 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4176 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
4177 printf (_(" DW_MACRO_GNU_define_indirect_alt - lineno : %d macro offset : 0x%lx\n"),
4178 lineno
, (unsigned long) offset
);
4181 case DW_MACRO_GNU_undef_indirect_alt
:
4182 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4184 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
4185 printf (_(" DW_MACRO_GNU_undef_indirect_alt - lineno : %d macro offset : 0x%lx\n"),
4186 lineno
, (unsigned long) offset
);
4189 case DW_MACRO_GNU_transparent_include_alt
:
4190 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
4191 printf (_(" DW_MACRO_GNU_transparent_include_alt - offset : 0x%lx\n"),
4192 (unsigned long) offset
);
4196 if (extended_ops
== NULL
|| extended_ops
[op
] == NULL
)
4198 error (_(" Unknown macro opcode %02x seen\n"), op
);
4203 /* Skip over unhandled opcodes. */
4205 unsigned char *desc
= extended_ops
[op
];
4206 nargs
= read_uleb128 (desc
, &bytes_read
, end
);
4210 printf (_(" DW_MACRO_GNU_%02x\n"), op
);
4213 printf (_(" DW_MACRO_GNU_%02x -"), op
);
4214 for (n
= 0; n
< nargs
; n
++)
4218 SAFE_BYTE_GET_AND_INC (val
, desc
, 1, end
);
4220 = read_and_display_attr_value (0, val
,
4221 curr
, end
, 0, 0, offset_size
,
4222 version
, NULL
, 0, NULL
,
4240 display_debug_abbrev (struct dwarf_section
*section
,
4241 void *file ATTRIBUTE_UNUSED
)
4243 abbrev_entry
*entry
;
4244 unsigned char *start
= section
->start
;
4245 unsigned char *end
= start
+ section
->size
;
4247 printf (_("Contents of the %s section:\n\n"), section
->name
);
4251 unsigned char *last
;
4256 start
= process_abbrev_section (start
, end
);
4258 if (first_abbrev
== NULL
)
4261 printf (_(" Number TAG (0x%lx)\n"), (long) (last
- section
->start
));
4263 for (entry
= first_abbrev
; entry
; entry
= entry
->next
)
4267 printf (" %ld %s [%s]\n",
4269 get_TAG_name (entry
->tag
),
4270 entry
->children
? _("has children") : _("no children"));
4272 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
4273 printf (" %-18s %s\n",
4274 get_AT_name (attr
->attribute
),
4275 get_FORM_name (attr
->form
));
4285 /* Display a location list from a normal (ie, non-dwo) .debug_loc section. */
4288 display_loc_list (struct dwarf_section
*section
,
4289 unsigned char **start_ptr
,
4290 unsigned int debug_info_entry
,
4291 unsigned long offset
,
4292 unsigned long base_address
,
4295 unsigned char *start
= *start_ptr
;
4296 unsigned char *section_end
= section
->start
+ section
->size
;
4297 unsigned long cu_offset
;
4298 unsigned int pointer_size
;
4299 unsigned int offset_size
;
4304 unsigned short length
;
4305 int need_frame_base
;
4307 if (debug_info_entry
>= num_debug_info_entries
)
4309 warn (_("No debug information available for loc lists of entry: %u\n"),
4314 cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
4315 pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
4316 offset_size
= debug_information
[debug_info_entry
].offset_size
;
4317 dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
4319 if (pointer_size
< 2 || pointer_size
> 8)
4321 warn (_("Invalid pointer size (%d) in debug info for entry %d\n"),
4322 pointer_size
, debug_info_entry
);
4328 if (start
+ 2 * pointer_size
> section_end
)
4330 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4335 printf (" %8.8lx ", offset
+ (start
- *start_ptr
));
4337 /* Note: we use sign extension here in order to be sure that we can detect
4338 the -1 escape value. Sign extension into the top 32 bits of a 32-bit
4339 address will not affect the values that we display since we always show
4340 hex values, and always the bottom 32-bits. */
4341 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, section_end
);
4342 SAFE_BYTE_GET_AND_INC (end
, start
, pointer_size
, section_end
);
4344 if (begin
== 0 && end
== 0)
4346 printf (_("<End of list>\n"));
4350 /* Check base address specifiers. */
4351 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
4354 print_dwarf_vma (begin
, pointer_size
);
4355 print_dwarf_vma (end
, pointer_size
);
4356 printf (_("(base address)\n"));
4360 if (start
+ 2 > section_end
)
4362 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4367 SAFE_BYTE_GET_AND_INC (length
, start
, 2, section_end
);
4369 if (start
+ length
> section_end
)
4371 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4376 print_dwarf_vma (begin
+ base_address
, pointer_size
);
4377 print_dwarf_vma (end
+ base_address
, pointer_size
);
4380 need_frame_base
= decode_location_expression (start
,
4385 cu_offset
, section
);
4388 if (need_frame_base
&& !has_frame_base
)
4389 printf (_(" [without DW_AT_frame_base]"));
4392 fputs (_(" (start == end)"), stdout
);
4393 else if (begin
> end
)
4394 fputs (_(" (start > end)"), stdout
);
4404 /* Print a .debug_addr table index in decimal, surrounded by square brackets,
4405 right-adjusted in a field of length LEN, and followed by a space. */
4408 print_addr_index (unsigned int idx
, unsigned int len
)
4410 static char buf
[15];
4411 snprintf (buf
, sizeof (buf
), "[%d]", idx
);
4412 printf ("%*s ", len
, buf
);
4415 /* Display a location list from a .dwo section. It uses address indexes rather
4416 than embedded addresses. This code closely follows display_loc_list, but the
4417 two are sufficiently different that combining things is very ugly. */
4420 display_loc_list_dwo (struct dwarf_section
*section
,
4421 unsigned char **start_ptr
,
4422 unsigned int debug_info_entry
,
4423 unsigned long offset
,
4426 unsigned char *start
= *start_ptr
;
4427 unsigned char *section_end
= section
->start
+ section
->size
;
4428 unsigned long cu_offset
;
4429 unsigned int pointer_size
;
4430 unsigned int offset_size
;
4433 unsigned short length
;
4434 int need_frame_base
;
4436 unsigned int bytes_read
;
4438 if (debug_info_entry
>= num_debug_info_entries
)
4440 warn (_("No debug information for loc lists of entry: %u\n"),
4445 cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
4446 pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
4447 offset_size
= debug_information
[debug_info_entry
].offset_size
;
4448 dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
4450 if (pointer_size
< 2 || pointer_size
> 8)
4452 warn (_("Invalid pointer size (%d) in debug info for entry %d\n"),
4453 pointer_size
, debug_info_entry
);
4459 printf (" %8.8lx ", offset
+ (start
- *start_ptr
));
4461 if (start
>= section_end
)
4463 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4468 SAFE_BYTE_GET_AND_INC (entry_type
, start
, 1, section_end
);
4471 case 0: /* A terminating entry. */
4473 printf (_("<End of list>\n"));
4475 case 1: /* A base-address entry. */
4476 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
4477 start
+= bytes_read
;
4478 print_addr_index (idx
, 8);
4480 printf (_("(base address selection entry)\n"));
4482 case 2: /* A start/end entry. */
4483 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
4484 start
+= bytes_read
;
4485 print_addr_index (idx
, 8);
4486 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
4487 start
+= bytes_read
;
4488 print_addr_index (idx
, 8);
4490 case 3: /* A start/length entry. */
4491 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
4492 start
+= bytes_read
;
4493 print_addr_index (idx
, 8);
4494 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
4495 printf ("%08x ", idx
);
4497 case 4: /* An offset pair entry. */
4498 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
4499 printf ("%08x ", idx
);
4500 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
4501 printf ("%08x ", idx
);
4504 warn (_("Unknown location list entry type 0x%x.\n"), entry_type
);
4509 if (start
+ 2 > section_end
)
4511 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4516 SAFE_BYTE_GET_AND_INC (length
, start
, 2, section_end
);
4517 if (start
+ length
> section_end
)
4519 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
4525 need_frame_base
= decode_location_expression (start
,
4530 cu_offset
, section
);
4533 if (need_frame_base
&& !has_frame_base
)
4534 printf (_(" [without DW_AT_frame_base]"));
4544 /* Sort array of indexes in ascending order of loc_offsets[idx]. */
4546 static dwarf_vma
*loc_offsets
;
4549 loc_offsets_compar (const void *ap
, const void *bp
)
4551 dwarf_vma a
= loc_offsets
[*(const unsigned int *) ap
];
4552 dwarf_vma b
= loc_offsets
[*(const unsigned int *) bp
];
4554 return (a
> b
) - (b
> a
);
4558 display_debug_loc (struct dwarf_section
*section
, void *file
)
4560 unsigned char *start
= section
->start
;
4561 unsigned long bytes
;
4562 unsigned char *section_begin
= start
;
4563 unsigned int num_loc_list
= 0;
4564 unsigned long last_offset
= 0;
4565 unsigned int first
= 0;
4569 int seen_first_offset
= 0;
4570 int locs_sorted
= 1;
4571 unsigned char *next
;
4572 unsigned int *array
= NULL
;
4573 const char *suffix
= strrchr (section
->name
, '.');
4576 if (suffix
&& strcmp (suffix
, ".dwo") == 0)
4579 bytes
= section
->size
;
4583 printf (_("\nThe %s section is empty.\n"), section
->name
);
4587 if (load_debug_info (file
) == 0)
4589 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4594 /* Check the order of location list in .debug_info section. If
4595 offsets of location lists are in the ascending order, we can
4596 use `debug_information' directly. */
4597 for (i
= 0; i
< num_debug_info_entries
; i
++)
4601 num
= debug_information
[i
].num_loc_offsets
;
4602 if (num
> num_loc_list
)
4605 /* Check if we can use `debug_information' directly. */
4606 if (locs_sorted
&& num
!= 0)
4608 if (!seen_first_offset
)
4610 /* This is the first location list. */
4611 last_offset
= debug_information
[i
].loc_offsets
[0];
4613 seen_first_offset
= 1;
4619 for (; j
< num
; j
++)
4622 debug_information
[i
].loc_offsets
[j
])
4627 last_offset
= debug_information
[i
].loc_offsets
[j
];
4632 if (!seen_first_offset
)
4633 error (_("No location lists in .debug_info section!\n"));
4635 if (debug_information
[first
].num_loc_offsets
> 0
4636 && debug_information
[first
].loc_offsets
[0] != 0)
4637 warn (_("Location lists in %s section start at 0x%s\n"),
4639 dwarf_vmatoa ("x", debug_information
[first
].loc_offsets
[0]));
4642 array
= (unsigned int *) xcmalloc (num_loc_list
, sizeof (unsigned int));
4643 printf (_("Contents of the %s section:\n\n"), section
->name
);
4644 printf (_(" Offset Begin End Expression\n"));
4646 seen_first_offset
= 0;
4647 for (i
= first
; i
< num_debug_info_entries
; i
++)
4649 unsigned long offset
;
4650 unsigned long base_address
;
4655 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
4657 loc_offsets
= debug_information
[i
].loc_offsets
;
4658 qsort (array
, debug_information
[i
].num_loc_offsets
,
4659 sizeof (*array
), loc_offsets_compar
);
4662 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
4664 j
= locs_sorted
? k
: array
[k
];
4666 && debug_information
[i
].loc_offsets
[locs_sorted
4667 ? k
- 1 : array
[k
- 1]]
4668 == debug_information
[i
].loc_offsets
[j
])
4670 has_frame_base
= debug_information
[i
].have_frame_base
[j
];
4671 offset
= debug_information
[i
].loc_offsets
[j
];
4672 next
= section_begin
+ offset
;
4673 base_address
= debug_information
[i
].base_address
;
4675 if (!seen_first_offset
)
4676 seen_first_offset
= 1;
4680 warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"),
4681 (unsigned long) (start
- section_begin
),
4682 (unsigned long) (next
- section_begin
));
4683 else if (start
> next
)
4684 warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"),
4685 (unsigned long) (start
- section_begin
),
4686 (unsigned long) (next
- section_begin
));
4690 if (offset
>= bytes
)
4692 warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"),
4698 display_loc_list_dwo (section
, &start
, i
, offset
, has_frame_base
);
4700 display_loc_list (section
, &start
, i
, offset
, base_address
,
4705 if (start
< section
->start
+ section
->size
)
4706 warn (_("There are %ld unused bytes at the end of section %s\n"),
4707 (long) (section
->start
+ section
->size
- start
), section
->name
);
4714 display_debug_str (struct dwarf_section
*section
,
4715 void *file ATTRIBUTE_UNUSED
)
4717 unsigned char *start
= section
->start
;
4718 unsigned long bytes
= section
->size
;
4719 dwarf_vma addr
= section
->address
;
4723 printf (_("\nThe %s section is empty.\n"), section
->name
);
4727 printf (_("Contents of the %s section:\n\n"), section
->name
);
4735 lbytes
= (bytes
> 16 ? 16 : bytes
);
4737 printf (" 0x%8.8lx ", (unsigned long) addr
);
4739 for (j
= 0; j
< 16; j
++)
4742 printf ("%2.2x", start
[j
]);
4750 for (j
= 0; j
< lbytes
; j
++)
4753 if (k
>= ' ' && k
< 0x80)
4772 display_debug_info (struct dwarf_section
*section
, void *file
)
4774 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 0);
4778 display_debug_types (struct dwarf_section
*section
, void *file
)
4780 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 1);
4784 display_trace_info (struct dwarf_section
*section
, void *file
)
4786 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 0);
4790 display_debug_aranges (struct dwarf_section
*section
,
4791 void *file ATTRIBUTE_UNUSED
)
4793 unsigned char *start
= section
->start
;
4794 unsigned char *end
= start
+ section
->size
;
4796 printf (_("Contents of the %s section:\n\n"), section
->name
);
4798 /* It does not matter if this load fails,
4799 we test for that later on. */
4800 load_debug_info (file
);
4804 unsigned char *hdrptr
;
4805 DWARF2_Internal_ARange arange
;
4806 unsigned char *addr_ranges
;
4809 unsigned char address_size
;
4811 unsigned int offset_size
;
4812 unsigned int initial_length_size
;
4816 SAFE_BYTE_GET_AND_INC (arange
.ar_length
, hdrptr
, 4, end
);
4817 if (arange
.ar_length
== 0xffffffff)
4819 SAFE_BYTE_GET_AND_INC (arange
.ar_length
, hdrptr
, 8, end
);
4821 initial_length_size
= 12;
4826 initial_length_size
= 4;
4829 SAFE_BYTE_GET_AND_INC (arange
.ar_version
, hdrptr
, 2, end
);
4830 SAFE_BYTE_GET_AND_INC (arange
.ar_info_offset
, hdrptr
, offset_size
, end
);
4832 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
4833 && num_debug_info_entries
> 0
4834 && find_debug_info_for_offset (arange
.ar_info_offset
) == NULL
)
4835 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
4836 (unsigned long) arange
.ar_info_offset
, section
->name
);
4838 SAFE_BYTE_GET_AND_INC (arange
.ar_pointer_size
, hdrptr
, 1, end
);
4839 SAFE_BYTE_GET_AND_INC (arange
.ar_segment_size
, hdrptr
, 1, end
);
4841 if (arange
.ar_version
!= 2 && arange
.ar_version
!= 3)
4843 warn (_("Only DWARF 2 and 3 aranges are currently supported.\n"));
4847 printf (_(" Length: %ld\n"),
4848 (long) arange
.ar_length
);
4849 printf (_(" Version: %d\n"), arange
.ar_version
);
4850 printf (_(" Offset into .debug_info: 0x%lx\n"),
4851 (unsigned long) arange
.ar_info_offset
);
4852 printf (_(" Pointer Size: %d\n"), arange
.ar_pointer_size
);
4853 printf (_(" Segment Size: %d\n"), arange
.ar_segment_size
);
4855 address_size
= arange
.ar_pointer_size
+ arange
.ar_segment_size
;
4857 /* PR 17512: file: 001-108546-0.001:0.1. */
4858 if (address_size
== 0 || address_size
> 8)
4860 error (_("Invalid address size in %s section!\n"),
4865 /* The DWARF spec does not require that the address size be a power
4866 of two, but we do. This will have to change if we ever encounter
4867 an uneven architecture. */
4868 if ((address_size
& (address_size
- 1)) != 0)
4870 warn (_("Pointer size + Segment size is not a power of two.\n"));
4874 if (address_size
> 4)
4875 printf (_("\n Address Length\n"));
4877 printf (_("\n Address Length\n"));
4879 addr_ranges
= hdrptr
;
4881 /* Must pad to an alignment boundary that is twice the address size. */
4882 excess
= (hdrptr
- start
) % (2 * address_size
);
4884 addr_ranges
+= (2 * address_size
) - excess
;
4886 start
+= arange
.ar_length
+ initial_length_size
;
4888 while (addr_ranges
+ 2 * address_size
<= start
)
4890 SAFE_BYTE_GET_AND_INC (address
, addr_ranges
, address_size
, end
);
4891 SAFE_BYTE_GET_AND_INC (length
, addr_ranges
, address_size
, end
);
4894 print_dwarf_vma (address
, address_size
);
4895 print_dwarf_vma (length
, address_size
);
4905 /* Comparison function for qsort. */
4907 comp_addr_base (const void * v0
, const void * v1
)
4909 debug_info
* info0
= (debug_info
*) v0
;
4910 debug_info
* info1
= (debug_info
*) v1
;
4911 return info0
->addr_base
- info1
->addr_base
;
4914 /* Display the debug_addr section. */
4916 display_debug_addr (struct dwarf_section
*section
,
4919 debug_info
**debug_addr_info
;
4920 unsigned char *entry
;
4925 if (section
->size
== 0)
4927 printf (_("\nThe %s section is empty.\n"), section
->name
);
4931 if (load_debug_info (file
) == 0)
4933 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
4938 printf (_("Contents of the %s section:\n\n"), section
->name
);
4940 /* PR 17531: file: cf38d01b.
4941 We use xcalloc because a corrupt file may not have initialised all of the
4942 fields in the debug_info structure, which means that the sort below might
4943 try to move uninitialised data. */
4944 debug_addr_info
= (debug_info
**) xcalloc ((num_debug_info_entries
+ 1),
4945 sizeof (debug_info
*));
4948 for (i
= 0; i
< num_debug_info_entries
; i
++)
4949 if (debug_information
[i
].addr_base
!= DEBUG_INFO_UNAVAILABLE
)
4951 /* PR 17531: file: cf38d01b. */
4952 if (debug_information
[i
].addr_base
>= section
->size
)
4953 warn (_("Corrupt address base (%lx) found in debug section %u\n"),
4954 (unsigned long) debug_information
[i
].addr_base
, i
);
4956 debug_addr_info
[count
++] = debug_information
+ i
;
4959 /* Add a sentinel to make iteration convenient. */
4960 debug_addr_info
[count
] = (debug_info
*) xmalloc (sizeof (debug_info
));
4961 debug_addr_info
[count
]->addr_base
= section
->size
;
4962 qsort (debug_addr_info
, count
, sizeof (debug_info
*), comp_addr_base
);
4964 for (i
= 0; i
< count
; i
++)
4967 unsigned int address_size
= debug_addr_info
[i
]->pointer_size
;
4969 printf (_(" For compilation unit at offset 0x%s:\n"),
4970 dwarf_vmatoa ("x", debug_addr_info
[i
]->cu_offset
));
4972 printf (_("\tIndex\tAddress\n"));
4973 entry
= section
->start
+ debug_addr_info
[i
]->addr_base
;
4974 end
= section
->start
+ debug_addr_info
[i
+ 1]->addr_base
;
4978 dwarf_vma base
= byte_get (entry
, address_size
);
4979 printf (_("\t%d:\t"), idx
);
4980 print_dwarf_vma (base
, address_size
);
4982 entry
+= address_size
;
4988 free (debug_addr_info
);
4992 /* Display the .debug_str_offsets and .debug_str_offsets.dwo sections. */
4994 display_debug_str_offsets (struct dwarf_section
*section
,
4995 void *file ATTRIBUTE_UNUSED
)
4997 if (section
->size
== 0)
4999 printf (_("\nThe %s section is empty.\n"), section
->name
);
5002 /* TODO: Dump the contents. This is made somewhat difficult by not knowing
5003 what the offset size is for this section. */
5007 /* Each debug_information[x].range_lists[y] gets this representation for
5008 sorting purposes. */
5012 /* The debug_information[x].range_lists[y] value. */
5013 unsigned long ranges_offset
;
5015 /* Original debug_information to find parameters of the data. */
5016 debug_info
*debug_info_p
;
5019 /* Sort struct range_entry in ascending order of its RANGES_OFFSET. */
5022 range_entry_compar (const void *ap
, const void *bp
)
5024 const struct range_entry
*a_re
= (const struct range_entry
*) ap
;
5025 const struct range_entry
*b_re
= (const struct range_entry
*) bp
;
5026 const unsigned long a
= a_re
->ranges_offset
;
5027 const unsigned long b
= b_re
->ranges_offset
;
5029 return (a
> b
) - (b
> a
);
5033 display_debug_ranges (struct dwarf_section
*section
,
5034 void *file ATTRIBUTE_UNUSED
)
5036 unsigned char *start
= section
->start
;
5037 unsigned char *last_start
= start
;
5038 unsigned long bytes
= section
->size
;
5039 unsigned char *section_begin
= start
;
5040 unsigned char *finish
= start
+ bytes
;
5041 unsigned int num_range_list
, i
;
5042 struct range_entry
*range_entries
, *range_entry_fill
;
5046 printf (_("\nThe %s section is empty.\n"), section
->name
);
5050 if (load_debug_info (file
) == 0)
5052 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
5058 for (i
= 0; i
< num_debug_info_entries
; i
++)
5059 num_range_list
+= debug_information
[i
].num_range_lists
;
5061 if (num_range_list
== 0)
5063 /* This can happen when the file was compiled with -gsplit-debug
5064 which removes references to range lists from the primary .o file. */
5065 printf (_("No range lists in .debug_info section.\n"));
5069 range_entries
= (struct range_entry
*)
5070 xmalloc (sizeof (*range_entries
) * num_range_list
);
5071 range_entry_fill
= range_entries
;
5073 for (i
= 0; i
< num_debug_info_entries
; i
++)
5075 debug_info
*debug_info_p
= &debug_information
[i
];
5078 for (j
= 0; j
< debug_info_p
->num_range_lists
; j
++)
5080 range_entry_fill
->ranges_offset
= debug_info_p
->range_lists
[j
];
5081 range_entry_fill
->debug_info_p
= debug_info_p
;
5086 qsort (range_entries
, num_range_list
, sizeof (*range_entries
),
5087 range_entry_compar
);
5089 if (dwarf_check
!= 0 && range_entries
[0].ranges_offset
!= 0)
5090 warn (_("Range lists in %s section start at 0x%lx\n"),
5091 section
->name
, range_entries
[0].ranges_offset
);
5093 printf (_("Contents of the %s section:\n\n"), section
->name
);
5094 printf (_(" Offset Begin End\n"));
5096 for (i
= 0; i
< num_range_list
; i
++)
5098 struct range_entry
*range_entry
= &range_entries
[i
];
5099 debug_info
*debug_info_p
= range_entry
->debug_info_p
;
5100 unsigned int pointer_size
;
5101 unsigned long offset
;
5102 unsigned char *next
;
5103 unsigned long base_address
;
5105 pointer_size
= debug_info_p
->pointer_size
;
5106 offset
= range_entry
->ranges_offset
;
5107 next
= section_begin
+ offset
;
5108 base_address
= debug_info_p
->base_address
;
5110 /* PR 17512: file: 001-101485-0.001:0.1. */
5111 if (pointer_size
< 2 || pointer_size
> 8)
5113 warn (_("Corrupt pointer size (%d) in debug entry at offset %8.8lx\n"),
5114 pointer_size
, offset
);
5118 if (dwarf_check
!= 0 && i
> 0)
5121 warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"),
5122 (unsigned long) (start
- section_begin
),
5123 (unsigned long) (next
- section_begin
), section
->name
);
5124 else if (start
> next
)
5126 if (next
== last_start
)
5128 warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"),
5129 (unsigned long) (start
- section_begin
),
5130 (unsigned long) (next
- section_begin
), section
->name
);
5136 while (start
< finish
)
5141 /* Note: we use sign extension here in order to be sure that
5142 we can detect the -1 escape value. Sign extension into the
5143 top 32 bits of a 32-bit address will not affect the values
5144 that we display since we always show hex values, and always
5145 the bottom 32-bits. */
5146 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, finish
);
5147 if (start
>= finish
)
5149 SAFE_SIGNED_BYTE_GET_AND_INC (end
, start
, pointer_size
, finish
);
5151 printf (" %8.8lx ", offset
);
5153 if (begin
== 0 && end
== 0)
5155 printf (_("<End of list>\n"));
5159 /* Check base address specifiers. */
5160 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
5163 print_dwarf_vma (begin
, pointer_size
);
5164 print_dwarf_vma (end
, pointer_size
);
5165 printf ("(base address)\n");
5169 print_dwarf_vma (begin
+ base_address
, pointer_size
);
5170 print_dwarf_vma (end
+ base_address
, pointer_size
);
5173 fputs (_("(start == end)"), stdout
);
5174 else if (begin
> end
)
5175 fputs (_("(start > end)"), stdout
);
5182 free (range_entries
);
5187 typedef struct Frame_Chunk
5189 struct Frame_Chunk
*next
;
5190 unsigned char *chunk_start
;
5192 /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
5193 short int *col_type
;
5196 unsigned int code_factor
;
5203 unsigned char fde_encoding
;
5204 unsigned char cfa_exp
;
5205 unsigned char ptr_size
;
5206 unsigned char segment_size
;
5210 static const char *const *dwarf_regnames
;
5211 static unsigned int dwarf_regnames_count
;
5213 /* A marker for a col_type that means this column was never referenced
5214 in the frame info. */
5215 #define DW_CFA_unreferenced (-1)
5217 /* Return 0 if no more space is needed, 1 if more space is needed,
5218 -1 for invalid reg. */
5221 frame_need_space (Frame_Chunk
*fc
, unsigned int reg
)
5223 unsigned int prev
= fc
->ncols
;
5225 if (reg
< (unsigned int) fc
->ncols
)
5228 if (dwarf_regnames_count
5229 && reg
> dwarf_regnames_count
)
5232 fc
->ncols
= reg
+ 1;
5233 /* PR 17512: file: 10450-2643-0.004.
5234 If reg == -1 then this can happen... */
5238 /* PR 17512: file: 2844a11d. */
5239 if (fc
->ncols
> 1024)
5241 error (_("Unfeasibly large register number: %u\n"), reg
);
5243 /* FIXME: 1024 is an arbitrary limit. Increase it if
5244 we ever encounter a valid binary that exceeds it. */
5248 fc
->col_type
= (short int *) xcrealloc (fc
->col_type
, fc
->ncols
,
5249 sizeof (short int));
5250 fc
->col_offset
= (int *) xcrealloc (fc
->col_offset
, fc
->ncols
, sizeof (int));
5251 /* PR 17512: file:002-10025-0.005. */
5252 if (fc
->col_type
== NULL
|| fc
->col_offset
== NULL
)
5254 error (_("Out of memory allocating %u columns in dwarf frame arrays\n"),
5260 while (prev
< fc
->ncols
)
5262 fc
->col_type
[prev
] = DW_CFA_unreferenced
;
5263 fc
->col_offset
[prev
] = 0;
5269 static const char *const dwarf_regnames_i386
[] =
5271 "eax", "ecx", "edx", "ebx", /* 0 - 3 */
5272 "esp", "ebp", "esi", "edi", /* 4 - 7 */
5273 "eip", "eflags", NULL
, /* 8 - 10 */
5274 "st0", "st1", "st2", "st3", /* 11 - 14 */
5275 "st4", "st5", "st6", "st7", /* 15 - 18 */
5276 NULL
, NULL
, /* 19 - 20 */
5277 "xmm0", "xmm1", "xmm2", "xmm3", /* 21 - 24 */
5278 "xmm4", "xmm5", "xmm6", "xmm7", /* 25 - 28 */
5279 "mm0", "mm1", "mm2", "mm3", /* 29 - 32 */
5280 "mm4", "mm5", "mm6", "mm7", /* 33 - 36 */
5281 "fcw", "fsw", "mxcsr", /* 37 - 39 */
5282 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
, /* 40 - 47 */
5283 "tr", "ldtr", /* 48 - 49 */
5284 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 50 - 57 */
5285 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 58 - 65 */
5286 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 66 - 73 */
5287 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 74 - 81 */
5288 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 82 - 89 */
5289 NULL
, NULL
, NULL
, /* 90 - 92 */
5290 "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7" /* 93 - 100 */
5294 init_dwarf_regnames_i386 (void)
5296 dwarf_regnames
= dwarf_regnames_i386
;
5297 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_i386
);
5300 static const char *const dwarf_regnames_x86_64
[] =
5302 "rax", "rdx", "rcx", "rbx",
5303 "rsi", "rdi", "rbp", "rsp",
5304 "r8", "r9", "r10", "r11",
5305 "r12", "r13", "r14", "r15",
5307 "xmm0", "xmm1", "xmm2", "xmm3",
5308 "xmm4", "xmm5", "xmm6", "xmm7",
5309 "xmm8", "xmm9", "xmm10", "xmm11",
5310 "xmm12", "xmm13", "xmm14", "xmm15",
5311 "st0", "st1", "st2", "st3",
5312 "st4", "st5", "st6", "st7",
5313 "mm0", "mm1", "mm2", "mm3",
5314 "mm4", "mm5", "mm6", "mm7",
5316 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
5317 "fs.base", "gs.base", NULL
, NULL
,
5319 "mxcsr", "fcw", "fsw",
5320 "xmm16", "xmm17", "xmm18", "xmm19",
5321 "xmm20", "xmm21", "xmm22", "xmm23",
5322 "xmm24", "xmm25", "xmm26", "xmm27",
5323 "xmm28", "xmm29", "xmm30", "xmm31",
5324 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 83 - 90 */
5325 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 91 - 98 */
5326 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 99 - 106 */
5327 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 107 - 114 */
5328 NULL
, NULL
, NULL
, /* 115 - 117 */
5329 "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7"
5333 init_dwarf_regnames_x86_64 (void)
5335 dwarf_regnames
= dwarf_regnames_x86_64
;
5336 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_x86_64
);
5339 static const char *const dwarf_regnames_aarch64
[] =
5341 "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7",
5342 "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15",
5343 "x16", "x17", "x18", "x19", "x20", "x21", "x22", "x23",
5344 "x24", "x25", "x26", "x27", "x28", "x29", "x30", "sp",
5345 NULL
, "elr", NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
5346 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
5347 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
5348 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
5349 "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7",
5350 "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15",
5351 "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23",
5352 "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
5356 init_dwarf_regnames_aarch64 (void)
5358 dwarf_regnames
= dwarf_regnames_aarch64
;
5359 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_aarch64
);
5363 init_dwarf_regnames (unsigned int e_machine
)
5369 init_dwarf_regnames_i386 ();
5375 init_dwarf_regnames_x86_64 ();
5379 init_dwarf_regnames_aarch64 ();
5388 regname (unsigned int regno
, int row
)
5390 static char reg
[64];
5392 && regno
< dwarf_regnames_count
5393 && dwarf_regnames
[regno
] != NULL
)
5396 return dwarf_regnames
[regno
];
5397 snprintf (reg
, sizeof (reg
), "r%d (%s)", regno
,
5398 dwarf_regnames
[regno
]);
5401 snprintf (reg
, sizeof (reg
), "r%d", regno
);
5406 frame_display_row (Frame_Chunk
*fc
, int *need_col_headers
, unsigned int *max_regs
)
5411 if (*max_regs
< fc
->ncols
)
5412 *max_regs
= fc
->ncols
;
5414 if (*need_col_headers
)
5416 static const char *sloc
= " LOC";
5418 *need_col_headers
= 0;
5420 printf ("%-*s CFA ", eh_addr_size
* 2, sloc
);
5422 for (r
= 0; r
< *max_regs
; r
++)
5423 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
5428 printf ("%-5s ", regname (r
, 1));
5434 print_dwarf_vma (fc
->pc_begin
, eh_addr_size
);
5436 strcpy (tmp
, "exp");
5438 sprintf (tmp
, "%s%+d", regname (fc
->cfa_reg
, 1), fc
->cfa_offset
);
5439 printf ("%-8s ", tmp
);
5441 for (r
= 0; r
< fc
->ncols
; r
++)
5443 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
5445 switch (fc
->col_type
[r
])
5447 case DW_CFA_undefined
:
5450 case DW_CFA_same_value
:
5454 sprintf (tmp
, "c%+d", fc
->col_offset
[r
]);
5456 case DW_CFA_val_offset
:
5457 sprintf (tmp
, "v%+d", fc
->col_offset
[r
]);
5459 case DW_CFA_register
:
5460 sprintf (tmp
, "%s", regname (fc
->col_offset
[r
], 0));
5462 case DW_CFA_expression
:
5463 strcpy (tmp
, "exp");
5465 case DW_CFA_val_expression
:
5466 strcpy (tmp
, "vexp");
5469 strcpy (tmp
, "n/a");
5472 printf ("%-5s ", tmp
);
5478 #define GET(VAR, N) SAFE_BYTE_GET_AND_INC (VAR, start, N, end)
5479 #define LEB() read_uleb128 (start, & length_return, end); start += length_return
5480 #define SLEB() read_sleb128 (start, & length_return, end); start += length_return
5482 static unsigned char *
5483 read_cie (unsigned char *start
, unsigned char *end
,
5484 Frame_Chunk
**p_cie
, int *p_version
,
5485 unsigned long *p_aug_len
, unsigned char **p_aug
)
5489 unsigned int length_return
;
5490 unsigned char *augmentation_data
= NULL
;
5491 unsigned long augmentation_data_len
= 0;
5494 /* PR 17512: file: 001-228113-0.004. */
5498 fc
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
5499 memset (fc
, 0, sizeof (Frame_Chunk
));
5501 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
5502 fc
->col_offset
= (int *) xmalloc (sizeof (int));
5506 fc
->augmentation
= (char *) start
;
5507 /* PR 17512: file: 001-228113-0.004.
5508 Skip past augmentation name, but avoid running off the end of the data. */
5510 if (* start
++ == '\0')
5514 warn (_("No terminator for augmentation name\n"));
5518 if (strcmp (fc
->augmentation
, "eh") == 0)
5519 start
+= eh_addr_size
;
5523 GET (fc
->ptr_size
, 1);
5524 GET (fc
->segment_size
, 1);
5525 eh_addr_size
= fc
->ptr_size
;
5529 fc
->ptr_size
= eh_addr_size
;
5530 fc
->segment_size
= 0;
5532 fc
->code_factor
= LEB ();
5533 fc
->data_factor
= SLEB ();
5543 if (fc
->augmentation
[0] == 'z')
5545 augmentation_data_len
= LEB ();
5546 augmentation_data
= start
;
5547 start
+= augmentation_data_len
;
5548 /* PR 17512: file: 11042-2589-0.004. */
5551 warn (_("Augmentation data too long: 0x%lx\n"), augmentation_data_len
);
5556 if (augmentation_data_len
)
5560 unsigned char *qend
;
5562 p
= (unsigned char *) fc
->augmentation
+ 1;
5563 q
= augmentation_data
;
5564 qend
= q
+ augmentation_data_len
;
5566 /* PR 17531: file: 015adfaa. */
5569 warn (_("Negative augmentation data length: 0x%lx"), augmentation_data_len
);
5570 augmentation_data_len
= 0;
5573 while (p
< end
&& q
< augmentation_data
+ augmentation_data_len
)
5578 q
+= 1 + size_of_encoded_value (*q
);
5580 fc
->fde_encoding
= *q
++;
5587 /* Note - it is OK if this loop terminates with q < qend.
5588 Padding may have been inserted to align the end of the CIE. */
5593 *p_version
= version
;
5596 *p_aug_len
= augmentation_data_len
;
5597 *p_aug
= augmentation_data
;
5603 display_debug_frames (struct dwarf_section
*section
,
5604 void *file ATTRIBUTE_UNUSED
)
5606 unsigned char *start
= section
->start
;
5607 unsigned char *end
= start
+ section
->size
;
5608 unsigned char *section_start
= start
;
5609 Frame_Chunk
*chunks
= 0, *forward_refs
= 0;
5610 Frame_Chunk
*remembered_state
= 0;
5612 int is_eh
= strcmp (section
->name
, ".eh_frame") == 0;
5613 unsigned int length_return
;
5614 unsigned int max_regs
= 0;
5615 const char *bad_reg
= _("bad register: ");
5616 int saved_eh_addr_size
= eh_addr_size
;
5618 printf (_("Contents of the %s section:\n"), section
->name
);
5622 unsigned char *saved_start
;
5623 unsigned char *block_end
;
5628 int need_col_headers
= 1;
5629 unsigned char *augmentation_data
= NULL
;
5630 unsigned long augmentation_data_len
= 0;
5631 unsigned int encoded_ptr_size
= saved_eh_addr_size
;
5632 unsigned int offset_size
;
5633 unsigned int initial_length_size
;
5635 saved_start
= start
;
5637 SAFE_BYTE_GET_AND_INC (length
, start
, 4, end
);
5641 printf ("\n%08lx ZERO terminator\n\n",
5642 (unsigned long)(saved_start
- section_start
));
5643 /* Skip any zero terminators that directly follow.
5644 A corrupt section size could have loaded a whole
5645 slew of zero filled memory bytes. eg
5646 PR 17512: file: 070-19381-0.004. */
5647 while (start
< end
&& * start
== 0)
5652 if (length
== 0xffffffff)
5654 SAFE_BYTE_GET_AND_INC (length
, start
, 8, end
);
5656 initial_length_size
= 12;
5661 initial_length_size
= 4;
5664 block_end
= saved_start
+ length
+ initial_length_size
;
5665 if (block_end
> end
|| block_end
< start
)
5667 warn ("Invalid length 0x%s in FDE at %#08lx\n",
5668 dwarf_vmatoa_1 (NULL
, length
, offset_size
),
5669 (unsigned long) (saved_start
- section_start
));
5673 SAFE_BYTE_GET_AND_INC (cie_id
, start
, offset_size
, end
);
5675 if (is_eh
? (cie_id
== 0) : ((offset_size
== 4 && cie_id
== DW_CIE_ID
)
5676 || (offset_size
== 8 && cie_id
== DW64_CIE_ID
)))
5681 start
= read_cie (start
, end
, &cie
, &version
,
5682 &augmentation_data_len
, &augmentation_data
);
5683 /* PR 17512: file: 027-135133-0.005. */
5690 fc
->chunk_start
= saved_start
;
5691 mreg
= max_regs
> 0 ? max_regs
- 1 : 0;
5694 if (frame_need_space (fc
, mreg
) < 0)
5696 if (fc
->fde_encoding
)
5697 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
5699 printf ("\n%08lx ", (unsigned long) (saved_start
- section_start
));
5700 print_dwarf_vma (length
, fc
->ptr_size
);
5701 print_dwarf_vma (cie_id
, offset_size
);
5703 if (do_debug_frames_interp
)
5705 printf ("CIE \"%s\" cf=%d df=%d ra=%d\n", fc
->augmentation
,
5706 fc
->code_factor
, fc
->data_factor
, fc
->ra
);
5711 printf (" Version: %d\n", version
);
5712 printf (" Augmentation: \"%s\"\n", fc
->augmentation
);
5715 printf (" Pointer Size: %u\n", fc
->ptr_size
);
5716 printf (" Segment Size: %u\n", fc
->segment_size
);
5718 printf (" Code alignment factor: %u\n", fc
->code_factor
);
5719 printf (" Data alignment factor: %d\n", fc
->data_factor
);
5720 printf (" Return address column: %d\n", fc
->ra
);
5722 if (augmentation_data_len
)
5726 printf (" Augmentation data: ");
5727 for (i
= 0; i
< augmentation_data_len
; ++i
)
5728 /* FIXME: If do_wide is FALSE, then we should
5729 add carriage returns at 80 columns... */
5730 printf (" %02x", augmentation_data
[i
]);
5738 unsigned char *look_for
;
5739 static Frame_Chunk fde_fc
;
5740 unsigned long segment_selector
;
5744 dwarf_vma sign
= (dwarf_vma
) 1 << (offset_size
* 8 - 1);
5745 look_for
= start
- 4 - ((cie_id
^ sign
) - sign
);
5748 look_for
= section_start
+ cie_id
;
5750 if (look_for
<= saved_start
)
5752 for (cie
= chunks
; cie
; cie
= cie
->next
)
5753 if (cie
->chunk_start
== look_for
)
5758 for (cie
= forward_refs
; cie
; cie
= cie
->next
)
5759 if (cie
->chunk_start
== look_for
)
5763 unsigned int off_size
;
5764 unsigned char *cie_scan
;
5766 cie_scan
= look_for
;
5768 SAFE_BYTE_GET_AND_INC (length
, cie_scan
, 4, end
);
5769 if (length
== 0xffffffff)
5771 SAFE_BYTE_GET_AND_INC (length
, cie_scan
, 8, end
);
5778 SAFE_BYTE_GET_AND_INC (c_id
, cie_scan
, off_size
, end
);
5781 : ((off_size
== 4 && c_id
== DW_CIE_ID
)
5782 || (off_size
== 8 && c_id
== DW64_CIE_ID
)))
5787 read_cie (cie_scan
, end
, &cie
, &version
,
5788 &augmentation_data_len
, &augmentation_data
);
5789 /* PR 17512: file: 3450-2098-0.004. */
5792 warn (_("Failed to read CIE information\n"));
5795 cie
->next
= forward_refs
;
5797 cie
->chunk_start
= look_for
;
5798 mreg
= max_regs
> 0 ? max_regs
- 1 : 0;
5801 if (frame_need_space (cie
, mreg
) < 0)
5803 warn (_("Invalid max register\n"));
5806 if (cie
->fde_encoding
)
5808 = size_of_encoded_value (cie
->fde_encoding
);
5815 memset (fc
, 0, sizeof (Frame_Chunk
));
5819 warn ("Invalid CIE pointer 0x%s in FDE at %#08lx\n",
5820 dwarf_vmatoa_1 (NULL
, cie_id
, offset_size
),
5821 (unsigned long) (saved_start
- section_start
));
5823 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
5824 fc
->col_offset
= (int *) xmalloc (sizeof (int));
5825 if (frame_need_space (fc
, max_regs
> 0 ? max_regs
- 1 : 0) < 0)
5827 warn (_("Invalid max register\n"));
5831 fc
->augmentation
= "";
5832 fc
->fde_encoding
= 0;
5833 fc
->ptr_size
= eh_addr_size
;
5834 fc
->segment_size
= 0;
5838 fc
->ncols
= cie
->ncols
;
5839 fc
->col_type
= (short int *) xcmalloc (fc
->ncols
, sizeof (short int));
5840 fc
->col_offset
= (int *) xcmalloc (fc
->ncols
, sizeof (int));
5841 memcpy (fc
->col_type
, cie
->col_type
, fc
->ncols
* sizeof (short int));
5842 memcpy (fc
->col_offset
, cie
->col_offset
, fc
->ncols
* sizeof (int));
5843 fc
->augmentation
= cie
->augmentation
;
5844 fc
->ptr_size
= cie
->ptr_size
;
5845 eh_addr_size
= cie
->ptr_size
;
5846 fc
->segment_size
= cie
->segment_size
;
5847 fc
->code_factor
= cie
->code_factor
;
5848 fc
->data_factor
= cie
->data_factor
;
5849 fc
->cfa_reg
= cie
->cfa_reg
;
5850 fc
->cfa_offset
= cie
->cfa_offset
;
5852 if (frame_need_space (fc
, max_regs
> 0 ? max_regs
- 1: 0) < 0)
5854 warn (_("Invalid max register\n"));
5857 fc
->fde_encoding
= cie
->fde_encoding
;
5860 if (fc
->fde_encoding
)
5861 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
5863 segment_selector
= 0;
5864 if (fc
->segment_size
)
5865 SAFE_BYTE_GET_AND_INC (segment_selector
, start
, fc
->segment_size
, end
);
5867 fc
->pc_begin
= get_encoded_value (&start
, fc
->fde_encoding
, section
, end
);
5869 /* FIXME: It appears that sometimes the final pc_range value is
5870 encoded in less than encoded_ptr_size bytes. See the x86_64
5871 run of the "objcopy on compressed debug sections" test for an
5873 SAFE_BYTE_GET_AND_INC (fc
->pc_range
, start
, encoded_ptr_size
, end
);
5875 if (cie
->augmentation
[0] == 'z')
5877 augmentation_data_len
= LEB ();
5878 augmentation_data
= start
;
5879 start
+= augmentation_data_len
;
5880 /* PR 17512: file: 722-8446-0.004. */
5881 if (start
>= end
|| ((signed long) augmentation_data_len
) < 0)
5883 warn (_("Corrupt augmentation data length: %lx\n"),
5884 augmentation_data_len
);
5886 augmentation_data
= NULL
;
5887 augmentation_data_len
= 0;
5891 printf ("\n%08lx %s %s FDE cie=%08lx pc=",
5892 (unsigned long)(saved_start
- section_start
),
5893 dwarf_vmatoa_1 (NULL
, length
, fc
->ptr_size
),
5894 dwarf_vmatoa_1 (NULL
, cie_id
, offset_size
),
5895 (unsigned long)(cie
->chunk_start
- section_start
));
5897 if (fc
->segment_size
)
5898 printf ("%04lx:", segment_selector
);
5901 dwarf_vmatoa_1 (NULL
, fc
->pc_begin
, fc
->ptr_size
),
5902 dwarf_vmatoa_1 (NULL
, fc
->pc_begin
+ fc
->pc_range
, fc
->ptr_size
));
5904 if (! do_debug_frames_interp
&& augmentation_data_len
)
5908 printf (" Augmentation data: ");
5909 for (i
= 0; i
< augmentation_data_len
; ++i
)
5910 printf (" %02x", augmentation_data
[i
]);
5916 /* At this point, fc is the current chunk, cie (if any) is set, and
5917 we're about to interpret instructions for the chunk. */
5918 /* ??? At present we need to do this always, since this sizes the
5919 fc->col_type and fc->col_offset arrays, which we write into always.
5920 We should probably split the interpreted and non-interpreted bits
5921 into two different routines, since there's so much that doesn't
5922 really overlap between them. */
5923 if (1 || do_debug_frames_interp
)
5925 /* Start by making a pass over the chunk, allocating storage
5926 and taking note of what registers are used. */
5927 unsigned char *tmp
= start
;
5929 while (start
< block_end
)
5931 unsigned int reg
, op
, opa
;
5939 /* Warning: if you add any more cases to this switch, be
5940 sure to add them to the corresponding switch below. */
5943 case DW_CFA_advance_loc
:
5947 if (frame_need_space (fc
, opa
) >= 0)
5948 fc
->col_type
[opa
] = DW_CFA_undefined
;
5950 case DW_CFA_restore
:
5951 if (frame_need_space (fc
, opa
) >= 0)
5952 fc
->col_type
[opa
] = DW_CFA_undefined
;
5954 case DW_CFA_set_loc
:
5955 start
+= encoded_ptr_size
;
5957 case DW_CFA_advance_loc1
:
5960 case DW_CFA_advance_loc2
:
5963 case DW_CFA_advance_loc4
:
5966 case DW_CFA_offset_extended
:
5967 case DW_CFA_val_offset
:
5968 reg
= LEB (); LEB ();
5969 if (frame_need_space (fc
, reg
) >= 0)
5970 fc
->col_type
[reg
] = DW_CFA_undefined
;
5972 case DW_CFA_restore_extended
:
5974 if (frame_need_space (fc
, reg
) >= 0)
5975 fc
->col_type
[reg
] = DW_CFA_undefined
;
5977 case DW_CFA_undefined
:
5979 if (frame_need_space (fc
, reg
) >= 0)
5980 fc
->col_type
[reg
] = DW_CFA_undefined
;
5982 case DW_CFA_same_value
:
5984 if (frame_need_space (fc
, reg
) >= 0)
5985 fc
->col_type
[reg
] = DW_CFA_undefined
;
5987 case DW_CFA_register
:
5988 reg
= LEB (); LEB ();
5989 if (frame_need_space (fc
, reg
) >= 0)
5990 fc
->col_type
[reg
] = DW_CFA_undefined
;
5992 case DW_CFA_def_cfa
:
5995 case DW_CFA_def_cfa_register
:
5998 case DW_CFA_def_cfa_offset
:
6001 case DW_CFA_def_cfa_expression
:
6003 if (start
+ temp
< start
)
6005 warn (_("Corrupt CFA_def expression value: %lu\n"), temp
);
6011 case DW_CFA_expression
:
6012 case DW_CFA_val_expression
:
6015 if (start
+ temp
< start
)
6017 /* PR 17512: file:306-192417-0.005. */
6018 warn (_("Corrupt CFA expression value: %lu\n"), temp
);
6023 if (frame_need_space (fc
, reg
) >= 0)
6024 fc
->col_type
[reg
] = DW_CFA_undefined
;
6026 case DW_CFA_offset_extended_sf
:
6027 case DW_CFA_val_offset_sf
:
6028 reg
= LEB (); SLEB ();
6029 if (frame_need_space (fc
, reg
) >= 0)
6030 fc
->col_type
[reg
] = DW_CFA_undefined
;
6032 case DW_CFA_def_cfa_sf
:
6035 case DW_CFA_def_cfa_offset_sf
:
6038 case DW_CFA_MIPS_advance_loc8
:
6041 case DW_CFA_GNU_args_size
:
6044 case DW_CFA_GNU_negative_offset_extended
:
6045 reg
= LEB (); LEB ();
6046 if (frame_need_space (fc
, reg
) >= 0)
6047 fc
->col_type
[reg
] = DW_CFA_undefined
;
6056 /* Now we know what registers are used, make a second pass over
6057 the chunk, this time actually printing out the info. */
6059 while (start
< block_end
)
6062 unsigned long ul
, reg
, roffs
;
6066 const char *reg_prefix
= "";
6073 /* Warning: if you add any more cases to this switch, be
6074 sure to add them to the corresponding switch above. */
6077 case DW_CFA_advance_loc
:
6078 if (do_debug_frames_interp
)
6079 frame_display_row (fc
, &need_col_headers
, &max_regs
);
6081 printf (" DW_CFA_advance_loc: %d to %s\n",
6082 opa
* fc
->code_factor
,
6083 dwarf_vmatoa_1 (NULL
,
6084 fc
->pc_begin
+ opa
* fc
->code_factor
,
6086 fc
->pc_begin
+= opa
* fc
->code_factor
;
6091 if (opa
>= (unsigned int) fc
->ncols
)
6092 reg_prefix
= bad_reg
;
6093 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
6094 printf (" DW_CFA_offset: %s%s at cfa%+ld\n",
6095 reg_prefix
, regname (opa
, 0),
6096 roffs
* fc
->data_factor
);
6097 if (*reg_prefix
== '\0')
6099 fc
->col_type
[opa
] = DW_CFA_offset
;
6100 fc
->col_offset
[opa
] = roffs
* fc
->data_factor
;
6104 case DW_CFA_restore
:
6105 if (opa
>= (unsigned int) cie
->ncols
6106 || opa
>= (unsigned int) fc
->ncols
)
6107 reg_prefix
= bad_reg
;
6108 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
6109 printf (" DW_CFA_restore: %s%s\n",
6110 reg_prefix
, regname (opa
, 0));
6111 if (*reg_prefix
== '\0')
6113 fc
->col_type
[opa
] = cie
->col_type
[opa
];
6114 fc
->col_offset
[opa
] = cie
->col_offset
[opa
];
6115 if (do_debug_frames_interp
6116 && fc
->col_type
[opa
] == DW_CFA_unreferenced
)
6117 fc
->col_type
[opa
] = DW_CFA_undefined
;
6121 case DW_CFA_set_loc
:
6122 vma
= get_encoded_value (&start
, fc
->fde_encoding
, section
, block_end
);
6123 if (do_debug_frames_interp
)
6124 frame_display_row (fc
, &need_col_headers
, &max_regs
);
6126 printf (" DW_CFA_set_loc: %s\n",
6127 dwarf_vmatoa_1 (NULL
, vma
, fc
->ptr_size
));
6131 case DW_CFA_advance_loc1
:
6132 SAFE_BYTE_GET_AND_INC (ofs
, start
, 1, end
);
6133 if (do_debug_frames_interp
)
6134 frame_display_row (fc
, &need_col_headers
, &max_regs
);
6136 printf (" DW_CFA_advance_loc1: %ld to %s\n",
6137 (unsigned long) (ofs
* fc
->code_factor
),
6138 dwarf_vmatoa_1 (NULL
,
6139 fc
->pc_begin
+ ofs
* fc
->code_factor
,
6141 fc
->pc_begin
+= ofs
* fc
->code_factor
;
6144 case DW_CFA_advance_loc2
:
6145 SAFE_BYTE_GET_AND_INC (ofs
, start
, 2, block_end
);
6146 if (do_debug_frames_interp
)
6147 frame_display_row (fc
, &need_col_headers
, &max_regs
);
6149 printf (" DW_CFA_advance_loc2: %ld to %s\n",
6150 (unsigned long) (ofs
* fc
->code_factor
),
6151 dwarf_vmatoa_1 (NULL
,
6152 fc
->pc_begin
+ ofs
* fc
->code_factor
,
6154 fc
->pc_begin
+= ofs
* fc
->code_factor
;
6157 case DW_CFA_advance_loc4
:
6158 SAFE_BYTE_GET_AND_INC (ofs
, start
, 4, block_end
);
6159 if (do_debug_frames_interp
)
6160 frame_display_row (fc
, &need_col_headers
, &max_regs
);
6162 printf (" DW_CFA_advance_loc4: %ld to %s\n",
6163 (unsigned long) (ofs
* fc
->code_factor
),
6164 dwarf_vmatoa_1 (NULL
,
6165 fc
->pc_begin
+ ofs
* fc
->code_factor
,
6167 fc
->pc_begin
+= ofs
* fc
->code_factor
;
6170 case DW_CFA_offset_extended
:
6173 if (reg
>= (unsigned int) fc
->ncols
)
6174 reg_prefix
= bad_reg
;
6175 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
6176 printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n",
6177 reg_prefix
, regname (reg
, 0),
6178 roffs
* fc
->data_factor
);
6179 if (*reg_prefix
== '\0')
6181 fc
->col_type
[reg
] = DW_CFA_offset
;
6182 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
6186 case DW_CFA_val_offset
:
6189 if (reg
>= (unsigned int) fc
->ncols
)
6190 reg_prefix
= bad_reg
;
6191 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
6192 printf (" DW_CFA_val_offset: %s%s at cfa%+ld\n",
6193 reg_prefix
, regname (reg
, 0),
6194 roffs
* fc
->data_factor
);
6195 if (*reg_prefix
== '\0')
6197 fc
->col_type
[reg
] = DW_CFA_val_offset
;
6198 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
6202 case DW_CFA_restore_extended
:
6204 if (reg
>= (unsigned int) cie
->ncols
6205 || reg
>= (unsigned int) fc
->ncols
)
6206 reg_prefix
= bad_reg
;
6207 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
6208 printf (" DW_CFA_restore_extended: %s%s\n",
6209 reg_prefix
, regname (reg
, 0));
6210 if (*reg_prefix
== '\0')
6212 fc
->col_type
[reg
] = cie
->col_type
[reg
];
6213 fc
->col_offset
[reg
] = cie
->col_offset
[reg
];
6217 case DW_CFA_undefined
:
6219 if (reg
>= (unsigned int) fc
->ncols
)
6220 reg_prefix
= bad_reg
;
6221 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
6222 printf (" DW_CFA_undefined: %s%s\n",
6223 reg_prefix
, regname (reg
, 0));
6224 if (*reg_prefix
== '\0')
6226 fc
->col_type
[reg
] = DW_CFA_undefined
;
6227 fc
->col_offset
[reg
] = 0;
6231 case DW_CFA_same_value
:
6233 if (reg
>= (unsigned int) fc
->ncols
)
6234 reg_prefix
= bad_reg
;
6235 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
6236 printf (" DW_CFA_same_value: %s%s\n",
6237 reg_prefix
, regname (reg
, 0));
6238 if (*reg_prefix
== '\0')
6240 fc
->col_type
[reg
] = DW_CFA_same_value
;
6241 fc
->col_offset
[reg
] = 0;
6245 case DW_CFA_register
:
6248 if (reg
>= (unsigned int) fc
->ncols
)
6249 reg_prefix
= bad_reg
;
6250 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
6252 printf (" DW_CFA_register: %s%s in ",
6253 reg_prefix
, regname (reg
, 0));
6254 puts (regname (roffs
, 0));
6256 if (*reg_prefix
== '\0')
6258 fc
->col_type
[reg
] = DW_CFA_register
;
6259 fc
->col_offset
[reg
] = roffs
;
6263 case DW_CFA_remember_state
:
6264 if (! do_debug_frames_interp
)
6265 printf (" DW_CFA_remember_state\n");
6266 rs
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
6267 rs
->cfa_offset
= fc
->cfa_offset
;
6268 rs
->cfa_reg
= fc
->cfa_reg
;
6270 rs
->cfa_exp
= fc
->cfa_exp
;
6271 rs
->ncols
= fc
->ncols
;
6272 rs
->col_type
= (short int *) xcmalloc (rs
->ncols
,
6273 sizeof (* rs
->col_type
));
6274 rs
->col_offset
= (int *) xcmalloc (rs
->ncols
, sizeof (* rs
->col_offset
));
6275 memcpy (rs
->col_type
, fc
->col_type
, rs
->ncols
* sizeof (* fc
->col_type
));
6276 memcpy (rs
->col_offset
, fc
->col_offset
, rs
->ncols
* sizeof (* fc
->col_offset
));
6277 rs
->next
= remembered_state
;
6278 remembered_state
= rs
;
6281 case DW_CFA_restore_state
:
6282 if (! do_debug_frames_interp
)
6283 printf (" DW_CFA_restore_state\n");
6284 rs
= remembered_state
;
6287 remembered_state
= rs
->next
;
6288 fc
->cfa_offset
= rs
->cfa_offset
;
6289 fc
->cfa_reg
= rs
->cfa_reg
;
6291 fc
->cfa_exp
= rs
->cfa_exp
;
6292 if (frame_need_space (fc
, rs
->ncols
- 1) < 0)
6294 warn (_("Invalid column number in saved frame state\n"));
6298 memcpy (fc
->col_type
, rs
->col_type
, rs
->ncols
* sizeof (* rs
->col_type
));
6299 memcpy (fc
->col_offset
, rs
->col_offset
,
6300 rs
->ncols
* sizeof (* rs
->col_offset
));
6301 free (rs
->col_type
);
6302 free (rs
->col_offset
);
6305 else if (do_debug_frames_interp
)
6306 printf ("Mismatched DW_CFA_restore_state\n");
6309 case DW_CFA_def_cfa
:
6310 fc
->cfa_reg
= LEB ();
6311 fc
->cfa_offset
= LEB ();
6313 if (! do_debug_frames_interp
)
6314 printf (" DW_CFA_def_cfa: %s ofs %d\n",
6315 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
6318 case DW_CFA_def_cfa_register
:
6319 fc
->cfa_reg
= LEB ();
6321 if (! do_debug_frames_interp
)
6322 printf (" DW_CFA_def_cfa_register: %s\n",
6323 regname (fc
->cfa_reg
, 0));
6326 case DW_CFA_def_cfa_offset
:
6327 fc
->cfa_offset
= LEB ();
6328 if (! do_debug_frames_interp
)
6329 printf (" DW_CFA_def_cfa_offset: %d\n", fc
->cfa_offset
);
6333 if (! do_debug_frames_interp
)
6334 printf (" DW_CFA_nop\n");
6337 case DW_CFA_def_cfa_expression
:
6339 if (start
>= block_end
|| start
+ ul
> block_end
|| start
+ ul
< start
)
6341 printf (_(" DW_CFA_def_cfa_expression: <corrupt len %lu>\n"), ul
);
6344 if (! do_debug_frames_interp
)
6346 printf (" DW_CFA_def_cfa_expression (");
6347 decode_location_expression (start
, eh_addr_size
, 0, -1,
6355 case DW_CFA_expression
:
6358 if (reg
>= (unsigned int) fc
->ncols
)
6359 reg_prefix
= bad_reg
;
6360 /* PR 17512: file: 069-133014-0.006. */
6361 /* PR 17512: file: 98c02eb4. */
6362 if (start
>= block_end
|| start
+ ul
> block_end
|| start
+ ul
< start
)
6364 printf (_(" DW_CFA_expression: <corrupt len %lu>\n"), ul
);
6367 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
6369 printf (" DW_CFA_expression: %s%s (",
6370 reg_prefix
, regname (reg
, 0));
6371 decode_location_expression (start
, eh_addr_size
, 0, -1,
6375 if (*reg_prefix
== '\0')
6376 fc
->col_type
[reg
] = DW_CFA_expression
;
6380 case DW_CFA_val_expression
:
6383 if (reg
>= (unsigned int) fc
->ncols
)
6384 reg_prefix
= bad_reg
;
6385 if (start
>= block_end
|| start
+ ul
> block_end
|| start
+ ul
< start
)
6387 printf (" DW_CFA_val_expression: <corrupt len %lu>\n", ul
);
6390 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
6392 printf (" DW_CFA_val_expression: %s%s (",
6393 reg_prefix
, regname (reg
, 0));
6394 decode_location_expression (start
, eh_addr_size
, 0, -1,
6398 if (*reg_prefix
== '\0')
6399 fc
->col_type
[reg
] = DW_CFA_val_expression
;
6403 case DW_CFA_offset_extended_sf
:
6406 if (frame_need_space (fc
, reg
) < 0)
6407 reg_prefix
= bad_reg
;
6408 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
6409 printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n",
6410 reg_prefix
, regname (reg
, 0),
6411 l
* fc
->data_factor
);
6412 if (*reg_prefix
== '\0')
6414 fc
->col_type
[reg
] = DW_CFA_offset
;
6415 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
6419 case DW_CFA_val_offset_sf
:
6422 if (frame_need_space (fc
, reg
) < 0)
6423 reg_prefix
= bad_reg
;
6424 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
6425 printf (" DW_CFA_val_offset_sf: %s%s at cfa%+ld\n",
6426 reg_prefix
, regname (reg
, 0),
6427 l
* fc
->data_factor
);
6428 if (*reg_prefix
== '\0')
6430 fc
->col_type
[reg
] = DW_CFA_val_offset
;
6431 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
6435 case DW_CFA_def_cfa_sf
:
6436 fc
->cfa_reg
= LEB ();
6437 fc
->cfa_offset
= SLEB ();
6438 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
6440 if (! do_debug_frames_interp
)
6441 printf (" DW_CFA_def_cfa_sf: %s ofs %d\n",
6442 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
6445 case DW_CFA_def_cfa_offset_sf
:
6446 fc
->cfa_offset
= SLEB ();
6447 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
6448 if (! do_debug_frames_interp
)
6449 printf (" DW_CFA_def_cfa_offset_sf: %d\n", fc
->cfa_offset
);
6452 case DW_CFA_MIPS_advance_loc8
:
6453 SAFE_BYTE_GET_AND_INC (ofs
, start
, 8, block_end
);
6454 if (do_debug_frames_interp
)
6455 frame_display_row (fc
, &need_col_headers
, &max_regs
);
6457 printf (" DW_CFA_MIPS_advance_loc8: %ld to %s\n",
6458 (unsigned long) (ofs
* fc
->code_factor
),
6459 dwarf_vmatoa_1 (NULL
,
6460 fc
->pc_begin
+ ofs
* fc
->code_factor
,
6462 fc
->pc_begin
+= ofs
* fc
->code_factor
;
6465 case DW_CFA_GNU_window_save
:
6466 if (! do_debug_frames_interp
)
6467 printf (" DW_CFA_GNU_window_save\n");
6470 case DW_CFA_GNU_args_size
:
6472 if (! do_debug_frames_interp
)
6473 printf (" DW_CFA_GNU_args_size: %ld\n", ul
);
6476 case DW_CFA_GNU_negative_offset_extended
:
6479 if (frame_need_space (fc
, reg
) < 0)
6480 reg_prefix
= bad_reg
;
6481 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
6482 printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n",
6483 reg_prefix
, regname (reg
, 0),
6484 l
* fc
->data_factor
);
6485 if (*reg_prefix
== '\0')
6487 fc
->col_type
[reg
] = DW_CFA_offset
;
6488 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
6493 if (op
>= DW_CFA_lo_user
&& op
<= DW_CFA_hi_user
)
6494 printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op
);
6496 warn (_("Unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op
);
6501 if (do_debug_frames_interp
)
6502 frame_display_row (fc
, &need_col_headers
, &max_regs
);
6505 eh_addr_size
= saved_eh_addr_size
;
6518 display_gdb_index (struct dwarf_section
*section
,
6519 void *file ATTRIBUTE_UNUSED
)
6521 unsigned char *start
= section
->start
;
6523 uint32_t cu_list_offset
, tu_list_offset
;
6524 uint32_t address_table_offset
, symbol_table_offset
, constant_pool_offset
;
6525 unsigned int cu_list_elements
, tu_list_elements
;
6526 unsigned int address_table_size
, symbol_table_slots
;
6527 unsigned char *cu_list
, *tu_list
;
6528 unsigned char *address_table
, *symbol_table
, *constant_pool
;
6531 /* The documentation for the format of this file is in gdb/dwarf2read.c. */
6533 printf (_("Contents of the %s section:\n"), section
->name
);
6535 if (section
->size
< 6 * sizeof (uint32_t))
6537 warn (_("Truncated header in the %s section.\n"), section
->name
);
6541 version
= byte_get_little_endian (start
, 4);
6542 printf (_("Version %ld\n"), (long) version
);
6544 /* Prior versions are obsolete, and future versions may not be
6545 backwards compatible. */
6546 if (version
< 3 || version
> 8)
6548 warn (_("Unsupported version %lu.\n"), (unsigned long) version
);
6552 warn (_("The address table data in version 3 may be wrong.\n"));
6554 warn (_("Version 4 does not support case insensitive lookups.\n"));
6556 warn (_("Version 5 does not include inlined functions.\n"));
6558 warn (_("Version 6 does not include symbol attributes.\n"));
6559 /* Version 7 indices generated by Gold have bad type unit references,
6560 PR binutils/15021. But we don't know if the index was generated by
6561 Gold or not, so to avoid worrying users with gdb-generated indices
6562 we say nothing for version 7 here. */
6564 cu_list_offset
= byte_get_little_endian (start
+ 4, 4);
6565 tu_list_offset
= byte_get_little_endian (start
+ 8, 4);
6566 address_table_offset
= byte_get_little_endian (start
+ 12, 4);
6567 symbol_table_offset
= byte_get_little_endian (start
+ 16, 4);
6568 constant_pool_offset
= byte_get_little_endian (start
+ 20, 4);
6570 if (cu_list_offset
> section
->size
6571 || tu_list_offset
> section
->size
6572 || address_table_offset
> section
->size
6573 || symbol_table_offset
> section
->size
6574 || constant_pool_offset
> section
->size
)
6576 warn (_("Corrupt header in the %s section.\n"), section
->name
);
6580 /* PR 17531: file: 418d0a8a. */
6581 if (tu_list_offset
< cu_list_offset
)
6583 warn (_("TU offset (%x) is less than CU offset (%x)\n"),
6584 tu_list_offset
, cu_list_offset
);
6588 cu_list_elements
= (tu_list_offset
- cu_list_offset
) / 8;
6590 if (address_table_offset
< tu_list_offset
)
6592 warn (_("Address table offset (%x) is less than TU offset (%x)\n"),
6593 address_table_offset
, tu_list_offset
);
6597 tu_list_elements
= (address_table_offset
- tu_list_offset
) / 8;
6599 /* PR 17531: file: 18a47d3d. */
6600 if (symbol_table_offset
< address_table_offset
)
6602 warn (_("Symbol table offset (%xl) is less then Address table offset (%x)\n"),
6603 symbol_table_offset
, address_table_offset
);
6607 address_table_size
= symbol_table_offset
- address_table_offset
;
6609 if (constant_pool_offset
< symbol_table_offset
)
6611 warn (_("Constant pool offset (%x) is less than symbol table offset (%x)\n"),
6612 constant_pool_offset
, symbol_table_offset
);
6616 symbol_table_slots
= (constant_pool_offset
- symbol_table_offset
) / 8;
6618 cu_list
= start
+ cu_list_offset
;
6619 tu_list
= start
+ tu_list_offset
;
6620 address_table
= start
+ address_table_offset
;
6621 symbol_table
= start
+ symbol_table_offset
;
6622 constant_pool
= start
+ constant_pool_offset
;
6624 if (address_table
+ address_table_size
* (2 + 8 + 4) > section
->start
+ section
->size
)
6626 warn (_("Address table extends beyond end of section.\n"));
6630 printf (_("\nCU table:\n"));
6631 for (i
= 0; i
< cu_list_elements
; i
+= 2)
6633 uint64_t cu_offset
= byte_get_little_endian (cu_list
+ i
* 8, 8);
6634 uint64_t cu_length
= byte_get_little_endian (cu_list
+ i
* 8 + 8, 8);
6636 printf (_("[%3u] 0x%lx - 0x%lx\n"), i
/ 2,
6637 (unsigned long) cu_offset
,
6638 (unsigned long) (cu_offset
+ cu_length
- 1));
6641 printf (_("\nTU table:\n"));
6642 for (i
= 0; i
< tu_list_elements
; i
+= 3)
6644 uint64_t tu_offset
= byte_get_little_endian (tu_list
+ i
* 8, 8);
6645 uint64_t type_offset
= byte_get_little_endian (tu_list
+ i
* 8 + 8, 8);
6646 uint64_t signature
= byte_get_little_endian (tu_list
+ i
* 8 + 16, 8);
6648 printf (_("[%3u] 0x%lx 0x%lx "), i
/ 3,
6649 (unsigned long) tu_offset
,
6650 (unsigned long) type_offset
);
6651 print_dwarf_vma (signature
, 8);
6655 printf (_("\nAddress table:\n"));
6656 for (i
= 0; i
< address_table_size
&& i
<= address_table_size
- (2 * 8 + 4);
6659 uint64_t low
= byte_get_little_endian (address_table
+ i
, 8);
6660 uint64_t high
= byte_get_little_endian (address_table
+ i
+ 8, 8);
6661 uint32_t cu_index
= byte_get_little_endian (address_table
+ i
+ 16, 4);
6663 print_dwarf_vma (low
, 8);
6664 print_dwarf_vma (high
, 8);
6665 printf (_("%lu\n"), (unsigned long) cu_index
);
6668 printf (_("\nSymbol table:\n"));
6669 for (i
= 0; i
< symbol_table_slots
; ++i
)
6671 uint32_t name_offset
= byte_get_little_endian (symbol_table
+ i
* 8, 4);
6672 uint32_t cu_vector_offset
= byte_get_little_endian (symbol_table
+ i
* 8 + 4, 4);
6673 uint32_t num_cus
, cu
;
6675 if (name_offset
!= 0
6676 || cu_vector_offset
!= 0)
6680 /* PR 17531: file: 5b7b07ad. */
6681 if (constant_pool
+ name_offset
< constant_pool
6682 || constant_pool
+ name_offset
>= section
->start
+ section
->size
)
6684 printf (_("[%3u] <corrupt offset: %x>"), i
, name_offset
);
6685 warn (_("Corrupt name offset of 0x%x found for symbol table slot %d\n"),
6689 printf ("[%3u] %.*s:", i
,
6690 (int) (section
->size
- (constant_pool_offset
+ name_offset
)),
6691 constant_pool
+ name_offset
);
6693 if (constant_pool
+ cu_vector_offset
< constant_pool
6694 || constant_pool
+ cu_vector_offset
>= section
->start
+ section
->size
)
6696 printf (_("<invalid CU vector offset: %x>\n"), cu_vector_offset
);
6697 warn (_("Corrupt CU vector offset of 0x%x found for symbol table slot %d\n"),
6698 cu_vector_offset
, i
);
6702 num_cus
= byte_get_little_endian (constant_pool
+ cu_vector_offset
, 4);
6704 if (num_cus
* 4 < num_cus
6705 || constant_pool
+ cu_vector_offset
+ 4 + num_cus
* 4 >=
6706 section
->start
+ section
->size
)
6708 printf ("<invalid number of CUs: %d>\n", num_cus
);
6709 warn (_("Invalid number of CUs (0x%x) for symbol table slot %d\n"),
6716 for (j
= 0; j
< num_cus
; ++j
)
6719 gdb_index_symbol_kind kind
;
6721 cu
= byte_get_little_endian (constant_pool
+ cu_vector_offset
+ 4 + j
* 4, 4);
6722 is_static
= GDB_INDEX_SYMBOL_STATIC_VALUE (cu
);
6723 kind
= GDB_INDEX_SYMBOL_KIND_VALUE (cu
);
6724 cu
= GDB_INDEX_CU_VALUE (cu
);
6725 /* Convert to TU number if it's for a type unit. */
6726 if (cu
>= cu_list_elements
/ 2)
6727 printf ("%cT%lu", num_cus
> 1 ? '\t' : ' ',
6728 (unsigned long) (cu
- cu_list_elements
/ 2));
6730 printf ("%c%lu", num_cus
> 1 ? '\t' : ' ', (unsigned long) cu
);
6732 printf (" [%s, %s]",
6733 is_static
? _("static") : _("global"),
6734 get_gdb_index_symbol_kind_name (kind
));
6746 /* Pre-allocate enough space for the CU/TU sets needed. */
6749 prealloc_cu_tu_list (unsigned int nshndx
)
6751 if (shndx_pool
== NULL
)
6753 shndx_pool_size
= nshndx
;
6754 shndx_pool_used
= 0;
6755 shndx_pool
= (unsigned int *) xcmalloc (shndx_pool_size
,
6756 sizeof (unsigned int));
6760 shndx_pool_size
= shndx_pool_used
+ nshndx
;
6761 shndx_pool
= (unsigned int *) xcrealloc (shndx_pool
, shndx_pool_size
,
6762 sizeof (unsigned int));
6767 add_shndx_to_cu_tu_entry (unsigned int shndx
)
6769 if (shndx_pool_used
>= shndx_pool_size
)
6771 error (_("Internal error: out of space in the shndx pool.\n"));
6774 shndx_pool
[shndx_pool_used
++] = shndx
;
6778 end_cu_tu_entry (void)
6780 if (shndx_pool_used
>= shndx_pool_size
)
6782 error (_("Internal error: out of space in the shndx pool.\n"));
6785 shndx_pool
[shndx_pool_used
++] = 0;
6788 /* Return the short name of a DWARF section given by a DW_SECT enumerator. */
6791 get_DW_SECT_short_name (unsigned int dw_sect
)
6793 static char buf
[16];
6801 case DW_SECT_ABBREV
:
6807 case DW_SECT_STR_OFFSETS
:
6809 case DW_SECT_MACINFO
:
6817 snprintf (buf
, sizeof (buf
), "%d", dw_sect
);
6821 /* Process a CU or TU index. If DO_DISPLAY is true, print the contents.
6822 These sections are extensions for Fission.
6823 See http://gcc.gnu.org/wiki/DebugFissionDWP. */
6826 process_cu_tu_index (struct dwarf_section
*section
, int do_display
)
6828 unsigned char *phdr
= section
->start
;
6829 unsigned char *limit
= phdr
+ section
->size
;
6830 unsigned char *phash
;
6831 unsigned char *pindex
;
6832 unsigned char *ppool
;
6833 unsigned int version
;
6834 unsigned int ncols
= 0;
6836 unsigned int nslots
;
6839 dwarf_vma signature_high
;
6840 dwarf_vma signature_low
;
6843 /* PR 17512: file: 002-168123-0.004. */
6846 warn (_("Section %s is empty\n"), section
->name
);
6849 /* PR 17512: file: 002-376-0.004. */
6850 if (section
->size
< 24)
6852 warn (_("Section %s is too small to contain a CU/TU header\n"),
6857 SAFE_BYTE_GET (version
, phdr
, 4, limit
);
6859 SAFE_BYTE_GET (ncols
, phdr
+ 4, 4, limit
);
6860 SAFE_BYTE_GET (nused
, phdr
+ 8, 4, limit
);
6861 SAFE_BYTE_GET (nslots
, phdr
+ 12, 4, limit
);
6864 pindex
= phash
+ nslots
* 8;
6865 ppool
= pindex
+ nslots
* 4;
6869 printf (_("Contents of the %s section:\n\n"), section
->name
);
6870 printf (_(" Version: %d\n"), version
);
6872 printf (_(" Number of columns: %d\n"), ncols
);
6873 printf (_(" Number of used entries: %d\n"), nused
);
6874 printf (_(" Number of slots: %d\n\n"), nslots
);
6879 warn (_("Section %s too small for %d hash table entries\n"),
6880 section
->name
, nslots
);
6887 prealloc_cu_tu_list ((limit
- ppool
) / 4);
6888 for (i
= 0; i
< nslots
; i
++)
6890 unsigned char *shndx_list
;
6893 SAFE_BYTE_GET64 (phash
, &signature_high
, &signature_low
, limit
);
6894 if (signature_high
!= 0 || signature_low
!= 0)
6896 SAFE_BYTE_GET (j
, pindex
, 4, limit
);
6897 shndx_list
= ppool
+ j
* 4;
6899 printf (_(" [%3d] Signature: 0x%s Sections: "),
6900 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
6901 buf
, sizeof (buf
)));
6904 if (shndx_list
>= limit
)
6906 warn (_("Section %s too small for shndx pool\n"),
6910 SAFE_BYTE_GET (shndx
, shndx_list
, 4, limit
);
6914 printf (" %d", shndx
);
6916 add_shndx_to_cu_tu_entry (shndx
);
6928 else if (version
== 2)
6931 unsigned int dw_sect
;
6932 unsigned char *ph
= phash
;
6933 unsigned char *pi
= pindex
;
6934 unsigned char *poffsets
= ppool
+ ncols
* 4;
6935 unsigned char *psizes
= poffsets
+ nused
* ncols
* 4;
6936 unsigned char *pend
= psizes
+ nused
* ncols
* 4;
6937 bfd_boolean is_tu_index
;
6938 struct cu_tu_set
*this_set
= NULL
;
6940 unsigned char *prow
;
6942 is_tu_index
= strcmp (section
->name
, ".debug_tu_index") == 0;
6946 warn (_("Section %s too small for offset and size tables\n"),
6953 printf (_(" Offset table\n"));
6954 printf (" slot %-16s ",
6955 is_tu_index
? _("signature") : _("dwo_id"));
6962 tu_sets
= xcalloc2 (nused
, sizeof (struct cu_tu_set
));
6968 cu_sets
= xcalloc2 (nused
, sizeof (struct cu_tu_set
));
6975 for (j
= 0; j
< ncols
; j
++)
6977 SAFE_BYTE_GET (dw_sect
, ppool
+ j
* 4, 4, limit
);
6978 printf (" %8s", get_DW_SECT_short_name (dw_sect
));
6983 for (i
= 0; i
< nslots
; i
++)
6985 SAFE_BYTE_GET64 (ph
, &signature_high
, &signature_low
, limit
);
6987 SAFE_BYTE_GET (row
, pi
, 4, limit
);
6990 /* PR 17531: file: a05f6ab3. */
6993 warn (_("Row index (%u) is larger than number of used entries (%u)\n"),
6999 memcpy (&this_set
[row
- 1].signature
, ph
, sizeof (uint64_t));
7001 prow
= poffsets
+ (row
- 1) * ncols
* 4;
7004 printf (_(" [%3d] 0x%s"),
7005 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
7006 buf
, sizeof (buf
)));
7007 for (j
= 0; j
< ncols
; j
++)
7009 SAFE_BYTE_GET (val
, prow
+ j
* 4, 4, limit
);
7011 printf (" %8d", val
);
7014 SAFE_BYTE_GET (dw_sect
, ppool
+ j
* 4, 4, limit
);
7016 /* PR 17531: file: 10796eb3. */
7017 if (dw_sect
>= DW_SECT_MAX
)
7018 warn (_("Overlarge Dwarf section index detected: %u\n"), dw_sect
);
7020 this_set
[row
- 1].section_offsets
[dw_sect
] = val
;
7036 printf (_(" Size table\n"));
7037 printf (" slot %-16s ",
7038 is_tu_index
? _("signature") : _("dwo_id"));
7041 for (j
= 0; j
< ncols
; j
++)
7043 SAFE_BYTE_GET (val
, ppool
+ j
* 4, 4, limit
);
7045 printf (" %8s", get_DW_SECT_short_name (val
));
7051 for (i
= 0; i
< nslots
; i
++)
7053 SAFE_BYTE_GET64 (ph
, &signature_high
, &signature_low
, limit
);
7055 SAFE_BYTE_GET (row
, pi
, 4, limit
);
7058 prow
= psizes
+ (row
- 1) * ncols
* 4;
7061 printf (_(" [%3d] 0x%s"),
7062 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
7063 buf
, sizeof (buf
)));
7065 for (j
= 0; j
< ncols
; j
++)
7067 SAFE_BYTE_GET (val
, prow
+ j
* 4, 4, limit
);
7069 printf (" %8d", val
);
7072 SAFE_BYTE_GET (dw_sect
, ppool
+ j
* 4, 4, limit
);
7073 if (dw_sect
>= DW_SECT_MAX
)
7074 warn (_("Overlarge Dwarf section index detected: %u\n"), dw_sect
);
7076 this_set
[row
- 1].section_sizes
[dw_sect
] = val
;
7088 else if (do_display
)
7089 printf (_(" Unsupported version (%d)\n"), version
);
7097 /* Load the CU and TU indexes if present. This will build a list of
7098 section sets that we can use to associate a .debug_info.dwo section
7099 with its associated .debug_abbrev.dwo section in a .dwp file. */
7102 load_cu_tu_indexes (void *file
)
7104 /* If we have already loaded (or tried to load) the CU and TU indexes
7105 then do not bother to repeat the task. */
7106 if (cu_tu_indexes_read
)
7109 if (load_debug_section (dwp_cu_index
, file
))
7110 process_cu_tu_index (&debug_displays
[dwp_cu_index
].section
, 0);
7112 if (load_debug_section (dwp_tu_index
, file
))
7113 process_cu_tu_index (&debug_displays
[dwp_tu_index
].section
, 0);
7115 cu_tu_indexes_read
= 1;
7118 /* Find the set of sections that includes section SHNDX. */
7121 find_cu_tu_set (void *file
, unsigned int shndx
)
7125 load_cu_tu_indexes (file
);
7127 /* Find SHNDX in the shndx pool. */
7128 for (i
= 0; i
< shndx_pool_used
; i
++)
7129 if (shndx_pool
[i
] == shndx
)
7132 if (i
>= shndx_pool_used
)
7135 /* Now backup to find the first entry in the set. */
7136 while (i
> 0 && shndx_pool
[i
- 1] != 0)
7139 return shndx_pool
+ i
;
7142 /* Display a .debug_cu_index or .debug_tu_index section. */
7145 display_cu_index (struct dwarf_section
*section
, void *file ATTRIBUTE_UNUSED
)
7147 return process_cu_tu_index (section
, 1);
7151 display_debug_not_supported (struct dwarf_section
*section
,
7152 void *file ATTRIBUTE_UNUSED
)
7154 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
7160 /* Like malloc, but takes two parameters like calloc.
7161 Verifies that the first parameter is not too large.
7162 Note: does *not* initialise the allocated memory to zero. */
7164 cmalloc (size_t nmemb
, size_t size
)
7166 /* Check for overflow. */
7167 if (nmemb
>= ~(size_t) 0 / size
)
7170 return xmalloc (nmemb
* size
);
7173 /* Like xmalloc, but takes two parameters like calloc.
7174 Verifies that the first parameter is not too large.
7175 Note: does *not* initialise the allocated memory to zero. */
7177 xcmalloc (size_t nmemb
, size_t size
)
7179 /* Check for overflow. */
7180 if (nmemb
>= ~(size_t) 0 / size
)
7183 return xmalloc (nmemb
* size
);
7186 /* Like xrealloc, but takes three parameters.
7187 Verifies that the second parameter is not too large.
7188 Note: does *not* initialise any new memory to zero. */
7190 xcrealloc (void *ptr
, size_t nmemb
, size_t size
)
7192 /* Check for overflow. */
7193 if (nmemb
>= ~(size_t) 0 / size
)
7196 return xrealloc (ptr
, nmemb
* size
);
7199 /* Like xcalloc, but verifies that the first parameter is not too large. */
7201 xcalloc2 (size_t nmemb
, size_t size
)
7203 /* Check for overflow. */
7204 if (nmemb
>= ~(size_t) 0 / size
)
7207 return xcalloc (nmemb
, size
);
7211 free_debug_memory (void)
7217 for (i
= 0; i
< max
; i
++)
7218 free_debug_section ((enum dwarf_section_display_enum
) i
);
7220 if (debug_information
!= NULL
)
7222 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
)
7224 for (i
= 0; i
< num_debug_info_entries
; i
++)
7226 if (!debug_information
[i
].max_loc_offsets
)
7228 free (debug_information
[i
].loc_offsets
);
7229 free (debug_information
[i
].have_frame_base
);
7231 if (!debug_information
[i
].max_range_lists
)
7232 free (debug_information
[i
].range_lists
);
7235 free (debug_information
);
7236 debug_information
= NULL
;
7237 alloc_num_debug_info_entries
= num_debug_info_entries
= 0;
7242 dwarf_select_sections_by_names (const char *names
)
7246 const char * option
;
7250 debug_dump_long_opts
;
7252 static const debug_dump_long_opts opts_table
[] =
7254 /* Please keep this table alpha- sorted. */
7255 { "Ranges", & do_debug_ranges
, 1 },
7256 { "abbrev", & do_debug_abbrevs
, 1 },
7257 { "addr", & do_debug_addr
, 1 },
7258 { "aranges", & do_debug_aranges
, 1 },
7259 { "cu_index", & do_debug_cu_index
, 1 },
7260 { "decodedline", & do_debug_lines
, FLAG_DEBUG_LINES_DECODED
},
7261 { "frames", & do_debug_frames
, 1 },
7262 { "frames-interp", & do_debug_frames_interp
, 1 },
7263 /* The special .gdb_index section. */
7264 { "gdb_index", & do_gdb_index
, 1 },
7265 { "info", & do_debug_info
, 1 },
7266 { "line", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
}, /* For backwards compatibility. */
7267 { "loc", & do_debug_loc
, 1 },
7268 { "macro", & do_debug_macinfo
, 1 },
7269 { "pubnames", & do_debug_pubnames
, 1 },
7270 { "pubtypes", & do_debug_pubtypes
, 1 },
7271 /* This entry is for compatability
7272 with earlier versions of readelf. */
7273 { "ranges", & do_debug_aranges
, 1 },
7274 { "rawline", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
},
7275 { "str", & do_debug_str
, 1 },
7276 /* These trace_* sections are used by Itanium VMS. */
7277 { "trace_abbrev", & do_trace_abbrevs
, 1 },
7278 { "trace_aranges", & do_trace_aranges
, 1 },
7279 { "trace_info", & do_trace_info
, 1 },
7288 const debug_dump_long_opts
* entry
;
7290 for (entry
= opts_table
; entry
->option
; entry
++)
7292 size_t len
= strlen (entry
->option
);
7294 if (strncmp (p
, entry
->option
, len
) == 0
7295 && (p
[len
] == ',' || p
[len
] == '\0'))
7297 * entry
->variable
|= entry
->val
;
7299 /* The --debug-dump=frames-interp option also
7300 enables the --debug-dump=frames option. */
7301 if (do_debug_frames_interp
)
7302 do_debug_frames
= 1;
7309 if (entry
->option
== NULL
)
7311 warn (_("Unrecognized debug option '%s'\n"), p
);
7312 p
= strchr (p
, ',');
7323 dwarf_select_sections_by_letters (const char *letters
)
7325 unsigned int lindex
= 0;
7327 while (letters
[lindex
])
7328 switch (letters
[lindex
++])
7335 do_debug_abbrevs
= 1;
7339 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
7343 do_debug_lines
|= FLAG_DEBUG_LINES_DECODED
;
7347 do_debug_pubnames
= 1;
7351 do_debug_pubtypes
= 1;
7355 do_debug_aranges
= 1;
7359 do_debug_ranges
= 1;
7363 do_debug_frames_interp
= 1;
7365 do_debug_frames
= 1;
7369 do_debug_macinfo
= 1;
7381 warn (_("Unrecognized debug option '%s'\n"), optarg
);
7387 dwarf_select_sections_all (void)
7390 do_debug_abbrevs
= 1;
7391 do_debug_lines
= FLAG_DEBUG_LINES_RAW
;
7392 do_debug_pubnames
= 1;
7393 do_debug_pubtypes
= 1;
7394 do_debug_aranges
= 1;
7395 do_debug_ranges
= 1;
7396 do_debug_frames
= 1;
7397 do_debug_macinfo
= 1;
7402 do_trace_abbrevs
= 1;
7403 do_trace_aranges
= 1;
7405 do_debug_cu_index
= 1;
7408 struct dwarf_section_display debug_displays
[] =
7410 { { ".debug_abbrev", ".zdebug_abbrev", NULL
, NULL
, 0, 0, 0, NULL
},
7411 display_debug_abbrev
, &do_debug_abbrevs
, 0 },
7412 { { ".debug_aranges", ".zdebug_aranges", NULL
, NULL
, 0, 0, 0, NULL
},
7413 display_debug_aranges
, &do_debug_aranges
, 1 },
7414 { { ".debug_frame", ".zdebug_frame", NULL
, NULL
, 0, 0, 0, NULL
},
7415 display_debug_frames
, &do_debug_frames
, 1 },
7416 { { ".debug_info", ".zdebug_info", NULL
, NULL
, 0, 0, abbrev
, NULL
},
7417 display_debug_info
, &do_debug_info
, 1 },
7418 { { ".debug_line", ".zdebug_line", NULL
, NULL
, 0, 0, 0, NULL
},
7419 display_debug_lines
, &do_debug_lines
, 1 },
7420 { { ".debug_pubnames", ".zdebug_pubnames", NULL
, NULL
, 0, 0, 0, NULL
},
7421 display_debug_pubnames
, &do_debug_pubnames
, 0 },
7422 { { ".debug_gnu_pubnames", ".zdebug_gnu_pubnames", NULL
, NULL
, 0, 0, 0, NULL
},
7423 display_debug_gnu_pubnames
, &do_debug_pubnames
, 0 },
7424 { { ".eh_frame", "", NULL
, NULL
, 0, 0, 0, NULL
},
7425 display_debug_frames
, &do_debug_frames
, 1 },
7426 { { ".debug_macinfo", ".zdebug_macinfo", NULL
, NULL
, 0, 0, 0, NULL
},
7427 display_debug_macinfo
, &do_debug_macinfo
, 0 },
7428 { { ".debug_macro", ".zdebug_macro", NULL
, NULL
, 0, 0, 0, NULL
},
7429 display_debug_macro
, &do_debug_macinfo
, 1 },
7430 { { ".debug_str", ".zdebug_str", NULL
, NULL
, 0, 0, 0, NULL
},
7431 display_debug_str
, &do_debug_str
, 0 },
7432 { { ".debug_loc", ".zdebug_loc", NULL
, NULL
, 0, 0, 0, NULL
},
7433 display_debug_loc
, &do_debug_loc
, 1 },
7434 { { ".debug_pubtypes", ".zdebug_pubtypes", NULL
, NULL
, 0, 0, 0, NULL
},
7435 display_debug_pubnames
, &do_debug_pubtypes
, 0 },
7436 { { ".debug_gnu_pubtypes", ".zdebug_gnu_pubtypes", NULL
, NULL
, 0, 0, 0, NULL
},
7437 display_debug_gnu_pubnames
, &do_debug_pubtypes
, 0 },
7438 { { ".debug_ranges", ".zdebug_ranges", NULL
, NULL
, 0, 0, 0, NULL
},
7439 display_debug_ranges
, &do_debug_ranges
, 1 },
7440 { { ".debug_static_func", ".zdebug_static_func", NULL
, NULL
, 0, 0, 0, NULL
},
7441 display_debug_not_supported
, NULL
, 0 },
7442 { { ".debug_static_vars", ".zdebug_static_vars", NULL
, NULL
, 0, 0, 0, NULL
},
7443 display_debug_not_supported
, NULL
, 0 },
7444 { { ".debug_types", ".zdebug_types", NULL
, NULL
, 0, 0, abbrev
, NULL
},
7445 display_debug_types
, &do_debug_info
, 1 },
7446 { { ".debug_weaknames", ".zdebug_weaknames", NULL
, NULL
, 0, 0, 0, NULL
},
7447 display_debug_not_supported
, NULL
, 0 },
7448 { { ".gdb_index", "", NULL
, NULL
, 0, 0, 0, NULL
},
7449 display_gdb_index
, &do_gdb_index
, 0 },
7450 { { ".trace_info", "", NULL
, NULL
, 0, 0, trace_abbrev
, NULL
},
7451 display_trace_info
, &do_trace_info
, 1 },
7452 { { ".trace_abbrev", "", NULL
, NULL
, 0, 0, 0, NULL
},
7453 display_debug_abbrev
, &do_trace_abbrevs
, 0 },
7454 { { ".trace_aranges", "", NULL
, NULL
, 0, 0, 0, NULL
},
7455 display_debug_aranges
, &do_trace_aranges
, 0 },
7456 { { ".debug_info.dwo", ".zdebug_info.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
, NULL
},
7457 display_debug_info
, &do_debug_info
, 1 },
7458 { { ".debug_abbrev.dwo", ".zdebug_abbrev.dwo", NULL
, NULL
, 0, 0, 0, NULL
},
7459 display_debug_abbrev
, &do_debug_abbrevs
, 0 },
7460 { { ".debug_types.dwo", ".zdebug_types.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
, NULL
},
7461 display_debug_types
, &do_debug_info
, 1 },
7462 { { ".debug_line.dwo", ".zdebug_line.dwo", NULL
, NULL
, 0, 0, 0, NULL
},
7463 display_debug_lines
, &do_debug_lines
, 1 },
7464 { { ".debug_loc.dwo", ".zdebug_loc.dwo", NULL
, NULL
, 0, 0, 0, NULL
},
7465 display_debug_loc
, &do_debug_loc
, 1 },
7466 { { ".debug_macro.dwo", ".zdebug_macro.dwo", NULL
, NULL
, 0, 0, 0, NULL
},
7467 display_debug_macro
, &do_debug_macinfo
, 1 },
7468 { { ".debug_macinfo.dwo", ".zdebug_macinfo.dwo", NULL
, NULL
, 0, 0, 0, NULL
},
7469 display_debug_macinfo
, &do_debug_macinfo
, 0 },
7470 { { ".debug_str.dwo", ".zdebug_str.dwo", NULL
, NULL
, 0, 0, 0, NULL
},
7471 display_debug_str
, &do_debug_str
, 1 },
7472 { { ".debug_str_offsets", ".zdebug_str_offsets", NULL
, NULL
, 0, 0, 0, NULL
},
7473 display_debug_str_offsets
, NULL
, 0 },
7474 { { ".debug_str_offsets.dwo", ".zdebug_str_offsets.dwo", NULL
, NULL
, 0, 0, 0, NULL
},
7475 display_debug_str_offsets
, NULL
, 0 },
7476 { { ".debug_addr", ".zdebug_addr", NULL
, NULL
, 0, 0, 0, NULL
},
7477 display_debug_addr
, &do_debug_addr
, 1 },
7478 { { ".debug_cu_index", "", NULL
, NULL
, 0, 0, 0, NULL
},
7479 display_cu_index
, &do_debug_cu_index
, 0 },
7480 { { ".debug_tu_index", "", NULL
, NULL
, 0, 0, 0, NULL
},
7481 display_cu_index
, &do_debug_cu_index
, 0 },