1 /* dwarf.c -- display DWARF contents of a BFD binary file
2 Copyright (C) 2005-2017 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"
35 #define MAX(a, b) ((a) > (b) ? (a) : (b))
36 #define MIN(a, b) ((a) < (b) ? (a) : (b))
38 static const char *regname (unsigned int regno
, int row
);
40 static int have_frame_base
;
41 static int need_base_address
;
43 static unsigned int last_pointer_size
= 0;
44 static int warned_about_missing_comp_units
= FALSE
;
46 static unsigned int num_debug_info_entries
= 0;
47 static unsigned int alloc_num_debug_info_entries
= 0;
48 static debug_info
*debug_information
= NULL
;
49 /* Special value for num_debug_info_entries to indicate
50 that the .debug_info section could not be loaded/parsed. */
51 #define DEBUG_INFO_UNAVAILABLE (unsigned int) -1
53 unsigned int eh_addr_size
;
58 int do_debug_pubnames
;
59 int do_debug_pubtypes
;
63 int do_debug_frames_interp
;
72 int do_debug_cu_index
;
75 int dwarf_cutoff_level
= -1;
76 unsigned long dwarf_start_die
;
80 /* Collection of CU/TU section sets from .debug_cu_index and .debug_tu_index
81 sections. For version 1 package files, each set is stored in SHNDX_POOL
82 as a zero-terminated list of section indexes comprising one set of debug
83 sections from a .dwo file. */
85 static unsigned int *shndx_pool
= NULL
;
86 static unsigned int shndx_pool_size
= 0;
87 static unsigned int shndx_pool_used
= 0;
89 /* For version 2 package files, each set contains an array of section offsets
90 and an array of section sizes, giving the offset and size of the
91 contribution from a CU or TU within one of the debug sections.
92 When displaying debug info from a package file, we need to use these
93 tables to locate the corresponding contributions to each section. */
98 dwarf_vma section_offsets
[DW_SECT_MAX
];
99 size_t section_sizes
[DW_SECT_MAX
];
102 static int cu_count
= 0;
103 static int tu_count
= 0;
104 static struct cu_tu_set
*cu_sets
= NULL
;
105 static struct cu_tu_set
*tu_sets
= NULL
;
107 static bfd_boolean
load_cu_tu_indexes (void *);
109 /* Values for do_debug_lines. */
110 #define FLAG_DEBUG_LINES_RAW 1
111 #define FLAG_DEBUG_LINES_DECODED 2
114 size_of_encoded_value (int encoding
)
116 switch (encoding
& 0x7)
119 case 0: return eh_addr_size
;
127 get_encoded_value (unsigned char **pdata
,
129 struct dwarf_section
*section
,
132 unsigned char * data
= * pdata
;
133 unsigned int size
= size_of_encoded_value (encoding
);
136 if (data
+ size
>= end
)
138 warn (_("Encoded value extends past end of section\n"));
143 /* PR 17512: file: 002-829853-0.004. */
146 warn (_("Encoded size of %d is too large to read\n"), size
);
151 /* PR 17512: file: 1085-5603-0.004. */
154 warn (_("Encoded size of 0 is too small to read\n"));
159 if (encoding
& DW_EH_PE_signed
)
160 val
= byte_get_signed (data
, size
);
162 val
= byte_get (data
, size
);
164 if ((encoding
& 0x70) == DW_EH_PE_pcrel
)
165 val
+= section
->address
+ (data
- section
->start
);
167 * pdata
= data
+ size
;
171 #if defined HAVE_LONG_LONG && SIZEOF_LONG_LONG > SIZEOF_LONG
173 # define DWARF_VMA_FMT "ll"
174 # define DWARF_VMA_FMT_LONG "%16.16llx"
176 # define DWARF_VMA_FMT "I64"
177 # define DWARF_VMA_FMT_LONG "%016I64x"
180 # define DWARF_VMA_FMT "l"
181 # define DWARF_VMA_FMT_LONG "%16.16lx"
184 /* Convert a dwarf vma value into a string. Returns a pointer to a static
185 buffer containing the converted VALUE. The value is converted according
186 to the printf formating character FMTCH. If NUM_BYTES is non-zero then
187 it specifies the maximum number of bytes to be displayed in the converted
188 value and FMTCH is ignored - hex is always used. */
191 dwarf_vmatoa_1 (const char *fmtch
, dwarf_vma value
, unsigned num_bytes
)
193 /* As dwarf_vmatoa is used more then once in a printf call
194 for output, we are cycling through an fixed array of pointers
195 for return address. */
196 static int buf_pos
= 0;
197 static struct dwarf_vmatoa_buf
203 ret
= buf
[buf_pos
++].place
;
204 buf_pos
%= ARRAY_SIZE (buf
);
208 /* Printf does not have a way of specifying a maximum field width for an
209 integer value, so we print the full value into a buffer and then select
210 the precision we need. */
211 snprintf (ret
, sizeof (buf
[0].place
), DWARF_VMA_FMT_LONG
, value
);
214 return ret
+ (16 - 2 * num_bytes
);
221 sprintf (fmt
, "%%%s%s", DWARF_VMA_FMT
, fmtch
);
223 sprintf (fmt
, "%%%s", DWARF_VMA_FMT
);
224 snprintf (ret
, sizeof (buf
[0].place
), fmt
, value
);
229 static inline const char *
230 dwarf_vmatoa (const char * fmtch
, dwarf_vma value
)
232 return dwarf_vmatoa_1 (fmtch
, value
, 0);
235 /* Print a dwarf_vma value (typically an address, offset or length) in
236 hexadecimal format, followed by a space. The length of the VALUE (and
237 hence the precision displayed) is determined by the NUM_BYTES parameter. */
240 print_dwarf_vma (dwarf_vma value
, unsigned num_bytes
)
242 printf ("%s ", dwarf_vmatoa_1 (NULL
, value
, num_bytes
));
245 /* Format a 64-bit value, given as two 32-bit values, in hex.
246 For reentrancy, this uses a buffer provided by the caller. */
249 dwarf_vmatoa64 (dwarf_vma hvalue
, dwarf_vma lvalue
, char *buf
,
250 unsigned int buf_len
)
255 snprintf (buf
, buf_len
, "%" DWARF_VMA_FMT
"x", lvalue
);
258 len
= snprintf (buf
, buf_len
, "%" DWARF_VMA_FMT
"x", hvalue
);
259 snprintf (buf
+ len
, buf_len
- len
,
260 "%08" DWARF_VMA_FMT
"x", lvalue
);
266 /* Read in a LEB128 encoded value starting at address DATA.
267 If SIGN is true, return a signed LEB128 value.
268 If LENGTH_RETURN is not NULL, return in it the number of bytes read.
269 No bytes will be read at address END or beyond. */
272 read_leb128 (unsigned char *data
,
273 unsigned int *length_return
,
275 const unsigned char * const end
)
277 dwarf_vma result
= 0;
278 unsigned int num_read
= 0;
279 unsigned int shift
= 0;
280 unsigned char byte
= 0;
287 result
|= ((dwarf_vma
) (byte
& 0x7f)) << shift
;
290 if ((byte
& 0x80) == 0)
293 /* PR 17512: file: 0ca183b8.
294 FIXME: Should we signal this error somehow ? */
295 if (shift
>= sizeof (result
) * 8)
299 if (length_return
!= NULL
)
300 *length_return
= num_read
;
302 if (sign
&& (shift
< 8 * sizeof (result
)) && (byte
& 0x40))
303 result
|= -((dwarf_vma
) 1 << shift
);
308 /* Create a signed version to avoid painful typecasts. */
309 static inline dwarf_signed_vma
310 read_sleb128 (unsigned char * data
,
311 unsigned int * length_return
,
312 const unsigned char * const end
)
314 return (dwarf_signed_vma
) read_leb128 (data
, length_return
, TRUE
, end
);
317 static inline dwarf_vma
318 read_uleb128 (unsigned char * data
,
319 unsigned int * length_return
,
320 const unsigned char * const end
)
322 return read_leb128 (data
, length_return
, FALSE
, end
);
325 #define SKIP_ULEB() read_uleb128 (start, & length_return, end); start += length_return
326 #define SKIP_SLEB() read_sleb128 (start, & length_return, end); start += length_return
328 #define READ_ULEB(var) \
333 (var) = _val = read_uleb128 (start, &length_return, end); \
335 error (_("Internal error: %s%d: LEB value (%#" DWARF_VMA_FMT "x) too large for containing variable\n"), \
336 __FILE__, __LINE__, _val); \
337 start += length_return; \
341 #define READ_SLEB(var) \
344 dwarf_signed_vma _val; \
346 (var) = _val = read_sleb128 (start, &length_return, end); \
348 error (_("Internal error: %s%d: LEB value (%#" DWARF_VMA_FMT "x) too large for containing variable\n"), \
349 __FILE__, __LINE__, _val); \
350 start += length_return; \
354 #define SAFE_BYTE_GET(VAL, PTR, AMOUNT, END) \
357 unsigned int amount = (AMOUNT); \
358 if (sizeof (VAL) < amount) \
360 error (_("internal error: attempt to read %d bytes of data in to %d sized variable"),\
361 amount, (int) sizeof (VAL)); \
362 amount = sizeof (VAL); \
364 if (((PTR) + amount) >= (END)) \
367 amount = (END) - (PTR); \
371 if (amount == 0 || amount > 8) \
374 VAL = byte_get ((PTR), amount); \
378 #define SAFE_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \
381 SAFE_BYTE_GET (VAL, PTR, AMOUNT, END); \
386 #define SAFE_SIGNED_BYTE_GET(VAL, PTR, AMOUNT, END) \
389 unsigned int amount = (AMOUNT); \
390 if (((PTR) + amount) >= (END)) \
393 amount = (END) - (PTR); \
398 VAL = byte_get_signed ((PTR), amount); \
404 #define SAFE_SIGNED_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \
407 SAFE_SIGNED_BYTE_GET (VAL, PTR, AMOUNT, END); \
412 #define SAFE_BYTE_GET64(PTR, HIGH, LOW, END) \
415 if (((PTR) + 8) <= (END)) \
417 byte_get_64 ((PTR), (HIGH), (LOW)); \
421 * (LOW) = * (HIGH) = 0; \
426 typedef struct State_Machine_Registers
434 unsigned char op_index
;
435 unsigned char end_sequence
;
436 /* This variable hold the number of the last entry seen
437 in the File Table. */
438 unsigned int last_file_entry
;
441 static SMR state_machine_regs
;
444 reset_state_machine (int is_stmt
)
446 state_machine_regs
.address
= 0;
447 state_machine_regs
.op_index
= 0;
448 state_machine_regs
.file
= 1;
449 state_machine_regs
.line
= 1;
450 state_machine_regs
.column
= 0;
451 state_machine_regs
.is_stmt
= is_stmt
;
452 state_machine_regs
.basic_block
= 0;
453 state_machine_regs
.end_sequence
= 0;
454 state_machine_regs
.last_file_entry
= 0;
457 /* Handled an extend line op.
458 Returns the number of bytes read. */
461 process_extended_line_op (unsigned char * data
,
465 unsigned char op_code
;
466 unsigned int bytes_read
;
469 unsigned char *orig_data
= data
;
472 len
= read_uleb128 (data
, & bytes_read
, end
);
475 if (len
== 0 || data
== end
|| len
> (uintptr_t) (end
- data
))
477 warn (_("Badly formed extended line op encountered!\n"));
484 printf (_(" Extended opcode %d: "), op_code
);
488 case DW_LNE_end_sequence
:
489 printf (_("End of Sequence\n\n"));
490 reset_state_machine (is_stmt
);
493 case DW_LNE_set_address
:
494 /* PR 17512: file: 002-100480-0.004. */
495 if (len
- bytes_read
- 1 > 8)
497 warn (_("Length (%d) of DW_LNE_set_address op is too long\n"),
498 len
- bytes_read
- 1);
502 SAFE_BYTE_GET (adr
, data
, len
- bytes_read
- 1, end
);
503 printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr
));
504 state_machine_regs
.address
= adr
;
505 state_machine_regs
.op_index
= 0;
508 case DW_LNE_define_file
:
509 printf (_("define new File Table entry\n"));
510 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
511 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
517 l
= strnlen ((char *) data
, end
- data
);
519 printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
521 printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
523 printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
525 printf ("%.*s\n\n", (int) l
, name
);
528 if (((unsigned int) (data
- orig_data
) != len
) || data
== end
)
529 warn (_("DW_LNE_define_file: Bad opcode length\n"));
532 case DW_LNE_set_discriminator
:
533 printf (_("set Discriminator to %s\n"),
534 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
538 case DW_LNE_HP_negate_is_UV_update
:
539 printf ("DW_LNE_HP_negate_is_UV_update\n");
541 case DW_LNE_HP_push_context
:
542 printf ("DW_LNE_HP_push_context\n");
544 case DW_LNE_HP_pop_context
:
545 printf ("DW_LNE_HP_pop_context\n");
547 case DW_LNE_HP_set_file_line_column
:
548 printf ("DW_LNE_HP_set_file_line_column\n");
550 case DW_LNE_HP_set_routine_name
:
551 printf ("DW_LNE_HP_set_routine_name\n");
553 case DW_LNE_HP_set_sequence
:
554 printf ("DW_LNE_HP_set_sequence\n");
556 case DW_LNE_HP_negate_post_semantics
:
557 printf ("DW_LNE_HP_negate_post_semantics\n");
559 case DW_LNE_HP_negate_function_exit
:
560 printf ("DW_LNE_HP_negate_function_exit\n");
562 case DW_LNE_HP_negate_front_end_logical
:
563 printf ("DW_LNE_HP_negate_front_end_logical\n");
565 case DW_LNE_HP_define_proc
:
566 printf ("DW_LNE_HP_define_proc\n");
568 case DW_LNE_HP_source_file_correlation
:
570 unsigned char *edata
= data
+ len
- bytes_read
- 1;
572 printf ("DW_LNE_HP_source_file_correlation\n");
578 opc
= read_uleb128 (data
, & bytes_read
, edata
);
583 case DW_LNE_HP_SFC_formfeed
:
584 printf (" DW_LNE_HP_SFC_formfeed\n");
586 case DW_LNE_HP_SFC_set_listing_line
:
587 printf (" DW_LNE_HP_SFC_set_listing_line (%s)\n",
589 read_uleb128 (data
, & bytes_read
, edata
)));
592 case DW_LNE_HP_SFC_associate
:
593 printf (" DW_LNE_HP_SFC_associate ");
596 read_uleb128 (data
, & bytes_read
, edata
)));
600 read_uleb128 (data
, & bytes_read
, edata
)));
604 read_uleb128 (data
, & bytes_read
, edata
)));
608 printf (_(" UNKNOWN DW_LNE_HP_SFC opcode (%u)\n"), opc
);
618 unsigned int rlen
= len
- bytes_read
- 1;
620 if (op_code
>= DW_LNE_lo_user
621 /* The test against DW_LNW_hi_user is redundant due to
622 the limited range of the unsigned char data type used
624 /*&& op_code <= DW_LNE_hi_user*/)
625 printf (_("user defined: "));
627 printf (_("UNKNOWN: "));
628 printf (_("length %d ["), rlen
);
630 printf (" %02x", *data
++);
639 static const unsigned char *
640 fetch_indirect_string (dwarf_vma offset
)
642 struct dwarf_section
*section
= &debug_displays
[str
].section
;
643 const unsigned char * ret
;
645 if (section
->start
== NULL
)
646 return (const unsigned char *) _("<no .debug_str section>");
648 if (offset
>= section
->size
)
650 warn (_("DW_FORM_strp offset too big: %s\n"),
651 dwarf_vmatoa ("x", offset
));
652 return (const unsigned char *) _("<offset is too big>");
655 ret
= section
->start
+ offset
;
656 /* Unfortunately we cannot rely upon the .debug_str section ending with a
657 NUL byte. Since our caller is expecting to receive a well formed C
658 string we test for the lack of a terminating byte here. */
659 if (strnlen ((const char *) ret
, section
->size
- offset
)
660 == section
->size
- offset
)
661 ret
= (const unsigned char *)
662 _("<no NUL byte at end of .debug_str section>");
667 static const unsigned char *
668 fetch_indirect_line_string (dwarf_vma offset
)
670 struct dwarf_section
*section
= &debug_displays
[line_str
].section
;
671 const unsigned char * ret
;
673 if (section
->start
== NULL
)
674 return (const unsigned char *) _("<no .debug_line_str section>");
676 if (offset
>= section
->size
)
678 warn (_("DW_FORM_line_strp offset too big: %s\n"),
679 dwarf_vmatoa ("x", offset
));
680 return (const unsigned char *) _("<offset is too big>");
683 ret
= section
->start
+ offset
;
684 /* Unfortunately we cannot rely upon the .debug_line_str section ending
685 with a NUL byte. Since our caller is expecting to receive a well formed
686 C string we test for the lack of a terminating byte here. */
687 if (strnlen ((const char *) ret
, section
->size
- offset
)
688 == section
->size
- offset
)
689 ret
= (const unsigned char *)
690 _("<no NUL byte at end of .debug_line_str section>");
696 fetch_indexed_string (dwarf_vma idx
, struct cu_tu_set
*this_set
,
697 dwarf_vma offset_size
, int dwo
)
699 enum dwarf_section_display_enum str_sec_idx
= dwo
? str_dwo
: str
;
700 enum dwarf_section_display_enum idx_sec_idx
= dwo
? str_index_dwo
: str_index
;
701 struct dwarf_section
*index_section
= &debug_displays
[idx_sec_idx
].section
;
702 struct dwarf_section
*str_section
= &debug_displays
[str_sec_idx
].section
;
703 dwarf_vma index_offset
= idx
* offset_size
;
704 dwarf_vma str_offset
;
707 if (index_section
->start
== NULL
)
708 return (dwo
? _("<no .debug_str_offsets.dwo section>")
709 : _("<no .debug_str_offsets section>"));
711 if (this_set
!= NULL
)
712 index_offset
+= this_set
->section_offsets
[DW_SECT_STR_OFFSETS
];
713 if (index_offset
>= index_section
->size
)
715 warn (_("DW_FORM_GNU_str_index offset too big: %s\n"),
716 dwarf_vmatoa ("x", index_offset
));
717 return _("<index offset is too big>");
720 if (str_section
->start
== NULL
)
721 return (dwo
? _("<no .debug_str.dwo section>")
722 : _("<no .debug_str section>"));
724 str_offset
= byte_get (index_section
->start
+ index_offset
, offset_size
);
725 str_offset
-= str_section
->address
;
726 if (str_offset
>= str_section
->size
)
728 warn (_("DW_FORM_GNU_str_index indirect offset too big: %s\n"),
729 dwarf_vmatoa ("x", str_offset
));
730 return _("<indirect index offset is too big>");
733 ret
= (const char *) str_section
->start
+ str_offset
;
734 /* Unfortunately we cannot rely upon str_section ending with a NUL byte.
735 Since our caller is expecting to receive a well formed C string we test
736 for the lack of a terminating byte here. */
737 if (strnlen (ret
, str_section
->size
- str_offset
)
738 == str_section
->size
- str_offset
)
739 ret
= (const char *) _("<no NUL byte at end of section>");
745 fetch_indexed_value (dwarf_vma offset
, dwarf_vma bytes
)
747 struct dwarf_section
*section
= &debug_displays
[debug_addr
].section
;
749 if (section
->start
== NULL
)
750 return (_("<no .debug_addr section>"));
752 if (offset
+ bytes
> section
->size
)
754 warn (_("Offset into section %s too big: %s\n"),
755 section
->name
, dwarf_vmatoa ("x", offset
));
756 return "<offset too big>";
759 return dwarf_vmatoa ("x", byte_get (section
->start
+ offset
, bytes
));
763 /* FIXME: There are better and more efficient ways to handle
764 these structures. For now though, I just want something that
765 is simple to implement. */
766 typedef struct abbrev_attr
768 unsigned long attribute
;
770 bfd_signed_vma implicit_const
;
771 struct abbrev_attr
*next
;
775 typedef struct abbrev_entry
780 struct abbrev_attr
*first_attr
;
781 struct abbrev_attr
*last_attr
;
782 struct abbrev_entry
*next
;
786 static abbrev_entry
*first_abbrev
= NULL
;
787 static abbrev_entry
*last_abbrev
= NULL
;
794 for (abbrv
= first_abbrev
; abbrv
;)
796 abbrev_entry
*next_abbrev
= abbrv
->next
;
799 for (attr
= abbrv
->first_attr
; attr
;)
801 abbrev_attr
*next_attr
= attr
->next
;
811 last_abbrev
= first_abbrev
= NULL
;
815 add_abbrev (unsigned long number
, unsigned long tag
, int children
)
819 entry
= (abbrev_entry
*) malloc (sizeof (*entry
));
824 entry
->entry
= number
;
826 entry
->children
= children
;
827 entry
->first_attr
= NULL
;
828 entry
->last_attr
= NULL
;
831 if (first_abbrev
== NULL
)
832 first_abbrev
= entry
;
834 last_abbrev
->next
= entry
;
840 add_abbrev_attr (unsigned long attribute
, unsigned long form
,
841 bfd_signed_vma implicit_const
)
845 attr
= (abbrev_attr
*) malloc (sizeof (*attr
));
850 attr
->attribute
= attribute
;
852 attr
->implicit_const
= implicit_const
;
855 if (last_abbrev
->first_attr
== NULL
)
856 last_abbrev
->first_attr
= attr
;
858 last_abbrev
->last_attr
->next
= attr
;
860 last_abbrev
->last_attr
= attr
;
863 /* Processes the (partial) contents of a .debug_abbrev section.
864 Returns NULL if the end of the section was encountered.
865 Returns the address after the last byte read if the end of
866 an abbreviation set was found. */
868 static unsigned char *
869 process_abbrev_section (unsigned char *start
, unsigned char *end
)
871 if (first_abbrev
!= NULL
)
876 unsigned int bytes_read
;
879 unsigned long attribute
;
882 entry
= read_uleb128 (start
, & bytes_read
, end
);
885 /* A single zero is supposed to end the section according
886 to the standard. If there's more, then signal that to
893 tag
= read_uleb128 (start
, & bytes_read
, end
);
900 add_abbrev (entry
, tag
, children
);
905 /* Initialize it due to a false compiler warning. */
906 bfd_signed_vma implicit_const
= -1;
908 attribute
= read_uleb128 (start
, & bytes_read
, end
);
913 form
= read_uleb128 (start
, & bytes_read
, end
);
918 if (form
== DW_FORM_implicit_const
)
920 implicit_const
= read_sleb128 (start
, & bytes_read
, end
);
926 add_abbrev_attr (attribute
, form
, implicit_const
);
928 while (attribute
!= 0);
931 /* Report the missing single zero which ends the section. */
932 error (_(".debug_abbrev section not zero terminated\n"));
938 get_TAG_name (unsigned long tag
)
940 const char *name
= get_DW_TAG_name ((unsigned int)tag
);
944 static char buffer
[100];
946 snprintf (buffer
, sizeof (buffer
), _("Unknown TAG value: %lx"), tag
);
954 get_FORM_name (unsigned long form
)
959 return "DW_FORM value: 0";
961 name
= get_DW_FORM_name (form
);
964 static char buffer
[100];
966 snprintf (buffer
, sizeof (buffer
), _("Unknown FORM value: %lx"), form
);
974 get_IDX_name (unsigned long idx
)
976 const char *name
= get_DW_IDX_name ((unsigned int) idx
);
980 static char buffer
[100];
982 snprintf (buffer
, sizeof (buffer
), _("Unknown IDX value: %lx"), idx
);
989 static unsigned char *
990 display_block (unsigned char *data
,
992 const unsigned char * const end
, char delimiter
)
996 printf (_("%c%s byte block: "), delimiter
, dwarf_vmatoa ("u", length
));
998 return (unsigned char *) end
;
1000 maxlen
= (dwarf_vma
) (end
- data
);
1001 length
= length
> maxlen
? maxlen
: length
;
1004 printf ("%lx ", (unsigned long) byte_get (data
++, 1));
1010 decode_location_expression (unsigned char * data
,
1011 unsigned int pointer_size
,
1012 unsigned int offset_size
,
1015 dwarf_vma cu_offset
,
1016 struct dwarf_section
* section
)
1019 unsigned int bytes_read
;
1021 dwarf_signed_vma svalue
;
1022 unsigned char *end
= data
+ length
;
1023 int need_frame_base
= 0;
1032 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1033 printf ("DW_OP_addr: %s", dwarf_vmatoa ("x", uvalue
));
1036 printf ("DW_OP_deref");
1039 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1040 printf ("DW_OP_const1u: %lu", (unsigned long) uvalue
);
1043 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 1, end
);
1044 printf ("DW_OP_const1s: %ld", (long) svalue
);
1047 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 2, end
);
1048 printf ("DW_OP_const2u: %lu", (unsigned long) uvalue
);
1051 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
1052 printf ("DW_OP_const2s: %ld", (long) svalue
);
1055 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
1056 printf ("DW_OP_const4u: %lu", (unsigned long) uvalue
);
1059 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
1060 printf ("DW_OP_const4s: %ld", (long) svalue
);
1063 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
1064 printf ("DW_OP_const8u: %lu ", (unsigned long) uvalue
);
1065 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
1066 printf ("%lu", (unsigned long) uvalue
);
1069 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
1070 printf ("DW_OP_const8s: %ld ", (long) svalue
);
1071 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
1072 printf ("%ld", (long) svalue
);
1075 printf ("DW_OP_constu: %s",
1076 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1080 printf ("DW_OP_consts: %s",
1081 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
1085 printf ("DW_OP_dup");
1088 printf ("DW_OP_drop");
1091 printf ("DW_OP_over");
1094 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1095 printf ("DW_OP_pick: %ld", (unsigned long) uvalue
);
1098 printf ("DW_OP_swap");
1101 printf ("DW_OP_rot");
1104 printf ("DW_OP_xderef");
1107 printf ("DW_OP_abs");
1110 printf ("DW_OP_and");
1113 printf ("DW_OP_div");
1116 printf ("DW_OP_minus");
1119 printf ("DW_OP_mod");
1122 printf ("DW_OP_mul");
1125 printf ("DW_OP_neg");
1128 printf ("DW_OP_not");
1131 printf ("DW_OP_or");
1134 printf ("DW_OP_plus");
1136 case DW_OP_plus_uconst
:
1137 printf ("DW_OP_plus_uconst: %s",
1138 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1142 printf ("DW_OP_shl");
1145 printf ("DW_OP_shr");
1148 printf ("DW_OP_shra");
1151 printf ("DW_OP_xor");
1154 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
1155 printf ("DW_OP_bra: %ld", (long) svalue
);
1158 printf ("DW_OP_eq");
1161 printf ("DW_OP_ge");
1164 printf ("DW_OP_gt");
1167 printf ("DW_OP_le");
1170 printf ("DW_OP_lt");
1173 printf ("DW_OP_ne");
1176 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
1177 printf ("DW_OP_skip: %ld", (long) svalue
);
1212 printf ("DW_OP_lit%d", op
- DW_OP_lit0
);
1247 printf ("DW_OP_reg%d (%s)", op
- DW_OP_reg0
,
1248 regname (op
- DW_OP_reg0
, 1));
1283 printf ("DW_OP_breg%d (%s): %s",
1285 regname (op
- DW_OP_breg0
, 1),
1286 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
1291 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1293 printf ("DW_OP_regx: %s (%s)",
1294 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1));
1297 need_frame_base
= 1;
1298 printf ("DW_OP_fbreg: %s",
1299 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
1303 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1305 printf ("DW_OP_bregx: %s (%s) %s",
1306 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1),
1307 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
1311 printf ("DW_OP_piece: %s",
1312 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1315 case DW_OP_deref_size
:
1316 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1317 printf ("DW_OP_deref_size: %ld", (long) uvalue
);
1319 case DW_OP_xderef_size
:
1320 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1321 printf ("DW_OP_xderef_size: %ld", (long) uvalue
);
1324 printf ("DW_OP_nop");
1327 /* DWARF 3 extensions. */
1328 case DW_OP_push_object_address
:
1329 printf ("DW_OP_push_object_address");
1332 /* XXX: Strictly speaking for 64-bit DWARF3 files
1333 this ought to be an 8-byte wide computation. */
1334 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
1335 printf ("DW_OP_call2: <0x%s>",
1336 dwarf_vmatoa ("x", svalue
+ cu_offset
));
1339 /* XXX: Strictly speaking for 64-bit DWARF3 files
1340 this ought to be an 8-byte wide computation. */
1341 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
1342 printf ("DW_OP_call4: <0x%s>",
1343 dwarf_vmatoa ("x", svalue
+ cu_offset
));
1345 case DW_OP_call_ref
:
1346 /* XXX: Strictly speaking for 64-bit DWARF3 files
1347 this ought to be an 8-byte wide computation. */
1348 if (dwarf_version
== -1)
1350 printf (_("(DW_OP_call_ref in frame info)"));
1351 /* No way to tell where the next op is, so just bail. */
1352 return need_frame_base
;
1354 if (dwarf_version
== 2)
1356 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1360 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1362 printf ("DW_OP_call_ref: <0x%s>", dwarf_vmatoa ("x", uvalue
));
1364 case DW_OP_form_tls_address
:
1365 printf ("DW_OP_form_tls_address");
1367 case DW_OP_call_frame_cfa
:
1368 printf ("DW_OP_call_frame_cfa");
1370 case DW_OP_bit_piece
:
1371 printf ("DW_OP_bit_piece: ");
1372 printf (_("size: %s "),
1373 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1375 printf (_("offset: %s "),
1376 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1380 /* DWARF 4 extensions. */
1381 case DW_OP_stack_value
:
1382 printf ("DW_OP_stack_value");
1385 case DW_OP_implicit_value
:
1386 printf ("DW_OP_implicit_value");
1387 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1389 data
= display_block (data
, uvalue
, end
, ' ');
1392 /* GNU extensions. */
1393 case DW_OP_GNU_push_tls_address
:
1394 printf (_("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown"));
1396 case DW_OP_GNU_uninit
:
1397 printf ("DW_OP_GNU_uninit");
1398 /* FIXME: Is there data associated with this OP ? */
1400 case DW_OP_GNU_encoded_addr
:
1407 addr
= get_encoded_value (&data
, encoding
, section
, end
);
1409 printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding
);
1410 print_dwarf_vma (addr
, pointer_size
);
1413 case DW_OP_implicit_pointer
:
1414 case DW_OP_GNU_implicit_pointer
:
1415 /* XXX: Strictly speaking for 64-bit DWARF3 files
1416 this ought to be an 8-byte wide computation. */
1417 if (dwarf_version
== -1)
1419 printf (_("(%s in frame info)"),
1420 (op
== DW_OP_implicit_pointer
1421 ? "DW_OP_implicit_pointer"
1422 : "DW_OP_GNU_implicit_pointer"));
1423 /* No way to tell where the next op is, so just bail. */
1424 return need_frame_base
;
1426 if (dwarf_version
== 2)
1428 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1432 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1434 printf ("%s: <0x%s> %s",
1435 (op
== DW_OP_implicit_pointer
1436 ? "DW_OP_implicit_pointer" : "DW_OP_GNU_implicit_pointer"),
1437 dwarf_vmatoa ("x", uvalue
),
1438 dwarf_vmatoa ("d", read_sleb128 (data
,
1439 &bytes_read
, end
)));
1442 case DW_OP_entry_value
:
1443 case DW_OP_GNU_entry_value
:
1444 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1446 /* PR 17531: file: 0cc9cd00. */
1447 if (uvalue
> (dwarf_vma
) (end
- data
))
1448 uvalue
= end
- data
;
1449 printf ("%s: (", (op
== DW_OP_entry_value
? "DW_OP_entry_value"
1450 : "DW_OP_GNU_entry_value"));
1451 if (decode_location_expression (data
, pointer_size
, offset_size
,
1452 dwarf_version
, uvalue
,
1453 cu_offset
, section
))
1454 need_frame_base
= 1;
1460 case DW_OP_const_type
:
1461 case DW_OP_GNU_const_type
:
1462 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1464 printf ("%s: <0x%s> ",
1465 (op
== DW_OP_const_type
? "DW_OP_const_type"
1466 : "DW_OP_GNU_const_type"),
1467 dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1468 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1469 data
= display_block (data
, uvalue
, end
, ' ');
1471 case DW_OP_regval_type
:
1472 case DW_OP_GNU_regval_type
:
1473 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1475 printf ("%s: %s (%s)",
1476 (op
== DW_OP_regval_type
? "DW_OP_regval_type"
1477 : "DW_OP_GNU_regval_type"),
1478 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1));
1479 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1481 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1483 case DW_OP_deref_type
:
1484 case DW_OP_GNU_deref_type
:
1485 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1487 (op
== DW_OP_deref_type
? "DW_OP_deref_type"
1488 : "DW_OP_GNU_deref_type"),
1490 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1492 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1495 case DW_OP_GNU_convert
:
1496 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1498 printf ("%s <0x%s>",
1499 (op
== DW_OP_convert
? "DW_OP_convert" : "DW_OP_GNU_convert"),
1500 dwarf_vmatoa ("x", uvalue
? cu_offset
+ uvalue
: 0));
1502 case DW_OP_reinterpret
:
1503 case DW_OP_GNU_reinterpret
:
1504 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1506 printf ("%s <0x%s>",
1507 (op
== DW_OP_reinterpret
? "DW_OP_reinterpret"
1508 : "DW_OP_GNU_reinterpret"),
1509 dwarf_vmatoa ("x", uvalue
? cu_offset
+ uvalue
: 0));
1511 case DW_OP_GNU_parameter_ref
:
1512 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
1513 printf ("DW_OP_GNU_parameter_ref: <0x%s>",
1514 dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1516 case DW_OP_GNU_addr_index
:
1517 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1519 printf ("DW_OP_GNU_addr_index <0x%s>", dwarf_vmatoa ("x", uvalue
));
1521 case DW_OP_GNU_const_index
:
1522 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1524 printf ("DW_OP_GNU_const_index <0x%s>", dwarf_vmatoa ("x", uvalue
));
1527 /* HP extensions. */
1528 case DW_OP_HP_is_value
:
1529 printf ("DW_OP_HP_is_value");
1530 /* FIXME: Is there data associated with this OP ? */
1532 case DW_OP_HP_fltconst4
:
1533 printf ("DW_OP_HP_fltconst4");
1534 /* FIXME: Is there data associated with this OP ? */
1536 case DW_OP_HP_fltconst8
:
1537 printf ("DW_OP_HP_fltconst8");
1538 /* FIXME: Is there data associated with this OP ? */
1540 case DW_OP_HP_mod_range
:
1541 printf ("DW_OP_HP_mod_range");
1542 /* FIXME: Is there data associated with this OP ? */
1544 case DW_OP_HP_unmod_range
:
1545 printf ("DW_OP_HP_unmod_range");
1546 /* FIXME: Is there data associated with this OP ? */
1549 printf ("DW_OP_HP_tls");
1550 /* FIXME: Is there data associated with this OP ? */
1553 /* PGI (STMicroelectronics) extensions. */
1554 case DW_OP_PGI_omp_thread_num
:
1555 /* Pushes the thread number for the current thread as it would be
1556 returned by the standard OpenMP library function:
1557 omp_get_thread_num(). The "current thread" is the thread for
1558 which the expression is being evaluated. */
1559 printf ("DW_OP_PGI_omp_thread_num");
1563 if (op
>= DW_OP_lo_user
1564 && op
<= DW_OP_hi_user
)
1565 printf (_("(User defined location op 0x%x)"), op
);
1567 printf (_("(Unknown location op 0x%x)"), op
);
1568 /* No way to tell where the next op is, so just bail. */
1569 return need_frame_base
;
1572 /* Separate the ops. */
1577 return need_frame_base
;
1580 /* Find the CU or TU set corresponding to the given CU_OFFSET.
1581 This is used for DWARF package files. */
1583 static struct cu_tu_set
*
1584 find_cu_tu_set_v2 (dwarf_vma cu_offset
, int do_types
)
1586 struct cu_tu_set
*p
;
1588 unsigned int dw_sect
;
1594 dw_sect
= DW_SECT_TYPES
;
1600 dw_sect
= DW_SECT_INFO
;
1604 if (p
->section_offsets
[dw_sect
] == cu_offset
)
1612 /* Add INC to HIGH_BITS:LOW_BITS. */
1614 add64 (dwarf_vma
* high_bits
, dwarf_vma
* low_bits
, dwarf_vma inc
)
1616 dwarf_vma tmp
= * low_bits
;
1620 /* FIXME: There is probably a better way of handling this:
1622 We need to cope with dwarf_vma being a 32-bit or 64-bit
1623 type. Plus regardless of its size LOW_BITS is meant to
1624 only hold 32-bits, so if there is overflow or wrap around
1625 we must propagate into HIGH_BITS. */
1626 if (tmp
< * low_bits
)
1630 else if (sizeof (tmp
) > 8
1640 static unsigned char *
1641 read_and_display_attr_value (unsigned long attribute
,
1643 dwarf_signed_vma implicit_const
,
1644 unsigned char * data
,
1645 unsigned char * end
,
1646 dwarf_vma cu_offset
,
1647 dwarf_vma pointer_size
,
1648 dwarf_vma offset_size
,
1650 debug_info
* debug_info_p
,
1652 struct dwarf_section
* section
,
1653 struct cu_tu_set
* this_set
, char delimiter
)
1655 dwarf_vma uvalue
= 0;
1656 unsigned char *block_start
= NULL
;
1657 unsigned char * orig_data
= data
;
1658 unsigned int bytes_read
;
1660 if (data
> end
|| (data
== end
&& form
!= DW_FORM_flag_present
))
1662 warn (_("Corrupt attribute\n"));
1671 case DW_FORM_ref_addr
:
1672 if (dwarf_version
== 2)
1673 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1674 else if (dwarf_version
== 3 || dwarf_version
== 4)
1675 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1677 error (_("Internal error: DWARF version is not 2, 3 or 4.\n"));
1682 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1686 case DW_FORM_line_strp
:
1687 case DW_FORM_sec_offset
:
1688 case DW_FORM_GNU_ref_alt
:
1689 case DW_FORM_GNU_strp_alt
:
1690 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1693 case DW_FORM_flag_present
:
1700 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1705 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 2, end
);
1710 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
1714 uvalue
= read_sleb128 (data
, & bytes_read
, end
);
1718 case DW_FORM_GNU_str_index
:
1719 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
1723 case DW_FORM_ref_udata
:
1725 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
1729 case DW_FORM_indirect
:
1730 form
= read_uleb128 (data
, & bytes_read
, end
);
1733 printf ("%c%s", delimiter
, get_FORM_name (form
));
1734 if (form
== DW_FORM_implicit_const
)
1736 implicit_const
= read_sleb128 (data
, & bytes_read
, end
);
1739 return read_and_display_attr_value (attribute
, form
, implicit_const
, data
,
1740 end
, cu_offset
, pointer_size
,
1741 offset_size
, dwarf_version
,
1742 debug_info_p
, do_loc
,
1743 section
, this_set
, delimiter
);
1744 case DW_FORM_GNU_addr_index
:
1745 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
1752 case DW_FORM_ref_addr
:
1754 printf ("%c<0x%s>", delimiter
, dwarf_vmatoa ("x",uvalue
));
1757 case DW_FORM_GNU_ref_alt
:
1759 printf ("%c<alt 0x%s>", delimiter
, dwarf_vmatoa ("x",uvalue
));
1765 case DW_FORM_ref_udata
:
1767 printf ("%c<0x%s>", delimiter
, dwarf_vmatoa ("x", uvalue
+ cu_offset
));
1772 case DW_FORM_sec_offset
:
1774 printf ("%c0x%s", delimiter
, dwarf_vmatoa ("x", uvalue
));
1777 case DW_FORM_flag_present
:
1784 printf ("%c%s", delimiter
, dwarf_vmatoa ("d", uvalue
));
1787 case DW_FORM_implicit_const
:
1789 printf ("%c%s", delimiter
, dwarf_vmatoa ("d", implicit_const
));
1796 dwarf_vma high_bits
;
1800 SAFE_BYTE_GET64 (data
, &high_bits
, &uvalue
, end
);
1802 if (form
== DW_FORM_ref8
)
1803 add64 (& high_bits
, & utmp
, cu_offset
);
1804 printf ("%c0x%s", delimiter
,
1805 dwarf_vmatoa64 (high_bits
, utmp
, buf
, sizeof (buf
)));
1808 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1809 && num_debug_info_entries
== 0)
1811 if (sizeof (uvalue
) == 8)
1812 SAFE_BYTE_GET (uvalue
, data
, 8, end
);
1814 error (_("DW_FORM_data8 is unsupported when sizeof (dwarf_vma) != 8\n"));
1820 case DW_FORM_data16
:
1823 dwarf_vma left_high_bits
, left_low_bits
;
1824 dwarf_vma right_high_bits
, right_low_bits
;
1826 SAFE_BYTE_GET64 (data
, &left_high_bits
, &left_low_bits
, end
);
1827 SAFE_BYTE_GET64 (data
+ 8, &right_high_bits
, &right_low_bits
, end
);
1828 if (byte_get
== byte_get_little_endian
)
1831 left_high_bits
^= right_high_bits
;
1832 right_high_bits
^= left_high_bits
;
1833 left_high_bits
^= right_high_bits
;
1834 left_low_bits
^= right_low_bits
;
1835 right_low_bits
^= left_low_bits
;
1836 left_low_bits
^= right_low_bits
;
1838 printf (" 0x%08" DWARF_VMA_FMT
"x%08" DWARF_VMA_FMT
"x"
1839 "%08" DWARF_VMA_FMT
"x%08" DWARF_VMA_FMT
"x",
1840 left_high_bits
, left_low_bits
, right_high_bits
,
1846 case DW_FORM_string
:
1848 printf ("%c%.*s", delimiter
, (int) (end
- data
), data
);
1849 data
+= strnlen ((char *) data
, end
- data
) + 1;
1853 case DW_FORM_exprloc
:
1854 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
1855 block_start
= data
+ bytes_read
;
1856 if (block_start
>= end
)
1858 warn (_("Block ends prematurely\n"));
1862 /* FIXME: Testing "(block_start + uvalue) < block_start" miscompiles with
1863 gcc 4.8.3 running on an x86_64 host in 32-bit mode. So we pre-compute
1864 block_start + uvalue here. */
1865 data
= block_start
+ uvalue
;
1866 /* PR 17512: file: 008-103549-0.001:0.1. */
1867 if (block_start
+ uvalue
> end
|| data
< block_start
)
1869 warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue
);
1870 uvalue
= end
- block_start
;
1873 data
= block_start
+ uvalue
;
1875 data
= display_block (block_start
, uvalue
, end
, delimiter
);
1878 case DW_FORM_block1
:
1879 SAFE_BYTE_GET (uvalue
, data
, 1, end
);
1880 block_start
= data
+ 1;
1881 if (block_start
>= end
)
1883 warn (_("Block ends prematurely\n"));
1887 data
= block_start
+ uvalue
;
1888 if (block_start
+ uvalue
> end
|| data
< block_start
)
1890 warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue
);
1891 uvalue
= end
- block_start
;
1894 data
= block_start
+ uvalue
;
1896 data
= display_block (block_start
, uvalue
, end
, delimiter
);
1899 case DW_FORM_block2
:
1900 SAFE_BYTE_GET (uvalue
, data
, 2, end
);
1901 block_start
= data
+ 2;
1902 if (block_start
>= end
)
1904 warn (_("Block ends prematurely\n"));
1908 data
= block_start
+ uvalue
;
1909 if (block_start
+ uvalue
> end
|| data
< block_start
)
1911 warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue
);
1912 uvalue
= end
- block_start
;
1915 data
= block_start
+ uvalue
;
1917 data
= display_block (block_start
, uvalue
, end
, delimiter
);
1920 case DW_FORM_block4
:
1921 SAFE_BYTE_GET (uvalue
, data
, 4, end
);
1922 block_start
= data
+ 4;
1923 /* PR 17512: file: 3371-3907-0.004. */
1924 if (block_start
>= end
)
1926 warn (_("Block ends prematurely\n"));
1930 data
= block_start
+ uvalue
;
1931 if (block_start
+ uvalue
> end
1932 /* PR 17531: file: 5b5f0592. */
1933 || data
< block_start
)
1935 warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue
);
1936 uvalue
= end
- block_start
;
1939 data
= block_start
+ uvalue
;
1941 data
= display_block (block_start
, uvalue
, end
, delimiter
);
1946 printf (_("%c(indirect string, offset: 0x%s): %s"), delimiter
,
1947 dwarf_vmatoa ("x", uvalue
),
1948 fetch_indirect_string (uvalue
));
1951 case DW_FORM_line_strp
:
1953 printf (_("%c(indirect line string, offset: 0x%s): %s"), delimiter
,
1954 dwarf_vmatoa ("x", uvalue
),
1955 fetch_indirect_line_string (uvalue
));
1958 case DW_FORM_GNU_str_index
:
1961 const char *suffix
= strrchr (section
->name
, '.');
1962 int dwo
= (suffix
&& strcmp (suffix
, ".dwo") == 0) ? 1 : 0;
1964 printf (_("%c(indexed string: 0x%s): %s"), delimiter
,
1965 dwarf_vmatoa ("x", uvalue
),
1966 fetch_indexed_string (uvalue
, this_set
, offset_size
, dwo
));
1970 case DW_FORM_GNU_strp_alt
:
1972 printf (_("%c(alt indirect string, offset: 0x%s)"), delimiter
,
1973 dwarf_vmatoa ("x", uvalue
));
1976 case DW_FORM_indirect
:
1977 /* Handled above. */
1980 case DW_FORM_ref_sig8
:
1983 dwarf_vma high_bits
;
1986 SAFE_BYTE_GET64 (data
, &high_bits
, &uvalue
, end
);
1987 printf ("%csignature: 0x%s", delimiter
,
1988 dwarf_vmatoa64 (high_bits
, uvalue
, buf
, sizeof (buf
)));
1993 case DW_FORM_GNU_addr_index
:
1995 printf (_("%c(addr_index: 0x%s): %s"), delimiter
,
1996 dwarf_vmatoa ("x", uvalue
),
1997 fetch_indexed_value (uvalue
* pointer_size
, pointer_size
));
2001 warn (_("Unrecognized form: %lu\n"), form
);
2005 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2006 && num_debug_info_entries
== 0
2007 && debug_info_p
!= NULL
)
2011 case DW_AT_frame_base
:
2012 have_frame_base
= 1;
2014 case DW_AT_location
:
2015 case DW_AT_string_length
:
2016 case DW_AT_return_addr
:
2017 case DW_AT_data_member_location
:
2018 case DW_AT_vtable_elem_location
:
2020 case DW_AT_static_link
:
2021 case DW_AT_use_location
:
2022 case DW_AT_call_value
:
2023 case DW_AT_GNU_call_site_value
:
2024 case DW_AT_call_data_value
:
2025 case DW_AT_GNU_call_site_data_value
:
2026 case DW_AT_call_target
:
2027 case DW_AT_GNU_call_site_target
:
2028 case DW_AT_call_target_clobbered
:
2029 case DW_AT_GNU_call_site_target_clobbered
:
2030 if ((dwarf_version
< 4
2031 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
2032 || form
== DW_FORM_sec_offset
)
2034 /* Process location list. */
2035 unsigned int lmax
= debug_info_p
->max_loc_offsets
;
2036 unsigned int num
= debug_info_p
->num_loc_offsets
;
2038 if (lmax
== 0 || num
>= lmax
)
2041 debug_info_p
->loc_offsets
= (dwarf_vma
*)
2042 xcrealloc (debug_info_p
->loc_offsets
,
2043 lmax
, sizeof (*debug_info_p
->loc_offsets
));
2044 debug_info_p
->have_frame_base
= (int *)
2045 xcrealloc (debug_info_p
->have_frame_base
,
2046 lmax
, sizeof (*debug_info_p
->have_frame_base
));
2047 debug_info_p
->max_loc_offsets
= lmax
;
2049 if (this_set
!= NULL
)
2050 uvalue
+= this_set
->section_offsets
[DW_SECT_LOC
];
2051 debug_info_p
->loc_offsets
[num
] = uvalue
;
2052 debug_info_p
->have_frame_base
[num
] = have_frame_base
;
2053 debug_info_p
->num_loc_offsets
++;
2058 if (need_base_address
)
2059 debug_info_p
->base_address
= uvalue
;
2062 case DW_AT_GNU_addr_base
:
2063 debug_info_p
->addr_base
= uvalue
;
2066 case DW_AT_GNU_ranges_base
:
2067 debug_info_p
->ranges_base
= uvalue
;
2071 if ((dwarf_version
< 4
2072 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
2073 || form
== DW_FORM_sec_offset
)
2075 /* Process range list. */
2076 unsigned int lmax
= debug_info_p
->max_range_lists
;
2077 unsigned int num
= debug_info_p
->num_range_lists
;
2079 if (lmax
== 0 || num
>= lmax
)
2082 debug_info_p
->range_lists
= (dwarf_vma
*)
2083 xcrealloc (debug_info_p
->range_lists
,
2084 lmax
, sizeof (*debug_info_p
->range_lists
));
2085 debug_info_p
->max_range_lists
= lmax
;
2087 debug_info_p
->range_lists
[num
] = uvalue
;
2088 debug_info_p
->num_range_lists
++;
2097 if (do_loc
|| attribute
== 0)
2100 /* For some attributes we can display further information. */
2107 case DW_INL_not_inlined
:
2108 printf (_("(not inlined)"));
2110 case DW_INL_inlined
:
2111 printf (_("(inlined)"));
2113 case DW_INL_declared_not_inlined
:
2114 printf (_("(declared as inline but ignored)"));
2116 case DW_INL_declared_inlined
:
2117 printf (_("(declared as inline and inlined)"));
2120 printf (_(" (Unknown inline attribute value: %s)"),
2121 dwarf_vmatoa ("x", uvalue
));
2126 case DW_AT_language
:
2130 /* Ordered by the numeric value of these constants. */
2131 case DW_LANG_C89
: printf ("(ANSI C)"); break;
2132 case DW_LANG_C
: printf ("(non-ANSI C)"); break;
2133 case DW_LANG_Ada83
: printf ("(Ada)"); break;
2134 case DW_LANG_C_plus_plus
: printf ("(C++)"); break;
2135 case DW_LANG_Cobol74
: printf ("(Cobol 74)"); break;
2136 case DW_LANG_Cobol85
: printf ("(Cobol 85)"); break;
2137 case DW_LANG_Fortran77
: printf ("(FORTRAN 77)"); break;
2138 case DW_LANG_Fortran90
: printf ("(Fortran 90)"); break;
2139 case DW_LANG_Pascal83
: printf ("(ANSI Pascal)"); break;
2140 case DW_LANG_Modula2
: printf ("(Modula 2)"); break;
2141 /* DWARF 2.1 values. */
2142 case DW_LANG_Java
: printf ("(Java)"); break;
2143 case DW_LANG_C99
: printf ("(ANSI C99)"); break;
2144 case DW_LANG_Ada95
: printf ("(ADA 95)"); break;
2145 case DW_LANG_Fortran95
: printf ("(Fortran 95)"); break;
2146 /* DWARF 3 values. */
2147 case DW_LANG_PLI
: printf ("(PLI)"); break;
2148 case DW_LANG_ObjC
: printf ("(Objective C)"); break;
2149 case DW_LANG_ObjC_plus_plus
: printf ("(Objective C++)"); break;
2150 case DW_LANG_UPC
: printf ("(Unified Parallel C)"); break;
2151 case DW_LANG_D
: printf ("(D)"); break;
2152 /* DWARF 4 values. */
2153 case DW_LANG_Python
: printf ("(Python)"); break;
2154 /* DWARF 5 values. */
2155 case DW_LANG_Go
: printf ("(Go)"); break;
2156 case DW_LANG_C_plus_plus_11
: printf ("(C++11)"); break;
2157 case DW_LANG_C11
: printf ("(C11)"); break;
2158 case DW_LANG_C_plus_plus_14
: printf ("(C++14)"); break;
2159 case DW_LANG_Fortran03
: printf ("(Fortran 03)"); break;
2160 case DW_LANG_Fortran08
: printf ("(Fortran 08)"); break;
2161 /* MIPS extension. */
2162 case DW_LANG_Mips_Assembler
: printf ("(MIPS assembler)"); break;
2163 /* UPC extension. */
2164 case DW_LANG_Upc
: printf ("(Unified Parallel C)"); break;
2166 if (uvalue
>= DW_LANG_lo_user
&& uvalue
<= DW_LANG_hi_user
)
2167 printf (_("(implementation defined: %s)"),
2168 dwarf_vmatoa ("x", uvalue
));
2170 printf (_("(Unknown: %s)"), dwarf_vmatoa ("x", uvalue
));
2175 case DW_AT_encoding
:
2179 case DW_ATE_void
: printf ("(void)"); break;
2180 case DW_ATE_address
: printf ("(machine address)"); break;
2181 case DW_ATE_boolean
: printf ("(boolean)"); break;
2182 case DW_ATE_complex_float
: printf ("(complex float)"); break;
2183 case DW_ATE_float
: printf ("(float)"); break;
2184 case DW_ATE_signed
: printf ("(signed)"); break;
2185 case DW_ATE_signed_char
: printf ("(signed char)"); break;
2186 case DW_ATE_unsigned
: printf ("(unsigned)"); break;
2187 case DW_ATE_unsigned_char
: printf ("(unsigned char)"); break;
2188 /* DWARF 2.1 values: */
2189 case DW_ATE_imaginary_float
: printf ("(imaginary float)"); break;
2190 case DW_ATE_decimal_float
: printf ("(decimal float)"); break;
2191 /* DWARF 3 values: */
2192 case DW_ATE_packed_decimal
: printf ("(packed_decimal)"); break;
2193 case DW_ATE_numeric_string
: printf ("(numeric_string)"); break;
2194 case DW_ATE_edited
: printf ("(edited)"); break;
2195 case DW_ATE_signed_fixed
: printf ("(signed_fixed)"); break;
2196 case DW_ATE_unsigned_fixed
: printf ("(unsigned_fixed)"); break;
2197 /* HP extensions: */
2198 case DW_ATE_HP_float80
: printf ("(HP_float80)"); break;
2199 case DW_ATE_HP_complex_float80
: printf ("(HP_complex_float80)"); break;
2200 case DW_ATE_HP_float128
: printf ("(HP_float128)"); break;
2201 case DW_ATE_HP_complex_float128
:printf ("(HP_complex_float128)"); break;
2202 case DW_ATE_HP_floathpintel
: printf ("(HP_floathpintel)"); break;
2203 case DW_ATE_HP_imaginary_float80
: printf ("(HP_imaginary_float80)"); break;
2204 case DW_ATE_HP_imaginary_float128
: printf ("(HP_imaginary_float128)"); break;
2205 /* DWARF 4 values: */
2206 case DW_ATE_UTF
: printf ("(unicode string)"); break;
2209 if (uvalue
>= DW_ATE_lo_user
2210 && uvalue
<= DW_ATE_hi_user
)
2211 printf (_("(user defined type)"));
2213 printf (_("(unknown type)"));
2218 case DW_AT_accessibility
:
2222 case DW_ACCESS_public
: printf ("(public)"); break;
2223 case DW_ACCESS_protected
: printf ("(protected)"); break;
2224 case DW_ACCESS_private
: printf ("(private)"); break;
2226 printf (_("(unknown accessibility)"));
2231 case DW_AT_visibility
:
2235 case DW_VIS_local
: printf ("(local)"); break;
2236 case DW_VIS_exported
: printf ("(exported)"); break;
2237 case DW_VIS_qualified
: printf ("(qualified)"); break;
2238 default: printf (_("(unknown visibility)")); break;
2242 case DW_AT_virtuality
:
2246 case DW_VIRTUALITY_none
: printf ("(none)"); break;
2247 case DW_VIRTUALITY_virtual
: printf ("(virtual)"); break;
2248 case DW_VIRTUALITY_pure_virtual
:printf ("(pure_virtual)"); break;
2249 default: printf (_("(unknown virtuality)")); break;
2253 case DW_AT_identifier_case
:
2257 case DW_ID_case_sensitive
: printf ("(case_sensitive)"); break;
2258 case DW_ID_up_case
: printf ("(up_case)"); break;
2259 case DW_ID_down_case
: printf ("(down_case)"); break;
2260 case DW_ID_case_insensitive
: printf ("(case_insensitive)"); break;
2261 default: printf (_("(unknown case)")); break;
2265 case DW_AT_calling_convention
:
2269 case DW_CC_normal
: printf ("(normal)"); break;
2270 case DW_CC_program
: printf ("(program)"); break;
2271 case DW_CC_nocall
: printf ("(nocall)"); break;
2273 if (uvalue
>= DW_CC_lo_user
2274 && uvalue
<= DW_CC_hi_user
)
2275 printf (_("(user defined)"));
2277 printf (_("(unknown convention)"));
2281 case DW_AT_ordering
:
2285 case -1: printf (_("(undefined)")); break;
2286 case 0: printf ("(row major)"); break;
2287 case 1: printf ("(column major)"); break;
2291 case DW_AT_frame_base
:
2292 have_frame_base
= 1;
2294 case DW_AT_location
:
2295 case DW_AT_string_length
:
2296 case DW_AT_return_addr
:
2297 case DW_AT_data_member_location
:
2298 case DW_AT_vtable_elem_location
:
2300 case DW_AT_static_link
:
2301 case DW_AT_use_location
:
2302 case DW_AT_call_value
:
2303 case DW_AT_GNU_call_site_value
:
2304 case DW_AT_call_data_value
:
2305 case DW_AT_GNU_call_site_data_value
:
2306 case DW_AT_call_target
:
2307 case DW_AT_GNU_call_site_target
:
2308 case DW_AT_call_target_clobbered
:
2309 case DW_AT_GNU_call_site_target_clobbered
:
2310 if ((dwarf_version
< 4
2311 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
2312 || form
== DW_FORM_sec_offset
)
2313 printf (_(" (location list)"));
2315 case DW_AT_allocated
:
2316 case DW_AT_associated
:
2317 case DW_AT_data_location
:
2319 case DW_AT_upper_bound
:
2320 case DW_AT_lower_bound
:
2323 int need_frame_base
;
2326 need_frame_base
= decode_location_expression (block_start
,
2331 cu_offset
, section
);
2333 if (need_frame_base
&& !have_frame_base
)
2334 printf (_(" [without DW_AT_frame_base]"));
2340 if (form
== DW_FORM_ref_sig8
2341 || form
== DW_FORM_GNU_ref_alt
)
2344 if (form
== DW_FORM_ref1
2345 || form
== DW_FORM_ref2
2346 || form
== DW_FORM_ref4
2347 || form
== DW_FORM_ref_udata
)
2348 uvalue
+= cu_offset
;
2350 if (uvalue
>= section
->size
)
2351 warn (_("Offset %s used as value for DW_AT_import attribute of DIE at offset 0x%lx is too big.\n"),
2352 dwarf_vmatoa ("x", uvalue
),
2353 (unsigned long) (orig_data
- section
->start
));
2356 unsigned long abbrev_number
;
2357 abbrev_entry
* entry
;
2359 abbrev_number
= read_uleb128 (section
->start
+ uvalue
, NULL
, end
);
2361 printf (_("\t[Abbrev Number: %ld"), abbrev_number
);
2362 /* Don't look up abbrev for DW_FORM_ref_addr, as it very often will
2363 use different abbrev table, and we don't track .debug_info chunks
2365 if (form
!= DW_FORM_ref_addr
)
2367 for (entry
= first_abbrev
; entry
!= NULL
; entry
= entry
->next
)
2368 if (entry
->entry
== abbrev_number
)
2371 printf (" (%s)", get_TAG_name (entry
->tag
));
2386 get_AT_name (unsigned long attribute
)
2391 return "DW_AT value: 0";
2393 /* One value is shared by the MIPS and HP extensions: */
2394 if (attribute
== DW_AT_MIPS_fde
)
2395 return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable";
2397 name
= get_DW_AT_name (attribute
);
2401 static char buffer
[100];
2403 snprintf (buffer
, sizeof (buffer
), _("Unknown AT value: %lx"),
2411 static unsigned char *
2412 read_and_display_attr (unsigned long attribute
,
2414 dwarf_signed_vma implicit_const
,
2415 unsigned char * data
,
2416 unsigned char * end
,
2417 dwarf_vma cu_offset
,
2418 dwarf_vma pointer_size
,
2419 dwarf_vma offset_size
,
2421 debug_info
* debug_info_p
,
2423 struct dwarf_section
* section
,
2424 struct cu_tu_set
* this_set
)
2427 printf (" %-18s:", get_AT_name (attribute
));
2428 data
= read_and_display_attr_value (attribute
, form
, implicit_const
, data
, end
,
2429 cu_offset
, pointer_size
, offset_size
,
2430 dwarf_version
, debug_info_p
,
2431 do_loc
, section
, this_set
, ' ');
2437 /* Process the contents of a .debug_info section. If do_loc is non-zero
2438 then we are scanning for location lists and we do not want to display
2439 anything to the user. If do_types is non-zero, we are processing
2440 a .debug_types section instead of a .debug_info section. */
2443 process_debug_info (struct dwarf_section
*section
,
2445 enum dwarf_section_display_enum abbrev_sec
,
2449 unsigned char *start
= section
->start
;
2450 unsigned char *end
= start
+ section
->size
;
2451 unsigned char *section_begin
;
2453 unsigned int num_units
= 0;
2455 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2456 && num_debug_info_entries
== 0
2461 /* First scan the section to get the number of comp units. */
2462 for (section_begin
= start
, num_units
= 0; section_begin
< end
;
2465 /* Read the first 4 bytes. For a 32-bit DWARF section, this
2466 will be the length. For a 64-bit DWARF section, it'll be
2467 the escape code 0xffffffff followed by an 8 byte length. */
2468 SAFE_BYTE_GET (length
, section_begin
, 4, end
);
2470 if (length
== 0xffffffff)
2472 SAFE_BYTE_GET (length
, section_begin
+ 4, 8, end
);
2473 section_begin
+= length
+ 12;
2475 else if (length
>= 0xfffffff0 && length
< 0xffffffff)
2477 warn (_("Reserved length value (0x%s) found in section %s\n"),
2478 dwarf_vmatoa ("x", length
), section
->name
);
2482 section_begin
+= length
+ 4;
2484 /* Negative values are illegal, they may even cause infinite
2485 looping. This can happen if we can't accurately apply
2486 relocations to an object file, or if the file is corrupt. */
2487 if ((signed long) length
<= 0 || section_begin
< start
)
2489 warn (_("Corrupt unit length (0x%s) found in section %s\n"),
2490 dwarf_vmatoa ("x", length
), section
->name
);
2497 error (_("No comp units in %s section ?\n"), section
->name
);
2501 /* Then allocate an array to hold the information. */
2502 debug_information
= (debug_info
*) cmalloc (num_units
,
2503 sizeof (* debug_information
));
2504 if (debug_information
== NULL
)
2506 error (_("Not enough memory for a debug info array of %u entries\n"),
2508 alloc_num_debug_info_entries
= num_debug_info_entries
= 0;
2511 /* PR 17531: file: 92ca3797.
2512 We cannot rely upon the debug_information array being initialised
2513 before it is used. A corrupt file could easily contain references
2514 to a unit for which information has not been made available. So
2515 we ensure that the array is zeroed here. */
2516 memset (debug_information
, 0, num_units
* sizeof (*debug_information
));
2518 alloc_num_debug_info_entries
= num_units
;
2523 if (dwarf_start_die
== 0)
2524 printf (_("Contents of the %s section:\n\n"), section
->name
);
2526 load_debug_section (str
, file
);
2527 load_debug_section (line_str
, file
);
2528 load_debug_section (str_dwo
, file
);
2529 load_debug_section (str_index
, file
);
2530 load_debug_section (str_index_dwo
, file
);
2531 load_debug_section (debug_addr
, file
);
2534 load_debug_section (abbrev_sec
, file
);
2535 if (debug_displays
[abbrev_sec
].section
.start
== NULL
)
2537 warn (_("Unable to locate %s section!\n"),
2538 debug_displays
[abbrev_sec
].section
.name
);
2542 for (section_begin
= start
, unit
= 0; start
< end
; unit
++)
2544 DWARF2_Internal_CompUnit compunit
;
2545 unsigned char *hdrptr
;
2546 unsigned char *tags
;
2547 int level
, last_level
, saved_level
;
2548 dwarf_vma cu_offset
;
2549 unsigned int offset_size
;
2550 int initial_length_size
;
2551 dwarf_vma signature_high
= 0;
2552 dwarf_vma signature_low
= 0;
2553 dwarf_vma type_offset
= 0;
2554 struct cu_tu_set
*this_set
;
2555 dwarf_vma abbrev_base
;
2560 SAFE_BYTE_GET_AND_INC (compunit
.cu_length
, hdrptr
, 4, end
);
2562 if (compunit
.cu_length
== 0xffffffff)
2564 SAFE_BYTE_GET_AND_INC (compunit
.cu_length
, hdrptr
, 8, end
);
2566 initial_length_size
= 12;
2571 initial_length_size
= 4;
2574 SAFE_BYTE_GET_AND_INC (compunit
.cu_version
, hdrptr
, 2, end
);
2576 cu_offset
= start
- section_begin
;
2578 this_set
= find_cu_tu_set_v2 (cu_offset
, do_types
);
2580 if (compunit
.cu_version
< 5)
2582 compunit
.cu_unit_type
= DW_UT_compile
;
2583 /* Initialize it due to a false compiler warning. */
2584 compunit
.cu_pointer_size
= -1;
2588 SAFE_BYTE_GET_AND_INC (compunit
.cu_unit_type
, hdrptr
, 1, end
);
2589 do_types
= (compunit
.cu_unit_type
== DW_UT_type
);
2591 SAFE_BYTE_GET_AND_INC (compunit
.cu_pointer_size
, hdrptr
, 1, end
);
2594 SAFE_BYTE_GET_AND_INC (compunit
.cu_abbrev_offset
, hdrptr
, offset_size
, end
);
2596 if (this_set
== NULL
)
2599 abbrev_size
= debug_displays
[abbrev_sec
].section
.size
;
2603 abbrev_base
= this_set
->section_offsets
[DW_SECT_ABBREV
];
2604 abbrev_size
= this_set
->section_sizes
[DW_SECT_ABBREV
];
2607 if (compunit
.cu_version
< 5)
2608 SAFE_BYTE_GET_AND_INC (compunit
.cu_pointer_size
, hdrptr
, 1, end
);
2610 /* PR 17512: file: 001-108546-0.001:0.1. */
2611 if (compunit
.cu_pointer_size
< 2 || compunit
.cu_pointer_size
> 8)
2613 warn (_("Invalid pointer size (%d) in compunit header, using %d instead\n"),
2614 compunit
.cu_pointer_size
, offset_size
);
2615 compunit
.cu_pointer_size
= offset_size
;
2620 SAFE_BYTE_GET64 (hdrptr
, &signature_high
, &signature_low
, end
);
2622 SAFE_BYTE_GET_AND_INC (type_offset
, hdrptr
, offset_size
, end
);
2625 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2626 && num_debug_info_entries
== 0
2629 debug_information
[unit
].cu_offset
= cu_offset
;
2630 debug_information
[unit
].pointer_size
2631 = compunit
.cu_pointer_size
;
2632 debug_information
[unit
].offset_size
= offset_size
;
2633 debug_information
[unit
].dwarf_version
= compunit
.cu_version
;
2634 debug_information
[unit
].base_address
= 0;
2635 debug_information
[unit
].addr_base
= DEBUG_INFO_UNAVAILABLE
;
2636 debug_information
[unit
].ranges_base
= DEBUG_INFO_UNAVAILABLE
;
2637 debug_information
[unit
].loc_offsets
= NULL
;
2638 debug_information
[unit
].have_frame_base
= NULL
;
2639 debug_information
[unit
].max_loc_offsets
= 0;
2640 debug_information
[unit
].num_loc_offsets
= 0;
2641 debug_information
[unit
].range_lists
= NULL
;
2642 debug_information
[unit
].max_range_lists
= 0;
2643 debug_information
[unit
].num_range_lists
= 0;
2646 if (!do_loc
&& dwarf_start_die
== 0)
2648 printf (_(" Compilation Unit @ offset 0x%s:\n"),
2649 dwarf_vmatoa ("x", cu_offset
));
2650 printf (_(" Length: 0x%s (%s)\n"),
2651 dwarf_vmatoa ("x", compunit
.cu_length
),
2652 offset_size
== 8 ? "64-bit" : "32-bit");
2653 printf (_(" Version: %d\n"), compunit
.cu_version
);
2654 printf (_(" Abbrev Offset: 0x%s\n"),
2655 dwarf_vmatoa ("x", compunit
.cu_abbrev_offset
));
2656 printf (_(" Pointer Size: %d\n"), compunit
.cu_pointer_size
);
2661 printf (_(" Signature: 0x%s\n"),
2662 dwarf_vmatoa64 (signature_high
, signature_low
,
2663 buf
, sizeof (buf
)));
2664 printf (_(" Type Offset: 0x%s\n"),
2665 dwarf_vmatoa ("x", type_offset
));
2667 if (this_set
!= NULL
)
2669 dwarf_vma
*offsets
= this_set
->section_offsets
;
2670 size_t *sizes
= this_set
->section_sizes
;
2672 printf (_(" Section contributions:\n"));
2673 printf (_(" .debug_abbrev.dwo: 0x%s 0x%s\n"),
2674 dwarf_vmatoa ("x", offsets
[DW_SECT_ABBREV
]),
2675 dwarf_vmatoa ("x", sizes
[DW_SECT_ABBREV
]));
2676 printf (_(" .debug_line.dwo: 0x%s 0x%s\n"),
2677 dwarf_vmatoa ("x", offsets
[DW_SECT_LINE
]),
2678 dwarf_vmatoa ("x", sizes
[DW_SECT_LINE
]));
2679 printf (_(" .debug_loc.dwo: 0x%s 0x%s\n"),
2680 dwarf_vmatoa ("x", offsets
[DW_SECT_LOC
]),
2681 dwarf_vmatoa ("x", sizes
[DW_SECT_LOC
]));
2682 printf (_(" .debug_str_offsets.dwo: 0x%s 0x%s\n"),
2683 dwarf_vmatoa ("x", offsets
[DW_SECT_STR_OFFSETS
]),
2684 dwarf_vmatoa ("x", sizes
[DW_SECT_STR_OFFSETS
]));
2688 if (cu_offset
+ compunit
.cu_length
+ initial_length_size
2691 warn (_("Debug info is corrupted, length of CU at %s"
2692 " extends beyond end of section (length = %s)\n"),
2693 dwarf_vmatoa ("x", cu_offset
),
2694 dwarf_vmatoa ("x", compunit
.cu_length
));
2699 start
+= compunit
.cu_length
+ initial_length_size
;
2703 warn (_("Debug info is corrupt. CU at %s extends beyond end of section"),
2704 dwarf_vmatoa ("x", cu_offset
));
2708 if (compunit
.cu_version
< 2 || compunit
.cu_version
> 5)
2710 warn (_("CU at offset %s contains corrupt or "
2711 "unsupported version number: %d.\n"),
2712 dwarf_vmatoa ("x", cu_offset
), compunit
.cu_version
);
2716 if (compunit
.cu_unit_type
!= DW_UT_compile
2717 && compunit
.cu_unit_type
!= DW_UT_type
)
2719 warn (_("CU at offset %s contains corrupt or "
2720 "unsupported unit type: %d.\n"),
2721 dwarf_vmatoa ("x", cu_offset
), compunit
.cu_unit_type
);
2727 /* Process the abbrevs used by this compilation unit. */
2728 if (compunit
.cu_abbrev_offset
>= abbrev_size
)
2729 warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"),
2730 (unsigned long) compunit
.cu_abbrev_offset
,
2731 (unsigned long) abbrev_size
);
2732 /* PR 17531: file:4bcd9ce9. */
2733 else if ((abbrev_base
+ abbrev_size
)
2734 > debug_displays
[abbrev_sec
].section
.size
)
2735 warn (_("Debug info is corrupted, abbrev size (%lx) is larger than abbrev section size (%lx)\n"),
2736 (unsigned long) abbrev_base
+ abbrev_size
,
2737 (unsigned long) debug_displays
[abbrev_sec
].section
.size
);
2739 process_abbrev_section
2740 (((unsigned char *) debug_displays
[abbrev_sec
].section
.start
2741 + abbrev_base
+ compunit
.cu_abbrev_offset
),
2742 ((unsigned char *) debug_displays
[abbrev_sec
].section
.start
2743 + abbrev_base
+ abbrev_size
));
2748 while (tags
< start
)
2750 unsigned int bytes_read
;
2751 unsigned long abbrev_number
;
2752 unsigned long die_offset
;
2753 abbrev_entry
*entry
;
2755 int do_printing
= 1;
2757 die_offset
= tags
- section_begin
;
2759 abbrev_number
= read_uleb128 (tags
, & bytes_read
, start
);
2762 /* A null DIE marks the end of a list of siblings or it may also be
2763 a section padding. */
2764 if (abbrev_number
== 0)
2766 /* Check if it can be a section padding for the last CU. */
2767 if (level
== 0 && start
== end
)
2771 for (chk
= tags
; chk
< start
; chk
++)
2778 if (!do_loc
&& die_offset
>= dwarf_start_die
2779 && (dwarf_cutoff_level
== -1
2780 || level
< dwarf_cutoff_level
))
2781 printf (_(" <%d><%lx>: Abbrev Number: 0\n"),
2787 static unsigned num_bogus_warns
= 0;
2789 if (num_bogus_warns
< 3)
2791 warn (_("Bogus end-of-siblings marker detected at offset %lx in %s section\n"),
2792 die_offset
, section
->name
);
2794 if (num_bogus_warns
== 3)
2795 warn (_("Further warnings about bogus end-of-sibling markers suppressed\n"));
2798 if (dwarf_start_die
!= 0 && level
< saved_level
)
2805 if (dwarf_start_die
!= 0 && die_offset
< dwarf_start_die
)
2809 if (dwarf_start_die
!= 0 && die_offset
== dwarf_start_die
)
2810 saved_level
= level
;
2811 do_printing
= (dwarf_cutoff_level
== -1
2812 || level
< dwarf_cutoff_level
);
2814 printf (_(" <%d><%lx>: Abbrev Number: %lu"),
2815 level
, die_offset
, abbrev_number
);
2816 else if (dwarf_cutoff_level
== -1
2817 || last_level
< dwarf_cutoff_level
)
2818 printf (_(" <%d><%lx>: ...\n"), level
, die_offset
);
2823 /* Scan through the abbreviation list until we reach the
2825 for (entry
= first_abbrev
;
2826 entry
&& entry
->entry
!= abbrev_number
;
2827 entry
= entry
->next
)
2832 if (!do_loc
&& do_printing
)
2837 warn (_("DIE at offset 0x%lx refers to abbreviation number %lu which does not exist\n"),
2838 die_offset
, abbrev_number
);
2842 if (!do_loc
&& do_printing
)
2843 printf (" (%s)\n", get_TAG_name (entry
->tag
));
2848 need_base_address
= 0;
2850 case DW_TAG_compile_unit
:
2851 need_base_address
= 1;
2853 case DW_TAG_entry_point
:
2854 case DW_TAG_subprogram
:
2855 need_base_address
= 0;
2856 /* Assuming that there is no DW_AT_frame_base. */
2857 have_frame_base
= 0;
2861 for (attr
= entry
->first_attr
;
2862 attr
&& attr
->attribute
;
2867 if (! do_loc
&& do_printing
)
2868 /* Show the offset from where the tag was extracted. */
2869 printf (" <%lx>", (unsigned long)(tags
- section_begin
));
2871 if (debug_information
&& unit
< alloc_num_debug_info_entries
)
2872 arg
= debug_information
+ unit
;
2876 tags
= read_and_display_attr (attr
->attribute
,
2878 attr
->implicit_const
,
2882 compunit
.cu_pointer_size
,
2884 compunit
.cu_version
,
2886 do_loc
|| ! do_printing
,
2891 if (entry
->children
)
2896 /* Set num_debug_info_entries here so that it can be used to check if
2897 we need to process .debug_loc and .debug_ranges sections. */
2898 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2899 && num_debug_info_entries
== 0
2902 if (num_units
> alloc_num_debug_info_entries
)
2903 num_debug_info_entries
= alloc_num_debug_info_entries
;
2905 num_debug_info_entries
= num_units
;
2914 /* Locate and scan the .debug_info section in the file and record the pointer
2915 sizes and offsets for the compilation units in it. Usually an executable
2916 will have just one pointer size, but this is not guaranteed, and so we try
2917 not to make any assumptions. Returns zero upon failure, or the number of
2918 compilation units upon success. */
2921 load_debug_info (void * file
)
2923 /* Reset the last pointer size so that we can issue correct error
2924 messages if we are displaying the contents of more than one section. */
2925 last_pointer_size
= 0;
2926 warned_about_missing_comp_units
= FALSE
;
2928 /* If we have already tried and failed to load the .debug_info
2929 section then do not bother to repeat the task. */
2930 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
2933 /* If we already have the information there is nothing else to do. */
2934 if (num_debug_info_entries
> 0)
2935 return num_debug_info_entries
;
2937 /* If this is a DWARF package file, load the CU and TU indexes. */
2938 (void) load_cu_tu_indexes (file
);
2940 if (load_debug_section (info
, file
)
2941 && process_debug_info (&debug_displays
[info
].section
, file
, abbrev
, 1, 0))
2942 return num_debug_info_entries
;
2944 if (load_debug_section (info_dwo
, file
)
2945 && process_debug_info (&debug_displays
[info_dwo
].section
, file
,
2947 return num_debug_info_entries
;
2949 num_debug_info_entries
= DEBUG_INFO_UNAVAILABLE
;
2953 /* Read a DWARF .debug_line section header starting at DATA.
2954 Upon success returns an updated DATA pointer and the LINFO
2955 structure and the END_OF_SEQUENCE pointer will be filled in.
2956 Otherwise returns NULL. */
2958 static unsigned char *
2959 read_debug_line_header (struct dwarf_section
* section
,
2960 unsigned char * data
,
2961 unsigned char * end
,
2962 DWARF2_Internal_LineInfo
* linfo
,
2963 unsigned char ** end_of_sequence
)
2965 unsigned char *hdrptr
;
2966 unsigned int initial_length_size
;
2967 unsigned char address_size
, segment_selector_size
;
2969 /* Extract information from the Line Number Program Header.
2970 (section 6.2.4 in the Dwarf3 doc). */
2973 /* Get and check the length of the block. */
2974 SAFE_BYTE_GET_AND_INC (linfo
->li_length
, hdrptr
, 4, end
);
2976 if (linfo
->li_length
== 0xffffffff)
2978 /* This section is 64-bit DWARF 3. */
2979 SAFE_BYTE_GET_AND_INC (linfo
->li_length
, hdrptr
, 8, end
);
2980 linfo
->li_offset_size
= 8;
2981 initial_length_size
= 12;
2985 linfo
->li_offset_size
= 4;
2986 initial_length_size
= 4;
2989 if (linfo
->li_length
+ initial_length_size
> section
->size
)
2991 /* If the length field has a relocation against it, then we should
2992 not complain if it is inaccurate (and probably negative). This
2993 happens in object files when the .debug_line section is actually
2994 comprised of several different .debug_line.* sections, (some of
2995 which may be removed by linker garbage collection), and a relocation
2996 is used to compute the correct length once that is done. */
2997 if (reloc_at (section
, (hdrptr
- section
->start
) - linfo
->li_offset_size
))
2999 linfo
->li_length
= (end
- data
) - initial_length_size
;
3003 warn (_("The length field (0x%lx) in the debug_line header is wrong - the section is too small\n"),
3004 (long) linfo
->li_length
);
3009 /* Get and check the version number. */
3010 SAFE_BYTE_GET_AND_INC (linfo
->li_version
, hdrptr
, 2, end
);
3012 if (linfo
->li_version
!= 2
3013 && linfo
->li_version
!= 3
3014 && linfo
->li_version
!= 4
3015 && linfo
->li_version
!= 5)
3017 warn (_("Only DWARF version 2, 3, 4 and 5 line info "
3018 "is currently supported.\n"));
3022 if (linfo
->li_version
>= 5)
3024 SAFE_BYTE_GET_AND_INC (address_size
, hdrptr
, 1, end
);
3026 SAFE_BYTE_GET_AND_INC (segment_selector_size
, hdrptr
, 1, end
);
3027 if (segment_selector_size
!= 0)
3029 warn (_("The %s section contains "
3030 "unsupported segment selector size: %d.\n"),
3031 section
->name
, segment_selector_size
);
3036 SAFE_BYTE_GET_AND_INC (linfo
->li_prologue_length
, hdrptr
,
3037 linfo
->li_offset_size
, end
);
3038 SAFE_BYTE_GET_AND_INC (linfo
->li_min_insn_length
, hdrptr
, 1, end
);
3040 if (linfo
->li_version
>= 4)
3042 SAFE_BYTE_GET_AND_INC (linfo
->li_max_ops_per_insn
, hdrptr
, 1, end
);
3044 if (linfo
->li_max_ops_per_insn
== 0)
3046 warn (_("Invalid maximum operations per insn.\n"));
3051 linfo
->li_max_ops_per_insn
= 1;
3053 SAFE_BYTE_GET_AND_INC (linfo
->li_default_is_stmt
, hdrptr
, 1, end
);
3054 SAFE_SIGNED_BYTE_GET_AND_INC (linfo
->li_line_base
, hdrptr
, 1, end
);
3055 SAFE_BYTE_GET_AND_INC (linfo
->li_line_range
, hdrptr
, 1, end
);
3056 SAFE_BYTE_GET_AND_INC (linfo
->li_opcode_base
, hdrptr
, 1, end
);
3058 * end_of_sequence
= data
+ linfo
->li_length
+ initial_length_size
;
3059 /* PR 17512: file:002-117414-0.004. */
3060 if (* end_of_sequence
> end
)
3062 warn (_("Line length %s extends beyond end of section\n"),
3063 dwarf_vmatoa ("u", linfo
->li_length
));
3064 * end_of_sequence
= end
;
3071 static unsigned char *
3072 display_formatted_table (unsigned char *data
,
3073 unsigned char *start
, unsigned char *end
,
3074 const DWARF2_Internal_LineInfo
*linfo
,
3075 struct dwarf_section
*section
, const char *what
)
3077 unsigned char *format_start
, format_count
, *format
, formati
;
3078 dwarf_vma data_count
, datai
;
3079 unsigned int bytes_read
, namepass
, last_entry
= 0;
3081 SAFE_BYTE_GET_AND_INC (format_count
, data
, 1, end
);
3082 format_start
= data
;
3083 for (formati
= 0; formati
< format_count
; formati
++)
3085 read_uleb128 (data
, & bytes_read
, end
);
3087 read_uleb128 (data
, & bytes_read
, end
);
3091 warn (_("Corrupt %s format table entry\n"), what
);
3096 data_count
= read_uleb128 (data
, & bytes_read
, end
);
3100 warn (_("Corrupt %s list\n"), what
);
3104 if (data_count
== 0)
3106 printf (_("\n The %s Table is empty.\n"), what
);
3110 printf (_("\n The %s Table (offset 0x%lx):\n"), what
,
3111 (long)(data
- start
));
3113 printf (_(" Entry"));
3114 /* Delay displaying name as the last entry for better screen layout. */
3115 for (namepass
= 0; namepass
< 2; namepass
++)
3117 format
= format_start
;
3118 for (formati
= 0; formati
< format_count
; formati
++)
3120 dwarf_vma content_type
;
3122 content_type
= read_uleb128 (format
, & bytes_read
, end
);
3123 format
+= bytes_read
;
3124 if ((content_type
== DW_LNCT_path
) == (namepass
== 1))
3125 switch (content_type
)
3128 printf (_("\tName"));
3130 case DW_LNCT_directory_index
:
3131 printf (_("\tDir"));
3133 case DW_LNCT_timestamp
:
3134 printf (_("\tTime"));
3137 printf (_("\tSize"));
3140 printf (_("\tMD5"));
3143 printf (_("\t(Unknown format content type %s)"),
3144 dwarf_vmatoa ("u", content_type
));
3146 read_uleb128 (format
, & bytes_read
, end
);
3147 format
+= bytes_read
;
3152 for (datai
= 0; datai
< data_count
; datai
++)
3154 unsigned char *datapass
= data
;
3156 printf (" %d", last_entry
++);
3157 /* Delay displaying name as the last entry for better screen layout. */
3158 for (namepass
= 0; namepass
< 2; namepass
++)
3160 format
= format_start
;
3162 for (formati
= 0; formati
< format_count
; formati
++)
3164 dwarf_vma content_type
, form
;
3166 content_type
= read_uleb128 (format
, & bytes_read
, end
);
3167 format
+= bytes_read
;
3168 form
= read_uleb128 (format
, & bytes_read
, end
);
3169 format
+= bytes_read
;
3170 data
= read_and_display_attr_value (0, form
, 0, data
, end
, 0, 0,
3171 linfo
->li_offset_size
,
3172 linfo
->li_version
, NULL
,
3173 ((content_type
== DW_LNCT_path
) != (namepass
== 1)),
3174 section
, NULL
, '\t');
3179 warn (_("Corrupt %s entries list\n"), what
);
3188 display_debug_lines_raw (struct dwarf_section
*section
,
3189 unsigned char *data
,
3190 unsigned char *end
, void *file
)
3192 unsigned char *start
= section
->start
;
3194 printf (_("Raw dump of debug contents of section %s:\n\n"),
3199 static DWARF2_Internal_LineInfo saved_linfo
;
3200 DWARF2_Internal_LineInfo linfo
;
3201 unsigned char *standard_opcodes
;
3202 unsigned char *end_of_sequence
;
3205 if (const_strneq (section
->name
, ".debug_line.")
3206 /* Note: the following does not apply to .debug_line.dwo sections.
3207 These are full debug_line sections. */
3208 && strcmp (section
->name
, ".debug_line.dwo") != 0)
3210 /* Sections named .debug_line.<foo> are fragments of a .debug_line
3211 section containing just the Line Number Statements. They are
3212 created by the assembler and intended to be used alongside gcc's
3213 -ffunction-sections command line option. When the linker's
3214 garbage collection decides to discard a .text.<foo> section it
3215 can then also discard the line number information in .debug_line.<foo>.
3217 Since the section is a fragment it does not have the details
3218 needed to fill out a LineInfo structure, so instead we use the
3219 details from the last full debug_line section that we processed. */
3220 end_of_sequence
= end
;
3221 standard_opcodes
= NULL
;
3222 linfo
= saved_linfo
;
3223 /* PR 17531: file: 0522b371. */
3224 if (linfo
.li_line_range
== 0)
3226 warn (_("Partial .debug_line. section encountered without a prior full .debug_line section\n"));
3229 reset_state_machine (linfo
.li_default_is_stmt
);
3233 unsigned char * hdrptr
;
3235 if ((hdrptr
= read_debug_line_header (section
, data
, end
, & linfo
,
3236 & end_of_sequence
)) == NULL
)
3239 printf (_(" Offset: 0x%lx\n"), (long)(data
- start
));
3240 printf (_(" Length: %ld\n"), (long) linfo
.li_length
);
3241 printf (_(" DWARF Version: %d\n"), linfo
.li_version
);
3242 printf (_(" Prologue Length: %d\n"), (int) linfo
.li_prologue_length
);
3243 printf (_(" Minimum Instruction Length: %d\n"), linfo
.li_min_insn_length
);
3244 if (linfo
.li_version
>= 4)
3245 printf (_(" Maximum Ops per Instruction: %d\n"), linfo
.li_max_ops_per_insn
);
3246 printf (_(" Initial value of 'is_stmt': %d\n"), linfo
.li_default_is_stmt
);
3247 printf (_(" Line Base: %d\n"), linfo
.li_line_base
);
3248 printf (_(" Line Range: %d\n"), linfo
.li_line_range
);
3249 printf (_(" Opcode Base: %d\n"), linfo
.li_opcode_base
);
3251 /* PR 17512: file: 1665-6428-0.004. */
3252 if (linfo
.li_line_range
== 0)
3254 warn (_("Line range of 0 is invalid, using 1 instead\n"));
3255 linfo
.li_line_range
= 1;
3258 reset_state_machine (linfo
.li_default_is_stmt
);
3260 /* Display the contents of the Opcodes table. */
3261 standard_opcodes
= hdrptr
;
3263 /* PR 17512: file: 002-417945-0.004. */
3264 if (standard_opcodes
+ linfo
.li_opcode_base
>= end
)
3266 warn (_("Line Base extends beyond end of section\n"));
3270 printf (_("\n Opcodes:\n"));
3272 for (i
= 1; i
< linfo
.li_opcode_base
; i
++)
3273 printf (_(" Opcode %d has %d args\n"), i
, standard_opcodes
[i
- 1]);
3275 /* Display the contents of the Directory table. */
3276 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
3278 if (linfo
.li_version
>= 5)
3280 load_debug_section (line_str
, file
);
3282 data
= display_formatted_table (data
, start
, end
, &linfo
, section
,
3284 data
= display_formatted_table (data
, start
, end
, &linfo
, section
,
3290 printf (_("\n The Directory Table is empty.\n"));
3293 unsigned int last_dir_entry
= 0;
3295 printf (_("\n The Directory Table (offset 0x%lx):\n"),
3296 (long)(data
- start
));
3298 while (data
< end
&& *data
!= 0)
3300 printf (" %d\t%.*s\n", ++last_dir_entry
, (int) (end
- data
), data
);
3302 data
+= strnlen ((char *) data
, end
- data
) + 1;
3305 /* PR 17512: file: 002-132094-0.004. */
3306 if (data
>= end
- 1)
3310 /* Skip the NUL at the end of the table. */
3313 /* Display the contents of the File Name table. */
3315 printf (_("\n The File Name Table is empty.\n"));
3318 printf (_("\n The File Name Table (offset 0x%lx):\n"),
3319 (long)(data
- start
));
3320 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
3322 while (data
< end
&& *data
!= 0)
3324 unsigned char *name
;
3325 unsigned int bytes_read
;
3327 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
3329 data
+= strnlen ((char *) data
, end
- data
) + 1;
3332 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
3335 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
3338 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
3340 printf ("%.*s\n", (int)(end
- name
), name
);
3344 warn (_("Corrupt file name table entry\n"));
3350 /* Skip the NUL at the end of the table. */
3355 saved_linfo
= linfo
;
3358 /* Now display the statements. */
3359 if (data
>= end_of_sequence
)
3360 printf (_(" No Line Number Statements.\n"));
3363 printf (_(" Line Number Statements:\n"));
3365 while (data
< end_of_sequence
)
3367 unsigned char op_code
;
3368 dwarf_signed_vma adv
;
3370 unsigned int bytes_read
;
3372 printf (" [0x%08lx]", (long)(data
- start
));
3376 if (op_code
>= linfo
.li_opcode_base
)
3378 op_code
-= linfo
.li_opcode_base
;
3379 uladv
= (op_code
/ linfo
.li_line_range
);
3380 if (linfo
.li_max_ops_per_insn
== 1)
3382 uladv
*= linfo
.li_min_insn_length
;
3383 state_machine_regs
.address
+= uladv
;
3384 printf (_(" Special opcode %d: "
3385 "advance Address by %s to 0x%s"),
3386 op_code
, dwarf_vmatoa ("u", uladv
),
3387 dwarf_vmatoa ("x", state_machine_regs
.address
));
3391 state_machine_regs
.address
3392 += ((state_machine_regs
.op_index
+ uladv
)
3393 / linfo
.li_max_ops_per_insn
)
3394 * linfo
.li_min_insn_length
;
3395 state_machine_regs
.op_index
3396 = (state_machine_regs
.op_index
+ uladv
)
3397 % linfo
.li_max_ops_per_insn
;
3398 printf (_(" Special opcode %d: "
3399 "advance Address by %s to 0x%s[%d]"),
3400 op_code
, dwarf_vmatoa ("u", uladv
),
3401 dwarf_vmatoa ("x", state_machine_regs
.address
),
3402 state_machine_regs
.op_index
);
3404 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
3405 state_machine_regs
.line
+= adv
;
3406 printf (_(" and Line by %s to %d\n"),
3407 dwarf_vmatoa ("d", adv
), state_machine_regs
.line
);
3409 else switch (op_code
)
3411 case DW_LNS_extended_op
:
3412 data
+= process_extended_line_op (data
, linfo
.li_default_is_stmt
, end
);
3416 printf (_(" Copy\n"));
3419 case DW_LNS_advance_pc
:
3420 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3422 if (linfo
.li_max_ops_per_insn
== 1)
3424 uladv
*= linfo
.li_min_insn_length
;
3425 state_machine_regs
.address
+= uladv
;
3426 printf (_(" Advance PC by %s to 0x%s\n"),
3427 dwarf_vmatoa ("u", uladv
),
3428 dwarf_vmatoa ("x", state_machine_regs
.address
));
3432 state_machine_regs
.address
3433 += ((state_machine_regs
.op_index
+ uladv
)
3434 / linfo
.li_max_ops_per_insn
)
3435 * linfo
.li_min_insn_length
;
3436 state_machine_regs
.op_index
3437 = (state_machine_regs
.op_index
+ uladv
)
3438 % linfo
.li_max_ops_per_insn
;
3439 printf (_(" Advance PC by %s to 0x%s[%d]\n"),
3440 dwarf_vmatoa ("u", uladv
),
3441 dwarf_vmatoa ("x", state_machine_regs
.address
),
3442 state_machine_regs
.op_index
);
3446 case DW_LNS_advance_line
:
3447 adv
= read_sleb128 (data
, & bytes_read
, end
);
3449 state_machine_regs
.line
+= adv
;
3450 printf (_(" Advance Line by %s to %d\n"),
3451 dwarf_vmatoa ("d", adv
),
3452 state_machine_regs
.line
);
3455 case DW_LNS_set_file
:
3456 adv
= read_uleb128 (data
, & bytes_read
, end
);
3458 printf (_(" Set File Name to entry %s in the File Name Table\n"),
3459 dwarf_vmatoa ("d", adv
));
3460 state_machine_regs
.file
= adv
;
3463 case DW_LNS_set_column
:
3464 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3466 printf (_(" Set column to %s\n"),
3467 dwarf_vmatoa ("u", uladv
));
3468 state_machine_regs
.column
= uladv
;
3471 case DW_LNS_negate_stmt
:
3472 adv
= state_machine_regs
.is_stmt
;
3474 printf (_(" Set is_stmt to %s\n"), dwarf_vmatoa ("d", adv
));
3475 state_machine_regs
.is_stmt
= adv
;
3478 case DW_LNS_set_basic_block
:
3479 printf (_(" Set basic block\n"));
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
)
3487 uladv
*= linfo
.li_min_insn_length
;
3488 state_machine_regs
.address
+= uladv
;
3489 printf (_(" Advance PC by constant %s to 0x%s\n"),
3490 dwarf_vmatoa ("u", uladv
),
3491 dwarf_vmatoa ("x", state_machine_regs
.address
));
3495 state_machine_regs
.address
3496 += ((state_machine_regs
.op_index
+ uladv
)
3497 / linfo
.li_max_ops_per_insn
)
3498 * linfo
.li_min_insn_length
;
3499 state_machine_regs
.op_index
3500 = (state_machine_regs
.op_index
+ uladv
)
3501 % linfo
.li_max_ops_per_insn
;
3502 printf (_(" Advance PC by constant %s to 0x%s[%d]\n"),
3503 dwarf_vmatoa ("u", uladv
),
3504 dwarf_vmatoa ("x", state_machine_regs
.address
),
3505 state_machine_regs
.op_index
);
3509 case DW_LNS_fixed_advance_pc
:
3510 SAFE_BYTE_GET_AND_INC (uladv
, data
, 2, end
);
3511 state_machine_regs
.address
+= uladv
;
3512 state_machine_regs
.op_index
= 0;
3513 printf (_(" Advance PC by fixed size amount %s to 0x%s\n"),
3514 dwarf_vmatoa ("u", uladv
),
3515 dwarf_vmatoa ("x", state_machine_regs
.address
));
3518 case DW_LNS_set_prologue_end
:
3519 printf (_(" Set prologue_end to true\n"));
3522 case DW_LNS_set_epilogue_begin
:
3523 printf (_(" Set epilogue_begin to true\n"));
3526 case DW_LNS_set_isa
:
3527 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3529 printf (_(" Set ISA to %s\n"), dwarf_vmatoa ("u", uladv
));
3533 printf (_(" Unknown opcode %d with operands: "), op_code
);
3535 if (standard_opcodes
!= NULL
)
3536 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
3538 printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data
,
3540 i
== 1 ? "" : ", ");
3556 unsigned char *name
;
3557 unsigned int directory_index
;
3558 unsigned int modification_date
;
3559 unsigned int length
;
3562 /* Output a decoded representation of the .debug_line section. */
3565 display_debug_lines_decoded (struct dwarf_section
*section
,
3566 unsigned char *data
,
3567 unsigned char *end
, void *fileptr
)
3569 static DWARF2_Internal_LineInfo saved_linfo
;
3571 printf (_("Decoded dump of debug contents of section %s:\n\n"),
3576 /* This loop amounts to one iteration per compilation unit. */
3577 DWARF2_Internal_LineInfo linfo
;
3578 unsigned char *standard_opcodes
;
3579 unsigned char *end_of_sequence
;
3581 File_Entry
*file_table
= NULL
;
3582 unsigned int n_files
= 0;
3583 unsigned char **directory_table
= NULL
;
3584 dwarf_vma n_directories
= 0;
3586 if (const_strneq (section
->name
, ".debug_line.")
3587 /* Note: the following does not apply to .debug_line.dwo sections.
3588 These are full debug_line sections. */
3589 && strcmp (section
->name
, ".debug_line.dwo") != 0)
3591 /* See comment in display_debug_lines_raw(). */
3592 end_of_sequence
= end
;
3593 standard_opcodes
= NULL
;
3594 linfo
= saved_linfo
;
3595 /* PR 17531: file: 0522b371. */
3596 if (linfo
.li_line_range
== 0)
3598 warn (_("Partial .debug_line. section encountered without a prior full .debug_line section\n"));
3601 reset_state_machine (linfo
.li_default_is_stmt
);
3605 unsigned char *hdrptr
;
3607 if ((hdrptr
= read_debug_line_header (section
, data
, end
, & linfo
,
3608 & end_of_sequence
)) == NULL
)
3611 /* PR 17531: file: 0522b371. */
3612 if (linfo
.li_line_range
== 0)
3614 warn (_("Line range of 0 is invalid, using 1 instead\n"));
3615 linfo
.li_line_range
= 1;
3617 reset_state_machine (linfo
.li_default_is_stmt
);
3619 /* Save a pointer to the contents of the Opcodes table. */
3620 standard_opcodes
= hdrptr
;
3622 /* Traverse the Directory table just to count entries. */
3623 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
3627 warn (_("opcode base of %d extends beyond end of section\n"),
3628 linfo
.li_opcode_base
);
3632 if (linfo
.li_version
>= 5)
3634 unsigned char *format_start
, format_count
, *format
;
3635 dwarf_vma formati
, entryi
;
3636 unsigned int bytes_read
;
3638 load_debug_section (line_str
, fileptr
);
3640 /* Skip directories format. */
3641 SAFE_BYTE_GET_AND_INC (format_count
, data
, 1, end
);
3642 format_start
= data
;
3643 for (formati
= 0; formati
< format_count
; formati
++)
3645 read_uleb128 (data
, & bytes_read
, end
);
3647 read_uleb128 (data
, & bytes_read
, end
);
3651 n_directories
= read_uleb128 (data
, & bytes_read
, end
);
3655 warn (_("Corrupt directories list\n"));
3659 directory_table
= (unsigned char **)
3660 xmalloc (n_directories
* sizeof (unsigned char *));
3662 for (entryi
= 0; entryi
< n_directories
; entryi
++)
3664 unsigned char **pathp
= &directory_table
[entryi
];
3666 format
= format_start
;
3667 for (formati
= 0; formati
< format_count
; formati
++)
3669 dwarf_vma content_type
, form
;
3672 content_type
= read_uleb128 (format
, & bytes_read
, end
);
3673 format
+= bytes_read
;
3674 form
= read_uleb128 (format
, & bytes_read
, end
);
3675 format
+= bytes_read
;
3678 warn (_("Corrupt directories list\n"));
3681 switch (content_type
)
3686 case DW_FORM_string
:
3689 case DW_FORM_line_strp
:
3690 SAFE_BYTE_GET (uvalue
, data
, linfo
.li_offset_size
,
3692 /* Remove const by the cast. */
3693 *pathp
= (unsigned char *)
3694 fetch_indirect_line_string (uvalue
);
3699 data
= read_and_display_attr_value (0, form
, 0, data
, end
,
3701 linfo
.li_offset_size
,
3708 warn (_("Corrupt directories list\n"));
3713 /* Skip files format. */
3714 SAFE_BYTE_GET_AND_INC (format_count
, data
, 1, end
);
3715 format_start
= data
;
3716 for (formati
= 0; formati
< format_count
; formati
++)
3718 read_uleb128 (data
, & bytes_read
, end
);
3720 read_uleb128 (data
, & bytes_read
, end
);
3724 n_files
= read_uleb128 (data
, & bytes_read
, end
);
3728 warn (_("Corrupt file name list\n"));
3732 file_table
= (File_Entry
*) xcalloc (1, n_files
3733 * sizeof (File_Entry
));
3735 for (entryi
= 0; entryi
< n_files
; entryi
++)
3737 File_Entry
*file
= &file_table
[entryi
];
3739 format
= format_start
;
3740 for (formati
= 0; formati
< format_count
; formati
++)
3742 dwarf_vma content_type
, form
;
3745 content_type
= read_uleb128 (format
, & bytes_read
, end
);
3746 format
+= bytes_read
;
3747 form
= read_uleb128 (format
, & bytes_read
, end
);
3748 format
+= bytes_read
;
3751 warn (_("Corrupt file name list\n"));
3754 switch (content_type
)
3759 case DW_FORM_string
:
3762 case DW_FORM_line_strp
:
3763 SAFE_BYTE_GET (uvalue
, data
, linfo
.li_offset_size
,
3765 /* Remove const by the cast. */
3766 file
->name
= (unsigned char *)
3767 fetch_indirect_line_string (uvalue
);
3771 case DW_LNCT_directory_index
:
3775 SAFE_BYTE_GET (file
->directory_index
, data
, 1,
3779 SAFE_BYTE_GET (file
->directory_index
, data
, 2,
3783 file
->directory_index
= read_uleb128 (data
, NULL
,
3789 data
= read_and_display_attr_value (0, form
, 0, data
, end
,
3791 linfo
.li_offset_size
,
3798 warn (_("Corrupt file name list\n"));
3807 unsigned char *ptr_directory_table
= data
;
3809 while (data
< end
&& *data
!= 0)
3811 data
+= strnlen ((char *) data
, end
- data
) + 1;
3818 warn (_("directory table ends unexpectedly\n"));
3823 /* Go through the directory table again to save the directories. */
3824 directory_table
= (unsigned char **)
3825 xmalloc (n_directories
* sizeof (unsigned char *));
3828 while (*ptr_directory_table
!= 0)
3830 directory_table
[i
] = ptr_directory_table
;
3831 ptr_directory_table
+= strnlen ((char *) ptr_directory_table
,
3832 ptr_directory_table
- end
) + 1;
3836 /* Skip the NUL at the end of the table. */
3839 /* Traverse the File Name table just to count the entries. */
3840 if (data
< end
&& *data
!= 0)
3842 unsigned char *ptr_file_name_table
= data
;
3844 while (data
< end
&& *data
!= 0)
3846 unsigned int bytes_read
;
3848 /* Skip Name, directory index, last modification time and length
3850 data
+= strnlen ((char *) data
, end
- data
) + 1;
3851 read_uleb128 (data
, & bytes_read
, end
);
3853 read_uleb128 (data
, & bytes_read
, end
);
3855 read_uleb128 (data
, & bytes_read
, end
);
3863 warn (_("file table ends unexpectedly\n"));
3868 /* Go through the file table again to save the strings. */
3869 file_table
= (File_Entry
*) xmalloc (n_files
* sizeof (File_Entry
));
3872 while (*ptr_file_name_table
!= 0)
3874 unsigned int bytes_read
;
3876 file_table
[i
].name
= ptr_file_name_table
;
3877 ptr_file_name_table
+= strnlen ((char *) ptr_file_name_table
,
3878 end
- ptr_file_name_table
) + 1;
3880 /* We are not interested in directory, time or size. */
3881 file_table
[i
].directory_index
= read_uleb128 (ptr_file_name_table
,
3883 ptr_file_name_table
+= bytes_read
;
3884 file_table
[i
].modification_date
= read_uleb128 (ptr_file_name_table
,
3886 ptr_file_name_table
+= bytes_read
;
3887 file_table
[i
].length
= read_uleb128 (ptr_file_name_table
, & bytes_read
, end
);
3888 ptr_file_name_table
+= bytes_read
;
3894 /* Skip the NUL at the end of the table. */
3898 /* Print the Compilation Unit's name and a header. */
3899 if (file_table
== NULL
)
3901 else if (directory_table
== NULL
)
3902 printf (_("CU: %s:\n"), file_table
[0].name
);
3905 unsigned int ix
= file_table
[0].directory_index
;
3906 const char *directory
;
3911 else if (n_directories
== 0)
3912 directory
= _("<unknown>");
3913 else if (ix
> n_directories
)
3915 warn (_("directory index %u > number of directories %s\n"),
3916 ix
, dwarf_vmatoa ("u", n_directories
));
3917 directory
= _("<corrupt>");
3920 directory
= (char *) directory_table
[ix
- 1];
3922 if (do_wide
|| strlen (directory
) < 76)
3923 printf (_("CU: %s/%s:\n"), directory
, file_table
[0].name
);
3925 printf ("%s:\n", file_table
[0].name
);
3928 printf (_("File name Line number Starting address\n"));
3929 saved_linfo
= linfo
;
3932 /* This loop iterates through the Dwarf Line Number Program. */
3933 while (data
< end_of_sequence
)
3935 unsigned char op_code
;
3937 unsigned long int uladv
;
3938 unsigned int bytes_read
;
3939 int is_special_opcode
= 0;
3943 if (op_code
>= linfo
.li_opcode_base
)
3945 op_code
-= linfo
.li_opcode_base
;
3946 uladv
= (op_code
/ linfo
.li_line_range
);
3947 if (linfo
.li_max_ops_per_insn
== 1)
3949 uladv
*= linfo
.li_min_insn_length
;
3950 state_machine_regs
.address
+= uladv
;
3954 state_machine_regs
.address
3955 += ((state_machine_regs
.op_index
+ uladv
)
3956 / linfo
.li_max_ops_per_insn
)
3957 * linfo
.li_min_insn_length
;
3958 state_machine_regs
.op_index
3959 = (state_machine_regs
.op_index
+ uladv
)
3960 % linfo
.li_max_ops_per_insn
;
3963 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
3964 state_machine_regs
.line
+= adv
;
3965 is_special_opcode
= 1;
3967 else switch (op_code
)
3969 case DW_LNS_extended_op
:
3971 unsigned int ext_op_code_len
;
3972 unsigned char ext_op_code
;
3973 unsigned char *op_code_data
= data
;
3975 ext_op_code_len
= read_uleb128 (op_code_data
, &bytes_read
,
3977 op_code_data
+= bytes_read
;
3979 if (ext_op_code_len
== 0)
3981 warn (_("Badly formed extended line op encountered!\n"));
3984 ext_op_code_len
+= bytes_read
;
3985 ext_op_code
= *op_code_data
++;
3987 switch (ext_op_code
)
3989 case DW_LNE_end_sequence
:
3990 reset_state_machine (linfo
.li_default_is_stmt
);
3992 case DW_LNE_set_address
:
3993 SAFE_BYTE_GET_AND_INC (state_machine_regs
.address
,
3995 ext_op_code_len
- bytes_read
- 1,
3997 state_machine_regs
.op_index
= 0;
3999 case DW_LNE_define_file
:
4001 file_table
= (File_Entry
*) xrealloc
4002 (file_table
, (n_files
+ 1) * sizeof (File_Entry
));
4004 ++state_machine_regs
.last_file_entry
;
4005 /* Source file name. */
4006 file_table
[n_files
].name
= op_code_data
;
4007 op_code_data
+= strlen ((char *) op_code_data
) + 1;
4008 /* Directory index. */
4009 file_table
[n_files
].directory_index
=
4010 read_uleb128 (op_code_data
, & bytes_read
,
4012 op_code_data
+= bytes_read
;
4013 /* Last modification time. */
4014 file_table
[n_files
].modification_date
=
4015 read_uleb128 (op_code_data
, & bytes_read
,
4017 op_code_data
+= bytes_read
;
4019 file_table
[n_files
].length
=
4020 read_uleb128 (op_code_data
, & bytes_read
,
4026 case DW_LNE_set_discriminator
:
4027 case DW_LNE_HP_set_sequence
:
4028 /* Simply ignored. */
4032 printf (_("UNKNOWN (%u): length %d\n"),
4033 ext_op_code
, ext_op_code_len
- bytes_read
);
4036 data
+= ext_op_code_len
;
4042 case DW_LNS_advance_pc
:
4043 uladv
= read_uleb128 (data
, & bytes_read
, end
);
4045 if (linfo
.li_max_ops_per_insn
== 1)
4047 uladv
*= linfo
.li_min_insn_length
;
4048 state_machine_regs
.address
+= uladv
;
4052 state_machine_regs
.address
4053 += ((state_machine_regs
.op_index
+ uladv
)
4054 / linfo
.li_max_ops_per_insn
)
4055 * linfo
.li_min_insn_length
;
4056 state_machine_regs
.op_index
4057 = (state_machine_regs
.op_index
+ uladv
)
4058 % linfo
.li_max_ops_per_insn
;
4062 case DW_LNS_advance_line
:
4063 adv
= read_sleb128 (data
, & bytes_read
, end
);
4065 state_machine_regs
.line
+= adv
;
4068 case DW_LNS_set_file
:
4069 adv
= read_uleb128 (data
, & bytes_read
, end
);
4071 state_machine_regs
.file
= adv
;
4074 unsigned file
= state_machine_regs
.file
- 1;
4077 if (file_table
== NULL
|| n_files
== 0)
4078 printf (_("\n [Use file table entry %d]\n"), file
);
4080 else if (file
>= n_files
)
4082 warn (_("file index %u > number of files %u\n"), file
+ 1, n_files
);
4083 printf (_("\n <over large file table index %u>"), file
);
4085 else if ((dir
= file_table
[file
].directory_index
) == 0)
4086 /* If directory index is 0, that means current directory. */
4087 printf ("\n./%s:[++]\n", file_table
[file
].name
);
4088 else if (directory_table
== NULL
|| n_directories
== 0)
4089 printf (_("\n [Use file %s in directory table entry %d]\n"),
4090 file_table
[file
].name
, dir
);
4092 else if (dir
> n_directories
)
4094 warn (_("directory index %u > number of directories %s\n"),
4095 dir
, dwarf_vmatoa ("u", n_directories
));
4096 printf (_("\n <over large directory table entry %u>\n"), dir
);
4099 printf ("\n%s/%s:\n",
4100 /* The directory index starts counting at 1. */
4101 directory_table
[dir
- 1], file_table
[file
].name
);
4105 case DW_LNS_set_column
:
4106 uladv
= read_uleb128 (data
, & bytes_read
, end
);
4108 state_machine_regs
.column
= uladv
;
4111 case DW_LNS_negate_stmt
:
4112 adv
= state_machine_regs
.is_stmt
;
4114 state_machine_regs
.is_stmt
= adv
;
4117 case DW_LNS_set_basic_block
:
4118 state_machine_regs
.basic_block
= 1;
4121 case DW_LNS_const_add_pc
:
4122 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
4123 if (linfo
.li_max_ops_per_insn
== 1)
4125 uladv
*= linfo
.li_min_insn_length
;
4126 state_machine_regs
.address
+= uladv
;
4130 state_machine_regs
.address
4131 += ((state_machine_regs
.op_index
+ uladv
)
4132 / linfo
.li_max_ops_per_insn
)
4133 * linfo
.li_min_insn_length
;
4134 state_machine_regs
.op_index
4135 = (state_machine_regs
.op_index
+ uladv
)
4136 % linfo
.li_max_ops_per_insn
;
4140 case DW_LNS_fixed_advance_pc
:
4141 SAFE_BYTE_GET_AND_INC (uladv
, data
, 2, end
);
4142 state_machine_regs
.address
+= uladv
;
4143 state_machine_regs
.op_index
= 0;
4146 case DW_LNS_set_prologue_end
:
4149 case DW_LNS_set_epilogue_begin
:
4152 case DW_LNS_set_isa
:
4153 uladv
= read_uleb128 (data
, & bytes_read
, end
);
4155 printf (_(" Set ISA to %lu\n"), uladv
);
4159 printf (_(" Unknown opcode %d with operands: "), op_code
);
4161 if (standard_opcodes
!= NULL
)
4162 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
4164 printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data
,
4166 i
== 1 ? "" : ", ");
4173 /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row
4174 to the DWARF address/line matrix. */
4175 if ((is_special_opcode
) || (op_code
== DW_LNE_end_sequence
)
4176 || (op_code
== DW_LNS_copy
))
4178 const unsigned int MAX_FILENAME_LENGTH
= 35;
4180 char *newFileName
= NULL
;
4181 size_t fileNameLength
;
4185 unsigned indx
= state_machine_regs
.file
- 1;
4187 if (indx
>= n_files
)
4189 warn (_("corrupt file index %u encountered\n"), indx
);
4190 fileName
= _("<corrupt>");
4193 fileName
= (char *) file_table
[indx
].name
;
4196 fileName
= _("<unknown>");
4198 fileNameLength
= strlen (fileName
);
4200 if ((fileNameLength
> MAX_FILENAME_LENGTH
) && (!do_wide
))
4202 newFileName
= (char *) xmalloc (MAX_FILENAME_LENGTH
+ 1);
4203 /* Truncate file name */
4204 strncpy (newFileName
,
4205 fileName
+ fileNameLength
- MAX_FILENAME_LENGTH
,
4206 MAX_FILENAME_LENGTH
+ 1);
4210 newFileName
= (char *) xmalloc (fileNameLength
+ 1);
4211 strncpy (newFileName
, fileName
, fileNameLength
+ 1);
4214 if (!do_wide
|| (fileNameLength
<= MAX_FILENAME_LENGTH
))
4216 if (linfo
.li_max_ops_per_insn
== 1)
4217 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x\n",
4218 newFileName
, state_machine_regs
.line
,
4219 state_machine_regs
.address
);
4221 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x[%d]\n",
4222 newFileName
, state_machine_regs
.line
,
4223 state_machine_regs
.address
,
4224 state_machine_regs
.op_index
);
4228 if (linfo
.li_max_ops_per_insn
== 1)
4229 printf ("%s %11d %#18" DWARF_VMA_FMT
"x\n",
4230 newFileName
, state_machine_regs
.line
,
4231 state_machine_regs
.address
);
4233 printf ("%s %11d %#18" DWARF_VMA_FMT
"x[%d]\n",
4234 newFileName
, state_machine_regs
.line
,
4235 state_machine_regs
.address
,
4236 state_machine_regs
.op_index
);
4239 if (op_code
== DW_LNE_end_sequence
)
4253 if (directory_table
)
4255 free (directory_table
);
4256 directory_table
= NULL
;
4267 display_debug_lines (struct dwarf_section
*section
, void *file
)
4269 unsigned char *data
= section
->start
;
4270 unsigned char *end
= data
+ section
->size
;
4272 int retValDecoded
= 1;
4274 if (do_debug_lines
== 0)
4275 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
4277 if (do_debug_lines
& FLAG_DEBUG_LINES_RAW
)
4278 retValRaw
= display_debug_lines_raw (section
, data
, end
, file
);
4280 if (do_debug_lines
& FLAG_DEBUG_LINES_DECODED
)
4281 retValDecoded
= display_debug_lines_decoded (section
, data
, end
, file
);
4283 if (!retValRaw
|| !retValDecoded
)
4290 find_debug_info_for_offset (unsigned long offset
)
4294 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
4297 for (i
= 0; i
< num_debug_info_entries
; i
++)
4298 if (debug_information
[i
].cu_offset
== offset
)
4299 return debug_information
+ i
;
4305 get_gdb_index_symbol_kind_name (gdb_index_symbol_kind kind
)
4307 /* See gdb/gdb-index.h. */
4308 static const char * const kinds
[] =
4320 return _ (kinds
[kind
]);
4324 display_debug_pubnames_worker (struct dwarf_section
*section
,
4325 void *file ATTRIBUTE_UNUSED
,
4328 DWARF2_Internal_PubNames names
;
4329 unsigned char *start
= section
->start
;
4330 unsigned char *end
= start
+ section
->size
;
4332 /* It does not matter if this load fails,
4333 we test for that later on. */
4334 load_debug_info (file
);
4336 printf (_("Contents of the %s section:\n\n"), section
->name
);
4340 unsigned char *data
;
4343 unsigned int offset_size
, initial_length_size
;
4347 SAFE_BYTE_GET_AND_INC (names
.pn_length
, data
, 4, end
);
4348 if (names
.pn_length
== 0xffffffff)
4350 SAFE_BYTE_GET_AND_INC (names
.pn_length
, data
, 8, end
);
4352 initial_length_size
= 12;
4357 initial_length_size
= 4;
4360 SAFE_BYTE_GET_AND_INC (names
.pn_version
, data
, 2, end
);
4361 SAFE_BYTE_GET_AND_INC (names
.pn_offset
, data
, offset_size
, end
);
4363 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
4364 && num_debug_info_entries
> 0
4365 && find_debug_info_for_offset (names
.pn_offset
) == NULL
)
4366 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
4367 (unsigned long) names
.pn_offset
, section
->name
);
4369 SAFE_BYTE_GET_AND_INC (names
.pn_size
, data
, offset_size
, end
);
4371 adr
= start
+ names
.pn_length
+ initial_length_size
;
4372 /* PR 17531: file: 7615b6b2. */
4373 if ((dwarf_signed_vma
) names
.pn_length
< 0
4374 /* PR 17531: file: a5dbeaa7. */
4377 warn (_("Negative length for public name: 0x%lx\n"), (long) names
.pn_length
);
4383 printf (_(" Length: %ld\n"),
4384 (long) names
.pn_length
);
4385 printf (_(" Version: %d\n"),
4387 printf (_(" Offset into .debug_info section: 0x%lx\n"),
4388 (unsigned long) names
.pn_offset
);
4389 printf (_(" Size of area in .debug_info section: %ld\n"),
4390 (long) names
.pn_size
);
4392 if (names
.pn_version
!= 2 && names
.pn_version
!= 3)
4394 static int warned
= 0;
4398 warn (_("Only DWARF 2 and 3 pubnames are currently supported\n"));
4406 printf (_("\n Offset Kind Name\n"));
4408 printf (_("\n Offset\tName\n"));
4412 bfd_size_type maxprint
;
4414 SAFE_BYTE_GET (offset
, data
, offset_size
, end
);
4418 data
+= offset_size
;
4421 maxprint
= (end
- data
) - 1;
4425 unsigned int kind_data
;
4426 gdb_index_symbol_kind kind
;
4427 const char *kind_name
;
4430 SAFE_BYTE_GET (kind_data
, data
, 1, end
);
4433 /* GCC computes the kind as the upper byte in the CU index
4434 word, and then right shifts it by the CU index size.
4435 Left shift KIND to where the gdb-index.h accessor macros
4437 kind_data
<<= GDB_INDEX_CU_BITSIZE
;
4438 kind
= GDB_INDEX_SYMBOL_KIND_VALUE (kind_data
);
4439 kind_name
= get_gdb_index_symbol_kind_name (kind
);
4440 is_static
= GDB_INDEX_SYMBOL_STATIC_VALUE (kind_data
);
4441 printf (" %-6lx %s,%-10s %.*s\n",
4442 (unsigned long) offset
, is_static
? _("s") : _("g"),
4443 kind_name
, (int) maxprint
, data
);
4446 printf (" %-6lx\t%.*s\n",
4447 (unsigned long) offset
, (int) maxprint
, data
);
4449 data
+= strnlen ((char *) data
, maxprint
) + 1;
4454 while (offset
!= 0);
4462 display_debug_pubnames (struct dwarf_section
*section
, void *file
)
4464 return display_debug_pubnames_worker (section
, file
, 0);
4468 display_debug_gnu_pubnames (struct dwarf_section
*section
, void *file
)
4470 return display_debug_pubnames_worker (section
, file
, 1);
4474 display_debug_macinfo (struct dwarf_section
*section
,
4475 void *file ATTRIBUTE_UNUSED
)
4477 unsigned char *start
= section
->start
;
4478 unsigned char *end
= start
+ section
->size
;
4479 unsigned char *curr
= start
;
4480 unsigned int bytes_read
;
4481 enum dwarf_macinfo_record_type op
;
4483 printf (_("Contents of the %s section:\n\n"), section
->name
);
4487 unsigned int lineno
;
4488 const unsigned char *string
;
4490 op
= (enum dwarf_macinfo_record_type
) *curr
;
4495 case DW_MACINFO_start_file
:
4497 unsigned int filenum
;
4499 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
4501 filenum
= read_uleb128 (curr
, & bytes_read
, end
);
4504 printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"),
4509 case DW_MACINFO_end_file
:
4510 printf (_(" DW_MACINFO_end_file\n"));
4513 case DW_MACINFO_define
:
4514 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
4517 curr
+= strnlen ((char *) string
, end
- string
) + 1;
4518 printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"),
4522 case DW_MACINFO_undef
:
4523 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
4526 curr
+= strnlen ((char *) string
, end
- string
) + 1;
4527 printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"),
4531 case DW_MACINFO_vendor_ext
:
4533 unsigned int constant
;
4535 constant
= read_uleb128 (curr
, & bytes_read
, end
);
4538 curr
+= strnlen ((char *) string
, end
- string
) + 1;
4539 printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"),
4549 /* Given LINE_OFFSET into the .debug_line section, attempt to return
4550 filename and dirname corresponding to file name table entry with index
4551 FILEIDX. Return NULL on failure. */
4553 static unsigned char *
4554 get_line_filename_and_dirname (dwarf_vma line_offset
,
4556 unsigned char **dir_name
)
4558 struct dwarf_section
*section
= &debug_displays
[line
].section
;
4559 unsigned char *hdrptr
, *dirtable
, *file_name
;
4560 unsigned int offset_size
, initial_length_size
;
4561 unsigned int version
, opcode_base
, bytes_read
;
4562 dwarf_vma length
, diridx
;
4563 const unsigned char * end
;
4566 if (section
->start
== NULL
4567 || line_offset
>= section
->size
4571 hdrptr
= section
->start
+ line_offset
;
4572 end
= section
->start
+ section
->size
;
4574 SAFE_BYTE_GET_AND_INC (length
, hdrptr
, 4, end
);
4575 if (length
== 0xffffffff)
4577 /* This section is 64-bit DWARF 3. */
4578 SAFE_BYTE_GET_AND_INC (length
, hdrptr
, 8, end
);
4580 initial_length_size
= 12;
4585 initial_length_size
= 4;
4587 if (length
+ initial_length_size
> section
->size
)
4590 SAFE_BYTE_GET_AND_INC (version
, hdrptr
, 2, end
);
4591 if (version
!= 2 && version
!= 3 && version
!= 4)
4593 hdrptr
+= offset_size
+ 1;/* Skip prologue_length and min_insn_length. */
4595 hdrptr
++; /* Skip max_ops_per_insn. */
4596 hdrptr
+= 3; /* Skip default_is_stmt, line_base, line_range. */
4598 SAFE_BYTE_GET_AND_INC (opcode_base
, hdrptr
, 1, end
);
4599 if (opcode_base
== 0)
4602 hdrptr
+= opcode_base
- 1;
4604 /* Skip over dirname table. */
4605 while (*hdrptr
!= '\0')
4606 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
4607 hdrptr
++; /* Skip the NUL at the end of the table. */
4608 /* Now skip over preceding filename table entries. */
4609 for (; *hdrptr
!= '\0' && fileidx
> 1; fileidx
--)
4611 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
4612 read_uleb128 (hdrptr
, &bytes_read
, end
);
4613 hdrptr
+= bytes_read
;
4614 read_uleb128 (hdrptr
, &bytes_read
, end
);
4615 hdrptr
+= bytes_read
;
4616 read_uleb128 (hdrptr
, &bytes_read
, end
);
4617 hdrptr
+= bytes_read
;
4619 if (hdrptr
== end
|| *hdrptr
== '\0')
4622 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
4623 diridx
= read_uleb128 (hdrptr
, &bytes_read
, end
);
4626 for (; *dirtable
!= '\0' && diridx
> 1; diridx
--)
4627 dirtable
+= strnlen ((char *) dirtable
, end
- dirtable
) + 1;
4628 if (*dirtable
== '\0')
4630 *dir_name
= dirtable
;
4635 display_debug_macro (struct dwarf_section
*section
,
4638 unsigned char *start
= section
->start
;
4639 unsigned char *end
= start
+ section
->size
;
4640 unsigned char *curr
= start
;
4641 unsigned char *extended_op_buf
[256];
4642 unsigned int bytes_read
;
4644 load_debug_section (str
, file
);
4645 load_debug_section (line
, file
);
4647 printf (_("Contents of the %s section:\n\n"), section
->name
);
4651 unsigned int lineno
, version
, flags
;
4652 unsigned int offset_size
= 4;
4653 const unsigned char *string
;
4654 dwarf_vma line_offset
= 0, sec_offset
= curr
- start
, offset
;
4655 unsigned char **extended_ops
= NULL
;
4657 SAFE_BYTE_GET_AND_INC (version
, curr
, 2, end
);
4658 if (version
!= 4 && version
!= 5)
4660 error (_("Only GNU extension to DWARF 4 or 5 of %s is currently supported.\n"),
4665 SAFE_BYTE_GET_AND_INC (flags
, curr
, 1, end
);
4668 printf (_(" Offset: 0x%lx\n"),
4669 (unsigned long) sec_offset
);
4670 printf (_(" Version: %d\n"), version
);
4671 printf (_(" Offset size: %d\n"), offset_size
);
4674 SAFE_BYTE_GET_AND_INC (line_offset
, curr
, offset_size
, end
);
4675 printf (_(" Offset into .debug_line: 0x%lx\n"),
4676 (unsigned long) line_offset
);
4680 unsigned int i
, count
, op
;
4683 SAFE_BYTE_GET_AND_INC (count
, curr
, 1, end
);
4685 memset (extended_op_buf
, 0, sizeof (extended_op_buf
));
4686 extended_ops
= extended_op_buf
;
4689 printf (_(" Extension opcode arguments:\n"));
4690 for (i
= 0; i
< count
; i
++)
4692 SAFE_BYTE_GET_AND_INC (op
, curr
, 1, end
);
4693 extended_ops
[op
] = curr
;
4694 nargs
= read_uleb128 (curr
, &bytes_read
, end
);
4697 printf (_(" DW_MACRO_%02x has no arguments\n"), op
);
4700 printf (_(" DW_MACRO_%02x arguments: "), op
);
4701 for (n
= 0; n
< nargs
; n
++)
4705 SAFE_BYTE_GET_AND_INC (form
, curr
, 1, end
);
4706 printf ("%s%s", get_FORM_name (form
),
4707 n
== nargs
- 1 ? "\n" : ", ");
4717 case DW_FORM_block1
:
4718 case DW_FORM_block2
:
4719 case DW_FORM_block4
:
4721 case DW_FORM_string
:
4723 case DW_FORM_sec_offset
:
4726 error (_("Invalid extension opcode form %s\n"),
4727 get_FORM_name (form
));
4743 error (_(".debug_macro section not zero terminated\n"));
4747 SAFE_BYTE_GET_AND_INC (op
, curr
, 1, end
);
4753 case DW_MACRO_start_file
:
4755 unsigned int filenum
;
4756 unsigned char *file_name
= NULL
, *dir_name
= NULL
;
4758 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4760 filenum
= read_uleb128 (curr
, &bytes_read
, end
);
4763 if ((flags
& 2) == 0)
4764 error (_("DW_MACRO_start_file used, but no .debug_line offset provided.\n"));
4767 = get_line_filename_and_dirname (line_offset
, filenum
,
4769 if (file_name
== NULL
)
4770 printf (_(" DW_MACRO_start_file - lineno: %d filenum: %d\n"),
4773 printf (_(" DW_MACRO_start_file - lineno: %d filenum: %d filename: %s%s%s\n"),
4775 dir_name
!= NULL
? (const char *) dir_name
: "",
4776 dir_name
!= NULL
? "/" : "", file_name
);
4780 case DW_MACRO_end_file
:
4781 printf (_(" DW_MACRO_end_file\n"));
4784 case DW_MACRO_define
:
4785 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4788 curr
+= strnlen ((char *) string
, end
- string
) + 1;
4789 printf (_(" DW_MACRO_define - lineno : %d macro : %s\n"),
4793 case DW_MACRO_undef
:
4794 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4797 curr
+= strnlen ((char *) string
, end
- string
) + 1;
4798 printf (_(" DW_MACRO_undef - lineno : %d macro : %s\n"),
4802 case DW_MACRO_define_strp
:
4803 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4805 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
4806 string
= fetch_indirect_string (offset
);
4807 printf (_(" DW_MACRO_define_strp - lineno : %d macro : %s\n"),
4811 case DW_MACRO_undef_strp
:
4812 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4814 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
4815 string
= fetch_indirect_string (offset
);
4816 printf (_(" DW_MACRO_undef_strp - lineno : %d macro : %s\n"),
4820 case DW_MACRO_import
:
4821 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
4822 printf (_(" DW_MACRO_import - offset : 0x%lx\n"),
4823 (unsigned long) offset
);
4826 case DW_MACRO_define_sup
:
4827 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4829 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
4830 printf (_(" DW_MACRO_define_sup - lineno : %d macro offset : 0x%lx\n"),
4831 lineno
, (unsigned long) offset
);
4834 case DW_MACRO_undef_sup
:
4835 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4837 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
4838 printf (_(" DW_MACRO_undef_sup - lineno : %d macro offset : 0x%lx\n"),
4839 lineno
, (unsigned long) offset
);
4842 case DW_MACRO_import_sup
:
4843 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
4844 printf (_(" DW_MACRO_import_sup - offset : 0x%lx\n"),
4845 (unsigned long) offset
);
4849 if (extended_ops
== NULL
|| extended_ops
[op
] == NULL
)
4851 error (_(" Unknown macro opcode %02x seen\n"), op
);
4856 /* Skip over unhandled opcodes. */
4858 unsigned char *desc
= extended_ops
[op
];
4859 nargs
= read_uleb128 (desc
, &bytes_read
, end
);
4863 printf (_(" DW_MACRO_%02x\n"), op
);
4866 printf (_(" DW_MACRO_%02x -"), op
);
4867 for (n
= 0; n
< nargs
; n
++)
4871 /* DW_FORM_implicit_const is not expected here. */
4872 SAFE_BYTE_GET_AND_INC (val
, desc
, 1, end
);
4874 = read_and_display_attr_value (0, val
, 0,
4875 curr
, end
, 0, 0, offset_size
,
4876 version
, NULL
, 0, NULL
,
4894 display_debug_abbrev (struct dwarf_section
*section
,
4895 void *file ATTRIBUTE_UNUSED
)
4897 abbrev_entry
*entry
;
4898 unsigned char *start
= section
->start
;
4899 unsigned char *end
= start
+ section
->size
;
4901 printf (_("Contents of the %s section:\n\n"), section
->name
);
4905 unsigned char *last
;
4910 start
= process_abbrev_section (start
, end
);
4912 if (first_abbrev
== NULL
)
4915 printf (_(" Number TAG (0x%lx)\n"), (long) (last
- section
->start
));
4917 for (entry
= first_abbrev
; entry
; entry
= entry
->next
)
4921 printf (" %ld %s [%s]\n",
4923 get_TAG_name (entry
->tag
),
4924 entry
->children
? _("has children") : _("no children"));
4926 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
4928 printf (" %-18s %s",
4929 get_AT_name (attr
->attribute
),
4930 get_FORM_name (attr
->form
));
4931 if (attr
->form
== DW_FORM_implicit_const
)
4932 printf (": %" BFD_VMA_FMT
"d", attr
->implicit_const
);
4944 /* Return true when ADDR is the maximum address, when addresses are
4945 POINTER_SIZE bytes long. */
4948 is_max_address (dwarf_vma addr
, unsigned int pointer_size
)
4950 dwarf_vma mask
= ~(~(dwarf_vma
) 1 << (pointer_size
* 8 - 1));
4951 return ((addr
& mask
) == mask
);
4954 /* Display a location list from a normal (ie, non-dwo) .debug_loc section. */
4957 display_loc_list (struct dwarf_section
*section
,
4958 unsigned char **start_ptr
,
4959 unsigned int debug_info_entry
,
4961 dwarf_vma base_address
,
4964 unsigned char *start
= *start_ptr
;
4965 unsigned char *section_end
= section
->start
+ section
->size
;
4966 unsigned long cu_offset
;
4967 unsigned int pointer_size
;
4968 unsigned int offset_size
;
4973 unsigned short length
;
4974 int need_frame_base
;
4976 if (debug_info_entry
>= num_debug_info_entries
)
4978 warn (_("No debug information available for loc lists of entry: %u\n"),
4983 cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
4984 pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
4985 offset_size
= debug_information
[debug_info_entry
].offset_size
;
4986 dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
4988 if (pointer_size
< 2 || pointer_size
> 8)
4990 warn (_("Invalid pointer size (%d) in debug info for entry %d\n"),
4991 pointer_size
, debug_info_entry
);
4997 dwarf_vma off
= offset
+ (start
- *start_ptr
);
4999 if (start
+ 2 * pointer_size
> section_end
)
5001 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5002 (unsigned long) offset
);
5006 printf (" %8.8lx ", (unsigned long) off
);
5008 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, section_end
);
5009 SAFE_BYTE_GET_AND_INC (end
, start
, pointer_size
, section_end
);
5011 if (begin
== 0 && end
== 0)
5013 /* PR 18374: In a object file we can have a location list that
5014 starts with a begin and end of 0 because there are relocations
5015 that need to be applied to the addresses. Actually applying
5016 the relocations now does not help as they will probably resolve
5017 to 0, since the object file has not been fully linked. Real
5018 end of list markers will not have any relocations against them. */
5019 if (! reloc_at (section
, off
)
5020 && ! reloc_at (section
, off
+ pointer_size
))
5022 printf (_("<End of list>\n"));
5027 /* Check base address specifiers. */
5028 if (is_max_address (begin
, pointer_size
)
5029 && !is_max_address (end
, pointer_size
))
5032 print_dwarf_vma (begin
, pointer_size
);
5033 print_dwarf_vma (end
, pointer_size
);
5034 printf (_("(base address)\n"));
5038 if (start
+ 2 > section_end
)
5040 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5041 (unsigned long) offset
);
5045 SAFE_BYTE_GET_AND_INC (length
, start
, 2, section_end
);
5047 if (start
+ length
> section_end
)
5049 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5050 (unsigned long) offset
);
5054 print_dwarf_vma (begin
+ base_address
, pointer_size
);
5055 print_dwarf_vma (end
+ base_address
, pointer_size
);
5058 need_frame_base
= decode_location_expression (start
,
5063 cu_offset
, section
);
5066 if (need_frame_base
&& !has_frame_base
)
5067 printf (_(" [without DW_AT_frame_base]"));
5070 fputs (_(" (start == end)"), stdout
);
5071 else if (begin
> end
)
5072 fputs (_(" (start > end)"), stdout
);
5082 /* Display a location list from a normal (ie, non-dwo) .debug_loclists section. */
5085 display_loclists_list (struct dwarf_section
*section
,
5086 unsigned char **start_ptr
,
5087 unsigned int debug_info_entry
,
5089 dwarf_vma base_address
,
5092 unsigned char *start
= *start_ptr
;
5093 unsigned char *section_end
= section
->start
+ section
->size
;
5094 unsigned long cu_offset
;
5095 unsigned int pointer_size
;
5096 unsigned int offset_size
;
5098 unsigned int bytes_read
;
5100 /* Initialize it due to a false compiler warning. */
5101 dwarf_vma begin
= -1;
5104 int need_frame_base
;
5106 if (debug_info_entry
>= num_debug_info_entries
)
5108 warn (_("No debug information available for "
5109 "loclists lists of entry: %u\n"),
5114 cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
5115 pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
5116 offset_size
= debug_information
[debug_info_entry
].offset_size
;
5117 dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
5119 if (pointer_size
< 2 || pointer_size
> 8)
5121 warn (_("Invalid pointer size (%d) in debug info for entry %d\n"),
5122 pointer_size
, debug_info_entry
);
5128 dwarf_vma off
= offset
+ (start
- *start_ptr
);
5129 enum dwarf_location_list_entry_type llet
;
5131 if (start
+ 1 > section_end
)
5133 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5134 (unsigned long) offset
);
5138 printf (" %8.8lx ", (unsigned long) off
);
5140 SAFE_BYTE_GET_AND_INC (llet
, start
, 1, section_end
);
5144 case DW_LLE_end_of_list
:
5145 printf (_("<End of list>\n"));
5147 case DW_LLE_offset_pair
:
5148 begin
= read_uleb128 (start
, &bytes_read
, section_end
);
5149 start
+= bytes_read
;
5150 end
= read_uleb128 (start
, &bytes_read
, section_end
);
5151 start
+= bytes_read
;
5153 case DW_LLE_base_address
:
5154 SAFE_BYTE_GET_AND_INC (base_address
, start
, pointer_size
,
5156 print_dwarf_vma (base_address
, pointer_size
);
5157 printf (_("(base address)\n"));
5160 error (_("Invalid location list entry type %d\n"), llet
);
5163 if (llet
== DW_LLE_end_of_list
)
5165 if (llet
!= DW_LLE_offset_pair
)
5168 if (start
+ 2 > section_end
)
5170 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5171 (unsigned long) offset
);
5175 length
= read_uleb128 (start
, &bytes_read
, section_end
);
5176 start
+= bytes_read
;
5178 print_dwarf_vma (begin
+ base_address
, pointer_size
);
5179 print_dwarf_vma (end
+ base_address
, pointer_size
);
5182 need_frame_base
= decode_location_expression (start
,
5187 cu_offset
, section
);
5190 if (need_frame_base
&& !has_frame_base
)
5191 printf (_(" [without DW_AT_frame_base]"));
5194 fputs (_(" (start == end)"), stdout
);
5195 else if (begin
> end
)
5196 fputs (_(" (start > end)"), stdout
);
5206 /* Print a .debug_addr table index in decimal, surrounded by square brackets,
5207 right-adjusted in a field of length LEN, and followed by a space. */
5210 print_addr_index (unsigned int idx
, unsigned int len
)
5212 static char buf
[15];
5213 snprintf (buf
, sizeof (buf
), "[%d]", idx
);
5214 printf ("%*s ", len
, buf
);
5217 /* Display a location list from a .dwo section. It uses address indexes rather
5218 than embedded addresses. This code closely follows display_loc_list, but the
5219 two are sufficiently different that combining things is very ugly. */
5222 display_loc_list_dwo (struct dwarf_section
*section
,
5223 unsigned char **start_ptr
,
5224 unsigned int debug_info_entry
,
5228 unsigned char *start
= *start_ptr
;
5229 unsigned char *section_end
= section
->start
+ section
->size
;
5230 unsigned long cu_offset
;
5231 unsigned int pointer_size
;
5232 unsigned int offset_size
;
5235 unsigned short length
;
5236 int need_frame_base
;
5238 unsigned int bytes_read
;
5240 if (debug_info_entry
>= num_debug_info_entries
)
5242 warn (_("No debug information for loc lists of entry: %u\n"),
5247 cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
5248 pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
5249 offset_size
= debug_information
[debug_info_entry
].offset_size
;
5250 dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
5252 if (pointer_size
< 2 || pointer_size
> 8)
5254 warn (_("Invalid pointer size (%d) in debug info for entry %d\n"),
5255 pointer_size
, debug_info_entry
);
5261 printf (" %8.8lx ", (unsigned long) (offset
+ (start
- *start_ptr
)));
5263 if (start
>= section_end
)
5265 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5266 (unsigned long) offset
);
5270 SAFE_BYTE_GET_AND_INC (entry_type
, start
, 1, section_end
);
5273 case 0: /* A terminating entry. */
5275 printf (_("<End of list>\n"));
5277 case 1: /* A base-address entry. */
5278 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
5279 start
+= bytes_read
;
5280 print_addr_index (idx
, 8);
5282 printf (_("(base address selection entry)\n"));
5284 case 2: /* A start/end entry. */
5285 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
5286 start
+= bytes_read
;
5287 print_addr_index (idx
, 8);
5288 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
5289 start
+= bytes_read
;
5290 print_addr_index (idx
, 8);
5292 case 3: /* A start/length entry. */
5293 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
5294 start
+= bytes_read
;
5295 print_addr_index (idx
, 8);
5296 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
5297 printf ("%08x ", idx
);
5299 case 4: /* An offset pair entry. */
5300 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
5301 printf ("%08x ", idx
);
5302 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
5303 printf ("%08x ", idx
);
5306 warn (_("Unknown location list entry type 0x%x.\n"), entry_type
);
5311 if (start
+ 2 > section_end
)
5313 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5314 (unsigned long) offset
);
5318 SAFE_BYTE_GET_AND_INC (length
, start
, 2, section_end
);
5319 if (start
+ length
> section_end
)
5321 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5322 (unsigned long) offset
);
5327 need_frame_base
= decode_location_expression (start
,
5332 cu_offset
, section
);
5335 if (need_frame_base
&& !has_frame_base
)
5336 printf (_(" [without DW_AT_frame_base]"));
5346 /* Sort array of indexes in ascending order of loc_offsets[idx]. */
5348 static dwarf_vma
*loc_offsets
;
5351 loc_offsets_compar (const void *ap
, const void *bp
)
5353 dwarf_vma a
= loc_offsets
[*(const unsigned int *) ap
];
5354 dwarf_vma b
= loc_offsets
[*(const unsigned int *) bp
];
5356 return (a
> b
) - (b
> a
);
5360 display_debug_loc (struct dwarf_section
*section
, void *file
)
5362 unsigned char *start
= section
->start
;
5363 unsigned long bytes
;
5364 unsigned char *section_begin
= start
;
5365 unsigned int num_loc_list
= 0;
5366 unsigned long last_offset
= 0;
5367 unsigned int first
= 0;
5370 int seen_first_offset
= 0;
5371 int locs_sorted
= 1;
5372 unsigned char *next
;
5373 unsigned int *array
= NULL
;
5374 const char *suffix
= strrchr (section
->name
, '.');
5376 int is_loclists
= strstr (section
->name
, "debug_loclists") != NULL
;
5377 dwarf_vma expected_start
= 0;
5379 if (suffix
&& strcmp (suffix
, ".dwo") == 0)
5382 bytes
= section
->size
;
5386 printf (_("\nThe %s section is empty.\n"), section
->name
);
5392 unsigned char *hdrptr
= section_begin
;
5393 dwarf_vma ll_length
;
5394 unsigned short ll_version
;
5395 unsigned char *end
= section_begin
+ section
->size
;
5396 unsigned char address_size
, segment_selector_size
;
5397 uint32_t offset_entry_count
;
5399 SAFE_BYTE_GET_AND_INC (ll_length
, hdrptr
, 4, end
);
5400 if (ll_length
== 0xffffffff)
5401 SAFE_BYTE_GET_AND_INC (ll_length
, hdrptr
, 8, end
);
5403 SAFE_BYTE_GET_AND_INC (ll_version
, hdrptr
, 2, end
);
5404 if (ll_version
!= 5)
5406 warn (_("The %s section contains corrupt or "
5407 "unsupported version number: %d.\n"),
5408 section
->name
, ll_version
);
5412 SAFE_BYTE_GET_AND_INC (address_size
, hdrptr
, 1, end
);
5414 SAFE_BYTE_GET_AND_INC (segment_selector_size
, hdrptr
, 1, end
);
5415 if (segment_selector_size
!= 0)
5417 warn (_("The %s section contains "
5418 "unsupported segment selector size: %d.\n"),
5419 section
->name
, segment_selector_size
);
5423 SAFE_BYTE_GET_AND_INC (offset_entry_count
, hdrptr
, 4, end
);
5424 if (offset_entry_count
!= 0)
5426 warn (_("The %s section contains "
5427 "unsupported offset entry count: %d.\n"),
5428 section
->name
, offset_entry_count
);
5432 expected_start
= hdrptr
- section_begin
;
5435 if (load_debug_info (file
) == 0)
5437 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
5442 /* Check the order of location list in .debug_info section. If
5443 offsets of location lists are in the ascending order, we can
5444 use `debug_information' directly. */
5445 for (i
= 0; i
< num_debug_info_entries
; i
++)
5449 num
= debug_information
[i
].num_loc_offsets
;
5450 if (num
> num_loc_list
)
5453 /* Check if we can use `debug_information' directly. */
5454 if (locs_sorted
&& num
!= 0)
5456 if (!seen_first_offset
)
5458 /* This is the first location list. */
5459 last_offset
= debug_information
[i
].loc_offsets
[0];
5461 seen_first_offset
= 1;
5467 for (; j
< num
; j
++)
5470 debug_information
[i
].loc_offsets
[j
])
5475 last_offset
= debug_information
[i
].loc_offsets
[j
];
5480 if (!seen_first_offset
)
5481 error (_("No location lists in .debug_info section!\n"));
5483 if (debug_information
[first
].num_loc_offsets
> 0
5484 && debug_information
[first
].loc_offsets
[0] != expected_start
)
5485 warn (_("Location lists in %s section start at 0x%s\n"),
5487 dwarf_vmatoa ("x", debug_information
[first
].loc_offsets
[0]));
5490 array
= (unsigned int *) xcmalloc (num_loc_list
, sizeof (unsigned int));
5491 printf (_("Contents of the %s section:\n\n"), section
->name
);
5492 if (reloc_at (section
, 0))
5493 printf (_(" Warning: This section has relocations - addresses seen here may not be accurate.\n\n"));
5494 printf (_(" Offset Begin End Expression\n"));
5496 seen_first_offset
= 0;
5497 for (i
= first
; i
< num_debug_info_entries
; i
++)
5500 dwarf_vma base_address
;
5506 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
5508 loc_offsets
= debug_information
[i
].loc_offsets
;
5509 qsort (array
, debug_information
[i
].num_loc_offsets
,
5510 sizeof (*array
), loc_offsets_compar
);
5513 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
5515 j
= locs_sorted
? k
: array
[k
];
5517 && debug_information
[i
].loc_offsets
[locs_sorted
5518 ? k
- 1 : array
[k
- 1]]
5519 == debug_information
[i
].loc_offsets
[j
])
5521 has_frame_base
= debug_information
[i
].have_frame_base
[j
];
5522 offset
= debug_information
[i
].loc_offsets
[j
];
5523 next
= section_begin
+ offset
;
5524 base_address
= debug_information
[i
].base_address
;
5526 if (!seen_first_offset
)
5527 seen_first_offset
= 1;
5531 warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"),
5532 (unsigned long) (start
- section_begin
),
5533 (unsigned long) offset
);
5534 else if (start
> next
)
5535 warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"),
5536 (unsigned long) (start
- section_begin
),
5537 (unsigned long) offset
);
5541 if (offset
>= bytes
)
5543 warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"),
5544 (unsigned long) offset
);
5551 display_loc_list_dwo (section
, &start
, i
, offset
,
5554 display_loc_list (section
, &start
, i
, offset
, base_address
,
5560 warn (_("DWO is not yet supported.\n"));
5562 display_loclists_list (section
, &start
, i
, offset
, base_address
,
5568 if (start
< section
->start
+ section
->size
)
5569 warn (_("There are %ld unused bytes at the end of section %s\n"),
5570 (long) (section
->start
+ section
->size
- start
), section
->name
);
5577 display_debug_str (struct dwarf_section
*section
,
5578 void *file ATTRIBUTE_UNUSED
)
5580 unsigned char *start
= section
->start
;
5581 unsigned long bytes
= section
->size
;
5582 dwarf_vma addr
= section
->address
;
5586 printf (_("\nThe %s section is empty.\n"), section
->name
);
5590 printf (_("Contents of the %s section:\n\n"), section
->name
);
5598 lbytes
= (bytes
> 16 ? 16 : bytes
);
5600 printf (" 0x%8.8lx ", (unsigned long) addr
);
5602 for (j
= 0; j
< 16; j
++)
5605 printf ("%2.2x", start
[j
]);
5613 for (j
= 0; j
< lbytes
; j
++)
5616 if (k
>= ' ' && k
< 0x80)
5635 display_debug_info (struct dwarf_section
*section
, void *file
)
5637 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 0);
5641 display_debug_types (struct dwarf_section
*section
, void *file
)
5643 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 1);
5647 display_trace_info (struct dwarf_section
*section
, void *file
)
5649 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 0);
5653 display_debug_aranges (struct dwarf_section
*section
,
5654 void *file ATTRIBUTE_UNUSED
)
5656 unsigned char *start
= section
->start
;
5657 unsigned char *end
= start
+ section
->size
;
5659 printf (_("Contents of the %s section:\n\n"), section
->name
);
5661 /* It does not matter if this load fails,
5662 we test for that later on. */
5663 load_debug_info (file
);
5667 unsigned char *hdrptr
;
5668 DWARF2_Internal_ARange arange
;
5669 unsigned char *addr_ranges
;
5672 unsigned char address_size
;
5674 unsigned int offset_size
;
5675 unsigned int initial_length_size
;
5679 SAFE_BYTE_GET_AND_INC (arange
.ar_length
, hdrptr
, 4, end
);
5680 if (arange
.ar_length
== 0xffffffff)
5682 SAFE_BYTE_GET_AND_INC (arange
.ar_length
, hdrptr
, 8, end
);
5684 initial_length_size
= 12;
5689 initial_length_size
= 4;
5692 SAFE_BYTE_GET_AND_INC (arange
.ar_version
, hdrptr
, 2, end
);
5693 SAFE_BYTE_GET_AND_INC (arange
.ar_info_offset
, hdrptr
, offset_size
, end
);
5695 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
5696 && num_debug_info_entries
> 0
5697 && find_debug_info_for_offset (arange
.ar_info_offset
) == NULL
)
5698 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
5699 (unsigned long) arange
.ar_info_offset
, section
->name
);
5701 SAFE_BYTE_GET_AND_INC (arange
.ar_pointer_size
, hdrptr
, 1, end
);
5702 SAFE_BYTE_GET_AND_INC (arange
.ar_segment_size
, hdrptr
, 1, end
);
5704 if (arange
.ar_version
!= 2 && arange
.ar_version
!= 3)
5706 /* PR 19872: A version number of 0 probably means that there is
5707 padding at the end of the .debug_aranges section. Gold puts
5708 it there when performing an incremental link, for example.
5709 So do not generate a warning in this case. */
5710 if (arange
.ar_version
)
5711 warn (_("Only DWARF 2 and 3 aranges are currently supported.\n"));
5715 printf (_(" Length: %ld\n"),
5716 (long) arange
.ar_length
);
5717 printf (_(" Version: %d\n"), arange
.ar_version
);
5718 printf (_(" Offset into .debug_info: 0x%lx\n"),
5719 (unsigned long) arange
.ar_info_offset
);
5720 printf (_(" Pointer Size: %d\n"), arange
.ar_pointer_size
);
5721 printf (_(" Segment Size: %d\n"), arange
.ar_segment_size
);
5723 address_size
= arange
.ar_pointer_size
+ arange
.ar_segment_size
;
5725 /* PR 17512: file: 001-108546-0.001:0.1. */
5726 if (address_size
== 0 || address_size
> 8)
5728 error (_("Invalid address size in %s section!\n"),
5733 /* The DWARF spec does not require that the address size be a power
5734 of two, but we do. This will have to change if we ever encounter
5735 an uneven architecture. */
5736 if ((address_size
& (address_size
- 1)) != 0)
5738 warn (_("Pointer size + Segment size is not a power of two.\n"));
5742 if (address_size
> 4)
5743 printf (_("\n Address Length\n"));
5745 printf (_("\n Address Length\n"));
5747 addr_ranges
= hdrptr
;
5749 /* Must pad to an alignment boundary that is twice the address size. */
5750 excess
= (hdrptr
- start
) % (2 * address_size
);
5752 addr_ranges
+= (2 * address_size
) - excess
;
5754 hdrptr
= start
+ arange
.ar_length
+ initial_length_size
;
5755 if (hdrptr
< start
|| hdrptr
> end
)
5757 error (_("Excessive header length: %lx\n"), (long) arange
.ar_length
);
5762 while (addr_ranges
+ 2 * address_size
<= start
)
5764 SAFE_BYTE_GET_AND_INC (address
, addr_ranges
, address_size
, end
);
5765 SAFE_BYTE_GET_AND_INC (length
, addr_ranges
, address_size
, end
);
5768 print_dwarf_vma (address
, address_size
);
5769 print_dwarf_vma (length
, address_size
);
5779 /* Comparison function for qsort. */
5781 comp_addr_base (const void * v0
, const void * v1
)
5783 debug_info
* info0
= (debug_info
*) v0
;
5784 debug_info
* info1
= (debug_info
*) v1
;
5785 return info0
->addr_base
- info1
->addr_base
;
5788 /* Display the debug_addr section. */
5790 display_debug_addr (struct dwarf_section
*section
,
5793 debug_info
**debug_addr_info
;
5794 unsigned char *entry
;
5799 if (section
->size
== 0)
5801 printf (_("\nThe %s section is empty.\n"), section
->name
);
5805 if (load_debug_info (file
) == 0)
5807 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
5812 printf (_("Contents of the %s section:\n\n"), section
->name
);
5814 /* PR 17531: file: cf38d01b.
5815 We use xcalloc because a corrupt file may not have initialised all of the
5816 fields in the debug_info structure, which means that the sort below might
5817 try to move uninitialised data. */
5818 debug_addr_info
= (debug_info
**) xcalloc ((num_debug_info_entries
+ 1),
5819 sizeof (debug_info
*));
5822 for (i
= 0; i
< num_debug_info_entries
; i
++)
5823 if (debug_information
[i
].addr_base
!= DEBUG_INFO_UNAVAILABLE
)
5825 /* PR 17531: file: cf38d01b. */
5826 if (debug_information
[i
].addr_base
>= section
->size
)
5827 warn (_("Corrupt address base (%lx) found in debug section %u\n"),
5828 (unsigned long) debug_information
[i
].addr_base
, i
);
5830 debug_addr_info
[count
++] = debug_information
+ i
;
5833 /* Add a sentinel to make iteration convenient. */
5834 debug_addr_info
[count
] = (debug_info
*) xmalloc (sizeof (debug_info
));
5835 debug_addr_info
[count
]->addr_base
= section
->size
;
5836 qsort (debug_addr_info
, count
, sizeof (debug_info
*), comp_addr_base
);
5838 for (i
= 0; i
< count
; i
++)
5841 unsigned int address_size
= debug_addr_info
[i
]->pointer_size
;
5843 printf (_(" For compilation unit at offset 0x%s:\n"),
5844 dwarf_vmatoa ("x", debug_addr_info
[i
]->cu_offset
));
5846 printf (_("\tIndex\tAddress\n"));
5847 entry
= section
->start
+ debug_addr_info
[i
]->addr_base
;
5848 end
= section
->start
+ debug_addr_info
[i
+ 1]->addr_base
;
5852 dwarf_vma base
= byte_get (entry
, address_size
);
5853 printf (_("\t%d:\t"), idx
);
5854 print_dwarf_vma (base
, address_size
);
5856 entry
+= address_size
;
5862 free (debug_addr_info
);
5866 /* Display the .debug_str_offsets and .debug_str_offsets.dwo sections. */
5868 display_debug_str_offsets (struct dwarf_section
*section
,
5869 void *file ATTRIBUTE_UNUSED
)
5871 if (section
->size
== 0)
5873 printf (_("\nThe %s section is empty.\n"), section
->name
);
5876 /* TODO: Dump the contents. This is made somewhat difficult by not knowing
5877 what the offset size is for this section. */
5881 /* Each debug_information[x].range_lists[y] gets this representation for
5882 sorting purposes. */
5886 /* The debug_information[x].range_lists[y] value. */
5887 dwarf_vma ranges_offset
;
5889 /* Original debug_information to find parameters of the data. */
5890 debug_info
*debug_info_p
;
5893 /* Sort struct range_entry in ascending order of its RANGES_OFFSET. */
5896 range_entry_compar (const void *ap
, const void *bp
)
5898 const struct range_entry
*a_re
= (const struct range_entry
*) ap
;
5899 const struct range_entry
*b_re
= (const struct range_entry
*) bp
;
5900 const dwarf_vma a
= a_re
->ranges_offset
;
5901 const dwarf_vma b
= b_re
->ranges_offset
;
5903 return (a
> b
) - (b
> a
);
5907 display_debug_ranges_list (unsigned char *start
, unsigned char *finish
,
5908 unsigned int pointer_size
, unsigned long offset
,
5909 unsigned long base_address
)
5911 while (start
< finish
)
5916 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, finish
);
5917 if (start
>= finish
)
5919 SAFE_SIGNED_BYTE_GET_AND_INC (end
, start
, pointer_size
, finish
);
5921 printf (" %8.8lx ", offset
);
5923 if (begin
== 0 && end
== 0)
5925 printf (_("<End of list>\n"));
5929 /* Check base address specifiers. */
5930 if (is_max_address (begin
, pointer_size
)
5931 && !is_max_address (end
, pointer_size
))
5934 print_dwarf_vma (begin
, pointer_size
);
5935 print_dwarf_vma (end
, pointer_size
);
5936 printf ("(base address)\n");
5940 print_dwarf_vma (begin
+ base_address
, pointer_size
);
5941 print_dwarf_vma (end
+ base_address
, pointer_size
);
5944 fputs (_("(start == end)"), stdout
);
5945 else if (begin
> end
)
5946 fputs (_("(start > end)"), stdout
);
5953 display_debug_rnglists_list (unsigned char *start
, unsigned char *finish
,
5954 unsigned int pointer_size
, unsigned long offset
,
5955 unsigned long base_address
)
5957 unsigned char *next
= start
;
5961 unsigned long off
= offset
+ (start
- next
);
5962 enum dwarf_range_list_entry rlet
;
5963 /* Initialize it due to a false compiler warning. */
5964 dwarf_vma begin
= -1, length
, end
= -1;
5965 unsigned int bytes_read
;
5967 if (start
+ 1 > finish
)
5969 warn (_("Range list starting at offset 0x%lx is not terminated.\n"),
5974 printf (" %8.8lx ", off
);
5976 SAFE_BYTE_GET_AND_INC (rlet
, start
, 1, finish
);
5980 case DW_RLE_end_of_list
:
5981 printf (_("<End of list>\n"));
5983 case DW_RLE_base_address
:
5984 SAFE_BYTE_GET_AND_INC (base_address
, start
, pointer_size
, finish
);
5985 print_dwarf_vma (base_address
, pointer_size
);
5986 printf (_("(base address)\n"));
5988 case DW_RLE_start_length
:
5989 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, finish
);
5990 length
= read_uleb128 (start
, &bytes_read
, finish
);
5991 start
+= bytes_read
;
5992 end
= begin
+ length
;
5994 case DW_RLE_offset_pair
:
5995 begin
= read_uleb128 (start
, &bytes_read
, finish
);
5996 start
+= bytes_read
;
5997 end
= read_uleb128 (start
, &bytes_read
, finish
);
5998 start
+= bytes_read
;
6000 case DW_RLE_start_end
:
6001 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, finish
);
6002 SAFE_BYTE_GET_AND_INC (end
, start
, pointer_size
, finish
);
6005 error (_("Invalid range list entry type %d\n"), rlet
);
6006 rlet
= DW_RLE_end_of_list
;
6009 if (rlet
== DW_RLE_end_of_list
)
6011 if (rlet
== DW_RLE_base_address
)
6014 print_dwarf_vma (begin
+ base_address
, pointer_size
);
6015 print_dwarf_vma (end
+ base_address
, pointer_size
);
6018 fputs (_("(start == end)"), stdout
);
6019 else if (begin
> end
)
6020 fputs (_("(start > end)"), stdout
);
6027 display_debug_ranges (struct dwarf_section
*section
,
6028 void *file ATTRIBUTE_UNUSED
)
6030 unsigned char *start
= section
->start
;
6031 unsigned char *last_start
= start
;
6032 unsigned long bytes
= section
->size
;
6033 unsigned char *section_begin
= start
;
6034 unsigned char *finish
= start
+ bytes
;
6035 unsigned int num_range_list
, i
;
6036 struct range_entry
*range_entries
, *range_entry_fill
;
6037 int is_rnglists
= strstr (section
->name
, "debug_rnglists") != NULL
;
6038 /* Initialize it due to a false compiler warning. */
6039 unsigned char address_size
= 0;
6043 printf (_("\nThe %s section is empty.\n"), section
->name
);
6049 dwarf_vma initial_length
;
6050 unsigned int initial_length_size
;
6051 unsigned char segment_selector_size
;
6052 unsigned int offset_size
, offset_entry_count
;
6053 unsigned short version
;
6055 /* Get and check the length of the block. */
6056 SAFE_BYTE_GET_AND_INC (initial_length
, start
, 4, finish
);
6058 if (initial_length
== 0xffffffff)
6060 /* This section is 64-bit DWARF 3. */
6061 SAFE_BYTE_GET_AND_INC (initial_length
, start
, 8, finish
);
6063 initial_length_size
= 12;
6068 initial_length_size
= 4;
6071 if (initial_length
+ initial_length_size
> section
->size
)
6073 /* If the length field has a relocation against it, then we should
6074 not complain if it is inaccurate (and probably negative).
6075 It is copied from .debug_line handling code. */
6076 if (reloc_at (section
, (start
- section
->start
) - offset_size
))
6078 initial_length
= (finish
- start
) - initial_length_size
;
6082 warn (_("The length field (0x%lx) in the debug_rnglists header is wrong - the section is too small\n"),
6083 (long) initial_length
);
6088 /* Get and check the version number. */
6089 SAFE_BYTE_GET_AND_INC (version
, start
, 2, finish
);
6093 warn (_("Only DWARF version 5 debug_rnglists info "
6094 "is currently supported.\n"));
6098 SAFE_BYTE_GET_AND_INC (address_size
, start
, 1, finish
);
6100 SAFE_BYTE_GET_AND_INC (segment_selector_size
, start
, 1, finish
);
6101 if (segment_selector_size
!= 0)
6103 warn (_("The %s section contains "
6104 "unsupported segment selector size: %d.\n"),
6105 section
->name
, segment_selector_size
);
6109 SAFE_BYTE_GET_AND_INC (offset_entry_count
, start
, 4, finish
);
6110 if (offset_entry_count
!= 0)
6112 warn (_("The %s section contains "
6113 "unsupported offset entry count: %u.\n"),
6114 section
->name
, offset_entry_count
);
6119 if (load_debug_info (file
) == 0)
6121 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
6127 for (i
= 0; i
< num_debug_info_entries
; i
++)
6128 num_range_list
+= debug_information
[i
].num_range_lists
;
6130 if (num_range_list
== 0)
6132 /* This can happen when the file was compiled with -gsplit-debug
6133 which removes references to range lists from the primary .o file. */
6134 printf (_("No range lists in .debug_info section.\n"));
6138 range_entries
= (struct range_entry
*)
6139 xmalloc (sizeof (*range_entries
) * num_range_list
);
6140 range_entry_fill
= range_entries
;
6142 for (i
= 0; i
< num_debug_info_entries
; i
++)
6144 debug_info
*debug_info_p
= &debug_information
[i
];
6147 for (j
= 0; j
< debug_info_p
->num_range_lists
; j
++)
6149 range_entry_fill
->ranges_offset
= debug_info_p
->range_lists
[j
];
6150 range_entry_fill
->debug_info_p
= debug_info_p
;
6155 qsort (range_entries
, num_range_list
, sizeof (*range_entries
),
6156 range_entry_compar
);
6158 if (dwarf_check
!= 0 && range_entries
[0].ranges_offset
!= 0)
6159 warn (_("Range lists in %s section start at 0x%lx\n"),
6160 section
->name
, (unsigned long) range_entries
[0].ranges_offset
);
6162 printf (_("Contents of the %s section:\n\n"), section
->name
);
6163 printf (_(" Offset Begin End\n"));
6165 for (i
= 0; i
< num_range_list
; i
++)
6167 struct range_entry
*range_entry
= &range_entries
[i
];
6168 debug_info
*debug_info_p
= range_entry
->debug_info_p
;
6169 unsigned int pointer_size
;
6171 unsigned char *next
;
6172 dwarf_vma base_address
;
6174 pointer_size
= (is_rnglists
? address_size
: debug_info_p
->pointer_size
);
6175 offset
= range_entry
->ranges_offset
;
6176 next
= section_begin
+ offset
;
6177 base_address
= debug_info_p
->base_address
;
6179 /* PR 17512: file: 001-101485-0.001:0.1. */
6180 if (pointer_size
< 2 || pointer_size
> 8)
6182 warn (_("Corrupt pointer size (%d) in debug entry at offset %8.8lx\n"),
6183 pointer_size
, (unsigned long) offset
);
6187 if (dwarf_check
!= 0 && i
> 0)
6190 warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"),
6191 (unsigned long) (start
- section_begin
),
6192 (unsigned long) (next
- section_begin
), section
->name
);
6193 else if (start
> next
)
6195 if (next
== last_start
)
6197 warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"),
6198 (unsigned long) (start
- section_begin
),
6199 (unsigned long) (next
- section_begin
), section
->name
);
6205 (is_rnglists
? display_debug_rnglists_list
: display_debug_ranges_list
)
6206 (start
, finish
, pointer_size
, offset
, base_address
);
6210 free (range_entries
);
6215 typedef struct Frame_Chunk
6217 struct Frame_Chunk
*next
;
6218 unsigned char *chunk_start
;
6220 /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
6221 short int *col_type
;
6224 unsigned int code_factor
;
6229 dwarf_vma cfa_offset
;
6231 unsigned char fde_encoding
;
6232 unsigned char cfa_exp
;
6233 unsigned char ptr_size
;
6234 unsigned char segment_size
;
6238 static const char *const *dwarf_regnames
;
6239 static unsigned int dwarf_regnames_count
;
6241 /* A marker for a col_type that means this column was never referenced
6242 in the frame info. */
6243 #define DW_CFA_unreferenced (-1)
6245 /* Return 0 if no more space is needed, 1 if more space is needed,
6246 -1 for invalid reg. */
6249 frame_need_space (Frame_Chunk
*fc
, unsigned int reg
)
6251 unsigned int prev
= fc
->ncols
;
6253 if (reg
< (unsigned int) fc
->ncols
)
6256 if (dwarf_regnames_count
6257 && reg
> dwarf_regnames_count
)
6260 fc
->ncols
= reg
+ 1;
6261 /* PR 17512: file: 10450-2643-0.004.
6262 If reg == -1 then this can happen... */
6266 /* PR 17512: file: 2844a11d. */
6267 if (fc
->ncols
> 1024)
6269 error (_("Unfeasibly large register number: %u\n"), reg
);
6271 /* FIXME: 1024 is an arbitrary limit. Increase it if
6272 we ever encounter a valid binary that exceeds it. */
6276 fc
->col_type
= (short int *) xcrealloc (fc
->col_type
, fc
->ncols
,
6277 sizeof (short int));
6278 fc
->col_offset
= (int *) xcrealloc (fc
->col_offset
, fc
->ncols
, sizeof (int));
6279 /* PR 17512: file:002-10025-0.005. */
6280 if (fc
->col_type
== NULL
|| fc
->col_offset
== NULL
)
6282 error (_("Out of memory allocating %u columns in dwarf frame arrays\n"),
6288 while (prev
< fc
->ncols
)
6290 fc
->col_type
[prev
] = DW_CFA_unreferenced
;
6291 fc
->col_offset
[prev
] = 0;
6297 static const char *const dwarf_regnames_i386
[] =
6299 "eax", "ecx", "edx", "ebx", /* 0 - 3 */
6300 "esp", "ebp", "esi", "edi", /* 4 - 7 */
6301 "eip", "eflags", NULL
, /* 8 - 10 */
6302 "st0", "st1", "st2", "st3", /* 11 - 14 */
6303 "st4", "st5", "st6", "st7", /* 15 - 18 */
6304 NULL
, NULL
, /* 19 - 20 */
6305 "xmm0", "xmm1", "xmm2", "xmm3", /* 21 - 24 */
6306 "xmm4", "xmm5", "xmm6", "xmm7", /* 25 - 28 */
6307 "mm0", "mm1", "mm2", "mm3", /* 29 - 32 */
6308 "mm4", "mm5", "mm6", "mm7", /* 33 - 36 */
6309 "fcw", "fsw", "mxcsr", /* 37 - 39 */
6310 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
, /* 40 - 47 */
6311 "tr", "ldtr", /* 48 - 49 */
6312 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 50 - 57 */
6313 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 58 - 65 */
6314 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 66 - 73 */
6315 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 74 - 81 */
6316 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 82 - 89 */
6317 NULL
, NULL
, NULL
, /* 90 - 92 */
6318 "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7" /* 93 - 100 */
6321 static const char *const dwarf_regnames_iamcu
[] =
6323 "eax", "ecx", "edx", "ebx", /* 0 - 3 */
6324 "esp", "ebp", "esi", "edi", /* 4 - 7 */
6325 "eip", "eflags", NULL
, /* 8 - 10 */
6326 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 11 - 18 */
6327 NULL
, NULL
, /* 19 - 20 */
6328 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 21 - 28 */
6329 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 29 - 36 */
6330 NULL
, NULL
, NULL
, /* 37 - 39 */
6331 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
, /* 40 - 47 */
6332 "tr", "ldtr", /* 48 - 49 */
6333 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 50 - 57 */
6334 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 58 - 65 */
6335 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 66 - 73 */
6336 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 74 - 81 */
6337 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 82 - 89 */
6338 NULL
, NULL
, NULL
, /* 90 - 92 */
6339 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
/* 93 - 100 */
6343 init_dwarf_regnames_i386 (void)
6345 dwarf_regnames
= dwarf_regnames_i386
;
6346 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_i386
);
6350 init_dwarf_regnames_iamcu (void)
6352 dwarf_regnames
= dwarf_regnames_iamcu
;
6353 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_iamcu
);
6356 static const char *const dwarf_regnames_x86_64
[] =
6358 "rax", "rdx", "rcx", "rbx",
6359 "rsi", "rdi", "rbp", "rsp",
6360 "r8", "r9", "r10", "r11",
6361 "r12", "r13", "r14", "r15",
6363 "xmm0", "xmm1", "xmm2", "xmm3",
6364 "xmm4", "xmm5", "xmm6", "xmm7",
6365 "xmm8", "xmm9", "xmm10", "xmm11",
6366 "xmm12", "xmm13", "xmm14", "xmm15",
6367 "st0", "st1", "st2", "st3",
6368 "st4", "st5", "st6", "st7",
6369 "mm0", "mm1", "mm2", "mm3",
6370 "mm4", "mm5", "mm6", "mm7",
6372 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
6373 "fs.base", "gs.base", NULL
, NULL
,
6375 "mxcsr", "fcw", "fsw",
6376 "xmm16", "xmm17", "xmm18", "xmm19",
6377 "xmm20", "xmm21", "xmm22", "xmm23",
6378 "xmm24", "xmm25", "xmm26", "xmm27",
6379 "xmm28", "xmm29", "xmm30", "xmm31",
6380 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 83 - 90 */
6381 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 91 - 98 */
6382 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 99 - 106 */
6383 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 107 - 114 */
6384 NULL
, NULL
, NULL
, /* 115 - 117 */
6385 "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7"
6389 init_dwarf_regnames_x86_64 (void)
6391 dwarf_regnames
= dwarf_regnames_x86_64
;
6392 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_x86_64
);
6395 static const char *const dwarf_regnames_aarch64
[] =
6397 "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7",
6398 "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15",
6399 "x16", "x17", "x18", "x19", "x20", "x21", "x22", "x23",
6400 "x24", "x25", "x26", "x27", "x28", "x29", "x30", "sp",
6401 NULL
, "elr", NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
6402 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
6403 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
6404 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
6405 "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7",
6406 "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15",
6407 "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23",
6408 "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
6412 init_dwarf_regnames_aarch64 (void)
6414 dwarf_regnames
= dwarf_regnames_aarch64
;
6415 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_aarch64
);
6418 static const char *const dwarf_regnames_s390
[] =
6420 /* Avoid saying "r5 (r5)", so omit the names of r0-r15. */
6421 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
6422 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
6423 "f0", "f2", "f4", "f6", "f1", "f3", "f5", "f7",
6424 "f8", "f10", "f12", "f14", "f9", "f11", "f13", "f15",
6425 "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",
6426 "cr8", "cr9", "cr10", "cr11", "cr12", "cr13", "cr14", "cr15",
6427 "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
6428 "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15",
6431 "v16", "v18", "v20", "v22", "v17", "v19", "v21", "v23",
6432 "v24", "v26", "v28", "v30", "v25", "v27", "v29", "v31",
6436 init_dwarf_regnames_s390 (void)
6438 dwarf_regnames
= dwarf_regnames_s390
;
6439 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_s390
);
6443 init_dwarf_regnames (unsigned int e_machine
)
6448 init_dwarf_regnames_i386 ();
6452 init_dwarf_regnames_iamcu ();
6458 init_dwarf_regnames_x86_64 ();
6462 init_dwarf_regnames_aarch64 ();
6466 init_dwarf_regnames_s390 ();
6475 regname (unsigned int regno
, int row
)
6477 static char reg
[64];
6480 && regno
< dwarf_regnames_count
6481 && dwarf_regnames
[regno
] != NULL
)
6484 return dwarf_regnames
[regno
];
6485 snprintf (reg
, sizeof (reg
), "r%d (%s)", regno
,
6486 dwarf_regnames
[regno
]);
6489 snprintf (reg
, sizeof (reg
), "r%d", regno
);
6494 frame_display_row (Frame_Chunk
*fc
, int *need_col_headers
, unsigned int *max_regs
)
6499 if (*max_regs
!= fc
->ncols
)
6500 *max_regs
= fc
->ncols
;
6502 if (*need_col_headers
)
6504 static const char *sloc
= " LOC";
6506 *need_col_headers
= 0;
6508 printf ("%-*s CFA ", eh_addr_size
* 2, sloc
);
6510 for (r
= 0; r
< *max_regs
; r
++)
6511 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
6516 printf ("%-5s ", regname (r
, 1));
6522 print_dwarf_vma (fc
->pc_begin
, eh_addr_size
);
6524 strcpy (tmp
, "exp");
6526 sprintf (tmp
, "%s%+d", regname (fc
->cfa_reg
, 1), (int) fc
->cfa_offset
);
6527 printf ("%-8s ", tmp
);
6529 for (r
= 0; r
< fc
->ncols
; r
++)
6531 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
6533 switch (fc
->col_type
[r
])
6535 case DW_CFA_undefined
:
6538 case DW_CFA_same_value
:
6542 sprintf (tmp
, "c%+d", fc
->col_offset
[r
]);
6544 case DW_CFA_val_offset
:
6545 sprintf (tmp
, "v%+d", fc
->col_offset
[r
]);
6547 case DW_CFA_register
:
6548 sprintf (tmp
, "%s", regname (fc
->col_offset
[r
], 0));
6550 case DW_CFA_expression
:
6551 strcpy (tmp
, "exp");
6553 case DW_CFA_val_expression
:
6554 strcpy (tmp
, "vexp");
6557 strcpy (tmp
, "n/a");
6560 printf ("%-5s ", tmp
);
6566 #define GET(VAR, N) SAFE_BYTE_GET_AND_INC (VAR, start, N, end)
6568 static unsigned char *
6569 read_cie (unsigned char *start
, unsigned char *end
,
6570 Frame_Chunk
**p_cie
, int *p_version
,
6571 unsigned long *p_aug_len
, unsigned char **p_aug
)
6575 unsigned int length_return
;
6576 unsigned char *augmentation_data
= NULL
;
6577 unsigned long augmentation_data_len
= 0;
6580 /* PR 17512: file: 001-228113-0.004. */
6584 fc
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
6585 memset (fc
, 0, sizeof (Frame_Chunk
));
6587 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
6588 fc
->col_offset
= (int *) xmalloc (sizeof (int));
6592 fc
->augmentation
= (char *) start
;
6593 /* PR 17512: file: 001-228113-0.004.
6594 Skip past augmentation name, but avoid running off the end of the data. */
6596 if (* start
++ == '\0')
6600 warn (_("No terminator for augmentation name\n"));
6604 if (strcmp (fc
->augmentation
, "eh") == 0)
6605 start
+= eh_addr_size
;
6609 GET (fc
->ptr_size
, 1);
6610 if (fc
->ptr_size
< 1 || fc
->ptr_size
> 8)
6612 warn (_("Invalid pointer size (%d) in CIE data\n"), fc
->ptr_size
);
6616 GET (fc
->segment_size
, 1);
6617 /* PR 17512: file: e99d2804. */
6618 if (fc
->segment_size
> 8 || fc
->segment_size
+ fc
->ptr_size
> 8)
6620 warn (_("Invalid segment size (%d) in CIE data\n"), fc
->segment_size
);
6624 eh_addr_size
= fc
->ptr_size
;
6628 fc
->ptr_size
= eh_addr_size
;
6629 fc
->segment_size
= 0;
6631 READ_ULEB (fc
->code_factor
);
6632 READ_SLEB (fc
->data_factor
);
6642 if (fc
->augmentation
[0] == 'z')
6644 READ_ULEB (augmentation_data_len
);
6645 augmentation_data
= start
;
6646 start
+= augmentation_data_len
;
6647 /* PR 17512: file: 11042-2589-0.004. */
6650 warn (_("Augmentation data too long: %#lx, expected at most %#lx\n"),
6651 augmentation_data_len
, (long)((end
- start
) + augmentation_data_len
));
6656 if (augmentation_data_len
)
6660 unsigned char *qend
;
6662 p
= (unsigned char *) fc
->augmentation
+ 1;
6663 q
= augmentation_data
;
6664 qend
= q
+ augmentation_data_len
;
6666 /* PR 17531: file: 015adfaa. */
6669 warn (_("Negative augmentation data length: 0x%lx"), augmentation_data_len
);
6670 augmentation_data_len
= 0;
6673 while (p
< end
&& q
< augmentation_data
+ augmentation_data_len
)
6678 q
+= 1 + size_of_encoded_value (*q
);
6680 fc
->fde_encoding
= *q
++;
6687 /* Note - it is OK if this loop terminates with q < qend.
6688 Padding may have been inserted to align the end of the CIE. */
6693 *p_version
= version
;
6696 *p_aug_len
= augmentation_data_len
;
6697 *p_aug
= augmentation_data
;
6703 display_debug_frames (struct dwarf_section
*section
,
6704 void *file ATTRIBUTE_UNUSED
)
6706 unsigned char *start
= section
->start
;
6707 unsigned char *end
= start
+ section
->size
;
6708 unsigned char *section_start
= start
;
6709 Frame_Chunk
*chunks
= 0, *forward_refs
= 0;
6710 Frame_Chunk
*remembered_state
= 0;
6712 int is_eh
= strcmp (section
->name
, ".eh_frame") == 0;
6713 unsigned int length_return
;
6714 unsigned int max_regs
= 0;
6715 const char *bad_reg
= _("bad register: ");
6716 unsigned int saved_eh_addr_size
= eh_addr_size
;
6718 printf (_("Contents of the %s section:\n"), section
->name
);
6722 unsigned char *saved_start
;
6723 unsigned char *block_end
;
6728 int need_col_headers
= 1;
6729 unsigned char *augmentation_data
= NULL
;
6730 unsigned long augmentation_data_len
= 0;
6731 unsigned int encoded_ptr_size
= saved_eh_addr_size
;
6732 unsigned int offset_size
;
6733 unsigned int initial_length_size
;
6734 bfd_boolean all_nops
;
6736 saved_start
= start
;
6738 SAFE_BYTE_GET_AND_INC (length
, start
, 4, end
);
6742 printf ("\n%08lx ZERO terminator\n\n",
6743 (unsigned long)(saved_start
- section_start
));
6744 /* Skip any zero terminators that directly follow.
6745 A corrupt section size could have loaded a whole
6746 slew of zero filled memory bytes. eg
6747 PR 17512: file: 070-19381-0.004. */
6748 while (start
< end
&& * start
== 0)
6753 if (length
== 0xffffffff)
6755 SAFE_BYTE_GET_AND_INC (length
, start
, 8, end
);
6757 initial_length_size
= 12;
6762 initial_length_size
= 4;
6765 block_end
= saved_start
+ length
+ initial_length_size
;
6766 if (block_end
> end
|| block_end
< start
)
6768 warn ("Invalid length 0x%s in FDE at %#08lx\n",
6769 dwarf_vmatoa_1 (NULL
, length
, offset_size
),
6770 (unsigned long) (saved_start
- section_start
));
6774 SAFE_BYTE_GET_AND_INC (cie_id
, start
, offset_size
, end
);
6776 if (is_eh
? (cie_id
== 0) : ((offset_size
== 4 && cie_id
== DW_CIE_ID
)
6777 || (offset_size
== 8 && cie_id
== DW64_CIE_ID
)))
6782 start
= read_cie (start
, end
, &cie
, &version
,
6783 &augmentation_data_len
, &augmentation_data
);
6784 /* PR 17512: file: 027-135133-0.005. */
6791 fc
->chunk_start
= saved_start
;
6792 mreg
= max_regs
> 0 ? max_regs
- 1 : 0;
6795 if (frame_need_space (fc
, mreg
) < 0)
6797 if (fc
->fde_encoding
)
6798 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
6800 printf ("\n%08lx ", (unsigned long) (saved_start
- section_start
));
6801 print_dwarf_vma (length
, fc
->ptr_size
);
6802 print_dwarf_vma (cie_id
, offset_size
);
6804 if (do_debug_frames_interp
)
6806 printf ("CIE \"%s\" cf=%d df=%d ra=%d\n", fc
->augmentation
,
6807 fc
->code_factor
, fc
->data_factor
, fc
->ra
);
6812 printf (" Version: %d\n", version
);
6813 printf (" Augmentation: \"%s\"\n", fc
->augmentation
);
6816 printf (" Pointer Size: %u\n", fc
->ptr_size
);
6817 printf (" Segment Size: %u\n", fc
->segment_size
);
6819 printf (" Code alignment factor: %u\n", fc
->code_factor
);
6820 printf (" Data alignment factor: %d\n", fc
->data_factor
);
6821 printf (" Return address column: %d\n", fc
->ra
);
6823 if (augmentation_data_len
)
6827 printf (" Augmentation data: ");
6828 for (i
= 0; i
< augmentation_data_len
; ++i
)
6829 /* FIXME: If do_wide is FALSE, then we should
6830 add carriage returns at 80 columns... */
6831 printf (" %02x", augmentation_data
[i
]);
6839 unsigned char *look_for
;
6840 static Frame_Chunk fde_fc
;
6841 unsigned long segment_selector
;
6845 dwarf_vma sign
= (dwarf_vma
) 1 << (offset_size
* 8 - 1);
6846 look_for
= start
- 4 - ((cie_id
^ sign
) - sign
);
6849 look_for
= section_start
+ cie_id
;
6851 if (look_for
<= saved_start
)
6853 for (cie
= chunks
; cie
; cie
= cie
->next
)
6854 if (cie
->chunk_start
== look_for
)
6859 for (cie
= forward_refs
; cie
; cie
= cie
->next
)
6860 if (cie
->chunk_start
== look_for
)
6864 unsigned int off_size
;
6865 unsigned char *cie_scan
;
6867 cie_scan
= look_for
;
6869 SAFE_BYTE_GET_AND_INC (length
, cie_scan
, 4, end
);
6870 if (length
== 0xffffffff)
6872 SAFE_BYTE_GET_AND_INC (length
, cie_scan
, 8, end
);
6879 SAFE_BYTE_GET_AND_INC (c_id
, cie_scan
, off_size
, end
);
6882 : ((off_size
== 4 && c_id
== DW_CIE_ID
)
6883 || (off_size
== 8 && c_id
== DW64_CIE_ID
)))
6888 read_cie (cie_scan
, end
, &cie
, &version
,
6889 &augmentation_data_len
, &augmentation_data
);
6890 /* PR 17512: file: 3450-2098-0.004. */
6893 warn (_("Failed to read CIE information\n"));
6896 cie
->next
= forward_refs
;
6898 cie
->chunk_start
= look_for
;
6899 mreg
= max_regs
> 0 ? max_regs
- 1 : 0;
6902 if (frame_need_space (cie
, mreg
) < 0)
6904 warn (_("Invalid max register\n"));
6907 if (cie
->fde_encoding
)
6909 = size_of_encoded_value (cie
->fde_encoding
);
6916 memset (fc
, 0, sizeof (Frame_Chunk
));
6920 warn ("Invalid CIE pointer 0x%s in FDE at %#08lx\n",
6921 dwarf_vmatoa_1 (NULL
, cie_id
, offset_size
),
6922 (unsigned long) (saved_start
- section_start
));
6924 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
6925 fc
->col_offset
= (int *) xmalloc (sizeof (int));
6926 if (frame_need_space (fc
, max_regs
> 0 ? max_regs
- 1 : 0) < 0)
6928 warn (_("Invalid max register\n"));
6932 fc
->augmentation
= "";
6933 fc
->fde_encoding
= 0;
6934 fc
->ptr_size
= eh_addr_size
;
6935 fc
->segment_size
= 0;
6939 fc
->ncols
= cie
->ncols
;
6940 fc
->col_type
= (short int *) xcmalloc (fc
->ncols
, sizeof (short int));
6941 fc
->col_offset
= (int *) xcmalloc (fc
->ncols
, sizeof (int));
6942 memcpy (fc
->col_type
, cie
->col_type
, fc
->ncols
* sizeof (short int));
6943 memcpy (fc
->col_offset
, cie
->col_offset
, fc
->ncols
* sizeof (int));
6944 fc
->augmentation
= cie
->augmentation
;
6945 fc
->ptr_size
= cie
->ptr_size
;
6946 eh_addr_size
= cie
->ptr_size
;
6947 fc
->segment_size
= cie
->segment_size
;
6948 fc
->code_factor
= cie
->code_factor
;
6949 fc
->data_factor
= cie
->data_factor
;
6950 fc
->cfa_reg
= cie
->cfa_reg
;
6951 fc
->cfa_offset
= cie
->cfa_offset
;
6953 if (frame_need_space (fc
, max_regs
> 0 ? max_regs
- 1: 0) < 0)
6955 warn (_("Invalid max register\n"));
6958 fc
->fde_encoding
= cie
->fde_encoding
;
6961 if (fc
->fde_encoding
)
6962 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
6964 segment_selector
= 0;
6965 if (fc
->segment_size
)
6967 if (fc
->segment_size
> sizeof (segment_selector
))
6969 /* PR 17512: file: 9e196b3e. */
6970 warn (_("Probably corrupt segment size: %d - using 4 instead\n"), fc
->segment_size
);
6971 fc
->segment_size
= 4;
6973 SAFE_BYTE_GET_AND_INC (segment_selector
, start
, fc
->segment_size
, end
);
6976 fc
->pc_begin
= get_encoded_value (&start
, fc
->fde_encoding
, section
, end
);
6978 /* FIXME: It appears that sometimes the final pc_range value is
6979 encoded in less than encoded_ptr_size bytes. See the x86_64
6980 run of the "objcopy on compressed debug sections" test for an
6982 SAFE_BYTE_GET_AND_INC (fc
->pc_range
, start
, encoded_ptr_size
, end
);
6984 if (cie
->augmentation
[0] == 'z')
6986 READ_ULEB (augmentation_data_len
);
6987 augmentation_data
= start
;
6988 start
+= augmentation_data_len
;
6989 /* PR 17512: file: 722-8446-0.004. */
6990 if (start
>= end
|| ((signed long) augmentation_data_len
) < 0)
6992 warn (_("Corrupt augmentation data length: %lx\n"),
6993 augmentation_data_len
);
6995 augmentation_data
= NULL
;
6996 augmentation_data_len
= 0;
7000 printf ("\n%08lx %s %s FDE cie=%08lx pc=",
7001 (unsigned long)(saved_start
- section_start
),
7002 dwarf_vmatoa_1 (NULL
, length
, fc
->ptr_size
),
7003 dwarf_vmatoa_1 (NULL
, cie_id
, offset_size
),
7004 (unsigned long)(cie
->chunk_start
- section_start
));
7006 if (fc
->segment_size
)
7007 printf ("%04lx:", segment_selector
);
7010 dwarf_vmatoa_1 (NULL
, fc
->pc_begin
, fc
->ptr_size
),
7011 dwarf_vmatoa_1 (NULL
, fc
->pc_begin
+ fc
->pc_range
, fc
->ptr_size
));
7013 if (! do_debug_frames_interp
&& augmentation_data_len
)
7017 printf (" Augmentation data: ");
7018 for (i
= 0; i
< augmentation_data_len
; ++i
)
7019 printf (" %02x", augmentation_data
[i
]);
7025 /* At this point, fc is the current chunk, cie (if any) is set, and
7026 we're about to interpret instructions for the chunk. */
7027 /* ??? At present we need to do this always, since this sizes the
7028 fc->col_type and fc->col_offset arrays, which we write into always.
7029 We should probably split the interpreted and non-interpreted bits
7030 into two different routines, since there's so much that doesn't
7031 really overlap between them. */
7032 if (1 || do_debug_frames_interp
)
7034 /* Start by making a pass over the chunk, allocating storage
7035 and taking note of what registers are used. */
7036 unsigned char *tmp
= start
;
7038 while (start
< block_end
)
7040 unsigned int reg
, op
, opa
;
7042 unsigned char * new_start
;
7049 /* Warning: if you add any more cases to this switch, be
7050 sure to add them to the corresponding switch below. */
7053 case DW_CFA_advance_loc
:
7057 if (frame_need_space (fc
, opa
) >= 0)
7058 fc
->col_type
[opa
] = DW_CFA_undefined
;
7060 case DW_CFA_restore
:
7061 if (frame_need_space (fc
, opa
) >= 0)
7062 fc
->col_type
[opa
] = DW_CFA_undefined
;
7064 case DW_CFA_set_loc
:
7065 start
+= encoded_ptr_size
;
7067 case DW_CFA_advance_loc1
:
7070 case DW_CFA_advance_loc2
:
7073 case DW_CFA_advance_loc4
:
7076 case DW_CFA_offset_extended
:
7077 case DW_CFA_val_offset
:
7080 if (frame_need_space (fc
, reg
) >= 0)
7081 fc
->col_type
[reg
] = DW_CFA_undefined
;
7083 case DW_CFA_restore_extended
:
7085 if (frame_need_space (fc
, reg
) >= 0)
7086 fc
->col_type
[reg
] = DW_CFA_undefined
;
7088 case DW_CFA_undefined
:
7090 if (frame_need_space (fc
, reg
) >= 0)
7091 fc
->col_type
[reg
] = DW_CFA_undefined
;
7093 case DW_CFA_same_value
:
7095 if (frame_need_space (fc
, reg
) >= 0)
7096 fc
->col_type
[reg
] = DW_CFA_undefined
;
7098 case DW_CFA_register
:
7101 if (frame_need_space (fc
, reg
) >= 0)
7102 fc
->col_type
[reg
] = DW_CFA_undefined
;
7104 case DW_CFA_def_cfa
:
7108 case DW_CFA_def_cfa_register
:
7111 case DW_CFA_def_cfa_offset
:
7114 case DW_CFA_def_cfa_expression
:
7116 new_start
= start
+ temp
;
7117 if (new_start
< start
)
7119 warn (_("Corrupt CFA_def expression value: %lu\n"), temp
);
7125 case DW_CFA_expression
:
7126 case DW_CFA_val_expression
:
7129 new_start
= start
+ temp
;
7130 if (new_start
< start
)
7132 /* PR 17512: file:306-192417-0.005. */
7133 warn (_("Corrupt CFA expression value: %lu\n"), temp
);
7138 if (frame_need_space (fc
, reg
) >= 0)
7139 fc
->col_type
[reg
] = DW_CFA_undefined
;
7141 case DW_CFA_offset_extended_sf
:
7142 case DW_CFA_val_offset_sf
:
7145 if (frame_need_space (fc
, reg
) >= 0)
7146 fc
->col_type
[reg
] = DW_CFA_undefined
;
7148 case DW_CFA_def_cfa_sf
:
7152 case DW_CFA_def_cfa_offset_sf
:
7155 case DW_CFA_MIPS_advance_loc8
:
7158 case DW_CFA_GNU_args_size
:
7161 case DW_CFA_GNU_negative_offset_extended
:
7164 if (frame_need_space (fc
, reg
) >= 0)
7165 fc
->col_type
[reg
] = DW_CFA_undefined
;
7176 /* Now we know what registers are used, make a second pass over
7177 the chunk, this time actually printing out the info. */
7179 while (start
< block_end
)
7181 unsigned char * tmp
;
7183 unsigned long ul
, roffs
;
7184 /* Note: It is tempting to use an unsigned long for 'reg' but there
7185 are various functions, notably frame_space_needed() that assume that
7186 reg is an unsigned int. */
7191 const char *reg_prefix
= "";
7198 /* Make a note if something other than DW_CFA_nop happens. */
7199 if (op
!= DW_CFA_nop
)
7202 /* Warning: if you add any more cases to this switch, be
7203 sure to add them to the corresponding switch above. */
7206 case DW_CFA_advance_loc
:
7207 if (do_debug_frames_interp
)
7208 frame_display_row (fc
, &need_col_headers
, &max_regs
);
7210 printf (" DW_CFA_advance_loc: %d to %s\n",
7211 opa
* fc
->code_factor
,
7212 dwarf_vmatoa_1 (NULL
,
7213 fc
->pc_begin
+ opa
* fc
->code_factor
,
7215 fc
->pc_begin
+= opa
* fc
->code_factor
;
7220 if (opa
>= (unsigned int) fc
->ncols
)
7221 reg_prefix
= bad_reg
;
7222 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7223 printf (" DW_CFA_offset: %s%s at cfa%+ld\n",
7224 reg_prefix
, regname (opa
, 0),
7225 roffs
* fc
->data_factor
);
7226 if (*reg_prefix
== '\0')
7228 fc
->col_type
[opa
] = DW_CFA_offset
;
7229 fc
->col_offset
[opa
] = roffs
* fc
->data_factor
;
7233 case DW_CFA_restore
:
7234 if (opa
>= (unsigned int) fc
->ncols
)
7235 reg_prefix
= bad_reg
;
7236 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7237 printf (" DW_CFA_restore: %s%s\n",
7238 reg_prefix
, regname (opa
, 0));
7239 if (*reg_prefix
!= '\0')
7242 if (opa
>= (unsigned int) cie
->ncols
7243 || (do_debug_frames_interp
7244 && cie
->col_type
[opa
] == DW_CFA_unreferenced
))
7246 fc
->col_type
[opa
] = DW_CFA_undefined
;
7247 fc
->col_offset
[opa
] = 0;
7251 fc
->col_type
[opa
] = cie
->col_type
[opa
];
7252 fc
->col_offset
[opa
] = cie
->col_offset
[opa
];
7256 case DW_CFA_set_loc
:
7257 vma
= get_encoded_value (&start
, fc
->fde_encoding
, section
, block_end
);
7258 if (do_debug_frames_interp
)
7259 frame_display_row (fc
, &need_col_headers
, &max_regs
);
7261 printf (" DW_CFA_set_loc: %s\n",
7262 dwarf_vmatoa_1 (NULL
, vma
, fc
->ptr_size
));
7266 case DW_CFA_advance_loc1
:
7267 SAFE_BYTE_GET_AND_INC (ofs
, start
, 1, end
);
7268 if (do_debug_frames_interp
)
7269 frame_display_row (fc
, &need_col_headers
, &max_regs
);
7271 printf (" DW_CFA_advance_loc1: %ld to %s\n",
7272 (unsigned long) (ofs
* fc
->code_factor
),
7273 dwarf_vmatoa_1 (NULL
,
7274 fc
->pc_begin
+ ofs
* fc
->code_factor
,
7276 fc
->pc_begin
+= ofs
* fc
->code_factor
;
7279 case DW_CFA_advance_loc2
:
7280 SAFE_BYTE_GET_AND_INC (ofs
, start
, 2, block_end
);
7281 if (do_debug_frames_interp
)
7282 frame_display_row (fc
, &need_col_headers
, &max_regs
);
7284 printf (" DW_CFA_advance_loc2: %ld to %s\n",
7285 (unsigned long) (ofs
* fc
->code_factor
),
7286 dwarf_vmatoa_1 (NULL
,
7287 fc
->pc_begin
+ ofs
* fc
->code_factor
,
7289 fc
->pc_begin
+= ofs
* fc
->code_factor
;
7292 case DW_CFA_advance_loc4
:
7293 SAFE_BYTE_GET_AND_INC (ofs
, start
, 4, block_end
);
7294 if (do_debug_frames_interp
)
7295 frame_display_row (fc
, &need_col_headers
, &max_regs
);
7297 printf (" DW_CFA_advance_loc4: %ld to %s\n",
7298 (unsigned long) (ofs
* fc
->code_factor
),
7299 dwarf_vmatoa_1 (NULL
,
7300 fc
->pc_begin
+ ofs
* fc
->code_factor
,
7302 fc
->pc_begin
+= ofs
* fc
->code_factor
;
7305 case DW_CFA_offset_extended
:
7308 if (reg
>= (unsigned int) fc
->ncols
)
7309 reg_prefix
= bad_reg
;
7310 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7311 printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n",
7312 reg_prefix
, regname (reg
, 0),
7313 roffs
* fc
->data_factor
);
7314 if (*reg_prefix
== '\0')
7316 fc
->col_type
[reg
] = DW_CFA_offset
;
7317 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
7321 case DW_CFA_val_offset
:
7324 if (reg
>= (unsigned int) fc
->ncols
)
7325 reg_prefix
= bad_reg
;
7326 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7327 printf (" DW_CFA_val_offset: %s%s is cfa%+ld\n",
7328 reg_prefix
, regname (reg
, 0),
7329 roffs
* fc
->data_factor
);
7330 if (*reg_prefix
== '\0')
7332 fc
->col_type
[reg
] = DW_CFA_val_offset
;
7333 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
7337 case DW_CFA_restore_extended
:
7339 if (reg
>= (unsigned int) fc
->ncols
)
7340 reg_prefix
= bad_reg
;
7341 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7342 printf (" DW_CFA_restore_extended: %s%s\n",
7343 reg_prefix
, regname (reg
, 0));
7344 if (*reg_prefix
!= '\0')
7347 if (reg
>= (unsigned int) cie
->ncols
)
7349 fc
->col_type
[reg
] = DW_CFA_undefined
;
7350 fc
->col_offset
[reg
] = 0;
7354 fc
->col_type
[reg
] = cie
->col_type
[reg
];
7355 fc
->col_offset
[reg
] = cie
->col_offset
[reg
];
7359 case DW_CFA_undefined
:
7361 if (reg
>= (unsigned int) fc
->ncols
)
7362 reg_prefix
= bad_reg
;
7363 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7364 printf (" DW_CFA_undefined: %s%s\n",
7365 reg_prefix
, regname (reg
, 0));
7366 if (*reg_prefix
== '\0')
7368 fc
->col_type
[reg
] = DW_CFA_undefined
;
7369 fc
->col_offset
[reg
] = 0;
7373 case DW_CFA_same_value
:
7375 if (reg
>= (unsigned int) fc
->ncols
)
7376 reg_prefix
= bad_reg
;
7377 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7378 printf (" DW_CFA_same_value: %s%s\n",
7379 reg_prefix
, regname (reg
, 0));
7380 if (*reg_prefix
== '\0')
7382 fc
->col_type
[reg
] = DW_CFA_same_value
;
7383 fc
->col_offset
[reg
] = 0;
7387 case DW_CFA_register
:
7390 if (reg
>= (unsigned int) fc
->ncols
)
7391 reg_prefix
= bad_reg
;
7392 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7394 printf (" DW_CFA_register: %s%s in ",
7395 reg_prefix
, regname (reg
, 0));
7396 puts (regname (roffs
, 0));
7398 if (*reg_prefix
== '\0')
7400 fc
->col_type
[reg
] = DW_CFA_register
;
7401 fc
->col_offset
[reg
] = roffs
;
7405 case DW_CFA_remember_state
:
7406 if (! do_debug_frames_interp
)
7407 printf (" DW_CFA_remember_state\n");
7408 rs
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
7409 rs
->cfa_offset
= fc
->cfa_offset
;
7410 rs
->cfa_reg
= fc
->cfa_reg
;
7412 rs
->cfa_exp
= fc
->cfa_exp
;
7413 rs
->ncols
= fc
->ncols
;
7414 rs
->col_type
= (short int *) xcmalloc (rs
->ncols
,
7415 sizeof (* rs
->col_type
));
7416 rs
->col_offset
= (int *) xcmalloc (rs
->ncols
, sizeof (* rs
->col_offset
));
7417 memcpy (rs
->col_type
, fc
->col_type
, rs
->ncols
* sizeof (* fc
->col_type
));
7418 memcpy (rs
->col_offset
, fc
->col_offset
, rs
->ncols
* sizeof (* fc
->col_offset
));
7419 rs
->next
= remembered_state
;
7420 remembered_state
= rs
;
7423 case DW_CFA_restore_state
:
7424 if (! do_debug_frames_interp
)
7425 printf (" DW_CFA_restore_state\n");
7426 rs
= remembered_state
;
7429 remembered_state
= rs
->next
;
7430 fc
->cfa_offset
= rs
->cfa_offset
;
7431 fc
->cfa_reg
= rs
->cfa_reg
;
7433 fc
->cfa_exp
= rs
->cfa_exp
;
7434 if (frame_need_space (fc
, rs
->ncols
- 1) < 0)
7436 warn (_("Invalid column number in saved frame state\n"));
7440 memcpy (fc
->col_type
, rs
->col_type
, rs
->ncols
* sizeof (* rs
->col_type
));
7441 memcpy (fc
->col_offset
, rs
->col_offset
,
7442 rs
->ncols
* sizeof (* rs
->col_offset
));
7443 free (rs
->col_type
);
7444 free (rs
->col_offset
);
7447 else if (do_debug_frames_interp
)
7448 printf ("Mismatched DW_CFA_restore_state\n");
7451 case DW_CFA_def_cfa
:
7452 READ_SLEB (fc
->cfa_reg
);
7453 READ_ULEB (fc
->cfa_offset
);
7455 if (! do_debug_frames_interp
)
7456 printf (" DW_CFA_def_cfa: %s ofs %d\n",
7457 regname (fc
->cfa_reg
, 0), (int) fc
->cfa_offset
);
7460 case DW_CFA_def_cfa_register
:
7461 READ_SLEB (fc
->cfa_reg
);
7463 if (! do_debug_frames_interp
)
7464 printf (" DW_CFA_def_cfa_register: %s\n",
7465 regname (fc
->cfa_reg
, 0));
7468 case DW_CFA_def_cfa_offset
:
7469 READ_ULEB (fc
->cfa_offset
);
7470 if (! do_debug_frames_interp
)
7471 printf (" DW_CFA_def_cfa_offset: %d\n", (int) fc
->cfa_offset
);
7475 if (! do_debug_frames_interp
)
7476 printf (" DW_CFA_nop\n");
7479 case DW_CFA_def_cfa_expression
:
7481 if (start
>= block_end
|| ul
> (unsigned long) (block_end
- start
))
7483 printf (_(" DW_CFA_def_cfa_expression: <corrupt len %lu>\n"), ul
);
7486 if (! do_debug_frames_interp
)
7488 printf (" DW_CFA_def_cfa_expression (");
7489 decode_location_expression (start
, eh_addr_size
, 0, -1,
7497 case DW_CFA_expression
:
7500 if (reg
>= (unsigned int) fc
->ncols
)
7501 reg_prefix
= bad_reg
;
7502 /* PR 17512: file: 069-133014-0.006. */
7503 /* PR 17512: file: 98c02eb4. */
7505 if (start
>= block_end
|| tmp
> block_end
|| tmp
< start
)
7507 printf (_(" DW_CFA_expression: <corrupt len %lu>\n"), ul
);
7510 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7512 printf (" DW_CFA_expression: %s%s (",
7513 reg_prefix
, regname (reg
, 0));
7514 decode_location_expression (start
, eh_addr_size
, 0, -1,
7518 if (*reg_prefix
== '\0')
7519 fc
->col_type
[reg
] = DW_CFA_expression
;
7523 case DW_CFA_val_expression
:
7526 if (reg
>= (unsigned int) fc
->ncols
)
7527 reg_prefix
= bad_reg
;
7529 if (start
>= block_end
|| tmp
> block_end
|| tmp
< start
)
7531 printf (" DW_CFA_val_expression: <corrupt len %lu>\n", ul
);
7534 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7536 printf (" DW_CFA_val_expression: %s%s (",
7537 reg_prefix
, regname (reg
, 0));
7538 decode_location_expression (start
, eh_addr_size
, 0, -1,
7542 if (*reg_prefix
== '\0')
7543 fc
->col_type
[reg
] = DW_CFA_val_expression
;
7547 case DW_CFA_offset_extended_sf
:
7550 if (frame_need_space (fc
, reg
) < 0)
7551 reg_prefix
= bad_reg
;
7552 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7553 printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n",
7554 reg_prefix
, regname (reg
, 0),
7555 (long)(l
* fc
->data_factor
));
7556 if (*reg_prefix
== '\0')
7558 fc
->col_type
[reg
] = DW_CFA_offset
;
7559 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
7563 case DW_CFA_val_offset_sf
:
7566 if (frame_need_space (fc
, reg
) < 0)
7567 reg_prefix
= bad_reg
;
7568 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7569 printf (" DW_CFA_val_offset_sf: %s%s is cfa%+ld\n",
7570 reg_prefix
, regname (reg
, 0),
7571 (long)(l
* fc
->data_factor
));
7572 if (*reg_prefix
== '\0')
7574 fc
->col_type
[reg
] = DW_CFA_val_offset
;
7575 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
7579 case DW_CFA_def_cfa_sf
:
7580 READ_SLEB (fc
->cfa_reg
);
7581 READ_ULEB (fc
->cfa_offset
);
7582 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
7584 if (! do_debug_frames_interp
)
7585 printf (" DW_CFA_def_cfa_sf: %s ofs %d\n",
7586 regname (fc
->cfa_reg
, 0), (int) fc
->cfa_offset
);
7589 case DW_CFA_def_cfa_offset_sf
:
7590 READ_ULEB (fc
->cfa_offset
);
7591 fc
->cfa_offset
*= fc
->data_factor
;
7592 if (! do_debug_frames_interp
)
7593 printf (" DW_CFA_def_cfa_offset_sf: %d\n", (int) fc
->cfa_offset
);
7596 case DW_CFA_MIPS_advance_loc8
:
7597 SAFE_BYTE_GET_AND_INC (ofs
, start
, 8, block_end
);
7598 if (do_debug_frames_interp
)
7599 frame_display_row (fc
, &need_col_headers
, &max_regs
);
7601 printf (" DW_CFA_MIPS_advance_loc8: %ld to %s\n",
7602 (unsigned long) (ofs
* fc
->code_factor
),
7603 dwarf_vmatoa_1 (NULL
,
7604 fc
->pc_begin
+ ofs
* fc
->code_factor
,
7606 fc
->pc_begin
+= ofs
* fc
->code_factor
;
7609 case DW_CFA_GNU_window_save
:
7610 if (! do_debug_frames_interp
)
7611 printf (" DW_CFA_GNU_window_save\n");
7614 case DW_CFA_GNU_args_size
:
7616 if (! do_debug_frames_interp
)
7617 printf (" DW_CFA_GNU_args_size: %ld\n", ul
);
7620 case DW_CFA_GNU_negative_offset_extended
:
7624 if (frame_need_space (fc
, reg
) < 0)
7625 reg_prefix
= bad_reg
;
7626 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7627 printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n",
7628 reg_prefix
, regname (reg
, 0),
7629 (long)(l
* fc
->data_factor
));
7630 if (*reg_prefix
== '\0')
7632 fc
->col_type
[reg
] = DW_CFA_offset
;
7633 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
7638 if (op
>= DW_CFA_lo_user
&& op
<= DW_CFA_hi_user
)
7639 printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op
);
7641 warn (_("Unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op
);
7646 /* Interpret the CFA - as long as it is not completely full of NOPs. */
7647 if (do_debug_frames_interp
&& ! all_nops
)
7648 frame_display_row (fc
, &need_col_headers
, &max_regs
);
7651 eh_addr_size
= saved_eh_addr_size
;
7662 display_debug_names (struct dwarf_section
*section
, void *file
)
7664 unsigned char *hdrptr
= section
->start
;
7665 dwarf_vma unit_length
;
7666 unsigned char *unit_start
;
7667 const unsigned char *const section_end
= section
->start
+ section
->size
;
7668 unsigned char *unit_end
;
7670 printf (_("Contents of the %s section:\n"), section
->name
);
7672 load_debug_section (str
, file
);
7674 for (; hdrptr
< section_end
; hdrptr
= unit_end
)
7676 unsigned int offset_size
;
7677 uint16_t dwarf_version
, padding
;
7678 uint32_t comp_unit_count
, local_type_unit_count
, foreign_type_unit_count
;
7679 uint32_t bucket_count
, name_count
, abbrev_table_size
;
7680 uint32_t augmentation_string_size
;
7683 unit_start
= hdrptr
;
7685 /* Get and check the length of the block. */
7686 SAFE_BYTE_GET_AND_INC (unit_length
, hdrptr
, 4, section_end
);
7688 if (unit_length
== 0xffffffff)
7690 /* This section is 64-bit DWARF. */
7691 SAFE_BYTE_GET_AND_INC (unit_length
, hdrptr
, 8, section_end
);
7696 unit_end
= hdrptr
+ unit_length
;
7698 if ((hdrptr
- section
->start
) + unit_length
> section
->size
)
7700 warn (_("The length field (0x%lx) for unit 0x%lx in the debug_names "
7701 "header is wrong - the section is too small\n"),
7702 (long) unit_length
, (long) (unit_start
- section
->start
));
7706 /* Get and check the version number. */
7707 SAFE_BYTE_GET_AND_INC (dwarf_version
, hdrptr
, 2, unit_end
);
7708 printf (_("Version %ld\n"), (long) dwarf_version
);
7710 /* Prior versions did not exist, and future versions may not be
7711 backwards compatible. */
7712 if (dwarf_version
!= 5)
7714 warn (_("Only DWARF version 5 .debug_names "
7715 "is currently supported.\n"));
7719 SAFE_BYTE_GET_AND_INC (padding
, hdrptr
, 2, unit_end
);
7721 warn (_("Padding field of .debug_names must be 0 (found 0x%x)\n"),
7724 SAFE_BYTE_GET_AND_INC (comp_unit_count
, hdrptr
, 4, unit_end
);
7725 if (comp_unit_count
== 0)
7726 warn (_("Compilation unit count must be >= 1 in .debug_names\n"));
7728 SAFE_BYTE_GET_AND_INC (local_type_unit_count
, hdrptr
, 4, unit_end
);
7729 SAFE_BYTE_GET_AND_INC (foreign_type_unit_count
, hdrptr
, 4, unit_end
);
7730 SAFE_BYTE_GET_AND_INC (bucket_count
, hdrptr
, 4, unit_end
);
7731 SAFE_BYTE_GET_AND_INC (name_count
, hdrptr
, 4, unit_end
);
7732 SAFE_BYTE_GET_AND_INC (abbrev_table_size
, hdrptr
, 4, unit_end
);
7734 SAFE_BYTE_GET_AND_INC (augmentation_string_size
, hdrptr
, 4, unit_end
);
7735 if (augmentation_string_size
% 4 != 0)
7737 warn (_("Augmentation string length %u must be rounded up "
7738 "to a multiple of 4 in .debug_names.\n"),
7739 augmentation_string_size
);
7740 augmentation_string_size
+= (-augmentation_string_size
) & 3;
7742 printf (_("Augmentation string:"));
7743 for (i
= 0; i
< augmentation_string_size
; i
++)
7747 SAFE_BYTE_GET_AND_INC (uc
, hdrptr
, 1, unit_end
);
7748 printf (" %02x", uc
);
7753 printf (_("CU table:\n"));
7754 for (i
= 0; i
< comp_unit_count
; i
++)
7758 SAFE_BYTE_GET_AND_INC (cu_offset
, hdrptr
, offset_size
, unit_end
);
7759 printf (_("[%3u] 0x%lx\n"), i
, (unsigned long) cu_offset
);
7763 printf (_("TU table:\n"));
7764 for (i
= 0; i
< local_type_unit_count
; i
++)
7768 SAFE_BYTE_GET_AND_INC (tu_offset
, hdrptr
, offset_size
, unit_end
);
7769 printf (_("[%3u] 0x%lx\n"), i
, (unsigned long) tu_offset
);
7773 printf (_("Foreign TU table:\n"));
7774 for (i
= 0; i
< foreign_type_unit_count
; i
++)
7778 SAFE_BYTE_GET_AND_INC (signature
, hdrptr
, 8, unit_end
);
7779 printf (_("[%3u] "), i
);
7780 print_dwarf_vma (signature
, 8);
7785 const uint32_t *const hash_table_buckets
= (uint32_t *) hdrptr
;
7786 hdrptr
+= bucket_count
* sizeof (uint32_t);
7787 const uint32_t *const hash_table_hashes
= (uint32_t *) hdrptr
;
7788 hdrptr
+= name_count
* sizeof (uint32_t);
7789 unsigned char *const name_table_string_offsets
= hdrptr
;
7790 hdrptr
+= name_count
* offset_size
;
7791 unsigned char *const name_table_entry_offsets
= hdrptr
;
7792 hdrptr
+= name_count
* offset_size
;
7793 unsigned char *const abbrev_table
= hdrptr
;
7794 hdrptr
+= abbrev_table_size
;
7795 const unsigned char *const abbrev_table_end
= hdrptr
;
7796 unsigned char *const entry_pool
= hdrptr
;
7797 if (hdrptr
> unit_end
)
7799 warn (_("Entry pool offset (0x%lx) exceeds unit size 0x%lx "
7800 "for unit 0x%lx in the debug_names\n"),
7801 (long) (hdrptr
- section
->start
),
7802 (long) (unit_end
- section
->start
),
7803 (long) (unit_start
- section
->start
));
7807 size_t buckets_filled
= 0;
7809 for (bucketi
= 0; bucketi
< bucket_count
; bucketi
++)
7811 const uint32_t bucket
= hash_table_buckets
[bucketi
];
7816 printf (_("Used %zu of %lu buckets.\n"), buckets_filled
,
7817 (unsigned long) bucket_count
);
7819 uint32_t hash_prev
= 0;
7820 size_t hash_clash_count
= 0;
7821 size_t longest_clash
= 0;
7822 size_t this_length
= 0;
7824 for (hashi
= 0; hashi
< name_count
; hashi
++)
7826 const uint32_t hash_this
= hash_table_hashes
[hashi
];
7830 if (hash_prev
% bucket_count
== hash_this
% bucket_count
)
7834 longest_clash
= MAX (longest_clash
, this_length
);
7839 hash_prev
= hash_this
;
7841 printf (_("Out of %lu items there are %zu bucket clashes"
7842 " (longest of %zu entries).\n"),
7843 (unsigned long) name_count
, hash_clash_count
, longest_clash
);
7844 assert (name_count
== buckets_filled
+ hash_clash_count
);
7846 struct abbrev_lookup_entry
7848 dwarf_vma abbrev_tag
;
7849 unsigned char *abbrev_lookup_ptr
;
7851 struct abbrev_lookup_entry
*abbrev_lookup
= NULL
;
7852 size_t abbrev_lookup_used
= 0;
7853 size_t abbrev_lookup_allocated
= 0;
7855 unsigned char *abbrevptr
= abbrev_table
;
7858 unsigned int bytes_read
;
7859 const dwarf_vma abbrev_tag
= read_uleb128 (abbrevptr
, &bytes_read
,
7861 abbrevptr
+= bytes_read
;
7862 if (abbrev_tag
== 0)
7864 if (abbrev_lookup_used
== abbrev_lookup_allocated
)
7866 abbrev_lookup_allocated
= MAX (0x100,
7867 abbrev_lookup_allocated
* 2);
7868 abbrev_lookup
= xrealloc (abbrev_lookup
,
7869 (abbrev_lookup_allocated
7870 * sizeof (*abbrev_lookup
)));
7872 assert (abbrev_lookup_used
< abbrev_lookup_allocated
);
7873 struct abbrev_lookup_entry
*entry
;
7874 for (entry
= abbrev_lookup
;
7875 entry
< abbrev_lookup
+ abbrev_lookup_used
;
7877 if (entry
->abbrev_tag
== abbrev_tag
)
7879 warn (_("Duplicate abbreviation tag %lu "
7880 "in unit 0x%lx in the debug_names\n"),
7881 (long) abbrev_tag
, (long) (unit_start
- section
->start
));
7884 entry
= &abbrev_lookup
[abbrev_lookup_used
++];
7885 entry
->abbrev_tag
= abbrev_tag
;
7886 entry
->abbrev_lookup_ptr
= abbrevptr
;
7888 /* Skip DWARF tag. */
7889 read_uleb128 (abbrevptr
, &bytes_read
, abbrev_table_end
);
7890 abbrevptr
+= bytes_read
;
7893 const dwarf_vma xindex
= read_uleb128 (abbrevptr
,
7896 abbrevptr
+= bytes_read
;
7897 const dwarf_vma form
= read_uleb128 (abbrevptr
, &bytes_read
,
7899 abbrevptr
+= bytes_read
;
7900 if (xindex
== 0 && form
== 0)
7905 printf (_("\nSymbol table:\n"));
7907 for (namei
= 0; namei
< name_count
; ++namei
)
7909 uint64_t string_offset
, entry_offset
;
7911 SAFE_BYTE_GET (string_offset
,
7912 name_table_string_offsets
+ namei
* offset_size
,
7913 offset_size
, unit_end
);
7914 SAFE_BYTE_GET (entry_offset
,
7915 name_table_entry_offsets
+ namei
* offset_size
,
7916 offset_size
, unit_end
);
7918 printf ("[%3u] #%08x %s:", namei
, hash_table_hashes
[namei
],
7919 fetch_indirect_string (string_offset
));
7921 unsigned char *entryptr
= entry_pool
+ entry_offset
;
7923 // We need to scan first whether there is a single or multiple
7924 // entries. TAGNO is -2 for the first entry, it is -1 for the
7925 // initial tag read of the second entry, then it becomes 0 for the
7926 // first entry for real printing etc.
7928 /* Initialize it due to a false compiler warning. */
7929 dwarf_vma second_abbrev_tag
= -1;
7932 unsigned int bytes_read
;
7933 const dwarf_vma abbrev_tag
= read_uleb128 (entryptr
, &bytes_read
,
7935 entryptr
+= bytes_read
;
7938 second_abbrev_tag
= abbrev_tag
;
7940 entryptr
= entry_pool
+ entry_offset
;
7943 if (abbrev_tag
== 0)
7947 (tagno
== 0 && second_abbrev_tag
== 0 ? " " : "\n\t"),
7948 (unsigned long) abbrev_tag
);
7950 const struct abbrev_lookup_entry
*entry
;
7951 for (entry
= abbrev_lookup
;
7952 entry
< abbrev_lookup
+ abbrev_lookup_used
;
7954 if (entry
->abbrev_tag
== abbrev_tag
)
7956 if (entry
>= abbrev_lookup
+ abbrev_lookup_used
)
7958 warn (_("Undefined abbreviation tag %lu "
7959 "in unit 0x%lx in the debug_names\n"),
7961 (long) (unit_start
- section
->start
));
7964 abbrevptr
= entry
->abbrev_lookup_ptr
;
7965 const dwarf_vma dwarf_tag
= read_uleb128 (abbrevptr
, &bytes_read
,
7967 abbrevptr
+= bytes_read
;
7969 printf (" %s", get_TAG_name (dwarf_tag
));
7972 const dwarf_vma xindex
= read_uleb128 (abbrevptr
,
7975 abbrevptr
+= bytes_read
;
7976 const dwarf_vma form
= read_uleb128 (abbrevptr
, &bytes_read
,
7978 abbrevptr
+= bytes_read
;
7979 if (xindex
== 0 && form
== 0)
7983 printf (" %s", get_IDX_name (xindex
));
7984 entryptr
= read_and_display_attr_value (0, form
, 0, entryptr
,
7987 dwarf_version
, NULL
,
7994 printf (_(" <no entries>"));
7998 free (abbrev_lookup
);
8005 display_gdb_index (struct dwarf_section
*section
,
8006 void *file ATTRIBUTE_UNUSED
)
8008 unsigned char *start
= section
->start
;
8010 uint32_t cu_list_offset
, tu_list_offset
;
8011 uint32_t address_table_offset
, symbol_table_offset
, constant_pool_offset
;
8012 unsigned int cu_list_elements
, tu_list_elements
;
8013 unsigned int address_table_size
, symbol_table_slots
;
8014 unsigned char *cu_list
, *tu_list
;
8015 unsigned char *address_table
, *symbol_table
, *constant_pool
;
8018 /* The documentation for the format of this file is in gdb/dwarf2read.c. */
8020 printf (_("Contents of the %s section:\n"), section
->name
);
8022 if (section
->size
< 6 * sizeof (uint32_t))
8024 warn (_("Truncated header in the %s section.\n"), section
->name
);
8028 version
= byte_get_little_endian (start
, 4);
8029 printf (_("Version %ld\n"), (long) version
);
8031 /* Prior versions are obsolete, and future versions may not be
8032 backwards compatible. */
8033 if (version
< 3 || version
> 8)
8035 warn (_("Unsupported version %lu.\n"), (unsigned long) version
);
8039 warn (_("The address table data in version 3 may be wrong.\n"));
8041 warn (_("Version 4 does not support case insensitive lookups.\n"));
8043 warn (_("Version 5 does not include inlined functions.\n"));
8045 warn (_("Version 6 does not include symbol attributes.\n"));
8046 /* Version 7 indices generated by Gold have bad type unit references,
8047 PR binutils/15021. But we don't know if the index was generated by
8048 Gold or not, so to avoid worrying users with gdb-generated indices
8049 we say nothing for version 7 here. */
8051 cu_list_offset
= byte_get_little_endian (start
+ 4, 4);
8052 tu_list_offset
= byte_get_little_endian (start
+ 8, 4);
8053 address_table_offset
= byte_get_little_endian (start
+ 12, 4);
8054 symbol_table_offset
= byte_get_little_endian (start
+ 16, 4);
8055 constant_pool_offset
= byte_get_little_endian (start
+ 20, 4);
8057 if (cu_list_offset
> section
->size
8058 || tu_list_offset
> section
->size
8059 || address_table_offset
> section
->size
8060 || symbol_table_offset
> section
->size
8061 || constant_pool_offset
> section
->size
)
8063 warn (_("Corrupt header in the %s section.\n"), section
->name
);
8067 /* PR 17531: file: 418d0a8a. */
8068 if (tu_list_offset
< cu_list_offset
)
8070 warn (_("TU offset (%x) is less than CU offset (%x)\n"),
8071 tu_list_offset
, cu_list_offset
);
8075 cu_list_elements
= (tu_list_offset
- cu_list_offset
) / 8;
8077 if (address_table_offset
< tu_list_offset
)
8079 warn (_("Address table offset (%x) is less than TU offset (%x)\n"),
8080 address_table_offset
, tu_list_offset
);
8084 tu_list_elements
= (address_table_offset
- tu_list_offset
) / 8;
8086 /* PR 17531: file: 18a47d3d. */
8087 if (symbol_table_offset
< address_table_offset
)
8089 warn (_("Symbol table offset (%xl) is less then Address table offset (%x)\n"),
8090 symbol_table_offset
, address_table_offset
);
8094 address_table_size
= symbol_table_offset
- address_table_offset
;
8096 if (constant_pool_offset
< symbol_table_offset
)
8098 warn (_("Constant pool offset (%x) is less than symbol table offset (%x)\n"),
8099 constant_pool_offset
, symbol_table_offset
);
8103 symbol_table_slots
= (constant_pool_offset
- symbol_table_offset
) / 8;
8105 cu_list
= start
+ cu_list_offset
;
8106 tu_list
= start
+ tu_list_offset
;
8107 address_table
= start
+ address_table_offset
;
8108 symbol_table
= start
+ symbol_table_offset
;
8109 constant_pool
= start
+ constant_pool_offset
;
8111 if (address_table
+ address_table_size
> section
->start
+ section
->size
)
8113 warn (_("Address table extends beyond end of section.\n"));
8117 printf (_("\nCU table:\n"));
8118 for (i
= 0; i
< cu_list_elements
; i
+= 2)
8120 uint64_t cu_offset
= byte_get_little_endian (cu_list
+ i
* 8, 8);
8121 uint64_t cu_length
= byte_get_little_endian (cu_list
+ i
* 8 + 8, 8);
8123 printf (_("[%3u] 0x%lx - 0x%lx\n"), i
/ 2,
8124 (unsigned long) cu_offset
,
8125 (unsigned long) (cu_offset
+ cu_length
- 1));
8128 printf (_("\nTU table:\n"));
8129 for (i
= 0; i
< tu_list_elements
; i
+= 3)
8131 uint64_t tu_offset
= byte_get_little_endian (tu_list
+ i
* 8, 8);
8132 uint64_t type_offset
= byte_get_little_endian (tu_list
+ i
* 8 + 8, 8);
8133 uint64_t signature
= byte_get_little_endian (tu_list
+ i
* 8 + 16, 8);
8135 printf (_("[%3u] 0x%lx 0x%lx "), i
/ 3,
8136 (unsigned long) tu_offset
,
8137 (unsigned long) type_offset
);
8138 print_dwarf_vma (signature
, 8);
8142 printf (_("\nAddress table:\n"));
8143 for (i
= 0; i
< address_table_size
&& i
<= address_table_size
- (2 * 8 + 4);
8146 uint64_t low
= byte_get_little_endian (address_table
+ i
, 8);
8147 uint64_t high
= byte_get_little_endian (address_table
+ i
+ 8, 8);
8148 uint32_t cu_index
= byte_get_little_endian (address_table
+ i
+ 16, 4);
8150 print_dwarf_vma (low
, 8);
8151 print_dwarf_vma (high
, 8);
8152 printf (_("%lu\n"), (unsigned long) cu_index
);
8155 printf (_("\nSymbol table:\n"));
8156 for (i
= 0; i
< symbol_table_slots
; ++i
)
8158 uint32_t name_offset
= byte_get_little_endian (symbol_table
+ i
* 8, 4);
8159 uint32_t cu_vector_offset
= byte_get_little_endian (symbol_table
+ i
* 8 + 4, 4);
8160 uint32_t num_cus
, cu
;
8162 if (name_offset
!= 0
8163 || cu_vector_offset
!= 0)
8166 unsigned char * adr
;
8168 adr
= constant_pool
+ name_offset
;
8169 /* PR 17531: file: 5b7b07ad. */
8170 if (adr
< constant_pool
|| adr
>= section
->start
+ section
->size
)
8172 printf (_("[%3u] <corrupt offset: %x>"), i
, name_offset
);
8173 warn (_("Corrupt name offset of 0x%x found for symbol table slot %d\n"),
8177 printf ("[%3u] %.*s:", i
,
8178 (int) (section
->size
- (constant_pool_offset
+ name_offset
)),
8179 constant_pool
+ name_offset
);
8181 adr
= constant_pool
+ cu_vector_offset
;
8182 if (adr
< constant_pool
|| adr
>= section
->start
+ section
->size
- 3)
8184 printf (_("<invalid CU vector offset: %x>\n"), cu_vector_offset
);
8185 warn (_("Corrupt CU vector offset of 0x%x found for symbol table slot %d\n"),
8186 cu_vector_offset
, i
);
8190 num_cus
= byte_get_little_endian (adr
, 4);
8192 adr
= constant_pool
+ cu_vector_offset
+ 4 + num_cus
* 4;
8193 if (num_cus
* 4 < num_cus
8194 || adr
>= section
->start
+ section
->size
8195 || adr
< constant_pool
)
8197 printf ("<invalid number of CUs: %d>\n", num_cus
);
8198 warn (_("Invalid number of CUs (0x%x) for symbol table slot %d\n"),
8206 for (j
= 0; j
< num_cus
; ++j
)
8209 gdb_index_symbol_kind kind
;
8211 cu
= byte_get_little_endian (constant_pool
+ cu_vector_offset
+ 4 + j
* 4, 4);
8212 is_static
= GDB_INDEX_SYMBOL_STATIC_VALUE (cu
);
8213 kind
= GDB_INDEX_SYMBOL_KIND_VALUE (cu
);
8214 cu
= GDB_INDEX_CU_VALUE (cu
);
8215 /* Convert to TU number if it's for a type unit. */
8216 if (cu
>= cu_list_elements
/ 2)
8217 printf ("%cT%lu", num_cus
> 1 ? '\t' : ' ',
8218 (unsigned long) (cu
- cu_list_elements
/ 2));
8220 printf ("%c%lu", num_cus
> 1 ? '\t' : ' ', (unsigned long) cu
);
8222 printf (" [%s, %s]",
8223 is_static
? _("static") : _("global"),
8224 get_gdb_index_symbol_kind_name (kind
));
8236 /* Pre-allocate enough space for the CU/TU sets needed. */
8239 prealloc_cu_tu_list (unsigned int nshndx
)
8241 if (shndx_pool
== NULL
)
8243 shndx_pool_size
= nshndx
;
8244 shndx_pool_used
= 0;
8245 shndx_pool
= (unsigned int *) xcmalloc (shndx_pool_size
,
8246 sizeof (unsigned int));
8250 shndx_pool_size
= shndx_pool_used
+ nshndx
;
8251 shndx_pool
= (unsigned int *) xcrealloc (shndx_pool
, shndx_pool_size
,
8252 sizeof (unsigned int));
8257 add_shndx_to_cu_tu_entry (unsigned int shndx
)
8259 if (shndx_pool_used
>= shndx_pool_size
)
8261 error (_("Internal error: out of space in the shndx pool.\n"));
8264 shndx_pool
[shndx_pool_used
++] = shndx
;
8268 end_cu_tu_entry (void)
8270 if (shndx_pool_used
>= shndx_pool_size
)
8272 error (_("Internal error: out of space in the shndx pool.\n"));
8275 shndx_pool
[shndx_pool_used
++] = 0;
8278 /* Return the short name of a DWARF section given by a DW_SECT enumerator. */
8281 get_DW_SECT_short_name (unsigned int dw_sect
)
8283 static char buf
[16];
8291 case DW_SECT_ABBREV
:
8297 case DW_SECT_STR_OFFSETS
:
8299 case DW_SECT_MACINFO
:
8307 snprintf (buf
, sizeof (buf
), "%d", dw_sect
);
8311 /* Process a CU or TU index. If DO_DISPLAY is true, print the contents.
8312 These sections are extensions for Fission.
8313 See http://gcc.gnu.org/wiki/DebugFissionDWP. */
8316 process_cu_tu_index (struct dwarf_section
*section
, int do_display
)
8318 unsigned char *phdr
= section
->start
;
8319 unsigned char *limit
= phdr
+ section
->size
;
8320 unsigned char *phash
;
8321 unsigned char *pindex
;
8322 unsigned char *ppool
;
8323 unsigned int version
;
8324 unsigned int ncols
= 0;
8326 unsigned int nslots
;
8329 dwarf_vma signature_high
;
8330 dwarf_vma signature_low
;
8333 /* PR 17512: file: 002-168123-0.004. */
8336 warn (_("Section %s is empty\n"), section
->name
);
8339 /* PR 17512: file: 002-376-0.004. */
8340 if (section
->size
< 24)
8342 warn (_("Section %s is too small to contain a CU/TU header\n"),
8347 SAFE_BYTE_GET (version
, phdr
, 4, limit
);
8349 SAFE_BYTE_GET (ncols
, phdr
+ 4, 4, limit
);
8350 SAFE_BYTE_GET (nused
, phdr
+ 8, 4, limit
);
8351 SAFE_BYTE_GET (nslots
, phdr
+ 12, 4, limit
);
8354 pindex
= phash
+ nslots
* 8;
8355 ppool
= pindex
+ nslots
* 4;
8357 /* PR 17531: file: 45d69832. */
8358 if (pindex
< phash
|| ppool
< phdr
|| (pindex
== phash
&& nslots
!= 0))
8360 warn (_("Section %s is too small for %d slots\n"),
8361 section
->name
, nslots
);
8367 printf (_("Contents of the %s section:\n\n"), section
->name
);
8368 printf (_(" Version: %d\n"), version
);
8370 printf (_(" Number of columns: %d\n"), ncols
);
8371 printf (_(" Number of used entries: %d\n"), nused
);
8372 printf (_(" Number of slots: %d\n\n"), nslots
);
8375 if (ppool
> limit
|| ppool
< phdr
)
8377 warn (_("Section %s too small for %d hash table entries\n"),
8378 section
->name
, nslots
);
8385 prealloc_cu_tu_list ((limit
- ppool
) / 4);
8386 for (i
= 0; i
< nslots
; i
++)
8388 unsigned char *shndx_list
;
8391 SAFE_BYTE_GET64 (phash
, &signature_high
, &signature_low
, limit
);
8392 if (signature_high
!= 0 || signature_low
!= 0)
8394 SAFE_BYTE_GET (j
, pindex
, 4, limit
);
8395 shndx_list
= ppool
+ j
* 4;
8396 /* PR 17531: file: 705e010d. */
8397 if (shndx_list
< ppool
)
8399 warn (_("Section index pool located before start of section\n"));
8404 printf (_(" [%3d] Signature: 0x%s Sections: "),
8405 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
8406 buf
, sizeof (buf
)));
8409 if (shndx_list
>= limit
)
8411 warn (_("Section %s too small for shndx pool\n"),
8415 SAFE_BYTE_GET (shndx
, shndx_list
, 4, limit
);
8419 printf (" %d", shndx
);
8421 add_shndx_to_cu_tu_entry (shndx
);
8433 else if (version
== 2)
8436 unsigned int dw_sect
;
8437 unsigned char *ph
= phash
;
8438 unsigned char *pi
= pindex
;
8439 unsigned char *poffsets
= ppool
+ ncols
* 4;
8440 unsigned char *psizes
= poffsets
+ nused
* ncols
* 4;
8441 unsigned char *pend
= psizes
+ nused
* ncols
* 4;
8442 bfd_boolean is_tu_index
;
8443 struct cu_tu_set
*this_set
= NULL
;
8445 unsigned char *prow
;
8447 is_tu_index
= strcmp (section
->name
, ".debug_tu_index") == 0;
8449 /* PR 17531: file: 0dd159bf.
8450 Check for wraparound with an overlarge ncols value. */
8451 if (poffsets
< ppool
|| (unsigned int) ((poffsets
- ppool
) / 4) != ncols
)
8453 warn (_("Overlarge number of columns: %x\n"), ncols
);
8459 warn (_("Section %s too small for offset and size tables\n"),
8466 printf (_(" Offset table\n"));
8467 printf (" slot %-16s ",
8468 is_tu_index
? _("signature") : _("dwo_id"));
8475 tu_sets
= xcalloc2 (nused
, sizeof (struct cu_tu_set
));
8481 cu_sets
= xcalloc2 (nused
, sizeof (struct cu_tu_set
));
8488 for (j
= 0; j
< ncols
; j
++)
8490 SAFE_BYTE_GET (dw_sect
, ppool
+ j
* 4, 4, limit
);
8491 printf (" %8s", get_DW_SECT_short_name (dw_sect
));
8496 for (i
= 0; i
< nslots
; i
++)
8498 SAFE_BYTE_GET64 (ph
, &signature_high
, &signature_low
, limit
);
8500 SAFE_BYTE_GET (row
, pi
, 4, limit
);
8503 /* PR 17531: file: a05f6ab3. */
8506 warn (_("Row index (%u) is larger than number of used entries (%u)\n"),
8512 memcpy (&this_set
[row
- 1].signature
, ph
, sizeof (uint64_t));
8514 prow
= poffsets
+ (row
- 1) * ncols
* 4;
8515 /* PR 17531: file: b8ce60a8. */
8516 if (prow
< poffsets
|| prow
> limit
)
8518 warn (_("Row index (%u) * num columns (%u) > space remaining in section\n"),
8524 printf (_(" [%3d] 0x%s"),
8525 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
8526 buf
, sizeof (buf
)));
8527 for (j
= 0; j
< ncols
; j
++)
8529 SAFE_BYTE_GET (val
, prow
+ j
* 4, 4, limit
);
8531 printf (" %8d", val
);
8534 SAFE_BYTE_GET (dw_sect
, ppool
+ j
* 4, 4, limit
);
8536 /* PR 17531: file: 10796eb3. */
8537 if (dw_sect
>= DW_SECT_MAX
)
8538 warn (_("Overlarge Dwarf section index detected: %u\n"), dw_sect
);
8540 this_set
[row
- 1].section_offsets
[dw_sect
] = val
;
8556 printf (_(" Size table\n"));
8557 printf (" slot %-16s ",
8558 is_tu_index
? _("signature") : _("dwo_id"));
8561 for (j
= 0; j
< ncols
; j
++)
8563 SAFE_BYTE_GET (val
, ppool
+ j
* 4, 4, limit
);
8565 printf (" %8s", get_DW_SECT_short_name (val
));
8571 for (i
= 0; i
< nslots
; i
++)
8573 SAFE_BYTE_GET64 (ph
, &signature_high
, &signature_low
, limit
);
8575 SAFE_BYTE_GET (row
, pi
, 4, limit
);
8578 prow
= psizes
+ (row
- 1) * ncols
* 4;
8581 printf (_(" [%3d] 0x%s"),
8582 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
8583 buf
, sizeof (buf
)));
8585 for (j
= 0; j
< ncols
; j
++)
8587 SAFE_BYTE_GET (val
, prow
+ j
* 4, 4, limit
);
8589 printf (" %8d", val
);
8592 SAFE_BYTE_GET (dw_sect
, ppool
+ j
* 4, 4, limit
);
8593 if (dw_sect
>= DW_SECT_MAX
)
8594 warn (_("Overlarge Dwarf section index detected: %u\n"), dw_sect
);
8596 this_set
[row
- 1].section_sizes
[dw_sect
] = val
;
8608 else if (do_display
)
8609 printf (_(" Unsupported version (%d)\n"), version
);
8617 /* Load the CU and TU indexes if present. This will build a list of
8618 section sets that we can use to associate a .debug_info.dwo section
8619 with its associated .debug_abbrev.dwo section in a .dwp file. */
8622 load_cu_tu_indexes (void *file
)
8624 static int cu_tu_indexes_read
= -1; /* Tri-state variable. */
8626 /* If we have already loaded (or tried to load) the CU and TU indexes
8627 then do not bother to repeat the task. */
8628 if (cu_tu_indexes_read
== -1)
8630 cu_tu_indexes_read
= TRUE
;
8632 if (load_debug_section (dwp_cu_index
, file
))
8633 if (! process_cu_tu_index (&debug_displays
[dwp_cu_index
].section
, 0))
8634 cu_tu_indexes_read
= FALSE
;
8636 if (load_debug_section (dwp_tu_index
, file
))
8637 if (! process_cu_tu_index (&debug_displays
[dwp_tu_index
].section
, 0))
8638 cu_tu_indexes_read
= FALSE
;
8641 return (bfd_boolean
) cu_tu_indexes_read
;
8644 /* Find the set of sections that includes section SHNDX. */
8647 find_cu_tu_set (void *file
, unsigned int shndx
)
8651 if (! load_cu_tu_indexes (file
))
8654 /* Find SHNDX in the shndx pool. */
8655 for (i
= 0; i
< shndx_pool_used
; i
++)
8656 if (shndx_pool
[i
] == shndx
)
8659 if (i
>= shndx_pool_used
)
8662 /* Now backup to find the first entry in the set. */
8663 while (i
> 0 && shndx_pool
[i
- 1] != 0)
8666 return shndx_pool
+ i
;
8669 /* Display a .debug_cu_index or .debug_tu_index section. */
8672 display_cu_index (struct dwarf_section
*section
, void *file ATTRIBUTE_UNUSED
)
8674 return process_cu_tu_index (section
, 1);
8678 display_debug_not_supported (struct dwarf_section
*section
,
8679 void *file ATTRIBUTE_UNUSED
)
8681 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
8687 /* Like malloc, but takes two parameters like calloc.
8688 Verifies that the first parameter is not too large.
8689 Note: does *not* initialise the allocated memory to zero. */
8691 cmalloc (size_t nmemb
, size_t size
)
8693 /* Check for overflow. */
8694 if (nmemb
>= ~(size_t) 0 / size
)
8697 return xmalloc (nmemb
* size
);
8700 /* Like xmalloc, but takes two parameters like calloc.
8701 Verifies that the first parameter is not too large.
8702 Note: does *not* initialise the allocated memory to zero. */
8704 xcmalloc (size_t nmemb
, size_t size
)
8706 /* Check for overflow. */
8707 if (nmemb
>= ~(size_t) 0 / size
)
8710 _("Attempt to allocate an array with an excessive number of elements: 0x%lx\n"),
8715 return xmalloc (nmemb
* size
);
8718 /* Like xrealloc, but takes three parameters.
8719 Verifies that the second parameter is not too large.
8720 Note: does *not* initialise any new memory to zero. */
8722 xcrealloc (void *ptr
, size_t nmemb
, size_t size
)
8724 /* Check for overflow. */
8725 if (nmemb
>= ~(size_t) 0 / size
)
8728 _("Attempt to re-allocate an array with an excessive number of elements: 0x%lx\n"),
8733 return xrealloc (ptr
, nmemb
* size
);
8736 /* Like xcalloc, but verifies that the first parameter is not too large. */
8738 xcalloc2 (size_t nmemb
, size_t size
)
8740 /* Check for overflow. */
8741 if (nmemb
>= ~(size_t) 0 / size
)
8744 _("Attempt to allocate a zero'ed array with an excessive number of elements: 0x%lx\n"),
8749 return xcalloc (nmemb
, size
);
8753 free_debug_memory (void)
8759 for (i
= 0; i
< max
; i
++)
8760 free_debug_section ((enum dwarf_section_display_enum
) i
);
8762 if (debug_information
!= NULL
)
8764 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
)
8766 for (i
= 0; i
< num_debug_info_entries
; i
++)
8768 if (!debug_information
[i
].max_loc_offsets
)
8770 free (debug_information
[i
].loc_offsets
);
8771 free (debug_information
[i
].have_frame_base
);
8773 if (!debug_information
[i
].max_range_lists
)
8774 free (debug_information
[i
].range_lists
);
8777 free (debug_information
);
8778 debug_information
= NULL
;
8779 alloc_num_debug_info_entries
= num_debug_info_entries
= 0;
8784 dwarf_select_sections_by_names (const char *names
)
8788 const char * option
;
8792 debug_dump_long_opts
;
8794 static const debug_dump_long_opts opts_table
[] =
8796 /* Please keep this table alpha- sorted. */
8797 { "Ranges", & do_debug_ranges
, 1 },
8798 { "abbrev", & do_debug_abbrevs
, 1 },
8799 { "addr", & do_debug_addr
, 1 },
8800 { "aranges", & do_debug_aranges
, 1 },
8801 { "cu_index", & do_debug_cu_index
, 1 },
8802 { "decodedline", & do_debug_lines
, FLAG_DEBUG_LINES_DECODED
},
8803 { "frames", & do_debug_frames
, 1 },
8804 { "frames-interp", & do_debug_frames_interp
, 1 },
8805 /* The special .gdb_index section. */
8806 { "gdb_index", & do_gdb_index
, 1 },
8807 { "info", & do_debug_info
, 1 },
8808 { "line", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
}, /* For backwards compatibility. */
8809 { "loc", & do_debug_loc
, 1 },
8810 { "macro", & do_debug_macinfo
, 1 },
8811 { "pubnames", & do_debug_pubnames
, 1 },
8812 { "pubtypes", & do_debug_pubtypes
, 1 },
8813 /* This entry is for compatibility
8814 with earlier versions of readelf. */
8815 { "ranges", & do_debug_aranges
, 1 },
8816 { "rawline", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
},
8817 { "str", & do_debug_str
, 1 },
8818 /* These trace_* sections are used by Itanium VMS. */
8819 { "trace_abbrev", & do_trace_abbrevs
, 1 },
8820 { "trace_aranges", & do_trace_aranges
, 1 },
8821 { "trace_info", & do_trace_info
, 1 },
8830 const debug_dump_long_opts
* entry
;
8832 for (entry
= opts_table
; entry
->option
; entry
++)
8834 size_t len
= strlen (entry
->option
);
8836 if (strncmp (p
, entry
->option
, len
) == 0
8837 && (p
[len
] == ',' || p
[len
] == '\0'))
8839 * entry
->variable
|= entry
->val
;
8841 /* The --debug-dump=frames-interp option also
8842 enables the --debug-dump=frames option. */
8843 if (do_debug_frames_interp
)
8844 do_debug_frames
= 1;
8851 if (entry
->option
== NULL
)
8853 warn (_("Unrecognized debug option '%s'\n"), p
);
8854 p
= strchr (p
, ',');
8865 dwarf_select_sections_by_letters (const char *letters
)
8867 unsigned int lindex
= 0;
8869 while (letters
[lindex
])
8870 switch (letters
[lindex
++])
8877 do_debug_abbrevs
= 1;
8881 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
8885 do_debug_lines
|= FLAG_DEBUG_LINES_DECODED
;
8889 do_debug_pubnames
= 1;
8893 do_debug_pubtypes
= 1;
8897 do_debug_aranges
= 1;
8901 do_debug_ranges
= 1;
8905 do_debug_frames_interp
= 1;
8908 do_debug_frames
= 1;
8912 do_debug_macinfo
= 1;
8924 warn (_("Unrecognized debug option '%s'\n"), letters
);
8930 dwarf_select_sections_all (void)
8933 do_debug_abbrevs
= 1;
8934 do_debug_lines
= FLAG_DEBUG_LINES_RAW
;
8935 do_debug_pubnames
= 1;
8936 do_debug_pubtypes
= 1;
8937 do_debug_aranges
= 1;
8938 do_debug_ranges
= 1;
8939 do_debug_frames
= 1;
8940 do_debug_macinfo
= 1;
8945 do_trace_abbrevs
= 1;
8946 do_trace_aranges
= 1;
8948 do_debug_cu_index
= 1;
8951 struct dwarf_section_display debug_displays
[] =
8953 { { ".debug_abbrev", ".zdebug_abbrev", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8954 display_debug_abbrev
, &do_debug_abbrevs
, FALSE
},
8955 { { ".debug_aranges", ".zdebug_aranges", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8956 display_debug_aranges
, &do_debug_aranges
, TRUE
},
8957 { { ".debug_frame", ".zdebug_frame", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8958 display_debug_frames
, &do_debug_frames
, TRUE
},
8959 { { ".debug_info", ".zdebug_info", NULL
, NULL
, 0, 0, abbrev
, NULL
, 0, NULL
},
8960 display_debug_info
, &do_debug_info
, TRUE
},
8961 { { ".debug_line", ".zdebug_line", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8962 display_debug_lines
, &do_debug_lines
, TRUE
},
8963 { { ".debug_pubnames", ".zdebug_pubnames", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8964 display_debug_pubnames
, &do_debug_pubnames
, FALSE
},
8965 { { ".debug_gnu_pubnames", ".zdebug_gnu_pubnames", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8966 display_debug_gnu_pubnames
, &do_debug_pubnames
, FALSE
},
8967 { { ".eh_frame", "", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8968 display_debug_frames
, &do_debug_frames
, TRUE
},
8969 { { ".debug_macinfo", ".zdebug_macinfo", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8970 display_debug_macinfo
, &do_debug_macinfo
, FALSE
},
8971 { { ".debug_macro", ".zdebug_macro", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8972 display_debug_macro
, &do_debug_macinfo
, TRUE
},
8973 { { ".debug_str", ".zdebug_str", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8974 display_debug_str
, &do_debug_str
, FALSE
},
8975 { { ".debug_line_str", ".zdebug_line_str", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8976 display_debug_str
, &do_debug_str
, FALSE
},
8977 { { ".debug_loc", ".zdebug_loc", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8978 display_debug_loc
, &do_debug_loc
, TRUE
},
8979 { { ".debug_loclists", ".zdebug_loclists", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8980 display_debug_loc
, &do_debug_loc
, TRUE
},
8981 { { ".debug_pubtypes", ".zdebug_pubtypes", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8982 display_debug_pubnames
, &do_debug_pubtypes
, FALSE
},
8983 { { ".debug_gnu_pubtypes", ".zdebug_gnu_pubtypes", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8984 display_debug_gnu_pubnames
, &do_debug_pubtypes
, FALSE
},
8985 { { ".debug_ranges", ".zdebug_ranges", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8986 display_debug_ranges
, &do_debug_ranges
, TRUE
},
8987 { { ".debug_rnglists", ".zdebug_rnglists", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8988 display_debug_ranges
, &do_debug_ranges
, TRUE
},
8989 { { ".debug_static_func", ".zdebug_static_func", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8990 display_debug_not_supported
, NULL
, FALSE
},
8991 { { ".debug_static_vars", ".zdebug_static_vars", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8992 display_debug_not_supported
, NULL
, FALSE
},
8993 { { ".debug_types", ".zdebug_types", NULL
, NULL
, 0, 0, abbrev
, NULL
, 0, NULL
},
8994 display_debug_types
, &do_debug_info
, TRUE
},
8995 { { ".debug_weaknames", ".zdebug_weaknames", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8996 display_debug_not_supported
, NULL
, FALSE
},
8997 { { ".gdb_index", "", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
8998 display_gdb_index
, &do_gdb_index
, FALSE
},
8999 { { ".debug_names", "", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9000 display_debug_names
, &do_gdb_index
, FALSE
},
9001 { { ".trace_info", "", NULL
, NULL
, 0, 0, trace_abbrev
, NULL
, 0, NULL
},
9002 display_trace_info
, &do_trace_info
, TRUE
},
9003 { { ".trace_abbrev", "", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9004 display_debug_abbrev
, &do_trace_abbrevs
, FALSE
},
9005 { { ".trace_aranges", "", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9006 display_debug_aranges
, &do_trace_aranges
, FALSE
},
9007 { { ".debug_info.dwo", ".zdebug_info.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
, NULL
, 0, NULL
},
9008 display_debug_info
, &do_debug_info
, TRUE
},
9009 { { ".debug_abbrev.dwo", ".zdebug_abbrev.dwo", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9010 display_debug_abbrev
, &do_debug_abbrevs
, FALSE
},
9011 { { ".debug_types.dwo", ".zdebug_types.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
, NULL
, 0, NULL
},
9012 display_debug_types
, &do_debug_info
, TRUE
},
9013 { { ".debug_line.dwo", ".zdebug_line.dwo", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9014 display_debug_lines
, &do_debug_lines
, TRUE
},
9015 { { ".debug_loc.dwo", ".zdebug_loc.dwo", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9016 display_debug_loc
, &do_debug_loc
, TRUE
},
9017 { { ".debug_macro.dwo", ".zdebug_macro.dwo", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9018 display_debug_macro
, &do_debug_macinfo
, TRUE
},
9019 { { ".debug_macinfo.dwo", ".zdebug_macinfo.dwo", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9020 display_debug_macinfo
, &do_debug_macinfo
, FALSE
},
9021 { { ".debug_str.dwo", ".zdebug_str.dwo", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9022 display_debug_str
, &do_debug_str
, TRUE
},
9023 { { ".debug_str_offsets", ".zdebug_str_offsets", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9024 display_debug_str_offsets
, NULL
, FALSE
},
9025 { { ".debug_str_offsets.dwo", ".zdebug_str_offsets.dwo", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9026 display_debug_str_offsets
, NULL
, FALSE
},
9027 { { ".debug_addr", ".zdebug_addr", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9028 display_debug_addr
, &do_debug_addr
, TRUE
},
9029 { { ".debug_cu_index", "", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9030 display_cu_index
, &do_debug_cu_index
, FALSE
},
9031 { { ".debug_tu_index", "", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9032 display_cu_index
, &do_debug_cu_index
, FALSE
},
9035 /* A static assertion. */
9036 extern int debug_displays_assert
[ARRAY_SIZE (debug_displays
) == max
? 1 : -1];