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 num_debug_info_entries
= 0;
44 static unsigned int alloc_num_debug_info_entries
= 0;
45 static debug_info
*debug_information
= NULL
;
46 /* Special value for num_debug_info_entries to indicate
47 that the .debug_info section could not be loaded/parsed. */
48 #define DEBUG_INFO_UNAVAILABLE (unsigned int) -1
50 unsigned int eh_addr_size
;
55 int do_debug_pubnames
;
56 int do_debug_pubtypes
;
60 int do_debug_frames_interp
;
69 int do_debug_cu_index
;
72 int dwarf_cutoff_level
= -1;
73 unsigned long dwarf_start_die
;
77 /* Collection of CU/TU section sets from .debug_cu_index and .debug_tu_index
78 sections. For version 1 package files, each set is stored in SHNDX_POOL
79 as a zero-terminated list of section indexes comprising one set of debug
80 sections from a .dwo file. */
82 static unsigned int *shndx_pool
= NULL
;
83 static unsigned int shndx_pool_size
= 0;
84 static unsigned int shndx_pool_used
= 0;
86 /* For version 2 package files, each set contains an array of section offsets
87 and an array of section sizes, giving the offset and size of the
88 contribution from a CU or TU within one of the debug sections.
89 When displaying debug info from a package file, we need to use these
90 tables to locate the corresponding contributions to each section. */
95 dwarf_vma section_offsets
[DW_SECT_MAX
];
96 size_t section_sizes
[DW_SECT_MAX
];
99 static int cu_count
= 0;
100 static int tu_count
= 0;
101 static struct cu_tu_set
*cu_sets
= NULL
;
102 static struct cu_tu_set
*tu_sets
= NULL
;
104 static bfd_boolean
load_cu_tu_indexes (void *);
106 /* Values for do_debug_lines. */
107 #define FLAG_DEBUG_LINES_RAW 1
108 #define FLAG_DEBUG_LINES_DECODED 2
111 size_of_encoded_value (int encoding
)
113 switch (encoding
& 0x7)
116 case 0: return eh_addr_size
;
124 get_encoded_value (unsigned char **pdata
,
126 struct dwarf_section
*section
,
129 unsigned char * data
= * pdata
;
130 unsigned int size
= size_of_encoded_value (encoding
);
133 if (data
+ size
>= end
)
135 warn (_("Encoded value extends past end of section\n"));
140 /* PR 17512: file: 002-829853-0.004. */
143 warn (_("Encoded size of %d is too large to read\n"), size
);
148 /* PR 17512: file: 1085-5603-0.004. */
151 warn (_("Encoded size of 0 is too small to read\n"));
156 if (encoding
& DW_EH_PE_signed
)
157 val
= byte_get_signed (data
, size
);
159 val
= byte_get (data
, size
);
161 if ((encoding
& 0x70) == DW_EH_PE_pcrel
)
162 val
+= section
->address
+ (data
- section
->start
);
164 * pdata
= data
+ size
;
168 #if defined HAVE_LONG_LONG && SIZEOF_LONG_LONG > SIZEOF_LONG
170 # define DWARF_VMA_FMT "ll"
171 # define DWARF_VMA_FMT_LONG "%16.16llx"
173 # define DWARF_VMA_FMT "I64"
174 # define DWARF_VMA_FMT_LONG "%016I64x"
177 # define DWARF_VMA_FMT "l"
178 # define DWARF_VMA_FMT_LONG "%16.16lx"
181 /* Convert a dwarf vma value into a string. Returns a pointer to a static
182 buffer containing the converted VALUE. The value is converted according
183 to the printf formating character FMTCH. If NUM_BYTES is non-zero then
184 it specifies the maximum number of bytes to be displayed in the converted
185 value and FMTCH is ignored - hex is always used. */
188 dwarf_vmatoa_1 (const char *fmtch
, dwarf_vma value
, unsigned num_bytes
)
190 /* As dwarf_vmatoa is used more then once in a printf call
191 for output, we are cycling through an fixed array of pointers
192 for return address. */
193 static int buf_pos
= 0;
194 static struct dwarf_vmatoa_buf
200 ret
= buf
[buf_pos
++].place
;
201 buf_pos
%= ARRAY_SIZE (buf
);
205 /* Printf does not have a way of specifying a maximum field width for an
206 integer value, so we print the full value into a buffer and then select
207 the precision we need. */
208 snprintf (ret
, sizeof (buf
[0].place
), DWARF_VMA_FMT_LONG
, value
);
211 return ret
+ (16 - 2 * num_bytes
);
218 sprintf (fmt
, "%%%s%s", DWARF_VMA_FMT
, fmtch
);
220 sprintf (fmt
, "%%%s", DWARF_VMA_FMT
);
221 snprintf (ret
, sizeof (buf
[0].place
), fmt
, value
);
226 static inline const char *
227 dwarf_vmatoa (const char * fmtch
, dwarf_vma value
)
229 return dwarf_vmatoa_1 (fmtch
, value
, 0);
232 /* Print a dwarf_vma value (typically an address, offset or length) in
233 hexadecimal format, followed by a space. The length of the VALUE (and
234 hence the precision displayed) is determined by the NUM_BYTES parameter. */
237 print_dwarf_vma (dwarf_vma value
, unsigned num_bytes
)
239 printf ("%s ", dwarf_vmatoa_1 (NULL
, value
, num_bytes
));
242 /* Format a 64-bit value, given as two 32-bit values, in hex.
243 For reentrancy, this uses a buffer provided by the caller. */
246 dwarf_vmatoa64 (dwarf_vma hvalue
, dwarf_vma lvalue
, char *buf
,
247 unsigned int buf_len
)
252 snprintf (buf
, buf_len
, "%" DWARF_VMA_FMT
"x", lvalue
);
255 len
= snprintf (buf
, buf_len
, "%" DWARF_VMA_FMT
"x", hvalue
);
256 snprintf (buf
+ len
, buf_len
- len
,
257 "%08" DWARF_VMA_FMT
"x", lvalue
);
263 /* Read in a LEB128 encoded value starting at address DATA.
264 If SIGN is true, return a signed LEB128 value.
265 If LENGTH_RETURN is not NULL, return in it the number of bytes read.
266 No bytes will be read at address END or beyond. */
269 read_leb128 (unsigned char *data
,
270 unsigned int *length_return
,
272 const unsigned char * const end
)
274 dwarf_vma result
= 0;
275 unsigned int num_read
= 0;
276 unsigned int shift
= 0;
277 unsigned char byte
= 0;
284 result
|= ((dwarf_vma
) (byte
& 0x7f)) << shift
;
287 if ((byte
& 0x80) == 0)
290 /* PR 17512: file: 0ca183b8.
291 FIXME: Should we signal this error somehow ? */
292 if (shift
>= sizeof (result
) * 8)
296 if (length_return
!= NULL
)
297 *length_return
= num_read
;
299 if (sign
&& (shift
< 8 * sizeof (result
)) && (byte
& 0x40))
300 result
|= -((dwarf_vma
) 1 << shift
);
305 /* Create a signed version to avoid painful typecasts. */
306 static inline dwarf_signed_vma
307 read_sleb128 (unsigned char * data
,
308 unsigned int * length_return
,
309 const unsigned char * const end
)
311 return (dwarf_signed_vma
) read_leb128 (data
, length_return
, TRUE
, end
);
314 static inline dwarf_vma
315 read_uleb128 (unsigned char * data
,
316 unsigned int * length_return
,
317 const unsigned char * const end
)
319 return read_leb128 (data
, length_return
, FALSE
, end
);
322 #define SKIP_ULEB() read_uleb128 (start, & length_return, end); start += length_return
323 #define SKIP_SLEB() read_sleb128 (start, & length_return, end); start += length_return
325 #define READ_ULEB(var) \
330 (var) = _val = read_uleb128 (start, &length_return, end); \
332 error (_("Internal error: %s%d: LEB value (%#" DWARF_VMA_FMT "x) too large for containing variable\n"), \
333 __FILE__, __LINE__, _val); \
334 start += length_return; \
338 #define READ_SLEB(var) \
341 dwarf_signed_vma _val; \
343 (var) = _val = read_sleb128 (start, &length_return, end); \
345 error (_("Internal error: %s%d: LEB value (%#" DWARF_VMA_FMT "x) too large for containing variable\n"), \
346 __FILE__, __LINE__, _val); \
347 start += length_return; \
351 #define SAFE_BYTE_GET(VAL, PTR, AMOUNT, END) \
354 unsigned int amount = (AMOUNT); \
355 if (sizeof (VAL) < amount) \
357 error (_("internal error: attempt to read %d bytes of data in to %d sized variable"),\
358 amount, (int) sizeof (VAL)); \
359 amount = sizeof (VAL); \
361 if (((PTR) + amount) >= (END)) \
364 amount = (END) - (PTR); \
368 if (amount == 0 || amount > 8) \
371 VAL = byte_get ((PTR), amount); \
375 #define SAFE_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \
378 SAFE_BYTE_GET (VAL, PTR, AMOUNT, END); \
383 #define SAFE_SIGNED_BYTE_GET(VAL, PTR, AMOUNT, END) \
386 unsigned int amount = (AMOUNT); \
387 if (((PTR) + amount) >= (END)) \
390 amount = (END) - (PTR); \
395 VAL = byte_get_signed ((PTR), amount); \
401 #define SAFE_SIGNED_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \
404 SAFE_SIGNED_BYTE_GET (VAL, PTR, AMOUNT, END); \
409 #define SAFE_BYTE_GET64(PTR, HIGH, LOW, END) \
412 if (((PTR) + 8) <= (END)) \
414 byte_get_64 ((PTR), (HIGH), (LOW)); \
418 * (LOW) = * (HIGH) = 0; \
423 typedef struct State_Machine_Registers
432 unsigned char op_index
;
433 unsigned char end_sequence
;
434 /* This variable hold the number of the last entry seen
435 in the File Table. */
436 unsigned int last_file_entry
;
439 static SMR state_machine_regs
;
442 reset_state_machine (int is_stmt
)
444 state_machine_regs
.address
= 0;
445 state_machine_regs
.view
= 0;
446 state_machine_regs
.op_index
= 0;
447 state_machine_regs
.file
= 1;
448 state_machine_regs
.line
= 1;
449 state_machine_regs
.column
= 0;
450 state_machine_regs
.is_stmt
= is_stmt
;
451 state_machine_regs
.basic_block
= 0;
452 state_machine_regs
.end_sequence
= 0;
453 state_machine_regs
.last_file_entry
= 0;
456 /* Handled an extend line op.
457 Returns the number of bytes read. */
460 process_extended_line_op (unsigned char * data
,
464 unsigned char op_code
;
465 unsigned int bytes_read
;
468 unsigned char *orig_data
= data
;
471 len
= read_uleb128 (data
, & bytes_read
, end
);
474 if (len
== 0 || data
== end
|| len
> (uintptr_t) (end
- data
))
476 warn (_("Badly formed extended line op encountered!\n"));
483 printf (_(" Extended opcode %d: "), op_code
);
487 case DW_LNE_end_sequence
:
488 printf (_("End of Sequence\n\n"));
489 reset_state_machine (is_stmt
);
492 case DW_LNE_set_address
:
493 /* PR 17512: file: 002-100480-0.004. */
494 if (len
- bytes_read
- 1 > 8)
496 warn (_("Length (%d) of DW_LNE_set_address op is too long\n"),
497 len
- bytes_read
- 1);
501 SAFE_BYTE_GET (adr
, data
, len
- bytes_read
- 1, end
);
502 printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr
));
503 state_machine_regs
.address
= adr
;
504 state_machine_regs
.view
= 0;
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 /* If we have already tried and failed to load the .debug_info
2924 section then do not bother to repeat the task. */
2925 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
2928 /* If we already have the information there is nothing else to do. */
2929 if (num_debug_info_entries
> 0)
2930 return num_debug_info_entries
;
2932 /* If this is a DWARF package file, load the CU and TU indexes. */
2933 (void) load_cu_tu_indexes (file
);
2935 if (load_debug_section (info
, file
)
2936 && process_debug_info (&debug_displays
[info
].section
, file
, abbrev
, 1, 0))
2937 return num_debug_info_entries
;
2939 if (load_debug_section (info_dwo
, file
)
2940 && process_debug_info (&debug_displays
[info_dwo
].section
, file
,
2942 return num_debug_info_entries
;
2944 num_debug_info_entries
= DEBUG_INFO_UNAVAILABLE
;
2948 /* Read a DWARF .debug_line section header starting at DATA.
2949 Upon success returns an updated DATA pointer and the LINFO
2950 structure and the END_OF_SEQUENCE pointer will be filled in.
2951 Otherwise returns NULL. */
2953 static unsigned char *
2954 read_debug_line_header (struct dwarf_section
* section
,
2955 unsigned char * data
,
2956 unsigned char * end
,
2957 DWARF2_Internal_LineInfo
* linfo
,
2958 unsigned char ** end_of_sequence
)
2960 unsigned char *hdrptr
;
2961 unsigned int initial_length_size
;
2962 unsigned char address_size
, segment_selector_size
;
2964 /* Extract information from the Line Number Program Header.
2965 (section 6.2.4 in the Dwarf3 doc). */
2968 /* Get and check the length of the block. */
2969 SAFE_BYTE_GET_AND_INC (linfo
->li_length
, hdrptr
, 4, end
);
2971 if (linfo
->li_length
== 0xffffffff)
2973 /* This section is 64-bit DWARF 3. */
2974 SAFE_BYTE_GET_AND_INC (linfo
->li_length
, hdrptr
, 8, end
);
2975 linfo
->li_offset_size
= 8;
2976 initial_length_size
= 12;
2980 linfo
->li_offset_size
= 4;
2981 initial_length_size
= 4;
2984 if (linfo
->li_length
+ initial_length_size
> section
->size
)
2986 /* If the length field has a relocation against it, then we should
2987 not complain if it is inaccurate (and probably negative). This
2988 happens in object files when the .debug_line section is actually
2989 comprised of several different .debug_line.* sections, (some of
2990 which may be removed by linker garbage collection), and a relocation
2991 is used to compute the correct length once that is done. */
2992 if (reloc_at (section
, (hdrptr
- section
->start
) - linfo
->li_offset_size
))
2994 linfo
->li_length
= (end
- data
) - initial_length_size
;
2998 warn (_("The length field (0x%lx) in the debug_line header is wrong - the section is too small\n"),
2999 (long) linfo
->li_length
);
3004 /* Get and check the version number. */
3005 SAFE_BYTE_GET_AND_INC (linfo
->li_version
, hdrptr
, 2, end
);
3007 if (linfo
->li_version
!= 2
3008 && linfo
->li_version
!= 3
3009 && linfo
->li_version
!= 4
3010 && linfo
->li_version
!= 5)
3012 warn (_("Only DWARF version 2, 3, 4 and 5 line info "
3013 "is currently supported.\n"));
3017 if (linfo
->li_version
>= 5)
3019 SAFE_BYTE_GET_AND_INC (address_size
, hdrptr
, 1, end
);
3021 SAFE_BYTE_GET_AND_INC (segment_selector_size
, hdrptr
, 1, end
);
3022 if (segment_selector_size
!= 0)
3024 warn (_("The %s section contains "
3025 "unsupported segment selector size: %d.\n"),
3026 section
->name
, segment_selector_size
);
3031 SAFE_BYTE_GET_AND_INC (linfo
->li_prologue_length
, hdrptr
,
3032 linfo
->li_offset_size
, end
);
3033 SAFE_BYTE_GET_AND_INC (linfo
->li_min_insn_length
, hdrptr
, 1, end
);
3035 if (linfo
->li_version
>= 4)
3037 SAFE_BYTE_GET_AND_INC (linfo
->li_max_ops_per_insn
, hdrptr
, 1, end
);
3039 if (linfo
->li_max_ops_per_insn
== 0)
3041 warn (_("Invalid maximum operations per insn.\n"));
3046 linfo
->li_max_ops_per_insn
= 1;
3048 SAFE_BYTE_GET_AND_INC (linfo
->li_default_is_stmt
, hdrptr
, 1, end
);
3049 SAFE_SIGNED_BYTE_GET_AND_INC (linfo
->li_line_base
, hdrptr
, 1, end
);
3050 SAFE_BYTE_GET_AND_INC (linfo
->li_line_range
, hdrptr
, 1, end
);
3051 SAFE_BYTE_GET_AND_INC (linfo
->li_opcode_base
, hdrptr
, 1, end
);
3053 * end_of_sequence
= data
+ linfo
->li_length
+ initial_length_size
;
3054 /* PR 17512: file:002-117414-0.004. */
3055 if (* end_of_sequence
> end
)
3057 warn (_("Line length %s extends beyond end of section\n"),
3058 dwarf_vmatoa ("u", linfo
->li_length
));
3059 * end_of_sequence
= end
;
3066 static unsigned char *
3067 display_formatted_table (unsigned char *data
,
3068 unsigned char *start
, unsigned char *end
,
3069 const DWARF2_Internal_LineInfo
*linfo
,
3070 struct dwarf_section
*section
, const char *what
)
3072 unsigned char *format_start
, format_count
, *format
, formati
;
3073 dwarf_vma data_count
, datai
;
3074 unsigned int bytes_read
, namepass
, last_entry
= 0;
3076 SAFE_BYTE_GET_AND_INC (format_count
, data
, 1, end
);
3077 format_start
= data
;
3078 for (formati
= 0; formati
< format_count
; formati
++)
3080 read_uleb128 (data
, & bytes_read
, end
);
3082 read_uleb128 (data
, & bytes_read
, end
);
3086 warn (_("Corrupt %s format table entry\n"), what
);
3091 data_count
= read_uleb128 (data
, & bytes_read
, end
);
3095 warn (_("Corrupt %s list\n"), what
);
3099 if (data_count
== 0)
3101 printf (_("\n The %s Table is empty.\n"), what
);
3105 printf (_("\n The %s Table (offset 0x%lx):\n"), what
,
3106 (long)(data
- start
));
3108 printf (_(" Entry"));
3109 /* Delay displaying name as the last entry for better screen layout. */
3110 for (namepass
= 0; namepass
< 2; namepass
++)
3112 format
= format_start
;
3113 for (formati
= 0; formati
< format_count
; formati
++)
3115 dwarf_vma content_type
;
3117 content_type
= read_uleb128 (format
, & bytes_read
, end
);
3118 format
+= bytes_read
;
3119 if ((content_type
== DW_LNCT_path
) == (namepass
== 1))
3120 switch (content_type
)
3123 printf (_("\tName"));
3125 case DW_LNCT_directory_index
:
3126 printf (_("\tDir"));
3128 case DW_LNCT_timestamp
:
3129 printf (_("\tTime"));
3132 printf (_("\tSize"));
3135 printf (_("\tMD5"));
3138 printf (_("\t(Unknown format content type %s)"),
3139 dwarf_vmatoa ("u", content_type
));
3141 read_uleb128 (format
, & bytes_read
, end
);
3142 format
+= bytes_read
;
3147 for (datai
= 0; datai
< data_count
; datai
++)
3149 unsigned char *datapass
= data
;
3151 printf (" %d", last_entry
++);
3152 /* Delay displaying name as the last entry for better screen layout. */
3153 for (namepass
= 0; namepass
< 2; namepass
++)
3155 format
= format_start
;
3157 for (formati
= 0; formati
< format_count
; formati
++)
3159 dwarf_vma content_type
, form
;
3161 content_type
= read_uleb128 (format
, & bytes_read
, end
);
3162 format
+= bytes_read
;
3163 form
= read_uleb128 (format
, & bytes_read
, end
);
3164 format
+= bytes_read
;
3165 data
= read_and_display_attr_value (0, form
, 0, data
, end
, 0, 0,
3166 linfo
->li_offset_size
,
3167 linfo
->li_version
, NULL
,
3168 ((content_type
== DW_LNCT_path
) != (namepass
== 1)),
3169 section
, NULL
, '\t');
3174 warn (_("Corrupt %s entries list\n"), what
);
3183 display_debug_lines_raw (struct dwarf_section
*section
,
3184 unsigned char *data
,
3185 unsigned char *end
, void *file
)
3187 unsigned char *start
= section
->start
;
3188 int verbose_view
= 0;
3190 printf (_("Raw dump of debug contents of section %s:\n\n"),
3195 static DWARF2_Internal_LineInfo saved_linfo
;
3196 DWARF2_Internal_LineInfo linfo
;
3197 unsigned char *standard_opcodes
;
3198 unsigned char *end_of_sequence
;
3201 if (const_strneq (section
->name
, ".debug_line.")
3202 /* Note: the following does not apply to .debug_line.dwo sections.
3203 These are full debug_line sections. */
3204 && strcmp (section
->name
, ".debug_line.dwo") != 0)
3206 /* Sections named .debug_line.<foo> are fragments of a .debug_line
3207 section containing just the Line Number Statements. They are
3208 created by the assembler and intended to be used alongside gcc's
3209 -ffunction-sections command line option. When the linker's
3210 garbage collection decides to discard a .text.<foo> section it
3211 can then also discard the line number information in .debug_line.<foo>.
3213 Since the section is a fragment it does not have the details
3214 needed to fill out a LineInfo structure, so instead we use the
3215 details from the last full debug_line section that we processed. */
3216 end_of_sequence
= end
;
3217 standard_opcodes
= NULL
;
3218 linfo
= saved_linfo
;
3219 /* PR 17531: file: 0522b371. */
3220 if (linfo
.li_line_range
== 0)
3222 warn (_("Partial .debug_line. section encountered without a prior full .debug_line section\n"));
3225 reset_state_machine (linfo
.li_default_is_stmt
);
3229 unsigned char * hdrptr
;
3231 if ((hdrptr
= read_debug_line_header (section
, data
, end
, & linfo
,
3232 & end_of_sequence
)) == NULL
)
3235 printf (_(" Offset: 0x%lx\n"), (long)(data
- start
));
3236 printf (_(" Length: %ld\n"), (long) linfo
.li_length
);
3237 printf (_(" DWARF Version: %d\n"), linfo
.li_version
);
3238 printf (_(" Prologue Length: %d\n"), (int) linfo
.li_prologue_length
);
3239 printf (_(" Minimum Instruction Length: %d\n"), linfo
.li_min_insn_length
);
3240 if (linfo
.li_version
>= 4)
3241 printf (_(" Maximum Ops per Instruction: %d\n"), linfo
.li_max_ops_per_insn
);
3242 printf (_(" Initial value of 'is_stmt': %d\n"), linfo
.li_default_is_stmt
);
3243 printf (_(" Line Base: %d\n"), linfo
.li_line_base
);
3244 printf (_(" Line Range: %d\n"), linfo
.li_line_range
);
3245 printf (_(" Opcode Base: %d\n"), linfo
.li_opcode_base
);
3247 /* PR 17512: file: 1665-6428-0.004. */
3248 if (linfo
.li_line_range
== 0)
3250 warn (_("Line range of 0 is invalid, using 1 instead\n"));
3251 linfo
.li_line_range
= 1;
3254 reset_state_machine (linfo
.li_default_is_stmt
);
3256 /* Display the contents of the Opcodes table. */
3257 standard_opcodes
= hdrptr
;
3259 /* PR 17512: file: 002-417945-0.004. */
3260 if (standard_opcodes
+ linfo
.li_opcode_base
>= end
)
3262 warn (_("Line Base extends beyond end of section\n"));
3266 printf (_("\n Opcodes:\n"));
3268 for (i
= 1; i
< linfo
.li_opcode_base
; i
++)
3269 printf (_(" Opcode %d has %d args\n"), i
, standard_opcodes
[i
- 1]);
3271 /* Display the contents of the Directory table. */
3272 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
3274 if (linfo
.li_version
>= 5)
3276 load_debug_section (line_str
, file
);
3278 data
= display_formatted_table (data
, start
, end
, &linfo
, section
,
3280 data
= display_formatted_table (data
, start
, end
, &linfo
, section
,
3286 printf (_("\n The Directory Table is empty.\n"));
3289 unsigned int last_dir_entry
= 0;
3291 printf (_("\n The Directory Table (offset 0x%lx):\n"),
3292 (long)(data
- start
));
3294 while (data
< end
&& *data
!= 0)
3296 printf (" %d\t%.*s\n", ++last_dir_entry
, (int) (end
- data
), data
);
3298 data
+= strnlen ((char *) data
, end
- data
) + 1;
3301 /* PR 17512: file: 002-132094-0.004. */
3302 if (data
>= end
- 1)
3306 /* Skip the NUL at the end of the table. */
3309 /* Display the contents of the File Name table. */
3311 printf (_("\n The File Name Table is empty.\n"));
3314 printf (_("\n The File Name Table (offset 0x%lx):\n"),
3315 (long)(data
- start
));
3316 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
3318 while (data
< end
&& *data
!= 0)
3320 unsigned char *name
;
3321 unsigned int bytes_read
;
3323 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
3325 data
+= strnlen ((char *) data
, end
- data
) + 1;
3328 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
3331 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
3334 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
3336 printf ("%.*s\n", (int)(end
- name
), name
);
3340 warn (_("Corrupt file name table entry\n"));
3346 /* Skip the NUL at the end of the table. */
3351 saved_linfo
= linfo
;
3354 /* Now display the statements. */
3355 if (data
>= end_of_sequence
)
3356 printf (_(" No Line Number Statements.\n"));
3359 printf (_(" Line Number Statements:\n"));
3361 while (data
< end_of_sequence
)
3363 unsigned char op_code
;
3364 dwarf_signed_vma adv
;
3366 unsigned int bytes_read
;
3368 printf (" [0x%08lx]", (long)(data
- start
));
3372 if (op_code
>= linfo
.li_opcode_base
)
3374 op_code
-= linfo
.li_opcode_base
;
3375 uladv
= (op_code
/ linfo
.li_line_range
);
3376 if (linfo
.li_max_ops_per_insn
== 1)
3378 uladv
*= linfo
.li_min_insn_length
;
3379 state_machine_regs
.address
+= uladv
;
3381 state_machine_regs
.view
= 0;
3382 printf (_(" Special opcode %d: "
3383 "advance Address by %s to 0x%s%s"),
3384 op_code
, dwarf_vmatoa ("u", uladv
),
3385 dwarf_vmatoa ("x", state_machine_regs
.address
),
3386 verbose_view
&& uladv
3387 ? _(" (reset view)") : "");
3392 = ((state_machine_regs
.op_index
+ uladv
)
3393 / linfo
.li_max_ops_per_insn
)
3394 * linfo
.li_min_insn_length
;
3396 state_machine_regs
.address
+= addrdelta
;
3397 state_machine_regs
.op_index
3398 = (state_machine_regs
.op_index
+ uladv
)
3399 % linfo
.li_max_ops_per_insn
;
3401 state_machine_regs
.view
= 0;
3402 printf (_(" Special opcode %d: "
3403 "advance Address by %s to 0x%s[%d]%s"),
3404 op_code
, dwarf_vmatoa ("u", uladv
),
3405 dwarf_vmatoa ("x", state_machine_regs
.address
),
3406 state_machine_regs
.op_index
,
3407 verbose_view
&& addrdelta
3408 ? _(" (reset view)") : "");
3410 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
3411 state_machine_regs
.line
+= adv
;
3412 printf (_(" and Line by %s to %d"),
3413 dwarf_vmatoa ("d", adv
), state_machine_regs
.line
);
3414 if (verbose_view
|| state_machine_regs
.view
)
3415 printf (_(" (view %u)\n"), state_machine_regs
.view
);
3418 state_machine_regs
.view
++;
3420 else switch (op_code
)
3422 case DW_LNS_extended_op
:
3423 data
+= process_extended_line_op (data
, linfo
.li_default_is_stmt
, end
);
3427 printf (_(" Copy"));
3428 if (verbose_view
|| state_machine_regs
.view
)
3429 printf (_(" (view %u)\n"), state_machine_regs
.view
);
3432 state_machine_regs
.view
++;
3435 case DW_LNS_advance_pc
:
3436 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3438 if (linfo
.li_max_ops_per_insn
== 1)
3440 uladv
*= linfo
.li_min_insn_length
;
3441 state_machine_regs
.address
+= uladv
;
3443 state_machine_regs
.view
= 0;
3444 printf (_(" Advance PC by %s to 0x%s%s\n"),
3445 dwarf_vmatoa ("u", uladv
),
3446 dwarf_vmatoa ("x", state_machine_regs
.address
),
3447 verbose_view
&& uladv
3448 ? _(" (reset view)") : "");
3453 = ((state_machine_regs
.op_index
+ uladv
)
3454 / linfo
.li_max_ops_per_insn
)
3455 * linfo
.li_min_insn_length
;
3456 state_machine_regs
.address
3458 state_machine_regs
.op_index
3459 = (state_machine_regs
.op_index
+ uladv
)
3460 % linfo
.li_max_ops_per_insn
;
3462 state_machine_regs
.view
= 0;
3463 printf (_(" Advance PC by %s to 0x%s[%d]%s\n"),
3464 dwarf_vmatoa ("u", uladv
),
3465 dwarf_vmatoa ("x", state_machine_regs
.address
),
3466 state_machine_regs
.op_index
,
3467 verbose_view
&& addrdelta
3468 ? _(" (reset view)") : "");
3472 case DW_LNS_advance_line
:
3473 adv
= read_sleb128 (data
, & bytes_read
, end
);
3475 state_machine_regs
.line
+= adv
;
3476 printf (_(" Advance Line by %s to %d\n"),
3477 dwarf_vmatoa ("d", adv
),
3478 state_machine_regs
.line
);
3481 case DW_LNS_set_file
:
3482 adv
= read_uleb128 (data
, & bytes_read
, end
);
3484 printf (_(" Set File Name to entry %s in the File Name Table\n"),
3485 dwarf_vmatoa ("d", adv
));
3486 state_machine_regs
.file
= adv
;
3489 case DW_LNS_set_column
:
3490 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3492 printf (_(" Set column to %s\n"),
3493 dwarf_vmatoa ("u", uladv
));
3494 state_machine_regs
.column
= uladv
;
3497 case DW_LNS_negate_stmt
:
3498 adv
= state_machine_regs
.is_stmt
;
3500 printf (_(" Set is_stmt to %s\n"), dwarf_vmatoa ("d", adv
));
3501 state_machine_regs
.is_stmt
= adv
;
3504 case DW_LNS_set_basic_block
:
3505 printf (_(" Set basic block\n"));
3506 state_machine_regs
.basic_block
= 1;
3509 case DW_LNS_const_add_pc
:
3510 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
3511 if (linfo
.li_max_ops_per_insn
)
3513 uladv
*= linfo
.li_min_insn_length
;
3514 state_machine_regs
.address
+= uladv
;
3516 state_machine_regs
.view
= 0;
3517 printf (_(" Advance PC by constant %s to 0x%s%s\n"),
3518 dwarf_vmatoa ("u", uladv
),
3519 dwarf_vmatoa ("x", state_machine_regs
.address
),
3520 verbose_view
&& uladv
3521 ? _(" (reset view)") : "");
3526 = ((state_machine_regs
.op_index
+ uladv
)
3527 / linfo
.li_max_ops_per_insn
)
3528 * linfo
.li_min_insn_length
;
3529 state_machine_regs
.address
3531 state_machine_regs
.op_index
3532 = (state_machine_regs
.op_index
+ uladv
)
3533 % linfo
.li_max_ops_per_insn
;
3535 state_machine_regs
.view
= 0;
3536 printf (_(" Advance PC by constant %s to 0x%s[%d]%s\n"),
3537 dwarf_vmatoa ("u", uladv
),
3538 dwarf_vmatoa ("x", state_machine_regs
.address
),
3539 state_machine_regs
.op_index
,
3540 verbose_view
&& addrdelta
3541 ? _(" (reset view)") : "");
3545 case DW_LNS_fixed_advance_pc
:
3546 SAFE_BYTE_GET_AND_INC (uladv
, data
, 2, end
);
3547 state_machine_regs
.address
+= uladv
;
3548 state_machine_regs
.op_index
= 0;
3549 printf (_(" Advance PC by fixed size amount %s to 0x%s\n"),
3550 dwarf_vmatoa ("u", uladv
),
3551 dwarf_vmatoa ("x", state_machine_regs
.address
));
3552 /* Do NOT reset view. */
3555 case DW_LNS_set_prologue_end
:
3556 printf (_(" Set prologue_end to true\n"));
3559 case DW_LNS_set_epilogue_begin
:
3560 printf (_(" Set epilogue_begin to true\n"));
3563 case DW_LNS_set_isa
:
3564 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3566 printf (_(" Set ISA to %s\n"), dwarf_vmatoa ("u", uladv
));
3570 printf (_(" Unknown opcode %d with operands: "), op_code
);
3572 if (standard_opcodes
!= NULL
)
3573 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
3575 printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data
,
3577 i
== 1 ? "" : ", ");
3593 unsigned char *name
;
3594 unsigned int directory_index
;
3595 unsigned int modification_date
;
3596 unsigned int length
;
3599 /* Output a decoded representation of the .debug_line section. */
3602 display_debug_lines_decoded (struct dwarf_section
*section
,
3603 unsigned char *data
,
3604 unsigned char *end
, void *fileptr
)
3606 static DWARF2_Internal_LineInfo saved_linfo
;
3608 printf (_("Decoded dump of debug contents of section %s:\n\n"),
3613 /* This loop amounts to one iteration per compilation unit. */
3614 DWARF2_Internal_LineInfo linfo
;
3615 unsigned char *standard_opcodes
;
3616 unsigned char *end_of_sequence
;
3618 File_Entry
*file_table
= NULL
;
3619 unsigned int n_files
= 0;
3620 unsigned char **directory_table
= NULL
;
3621 dwarf_vma n_directories
= 0;
3623 if (const_strneq (section
->name
, ".debug_line.")
3624 /* Note: the following does not apply to .debug_line.dwo sections.
3625 These are full debug_line sections. */
3626 && strcmp (section
->name
, ".debug_line.dwo") != 0)
3628 /* See comment in display_debug_lines_raw(). */
3629 end_of_sequence
= end
;
3630 standard_opcodes
= NULL
;
3631 linfo
= saved_linfo
;
3632 /* PR 17531: file: 0522b371. */
3633 if (linfo
.li_line_range
== 0)
3635 warn (_("Partial .debug_line. section encountered without a prior full .debug_line section\n"));
3638 reset_state_machine (linfo
.li_default_is_stmt
);
3642 unsigned char *hdrptr
;
3644 if ((hdrptr
= read_debug_line_header (section
, data
, end
, & linfo
,
3645 & end_of_sequence
)) == NULL
)
3648 /* PR 17531: file: 0522b371. */
3649 if (linfo
.li_line_range
== 0)
3651 warn (_("Line range of 0 is invalid, using 1 instead\n"));
3652 linfo
.li_line_range
= 1;
3654 reset_state_machine (linfo
.li_default_is_stmt
);
3656 /* Save a pointer to the contents of the Opcodes table. */
3657 standard_opcodes
= hdrptr
;
3659 /* Traverse the Directory table just to count entries. */
3660 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
3664 warn (_("opcode base of %d extends beyond end of section\n"),
3665 linfo
.li_opcode_base
);
3669 if (linfo
.li_version
>= 5)
3671 unsigned char *format_start
, format_count
, *format
;
3672 dwarf_vma formati
, entryi
;
3673 unsigned int bytes_read
;
3675 load_debug_section (line_str
, fileptr
);
3677 /* Skip directories format. */
3678 SAFE_BYTE_GET_AND_INC (format_count
, data
, 1, end
);
3679 format_start
= data
;
3680 for (formati
= 0; formati
< format_count
; formati
++)
3682 read_uleb128 (data
, & bytes_read
, end
);
3684 read_uleb128 (data
, & bytes_read
, end
);
3688 n_directories
= read_uleb128 (data
, & bytes_read
, end
);
3692 warn (_("Corrupt directories list\n"));
3696 directory_table
= (unsigned char **)
3697 xmalloc (n_directories
* sizeof (unsigned char *));
3699 for (entryi
= 0; entryi
< n_directories
; entryi
++)
3701 unsigned char **pathp
= &directory_table
[entryi
];
3703 format
= format_start
;
3704 for (formati
= 0; formati
< format_count
; formati
++)
3706 dwarf_vma content_type
, form
;
3709 content_type
= read_uleb128 (format
, & bytes_read
, end
);
3710 format
+= bytes_read
;
3711 form
= read_uleb128 (format
, & bytes_read
, end
);
3712 format
+= bytes_read
;
3715 warn (_("Corrupt directories list\n"));
3718 switch (content_type
)
3723 case DW_FORM_string
:
3726 case DW_FORM_line_strp
:
3727 SAFE_BYTE_GET (uvalue
, data
, linfo
.li_offset_size
,
3729 /* Remove const by the cast. */
3730 *pathp
= (unsigned char *)
3731 fetch_indirect_line_string (uvalue
);
3736 data
= read_and_display_attr_value (0, form
, 0, data
, end
,
3738 linfo
.li_offset_size
,
3745 warn (_("Corrupt directories list\n"));
3750 /* Skip files format. */
3751 SAFE_BYTE_GET_AND_INC (format_count
, data
, 1, end
);
3752 format_start
= data
;
3753 for (formati
= 0; formati
< format_count
; formati
++)
3755 read_uleb128 (data
, & bytes_read
, end
);
3757 read_uleb128 (data
, & bytes_read
, end
);
3761 n_files
= read_uleb128 (data
, & bytes_read
, end
);
3765 warn (_("Corrupt file name list\n"));
3769 file_table
= (File_Entry
*) xcalloc (1, n_files
3770 * sizeof (File_Entry
));
3772 for (entryi
= 0; entryi
< n_files
; entryi
++)
3774 File_Entry
*file
= &file_table
[entryi
];
3776 format
= format_start
;
3777 for (formati
= 0; formati
< format_count
; formati
++)
3779 dwarf_vma content_type
, form
;
3782 content_type
= read_uleb128 (format
, & bytes_read
, end
);
3783 format
+= bytes_read
;
3784 form
= read_uleb128 (format
, & bytes_read
, end
);
3785 format
+= bytes_read
;
3788 warn (_("Corrupt file name list\n"));
3791 switch (content_type
)
3796 case DW_FORM_string
:
3799 case DW_FORM_line_strp
:
3800 SAFE_BYTE_GET (uvalue
, data
, linfo
.li_offset_size
,
3802 /* Remove const by the cast. */
3803 file
->name
= (unsigned char *)
3804 fetch_indirect_line_string (uvalue
);
3808 case DW_LNCT_directory_index
:
3812 SAFE_BYTE_GET (file
->directory_index
, data
, 1,
3816 SAFE_BYTE_GET (file
->directory_index
, data
, 2,
3820 file
->directory_index
= read_uleb128 (data
, NULL
,
3826 data
= read_and_display_attr_value (0, form
, 0, data
, end
,
3828 linfo
.li_offset_size
,
3835 warn (_("Corrupt file name list\n"));
3844 unsigned char *ptr_directory_table
= data
;
3846 while (data
< end
&& *data
!= 0)
3848 data
+= strnlen ((char *) data
, end
- data
) + 1;
3855 warn (_("directory table ends unexpectedly\n"));
3860 /* Go through the directory table again to save the directories. */
3861 directory_table
= (unsigned char **)
3862 xmalloc (n_directories
* sizeof (unsigned char *));
3865 while (*ptr_directory_table
!= 0)
3867 directory_table
[i
] = ptr_directory_table
;
3868 ptr_directory_table
+= strnlen ((char *) ptr_directory_table
,
3869 ptr_directory_table
- end
) + 1;
3873 /* Skip the NUL at the end of the table. */
3876 /* Traverse the File Name table just to count the entries. */
3877 if (data
< end
&& *data
!= 0)
3879 unsigned char *ptr_file_name_table
= data
;
3881 while (data
< end
&& *data
!= 0)
3883 unsigned int bytes_read
;
3885 /* Skip Name, directory index, last modification time and length
3887 data
+= strnlen ((char *) data
, end
- data
) + 1;
3888 read_uleb128 (data
, & bytes_read
, end
);
3890 read_uleb128 (data
, & bytes_read
, end
);
3892 read_uleb128 (data
, & bytes_read
, end
);
3900 warn (_("file table ends unexpectedly\n"));
3905 /* Go through the file table again to save the strings. */
3906 file_table
= (File_Entry
*) xmalloc (n_files
* sizeof (File_Entry
));
3909 while (*ptr_file_name_table
!= 0)
3911 unsigned int bytes_read
;
3913 file_table
[i
].name
= ptr_file_name_table
;
3914 ptr_file_name_table
+= strnlen ((char *) ptr_file_name_table
,
3915 end
- ptr_file_name_table
) + 1;
3917 /* We are not interested in directory, time or size. */
3918 file_table
[i
].directory_index
= read_uleb128 (ptr_file_name_table
,
3920 ptr_file_name_table
+= bytes_read
;
3921 file_table
[i
].modification_date
= read_uleb128 (ptr_file_name_table
,
3923 ptr_file_name_table
+= bytes_read
;
3924 file_table
[i
].length
= read_uleb128 (ptr_file_name_table
, & bytes_read
, end
);
3925 ptr_file_name_table
+= bytes_read
;
3931 /* Skip the NUL at the end of the table. */
3935 /* Print the Compilation Unit's name and a header. */
3936 if (file_table
== NULL
)
3938 else if (directory_table
== NULL
)
3939 printf (_("CU: %s:\n"), file_table
[0].name
);
3942 unsigned int ix
= file_table
[0].directory_index
;
3943 const char *directory
;
3948 else if (n_directories
== 0)
3949 directory
= _("<unknown>");
3950 else if (ix
> n_directories
)
3952 warn (_("directory index %u > number of directories %s\n"),
3953 ix
, dwarf_vmatoa ("u", n_directories
));
3954 directory
= _("<corrupt>");
3957 directory
= (char *) directory_table
[ix
- 1];
3959 if (do_wide
|| strlen (directory
) < 76)
3960 printf (_("CU: %s/%s:\n"), directory
, file_table
[0].name
);
3962 printf ("%s:\n", file_table
[0].name
);
3965 printf (_("File name Line number Starting address View\n"));
3966 saved_linfo
= linfo
;
3969 /* This loop iterates through the Dwarf Line Number Program. */
3970 while (data
< end_of_sequence
)
3972 unsigned char op_code
;
3975 unsigned long int uladv
;
3976 unsigned int bytes_read
;
3977 int is_special_opcode
= 0;
3982 if (op_code
>= linfo
.li_opcode_base
)
3984 op_code
-= linfo
.li_opcode_base
;
3985 uladv
= (op_code
/ linfo
.li_line_range
);
3986 if (linfo
.li_max_ops_per_insn
== 1)
3988 uladv
*= linfo
.li_min_insn_length
;
3989 state_machine_regs
.address
+= uladv
;
3991 state_machine_regs
.view
= 0;
3996 = ((state_machine_regs
.op_index
+ uladv
)
3997 / linfo
.li_max_ops_per_insn
)
3998 * linfo
.li_min_insn_length
;
3999 state_machine_regs
.address
4001 state_machine_regs
.op_index
4002 = (state_machine_regs
.op_index
+ uladv
)
4003 % linfo
.li_max_ops_per_insn
;
4005 state_machine_regs
.view
= 0;
4008 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
4009 state_machine_regs
.line
+= adv
;
4010 is_special_opcode
= 1;
4011 /* Increment view after printing this row. */
4013 else switch (op_code
)
4015 case DW_LNS_extended_op
:
4017 unsigned int ext_op_code_len
;
4018 unsigned char ext_op_code
;
4019 unsigned char *op_code_data
= data
;
4021 ext_op_code_len
= read_uleb128 (op_code_data
, &bytes_read
,
4023 op_code_data
+= bytes_read
;
4025 if (ext_op_code_len
== 0)
4027 warn (_("Badly formed extended line op encountered!\n"));
4030 ext_op_code_len
+= bytes_read
;
4031 ext_op_code
= *op_code_data
++;
4035 switch (ext_op_code
)
4037 case DW_LNE_end_sequence
:
4038 /* Reset stuff after printing this row. */
4040 case DW_LNE_set_address
:
4041 SAFE_BYTE_GET_AND_INC (state_machine_regs
.address
,
4043 ext_op_code_len
- bytes_read
- 1,
4045 state_machine_regs
.op_index
= 0;
4046 state_machine_regs
.view
= 0;
4048 case DW_LNE_define_file
:
4050 file_table
= (File_Entry
*) xrealloc
4051 (file_table
, (n_files
+ 1) * sizeof (File_Entry
));
4053 ++state_machine_regs
.last_file_entry
;
4054 /* Source file name. */
4055 file_table
[n_files
].name
= op_code_data
;
4056 op_code_data
+= strlen ((char *) op_code_data
) + 1;
4057 /* Directory index. */
4058 file_table
[n_files
].directory_index
=
4059 read_uleb128 (op_code_data
, & bytes_read
,
4061 op_code_data
+= bytes_read
;
4062 /* Last modification time. */
4063 file_table
[n_files
].modification_date
=
4064 read_uleb128 (op_code_data
, & bytes_read
,
4066 op_code_data
+= bytes_read
;
4068 file_table
[n_files
].length
=
4069 read_uleb128 (op_code_data
, & bytes_read
,
4075 case DW_LNE_set_discriminator
:
4076 case DW_LNE_HP_set_sequence
:
4077 /* Simply ignored. */
4081 printf (_("UNKNOWN (%u): length %d\n"),
4082 ext_op_code
, ext_op_code_len
- bytes_read
);
4085 data
+= ext_op_code_len
;
4089 /* Increment view after printing this row. */
4092 case DW_LNS_advance_pc
:
4093 uladv
= read_uleb128 (data
, & bytes_read
, end
);
4095 if (linfo
.li_max_ops_per_insn
== 1)
4097 uladv
*= linfo
.li_min_insn_length
;
4098 state_machine_regs
.address
+= uladv
;
4100 state_machine_regs
.view
= 0;
4105 = ((state_machine_regs
.op_index
+ uladv
)
4106 / linfo
.li_max_ops_per_insn
)
4107 * linfo
.li_min_insn_length
;
4108 state_machine_regs
.address
4110 state_machine_regs
.op_index
4111 = (state_machine_regs
.op_index
+ uladv
)
4112 % linfo
.li_max_ops_per_insn
;
4114 state_machine_regs
.view
= 0;
4118 case DW_LNS_advance_line
:
4119 adv
= read_sleb128 (data
, & bytes_read
, end
);
4121 state_machine_regs
.line
+= adv
;
4124 case DW_LNS_set_file
:
4125 adv
= read_uleb128 (data
, & bytes_read
, end
);
4127 state_machine_regs
.file
= adv
;
4130 unsigned file
= state_machine_regs
.file
- 1;
4133 if (file_table
== NULL
|| n_files
== 0)
4134 printf (_("\n [Use file table entry %d]\n"), file
);
4136 else if (file
>= n_files
)
4138 warn (_("file index %u > number of files %u\n"), file
+ 1, n_files
);
4139 printf (_("\n <over large file table index %u>"), file
);
4141 else if ((dir
= file_table
[file
].directory_index
) == 0)
4142 /* If directory index is 0, that means current directory. */
4143 printf ("\n./%s:[++]\n", file_table
[file
].name
);
4144 else if (directory_table
== NULL
|| n_directories
== 0)
4145 printf (_("\n [Use file %s in directory table entry %d]\n"),
4146 file_table
[file
].name
, dir
);
4148 else if (dir
> n_directories
)
4150 warn (_("directory index %u > number of directories %s\n"),
4151 dir
, dwarf_vmatoa ("u", n_directories
));
4152 printf (_("\n <over large directory table entry %u>\n"), dir
);
4155 printf ("\n%s/%s:\n",
4156 /* The directory index starts counting at 1. */
4157 directory_table
[dir
- 1], file_table
[file
].name
);
4161 case DW_LNS_set_column
:
4162 uladv
= read_uleb128 (data
, & bytes_read
, end
);
4164 state_machine_regs
.column
= uladv
;
4167 case DW_LNS_negate_stmt
:
4168 adv
= state_machine_regs
.is_stmt
;
4170 state_machine_regs
.is_stmt
= adv
;
4173 case DW_LNS_set_basic_block
:
4174 state_machine_regs
.basic_block
= 1;
4177 case DW_LNS_const_add_pc
:
4178 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
4179 if (linfo
.li_max_ops_per_insn
== 1)
4181 uladv
*= linfo
.li_min_insn_length
;
4182 state_machine_regs
.address
+= uladv
;
4184 state_machine_regs
.view
= 0;
4189 = ((state_machine_regs
.op_index
+ uladv
)
4190 / linfo
.li_max_ops_per_insn
)
4191 * linfo
.li_min_insn_length
;
4192 state_machine_regs
.address
4194 state_machine_regs
.op_index
4195 = (state_machine_regs
.op_index
+ uladv
)
4196 % linfo
.li_max_ops_per_insn
;
4198 state_machine_regs
.view
= 0;
4202 case DW_LNS_fixed_advance_pc
:
4203 SAFE_BYTE_GET_AND_INC (uladv
, data
, 2, end
);
4204 state_machine_regs
.address
+= uladv
;
4205 state_machine_regs
.op_index
= 0;
4206 /* Do NOT reset view. */
4209 case DW_LNS_set_prologue_end
:
4212 case DW_LNS_set_epilogue_begin
:
4215 case DW_LNS_set_isa
:
4216 uladv
= read_uleb128 (data
, & bytes_read
, end
);
4218 printf (_(" Set ISA to %lu\n"), uladv
);
4222 printf (_(" Unknown opcode %d with operands: "), op_code
);
4224 if (standard_opcodes
!= NULL
)
4225 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
4227 printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data
,
4229 i
== 1 ? "" : ", ");
4236 /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row
4237 to the DWARF address/line matrix. */
4238 if ((is_special_opcode
) || (xop
== -DW_LNE_end_sequence
)
4239 || (xop
== DW_LNS_copy
))
4241 const unsigned int MAX_FILENAME_LENGTH
= 35;
4243 char *newFileName
= NULL
;
4244 size_t fileNameLength
;
4248 unsigned indx
= state_machine_regs
.file
- 1;
4250 if (indx
>= n_files
)
4252 warn (_("corrupt file index %u encountered\n"), indx
);
4253 fileName
= _("<corrupt>");
4256 fileName
= (char *) file_table
[indx
].name
;
4259 fileName
= _("<unknown>");
4261 fileNameLength
= strlen (fileName
);
4263 if ((fileNameLength
> MAX_FILENAME_LENGTH
) && (!do_wide
))
4265 newFileName
= (char *) xmalloc (MAX_FILENAME_LENGTH
+ 1);
4266 /* Truncate file name */
4267 strncpy (newFileName
,
4268 fileName
+ fileNameLength
- MAX_FILENAME_LENGTH
,
4269 MAX_FILENAME_LENGTH
+ 1);
4273 newFileName
= (char *) xmalloc (fileNameLength
+ 1);
4274 strncpy (newFileName
, fileName
, fileNameLength
+ 1);
4277 if (!do_wide
|| (fileNameLength
<= MAX_FILENAME_LENGTH
))
4279 if (linfo
.li_max_ops_per_insn
== 1)
4280 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x",
4281 newFileName
, state_machine_regs
.line
,
4282 state_machine_regs
.address
);
4284 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x[%d]",
4285 newFileName
, state_machine_regs
.line
,
4286 state_machine_regs
.address
,
4287 state_machine_regs
.op_index
);
4291 if (linfo
.li_max_ops_per_insn
== 1)
4292 printf ("%s %11d %#18" DWARF_VMA_FMT
"x",
4293 newFileName
, state_machine_regs
.line
,
4294 state_machine_regs
.address
);
4296 printf ("%s %11d %#18" DWARF_VMA_FMT
"x[%d]",
4297 newFileName
, state_machine_regs
.line
,
4298 state_machine_regs
.address
,
4299 state_machine_regs
.op_index
);
4302 if (state_machine_regs
.view
)
4303 printf (" %6u\n", state_machine_regs
.view
);
4306 state_machine_regs
.view
++;
4308 if (xop
== -DW_LNE_end_sequence
)
4310 reset_state_machine (linfo
.li_default_is_stmt
);
4325 if (directory_table
)
4327 free (directory_table
);
4328 directory_table
= NULL
;
4339 display_debug_lines (struct dwarf_section
*section
, void *file
)
4341 unsigned char *data
= section
->start
;
4342 unsigned char *end
= data
+ section
->size
;
4344 int retValDecoded
= 1;
4346 if (do_debug_lines
== 0)
4347 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
4349 if (do_debug_lines
& FLAG_DEBUG_LINES_RAW
)
4350 retValRaw
= display_debug_lines_raw (section
, data
, end
, file
);
4352 if (do_debug_lines
& FLAG_DEBUG_LINES_DECODED
)
4353 retValDecoded
= display_debug_lines_decoded (section
, data
, end
, file
);
4355 if (!retValRaw
|| !retValDecoded
)
4362 find_debug_info_for_offset (unsigned long offset
)
4366 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
4369 for (i
= 0; i
< num_debug_info_entries
; i
++)
4370 if (debug_information
[i
].cu_offset
== offset
)
4371 return debug_information
+ i
;
4377 get_gdb_index_symbol_kind_name (gdb_index_symbol_kind kind
)
4379 /* See gdb/gdb-index.h. */
4380 static const char * const kinds
[] =
4392 return _ (kinds
[kind
]);
4396 display_debug_pubnames_worker (struct dwarf_section
*section
,
4397 void *file ATTRIBUTE_UNUSED
,
4400 DWARF2_Internal_PubNames names
;
4401 unsigned char *start
= section
->start
;
4402 unsigned char *end
= start
+ section
->size
;
4404 /* It does not matter if this load fails,
4405 we test for that later on. */
4406 load_debug_info (file
);
4408 printf (_("Contents of the %s section:\n\n"), section
->name
);
4412 unsigned char *data
;
4415 unsigned int offset_size
, initial_length_size
;
4419 SAFE_BYTE_GET_AND_INC (names
.pn_length
, data
, 4, end
);
4420 if (names
.pn_length
== 0xffffffff)
4422 SAFE_BYTE_GET_AND_INC (names
.pn_length
, data
, 8, end
);
4424 initial_length_size
= 12;
4429 initial_length_size
= 4;
4432 SAFE_BYTE_GET_AND_INC (names
.pn_version
, data
, 2, end
);
4433 SAFE_BYTE_GET_AND_INC (names
.pn_offset
, data
, offset_size
, end
);
4435 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
4436 && num_debug_info_entries
> 0
4437 && find_debug_info_for_offset (names
.pn_offset
) == NULL
)
4438 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
4439 (unsigned long) names
.pn_offset
, section
->name
);
4441 SAFE_BYTE_GET_AND_INC (names
.pn_size
, data
, offset_size
, end
);
4443 adr
= start
+ names
.pn_length
+ initial_length_size
;
4444 /* PR 17531: file: 7615b6b2. */
4445 if ((dwarf_signed_vma
) names
.pn_length
< 0
4446 /* PR 17531: file: a5dbeaa7. */
4449 warn (_("Negative length for public name: 0x%lx\n"), (long) names
.pn_length
);
4455 printf (_(" Length: %ld\n"),
4456 (long) names
.pn_length
);
4457 printf (_(" Version: %d\n"),
4459 printf (_(" Offset into .debug_info section: 0x%lx\n"),
4460 (unsigned long) names
.pn_offset
);
4461 printf (_(" Size of area in .debug_info section: %ld\n"),
4462 (long) names
.pn_size
);
4464 if (names
.pn_version
!= 2 && names
.pn_version
!= 3)
4466 static int warned
= 0;
4470 warn (_("Only DWARF 2 and 3 pubnames are currently supported\n"));
4478 printf (_("\n Offset Kind Name\n"));
4480 printf (_("\n Offset\tName\n"));
4484 bfd_size_type maxprint
;
4486 SAFE_BYTE_GET (offset
, data
, offset_size
, end
);
4490 data
+= offset_size
;
4493 maxprint
= (end
- data
) - 1;
4497 unsigned int kind_data
;
4498 gdb_index_symbol_kind kind
;
4499 const char *kind_name
;
4502 SAFE_BYTE_GET (kind_data
, data
, 1, end
);
4505 /* GCC computes the kind as the upper byte in the CU index
4506 word, and then right shifts it by the CU index size.
4507 Left shift KIND to where the gdb-index.h accessor macros
4509 kind_data
<<= GDB_INDEX_CU_BITSIZE
;
4510 kind
= GDB_INDEX_SYMBOL_KIND_VALUE (kind_data
);
4511 kind_name
= get_gdb_index_symbol_kind_name (kind
);
4512 is_static
= GDB_INDEX_SYMBOL_STATIC_VALUE (kind_data
);
4513 printf (" %-6lx %s,%-10s %.*s\n",
4514 (unsigned long) offset
, is_static
? _("s") : _("g"),
4515 kind_name
, (int) maxprint
, data
);
4518 printf (" %-6lx\t%.*s\n",
4519 (unsigned long) offset
, (int) maxprint
, data
);
4521 data
+= strnlen ((char *) data
, maxprint
) + 1;
4526 while (offset
!= 0);
4534 display_debug_pubnames (struct dwarf_section
*section
, void *file
)
4536 return display_debug_pubnames_worker (section
, file
, 0);
4540 display_debug_gnu_pubnames (struct dwarf_section
*section
, void *file
)
4542 return display_debug_pubnames_worker (section
, file
, 1);
4546 display_debug_macinfo (struct dwarf_section
*section
,
4547 void *file ATTRIBUTE_UNUSED
)
4549 unsigned char *start
= section
->start
;
4550 unsigned char *end
= start
+ section
->size
;
4551 unsigned char *curr
= start
;
4552 unsigned int bytes_read
;
4553 enum dwarf_macinfo_record_type op
;
4555 printf (_("Contents of the %s section:\n\n"), section
->name
);
4559 unsigned int lineno
;
4560 const unsigned char *string
;
4562 op
= (enum dwarf_macinfo_record_type
) *curr
;
4567 case DW_MACINFO_start_file
:
4569 unsigned int filenum
;
4571 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
4573 filenum
= read_uleb128 (curr
, & bytes_read
, end
);
4576 printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"),
4581 case DW_MACINFO_end_file
:
4582 printf (_(" DW_MACINFO_end_file\n"));
4585 case DW_MACINFO_define
:
4586 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
4589 curr
+= strnlen ((char *) string
, end
- string
) + 1;
4590 printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"),
4594 case DW_MACINFO_undef
:
4595 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
4598 curr
+= strnlen ((char *) string
, end
- string
) + 1;
4599 printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"),
4603 case DW_MACINFO_vendor_ext
:
4605 unsigned int constant
;
4607 constant
= read_uleb128 (curr
, & bytes_read
, end
);
4610 curr
+= strnlen ((char *) string
, end
- string
) + 1;
4611 printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"),
4621 /* Given LINE_OFFSET into the .debug_line section, attempt to return
4622 filename and dirname corresponding to file name table entry with index
4623 FILEIDX. Return NULL on failure. */
4625 static unsigned char *
4626 get_line_filename_and_dirname (dwarf_vma line_offset
,
4628 unsigned char **dir_name
)
4630 struct dwarf_section
*section
= &debug_displays
[line
].section
;
4631 unsigned char *hdrptr
, *dirtable
, *file_name
;
4632 unsigned int offset_size
, initial_length_size
;
4633 unsigned int version
, opcode_base
, bytes_read
;
4634 dwarf_vma length
, diridx
;
4635 const unsigned char * end
;
4638 if (section
->start
== NULL
4639 || line_offset
>= section
->size
4643 hdrptr
= section
->start
+ line_offset
;
4644 end
= section
->start
+ section
->size
;
4646 SAFE_BYTE_GET_AND_INC (length
, hdrptr
, 4, end
);
4647 if (length
== 0xffffffff)
4649 /* This section is 64-bit DWARF 3. */
4650 SAFE_BYTE_GET_AND_INC (length
, hdrptr
, 8, end
);
4652 initial_length_size
= 12;
4657 initial_length_size
= 4;
4659 if (length
+ initial_length_size
> section
->size
)
4662 SAFE_BYTE_GET_AND_INC (version
, hdrptr
, 2, end
);
4663 if (version
!= 2 && version
!= 3 && version
!= 4)
4665 hdrptr
+= offset_size
+ 1;/* Skip prologue_length and min_insn_length. */
4667 hdrptr
++; /* Skip max_ops_per_insn. */
4668 hdrptr
+= 3; /* Skip default_is_stmt, line_base, line_range. */
4670 SAFE_BYTE_GET_AND_INC (opcode_base
, hdrptr
, 1, end
);
4671 if (opcode_base
== 0)
4674 hdrptr
+= opcode_base
- 1;
4676 /* Skip over dirname table. */
4677 while (*hdrptr
!= '\0')
4678 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
4679 hdrptr
++; /* Skip the NUL at the end of the table. */
4680 /* Now skip over preceding filename table entries. */
4681 for (; *hdrptr
!= '\0' && fileidx
> 1; fileidx
--)
4683 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
4684 read_uleb128 (hdrptr
, &bytes_read
, end
);
4685 hdrptr
+= bytes_read
;
4686 read_uleb128 (hdrptr
, &bytes_read
, end
);
4687 hdrptr
+= bytes_read
;
4688 read_uleb128 (hdrptr
, &bytes_read
, end
);
4689 hdrptr
+= bytes_read
;
4691 if (hdrptr
== end
|| *hdrptr
== '\0')
4694 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
4695 diridx
= read_uleb128 (hdrptr
, &bytes_read
, end
);
4698 for (; *dirtable
!= '\0' && diridx
> 1; diridx
--)
4699 dirtable
+= strnlen ((char *) dirtable
, end
- dirtable
) + 1;
4700 if (*dirtable
== '\0')
4702 *dir_name
= dirtable
;
4707 display_debug_macro (struct dwarf_section
*section
,
4710 unsigned char *start
= section
->start
;
4711 unsigned char *end
= start
+ section
->size
;
4712 unsigned char *curr
= start
;
4713 unsigned char *extended_op_buf
[256];
4714 unsigned int bytes_read
;
4716 load_debug_section (str
, file
);
4717 load_debug_section (line
, file
);
4719 printf (_("Contents of the %s section:\n\n"), section
->name
);
4723 unsigned int lineno
, version
, flags
;
4724 unsigned int offset_size
= 4;
4725 const unsigned char *string
;
4726 dwarf_vma line_offset
= 0, sec_offset
= curr
- start
, offset
;
4727 unsigned char **extended_ops
= NULL
;
4729 SAFE_BYTE_GET_AND_INC (version
, curr
, 2, end
);
4730 if (version
!= 4 && version
!= 5)
4732 error (_("Only GNU extension to DWARF 4 or 5 of %s is currently supported.\n"),
4737 SAFE_BYTE_GET_AND_INC (flags
, curr
, 1, end
);
4740 printf (_(" Offset: 0x%lx\n"),
4741 (unsigned long) sec_offset
);
4742 printf (_(" Version: %d\n"), version
);
4743 printf (_(" Offset size: %d\n"), offset_size
);
4746 SAFE_BYTE_GET_AND_INC (line_offset
, curr
, offset_size
, end
);
4747 printf (_(" Offset into .debug_line: 0x%lx\n"),
4748 (unsigned long) line_offset
);
4752 unsigned int i
, count
, op
;
4755 SAFE_BYTE_GET_AND_INC (count
, curr
, 1, end
);
4757 memset (extended_op_buf
, 0, sizeof (extended_op_buf
));
4758 extended_ops
= extended_op_buf
;
4761 printf (_(" Extension opcode arguments:\n"));
4762 for (i
= 0; i
< count
; i
++)
4764 SAFE_BYTE_GET_AND_INC (op
, curr
, 1, end
);
4765 extended_ops
[op
] = curr
;
4766 nargs
= read_uleb128 (curr
, &bytes_read
, end
);
4769 printf (_(" DW_MACRO_%02x has no arguments\n"), op
);
4772 printf (_(" DW_MACRO_%02x arguments: "), op
);
4773 for (n
= 0; n
< nargs
; n
++)
4777 SAFE_BYTE_GET_AND_INC (form
, curr
, 1, end
);
4778 printf ("%s%s", get_FORM_name (form
),
4779 n
== nargs
- 1 ? "\n" : ", ");
4789 case DW_FORM_block1
:
4790 case DW_FORM_block2
:
4791 case DW_FORM_block4
:
4793 case DW_FORM_string
:
4795 case DW_FORM_sec_offset
:
4798 error (_("Invalid extension opcode form %s\n"),
4799 get_FORM_name (form
));
4815 error (_(".debug_macro section not zero terminated\n"));
4819 SAFE_BYTE_GET_AND_INC (op
, curr
, 1, end
);
4825 case DW_MACRO_start_file
:
4827 unsigned int filenum
;
4828 unsigned char *file_name
= NULL
, *dir_name
= NULL
;
4830 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4832 filenum
= read_uleb128 (curr
, &bytes_read
, end
);
4835 if ((flags
& 2) == 0)
4836 error (_("DW_MACRO_start_file used, but no .debug_line offset provided.\n"));
4839 = get_line_filename_and_dirname (line_offset
, filenum
,
4841 if (file_name
== NULL
)
4842 printf (_(" DW_MACRO_start_file - lineno: %d filenum: %d\n"),
4845 printf (_(" DW_MACRO_start_file - lineno: %d filenum: %d filename: %s%s%s\n"),
4847 dir_name
!= NULL
? (const char *) dir_name
: "",
4848 dir_name
!= NULL
? "/" : "", file_name
);
4852 case DW_MACRO_end_file
:
4853 printf (_(" DW_MACRO_end_file\n"));
4856 case DW_MACRO_define
:
4857 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4860 curr
+= strnlen ((char *) string
, end
- string
) + 1;
4861 printf (_(" DW_MACRO_define - lineno : %d macro : %s\n"),
4865 case DW_MACRO_undef
:
4866 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4869 curr
+= strnlen ((char *) string
, end
- string
) + 1;
4870 printf (_(" DW_MACRO_undef - lineno : %d macro : %s\n"),
4874 case DW_MACRO_define_strp
:
4875 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4877 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
4878 string
= fetch_indirect_string (offset
);
4879 printf (_(" DW_MACRO_define_strp - lineno : %d macro : %s\n"),
4883 case DW_MACRO_undef_strp
:
4884 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4886 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
4887 string
= fetch_indirect_string (offset
);
4888 printf (_(" DW_MACRO_undef_strp - lineno : %d macro : %s\n"),
4892 case DW_MACRO_import
:
4893 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
4894 printf (_(" DW_MACRO_import - offset : 0x%lx\n"),
4895 (unsigned long) offset
);
4898 case DW_MACRO_define_sup
:
4899 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4901 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
4902 printf (_(" DW_MACRO_define_sup - lineno : %d macro offset : 0x%lx\n"),
4903 lineno
, (unsigned long) offset
);
4906 case DW_MACRO_undef_sup
:
4907 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
4909 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
4910 printf (_(" DW_MACRO_undef_sup - lineno : %d macro offset : 0x%lx\n"),
4911 lineno
, (unsigned long) offset
);
4914 case DW_MACRO_import_sup
:
4915 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
4916 printf (_(" DW_MACRO_import_sup - offset : 0x%lx\n"),
4917 (unsigned long) offset
);
4921 if (extended_ops
== NULL
|| extended_ops
[op
] == NULL
)
4923 error (_(" Unknown macro opcode %02x seen\n"), op
);
4928 /* Skip over unhandled opcodes. */
4930 unsigned char *desc
= extended_ops
[op
];
4931 nargs
= read_uleb128 (desc
, &bytes_read
, end
);
4935 printf (_(" DW_MACRO_%02x\n"), op
);
4938 printf (_(" DW_MACRO_%02x -"), op
);
4939 for (n
= 0; n
< nargs
; n
++)
4943 /* DW_FORM_implicit_const is not expected here. */
4944 SAFE_BYTE_GET_AND_INC (val
, desc
, 1, end
);
4946 = read_and_display_attr_value (0, val
, 0,
4947 curr
, end
, 0, 0, offset_size
,
4948 version
, NULL
, 0, NULL
,
4966 display_debug_abbrev (struct dwarf_section
*section
,
4967 void *file ATTRIBUTE_UNUSED
)
4969 abbrev_entry
*entry
;
4970 unsigned char *start
= section
->start
;
4971 unsigned char *end
= start
+ section
->size
;
4973 printf (_("Contents of the %s section:\n\n"), section
->name
);
4977 unsigned char *last
;
4982 start
= process_abbrev_section (start
, end
);
4984 if (first_abbrev
== NULL
)
4987 printf (_(" Number TAG (0x%lx)\n"), (long) (last
- section
->start
));
4989 for (entry
= first_abbrev
; entry
; entry
= entry
->next
)
4993 printf (" %ld %s [%s]\n",
4995 get_TAG_name (entry
->tag
),
4996 entry
->children
? _("has children") : _("no children"));
4998 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
5000 printf (" %-18s %s",
5001 get_AT_name (attr
->attribute
),
5002 get_FORM_name (attr
->form
));
5003 if (attr
->form
== DW_FORM_implicit_const
)
5004 printf (": %" BFD_VMA_FMT
"d", attr
->implicit_const
);
5016 /* Return true when ADDR is the maximum address, when addresses are
5017 POINTER_SIZE bytes long. */
5020 is_max_address (dwarf_vma addr
, unsigned int pointer_size
)
5022 dwarf_vma mask
= ~(~(dwarf_vma
) 1 << (pointer_size
* 8 - 1));
5023 return ((addr
& mask
) == mask
);
5026 /* Display a location list from a normal (ie, non-dwo) .debug_loc section. */
5029 display_loc_list (struct dwarf_section
*section
,
5030 unsigned char **start_ptr
,
5031 unsigned int debug_info_entry
,
5033 dwarf_vma base_address
,
5036 unsigned char *start
= *start_ptr
;
5037 unsigned char *section_end
= section
->start
+ section
->size
;
5038 unsigned long cu_offset
;
5039 unsigned int pointer_size
;
5040 unsigned int offset_size
;
5045 unsigned short length
;
5046 int need_frame_base
;
5048 if (debug_info_entry
>= num_debug_info_entries
)
5050 warn (_("No debug information available for loc lists of entry: %u\n"),
5055 cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
5056 pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
5057 offset_size
= debug_information
[debug_info_entry
].offset_size
;
5058 dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
5060 if (pointer_size
< 2 || pointer_size
> 8)
5062 warn (_("Invalid pointer size (%d) in debug info for entry %d\n"),
5063 pointer_size
, debug_info_entry
);
5069 dwarf_vma off
= offset
+ (start
- *start_ptr
);
5071 if (start
+ 2 * pointer_size
> section_end
)
5073 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5074 (unsigned long) offset
);
5078 printf (" %8.8lx ", (unsigned long) off
);
5080 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, section_end
);
5081 SAFE_BYTE_GET_AND_INC (end
, start
, pointer_size
, section_end
);
5083 if (begin
== 0 && end
== 0)
5085 /* PR 18374: In a object file we can have a location list that
5086 starts with a begin and end of 0 because there are relocations
5087 that need to be applied to the addresses. Actually applying
5088 the relocations now does not help as they will probably resolve
5089 to 0, since the object file has not been fully linked. Real
5090 end of list markers will not have any relocations against them. */
5091 if (! reloc_at (section
, off
)
5092 && ! reloc_at (section
, off
+ pointer_size
))
5094 printf (_("<End of list>\n"));
5099 /* Check base address specifiers. */
5100 if (is_max_address (begin
, pointer_size
)
5101 && !is_max_address (end
, pointer_size
))
5104 print_dwarf_vma (begin
, pointer_size
);
5105 print_dwarf_vma (end
, pointer_size
);
5106 printf (_("(base address)\n"));
5110 if (start
+ 2 > section_end
)
5112 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5113 (unsigned long) offset
);
5117 SAFE_BYTE_GET_AND_INC (length
, start
, 2, section_end
);
5119 if (start
+ length
> section_end
)
5121 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5122 (unsigned long) offset
);
5126 print_dwarf_vma (begin
+ base_address
, pointer_size
);
5127 print_dwarf_vma (end
+ base_address
, pointer_size
);
5130 need_frame_base
= decode_location_expression (start
,
5135 cu_offset
, section
);
5138 if (need_frame_base
&& !has_frame_base
)
5139 printf (_(" [without DW_AT_frame_base]"));
5142 fputs (_(" (start == end)"), stdout
);
5143 else if (begin
> end
)
5144 fputs (_(" (start > end)"), stdout
);
5154 /* Display a location list from a normal (ie, non-dwo) .debug_loclists section. */
5157 display_loclists_list (struct dwarf_section
*section
,
5158 unsigned char **start_ptr
,
5159 unsigned int debug_info_entry
,
5161 dwarf_vma base_address
,
5164 unsigned char *start
= *start_ptr
;
5165 unsigned char *section_end
= section
->start
+ section
->size
;
5166 unsigned long cu_offset
;
5167 unsigned int pointer_size
;
5168 unsigned int offset_size
;
5170 unsigned int bytes_read
;
5172 /* Initialize it due to a false compiler warning. */
5173 dwarf_vma begin
= -1;
5176 int need_frame_base
;
5178 if (debug_info_entry
>= num_debug_info_entries
)
5180 warn (_("No debug information available for "
5181 "loclists lists of entry: %u\n"),
5186 cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
5187 pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
5188 offset_size
= debug_information
[debug_info_entry
].offset_size
;
5189 dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
5191 if (pointer_size
< 2 || pointer_size
> 8)
5193 warn (_("Invalid pointer size (%d) in debug info for entry %d\n"),
5194 pointer_size
, debug_info_entry
);
5200 dwarf_vma off
= offset
+ (start
- *start_ptr
);
5201 enum dwarf_location_list_entry_type llet
;
5203 if (start
+ 1 > section_end
)
5205 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5206 (unsigned long) offset
);
5210 printf (" %8.8lx ", (unsigned long) off
);
5212 SAFE_BYTE_GET_AND_INC (llet
, start
, 1, section_end
);
5216 case DW_LLE_end_of_list
:
5217 printf (_("<End of list>\n"));
5219 case DW_LLE_offset_pair
:
5220 begin
= read_uleb128 (start
, &bytes_read
, section_end
);
5221 start
+= bytes_read
;
5222 end
= read_uleb128 (start
, &bytes_read
, section_end
);
5223 start
+= bytes_read
;
5225 case DW_LLE_base_address
:
5226 SAFE_BYTE_GET_AND_INC (base_address
, start
, pointer_size
,
5228 print_dwarf_vma (base_address
, pointer_size
);
5229 printf (_("(base address)\n"));
5232 error (_("Invalid location list entry type %d\n"), llet
);
5235 if (llet
== DW_LLE_end_of_list
)
5237 if (llet
!= DW_LLE_offset_pair
)
5240 if (start
+ 2 > section_end
)
5242 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5243 (unsigned long) offset
);
5247 length
= read_uleb128 (start
, &bytes_read
, section_end
);
5248 start
+= bytes_read
;
5250 print_dwarf_vma (begin
+ base_address
, pointer_size
);
5251 print_dwarf_vma (end
+ base_address
, pointer_size
);
5254 need_frame_base
= decode_location_expression (start
,
5259 cu_offset
, section
);
5262 if (need_frame_base
&& !has_frame_base
)
5263 printf (_(" [without DW_AT_frame_base]"));
5266 fputs (_(" (start == end)"), stdout
);
5267 else if (begin
> end
)
5268 fputs (_(" (start > end)"), stdout
);
5278 /* Print a .debug_addr table index in decimal, surrounded by square brackets,
5279 right-adjusted in a field of length LEN, and followed by a space. */
5282 print_addr_index (unsigned int idx
, unsigned int len
)
5284 static char buf
[15];
5285 snprintf (buf
, sizeof (buf
), "[%d]", idx
);
5286 printf ("%*s ", len
, buf
);
5289 /* Display a location list from a .dwo section. It uses address indexes rather
5290 than embedded addresses. This code closely follows display_loc_list, but the
5291 two are sufficiently different that combining things is very ugly. */
5294 display_loc_list_dwo (struct dwarf_section
*section
,
5295 unsigned char **start_ptr
,
5296 unsigned int debug_info_entry
,
5300 unsigned char *start
= *start_ptr
;
5301 unsigned char *section_end
= section
->start
+ section
->size
;
5302 unsigned long cu_offset
;
5303 unsigned int pointer_size
;
5304 unsigned int offset_size
;
5307 unsigned short length
;
5308 int need_frame_base
;
5310 unsigned int bytes_read
;
5312 if (debug_info_entry
>= num_debug_info_entries
)
5314 warn (_("No debug information for loc lists of entry: %u\n"),
5319 cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
5320 pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
5321 offset_size
= debug_information
[debug_info_entry
].offset_size
;
5322 dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
5324 if (pointer_size
< 2 || pointer_size
> 8)
5326 warn (_("Invalid pointer size (%d) in debug info for entry %d\n"),
5327 pointer_size
, debug_info_entry
);
5333 printf (" %8.8lx ", (unsigned long) (offset
+ (start
- *start_ptr
)));
5335 if (start
>= section_end
)
5337 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5338 (unsigned long) offset
);
5342 SAFE_BYTE_GET_AND_INC (entry_type
, start
, 1, section_end
);
5345 case 0: /* A terminating entry. */
5347 printf (_("<End of list>\n"));
5349 case 1: /* A base-address entry. */
5350 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
5351 start
+= bytes_read
;
5352 print_addr_index (idx
, 8);
5354 printf (_("(base address selection entry)\n"));
5356 case 2: /* A start/end entry. */
5357 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
5358 start
+= bytes_read
;
5359 print_addr_index (idx
, 8);
5360 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
5361 start
+= bytes_read
;
5362 print_addr_index (idx
, 8);
5364 case 3: /* A start/length entry. */
5365 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
5366 start
+= bytes_read
;
5367 print_addr_index (idx
, 8);
5368 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
5369 printf ("%08x ", idx
);
5371 case 4: /* An offset pair entry. */
5372 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
5373 printf ("%08x ", idx
);
5374 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
5375 printf ("%08x ", idx
);
5378 warn (_("Unknown location list entry type 0x%x.\n"), entry_type
);
5383 if (start
+ 2 > section_end
)
5385 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5386 (unsigned long) offset
);
5390 SAFE_BYTE_GET_AND_INC (length
, start
, 2, section_end
);
5391 if (start
+ length
> section_end
)
5393 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5394 (unsigned long) offset
);
5399 need_frame_base
= decode_location_expression (start
,
5404 cu_offset
, section
);
5407 if (need_frame_base
&& !has_frame_base
)
5408 printf (_(" [without DW_AT_frame_base]"));
5418 /* Sort array of indexes in ascending order of loc_offsets[idx]. */
5420 static dwarf_vma
*loc_offsets
;
5423 loc_offsets_compar (const void *ap
, const void *bp
)
5425 dwarf_vma a
= loc_offsets
[*(const unsigned int *) ap
];
5426 dwarf_vma b
= loc_offsets
[*(const unsigned int *) bp
];
5428 return (a
> b
) - (b
> a
);
5432 display_debug_loc (struct dwarf_section
*section
, void *file
)
5434 unsigned char *start
= section
->start
;
5435 unsigned long bytes
;
5436 unsigned char *section_begin
= start
;
5437 unsigned int num_loc_list
= 0;
5438 unsigned long last_offset
= 0;
5439 unsigned int first
= 0;
5442 int seen_first_offset
= 0;
5443 int locs_sorted
= 1;
5444 unsigned char *next
;
5445 unsigned int *array
= NULL
;
5446 const char *suffix
= strrchr (section
->name
, '.');
5448 int is_loclists
= strstr (section
->name
, "debug_loclists") != NULL
;
5449 dwarf_vma expected_start
= 0;
5451 if (suffix
&& strcmp (suffix
, ".dwo") == 0)
5454 bytes
= section
->size
;
5458 printf (_("\nThe %s section is empty.\n"), section
->name
);
5464 unsigned char *hdrptr
= section_begin
;
5465 dwarf_vma ll_length
;
5466 unsigned short ll_version
;
5467 unsigned char *end
= section_begin
+ section
->size
;
5468 unsigned char address_size
, segment_selector_size
;
5469 uint32_t offset_entry_count
;
5471 SAFE_BYTE_GET_AND_INC (ll_length
, hdrptr
, 4, end
);
5472 if (ll_length
== 0xffffffff)
5473 SAFE_BYTE_GET_AND_INC (ll_length
, hdrptr
, 8, end
);
5475 SAFE_BYTE_GET_AND_INC (ll_version
, hdrptr
, 2, end
);
5476 if (ll_version
!= 5)
5478 warn (_("The %s section contains corrupt or "
5479 "unsupported version number: %d.\n"),
5480 section
->name
, ll_version
);
5484 SAFE_BYTE_GET_AND_INC (address_size
, hdrptr
, 1, end
);
5486 SAFE_BYTE_GET_AND_INC (segment_selector_size
, hdrptr
, 1, end
);
5487 if (segment_selector_size
!= 0)
5489 warn (_("The %s section contains "
5490 "unsupported segment selector size: %d.\n"),
5491 section
->name
, segment_selector_size
);
5495 SAFE_BYTE_GET_AND_INC (offset_entry_count
, hdrptr
, 4, end
);
5496 if (offset_entry_count
!= 0)
5498 warn (_("The %s section contains "
5499 "unsupported offset entry count: %d.\n"),
5500 section
->name
, offset_entry_count
);
5504 expected_start
= hdrptr
- section_begin
;
5507 if (load_debug_info (file
) == 0)
5509 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
5514 /* Check the order of location list in .debug_info section. If
5515 offsets of location lists are in the ascending order, we can
5516 use `debug_information' directly. */
5517 for (i
= 0; i
< num_debug_info_entries
; i
++)
5521 num
= debug_information
[i
].num_loc_offsets
;
5522 if (num
> num_loc_list
)
5525 /* Check if we can use `debug_information' directly. */
5526 if (locs_sorted
&& num
!= 0)
5528 if (!seen_first_offset
)
5530 /* This is the first location list. */
5531 last_offset
= debug_information
[i
].loc_offsets
[0];
5533 seen_first_offset
= 1;
5539 for (; j
< num
; j
++)
5542 debug_information
[i
].loc_offsets
[j
])
5547 last_offset
= debug_information
[i
].loc_offsets
[j
];
5552 if (!seen_first_offset
)
5553 error (_("No location lists in .debug_info section!\n"));
5555 if (debug_information
[first
].num_loc_offsets
> 0
5556 && debug_information
[first
].loc_offsets
[0] != expected_start
)
5557 warn (_("Location lists in %s section start at 0x%s\n"),
5559 dwarf_vmatoa ("x", debug_information
[first
].loc_offsets
[0]));
5562 array
= (unsigned int *) xcmalloc (num_loc_list
, sizeof (unsigned int));
5563 printf (_("Contents of the %s section:\n\n"), section
->name
);
5564 if (reloc_at (section
, 0))
5565 printf (_(" Warning: This section has relocations - addresses seen here may not be accurate.\n\n"));
5566 printf (_(" Offset Begin End Expression\n"));
5568 seen_first_offset
= 0;
5569 for (i
= first
; i
< num_debug_info_entries
; i
++)
5572 dwarf_vma base_address
;
5578 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
5580 loc_offsets
= debug_information
[i
].loc_offsets
;
5581 qsort (array
, debug_information
[i
].num_loc_offsets
,
5582 sizeof (*array
), loc_offsets_compar
);
5585 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
5587 j
= locs_sorted
? k
: array
[k
];
5589 && debug_information
[i
].loc_offsets
[locs_sorted
5590 ? k
- 1 : array
[k
- 1]]
5591 == debug_information
[i
].loc_offsets
[j
])
5593 has_frame_base
= debug_information
[i
].have_frame_base
[j
];
5594 offset
= debug_information
[i
].loc_offsets
[j
];
5595 next
= section_begin
+ offset
;
5596 base_address
= debug_information
[i
].base_address
;
5598 if (!seen_first_offset
)
5599 seen_first_offset
= 1;
5603 warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"),
5604 (unsigned long) (start
- section_begin
),
5605 (unsigned long) offset
);
5606 else if (start
> next
)
5607 warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"),
5608 (unsigned long) (start
- section_begin
),
5609 (unsigned long) offset
);
5613 if (offset
>= bytes
)
5615 warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"),
5616 (unsigned long) offset
);
5623 display_loc_list_dwo (section
, &start
, i
, offset
,
5626 display_loc_list (section
, &start
, i
, offset
, base_address
,
5632 warn (_("DWO is not yet supported.\n"));
5634 display_loclists_list (section
, &start
, i
, offset
, base_address
,
5640 if (start
< section
->start
+ section
->size
)
5641 warn (_("There are %ld unused bytes at the end of section %s\n"),
5642 (long) (section
->start
+ section
->size
- start
), section
->name
);
5649 display_debug_str (struct dwarf_section
*section
,
5650 void *file ATTRIBUTE_UNUSED
)
5652 unsigned char *start
= section
->start
;
5653 unsigned long bytes
= section
->size
;
5654 dwarf_vma addr
= section
->address
;
5658 printf (_("\nThe %s section is empty.\n"), section
->name
);
5662 printf (_("Contents of the %s section:\n\n"), section
->name
);
5670 lbytes
= (bytes
> 16 ? 16 : bytes
);
5672 printf (" 0x%8.8lx ", (unsigned long) addr
);
5674 for (j
= 0; j
< 16; j
++)
5677 printf ("%2.2x", start
[j
]);
5685 for (j
= 0; j
< lbytes
; j
++)
5688 if (k
>= ' ' && k
< 0x80)
5707 display_debug_info (struct dwarf_section
*section
, void *file
)
5709 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 0);
5713 display_debug_types (struct dwarf_section
*section
, void *file
)
5715 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 1);
5719 display_trace_info (struct dwarf_section
*section
, void *file
)
5721 return process_debug_info (section
, file
, section
->abbrev_sec
, 0, 0);
5725 display_debug_aranges (struct dwarf_section
*section
,
5726 void *file ATTRIBUTE_UNUSED
)
5728 unsigned char *start
= section
->start
;
5729 unsigned char *end
= start
+ section
->size
;
5731 printf (_("Contents of the %s section:\n\n"), section
->name
);
5733 /* It does not matter if this load fails,
5734 we test for that later on. */
5735 load_debug_info (file
);
5739 unsigned char *hdrptr
;
5740 DWARF2_Internal_ARange arange
;
5741 unsigned char *addr_ranges
;
5744 unsigned char address_size
;
5746 unsigned int offset_size
;
5747 unsigned int initial_length_size
;
5751 SAFE_BYTE_GET_AND_INC (arange
.ar_length
, hdrptr
, 4, end
);
5752 if (arange
.ar_length
== 0xffffffff)
5754 SAFE_BYTE_GET_AND_INC (arange
.ar_length
, hdrptr
, 8, end
);
5756 initial_length_size
= 12;
5761 initial_length_size
= 4;
5764 SAFE_BYTE_GET_AND_INC (arange
.ar_version
, hdrptr
, 2, end
);
5765 SAFE_BYTE_GET_AND_INC (arange
.ar_info_offset
, hdrptr
, offset_size
, end
);
5767 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
5768 && num_debug_info_entries
> 0
5769 && find_debug_info_for_offset (arange
.ar_info_offset
) == NULL
)
5770 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
5771 (unsigned long) arange
.ar_info_offset
, section
->name
);
5773 SAFE_BYTE_GET_AND_INC (arange
.ar_pointer_size
, hdrptr
, 1, end
);
5774 SAFE_BYTE_GET_AND_INC (arange
.ar_segment_size
, hdrptr
, 1, end
);
5776 if (arange
.ar_version
!= 2 && arange
.ar_version
!= 3)
5778 /* PR 19872: A version number of 0 probably means that there is
5779 padding at the end of the .debug_aranges section. Gold puts
5780 it there when performing an incremental link, for example.
5781 So do not generate a warning in this case. */
5782 if (arange
.ar_version
)
5783 warn (_("Only DWARF 2 and 3 aranges are currently supported.\n"));
5787 printf (_(" Length: %ld\n"),
5788 (long) arange
.ar_length
);
5789 printf (_(" Version: %d\n"), arange
.ar_version
);
5790 printf (_(" Offset into .debug_info: 0x%lx\n"),
5791 (unsigned long) arange
.ar_info_offset
);
5792 printf (_(" Pointer Size: %d\n"), arange
.ar_pointer_size
);
5793 printf (_(" Segment Size: %d\n"), arange
.ar_segment_size
);
5795 address_size
= arange
.ar_pointer_size
+ arange
.ar_segment_size
;
5797 /* PR 17512: file: 001-108546-0.001:0.1. */
5798 if (address_size
== 0 || address_size
> 8)
5800 error (_("Invalid address size in %s section!\n"),
5805 /* The DWARF spec does not require that the address size be a power
5806 of two, but we do. This will have to change if we ever encounter
5807 an uneven architecture. */
5808 if ((address_size
& (address_size
- 1)) != 0)
5810 warn (_("Pointer size + Segment size is not a power of two.\n"));
5814 if (address_size
> 4)
5815 printf (_("\n Address Length\n"));
5817 printf (_("\n Address Length\n"));
5819 addr_ranges
= hdrptr
;
5821 /* Must pad to an alignment boundary that is twice the address size. */
5822 excess
= (hdrptr
- start
) % (2 * address_size
);
5824 addr_ranges
+= (2 * address_size
) - excess
;
5826 hdrptr
= start
+ arange
.ar_length
+ initial_length_size
;
5827 if (hdrptr
< start
|| hdrptr
> end
)
5829 error (_("Excessive header length: %lx\n"), (long) arange
.ar_length
);
5834 while (addr_ranges
+ 2 * address_size
<= start
)
5836 SAFE_BYTE_GET_AND_INC (address
, addr_ranges
, address_size
, end
);
5837 SAFE_BYTE_GET_AND_INC (length
, addr_ranges
, address_size
, end
);
5840 print_dwarf_vma (address
, address_size
);
5841 print_dwarf_vma (length
, address_size
);
5851 /* Comparison function for qsort. */
5853 comp_addr_base (const void * v0
, const void * v1
)
5855 debug_info
* info0
= (debug_info
*) v0
;
5856 debug_info
* info1
= (debug_info
*) v1
;
5857 return info0
->addr_base
- info1
->addr_base
;
5860 /* Display the debug_addr section. */
5862 display_debug_addr (struct dwarf_section
*section
,
5865 debug_info
**debug_addr_info
;
5866 unsigned char *entry
;
5871 if (section
->size
== 0)
5873 printf (_("\nThe %s section is empty.\n"), section
->name
);
5877 if (load_debug_info (file
) == 0)
5879 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
5884 printf (_("Contents of the %s section:\n\n"), section
->name
);
5886 /* PR 17531: file: cf38d01b.
5887 We use xcalloc because a corrupt file may not have initialised all of the
5888 fields in the debug_info structure, which means that the sort below might
5889 try to move uninitialised data. */
5890 debug_addr_info
= (debug_info
**) xcalloc ((num_debug_info_entries
+ 1),
5891 sizeof (debug_info
*));
5894 for (i
= 0; i
< num_debug_info_entries
; i
++)
5895 if (debug_information
[i
].addr_base
!= DEBUG_INFO_UNAVAILABLE
)
5897 /* PR 17531: file: cf38d01b. */
5898 if (debug_information
[i
].addr_base
>= section
->size
)
5899 warn (_("Corrupt address base (%lx) found in debug section %u\n"),
5900 (unsigned long) debug_information
[i
].addr_base
, i
);
5902 debug_addr_info
[count
++] = debug_information
+ i
;
5905 /* Add a sentinel to make iteration convenient. */
5906 debug_addr_info
[count
] = (debug_info
*) xmalloc (sizeof (debug_info
));
5907 debug_addr_info
[count
]->addr_base
= section
->size
;
5908 qsort (debug_addr_info
, count
, sizeof (debug_info
*), comp_addr_base
);
5910 for (i
= 0; i
< count
; i
++)
5913 unsigned int address_size
= debug_addr_info
[i
]->pointer_size
;
5915 printf (_(" For compilation unit at offset 0x%s:\n"),
5916 dwarf_vmatoa ("x", debug_addr_info
[i
]->cu_offset
));
5918 printf (_("\tIndex\tAddress\n"));
5919 entry
= section
->start
+ debug_addr_info
[i
]->addr_base
;
5920 end
= section
->start
+ debug_addr_info
[i
+ 1]->addr_base
;
5924 dwarf_vma base
= byte_get (entry
, address_size
);
5925 printf (_("\t%d:\t"), idx
);
5926 print_dwarf_vma (base
, address_size
);
5928 entry
+= address_size
;
5934 free (debug_addr_info
);
5938 /* Display the .debug_str_offsets and .debug_str_offsets.dwo sections. */
5940 display_debug_str_offsets (struct dwarf_section
*section
,
5941 void *file ATTRIBUTE_UNUSED
)
5943 if (section
->size
== 0)
5945 printf (_("\nThe %s section is empty.\n"), section
->name
);
5948 /* TODO: Dump the contents. This is made somewhat difficult by not knowing
5949 what the offset size is for this section. */
5953 /* Each debug_information[x].range_lists[y] gets this representation for
5954 sorting purposes. */
5958 /* The debug_information[x].range_lists[y] value. */
5959 dwarf_vma ranges_offset
;
5961 /* Original debug_information to find parameters of the data. */
5962 debug_info
*debug_info_p
;
5965 /* Sort struct range_entry in ascending order of its RANGES_OFFSET. */
5968 range_entry_compar (const void *ap
, const void *bp
)
5970 const struct range_entry
*a_re
= (const struct range_entry
*) ap
;
5971 const struct range_entry
*b_re
= (const struct range_entry
*) bp
;
5972 const dwarf_vma a
= a_re
->ranges_offset
;
5973 const dwarf_vma b
= b_re
->ranges_offset
;
5975 return (a
> b
) - (b
> a
);
5979 display_debug_ranges_list (unsigned char *start
, unsigned char *finish
,
5980 unsigned int pointer_size
, unsigned long offset
,
5981 unsigned long base_address
)
5983 while (start
< finish
)
5988 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, finish
);
5989 if (start
>= finish
)
5991 SAFE_SIGNED_BYTE_GET_AND_INC (end
, start
, pointer_size
, finish
);
5993 printf (" %8.8lx ", offset
);
5995 if (begin
== 0 && end
== 0)
5997 printf (_("<End of list>\n"));
6001 /* Check base address specifiers. */
6002 if (is_max_address (begin
, pointer_size
)
6003 && !is_max_address (end
, pointer_size
))
6006 print_dwarf_vma (begin
, pointer_size
);
6007 print_dwarf_vma (end
, pointer_size
);
6008 printf ("(base address)\n");
6012 print_dwarf_vma (begin
+ base_address
, pointer_size
);
6013 print_dwarf_vma (end
+ base_address
, pointer_size
);
6016 fputs (_("(start == end)"), stdout
);
6017 else if (begin
> end
)
6018 fputs (_("(start > end)"), stdout
);
6025 display_debug_rnglists_list (unsigned char *start
, unsigned char *finish
,
6026 unsigned int pointer_size
, unsigned long offset
,
6027 unsigned long base_address
)
6029 unsigned char *next
= start
;
6033 unsigned long off
= offset
+ (start
- next
);
6034 enum dwarf_range_list_entry rlet
;
6035 /* Initialize it due to a false compiler warning. */
6036 dwarf_vma begin
= -1, length
, end
= -1;
6037 unsigned int bytes_read
;
6039 if (start
+ 1 > finish
)
6041 warn (_("Range list starting at offset 0x%lx is not terminated.\n"),
6046 printf (" %8.8lx ", off
);
6048 SAFE_BYTE_GET_AND_INC (rlet
, start
, 1, finish
);
6052 case DW_RLE_end_of_list
:
6053 printf (_("<End of list>\n"));
6055 case DW_RLE_base_address
:
6056 SAFE_BYTE_GET_AND_INC (base_address
, start
, pointer_size
, finish
);
6057 print_dwarf_vma (base_address
, pointer_size
);
6058 printf (_("(base address)\n"));
6060 case DW_RLE_start_length
:
6061 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, finish
);
6062 length
= read_uleb128 (start
, &bytes_read
, finish
);
6063 start
+= bytes_read
;
6064 end
= begin
+ length
;
6066 case DW_RLE_offset_pair
:
6067 begin
= read_uleb128 (start
, &bytes_read
, finish
);
6068 start
+= bytes_read
;
6069 end
= read_uleb128 (start
, &bytes_read
, finish
);
6070 start
+= bytes_read
;
6072 case DW_RLE_start_end
:
6073 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, finish
);
6074 SAFE_BYTE_GET_AND_INC (end
, start
, pointer_size
, finish
);
6077 error (_("Invalid range list entry type %d\n"), rlet
);
6078 rlet
= DW_RLE_end_of_list
;
6081 if (rlet
== DW_RLE_end_of_list
)
6083 if (rlet
== DW_RLE_base_address
)
6086 print_dwarf_vma (begin
+ base_address
, pointer_size
);
6087 print_dwarf_vma (end
+ base_address
, pointer_size
);
6090 fputs (_("(start == end)"), stdout
);
6091 else if (begin
> end
)
6092 fputs (_("(start > end)"), stdout
);
6099 display_debug_ranges (struct dwarf_section
*section
,
6100 void *file ATTRIBUTE_UNUSED
)
6102 unsigned char *start
= section
->start
;
6103 unsigned char *last_start
= start
;
6104 unsigned long bytes
= section
->size
;
6105 unsigned char *section_begin
= start
;
6106 unsigned char *finish
= start
+ bytes
;
6107 unsigned int num_range_list
, i
;
6108 struct range_entry
*range_entries
, *range_entry_fill
;
6109 int is_rnglists
= strstr (section
->name
, "debug_rnglists") != NULL
;
6110 /* Initialize it due to a false compiler warning. */
6111 unsigned char address_size
= 0;
6115 printf (_("\nThe %s section is empty.\n"), section
->name
);
6121 dwarf_vma initial_length
;
6122 unsigned int initial_length_size
;
6123 unsigned char segment_selector_size
;
6124 unsigned int offset_size
, offset_entry_count
;
6125 unsigned short version
;
6127 /* Get and check the length of the block. */
6128 SAFE_BYTE_GET_AND_INC (initial_length
, start
, 4, finish
);
6130 if (initial_length
== 0xffffffff)
6132 /* This section is 64-bit DWARF 3. */
6133 SAFE_BYTE_GET_AND_INC (initial_length
, start
, 8, finish
);
6135 initial_length_size
= 12;
6140 initial_length_size
= 4;
6143 if (initial_length
+ initial_length_size
> section
->size
)
6145 /* If the length field has a relocation against it, then we should
6146 not complain if it is inaccurate (and probably negative).
6147 It is copied from .debug_line handling code. */
6148 if (reloc_at (section
, (start
- section
->start
) - offset_size
))
6150 initial_length
= (finish
- start
) - initial_length_size
;
6154 warn (_("The length field (0x%lx) in the debug_rnglists header is wrong - the section is too small\n"),
6155 (long) initial_length
);
6160 /* Get and check the version number. */
6161 SAFE_BYTE_GET_AND_INC (version
, start
, 2, finish
);
6165 warn (_("Only DWARF version 5 debug_rnglists info "
6166 "is currently supported.\n"));
6170 SAFE_BYTE_GET_AND_INC (address_size
, start
, 1, finish
);
6172 SAFE_BYTE_GET_AND_INC (segment_selector_size
, start
, 1, finish
);
6173 if (segment_selector_size
!= 0)
6175 warn (_("The %s section contains "
6176 "unsupported segment selector size: %d.\n"),
6177 section
->name
, segment_selector_size
);
6181 SAFE_BYTE_GET_AND_INC (offset_entry_count
, start
, 4, finish
);
6182 if (offset_entry_count
!= 0)
6184 warn (_("The %s section contains "
6185 "unsupported offset entry count: %u.\n"),
6186 section
->name
, offset_entry_count
);
6191 if (load_debug_info (file
) == 0)
6193 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
6199 for (i
= 0; i
< num_debug_info_entries
; i
++)
6200 num_range_list
+= debug_information
[i
].num_range_lists
;
6202 if (num_range_list
== 0)
6204 /* This can happen when the file was compiled with -gsplit-debug
6205 which removes references to range lists from the primary .o file. */
6206 printf (_("No range lists in .debug_info section.\n"));
6210 range_entries
= (struct range_entry
*)
6211 xmalloc (sizeof (*range_entries
) * num_range_list
);
6212 range_entry_fill
= range_entries
;
6214 for (i
= 0; i
< num_debug_info_entries
; i
++)
6216 debug_info
*debug_info_p
= &debug_information
[i
];
6219 for (j
= 0; j
< debug_info_p
->num_range_lists
; j
++)
6221 range_entry_fill
->ranges_offset
= debug_info_p
->range_lists
[j
];
6222 range_entry_fill
->debug_info_p
= debug_info_p
;
6227 qsort (range_entries
, num_range_list
, sizeof (*range_entries
),
6228 range_entry_compar
);
6230 if (dwarf_check
!= 0 && range_entries
[0].ranges_offset
!= 0)
6231 warn (_("Range lists in %s section start at 0x%lx\n"),
6232 section
->name
, (unsigned long) range_entries
[0].ranges_offset
);
6234 printf (_("Contents of the %s section:\n\n"), section
->name
);
6235 printf (_(" Offset Begin End\n"));
6237 for (i
= 0; i
< num_range_list
; i
++)
6239 struct range_entry
*range_entry
= &range_entries
[i
];
6240 debug_info
*debug_info_p
= range_entry
->debug_info_p
;
6241 unsigned int pointer_size
;
6243 unsigned char *next
;
6244 dwarf_vma base_address
;
6246 pointer_size
= (is_rnglists
? address_size
: debug_info_p
->pointer_size
);
6247 offset
= range_entry
->ranges_offset
;
6248 next
= section_begin
+ offset
;
6249 base_address
= debug_info_p
->base_address
;
6251 /* PR 17512: file: 001-101485-0.001:0.1. */
6252 if (pointer_size
< 2 || pointer_size
> 8)
6254 warn (_("Corrupt pointer size (%d) in debug entry at offset %8.8lx\n"),
6255 pointer_size
, (unsigned long) offset
);
6259 if (dwarf_check
!= 0 && i
> 0)
6262 warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"),
6263 (unsigned long) (start
- section_begin
),
6264 (unsigned long) (next
- section_begin
), section
->name
);
6265 else if (start
> next
)
6267 if (next
== last_start
)
6269 warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"),
6270 (unsigned long) (start
- section_begin
),
6271 (unsigned long) (next
- section_begin
), section
->name
);
6277 (is_rnglists
? display_debug_rnglists_list
: display_debug_ranges_list
)
6278 (start
, finish
, pointer_size
, offset
, base_address
);
6282 free (range_entries
);
6287 typedef struct Frame_Chunk
6289 struct Frame_Chunk
*next
;
6290 unsigned char *chunk_start
;
6292 /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
6293 short int *col_type
;
6296 unsigned int code_factor
;
6301 dwarf_vma cfa_offset
;
6303 unsigned char fde_encoding
;
6304 unsigned char cfa_exp
;
6305 unsigned char ptr_size
;
6306 unsigned char segment_size
;
6310 static const char *const *dwarf_regnames
;
6311 static unsigned int dwarf_regnames_count
;
6313 /* A marker for a col_type that means this column was never referenced
6314 in the frame info. */
6315 #define DW_CFA_unreferenced (-1)
6317 /* Return 0 if no more space is needed, 1 if more space is needed,
6318 -1 for invalid reg. */
6321 frame_need_space (Frame_Chunk
*fc
, unsigned int reg
)
6323 unsigned int prev
= fc
->ncols
;
6325 if (reg
< (unsigned int) fc
->ncols
)
6328 if (dwarf_regnames_count
6329 && reg
> dwarf_regnames_count
)
6332 fc
->ncols
= reg
+ 1;
6333 /* PR 17512: file: 10450-2643-0.004.
6334 If reg == -1 then this can happen... */
6338 /* PR 17512: file: 2844a11d. */
6339 if (fc
->ncols
> 1024)
6341 error (_("Unfeasibly large register number: %u\n"), reg
);
6343 /* FIXME: 1024 is an arbitrary limit. Increase it if
6344 we ever encounter a valid binary that exceeds it. */
6348 fc
->col_type
= (short int *) xcrealloc (fc
->col_type
, fc
->ncols
,
6349 sizeof (short int));
6350 fc
->col_offset
= (int *) xcrealloc (fc
->col_offset
, fc
->ncols
, sizeof (int));
6351 /* PR 17512: file:002-10025-0.005. */
6352 if (fc
->col_type
== NULL
|| fc
->col_offset
== NULL
)
6354 error (_("Out of memory allocating %u columns in dwarf frame arrays\n"),
6360 while (prev
< fc
->ncols
)
6362 fc
->col_type
[prev
] = DW_CFA_unreferenced
;
6363 fc
->col_offset
[prev
] = 0;
6369 static const char *const dwarf_regnames_i386
[] =
6371 "eax", "ecx", "edx", "ebx", /* 0 - 3 */
6372 "esp", "ebp", "esi", "edi", /* 4 - 7 */
6373 "eip", "eflags", NULL
, /* 8 - 10 */
6374 "st0", "st1", "st2", "st3", /* 11 - 14 */
6375 "st4", "st5", "st6", "st7", /* 15 - 18 */
6376 NULL
, NULL
, /* 19 - 20 */
6377 "xmm0", "xmm1", "xmm2", "xmm3", /* 21 - 24 */
6378 "xmm4", "xmm5", "xmm6", "xmm7", /* 25 - 28 */
6379 "mm0", "mm1", "mm2", "mm3", /* 29 - 32 */
6380 "mm4", "mm5", "mm6", "mm7", /* 33 - 36 */
6381 "fcw", "fsw", "mxcsr", /* 37 - 39 */
6382 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
, /* 40 - 47 */
6383 "tr", "ldtr", /* 48 - 49 */
6384 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 50 - 57 */
6385 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 58 - 65 */
6386 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 66 - 73 */
6387 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 74 - 81 */
6388 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 82 - 89 */
6389 NULL
, NULL
, NULL
, /* 90 - 92 */
6390 "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7" /* 93 - 100 */
6393 static const char *const dwarf_regnames_iamcu
[] =
6395 "eax", "ecx", "edx", "ebx", /* 0 - 3 */
6396 "esp", "ebp", "esi", "edi", /* 4 - 7 */
6397 "eip", "eflags", NULL
, /* 8 - 10 */
6398 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 11 - 18 */
6399 NULL
, NULL
, /* 19 - 20 */
6400 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 21 - 28 */
6401 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 29 - 36 */
6402 NULL
, NULL
, NULL
, /* 37 - 39 */
6403 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
, /* 40 - 47 */
6404 "tr", "ldtr", /* 48 - 49 */
6405 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 50 - 57 */
6406 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 58 - 65 */
6407 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 66 - 73 */
6408 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 74 - 81 */
6409 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 82 - 89 */
6410 NULL
, NULL
, NULL
, /* 90 - 92 */
6411 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
/* 93 - 100 */
6415 init_dwarf_regnames_i386 (void)
6417 dwarf_regnames
= dwarf_regnames_i386
;
6418 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_i386
);
6422 init_dwarf_regnames_iamcu (void)
6424 dwarf_regnames
= dwarf_regnames_iamcu
;
6425 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_iamcu
);
6428 static const char *const dwarf_regnames_x86_64
[] =
6430 "rax", "rdx", "rcx", "rbx",
6431 "rsi", "rdi", "rbp", "rsp",
6432 "r8", "r9", "r10", "r11",
6433 "r12", "r13", "r14", "r15",
6435 "xmm0", "xmm1", "xmm2", "xmm3",
6436 "xmm4", "xmm5", "xmm6", "xmm7",
6437 "xmm8", "xmm9", "xmm10", "xmm11",
6438 "xmm12", "xmm13", "xmm14", "xmm15",
6439 "st0", "st1", "st2", "st3",
6440 "st4", "st5", "st6", "st7",
6441 "mm0", "mm1", "mm2", "mm3",
6442 "mm4", "mm5", "mm6", "mm7",
6444 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
6445 "fs.base", "gs.base", NULL
, NULL
,
6447 "mxcsr", "fcw", "fsw",
6448 "xmm16", "xmm17", "xmm18", "xmm19",
6449 "xmm20", "xmm21", "xmm22", "xmm23",
6450 "xmm24", "xmm25", "xmm26", "xmm27",
6451 "xmm28", "xmm29", "xmm30", "xmm31",
6452 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 83 - 90 */
6453 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 91 - 98 */
6454 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 99 - 106 */
6455 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 107 - 114 */
6456 NULL
, NULL
, NULL
, /* 115 - 117 */
6457 "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7"
6461 init_dwarf_regnames_x86_64 (void)
6463 dwarf_regnames
= dwarf_regnames_x86_64
;
6464 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_x86_64
);
6467 static const char *const dwarf_regnames_aarch64
[] =
6469 "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7",
6470 "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15",
6471 "x16", "x17", "x18", "x19", "x20", "x21", "x22", "x23",
6472 "x24", "x25", "x26", "x27", "x28", "x29", "x30", "sp",
6473 NULL
, "elr", NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
6474 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
6475 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
6476 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
6477 "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7",
6478 "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15",
6479 "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23",
6480 "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
6484 init_dwarf_regnames_aarch64 (void)
6486 dwarf_regnames
= dwarf_regnames_aarch64
;
6487 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_aarch64
);
6490 static const char *const dwarf_regnames_s390
[] =
6492 /* Avoid saying "r5 (r5)", so omit the names of r0-r15. */
6493 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
6494 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
6495 "f0", "f2", "f4", "f6", "f1", "f3", "f5", "f7",
6496 "f8", "f10", "f12", "f14", "f9", "f11", "f13", "f15",
6497 "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",
6498 "cr8", "cr9", "cr10", "cr11", "cr12", "cr13", "cr14", "cr15",
6499 "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
6500 "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15",
6503 "v16", "v18", "v20", "v22", "v17", "v19", "v21", "v23",
6504 "v24", "v26", "v28", "v30", "v25", "v27", "v29", "v31",
6508 init_dwarf_regnames_s390 (void)
6510 dwarf_regnames
= dwarf_regnames_s390
;
6511 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_s390
);
6515 init_dwarf_regnames (unsigned int e_machine
)
6520 init_dwarf_regnames_i386 ();
6524 init_dwarf_regnames_iamcu ();
6530 init_dwarf_regnames_x86_64 ();
6534 init_dwarf_regnames_aarch64 ();
6538 init_dwarf_regnames_s390 ();
6547 regname (unsigned int regno
, int row
)
6549 static char reg
[64];
6552 && regno
< dwarf_regnames_count
6553 && dwarf_regnames
[regno
] != NULL
)
6556 return dwarf_regnames
[regno
];
6557 snprintf (reg
, sizeof (reg
), "r%d (%s)", regno
,
6558 dwarf_regnames
[regno
]);
6561 snprintf (reg
, sizeof (reg
), "r%d", regno
);
6566 frame_display_row (Frame_Chunk
*fc
, int *need_col_headers
, unsigned int *max_regs
)
6571 if (*max_regs
!= fc
->ncols
)
6572 *max_regs
= fc
->ncols
;
6574 if (*need_col_headers
)
6576 static const char *sloc
= " LOC";
6578 *need_col_headers
= 0;
6580 printf ("%-*s CFA ", eh_addr_size
* 2, sloc
);
6582 for (r
= 0; r
< *max_regs
; r
++)
6583 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
6588 printf ("%-5s ", regname (r
, 1));
6594 print_dwarf_vma (fc
->pc_begin
, eh_addr_size
);
6596 strcpy (tmp
, "exp");
6598 sprintf (tmp
, "%s%+d", regname (fc
->cfa_reg
, 1), (int) fc
->cfa_offset
);
6599 printf ("%-8s ", tmp
);
6601 for (r
= 0; r
< fc
->ncols
; r
++)
6603 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
6605 switch (fc
->col_type
[r
])
6607 case DW_CFA_undefined
:
6610 case DW_CFA_same_value
:
6614 sprintf (tmp
, "c%+d", fc
->col_offset
[r
]);
6616 case DW_CFA_val_offset
:
6617 sprintf (tmp
, "v%+d", fc
->col_offset
[r
]);
6619 case DW_CFA_register
:
6620 sprintf (tmp
, "%s", regname (fc
->col_offset
[r
], 0));
6622 case DW_CFA_expression
:
6623 strcpy (tmp
, "exp");
6625 case DW_CFA_val_expression
:
6626 strcpy (tmp
, "vexp");
6629 strcpy (tmp
, "n/a");
6632 printf ("%-5s ", tmp
);
6638 #define GET(VAR, N) SAFE_BYTE_GET_AND_INC (VAR, start, N, end)
6640 static unsigned char *
6641 read_cie (unsigned char *start
, unsigned char *end
,
6642 Frame_Chunk
**p_cie
, int *p_version
,
6643 unsigned long *p_aug_len
, unsigned char **p_aug
)
6647 unsigned int length_return
;
6648 unsigned char *augmentation_data
= NULL
;
6649 unsigned long augmentation_data_len
= 0;
6652 /* PR 17512: file: 001-228113-0.004. */
6656 fc
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
6657 memset (fc
, 0, sizeof (Frame_Chunk
));
6659 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
6660 fc
->col_offset
= (int *) xmalloc (sizeof (int));
6664 fc
->augmentation
= (char *) start
;
6665 /* PR 17512: file: 001-228113-0.004.
6666 Skip past augmentation name, but avoid running off the end of the data. */
6668 if (* start
++ == '\0')
6672 warn (_("No terminator for augmentation name\n"));
6676 if (strcmp (fc
->augmentation
, "eh") == 0)
6677 start
+= eh_addr_size
;
6681 GET (fc
->ptr_size
, 1);
6682 if (fc
->ptr_size
< 1 || fc
->ptr_size
> 8)
6684 warn (_("Invalid pointer size (%d) in CIE data\n"), fc
->ptr_size
);
6688 GET (fc
->segment_size
, 1);
6689 /* PR 17512: file: e99d2804. */
6690 if (fc
->segment_size
> 8 || fc
->segment_size
+ fc
->ptr_size
> 8)
6692 warn (_("Invalid segment size (%d) in CIE data\n"), fc
->segment_size
);
6696 eh_addr_size
= fc
->ptr_size
;
6700 fc
->ptr_size
= eh_addr_size
;
6701 fc
->segment_size
= 0;
6703 READ_ULEB (fc
->code_factor
);
6704 READ_SLEB (fc
->data_factor
);
6714 if (fc
->augmentation
[0] == 'z')
6716 READ_ULEB (augmentation_data_len
);
6717 augmentation_data
= start
;
6718 start
+= augmentation_data_len
;
6719 /* PR 17512: file: 11042-2589-0.004. */
6722 warn (_("Augmentation data too long: %#lx, expected at most %#lx\n"),
6723 augmentation_data_len
, (long)((end
- start
) + augmentation_data_len
));
6728 if (augmentation_data_len
)
6732 unsigned char *qend
;
6734 p
= (unsigned char *) fc
->augmentation
+ 1;
6735 q
= augmentation_data
;
6736 qend
= q
+ augmentation_data_len
;
6738 /* PR 17531: file: 015adfaa. */
6741 warn (_("Negative augmentation data length: 0x%lx"), augmentation_data_len
);
6742 augmentation_data_len
= 0;
6745 while (p
< end
&& q
< augmentation_data
+ augmentation_data_len
)
6750 q
+= 1 + size_of_encoded_value (*q
);
6752 fc
->fde_encoding
= *q
++;
6759 /* Note - it is OK if this loop terminates with q < qend.
6760 Padding may have been inserted to align the end of the CIE. */
6765 *p_version
= version
;
6768 *p_aug_len
= augmentation_data_len
;
6769 *p_aug
= augmentation_data
;
6775 display_debug_frames (struct dwarf_section
*section
,
6776 void *file ATTRIBUTE_UNUSED
)
6778 unsigned char *start
= section
->start
;
6779 unsigned char *end
= start
+ section
->size
;
6780 unsigned char *section_start
= start
;
6781 Frame_Chunk
*chunks
= 0, *forward_refs
= 0;
6782 Frame_Chunk
*remembered_state
= 0;
6784 int is_eh
= strcmp (section
->name
, ".eh_frame") == 0;
6785 unsigned int length_return
;
6786 unsigned int max_regs
= 0;
6787 const char *bad_reg
= _("bad register: ");
6788 unsigned int saved_eh_addr_size
= eh_addr_size
;
6790 printf (_("Contents of the %s section:\n"), section
->name
);
6794 unsigned char *saved_start
;
6795 unsigned char *block_end
;
6800 int need_col_headers
= 1;
6801 unsigned char *augmentation_data
= NULL
;
6802 unsigned long augmentation_data_len
= 0;
6803 unsigned int encoded_ptr_size
= saved_eh_addr_size
;
6804 unsigned int offset_size
;
6805 unsigned int initial_length_size
;
6806 bfd_boolean all_nops
;
6808 saved_start
= start
;
6810 SAFE_BYTE_GET_AND_INC (length
, start
, 4, end
);
6814 printf ("\n%08lx ZERO terminator\n\n",
6815 (unsigned long)(saved_start
- section_start
));
6816 /* Skip any zero terminators that directly follow.
6817 A corrupt section size could have loaded a whole
6818 slew of zero filled memory bytes. eg
6819 PR 17512: file: 070-19381-0.004. */
6820 while (start
< end
&& * start
== 0)
6825 if (length
== 0xffffffff)
6827 SAFE_BYTE_GET_AND_INC (length
, start
, 8, end
);
6829 initial_length_size
= 12;
6834 initial_length_size
= 4;
6837 block_end
= saved_start
+ length
+ initial_length_size
;
6838 if (block_end
> end
|| block_end
< start
)
6840 warn ("Invalid length 0x%s in FDE at %#08lx\n",
6841 dwarf_vmatoa_1 (NULL
, length
, offset_size
),
6842 (unsigned long) (saved_start
- section_start
));
6846 SAFE_BYTE_GET_AND_INC (cie_id
, start
, offset_size
, end
);
6848 if (is_eh
? (cie_id
== 0) : ((offset_size
== 4 && cie_id
== DW_CIE_ID
)
6849 || (offset_size
== 8 && cie_id
== DW64_CIE_ID
)))
6854 start
= read_cie (start
, end
, &cie
, &version
,
6855 &augmentation_data_len
, &augmentation_data
);
6856 /* PR 17512: file: 027-135133-0.005. */
6863 fc
->chunk_start
= saved_start
;
6864 mreg
= max_regs
> 0 ? max_regs
- 1 : 0;
6867 if (frame_need_space (fc
, mreg
) < 0)
6869 if (fc
->fde_encoding
)
6870 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
6872 printf ("\n%08lx ", (unsigned long) (saved_start
- section_start
));
6873 print_dwarf_vma (length
, fc
->ptr_size
);
6874 print_dwarf_vma (cie_id
, offset_size
);
6876 if (do_debug_frames_interp
)
6878 printf ("CIE \"%s\" cf=%d df=%d ra=%d\n", fc
->augmentation
,
6879 fc
->code_factor
, fc
->data_factor
, fc
->ra
);
6884 printf (" Version: %d\n", version
);
6885 printf (" Augmentation: \"%s\"\n", fc
->augmentation
);
6888 printf (" Pointer Size: %u\n", fc
->ptr_size
);
6889 printf (" Segment Size: %u\n", fc
->segment_size
);
6891 printf (" Code alignment factor: %u\n", fc
->code_factor
);
6892 printf (" Data alignment factor: %d\n", fc
->data_factor
);
6893 printf (" Return address column: %d\n", fc
->ra
);
6895 if (augmentation_data_len
)
6899 printf (" Augmentation data: ");
6900 for (i
= 0; i
< augmentation_data_len
; ++i
)
6901 /* FIXME: If do_wide is FALSE, then we should
6902 add carriage returns at 80 columns... */
6903 printf (" %02x", augmentation_data
[i
]);
6911 unsigned char *look_for
;
6912 static Frame_Chunk fde_fc
;
6913 unsigned long segment_selector
;
6917 dwarf_vma sign
= (dwarf_vma
) 1 << (offset_size
* 8 - 1);
6918 look_for
= start
- 4 - ((cie_id
^ sign
) - sign
);
6921 look_for
= section_start
+ cie_id
;
6923 if (look_for
<= saved_start
)
6925 for (cie
= chunks
; cie
; cie
= cie
->next
)
6926 if (cie
->chunk_start
== look_for
)
6931 for (cie
= forward_refs
; cie
; cie
= cie
->next
)
6932 if (cie
->chunk_start
== look_for
)
6936 unsigned int off_size
;
6937 unsigned char *cie_scan
;
6939 cie_scan
= look_for
;
6941 SAFE_BYTE_GET_AND_INC (length
, cie_scan
, 4, end
);
6942 if (length
== 0xffffffff)
6944 SAFE_BYTE_GET_AND_INC (length
, cie_scan
, 8, end
);
6951 SAFE_BYTE_GET_AND_INC (c_id
, cie_scan
, off_size
, end
);
6954 : ((off_size
== 4 && c_id
== DW_CIE_ID
)
6955 || (off_size
== 8 && c_id
== DW64_CIE_ID
)))
6960 read_cie (cie_scan
, end
, &cie
, &version
,
6961 &augmentation_data_len
, &augmentation_data
);
6962 /* PR 17512: file: 3450-2098-0.004. */
6965 warn (_("Failed to read CIE information\n"));
6968 cie
->next
= forward_refs
;
6970 cie
->chunk_start
= look_for
;
6971 mreg
= max_regs
> 0 ? max_regs
- 1 : 0;
6974 if (frame_need_space (cie
, mreg
) < 0)
6976 warn (_("Invalid max register\n"));
6979 if (cie
->fde_encoding
)
6981 = size_of_encoded_value (cie
->fde_encoding
);
6988 memset (fc
, 0, sizeof (Frame_Chunk
));
6992 warn ("Invalid CIE pointer 0x%s in FDE at %#08lx\n",
6993 dwarf_vmatoa_1 (NULL
, cie_id
, offset_size
),
6994 (unsigned long) (saved_start
- section_start
));
6996 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
6997 fc
->col_offset
= (int *) xmalloc (sizeof (int));
6998 if (frame_need_space (fc
, max_regs
> 0 ? max_regs
- 1 : 0) < 0)
7000 warn (_("Invalid max register\n"));
7004 fc
->augmentation
= "";
7005 fc
->fde_encoding
= 0;
7006 fc
->ptr_size
= eh_addr_size
;
7007 fc
->segment_size
= 0;
7011 fc
->ncols
= cie
->ncols
;
7012 fc
->col_type
= (short int *) xcmalloc (fc
->ncols
, sizeof (short int));
7013 fc
->col_offset
= (int *) xcmalloc (fc
->ncols
, sizeof (int));
7014 memcpy (fc
->col_type
, cie
->col_type
, fc
->ncols
* sizeof (short int));
7015 memcpy (fc
->col_offset
, cie
->col_offset
, fc
->ncols
* sizeof (int));
7016 fc
->augmentation
= cie
->augmentation
;
7017 fc
->ptr_size
= cie
->ptr_size
;
7018 eh_addr_size
= cie
->ptr_size
;
7019 fc
->segment_size
= cie
->segment_size
;
7020 fc
->code_factor
= cie
->code_factor
;
7021 fc
->data_factor
= cie
->data_factor
;
7022 fc
->cfa_reg
= cie
->cfa_reg
;
7023 fc
->cfa_offset
= cie
->cfa_offset
;
7025 if (frame_need_space (fc
, max_regs
> 0 ? max_regs
- 1: 0) < 0)
7027 warn (_("Invalid max register\n"));
7030 fc
->fde_encoding
= cie
->fde_encoding
;
7033 if (fc
->fde_encoding
)
7034 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
7036 segment_selector
= 0;
7037 if (fc
->segment_size
)
7039 if (fc
->segment_size
> sizeof (segment_selector
))
7041 /* PR 17512: file: 9e196b3e. */
7042 warn (_("Probably corrupt segment size: %d - using 4 instead\n"), fc
->segment_size
);
7043 fc
->segment_size
= 4;
7045 SAFE_BYTE_GET_AND_INC (segment_selector
, start
, fc
->segment_size
, end
);
7048 fc
->pc_begin
= get_encoded_value (&start
, fc
->fde_encoding
, section
, end
);
7050 /* FIXME: It appears that sometimes the final pc_range value is
7051 encoded in less than encoded_ptr_size bytes. See the x86_64
7052 run of the "objcopy on compressed debug sections" test for an
7054 SAFE_BYTE_GET_AND_INC (fc
->pc_range
, start
, encoded_ptr_size
, end
);
7056 if (cie
->augmentation
[0] == 'z')
7058 READ_ULEB (augmentation_data_len
);
7059 augmentation_data
= start
;
7060 start
+= augmentation_data_len
;
7061 /* PR 17512: file: 722-8446-0.004. */
7062 if (start
>= end
|| ((signed long) augmentation_data_len
) < 0)
7064 warn (_("Corrupt augmentation data length: %lx\n"),
7065 augmentation_data_len
);
7067 augmentation_data
= NULL
;
7068 augmentation_data_len
= 0;
7072 printf ("\n%08lx %s %s FDE cie=%08lx pc=",
7073 (unsigned long)(saved_start
- section_start
),
7074 dwarf_vmatoa_1 (NULL
, length
, fc
->ptr_size
),
7075 dwarf_vmatoa_1 (NULL
, cie_id
, offset_size
),
7076 (unsigned long)(cie
->chunk_start
- section_start
));
7078 if (fc
->segment_size
)
7079 printf ("%04lx:", segment_selector
);
7082 dwarf_vmatoa_1 (NULL
, fc
->pc_begin
, fc
->ptr_size
),
7083 dwarf_vmatoa_1 (NULL
, fc
->pc_begin
+ fc
->pc_range
, fc
->ptr_size
));
7085 if (! do_debug_frames_interp
&& augmentation_data_len
)
7089 printf (" Augmentation data: ");
7090 for (i
= 0; i
< augmentation_data_len
; ++i
)
7091 printf (" %02x", augmentation_data
[i
]);
7097 /* At this point, fc is the current chunk, cie (if any) is set, and
7098 we're about to interpret instructions for the chunk. */
7099 /* ??? At present we need to do this always, since this sizes the
7100 fc->col_type and fc->col_offset arrays, which we write into always.
7101 We should probably split the interpreted and non-interpreted bits
7102 into two different routines, since there's so much that doesn't
7103 really overlap between them. */
7104 if (1 || do_debug_frames_interp
)
7106 /* Start by making a pass over the chunk, allocating storage
7107 and taking note of what registers are used. */
7108 unsigned char *tmp
= start
;
7110 while (start
< block_end
)
7112 unsigned int reg
, op
, opa
;
7114 unsigned char * new_start
;
7121 /* Warning: if you add any more cases to this switch, be
7122 sure to add them to the corresponding switch below. */
7125 case DW_CFA_advance_loc
:
7129 if (frame_need_space (fc
, opa
) >= 0)
7130 fc
->col_type
[opa
] = DW_CFA_undefined
;
7132 case DW_CFA_restore
:
7133 if (frame_need_space (fc
, opa
) >= 0)
7134 fc
->col_type
[opa
] = DW_CFA_undefined
;
7136 case DW_CFA_set_loc
:
7137 start
+= encoded_ptr_size
;
7139 case DW_CFA_advance_loc1
:
7142 case DW_CFA_advance_loc2
:
7145 case DW_CFA_advance_loc4
:
7148 case DW_CFA_offset_extended
:
7149 case DW_CFA_val_offset
:
7152 if (frame_need_space (fc
, reg
) >= 0)
7153 fc
->col_type
[reg
] = DW_CFA_undefined
;
7155 case DW_CFA_restore_extended
:
7157 if (frame_need_space (fc
, reg
) >= 0)
7158 fc
->col_type
[reg
] = DW_CFA_undefined
;
7160 case DW_CFA_undefined
:
7162 if (frame_need_space (fc
, reg
) >= 0)
7163 fc
->col_type
[reg
] = DW_CFA_undefined
;
7165 case DW_CFA_same_value
:
7167 if (frame_need_space (fc
, reg
) >= 0)
7168 fc
->col_type
[reg
] = DW_CFA_undefined
;
7170 case DW_CFA_register
:
7173 if (frame_need_space (fc
, reg
) >= 0)
7174 fc
->col_type
[reg
] = DW_CFA_undefined
;
7176 case DW_CFA_def_cfa
:
7180 case DW_CFA_def_cfa_register
:
7183 case DW_CFA_def_cfa_offset
:
7186 case DW_CFA_def_cfa_expression
:
7188 new_start
= start
+ temp
;
7189 if (new_start
< start
)
7191 warn (_("Corrupt CFA_def expression value: %lu\n"), temp
);
7197 case DW_CFA_expression
:
7198 case DW_CFA_val_expression
:
7201 new_start
= start
+ temp
;
7202 if (new_start
< start
)
7204 /* PR 17512: file:306-192417-0.005. */
7205 warn (_("Corrupt CFA expression value: %lu\n"), temp
);
7210 if (frame_need_space (fc
, reg
) >= 0)
7211 fc
->col_type
[reg
] = DW_CFA_undefined
;
7213 case DW_CFA_offset_extended_sf
:
7214 case DW_CFA_val_offset_sf
:
7217 if (frame_need_space (fc
, reg
) >= 0)
7218 fc
->col_type
[reg
] = DW_CFA_undefined
;
7220 case DW_CFA_def_cfa_sf
:
7224 case DW_CFA_def_cfa_offset_sf
:
7227 case DW_CFA_MIPS_advance_loc8
:
7230 case DW_CFA_GNU_args_size
:
7233 case DW_CFA_GNU_negative_offset_extended
:
7236 if (frame_need_space (fc
, reg
) >= 0)
7237 fc
->col_type
[reg
] = DW_CFA_undefined
;
7248 /* Now we know what registers are used, make a second pass over
7249 the chunk, this time actually printing out the info. */
7251 while (start
< block_end
)
7253 unsigned char * tmp
;
7255 unsigned long ul
, roffs
;
7256 /* Note: It is tempting to use an unsigned long for 'reg' but there
7257 are various functions, notably frame_space_needed() that assume that
7258 reg is an unsigned int. */
7263 const char *reg_prefix
= "";
7270 /* Make a note if something other than DW_CFA_nop happens. */
7271 if (op
!= DW_CFA_nop
)
7274 /* Warning: if you add any more cases to this switch, be
7275 sure to add them to the corresponding switch above. */
7278 case DW_CFA_advance_loc
:
7279 if (do_debug_frames_interp
)
7280 frame_display_row (fc
, &need_col_headers
, &max_regs
);
7282 printf (" DW_CFA_advance_loc: %d to %s\n",
7283 opa
* fc
->code_factor
,
7284 dwarf_vmatoa_1 (NULL
,
7285 fc
->pc_begin
+ opa
* fc
->code_factor
,
7287 fc
->pc_begin
+= opa
* fc
->code_factor
;
7292 if (opa
>= (unsigned int) fc
->ncols
)
7293 reg_prefix
= bad_reg
;
7294 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7295 printf (" DW_CFA_offset: %s%s at cfa%+ld\n",
7296 reg_prefix
, regname (opa
, 0),
7297 roffs
* fc
->data_factor
);
7298 if (*reg_prefix
== '\0')
7300 fc
->col_type
[opa
] = DW_CFA_offset
;
7301 fc
->col_offset
[opa
] = roffs
* fc
->data_factor
;
7305 case DW_CFA_restore
:
7306 if (opa
>= (unsigned int) fc
->ncols
)
7307 reg_prefix
= bad_reg
;
7308 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7309 printf (" DW_CFA_restore: %s%s\n",
7310 reg_prefix
, regname (opa
, 0));
7311 if (*reg_prefix
!= '\0')
7314 if (opa
>= (unsigned int) cie
->ncols
7315 || (do_debug_frames_interp
7316 && cie
->col_type
[opa
] == DW_CFA_unreferenced
))
7318 fc
->col_type
[opa
] = DW_CFA_undefined
;
7319 fc
->col_offset
[opa
] = 0;
7323 fc
->col_type
[opa
] = cie
->col_type
[opa
];
7324 fc
->col_offset
[opa
] = cie
->col_offset
[opa
];
7328 case DW_CFA_set_loc
:
7329 vma
= get_encoded_value (&start
, fc
->fde_encoding
, section
, block_end
);
7330 if (do_debug_frames_interp
)
7331 frame_display_row (fc
, &need_col_headers
, &max_regs
);
7333 printf (" DW_CFA_set_loc: %s\n",
7334 dwarf_vmatoa_1 (NULL
, vma
, fc
->ptr_size
));
7338 case DW_CFA_advance_loc1
:
7339 SAFE_BYTE_GET_AND_INC (ofs
, start
, 1, end
);
7340 if (do_debug_frames_interp
)
7341 frame_display_row (fc
, &need_col_headers
, &max_regs
);
7343 printf (" DW_CFA_advance_loc1: %ld to %s\n",
7344 (unsigned long) (ofs
* fc
->code_factor
),
7345 dwarf_vmatoa_1 (NULL
,
7346 fc
->pc_begin
+ ofs
* fc
->code_factor
,
7348 fc
->pc_begin
+= ofs
* fc
->code_factor
;
7351 case DW_CFA_advance_loc2
:
7352 SAFE_BYTE_GET_AND_INC (ofs
, start
, 2, block_end
);
7353 if (do_debug_frames_interp
)
7354 frame_display_row (fc
, &need_col_headers
, &max_regs
);
7356 printf (" DW_CFA_advance_loc2: %ld to %s\n",
7357 (unsigned long) (ofs
* fc
->code_factor
),
7358 dwarf_vmatoa_1 (NULL
,
7359 fc
->pc_begin
+ ofs
* fc
->code_factor
,
7361 fc
->pc_begin
+= ofs
* fc
->code_factor
;
7364 case DW_CFA_advance_loc4
:
7365 SAFE_BYTE_GET_AND_INC (ofs
, start
, 4, block_end
);
7366 if (do_debug_frames_interp
)
7367 frame_display_row (fc
, &need_col_headers
, &max_regs
);
7369 printf (" DW_CFA_advance_loc4: %ld to %s\n",
7370 (unsigned long) (ofs
* fc
->code_factor
),
7371 dwarf_vmatoa_1 (NULL
,
7372 fc
->pc_begin
+ ofs
* fc
->code_factor
,
7374 fc
->pc_begin
+= ofs
* fc
->code_factor
;
7377 case DW_CFA_offset_extended
:
7380 if (reg
>= (unsigned int) fc
->ncols
)
7381 reg_prefix
= bad_reg
;
7382 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7383 printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n",
7384 reg_prefix
, regname (reg
, 0),
7385 roffs
* fc
->data_factor
);
7386 if (*reg_prefix
== '\0')
7388 fc
->col_type
[reg
] = DW_CFA_offset
;
7389 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
7393 case DW_CFA_val_offset
:
7396 if (reg
>= (unsigned int) fc
->ncols
)
7397 reg_prefix
= bad_reg
;
7398 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7399 printf (" DW_CFA_val_offset: %s%s is cfa%+ld\n",
7400 reg_prefix
, regname (reg
, 0),
7401 roffs
* fc
->data_factor
);
7402 if (*reg_prefix
== '\0')
7404 fc
->col_type
[reg
] = DW_CFA_val_offset
;
7405 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
7409 case DW_CFA_restore_extended
:
7411 if (reg
>= (unsigned int) fc
->ncols
)
7412 reg_prefix
= bad_reg
;
7413 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7414 printf (" DW_CFA_restore_extended: %s%s\n",
7415 reg_prefix
, regname (reg
, 0));
7416 if (*reg_prefix
!= '\0')
7419 if (reg
>= (unsigned int) cie
->ncols
)
7421 fc
->col_type
[reg
] = DW_CFA_undefined
;
7422 fc
->col_offset
[reg
] = 0;
7426 fc
->col_type
[reg
] = cie
->col_type
[reg
];
7427 fc
->col_offset
[reg
] = cie
->col_offset
[reg
];
7431 case DW_CFA_undefined
:
7433 if (reg
>= (unsigned int) fc
->ncols
)
7434 reg_prefix
= bad_reg
;
7435 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7436 printf (" DW_CFA_undefined: %s%s\n",
7437 reg_prefix
, regname (reg
, 0));
7438 if (*reg_prefix
== '\0')
7440 fc
->col_type
[reg
] = DW_CFA_undefined
;
7441 fc
->col_offset
[reg
] = 0;
7445 case DW_CFA_same_value
:
7447 if (reg
>= (unsigned int) fc
->ncols
)
7448 reg_prefix
= bad_reg
;
7449 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7450 printf (" DW_CFA_same_value: %s%s\n",
7451 reg_prefix
, regname (reg
, 0));
7452 if (*reg_prefix
== '\0')
7454 fc
->col_type
[reg
] = DW_CFA_same_value
;
7455 fc
->col_offset
[reg
] = 0;
7459 case DW_CFA_register
:
7462 if (reg
>= (unsigned int) fc
->ncols
)
7463 reg_prefix
= bad_reg
;
7464 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7466 printf (" DW_CFA_register: %s%s in ",
7467 reg_prefix
, regname (reg
, 0));
7468 puts (regname (roffs
, 0));
7470 if (*reg_prefix
== '\0')
7472 fc
->col_type
[reg
] = DW_CFA_register
;
7473 fc
->col_offset
[reg
] = roffs
;
7477 case DW_CFA_remember_state
:
7478 if (! do_debug_frames_interp
)
7479 printf (" DW_CFA_remember_state\n");
7480 rs
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
7481 rs
->cfa_offset
= fc
->cfa_offset
;
7482 rs
->cfa_reg
= fc
->cfa_reg
;
7484 rs
->cfa_exp
= fc
->cfa_exp
;
7485 rs
->ncols
= fc
->ncols
;
7486 rs
->col_type
= (short int *) xcmalloc (rs
->ncols
,
7487 sizeof (* rs
->col_type
));
7488 rs
->col_offset
= (int *) xcmalloc (rs
->ncols
, sizeof (* rs
->col_offset
));
7489 memcpy (rs
->col_type
, fc
->col_type
, rs
->ncols
* sizeof (* fc
->col_type
));
7490 memcpy (rs
->col_offset
, fc
->col_offset
, rs
->ncols
* sizeof (* fc
->col_offset
));
7491 rs
->next
= remembered_state
;
7492 remembered_state
= rs
;
7495 case DW_CFA_restore_state
:
7496 if (! do_debug_frames_interp
)
7497 printf (" DW_CFA_restore_state\n");
7498 rs
= remembered_state
;
7501 remembered_state
= rs
->next
;
7502 fc
->cfa_offset
= rs
->cfa_offset
;
7503 fc
->cfa_reg
= rs
->cfa_reg
;
7505 fc
->cfa_exp
= rs
->cfa_exp
;
7506 if (frame_need_space (fc
, rs
->ncols
- 1) < 0)
7508 warn (_("Invalid column number in saved frame state\n"));
7512 memcpy (fc
->col_type
, rs
->col_type
, rs
->ncols
* sizeof (* rs
->col_type
));
7513 memcpy (fc
->col_offset
, rs
->col_offset
,
7514 rs
->ncols
* sizeof (* rs
->col_offset
));
7515 free (rs
->col_type
);
7516 free (rs
->col_offset
);
7519 else if (do_debug_frames_interp
)
7520 printf ("Mismatched DW_CFA_restore_state\n");
7523 case DW_CFA_def_cfa
:
7524 READ_SLEB (fc
->cfa_reg
);
7525 READ_ULEB (fc
->cfa_offset
);
7527 if (! do_debug_frames_interp
)
7528 printf (" DW_CFA_def_cfa: %s ofs %d\n",
7529 regname (fc
->cfa_reg
, 0), (int) fc
->cfa_offset
);
7532 case DW_CFA_def_cfa_register
:
7533 READ_SLEB (fc
->cfa_reg
);
7535 if (! do_debug_frames_interp
)
7536 printf (" DW_CFA_def_cfa_register: %s\n",
7537 regname (fc
->cfa_reg
, 0));
7540 case DW_CFA_def_cfa_offset
:
7541 READ_ULEB (fc
->cfa_offset
);
7542 if (! do_debug_frames_interp
)
7543 printf (" DW_CFA_def_cfa_offset: %d\n", (int) fc
->cfa_offset
);
7547 if (! do_debug_frames_interp
)
7548 printf (" DW_CFA_nop\n");
7551 case DW_CFA_def_cfa_expression
:
7553 if (start
>= block_end
|| ul
> (unsigned long) (block_end
- start
))
7555 printf (_(" DW_CFA_def_cfa_expression: <corrupt len %lu>\n"), ul
);
7558 if (! do_debug_frames_interp
)
7560 printf (" DW_CFA_def_cfa_expression (");
7561 decode_location_expression (start
, eh_addr_size
, 0, -1,
7569 case DW_CFA_expression
:
7572 if (reg
>= (unsigned int) fc
->ncols
)
7573 reg_prefix
= bad_reg
;
7574 /* PR 17512: file: 069-133014-0.006. */
7575 /* PR 17512: file: 98c02eb4. */
7577 if (start
>= block_end
|| tmp
> block_end
|| tmp
< start
)
7579 printf (_(" DW_CFA_expression: <corrupt len %lu>\n"), ul
);
7582 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7584 printf (" DW_CFA_expression: %s%s (",
7585 reg_prefix
, regname (reg
, 0));
7586 decode_location_expression (start
, eh_addr_size
, 0, -1,
7590 if (*reg_prefix
== '\0')
7591 fc
->col_type
[reg
] = DW_CFA_expression
;
7595 case DW_CFA_val_expression
:
7598 if (reg
>= (unsigned int) fc
->ncols
)
7599 reg_prefix
= bad_reg
;
7601 if (start
>= block_end
|| tmp
> block_end
|| tmp
< start
)
7603 printf (" DW_CFA_val_expression: <corrupt len %lu>\n", ul
);
7606 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7608 printf (" DW_CFA_val_expression: %s%s (",
7609 reg_prefix
, regname (reg
, 0));
7610 decode_location_expression (start
, eh_addr_size
, 0, -1,
7614 if (*reg_prefix
== '\0')
7615 fc
->col_type
[reg
] = DW_CFA_val_expression
;
7619 case DW_CFA_offset_extended_sf
:
7622 if (frame_need_space (fc
, reg
) < 0)
7623 reg_prefix
= bad_reg
;
7624 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7625 printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n",
7626 reg_prefix
, regname (reg
, 0),
7627 (long)(l
* fc
->data_factor
));
7628 if (*reg_prefix
== '\0')
7630 fc
->col_type
[reg
] = DW_CFA_offset
;
7631 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
7635 case DW_CFA_val_offset_sf
:
7638 if (frame_need_space (fc
, reg
) < 0)
7639 reg_prefix
= bad_reg
;
7640 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7641 printf (" DW_CFA_val_offset_sf: %s%s is cfa%+ld\n",
7642 reg_prefix
, regname (reg
, 0),
7643 (long)(l
* fc
->data_factor
));
7644 if (*reg_prefix
== '\0')
7646 fc
->col_type
[reg
] = DW_CFA_val_offset
;
7647 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
7651 case DW_CFA_def_cfa_sf
:
7652 READ_SLEB (fc
->cfa_reg
);
7653 READ_ULEB (fc
->cfa_offset
);
7654 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
7656 if (! do_debug_frames_interp
)
7657 printf (" DW_CFA_def_cfa_sf: %s ofs %d\n",
7658 regname (fc
->cfa_reg
, 0), (int) fc
->cfa_offset
);
7661 case DW_CFA_def_cfa_offset_sf
:
7662 READ_ULEB (fc
->cfa_offset
);
7663 fc
->cfa_offset
*= fc
->data_factor
;
7664 if (! do_debug_frames_interp
)
7665 printf (" DW_CFA_def_cfa_offset_sf: %d\n", (int) fc
->cfa_offset
);
7668 case DW_CFA_MIPS_advance_loc8
:
7669 SAFE_BYTE_GET_AND_INC (ofs
, start
, 8, block_end
);
7670 if (do_debug_frames_interp
)
7671 frame_display_row (fc
, &need_col_headers
, &max_regs
);
7673 printf (" DW_CFA_MIPS_advance_loc8: %ld to %s\n",
7674 (unsigned long) (ofs
* fc
->code_factor
),
7675 dwarf_vmatoa_1 (NULL
,
7676 fc
->pc_begin
+ ofs
* fc
->code_factor
,
7678 fc
->pc_begin
+= ofs
* fc
->code_factor
;
7681 case DW_CFA_GNU_window_save
:
7682 if (! do_debug_frames_interp
)
7683 printf (" DW_CFA_GNU_window_save\n");
7686 case DW_CFA_GNU_args_size
:
7688 if (! do_debug_frames_interp
)
7689 printf (" DW_CFA_GNU_args_size: %ld\n", ul
);
7692 case DW_CFA_GNU_negative_offset_extended
:
7696 if (frame_need_space (fc
, reg
) < 0)
7697 reg_prefix
= bad_reg
;
7698 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
7699 printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n",
7700 reg_prefix
, regname (reg
, 0),
7701 (long)(l
* fc
->data_factor
));
7702 if (*reg_prefix
== '\0')
7704 fc
->col_type
[reg
] = DW_CFA_offset
;
7705 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
7710 if (op
>= DW_CFA_lo_user
&& op
<= DW_CFA_hi_user
)
7711 printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op
);
7713 warn (_("Unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op
);
7718 /* Interpret the CFA - as long as it is not completely full of NOPs. */
7719 if (do_debug_frames_interp
&& ! all_nops
)
7720 frame_display_row (fc
, &need_col_headers
, &max_regs
);
7723 eh_addr_size
= saved_eh_addr_size
;
7734 display_debug_names (struct dwarf_section
*section
, void *file
)
7736 unsigned char *hdrptr
= section
->start
;
7737 dwarf_vma unit_length
;
7738 unsigned char *unit_start
;
7739 const unsigned char *const section_end
= section
->start
+ section
->size
;
7740 unsigned char *unit_end
;
7742 printf (_("Contents of the %s section:\n"), section
->name
);
7744 load_debug_section (str
, file
);
7746 for (; hdrptr
< section_end
; hdrptr
= unit_end
)
7748 unsigned int offset_size
;
7749 uint16_t dwarf_version
, padding
;
7750 uint32_t comp_unit_count
, local_type_unit_count
, foreign_type_unit_count
;
7751 uint32_t bucket_count
, name_count
, abbrev_table_size
;
7752 uint32_t augmentation_string_size
;
7755 unit_start
= hdrptr
;
7757 /* Get and check the length of the block. */
7758 SAFE_BYTE_GET_AND_INC (unit_length
, hdrptr
, 4, section_end
);
7760 if (unit_length
== 0xffffffff)
7762 /* This section is 64-bit DWARF. */
7763 SAFE_BYTE_GET_AND_INC (unit_length
, hdrptr
, 8, section_end
);
7768 unit_end
= hdrptr
+ unit_length
;
7770 if ((hdrptr
- section
->start
) + unit_length
> section
->size
)
7772 warn (_("The length field (0x%lx) for unit 0x%lx in the debug_names "
7773 "header is wrong - the section is too small\n"),
7774 (long) unit_length
, (long) (unit_start
- section
->start
));
7778 /* Get and check the version number. */
7779 SAFE_BYTE_GET_AND_INC (dwarf_version
, hdrptr
, 2, unit_end
);
7780 printf (_("Version %ld\n"), (long) dwarf_version
);
7782 /* Prior versions did not exist, and future versions may not be
7783 backwards compatible. */
7784 if (dwarf_version
!= 5)
7786 warn (_("Only DWARF version 5 .debug_names "
7787 "is currently supported.\n"));
7791 SAFE_BYTE_GET_AND_INC (padding
, hdrptr
, 2, unit_end
);
7793 warn (_("Padding field of .debug_names must be 0 (found 0x%x)\n"),
7796 SAFE_BYTE_GET_AND_INC (comp_unit_count
, hdrptr
, 4, unit_end
);
7797 if (comp_unit_count
== 0)
7798 warn (_("Compilation unit count must be >= 1 in .debug_names\n"));
7800 SAFE_BYTE_GET_AND_INC (local_type_unit_count
, hdrptr
, 4, unit_end
);
7801 SAFE_BYTE_GET_AND_INC (foreign_type_unit_count
, hdrptr
, 4, unit_end
);
7802 SAFE_BYTE_GET_AND_INC (bucket_count
, hdrptr
, 4, unit_end
);
7803 SAFE_BYTE_GET_AND_INC (name_count
, hdrptr
, 4, unit_end
);
7804 SAFE_BYTE_GET_AND_INC (abbrev_table_size
, hdrptr
, 4, unit_end
);
7806 SAFE_BYTE_GET_AND_INC (augmentation_string_size
, hdrptr
, 4, unit_end
);
7807 if (augmentation_string_size
% 4 != 0)
7809 warn (_("Augmentation string length %u must be rounded up "
7810 "to a multiple of 4 in .debug_names.\n"),
7811 augmentation_string_size
);
7812 augmentation_string_size
+= (-augmentation_string_size
) & 3;
7814 printf (_("Augmentation string:"));
7815 for (i
= 0; i
< augmentation_string_size
; i
++)
7819 SAFE_BYTE_GET_AND_INC (uc
, hdrptr
, 1, unit_end
);
7820 printf (" %02x", uc
);
7825 printf (_("CU table:\n"));
7826 for (i
= 0; i
< comp_unit_count
; i
++)
7830 SAFE_BYTE_GET_AND_INC (cu_offset
, hdrptr
, offset_size
, unit_end
);
7831 printf (_("[%3u] 0x%lx\n"), i
, (unsigned long) cu_offset
);
7835 printf (_("TU table:\n"));
7836 for (i
= 0; i
< local_type_unit_count
; i
++)
7840 SAFE_BYTE_GET_AND_INC (tu_offset
, hdrptr
, offset_size
, unit_end
);
7841 printf (_("[%3u] 0x%lx\n"), i
, (unsigned long) tu_offset
);
7845 printf (_("Foreign TU table:\n"));
7846 for (i
= 0; i
< foreign_type_unit_count
; i
++)
7850 SAFE_BYTE_GET_AND_INC (signature
, hdrptr
, 8, unit_end
);
7851 printf (_("[%3u] "), i
);
7852 print_dwarf_vma (signature
, 8);
7857 const uint32_t *const hash_table_buckets
= (uint32_t *) hdrptr
;
7858 hdrptr
+= bucket_count
* sizeof (uint32_t);
7859 const uint32_t *const hash_table_hashes
= (uint32_t *) hdrptr
;
7860 hdrptr
+= name_count
* sizeof (uint32_t);
7861 unsigned char *const name_table_string_offsets
= hdrptr
;
7862 hdrptr
+= name_count
* offset_size
;
7863 unsigned char *const name_table_entry_offsets
= hdrptr
;
7864 hdrptr
+= name_count
* offset_size
;
7865 unsigned char *const abbrev_table
= hdrptr
;
7866 hdrptr
+= abbrev_table_size
;
7867 const unsigned char *const abbrev_table_end
= hdrptr
;
7868 unsigned char *const entry_pool
= hdrptr
;
7869 if (hdrptr
> unit_end
)
7871 warn (_("Entry pool offset (0x%lx) exceeds unit size 0x%lx "
7872 "for unit 0x%lx in the debug_names\n"),
7873 (long) (hdrptr
- section
->start
),
7874 (long) (unit_end
- section
->start
),
7875 (long) (unit_start
- section
->start
));
7879 size_t buckets_filled
= 0;
7881 for (bucketi
= 0; bucketi
< bucket_count
; bucketi
++)
7883 const uint32_t bucket
= hash_table_buckets
[bucketi
];
7888 printf (_("Used %zu of %lu buckets.\n"), buckets_filled
,
7889 (unsigned long) bucket_count
);
7891 uint32_t hash_prev
= 0;
7892 size_t hash_clash_count
= 0;
7893 size_t longest_clash
= 0;
7894 size_t this_length
= 0;
7896 for (hashi
= 0; hashi
< name_count
; hashi
++)
7898 const uint32_t hash_this
= hash_table_hashes
[hashi
];
7902 if (hash_prev
% bucket_count
== hash_this
% bucket_count
)
7906 longest_clash
= MAX (longest_clash
, this_length
);
7911 hash_prev
= hash_this
;
7913 printf (_("Out of %lu items there are %zu bucket clashes"
7914 " (longest of %zu entries).\n"),
7915 (unsigned long) name_count
, hash_clash_count
, longest_clash
);
7916 assert (name_count
== buckets_filled
+ hash_clash_count
);
7918 struct abbrev_lookup_entry
7920 dwarf_vma abbrev_tag
;
7921 unsigned char *abbrev_lookup_ptr
;
7923 struct abbrev_lookup_entry
*abbrev_lookup
= NULL
;
7924 size_t abbrev_lookup_used
= 0;
7925 size_t abbrev_lookup_allocated
= 0;
7927 unsigned char *abbrevptr
= abbrev_table
;
7930 unsigned int bytes_read
;
7931 const dwarf_vma abbrev_tag
= read_uleb128 (abbrevptr
, &bytes_read
,
7933 abbrevptr
+= bytes_read
;
7934 if (abbrev_tag
== 0)
7936 if (abbrev_lookup_used
== abbrev_lookup_allocated
)
7938 abbrev_lookup_allocated
= MAX (0x100,
7939 abbrev_lookup_allocated
* 2);
7940 abbrev_lookup
= xrealloc (abbrev_lookup
,
7941 (abbrev_lookup_allocated
7942 * sizeof (*abbrev_lookup
)));
7944 assert (abbrev_lookup_used
< abbrev_lookup_allocated
);
7945 struct abbrev_lookup_entry
*entry
;
7946 for (entry
= abbrev_lookup
;
7947 entry
< abbrev_lookup
+ abbrev_lookup_used
;
7949 if (entry
->abbrev_tag
== abbrev_tag
)
7951 warn (_("Duplicate abbreviation tag %lu "
7952 "in unit 0x%lx in the debug_names\n"),
7953 (long) abbrev_tag
, (long) (unit_start
- section
->start
));
7956 entry
= &abbrev_lookup
[abbrev_lookup_used
++];
7957 entry
->abbrev_tag
= abbrev_tag
;
7958 entry
->abbrev_lookup_ptr
= abbrevptr
;
7960 /* Skip DWARF tag. */
7961 read_uleb128 (abbrevptr
, &bytes_read
, abbrev_table_end
);
7962 abbrevptr
+= bytes_read
;
7965 const dwarf_vma xindex
= read_uleb128 (abbrevptr
,
7968 abbrevptr
+= bytes_read
;
7969 const dwarf_vma form
= read_uleb128 (abbrevptr
, &bytes_read
,
7971 abbrevptr
+= bytes_read
;
7972 if (xindex
== 0 && form
== 0)
7977 printf (_("\nSymbol table:\n"));
7979 for (namei
= 0; namei
< name_count
; ++namei
)
7981 uint64_t string_offset
, entry_offset
;
7983 SAFE_BYTE_GET (string_offset
,
7984 name_table_string_offsets
+ namei
* offset_size
,
7985 offset_size
, unit_end
);
7986 SAFE_BYTE_GET (entry_offset
,
7987 name_table_entry_offsets
+ namei
* offset_size
,
7988 offset_size
, unit_end
);
7990 printf ("[%3u] #%08x %s:", namei
, hash_table_hashes
[namei
],
7991 fetch_indirect_string (string_offset
));
7993 unsigned char *entryptr
= entry_pool
+ entry_offset
;
7995 // We need to scan first whether there is a single or multiple
7996 // entries. TAGNO is -2 for the first entry, it is -1 for the
7997 // initial tag read of the second entry, then it becomes 0 for the
7998 // first entry for real printing etc.
8000 /* Initialize it due to a false compiler warning. */
8001 dwarf_vma second_abbrev_tag
= -1;
8004 unsigned int bytes_read
;
8005 const dwarf_vma abbrev_tag
= read_uleb128 (entryptr
, &bytes_read
,
8007 entryptr
+= bytes_read
;
8010 second_abbrev_tag
= abbrev_tag
;
8012 entryptr
= entry_pool
+ entry_offset
;
8015 if (abbrev_tag
== 0)
8019 (tagno
== 0 && second_abbrev_tag
== 0 ? " " : "\n\t"),
8020 (unsigned long) abbrev_tag
);
8022 const struct abbrev_lookup_entry
*entry
;
8023 for (entry
= abbrev_lookup
;
8024 entry
< abbrev_lookup
+ abbrev_lookup_used
;
8026 if (entry
->abbrev_tag
== abbrev_tag
)
8028 if (entry
>= abbrev_lookup
+ abbrev_lookup_used
)
8030 warn (_("Undefined abbreviation tag %lu "
8031 "in unit 0x%lx in the debug_names\n"),
8033 (long) (unit_start
- section
->start
));
8036 abbrevptr
= entry
->abbrev_lookup_ptr
;
8037 const dwarf_vma dwarf_tag
= read_uleb128 (abbrevptr
, &bytes_read
,
8039 abbrevptr
+= bytes_read
;
8041 printf (" %s", get_TAG_name (dwarf_tag
));
8044 const dwarf_vma xindex
= read_uleb128 (abbrevptr
,
8047 abbrevptr
+= bytes_read
;
8048 const dwarf_vma form
= read_uleb128 (abbrevptr
, &bytes_read
,
8050 abbrevptr
+= bytes_read
;
8051 if (xindex
== 0 && form
== 0)
8055 printf (" %s", get_IDX_name (xindex
));
8056 entryptr
= read_and_display_attr_value (0, form
, 0, entryptr
,
8059 dwarf_version
, NULL
,
8066 printf (_(" <no entries>"));
8070 free (abbrev_lookup
);
8077 display_gdb_index (struct dwarf_section
*section
,
8078 void *file ATTRIBUTE_UNUSED
)
8080 unsigned char *start
= section
->start
;
8082 uint32_t cu_list_offset
, tu_list_offset
;
8083 uint32_t address_table_offset
, symbol_table_offset
, constant_pool_offset
;
8084 unsigned int cu_list_elements
, tu_list_elements
;
8085 unsigned int address_table_size
, symbol_table_slots
;
8086 unsigned char *cu_list
, *tu_list
;
8087 unsigned char *address_table
, *symbol_table
, *constant_pool
;
8090 /* The documentation for the format of this file is in gdb/dwarf2read.c. */
8092 printf (_("Contents of the %s section:\n"), section
->name
);
8094 if (section
->size
< 6 * sizeof (uint32_t))
8096 warn (_("Truncated header in the %s section.\n"), section
->name
);
8100 version
= byte_get_little_endian (start
, 4);
8101 printf (_("Version %ld\n"), (long) version
);
8103 /* Prior versions are obsolete, and future versions may not be
8104 backwards compatible. */
8105 if (version
< 3 || version
> 8)
8107 warn (_("Unsupported version %lu.\n"), (unsigned long) version
);
8111 warn (_("The address table data in version 3 may be wrong.\n"));
8113 warn (_("Version 4 does not support case insensitive lookups.\n"));
8115 warn (_("Version 5 does not include inlined functions.\n"));
8117 warn (_("Version 6 does not include symbol attributes.\n"));
8118 /* Version 7 indices generated by Gold have bad type unit references,
8119 PR binutils/15021. But we don't know if the index was generated by
8120 Gold or not, so to avoid worrying users with gdb-generated indices
8121 we say nothing for version 7 here. */
8123 cu_list_offset
= byte_get_little_endian (start
+ 4, 4);
8124 tu_list_offset
= byte_get_little_endian (start
+ 8, 4);
8125 address_table_offset
= byte_get_little_endian (start
+ 12, 4);
8126 symbol_table_offset
= byte_get_little_endian (start
+ 16, 4);
8127 constant_pool_offset
= byte_get_little_endian (start
+ 20, 4);
8129 if (cu_list_offset
> section
->size
8130 || tu_list_offset
> section
->size
8131 || address_table_offset
> section
->size
8132 || symbol_table_offset
> section
->size
8133 || constant_pool_offset
> section
->size
)
8135 warn (_("Corrupt header in the %s section.\n"), section
->name
);
8139 /* PR 17531: file: 418d0a8a. */
8140 if (tu_list_offset
< cu_list_offset
)
8142 warn (_("TU offset (%x) is less than CU offset (%x)\n"),
8143 tu_list_offset
, cu_list_offset
);
8147 cu_list_elements
= (tu_list_offset
- cu_list_offset
) / 8;
8149 if (address_table_offset
< tu_list_offset
)
8151 warn (_("Address table offset (%x) is less than TU offset (%x)\n"),
8152 address_table_offset
, tu_list_offset
);
8156 tu_list_elements
= (address_table_offset
- tu_list_offset
) / 8;
8158 /* PR 17531: file: 18a47d3d. */
8159 if (symbol_table_offset
< address_table_offset
)
8161 warn (_("Symbol table offset (%x) is less then Address table offset (%x)\n"),
8162 symbol_table_offset
, address_table_offset
);
8166 address_table_size
= symbol_table_offset
- address_table_offset
;
8168 if (constant_pool_offset
< symbol_table_offset
)
8170 warn (_("Constant pool offset (%x) is less than symbol table offset (%x)\n"),
8171 constant_pool_offset
, symbol_table_offset
);
8175 symbol_table_slots
= (constant_pool_offset
- symbol_table_offset
) / 8;
8177 cu_list
= start
+ cu_list_offset
;
8178 tu_list
= start
+ tu_list_offset
;
8179 address_table
= start
+ address_table_offset
;
8180 symbol_table
= start
+ symbol_table_offset
;
8181 constant_pool
= start
+ constant_pool_offset
;
8183 if (address_table
+ address_table_size
> section
->start
+ section
->size
)
8185 warn (_("Address table extends beyond end of section.\n"));
8189 printf (_("\nCU table:\n"));
8190 for (i
= 0; i
< cu_list_elements
; i
+= 2)
8192 uint64_t cu_offset
= byte_get_little_endian (cu_list
+ i
* 8, 8);
8193 uint64_t cu_length
= byte_get_little_endian (cu_list
+ i
* 8 + 8, 8);
8195 printf (_("[%3u] 0x%lx - 0x%lx\n"), i
/ 2,
8196 (unsigned long) cu_offset
,
8197 (unsigned long) (cu_offset
+ cu_length
- 1));
8200 printf (_("\nTU table:\n"));
8201 for (i
= 0; i
< tu_list_elements
; i
+= 3)
8203 uint64_t tu_offset
= byte_get_little_endian (tu_list
+ i
* 8, 8);
8204 uint64_t type_offset
= byte_get_little_endian (tu_list
+ i
* 8 + 8, 8);
8205 uint64_t signature
= byte_get_little_endian (tu_list
+ i
* 8 + 16, 8);
8207 printf (_("[%3u] 0x%lx 0x%lx "), i
/ 3,
8208 (unsigned long) tu_offset
,
8209 (unsigned long) type_offset
);
8210 print_dwarf_vma (signature
, 8);
8214 printf (_("\nAddress table:\n"));
8215 for (i
= 0; i
< address_table_size
&& i
<= address_table_size
- (2 * 8 + 4);
8218 uint64_t low
= byte_get_little_endian (address_table
+ i
, 8);
8219 uint64_t high
= byte_get_little_endian (address_table
+ i
+ 8, 8);
8220 uint32_t cu_index
= byte_get_little_endian (address_table
+ i
+ 16, 4);
8222 print_dwarf_vma (low
, 8);
8223 print_dwarf_vma (high
, 8);
8224 printf (_("%lu\n"), (unsigned long) cu_index
);
8227 printf (_("\nSymbol table:\n"));
8228 for (i
= 0; i
< symbol_table_slots
; ++i
)
8230 uint32_t name_offset
= byte_get_little_endian (symbol_table
+ i
* 8, 4);
8231 uint32_t cu_vector_offset
= byte_get_little_endian (symbol_table
+ i
* 8 + 4, 4);
8232 uint32_t num_cus
, cu
;
8234 if (name_offset
!= 0
8235 || cu_vector_offset
!= 0)
8238 unsigned char * adr
;
8240 adr
= constant_pool
+ name_offset
;
8241 /* PR 17531: file: 5b7b07ad. */
8242 if (adr
< constant_pool
|| adr
>= section
->start
+ section
->size
)
8244 printf (_("[%3u] <corrupt offset: %x>"), i
, name_offset
);
8245 warn (_("Corrupt name offset of 0x%x found for symbol table slot %d\n"),
8249 printf ("[%3u] %.*s:", i
,
8250 (int) (section
->size
- (constant_pool_offset
+ name_offset
)),
8251 constant_pool
+ name_offset
);
8253 adr
= constant_pool
+ cu_vector_offset
;
8254 if (adr
< constant_pool
|| adr
>= section
->start
+ section
->size
- 3)
8256 printf (_("<invalid CU vector offset: %x>\n"), cu_vector_offset
);
8257 warn (_("Corrupt CU vector offset of 0x%x found for symbol table slot %d\n"),
8258 cu_vector_offset
, i
);
8262 num_cus
= byte_get_little_endian (adr
, 4);
8264 adr
= constant_pool
+ cu_vector_offset
+ 4 + num_cus
* 4;
8265 if (num_cus
* 4 < num_cus
8266 || adr
>= section
->start
+ section
->size
8267 || adr
< constant_pool
)
8269 printf ("<invalid number of CUs: %d>\n", num_cus
);
8270 warn (_("Invalid number of CUs (0x%x) for symbol table slot %d\n"),
8278 for (j
= 0; j
< num_cus
; ++j
)
8281 gdb_index_symbol_kind kind
;
8283 cu
= byte_get_little_endian (constant_pool
+ cu_vector_offset
+ 4 + j
* 4, 4);
8284 is_static
= GDB_INDEX_SYMBOL_STATIC_VALUE (cu
);
8285 kind
= GDB_INDEX_SYMBOL_KIND_VALUE (cu
);
8286 cu
= GDB_INDEX_CU_VALUE (cu
);
8287 /* Convert to TU number if it's for a type unit. */
8288 if (cu
>= cu_list_elements
/ 2)
8289 printf ("%cT%lu", num_cus
> 1 ? '\t' : ' ',
8290 (unsigned long) (cu
- cu_list_elements
/ 2));
8292 printf ("%c%lu", num_cus
> 1 ? '\t' : ' ', (unsigned long) cu
);
8294 printf (" [%s, %s]",
8295 is_static
? _("static") : _("global"),
8296 get_gdb_index_symbol_kind_name (kind
));
8308 /* Pre-allocate enough space for the CU/TU sets needed. */
8311 prealloc_cu_tu_list (unsigned int nshndx
)
8313 if (shndx_pool
== NULL
)
8315 shndx_pool_size
= nshndx
;
8316 shndx_pool_used
= 0;
8317 shndx_pool
= (unsigned int *) xcmalloc (shndx_pool_size
,
8318 sizeof (unsigned int));
8322 shndx_pool_size
= shndx_pool_used
+ nshndx
;
8323 shndx_pool
= (unsigned int *) xcrealloc (shndx_pool
, shndx_pool_size
,
8324 sizeof (unsigned int));
8329 add_shndx_to_cu_tu_entry (unsigned int shndx
)
8331 if (shndx_pool_used
>= shndx_pool_size
)
8333 error (_("Internal error: out of space in the shndx pool.\n"));
8336 shndx_pool
[shndx_pool_used
++] = shndx
;
8340 end_cu_tu_entry (void)
8342 if (shndx_pool_used
>= shndx_pool_size
)
8344 error (_("Internal error: out of space in the shndx pool.\n"));
8347 shndx_pool
[shndx_pool_used
++] = 0;
8350 /* Return the short name of a DWARF section given by a DW_SECT enumerator. */
8353 get_DW_SECT_short_name (unsigned int dw_sect
)
8355 static char buf
[16];
8363 case DW_SECT_ABBREV
:
8369 case DW_SECT_STR_OFFSETS
:
8371 case DW_SECT_MACINFO
:
8379 snprintf (buf
, sizeof (buf
), "%d", dw_sect
);
8383 /* Process a CU or TU index. If DO_DISPLAY is true, print the contents.
8384 These sections are extensions for Fission.
8385 See http://gcc.gnu.org/wiki/DebugFissionDWP. */
8388 process_cu_tu_index (struct dwarf_section
*section
, int do_display
)
8390 unsigned char *phdr
= section
->start
;
8391 unsigned char *limit
= phdr
+ section
->size
;
8392 unsigned char *phash
;
8393 unsigned char *pindex
;
8394 unsigned char *ppool
;
8395 unsigned int version
;
8396 unsigned int ncols
= 0;
8398 unsigned int nslots
;
8401 dwarf_vma signature_high
;
8402 dwarf_vma signature_low
;
8405 /* PR 17512: file: 002-168123-0.004. */
8408 warn (_("Section %s is empty\n"), section
->name
);
8411 /* PR 17512: file: 002-376-0.004. */
8412 if (section
->size
< 24)
8414 warn (_("Section %s is too small to contain a CU/TU header\n"),
8419 SAFE_BYTE_GET (version
, phdr
, 4, limit
);
8421 SAFE_BYTE_GET (ncols
, phdr
+ 4, 4, limit
);
8422 SAFE_BYTE_GET (nused
, phdr
+ 8, 4, limit
);
8423 SAFE_BYTE_GET (nslots
, phdr
+ 12, 4, limit
);
8426 pindex
= phash
+ nslots
* 8;
8427 ppool
= pindex
+ nslots
* 4;
8429 /* PR 17531: file: 45d69832. */
8430 if (pindex
< phash
|| ppool
< phdr
|| (pindex
== phash
&& nslots
!= 0))
8432 warn (_("Section %s is too small for %d slots\n"),
8433 section
->name
, nslots
);
8439 printf (_("Contents of the %s section:\n\n"), section
->name
);
8440 printf (_(" Version: %d\n"), version
);
8442 printf (_(" Number of columns: %d\n"), ncols
);
8443 printf (_(" Number of used entries: %d\n"), nused
);
8444 printf (_(" Number of slots: %d\n\n"), nslots
);
8447 if (ppool
> limit
|| ppool
< phdr
)
8449 warn (_("Section %s too small for %d hash table entries\n"),
8450 section
->name
, nslots
);
8457 prealloc_cu_tu_list ((limit
- ppool
) / 4);
8458 for (i
= 0; i
< nslots
; i
++)
8460 unsigned char *shndx_list
;
8463 SAFE_BYTE_GET64 (phash
, &signature_high
, &signature_low
, limit
);
8464 if (signature_high
!= 0 || signature_low
!= 0)
8466 SAFE_BYTE_GET (j
, pindex
, 4, limit
);
8467 shndx_list
= ppool
+ j
* 4;
8468 /* PR 17531: file: 705e010d. */
8469 if (shndx_list
< ppool
)
8471 warn (_("Section index pool located before start of section\n"));
8476 printf (_(" [%3d] Signature: 0x%s Sections: "),
8477 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
8478 buf
, sizeof (buf
)));
8481 if (shndx_list
>= limit
)
8483 warn (_("Section %s too small for shndx pool\n"),
8487 SAFE_BYTE_GET (shndx
, shndx_list
, 4, limit
);
8491 printf (" %d", shndx
);
8493 add_shndx_to_cu_tu_entry (shndx
);
8505 else if (version
== 2)
8508 unsigned int dw_sect
;
8509 unsigned char *ph
= phash
;
8510 unsigned char *pi
= pindex
;
8511 unsigned char *poffsets
= ppool
+ ncols
* 4;
8512 unsigned char *psizes
= poffsets
+ nused
* ncols
* 4;
8513 unsigned char *pend
= psizes
+ nused
* ncols
* 4;
8514 bfd_boolean is_tu_index
;
8515 struct cu_tu_set
*this_set
= NULL
;
8517 unsigned char *prow
;
8519 is_tu_index
= strcmp (section
->name
, ".debug_tu_index") == 0;
8521 /* PR 17531: file: 0dd159bf.
8522 Check for wraparound with an overlarge ncols value. */
8523 if (poffsets
< ppool
|| (unsigned int) ((poffsets
- ppool
) / 4) != ncols
)
8525 warn (_("Overlarge number of columns: %x\n"), ncols
);
8531 warn (_("Section %s too small for offset and size tables\n"),
8538 printf (_(" Offset table\n"));
8539 printf (" slot %-16s ",
8540 is_tu_index
? _("signature") : _("dwo_id"));
8547 tu_sets
= xcalloc2 (nused
, sizeof (struct cu_tu_set
));
8553 cu_sets
= xcalloc2 (nused
, sizeof (struct cu_tu_set
));
8560 for (j
= 0; j
< ncols
; j
++)
8562 SAFE_BYTE_GET (dw_sect
, ppool
+ j
* 4, 4, limit
);
8563 printf (" %8s", get_DW_SECT_short_name (dw_sect
));
8568 for (i
= 0; i
< nslots
; i
++)
8570 SAFE_BYTE_GET64 (ph
, &signature_high
, &signature_low
, limit
);
8572 SAFE_BYTE_GET (row
, pi
, 4, limit
);
8575 /* PR 17531: file: a05f6ab3. */
8578 warn (_("Row index (%u) is larger than number of used entries (%u)\n"),
8584 memcpy (&this_set
[row
- 1].signature
, ph
, sizeof (uint64_t));
8586 prow
= poffsets
+ (row
- 1) * ncols
* 4;
8587 /* PR 17531: file: b8ce60a8. */
8588 if (prow
< poffsets
|| prow
> limit
)
8590 warn (_("Row index (%u) * num columns (%u) > space remaining in section\n"),
8596 printf (_(" [%3d] 0x%s"),
8597 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
8598 buf
, sizeof (buf
)));
8599 for (j
= 0; j
< ncols
; j
++)
8601 SAFE_BYTE_GET (val
, prow
+ j
* 4, 4, limit
);
8603 printf (" %8d", val
);
8606 SAFE_BYTE_GET (dw_sect
, ppool
+ j
* 4, 4, limit
);
8608 /* PR 17531: file: 10796eb3. */
8609 if (dw_sect
>= DW_SECT_MAX
)
8610 warn (_("Overlarge Dwarf section index detected: %u\n"), dw_sect
);
8612 this_set
[row
- 1].section_offsets
[dw_sect
] = val
;
8628 printf (_(" Size table\n"));
8629 printf (" slot %-16s ",
8630 is_tu_index
? _("signature") : _("dwo_id"));
8633 for (j
= 0; j
< ncols
; j
++)
8635 SAFE_BYTE_GET (val
, ppool
+ j
* 4, 4, limit
);
8637 printf (" %8s", get_DW_SECT_short_name (val
));
8643 for (i
= 0; i
< nslots
; i
++)
8645 SAFE_BYTE_GET64 (ph
, &signature_high
, &signature_low
, limit
);
8647 SAFE_BYTE_GET (row
, pi
, 4, limit
);
8650 prow
= psizes
+ (row
- 1) * ncols
* 4;
8653 printf (_(" [%3d] 0x%s"),
8654 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
8655 buf
, sizeof (buf
)));
8657 for (j
= 0; j
< ncols
; j
++)
8659 SAFE_BYTE_GET (val
, prow
+ j
* 4, 4, limit
);
8661 printf (" %8d", val
);
8664 SAFE_BYTE_GET (dw_sect
, ppool
+ j
* 4, 4, limit
);
8665 if (dw_sect
>= DW_SECT_MAX
)
8666 warn (_("Overlarge Dwarf section index detected: %u\n"), dw_sect
);
8668 this_set
[row
- 1].section_sizes
[dw_sect
] = val
;
8680 else if (do_display
)
8681 printf (_(" Unsupported version (%d)\n"), version
);
8689 /* Load the CU and TU indexes if present. This will build a list of
8690 section sets that we can use to associate a .debug_info.dwo section
8691 with its associated .debug_abbrev.dwo section in a .dwp file. */
8694 load_cu_tu_indexes (void *file
)
8696 static int cu_tu_indexes_read
= -1; /* Tri-state variable. */
8698 /* If we have already loaded (or tried to load) the CU and TU indexes
8699 then do not bother to repeat the task. */
8700 if (cu_tu_indexes_read
== -1)
8702 cu_tu_indexes_read
= TRUE
;
8704 if (load_debug_section (dwp_cu_index
, file
))
8705 if (! process_cu_tu_index (&debug_displays
[dwp_cu_index
].section
, 0))
8706 cu_tu_indexes_read
= FALSE
;
8708 if (load_debug_section (dwp_tu_index
, file
))
8709 if (! process_cu_tu_index (&debug_displays
[dwp_tu_index
].section
, 0))
8710 cu_tu_indexes_read
= FALSE
;
8713 return (bfd_boolean
) cu_tu_indexes_read
;
8716 /* Find the set of sections that includes section SHNDX. */
8719 find_cu_tu_set (void *file
, unsigned int shndx
)
8723 if (! load_cu_tu_indexes (file
))
8726 /* Find SHNDX in the shndx pool. */
8727 for (i
= 0; i
< shndx_pool_used
; i
++)
8728 if (shndx_pool
[i
] == shndx
)
8731 if (i
>= shndx_pool_used
)
8734 /* Now backup to find the first entry in the set. */
8735 while (i
> 0 && shndx_pool
[i
- 1] != 0)
8738 return shndx_pool
+ i
;
8741 /* Display a .debug_cu_index or .debug_tu_index section. */
8744 display_cu_index (struct dwarf_section
*section
, void *file ATTRIBUTE_UNUSED
)
8746 return process_cu_tu_index (section
, 1);
8750 display_debug_not_supported (struct dwarf_section
*section
,
8751 void *file ATTRIBUTE_UNUSED
)
8753 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
8759 /* Like malloc, but takes two parameters like calloc.
8760 Verifies that the first parameter is not too large.
8761 Note: does *not* initialise the allocated memory to zero. */
8763 cmalloc (size_t nmemb
, size_t size
)
8765 /* Check for overflow. */
8766 if (nmemb
>= ~(size_t) 0 / size
)
8769 return xmalloc (nmemb
* size
);
8772 /* Like xmalloc, but takes two parameters like calloc.
8773 Verifies that the first parameter is not too large.
8774 Note: does *not* initialise the allocated memory to zero. */
8776 xcmalloc (size_t nmemb
, size_t size
)
8778 /* Check for overflow. */
8779 if (nmemb
>= ~(size_t) 0 / size
)
8782 _("Attempt to allocate an array with an excessive number of elements: 0x%lx\n"),
8787 return xmalloc (nmemb
* size
);
8790 /* Like xrealloc, but takes three parameters.
8791 Verifies that the second parameter is not too large.
8792 Note: does *not* initialise any new memory to zero. */
8794 xcrealloc (void *ptr
, size_t nmemb
, size_t size
)
8796 /* Check for overflow. */
8797 if (nmemb
>= ~(size_t) 0 / size
)
8800 _("Attempt to re-allocate an array with an excessive number of elements: 0x%lx\n"),
8805 return xrealloc (ptr
, nmemb
* size
);
8808 /* Like xcalloc, but verifies that the first parameter is not too large. */
8810 xcalloc2 (size_t nmemb
, size_t size
)
8812 /* Check for overflow. */
8813 if (nmemb
>= ~(size_t) 0 / size
)
8816 _("Attempt to allocate a zero'ed array with an excessive number of elements: 0x%lx\n"),
8821 return xcalloc (nmemb
, size
);
8825 free_debug_memory (void)
8831 for (i
= 0; i
< max
; i
++)
8832 free_debug_section ((enum dwarf_section_display_enum
) i
);
8834 if (debug_information
!= NULL
)
8836 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
)
8838 for (i
= 0; i
< num_debug_info_entries
; i
++)
8840 if (!debug_information
[i
].max_loc_offsets
)
8842 free (debug_information
[i
].loc_offsets
);
8843 free (debug_information
[i
].have_frame_base
);
8845 if (!debug_information
[i
].max_range_lists
)
8846 free (debug_information
[i
].range_lists
);
8849 free (debug_information
);
8850 debug_information
= NULL
;
8851 alloc_num_debug_info_entries
= num_debug_info_entries
= 0;
8856 dwarf_select_sections_by_names (const char *names
)
8860 const char * option
;
8864 debug_dump_long_opts
;
8866 static const debug_dump_long_opts opts_table
[] =
8868 /* Please keep this table alpha- sorted. */
8869 { "Ranges", & do_debug_ranges
, 1 },
8870 { "abbrev", & do_debug_abbrevs
, 1 },
8871 { "addr", & do_debug_addr
, 1 },
8872 { "aranges", & do_debug_aranges
, 1 },
8873 { "cu_index", & do_debug_cu_index
, 1 },
8874 { "decodedline", & do_debug_lines
, FLAG_DEBUG_LINES_DECODED
},
8875 { "frames", & do_debug_frames
, 1 },
8876 { "frames-interp", & do_debug_frames_interp
, 1 },
8877 /* The special .gdb_index section. */
8878 { "gdb_index", & do_gdb_index
, 1 },
8879 { "info", & do_debug_info
, 1 },
8880 { "line", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
}, /* For backwards compatibility. */
8881 { "loc", & do_debug_loc
, 1 },
8882 { "macro", & do_debug_macinfo
, 1 },
8883 { "pubnames", & do_debug_pubnames
, 1 },
8884 { "pubtypes", & do_debug_pubtypes
, 1 },
8885 /* This entry is for compatibility
8886 with earlier versions of readelf. */
8887 { "ranges", & do_debug_aranges
, 1 },
8888 { "rawline", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
},
8889 { "str", & do_debug_str
, 1 },
8890 /* These trace_* sections are used by Itanium VMS. */
8891 { "trace_abbrev", & do_trace_abbrevs
, 1 },
8892 { "trace_aranges", & do_trace_aranges
, 1 },
8893 { "trace_info", & do_trace_info
, 1 },
8902 const debug_dump_long_opts
* entry
;
8904 for (entry
= opts_table
; entry
->option
; entry
++)
8906 size_t len
= strlen (entry
->option
);
8908 if (strncmp (p
, entry
->option
, len
) == 0
8909 && (p
[len
] == ',' || p
[len
] == '\0'))
8911 * entry
->variable
|= entry
->val
;
8913 /* The --debug-dump=frames-interp option also
8914 enables the --debug-dump=frames option. */
8915 if (do_debug_frames_interp
)
8916 do_debug_frames
= 1;
8923 if (entry
->option
== NULL
)
8925 warn (_("Unrecognized debug option '%s'\n"), p
);
8926 p
= strchr (p
, ',');
8937 dwarf_select_sections_by_letters (const char *letters
)
8939 unsigned int lindex
= 0;
8941 while (letters
[lindex
])
8942 switch (letters
[lindex
++])
8949 do_debug_abbrevs
= 1;
8953 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
8957 do_debug_lines
|= FLAG_DEBUG_LINES_DECODED
;
8961 do_debug_pubnames
= 1;
8965 do_debug_pubtypes
= 1;
8969 do_debug_aranges
= 1;
8973 do_debug_ranges
= 1;
8977 do_debug_frames_interp
= 1;
8980 do_debug_frames
= 1;
8984 do_debug_macinfo
= 1;
8996 warn (_("Unrecognized debug option '%s'\n"), letters
);
9002 dwarf_select_sections_all (void)
9005 do_debug_abbrevs
= 1;
9006 do_debug_lines
= FLAG_DEBUG_LINES_RAW
;
9007 do_debug_pubnames
= 1;
9008 do_debug_pubtypes
= 1;
9009 do_debug_aranges
= 1;
9010 do_debug_ranges
= 1;
9011 do_debug_frames
= 1;
9012 do_debug_macinfo
= 1;
9017 do_trace_abbrevs
= 1;
9018 do_trace_aranges
= 1;
9020 do_debug_cu_index
= 1;
9023 struct dwarf_section_display debug_displays
[] =
9025 { { ".debug_abbrev", ".zdebug_abbrev", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9026 display_debug_abbrev
, &do_debug_abbrevs
, FALSE
},
9027 { { ".debug_aranges", ".zdebug_aranges", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9028 display_debug_aranges
, &do_debug_aranges
, TRUE
},
9029 { { ".debug_frame", ".zdebug_frame", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9030 display_debug_frames
, &do_debug_frames
, TRUE
},
9031 { { ".debug_info", ".zdebug_info", NULL
, NULL
, 0, 0, abbrev
, NULL
, 0, NULL
},
9032 display_debug_info
, &do_debug_info
, TRUE
},
9033 { { ".debug_line", ".zdebug_line", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9034 display_debug_lines
, &do_debug_lines
, TRUE
},
9035 { { ".debug_pubnames", ".zdebug_pubnames", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9036 display_debug_pubnames
, &do_debug_pubnames
, FALSE
},
9037 { { ".debug_gnu_pubnames", ".zdebug_gnu_pubnames", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9038 display_debug_gnu_pubnames
, &do_debug_pubnames
, FALSE
},
9039 { { ".eh_frame", "", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9040 display_debug_frames
, &do_debug_frames
, TRUE
},
9041 { { ".debug_macinfo", ".zdebug_macinfo", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9042 display_debug_macinfo
, &do_debug_macinfo
, FALSE
},
9043 { { ".debug_macro", ".zdebug_macro", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9044 display_debug_macro
, &do_debug_macinfo
, TRUE
},
9045 { { ".debug_str", ".zdebug_str", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9046 display_debug_str
, &do_debug_str
, FALSE
},
9047 { { ".debug_line_str", ".zdebug_line_str", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9048 display_debug_str
, &do_debug_str
, FALSE
},
9049 { { ".debug_loc", ".zdebug_loc", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9050 display_debug_loc
, &do_debug_loc
, TRUE
},
9051 { { ".debug_loclists", ".zdebug_loclists", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9052 display_debug_loc
, &do_debug_loc
, TRUE
},
9053 { { ".debug_pubtypes", ".zdebug_pubtypes", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9054 display_debug_pubnames
, &do_debug_pubtypes
, FALSE
},
9055 { { ".debug_gnu_pubtypes", ".zdebug_gnu_pubtypes", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9056 display_debug_gnu_pubnames
, &do_debug_pubtypes
, FALSE
},
9057 { { ".debug_ranges", ".zdebug_ranges", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9058 display_debug_ranges
, &do_debug_ranges
, TRUE
},
9059 { { ".debug_rnglists", ".zdebug_rnglists", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9060 display_debug_ranges
, &do_debug_ranges
, TRUE
},
9061 { { ".debug_static_func", ".zdebug_static_func", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9062 display_debug_not_supported
, NULL
, FALSE
},
9063 { { ".debug_static_vars", ".zdebug_static_vars", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9064 display_debug_not_supported
, NULL
, FALSE
},
9065 { { ".debug_types", ".zdebug_types", NULL
, NULL
, 0, 0, abbrev
, NULL
, 0, NULL
},
9066 display_debug_types
, &do_debug_info
, TRUE
},
9067 { { ".debug_weaknames", ".zdebug_weaknames", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9068 display_debug_not_supported
, NULL
, FALSE
},
9069 { { ".gdb_index", "", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9070 display_gdb_index
, &do_gdb_index
, FALSE
},
9071 { { ".debug_names", "", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9072 display_debug_names
, &do_gdb_index
, FALSE
},
9073 { { ".trace_info", "", NULL
, NULL
, 0, 0, trace_abbrev
, NULL
, 0, NULL
},
9074 display_trace_info
, &do_trace_info
, TRUE
},
9075 { { ".trace_abbrev", "", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9076 display_debug_abbrev
, &do_trace_abbrevs
, FALSE
},
9077 { { ".trace_aranges", "", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9078 display_debug_aranges
, &do_trace_aranges
, FALSE
},
9079 { { ".debug_info.dwo", ".zdebug_info.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
, NULL
, 0, NULL
},
9080 display_debug_info
, &do_debug_info
, TRUE
},
9081 { { ".debug_abbrev.dwo", ".zdebug_abbrev.dwo", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9082 display_debug_abbrev
, &do_debug_abbrevs
, FALSE
},
9083 { { ".debug_types.dwo", ".zdebug_types.dwo", NULL
, NULL
, 0, 0, abbrev_dwo
, NULL
, 0, NULL
},
9084 display_debug_types
, &do_debug_info
, TRUE
},
9085 { { ".debug_line.dwo", ".zdebug_line.dwo", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9086 display_debug_lines
, &do_debug_lines
, TRUE
},
9087 { { ".debug_loc.dwo", ".zdebug_loc.dwo", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9088 display_debug_loc
, &do_debug_loc
, TRUE
},
9089 { { ".debug_macro.dwo", ".zdebug_macro.dwo", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9090 display_debug_macro
, &do_debug_macinfo
, TRUE
},
9091 { { ".debug_macinfo.dwo", ".zdebug_macinfo.dwo", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9092 display_debug_macinfo
, &do_debug_macinfo
, FALSE
},
9093 { { ".debug_str.dwo", ".zdebug_str.dwo", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9094 display_debug_str
, &do_debug_str
, TRUE
},
9095 { { ".debug_str_offsets", ".zdebug_str_offsets", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9096 display_debug_str_offsets
, NULL
, FALSE
},
9097 { { ".debug_str_offsets.dwo", ".zdebug_str_offsets.dwo", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9098 display_debug_str_offsets
, NULL
, FALSE
},
9099 { { ".debug_addr", ".zdebug_addr", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9100 display_debug_addr
, &do_debug_addr
, TRUE
},
9101 { { ".debug_cu_index", "", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9102 display_cu_index
, &do_debug_cu_index
, FALSE
},
9103 { { ".debug_tu_index", "", NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
9104 display_cu_index
, &do_debug_cu_index
, FALSE
},
9107 /* A static assertion. */
9108 extern int debug_displays_assert
[ARRAY_SIZE (debug_displays
) == max
? 1 : -1];