1 /* dwarf.c -- display DWARF contents of a BFD binary file
2 Copyright 2005, 2006, 2007, 2008, 2009
3 Free Software Foundation, Inc.
5 This file is part of GNU Binutils.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
23 #include "libiberty.h"
26 #include "elf/common.h"
30 static int have_frame_base
;
31 static int need_base_address
;
33 static unsigned int last_pointer_size
= 0;
34 static int warned_about_missing_comp_units
= FALSE
;
36 static unsigned int num_debug_info_entries
= 0;
37 static debug_info
*debug_information
= NULL
;
38 /* Special value for num_debug_info_entries to indicate
39 that the .debug_info section could not be loaded/parsed. */
40 #define DEBUG_INFO_UNAVAILABLE (unsigned int) -1
47 int do_debug_pubnames
;
48 int do_debug_pubtypes
;
52 int do_debug_frames_interp
;
58 /* Values for do_debug_lines. */
59 #define FLAG_DEBUG_LINES_RAW 1
60 #define FLAG_DEBUG_LINES_DECODED 2
62 dwarf_vma (*byte_get
) (unsigned char *, int);
65 byte_get_little_endian (unsigned char *field
, int size
)
73 return ((unsigned int) (field
[0]))
74 | (((unsigned int) (field
[1])) << 8);
77 return ((unsigned long) (field
[0]))
78 | (((unsigned long) (field
[1])) << 8)
79 | (((unsigned long) (field
[2])) << 16);
82 return ((unsigned long) (field
[0]))
83 | (((unsigned long) (field
[1])) << 8)
84 | (((unsigned long) (field
[2])) << 16)
85 | (((unsigned long) (field
[3])) << 24);
88 if (sizeof (dwarf_vma
) == 8)
89 return ((dwarf_vma
) (field
[0]))
90 | (((dwarf_vma
) (field
[1])) << 8)
91 | (((dwarf_vma
) (field
[2])) << 16)
92 | (((dwarf_vma
) (field
[3])) << 24)
93 | (((dwarf_vma
) (field
[4])) << 32)
94 | (((dwarf_vma
) (field
[5])) << 40)
95 | (((dwarf_vma
) (field
[6])) << 48)
96 | (((dwarf_vma
) (field
[7])) << 56);
97 else if (sizeof (dwarf_vma
) == 4)
98 /* We want to extract data from an 8 byte wide field and
99 place it into a 4 byte wide field. Since this is a little
100 endian source we can just use the 4 byte extraction code. */
101 return ((unsigned long) (field
[0]))
102 | (((unsigned long) (field
[1])) << 8)
103 | (((unsigned long) (field
[2])) << 16)
104 | (((unsigned long) (field
[3])) << 24);
107 error (_("Unhandled data length: %d\n"), size
);
113 byte_get_big_endian (unsigned char *field
, int size
)
121 return ((unsigned int) (field
[1])) | (((int) (field
[0])) << 8);
124 return ((unsigned long) (field
[2]))
125 | (((unsigned long) (field
[1])) << 8)
126 | (((unsigned long) (field
[0])) << 16);
129 return ((unsigned long) (field
[3]))
130 | (((unsigned long) (field
[2])) << 8)
131 | (((unsigned long) (field
[1])) << 16)
132 | (((unsigned long) (field
[0])) << 24);
135 if (sizeof (dwarf_vma
) == 8)
136 return ((dwarf_vma
) (field
[7]))
137 | (((dwarf_vma
) (field
[6])) << 8)
138 | (((dwarf_vma
) (field
[5])) << 16)
139 | (((dwarf_vma
) (field
[4])) << 24)
140 | (((dwarf_vma
) (field
[3])) << 32)
141 | (((dwarf_vma
) (field
[2])) << 40)
142 | (((dwarf_vma
) (field
[1])) << 48)
143 | (((dwarf_vma
) (field
[0])) << 56);
144 else if (sizeof (dwarf_vma
) == 4)
146 /* Although we are extracing data from an 8 byte wide field,
147 we are returning only 4 bytes of data. */
149 return ((unsigned long) (field
[3]))
150 | (((unsigned long) (field
[2])) << 8)
151 | (((unsigned long) (field
[1])) << 16)
152 | (((unsigned long) (field
[0])) << 24);
156 error (_("Unhandled data length: %d\n"), size
);
162 byte_get_signed (unsigned char *field
, int size
)
164 dwarf_vma x
= byte_get (field
, size
);
169 return (x
^ 0x80) - 0x80;
171 return (x
^ 0x8000) - 0x8000;
173 return (x
^ 0x80000000) - 0x80000000;
182 size_of_encoded_value (int encoding
)
184 switch (encoding
& 0x7)
187 case 0: return eh_addr_size
;
195 get_encoded_value (unsigned char *data
, int encoding
)
197 int size
= size_of_encoded_value (encoding
);
199 if (encoding
& DW_EH_PE_signed
)
200 return byte_get_signed (data
, size
);
202 return byte_get (data
, size
);
205 /* Print a dwarf_vma value (typically an address, offset or length) in
206 hexadecimal format, followed by a space. The length of the value (and
207 hence the precision displayed) is determined by the byte_size parameter. */
210 print_dwarf_vma (dwarf_vma val
, unsigned byte_size
)
212 static char buff
[18];
214 /* Printf does not have a way of specifiying a maximum field width for an
215 integer value, so we print the full value into a buffer and then select
216 the precision we need. */
217 #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
219 snprintf (buff
, sizeof (buff
), "%16.16llx ", val
);
221 snprintf (buff
, sizeof (buff
), "%016I64x ", val
);
224 snprintf (buff
, sizeof (buff
), "%16.16lx ", val
);
227 fputs (buff
+ (byte_size
== 4 ? 8 : 0), stdout
);
230 static unsigned long int
231 read_leb128 (unsigned char *data
, unsigned int *length_return
, int sign
)
233 unsigned long int result
= 0;
234 unsigned int num_read
= 0;
235 unsigned int shift
= 0;
243 result
|= ((unsigned long int) (byte
& 0x7f)) << shift
;
250 if (length_return
!= NULL
)
251 *length_return
= num_read
;
253 if (sign
&& (shift
< 8 * sizeof (result
)) && (byte
& 0x40))
254 result
|= -1L << shift
;
259 typedef struct State_Machine_Registers
261 unsigned long address
;
268 /* This variable hold the number of the last entry seen
269 in the File Table. */
270 unsigned int last_file_entry
;
273 static SMR state_machine_regs
;
276 reset_state_machine (int is_stmt
)
278 state_machine_regs
.address
= 0;
279 state_machine_regs
.file
= 1;
280 state_machine_regs
.line
= 1;
281 state_machine_regs
.column
= 0;
282 state_machine_regs
.is_stmt
= is_stmt
;
283 state_machine_regs
.basic_block
= 0;
284 state_machine_regs
.end_sequence
= 0;
285 state_machine_regs
.last_file_entry
= 0;
288 /* Handled an extend line op.
289 Returns the number of bytes read. */
292 process_extended_line_op (unsigned char *data
, int is_stmt
)
294 unsigned char op_code
;
295 unsigned int bytes_read
;
300 len
= read_leb128 (data
, & bytes_read
, 0);
305 warn (_("badly formed extended line op encountered!\n"));
312 printf (_(" Extended opcode %d: "), op_code
);
316 case DW_LNE_end_sequence
:
317 printf (_("End of Sequence\n\n"));
318 reset_state_machine (is_stmt
);
321 case DW_LNE_set_address
:
322 adr
= byte_get (data
, len
- bytes_read
- 1);
323 printf (_("set Address to 0x%lx\n"), adr
);
324 state_machine_regs
.address
= adr
;
327 case DW_LNE_define_file
:
328 printf (_(" define new File Table entry\n"));
329 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
331 printf (_(" %d\t"), ++state_machine_regs
.last_file_entry
);
333 data
+= strlen ((char *) data
) + 1;
334 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
336 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
338 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
339 printf (_("%s\n\n"), name
);
342 case DW_LNE_set_discriminator
:
343 printf (_("set Discriminator to %lu\n"),
344 read_leb128 (data
, & bytes_read
, 0));
348 case DW_LNE_HP_negate_is_UV_update
:
349 printf ("DW_LNE_HP_negate_is_UV_update\n");
351 case DW_LNE_HP_push_context
:
352 printf ("DW_LNE_HP_push_context\n");
354 case DW_LNE_HP_pop_context
:
355 printf ("DW_LNE_HP_pop_context\n");
357 case DW_LNE_HP_set_file_line_column
:
358 printf ("DW_LNE_HP_set_file_line_column\n");
360 case DW_LNE_HP_set_routine_name
:
361 printf ("DW_LNE_HP_set_routine_name\n");
363 case DW_LNE_HP_set_sequence
:
364 printf ("DW_LNE_HP_set_sequence\n");
366 case DW_LNE_HP_negate_post_semantics
:
367 printf ("DW_LNE_HP_negate_post_semantics\n");
369 case DW_LNE_HP_negate_function_exit
:
370 printf ("DW_LNE_HP_negate_function_exit\n");
372 case DW_LNE_HP_negate_front_end_logical
:
373 printf ("DW_LNE_HP_negate_front_end_logical\n");
375 case DW_LNE_HP_define_proc
:
376 printf ("DW_LNE_HP_define_proc\n");
380 if (op_code
>= DW_LNE_lo_user
381 /* The test against DW_LNW_hi_user is redundant due to
382 the limited range of the unsigned char data type used
384 /*&& op_code <= DW_LNE_hi_user*/)
385 printf (_("user defined: length %d\n"), len
- bytes_read
);
387 printf (_("UNKNOWN: length %d\n"), len
- bytes_read
);
395 fetch_indirect_string (unsigned long offset
)
397 struct dwarf_section
*section
= &debug_displays
[str
].section
;
399 if (section
->start
== NULL
)
400 return _("<no .debug_str section>");
402 /* DWARF sections under Mach-O have non-zero addresses. */
403 offset
-= section
->address
;
404 if (offset
> section
->size
)
406 warn (_("DW_FORM_strp offset too big: %lx\n"), offset
);
407 return _("<offset is too big>");
410 return (const char *) section
->start
+ offset
;
413 /* FIXME: There are better and more efficient ways to handle
414 these structures. For now though, I just want something that
415 is simple to implement. */
416 typedef struct abbrev_attr
418 unsigned long attribute
;
420 struct abbrev_attr
*next
;
424 typedef struct abbrev_entry
429 struct abbrev_attr
*first_attr
;
430 struct abbrev_attr
*last_attr
;
431 struct abbrev_entry
*next
;
435 static abbrev_entry
*first_abbrev
= NULL
;
436 static abbrev_entry
*last_abbrev
= NULL
;
443 for (abbrv
= first_abbrev
; abbrv
;)
445 abbrev_entry
*next_abbrev
= abbrv
->next
;
448 for (attr
= abbrv
->first_attr
; attr
;)
450 abbrev_attr
*next_attr
= attr
->next
;
460 last_abbrev
= first_abbrev
= NULL
;
464 add_abbrev (unsigned long number
, unsigned long tag
, int children
)
468 entry
= (abbrev_entry
*) malloc (sizeof (*entry
));
474 entry
->entry
= number
;
476 entry
->children
= children
;
477 entry
->first_attr
= NULL
;
478 entry
->last_attr
= NULL
;
481 if (first_abbrev
== NULL
)
482 first_abbrev
= entry
;
484 last_abbrev
->next
= entry
;
490 add_abbrev_attr (unsigned long attribute
, unsigned long form
)
494 attr
= (abbrev_attr
*) malloc (sizeof (*attr
));
500 attr
->attribute
= attribute
;
504 if (last_abbrev
->first_attr
== NULL
)
505 last_abbrev
->first_attr
= attr
;
507 last_abbrev
->last_attr
->next
= attr
;
509 last_abbrev
->last_attr
= attr
;
512 /* Processes the (partial) contents of a .debug_abbrev section.
513 Returns NULL if the end of the section was encountered.
514 Returns the address after the last byte read if the end of
515 an abbreviation set was found. */
517 static unsigned char *
518 process_abbrev_section (unsigned char *start
, unsigned char *end
)
520 if (first_abbrev
!= NULL
)
525 unsigned int bytes_read
;
528 unsigned long attribute
;
531 entry
= read_leb128 (start
, & bytes_read
, 0);
534 /* A single zero is supposed to end the section according
535 to the standard. If there's more, then signal that to
538 return start
== end
? NULL
: start
;
540 tag
= read_leb128 (start
, & bytes_read
, 0);
545 add_abbrev (entry
, tag
, children
);
551 attribute
= read_leb128 (start
, & bytes_read
, 0);
554 form
= read_leb128 (start
, & bytes_read
, 0);
558 add_abbrev_attr (attribute
, form
);
560 while (attribute
!= 0);
567 get_TAG_name (unsigned long tag
)
571 case DW_TAG_padding
: return "DW_TAG_padding";
572 case DW_TAG_array_type
: return "DW_TAG_array_type";
573 case DW_TAG_class_type
: return "DW_TAG_class_type";
574 case DW_TAG_entry_point
: return "DW_TAG_entry_point";
575 case DW_TAG_enumeration_type
: return "DW_TAG_enumeration_type";
576 case DW_TAG_formal_parameter
: return "DW_TAG_formal_parameter";
577 case DW_TAG_imported_declaration
: return "DW_TAG_imported_declaration";
578 case DW_TAG_label
: return "DW_TAG_label";
579 case DW_TAG_lexical_block
: return "DW_TAG_lexical_block";
580 case DW_TAG_member
: return "DW_TAG_member";
581 case DW_TAG_pointer_type
: return "DW_TAG_pointer_type";
582 case DW_TAG_reference_type
: return "DW_TAG_reference_type";
583 case DW_TAG_compile_unit
: return "DW_TAG_compile_unit";
584 case DW_TAG_string_type
: return "DW_TAG_string_type";
585 case DW_TAG_structure_type
: return "DW_TAG_structure_type";
586 case DW_TAG_subroutine_type
: return "DW_TAG_subroutine_type";
587 case DW_TAG_typedef
: return "DW_TAG_typedef";
588 case DW_TAG_union_type
: return "DW_TAG_union_type";
589 case DW_TAG_unspecified_parameters
: return "DW_TAG_unspecified_parameters";
590 case DW_TAG_variant
: return "DW_TAG_variant";
591 case DW_TAG_common_block
: return "DW_TAG_common_block";
592 case DW_TAG_common_inclusion
: return "DW_TAG_common_inclusion";
593 case DW_TAG_inheritance
: return "DW_TAG_inheritance";
594 case DW_TAG_inlined_subroutine
: return "DW_TAG_inlined_subroutine";
595 case DW_TAG_module
: return "DW_TAG_module";
596 case DW_TAG_ptr_to_member_type
: return "DW_TAG_ptr_to_member_type";
597 case DW_TAG_set_type
: return "DW_TAG_set_type";
598 case DW_TAG_subrange_type
: return "DW_TAG_subrange_type";
599 case DW_TAG_with_stmt
: return "DW_TAG_with_stmt";
600 case DW_TAG_access_declaration
: return "DW_TAG_access_declaration";
601 case DW_TAG_base_type
: return "DW_TAG_base_type";
602 case DW_TAG_catch_block
: return "DW_TAG_catch_block";
603 case DW_TAG_const_type
: return "DW_TAG_const_type";
604 case DW_TAG_constant
: return "DW_TAG_constant";
605 case DW_TAG_enumerator
: return "DW_TAG_enumerator";
606 case DW_TAG_file_type
: return "DW_TAG_file_type";
607 case DW_TAG_friend
: return "DW_TAG_friend";
608 case DW_TAG_namelist
: return "DW_TAG_namelist";
609 case DW_TAG_namelist_item
: return "DW_TAG_namelist_item";
610 case DW_TAG_packed_type
: return "DW_TAG_packed_type";
611 case DW_TAG_subprogram
: return "DW_TAG_subprogram";
612 case DW_TAG_template_type_param
: return "DW_TAG_template_type_param";
613 case DW_TAG_template_value_param
: return "DW_TAG_template_value_param";
614 case DW_TAG_thrown_type
: return "DW_TAG_thrown_type";
615 case DW_TAG_try_block
: return "DW_TAG_try_block";
616 case DW_TAG_variant_part
: return "DW_TAG_variant_part";
617 case DW_TAG_variable
: return "DW_TAG_variable";
618 case DW_TAG_volatile_type
: return "DW_TAG_volatile_type";
619 case DW_TAG_MIPS_loop
: return "DW_TAG_MIPS_loop";
620 case DW_TAG_format_label
: return "DW_TAG_format_label";
621 case DW_TAG_function_template
: return "DW_TAG_function_template";
622 case DW_TAG_class_template
: return "DW_TAG_class_template";
623 /* DWARF 2.1 values. */
624 case DW_TAG_dwarf_procedure
: return "DW_TAG_dwarf_procedure";
625 case DW_TAG_restrict_type
: return "DW_TAG_restrict_type";
626 case DW_TAG_interface_type
: return "DW_TAG_interface_type";
627 case DW_TAG_namespace
: return "DW_TAG_namespace";
628 case DW_TAG_imported_module
: return "DW_TAG_imported_module";
629 case DW_TAG_unspecified_type
: return "DW_TAG_unspecified_type";
630 case DW_TAG_partial_unit
: return "DW_TAG_partial_unit";
631 case DW_TAG_imported_unit
: return "DW_TAG_imported_unit";
632 case DW_TAG_condition
: return "DW_TAG_condition";
633 case DW_TAG_shared_type
: return "DW_TAG_shared_type";
634 /* DWARF 4 values. */
635 case DW_TAG_type_unit
: return "DW_TAG_type_unit";
636 case DW_TAG_rvalue_reference_type
: return "DW_TAG_rvalue_reference_type";
637 case DW_TAG_template_alias
: return "DW_TAG_template_alias";
639 case DW_TAG_upc_shared_type
: return "DW_TAG_upc_shared_type";
640 case DW_TAG_upc_strict_type
: return "DW_TAG_upc_strict_type";
641 case DW_TAG_upc_relaxed_type
: return "DW_TAG_upc_relaxed_type";
644 static char buffer
[100];
646 snprintf (buffer
, sizeof (buffer
), _("Unknown TAG value: %lx"), tag
);
653 get_FORM_name (unsigned long form
)
657 case DW_FORM_addr
: return "DW_FORM_addr";
658 case DW_FORM_block2
: return "DW_FORM_block2";
659 case DW_FORM_block4
: return "DW_FORM_block4";
660 case DW_FORM_data2
: return "DW_FORM_data2";
661 case DW_FORM_data4
: return "DW_FORM_data4";
662 case DW_FORM_data8
: return "DW_FORM_data8";
663 case DW_FORM_string
: return "DW_FORM_string";
664 case DW_FORM_block
: return "DW_FORM_block";
665 case DW_FORM_block1
: return "DW_FORM_block1";
666 case DW_FORM_data1
: return "DW_FORM_data1";
667 case DW_FORM_flag
: return "DW_FORM_flag";
668 case DW_FORM_sdata
: return "DW_FORM_sdata";
669 case DW_FORM_strp
: return "DW_FORM_strp";
670 case DW_FORM_udata
: return "DW_FORM_udata";
671 case DW_FORM_ref_addr
: return "DW_FORM_ref_addr";
672 case DW_FORM_ref1
: return "DW_FORM_ref1";
673 case DW_FORM_ref2
: return "DW_FORM_ref2";
674 case DW_FORM_ref4
: return "DW_FORM_ref4";
675 case DW_FORM_ref8
: return "DW_FORM_ref8";
676 case DW_FORM_ref_udata
: return "DW_FORM_ref_udata";
677 case DW_FORM_indirect
: return "DW_FORM_indirect";
678 /* DWARF 4 values. */
679 case DW_FORM_sec_offset
: return "DW_FORM_sec_offset";
680 case DW_FORM_exprloc
: return "DW_FORM_exprloc";
681 case DW_FORM_flag_present
: return "DW_FORM_flag_present";
682 case DW_FORM_ref_sig8
: return "DW_FORM_ref_sig8";
685 static char buffer
[100];
687 snprintf (buffer
, sizeof (buffer
), _("Unknown FORM value: %lx"), form
);
693 static unsigned char *
694 display_block (unsigned char *data
, unsigned long length
)
696 printf (_(" %lu byte block: "), length
);
699 printf ("%lx ", (unsigned long) byte_get (data
++, 1));
705 decode_location_expression (unsigned char * data
,
706 unsigned int pointer_size
,
707 unsigned long length
,
708 unsigned long cu_offset
,
709 struct dwarf_section
* section
)
712 unsigned int bytes_read
;
713 unsigned long uvalue
;
714 unsigned char *end
= data
+ length
;
715 int need_frame_base
= 0;
724 printf ("DW_OP_addr: %lx",
725 (unsigned long) byte_get (data
, pointer_size
));
726 data
+= pointer_size
;
729 printf ("DW_OP_deref");
732 printf ("DW_OP_const1u: %lu", (unsigned long) byte_get (data
++, 1));
735 printf ("DW_OP_const1s: %ld", (long) byte_get_signed (data
++, 1));
738 printf ("DW_OP_const2u: %lu", (unsigned long) byte_get (data
, 2));
742 printf ("DW_OP_const2s: %ld", (long) byte_get_signed (data
, 2));
746 printf ("DW_OP_const4u: %lu", (unsigned long) byte_get (data
, 4));
750 printf ("DW_OP_const4s: %ld", (long) byte_get_signed (data
, 4));
754 printf ("DW_OP_const8u: %lu %lu", (unsigned long) byte_get (data
, 4),
755 (unsigned long) byte_get (data
+ 4, 4));
759 printf ("DW_OP_const8s: %ld %ld", (long) byte_get (data
, 4),
760 (long) byte_get (data
+ 4, 4));
764 printf ("DW_OP_constu: %lu", read_leb128 (data
, &bytes_read
, 0));
768 printf ("DW_OP_consts: %ld", read_leb128 (data
, &bytes_read
, 1));
772 printf ("DW_OP_dup");
775 printf ("DW_OP_drop");
778 printf ("DW_OP_over");
781 printf ("DW_OP_pick: %ld", (unsigned long) byte_get (data
++, 1));
784 printf ("DW_OP_swap");
787 printf ("DW_OP_rot");
790 printf ("DW_OP_xderef");
793 printf ("DW_OP_abs");
796 printf ("DW_OP_and");
799 printf ("DW_OP_div");
802 printf ("DW_OP_minus");
805 printf ("DW_OP_mod");
808 printf ("DW_OP_mul");
811 printf ("DW_OP_neg");
814 printf ("DW_OP_not");
820 printf ("DW_OP_plus");
822 case DW_OP_plus_uconst
:
823 printf ("DW_OP_plus_uconst: %lu",
824 read_leb128 (data
, &bytes_read
, 0));
828 printf ("DW_OP_shl");
831 printf ("DW_OP_shr");
834 printf ("DW_OP_shra");
837 printf ("DW_OP_xor");
840 printf ("DW_OP_bra: %ld", (long) byte_get_signed (data
, 2));
862 printf ("DW_OP_skip: %ld", (long) byte_get_signed (data
, 2));
898 printf ("DW_OP_lit%d", op
- DW_OP_lit0
);
933 printf ("DW_OP_reg%d", op
- DW_OP_reg0
);
968 printf ("DW_OP_breg%d: %ld", op
- DW_OP_breg0
,
969 read_leb128 (data
, &bytes_read
, 1));
974 printf ("DW_OP_regx: %lu", read_leb128 (data
, &bytes_read
, 0));
979 printf ("DW_OP_fbreg: %ld", read_leb128 (data
, &bytes_read
, 1));
983 uvalue
= read_leb128 (data
, &bytes_read
, 0);
985 printf ("DW_OP_bregx: %lu %ld", uvalue
,
986 read_leb128 (data
, &bytes_read
, 1));
990 printf ("DW_OP_piece: %lu", read_leb128 (data
, &bytes_read
, 0));
993 case DW_OP_deref_size
:
994 printf ("DW_OP_deref_size: %ld", (long) byte_get (data
++, 1));
996 case DW_OP_xderef_size
:
997 printf ("DW_OP_xderef_size: %ld", (long) byte_get (data
++, 1));
1000 printf ("DW_OP_nop");
1003 /* DWARF 3 extensions. */
1004 case DW_OP_push_object_address
:
1005 printf ("DW_OP_push_object_address");
1008 /* XXX: Strictly speaking for 64-bit DWARF3 files
1009 this ought to be an 8-byte wide computation. */
1010 printf ("DW_OP_call2: <%lx>", (long) byte_get (data
, 2) + cu_offset
);
1014 /* XXX: Strictly speaking for 64-bit DWARF3 files
1015 this ought to be an 8-byte wide computation. */
1016 printf ("DW_OP_call4: <%lx>", (long) byte_get (data
, 4) + cu_offset
);
1019 case DW_OP_call_ref
:
1020 /* XXX: Strictly speaking for 64-bit DWARF3 files
1021 this ought to be an 8-byte wide computation. */
1022 printf ("DW_OP_call_ref: <%lx>", (long) byte_get (data
, 4) + cu_offset
);
1025 case DW_OP_form_tls_address
:
1026 printf ("DW_OP_form_tls_address");
1028 case DW_OP_call_frame_cfa
:
1029 printf ("DW_OP_call_frame_cfa");
1031 case DW_OP_bit_piece
:
1032 printf ("DW_OP_bit_piece: ");
1033 printf ("size: %lu ", read_leb128 (data
, &bytes_read
, 0));
1035 printf ("offset: %lu ", read_leb128 (data
, &bytes_read
, 0));
1039 /* DWARF 4 extensions. */
1040 case DW_OP_stack_value
:
1041 printf ("DW_OP_stack_value");
1044 case DW_OP_implicit_value
:
1045 printf ("DW_OP_implicit_value");
1046 uvalue
= read_leb128 (data
, &bytes_read
, 0);
1048 display_block (data
, uvalue
);
1052 /* GNU extensions. */
1053 case DW_OP_GNU_push_tls_address
:
1054 printf ("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown");
1056 case DW_OP_GNU_uninit
:
1057 printf ("DW_OP_GNU_uninit");
1058 /* FIXME: Is there data associated with this OP ? */
1060 case DW_OP_GNU_encoded_addr
:
1066 addr
= get_encoded_value (data
, encoding
);
1067 if ((encoding
& 0x70) == DW_EH_PE_pcrel
)
1068 addr
+= section
->address
+ (data
- section
->start
);
1069 data
+= size_of_encoded_value (encoding
);
1071 printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding
);
1072 print_dwarf_vma (addr
, pointer_size
);
1076 /* HP extensions. */
1077 case DW_OP_HP_is_value
:
1078 printf ("DW_OP_HP_is_value");
1079 /* FIXME: Is there data associated with this OP ? */
1081 case DW_OP_HP_fltconst4
:
1082 printf ("DW_OP_HP_fltconst4");
1083 /* FIXME: Is there data associated with this OP ? */
1085 case DW_OP_HP_fltconst8
:
1086 printf ("DW_OP_HP_fltconst8");
1087 /* FIXME: Is there data associated with this OP ? */
1089 case DW_OP_HP_mod_range
:
1090 printf ("DW_OP_HP_mod_range");
1091 /* FIXME: Is there data associated with this OP ? */
1093 case DW_OP_HP_unmod_range
:
1094 printf ("DW_OP_HP_unmod_range");
1095 /* FIXME: Is there data associated with this OP ? */
1098 printf ("DW_OP_HP_tls");
1099 /* FIXME: Is there data associated with this OP ? */
1102 /* PGI (STMicroelectronics) extensions. */
1103 case DW_OP_PGI_omp_thread_num
:
1104 /* Pushes the thread number for the current thread as it would be
1105 returned by the standard OpenMP library function:
1106 omp_get_thread_num(). The "current thread" is the thread for
1107 which the expression is being evaluated. */
1108 printf ("DW_OP_PGI_omp_thread_num");
1112 if (op
>= DW_OP_lo_user
1113 && op
<= DW_OP_hi_user
)
1114 printf (_("(User defined location op)"));
1116 printf (_("(Unknown location op)"));
1117 /* No way to tell where the next op is, so just bail. */
1118 return need_frame_base
;
1121 /* Separate the ops. */
1126 return need_frame_base
;
1129 static unsigned char *
1130 read_and_display_attr_value (unsigned long attribute
,
1132 unsigned char * data
,
1133 unsigned long cu_offset
,
1134 unsigned long pointer_size
,
1135 unsigned long offset_size
,
1137 debug_info
* debug_info_p
,
1139 struct dwarf_section
* section
)
1141 unsigned long uvalue
= 0;
1142 unsigned char *block_start
= NULL
;
1143 unsigned char * orig_data
= data
;
1144 unsigned int bytes_read
;
1151 case DW_FORM_ref_addr
:
1152 if (dwarf_version
== 2)
1154 uvalue
= byte_get (data
, pointer_size
);
1155 data
+= pointer_size
;
1157 else if (dwarf_version
== 3)
1159 uvalue
= byte_get (data
, offset_size
);
1160 data
+= offset_size
;
1164 error (_("Internal error: DWARF version is not 2 or 3.\n"));
1169 uvalue
= byte_get (data
, pointer_size
);
1170 data
+= pointer_size
;
1174 uvalue
= byte_get (data
, offset_size
);
1175 data
+= offset_size
;
1181 uvalue
= byte_get (data
++, 1);
1186 uvalue
= byte_get (data
, 2);
1192 uvalue
= byte_get (data
, 4);
1197 uvalue
= read_leb128 (data
, & bytes_read
, 1);
1201 case DW_FORM_ref_udata
:
1203 uvalue
= read_leb128 (data
, & bytes_read
, 0);
1207 case DW_FORM_indirect
:
1208 form
= read_leb128 (data
, & bytes_read
, 0);
1211 printf (" %s", get_FORM_name (form
));
1212 return read_and_display_attr_value (attribute
, form
, data
,
1213 cu_offset
, pointer_size
,
1214 offset_size
, dwarf_version
,
1215 debug_info_p
, do_loc
,
1221 case DW_FORM_ref_addr
:
1223 printf (" <0x%lx>", uvalue
);
1229 case DW_FORM_ref_udata
:
1231 printf (" <0x%lx>", uvalue
+ cu_offset
);
1237 printf (" 0x%lx", uvalue
);
1246 printf (" %ld", uvalue
);
1253 uvalue
= byte_get (data
, 4);
1254 printf (" 0x%lx", uvalue
);
1255 printf (" 0x%lx", (unsigned long) byte_get (data
+ 4, 4));
1257 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1258 && num_debug_info_entries
== 0)
1260 if (sizeof (uvalue
) == 8)
1261 uvalue
= byte_get (data
, 8);
1263 error (_("DW_FORM_data8 is unsupported when sizeof (unsigned long) != 8\n"));
1268 case DW_FORM_string
:
1270 printf (" %s", data
);
1271 data
+= strlen ((char *) data
) + 1;
1275 uvalue
= read_leb128 (data
, & bytes_read
, 0);
1276 block_start
= data
+ bytes_read
;
1278 data
= block_start
+ uvalue
;
1280 data
= display_block (block_start
, uvalue
);
1283 case DW_FORM_block1
:
1284 uvalue
= byte_get (data
, 1);
1285 block_start
= data
+ 1;
1287 data
= block_start
+ uvalue
;
1289 data
= display_block (block_start
, uvalue
);
1292 case DW_FORM_block2
:
1293 uvalue
= byte_get (data
, 2);
1294 block_start
= data
+ 2;
1296 data
= block_start
+ uvalue
;
1298 data
= display_block (block_start
, uvalue
);
1301 case DW_FORM_block4
:
1302 uvalue
= byte_get (data
, 4);
1303 block_start
= data
+ 4;
1305 data
= block_start
+ uvalue
;
1307 data
= display_block (block_start
, uvalue
);
1312 printf (_(" (indirect string, offset: 0x%lx): %s"),
1313 uvalue
, fetch_indirect_string (uvalue
));
1316 case DW_FORM_indirect
:
1317 /* Handled above. */
1320 case DW_FORM_ref_sig8
:
1324 printf (" signature: ");
1325 for (i
= 0; i
< 8; i
++)
1327 printf ("%02x", (unsigned) byte_get (data
, 1));
1336 warn (_("Unrecognized form: %lu\n"), form
);
1340 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1341 && num_debug_info_entries
== 0)
1345 case DW_AT_frame_base
:
1346 have_frame_base
= 1;
1347 case DW_AT_location
:
1348 case DW_AT_string_length
:
1349 case DW_AT_return_addr
:
1350 case DW_AT_data_member_location
:
1351 case DW_AT_vtable_elem_location
:
1353 case DW_AT_static_link
:
1354 case DW_AT_use_location
:
1355 if (form
== DW_FORM_data4
|| form
== DW_FORM_data8
)
1357 /* Process location list. */
1358 unsigned int lmax
= debug_info_p
->max_loc_offsets
;
1359 unsigned int num
= debug_info_p
->num_loc_offsets
;
1361 if (lmax
== 0 || num
>= lmax
)
1364 debug_info_p
->loc_offsets
= (long unsigned int *)
1365 xcrealloc (debug_info_p
->loc_offsets
,
1366 lmax
, sizeof (*debug_info_p
->loc_offsets
));
1367 debug_info_p
->have_frame_base
= (int *)
1368 xcrealloc (debug_info_p
->have_frame_base
,
1369 lmax
, sizeof (*debug_info_p
->have_frame_base
));
1370 debug_info_p
->max_loc_offsets
= lmax
;
1372 debug_info_p
->loc_offsets
[num
] = uvalue
;
1373 debug_info_p
->have_frame_base
[num
] = have_frame_base
;
1374 debug_info_p
->num_loc_offsets
++;
1379 if (need_base_address
)
1380 debug_info_p
->base_address
= uvalue
;
1384 if (form
== DW_FORM_data4
|| form
== DW_FORM_data8
)
1386 /* Process range list. */
1387 unsigned int lmax
= debug_info_p
->max_range_lists
;
1388 unsigned int num
= debug_info_p
->num_range_lists
;
1390 if (lmax
== 0 || num
>= lmax
)
1393 debug_info_p
->range_lists
= (long unsigned int *)
1394 xcrealloc (debug_info_p
->range_lists
,
1395 lmax
, sizeof (*debug_info_p
->range_lists
));
1396 debug_info_p
->max_range_lists
= lmax
;
1398 debug_info_p
->range_lists
[num
] = uvalue
;
1399 debug_info_p
->num_range_lists
++;
1411 /* For some attributes we can display further information. */
1419 case DW_INL_not_inlined
:
1420 printf (_("(not inlined)"));
1422 case DW_INL_inlined
:
1423 printf (_("(inlined)"));
1425 case DW_INL_declared_not_inlined
:
1426 printf (_("(declared as inline but ignored)"));
1428 case DW_INL_declared_inlined
:
1429 printf (_("(declared as inline and inlined)"));
1432 printf (_(" (Unknown inline attribute value: %lx)"), uvalue
);
1437 case DW_AT_language
:
1440 /* Ordered by the numeric value of these constants. */
1441 case DW_LANG_C89
: printf ("(ANSI C)"); break;
1442 case DW_LANG_C
: printf ("(non-ANSI C)"); break;
1443 case DW_LANG_Ada83
: printf ("(Ada)"); break;
1444 case DW_LANG_C_plus_plus
: printf ("(C++)"); break;
1445 case DW_LANG_Cobol74
: printf ("(Cobol 74)"); break;
1446 case DW_LANG_Cobol85
: printf ("(Cobol 85)"); break;
1447 case DW_LANG_Fortran77
: printf ("(FORTRAN 77)"); break;
1448 case DW_LANG_Fortran90
: printf ("(Fortran 90)"); break;
1449 case DW_LANG_Pascal83
: printf ("(ANSI Pascal)"); break;
1450 case DW_LANG_Modula2
: printf ("(Modula 2)"); break;
1451 /* DWARF 2.1 values. */
1452 case DW_LANG_Java
: printf ("(Java)"); break;
1453 case DW_LANG_C99
: printf ("(ANSI C99)"); break;
1454 case DW_LANG_Ada95
: printf ("(ADA 95)"); break;
1455 case DW_LANG_Fortran95
: printf ("(Fortran 95)"); break;
1456 /* DWARF 3 values. */
1457 case DW_LANG_PLI
: printf ("(PLI)"); break;
1458 case DW_LANG_ObjC
: printf ("(Objective C)"); break;
1459 case DW_LANG_ObjC_plus_plus
: printf ("(Objective C++)"); break;
1460 case DW_LANG_UPC
: printf ("(Unified Parallel C)"); break;
1461 case DW_LANG_D
: printf ("(D)"); break;
1462 /* DWARF 4 values. */
1463 case DW_LANG_Python
: printf ("(Python)"); break;
1464 /* MIPS extension. */
1465 case DW_LANG_Mips_Assembler
: printf ("(MIPS assembler)"); break;
1466 /* UPC extension. */
1467 case DW_LANG_Upc
: printf ("(Unified Parallel C)"); break;
1469 if (uvalue
>= DW_LANG_lo_user
&& uvalue
<= DW_LANG_hi_user
)
1470 printf ("(implementation defined: %lx)", uvalue
);
1472 printf ("(Unknown: %lx)", uvalue
);
1477 case DW_AT_encoding
:
1480 case DW_ATE_void
: printf ("(void)"); break;
1481 case DW_ATE_address
: printf ("(machine address)"); break;
1482 case DW_ATE_boolean
: printf ("(boolean)"); break;
1483 case DW_ATE_complex_float
: printf ("(complex float)"); break;
1484 case DW_ATE_float
: printf ("(float)"); break;
1485 case DW_ATE_signed
: printf ("(signed)"); break;
1486 case DW_ATE_signed_char
: printf ("(signed char)"); break;
1487 case DW_ATE_unsigned
: printf ("(unsigned)"); break;
1488 case DW_ATE_unsigned_char
: printf ("(unsigned char)"); break;
1489 /* DWARF 2.1 values: */
1490 case DW_ATE_imaginary_float
: printf ("(imaginary float)"); break;
1491 case DW_ATE_decimal_float
: printf ("(decimal float)"); break;
1492 /* DWARF 3 values: */
1493 case DW_ATE_packed_decimal
: printf ("(packed_decimal)"); break;
1494 case DW_ATE_numeric_string
: printf ("(numeric_string)"); break;
1495 case DW_ATE_edited
: printf ("(edited)"); break;
1496 case DW_ATE_signed_fixed
: printf ("(signed_fixed)"); break;
1497 case DW_ATE_unsigned_fixed
: printf ("(unsigned_fixed)"); break;
1498 /* HP extensions: */
1499 case DW_ATE_HP_float80
: printf ("(HP_float80)"); break;
1500 case DW_ATE_HP_complex_float80
: printf ("(HP_complex_float80)"); break;
1501 case DW_ATE_HP_float128
: printf ("(HP_float128)"); break;
1502 case DW_ATE_HP_complex_float128
:printf ("(HP_complex_float128)"); break;
1503 case DW_ATE_HP_floathpintel
: printf ("(HP_floathpintel)"); break;
1504 case DW_ATE_HP_imaginary_float80
: printf ("(HP_imaginary_float80)"); break;
1505 case DW_ATE_HP_imaginary_float128
: printf ("(HP_imaginary_float128)"); break;
1508 if (uvalue
>= DW_ATE_lo_user
1509 && uvalue
<= DW_ATE_hi_user
)
1510 printf ("(user defined type)");
1512 printf ("(unknown type)");
1517 case DW_AT_accessibility
:
1520 case DW_ACCESS_public
: printf ("(public)"); break;
1521 case DW_ACCESS_protected
: printf ("(protected)"); break;
1522 case DW_ACCESS_private
: printf ("(private)"); break;
1524 printf ("(unknown accessibility)");
1529 case DW_AT_visibility
:
1532 case DW_VIS_local
: printf ("(local)"); break;
1533 case DW_VIS_exported
: printf ("(exported)"); break;
1534 case DW_VIS_qualified
: printf ("(qualified)"); break;
1535 default: printf ("(unknown visibility)"); break;
1539 case DW_AT_virtuality
:
1542 case DW_VIRTUALITY_none
: printf ("(none)"); break;
1543 case DW_VIRTUALITY_virtual
: printf ("(virtual)"); break;
1544 case DW_VIRTUALITY_pure_virtual
:printf ("(pure_virtual)"); break;
1545 default: printf ("(unknown virtuality)"); break;
1549 case DW_AT_identifier_case
:
1552 case DW_ID_case_sensitive
: printf ("(case_sensitive)"); break;
1553 case DW_ID_up_case
: printf ("(up_case)"); break;
1554 case DW_ID_down_case
: printf ("(down_case)"); break;
1555 case DW_ID_case_insensitive
: printf ("(case_insensitive)"); break;
1556 default: printf ("(unknown case)"); break;
1560 case DW_AT_calling_convention
:
1563 case DW_CC_normal
: printf ("(normal)"); break;
1564 case DW_CC_program
: printf ("(program)"); break;
1565 case DW_CC_nocall
: printf ("(nocall)"); break;
1567 if (uvalue
>= DW_CC_lo_user
1568 && uvalue
<= DW_CC_hi_user
)
1569 printf ("(user defined)");
1571 printf ("(unknown convention)");
1575 case DW_AT_ordering
:
1578 case -1: printf ("(undefined)"); break;
1579 case 0: printf ("(row major)"); break;
1580 case 1: printf ("(column major)"); break;
1584 case DW_AT_frame_base
:
1585 have_frame_base
= 1;
1586 case DW_AT_location
:
1587 case DW_AT_string_length
:
1588 case DW_AT_return_addr
:
1589 case DW_AT_data_member_location
:
1590 case DW_AT_vtable_elem_location
:
1592 case DW_AT_static_link
:
1593 case DW_AT_use_location
:
1594 if (form
== DW_FORM_data4
|| form
== DW_FORM_data8
)
1595 printf (_("(location list)"));
1597 case DW_AT_allocated
:
1598 case DW_AT_associated
:
1599 case DW_AT_data_location
:
1601 case DW_AT_upper_bound
:
1602 case DW_AT_lower_bound
:
1605 int need_frame_base
;
1608 need_frame_base
= decode_location_expression (block_start
,
1611 cu_offset
, section
);
1613 if (need_frame_base
&& !have_frame_base
)
1614 printf (_(" [without DW_AT_frame_base]"));
1620 if (form
== DW_FORM_ref_sig8
)
1623 if (form
== DW_FORM_ref1
1624 || form
== DW_FORM_ref2
1625 || form
== DW_FORM_ref4
)
1626 uvalue
+= cu_offset
;
1628 if (uvalue
>= section
->size
)
1629 warn (_("Offset %lx used as value for DW_AT_import attribute of DIE at offset %lx is too big.\n"),
1630 uvalue
, (unsigned long) (orig_data
- section
->start
));
1633 unsigned long abbrev_number
;
1634 abbrev_entry
* entry
;
1636 abbrev_number
= read_leb128 (section
->start
+ uvalue
, NULL
, 0);
1638 printf ("[Abbrev Number: %ld", abbrev_number
);
1639 for (entry
= first_abbrev
; entry
!= NULL
; entry
= entry
->next
)
1640 if (entry
->entry
== abbrev_number
)
1643 printf (" (%s)", get_TAG_name (entry
->tag
));
1657 get_AT_name (unsigned long attribute
)
1661 case DW_AT_sibling
: return "DW_AT_sibling";
1662 case DW_AT_location
: return "DW_AT_location";
1663 case DW_AT_name
: return "DW_AT_name";
1664 case DW_AT_ordering
: return "DW_AT_ordering";
1665 case DW_AT_subscr_data
: return "DW_AT_subscr_data";
1666 case DW_AT_byte_size
: return "DW_AT_byte_size";
1667 case DW_AT_bit_offset
: return "DW_AT_bit_offset";
1668 case DW_AT_bit_size
: return "DW_AT_bit_size";
1669 case DW_AT_element_list
: return "DW_AT_element_list";
1670 case DW_AT_stmt_list
: return "DW_AT_stmt_list";
1671 case DW_AT_low_pc
: return "DW_AT_low_pc";
1672 case DW_AT_high_pc
: return "DW_AT_high_pc";
1673 case DW_AT_language
: return "DW_AT_language";
1674 case DW_AT_member
: return "DW_AT_member";
1675 case DW_AT_discr
: return "DW_AT_discr";
1676 case DW_AT_discr_value
: return "DW_AT_discr_value";
1677 case DW_AT_visibility
: return "DW_AT_visibility";
1678 case DW_AT_import
: return "DW_AT_import";
1679 case DW_AT_string_length
: return "DW_AT_string_length";
1680 case DW_AT_common_reference
: return "DW_AT_common_reference";
1681 case DW_AT_comp_dir
: return "DW_AT_comp_dir";
1682 case DW_AT_const_value
: return "DW_AT_const_value";
1683 case DW_AT_containing_type
: return "DW_AT_containing_type";
1684 case DW_AT_default_value
: return "DW_AT_default_value";
1685 case DW_AT_inline
: return "DW_AT_inline";
1686 case DW_AT_is_optional
: return "DW_AT_is_optional";
1687 case DW_AT_lower_bound
: return "DW_AT_lower_bound";
1688 case DW_AT_producer
: return "DW_AT_producer";
1689 case DW_AT_prototyped
: return "DW_AT_prototyped";
1690 case DW_AT_return_addr
: return "DW_AT_return_addr";
1691 case DW_AT_start_scope
: return "DW_AT_start_scope";
1692 case DW_AT_stride_size
: return "DW_AT_stride_size";
1693 case DW_AT_upper_bound
: return "DW_AT_upper_bound";
1694 case DW_AT_abstract_origin
: return "DW_AT_abstract_origin";
1695 case DW_AT_accessibility
: return "DW_AT_accessibility";
1696 case DW_AT_address_class
: return "DW_AT_address_class";
1697 case DW_AT_artificial
: return "DW_AT_artificial";
1698 case DW_AT_base_types
: return "DW_AT_base_types";
1699 case DW_AT_calling_convention
: return "DW_AT_calling_convention";
1700 case DW_AT_count
: return "DW_AT_count";
1701 case DW_AT_data_member_location
: return "DW_AT_data_member_location";
1702 case DW_AT_decl_column
: return "DW_AT_decl_column";
1703 case DW_AT_decl_file
: return "DW_AT_decl_file";
1704 case DW_AT_decl_line
: return "DW_AT_decl_line";
1705 case DW_AT_declaration
: return "DW_AT_declaration";
1706 case DW_AT_discr_list
: return "DW_AT_discr_list";
1707 case DW_AT_encoding
: return "DW_AT_encoding";
1708 case DW_AT_external
: return "DW_AT_external";
1709 case DW_AT_frame_base
: return "DW_AT_frame_base";
1710 case DW_AT_friend
: return "DW_AT_friend";
1711 case DW_AT_identifier_case
: return "DW_AT_identifier_case";
1712 case DW_AT_macro_info
: return "DW_AT_macro_info";
1713 case DW_AT_namelist_items
: return "DW_AT_namelist_items";
1714 case DW_AT_priority
: return "DW_AT_priority";
1715 case DW_AT_segment
: return "DW_AT_segment";
1716 case DW_AT_specification
: return "DW_AT_specification";
1717 case DW_AT_static_link
: return "DW_AT_static_link";
1718 case DW_AT_type
: return "DW_AT_type";
1719 case DW_AT_use_location
: return "DW_AT_use_location";
1720 case DW_AT_variable_parameter
: return "DW_AT_variable_parameter";
1721 case DW_AT_virtuality
: return "DW_AT_virtuality";
1722 case DW_AT_vtable_elem_location
: return "DW_AT_vtable_elem_location";
1723 /* DWARF 2.1 values. */
1724 case DW_AT_allocated
: return "DW_AT_allocated";
1725 case DW_AT_associated
: return "DW_AT_associated";
1726 case DW_AT_data_location
: return "DW_AT_data_location";
1727 case DW_AT_stride
: return "DW_AT_stride";
1728 case DW_AT_entry_pc
: return "DW_AT_entry_pc";
1729 case DW_AT_use_UTF8
: return "DW_AT_use_UTF8";
1730 case DW_AT_extension
: return "DW_AT_extension";
1731 case DW_AT_ranges
: return "DW_AT_ranges";
1732 case DW_AT_trampoline
: return "DW_AT_trampoline";
1733 case DW_AT_call_column
: return "DW_AT_call_column";
1734 case DW_AT_call_file
: return "DW_AT_call_file";
1735 case DW_AT_call_line
: return "DW_AT_call_line";
1736 case DW_AT_description
: return "DW_AT_description";
1737 case DW_AT_binary_scale
: return "DW_AT_binary_scale";
1738 case DW_AT_decimal_scale
: return "DW_AT_decimal_scale";
1739 case DW_AT_small
: return "DW_AT_small";
1740 case DW_AT_decimal_sign
: return "DW_AT_decimal_sign";
1741 case DW_AT_digit_count
: return "DW_AT_digit_count";
1742 case DW_AT_picture_string
: return "DW_AT_picture_string";
1743 case DW_AT_mutable
: return "DW_AT_mutable";
1744 case DW_AT_threads_scaled
: return "DW_AT_threads_scaled";
1745 case DW_AT_explicit
: return "DW_AT_explicit";
1746 case DW_AT_object_pointer
: return "DW_AT_object_pointer";
1747 case DW_AT_endianity
: return "DW_AT_endianity";
1748 case DW_AT_elemental
: return "DW_AT_elemental";
1749 case DW_AT_pure
: return "DW_AT_pure";
1750 case DW_AT_recursive
: return "DW_AT_recursive";
1751 /* DWARF 4 values. */
1752 case DW_AT_signature
: return "DW_AT_signature";
1753 case DW_AT_main_subprogram
: return "DW_AT_main_subprogram";
1754 case DW_AT_data_bit_offset
: return "DW_AT_data_bit_offset";
1755 case DW_AT_const_expr
: return "DW_AT_const_expr";
1756 case DW_AT_enum_class
: return "DW_AT_enum_class";
1757 case DW_AT_linkage_name
: return "DW_AT_linkage_name";
1759 /* HP and SGI/MIPS extensions. */
1760 case DW_AT_MIPS_loop_begin
: return "DW_AT_MIPS_loop_begin";
1761 case DW_AT_MIPS_tail_loop_begin
: return "DW_AT_MIPS_tail_loop_begin";
1762 case DW_AT_MIPS_epilog_begin
: return "DW_AT_MIPS_epilog_begin";
1763 case DW_AT_MIPS_loop_unroll_factor
: return "DW_AT_MIPS_loop_unroll_factor";
1764 case DW_AT_MIPS_software_pipeline_depth
: return "DW_AT_MIPS_software_pipeline_depth";
1765 case DW_AT_MIPS_linkage_name
: return "DW_AT_MIPS_linkage_name";
1766 case DW_AT_MIPS_stride
: return "DW_AT_MIPS_stride";
1767 case DW_AT_MIPS_abstract_name
: return "DW_AT_MIPS_abstract_name";
1768 case DW_AT_MIPS_clone_origin
: return "DW_AT_MIPS_clone_origin";
1769 case DW_AT_MIPS_has_inlines
: return "DW_AT_MIPS_has_inlines";
1771 /* HP Extensions. */
1772 case DW_AT_HP_block_index
: return "DW_AT_HP_block_index";
1773 case DW_AT_HP_actuals_stmt_list
: return "DW_AT_HP_actuals_stmt_list";
1774 case DW_AT_HP_proc_per_section
: return "DW_AT_HP_proc_per_section";
1775 case DW_AT_HP_raw_data_ptr
: return "DW_AT_HP_raw_data_ptr";
1776 case DW_AT_HP_pass_by_reference
: return "DW_AT_HP_pass_by_reference";
1777 case DW_AT_HP_opt_level
: return "DW_AT_HP_opt_level";
1778 case DW_AT_HP_prof_version_id
: return "DW_AT_HP_prof_version_id";
1779 case DW_AT_HP_opt_flags
: return "DW_AT_HP_opt_flags";
1780 case DW_AT_HP_cold_region_low_pc
: return "DW_AT_HP_cold_region_low_pc";
1781 case DW_AT_HP_cold_region_high_pc
: return "DW_AT_HP_cold_region_high_pc";
1782 case DW_AT_HP_all_variables_modifiable
: return "DW_AT_HP_all_variables_modifiable";
1783 case DW_AT_HP_linkage_name
: return "DW_AT_HP_linkage_name";
1784 case DW_AT_HP_prof_flags
: return "DW_AT_HP_prof_flags";
1786 /* One value is shared by the MIPS and HP extensions: */
1787 case DW_AT_MIPS_fde
: return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable";
1789 /* GNU extensions. */
1790 case DW_AT_sf_names
: return "DW_AT_sf_names";
1791 case DW_AT_src_info
: return "DW_AT_src_info";
1792 case DW_AT_mac_info
: return "DW_AT_mac_info";
1793 case DW_AT_src_coords
: return "DW_AT_src_coords";
1794 case DW_AT_body_begin
: return "DW_AT_body_begin";
1795 case DW_AT_body_end
: return "DW_AT_body_end";
1796 case DW_AT_GNU_vector
: return "DW_AT_GNU_vector";
1797 case DW_AT_GNU_guarded_by
: return "DW_AT_GNU_guarded_by";
1798 case DW_AT_GNU_pt_guarded_by
: return "DW_AT_GNU_pt_guarded_by";
1799 case DW_AT_GNU_guarded
: return "DW_AT_GNU_guarded";
1800 case DW_AT_GNU_pt_guarded
: return "DW_AT_GNU_pt_guarded";
1801 case DW_AT_GNU_locks_excluded
: return "DW_AT_GNU_locks_excluded";
1802 case DW_AT_GNU_exclusive_locks_required
: return "DW_AT_GNU_exclusive_locks_required";
1803 case DW_AT_GNU_shared_locks_required
: return "DW_AT_GNU_shared_locks_required";
1804 case DW_AT_GNU_odr_signature
: return "DW_AT_GNU_odr_signature";
1806 /* UPC extension. */
1807 case DW_AT_upc_threads_scaled
: return "DW_AT_upc_threads_scaled";
1809 /* PGI (STMicroelectronics) extensions. */
1810 case DW_AT_PGI_lbase
: return "DW_AT_PGI_lbase";
1811 case DW_AT_PGI_soffset
: return "DW_AT_PGI_soffset";
1812 case DW_AT_PGI_lstride
: return "DW_AT_PGI_lstride";
1816 static char buffer
[100];
1818 snprintf (buffer
, sizeof (buffer
), _("Unknown AT value: %lx"),
1825 static unsigned char *
1826 read_and_display_attr (unsigned long attribute
,
1828 unsigned char * data
,
1829 unsigned long cu_offset
,
1830 unsigned long pointer_size
,
1831 unsigned long offset_size
,
1833 debug_info
* debug_info_p
,
1835 struct dwarf_section
* section
)
1838 printf (" %-18s:", get_AT_name (attribute
));
1839 data
= read_and_display_attr_value (attribute
, form
, data
, cu_offset
,
1840 pointer_size
, offset_size
,
1841 dwarf_version
, debug_info_p
,
1849 /* Process the contents of a .debug_info section. If do_loc is non-zero
1850 then we are scanning for location lists and we do not want to display
1851 anything to the user. If do_types is non-zero, we are processing
1852 a .debug_types section instead of a .debug_info section. */
1855 process_debug_info (struct dwarf_section
*section
,
1860 unsigned char *start
= section
->start
;
1861 unsigned char *end
= start
+ section
->size
;
1862 unsigned char *section_begin
;
1864 unsigned int num_units
= 0;
1866 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1867 && num_debug_info_entries
== 0
1870 unsigned long length
;
1872 /* First scan the section to get the number of comp units. */
1873 for (section_begin
= start
, num_units
= 0; section_begin
< end
;
1876 /* Read the first 4 bytes. For a 32-bit DWARF section, this
1877 will be the length. For a 64-bit DWARF section, it'll be
1878 the escape code 0xffffffff followed by an 8 byte length. */
1879 length
= byte_get (section_begin
, 4);
1881 if (length
== 0xffffffff)
1883 length
= byte_get (section_begin
+ 4, 8);
1884 section_begin
+= length
+ 12;
1886 else if (length
>= 0xfffffff0 && length
< 0xffffffff)
1888 warn (_("Reserved length value (%lx) found in section %s\n"), length
, section
->name
);
1892 section_begin
+= length
+ 4;
1894 /* Negative values are illegal, they may even cause infinite
1895 looping. This can happen if we can't accurately apply
1896 relocations to an object file. */
1897 if ((signed long) length
<= 0)
1899 warn (_("Corrupt unit length (%lx) found in section %s\n"), length
, section
->name
);
1906 error (_("No comp units in %s section ?"), section
->name
);
1910 /* Then allocate an array to hold the information. */
1911 debug_information
= (debug_info
*) cmalloc (num_units
,
1912 sizeof (* debug_information
));
1913 if (debug_information
== NULL
)
1915 error (_("Not enough memory for a debug info array of %u entries"),
1923 printf (_("Contents of the %s section:\n\n"), section
->name
);
1925 load_debug_section (str
, file
);
1928 load_debug_section (abbrev
, file
);
1929 if (debug_displays
[abbrev
].section
.start
== NULL
)
1931 warn (_("Unable to locate %s section!\n"),
1932 debug_displays
[abbrev
].section
.name
);
1936 for (section_begin
= start
, unit
= 0; start
< end
; unit
++)
1938 DWARF2_Internal_CompUnit compunit
;
1939 unsigned char *hdrptr
;
1940 unsigned char *cu_abbrev_offset_ptr
;
1941 unsigned char *tags
;
1943 unsigned long cu_offset
;
1945 int initial_length_size
;
1946 unsigned char signature
[8];
1947 unsigned long type_offset
= 0;
1951 compunit
.cu_length
= byte_get (hdrptr
, 4);
1954 if (compunit
.cu_length
== 0xffffffff)
1956 compunit
.cu_length
= byte_get (hdrptr
, 8);
1959 initial_length_size
= 12;
1964 initial_length_size
= 4;
1967 compunit
.cu_version
= byte_get (hdrptr
, 2);
1970 cu_offset
= start
- section_begin
;
1972 cu_abbrev_offset_ptr
= hdrptr
;
1973 compunit
.cu_abbrev_offset
= byte_get (hdrptr
, offset_size
);
1974 hdrptr
+= offset_size
;
1976 compunit
.cu_pointer_size
= byte_get (hdrptr
, 1);
1983 for (i
= 0; i
< 8; i
++)
1985 signature
[i
] = byte_get (hdrptr
, 1);
1989 type_offset
= byte_get (hdrptr
, offset_size
);
1990 hdrptr
+= offset_size
;
1993 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1994 && num_debug_info_entries
== 0
1997 debug_information
[unit
].cu_offset
= cu_offset
;
1998 debug_information
[unit
].pointer_size
1999 = compunit
.cu_pointer_size
;
2000 debug_information
[unit
].base_address
= 0;
2001 debug_information
[unit
].loc_offsets
= NULL
;
2002 debug_information
[unit
].have_frame_base
= NULL
;
2003 debug_information
[unit
].max_loc_offsets
= 0;
2004 debug_information
[unit
].num_loc_offsets
= 0;
2005 debug_information
[unit
].range_lists
= NULL
;
2006 debug_information
[unit
].max_range_lists
= 0;
2007 debug_information
[unit
].num_range_lists
= 0;
2012 printf (_(" Compilation Unit @ offset 0x%lx:\n"), cu_offset
);
2013 printf (_(" Length: 0x%lx (%s)\n"), compunit
.cu_length
,
2014 initial_length_size
== 8 ? "64-bit" : "32-bit");
2015 printf (_(" Version: %d\n"), compunit
.cu_version
);
2016 printf (_(" Abbrev Offset: %ld\n"), compunit
.cu_abbrev_offset
);
2017 printf (_(" Pointer Size: %d\n"), compunit
.cu_pointer_size
);
2021 printf (_(" Signature: "));
2022 for (i
= 0; i
< 8; i
++)
2023 printf ("%02x", signature
[i
]);
2025 printf (_(" Type Offset: 0x%lx\n"), type_offset
);
2029 if (cu_offset
+ compunit
.cu_length
+ initial_length_size
2032 warn (_("Debug info is corrupted, length of CU at %lx extends beyond end of section (length = %lx)\n"),
2033 cu_offset
, compunit
.cu_length
);
2037 start
+= compunit
.cu_length
+ initial_length_size
;
2039 if (compunit
.cu_version
!= 2 && compunit
.cu_version
!= 3)
2041 warn (_("CU at offset %lx contains corrupt or unsupported version number: %d.\n"),
2042 cu_offset
, compunit
.cu_version
);
2048 /* Process the abbrevs used by this compilation unit. DWARF
2049 sections under Mach-O have non-zero addresses. */
2050 if (compunit
.cu_abbrev_offset
>= debug_displays
[abbrev
].section
.size
)
2051 warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"),
2052 (unsigned long) compunit
.cu_abbrev_offset
,
2053 (unsigned long) debug_displays
[abbrev
].section
.size
);
2055 process_abbrev_section
2056 ((unsigned char *) debug_displays
[abbrev
].section
.start
2057 + compunit
.cu_abbrev_offset
- debug_displays
[abbrev
].section
.address
,
2058 (unsigned char *) debug_displays
[abbrev
].section
.start
2059 + debug_displays
[abbrev
].section
.size
);
2062 while (tags
< start
)
2064 unsigned int bytes_read
;
2065 unsigned long abbrev_number
;
2066 unsigned long die_offset
;
2067 abbrev_entry
*entry
;
2070 die_offset
= tags
- section_begin
;
2072 abbrev_number
= read_leb128 (tags
, & bytes_read
, 0);
2075 /* A null DIE marks the end of a list of siblings or it may also be
2076 a section padding. */
2077 if (abbrev_number
== 0)
2079 /* Check if it can be a section padding for the last CU. */
2080 if (level
== 0 && start
== end
)
2084 for (chk
= tags
; chk
< start
; chk
++)
2094 static unsigned num_bogus_warns
= 0;
2096 if (num_bogus_warns
< 3)
2098 warn (_("Bogus end-of-siblings marker detected at offset %lx in .debug_info section\n"),
2101 if (num_bogus_warns
== 3)
2102 warn (_("Further warnings about bogus end-of-sibling markers suppressed\n"));
2109 printf (_(" <%d><%lx>: Abbrev Number: %lu"),
2110 level
, die_offset
, abbrev_number
);
2112 /* Scan through the abbreviation list until we reach the
2114 for (entry
= first_abbrev
;
2115 entry
&& entry
->entry
!= abbrev_number
;
2116 entry
= entry
->next
)
2126 warn (_("DIE at offset %lx refers to abbreviation number %lu which does not exist\n"),
2127 die_offset
, abbrev_number
);
2132 printf (_(" (%s)\n"), get_TAG_name (entry
->tag
));
2137 need_base_address
= 0;
2139 case DW_TAG_compile_unit
:
2140 need_base_address
= 1;
2142 case DW_TAG_entry_point
:
2143 case DW_TAG_subprogram
:
2144 need_base_address
= 0;
2145 /* Assuming that there is no DW_AT_frame_base. */
2146 have_frame_base
= 0;
2150 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
2153 /* Show the offset from where the tag was extracted. */
2154 printf (" <%2lx>", (unsigned long)(tags
- section_begin
));
2156 tags
= read_and_display_attr (attr
->attribute
,
2159 compunit
.cu_pointer_size
,
2161 compunit
.cu_version
,
2162 debug_information
+ unit
,
2166 if (entry
->children
)
2171 /* Set num_debug_info_entries here so that it can be used to check if
2172 we need to process .debug_loc and .debug_ranges sections. */
2173 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2174 && num_debug_info_entries
== 0
2176 num_debug_info_entries
= num_units
;
2186 /* Locate and scan the .debug_info section in the file and record the pointer
2187 sizes and offsets for the compilation units in it. Usually an executable
2188 will have just one pointer size, but this is not guaranteed, and so we try
2189 not to make any assumptions. Returns zero upon failure, or the number of
2190 compilation units upon success. */
2193 load_debug_info (void * file
)
2195 /* Reset the last pointer size so that we can issue correct error
2196 messages if we are displaying the contents of more than one section. */
2197 last_pointer_size
= 0;
2198 warned_about_missing_comp_units
= FALSE
;
2200 /* If we have already tried and failed to load the .debug_info
2201 section then do not bother to repear the task. */
2202 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
2205 /* If we already have the information there is nothing else to do. */
2206 if (num_debug_info_entries
> 0)
2207 return num_debug_info_entries
;
2209 if (load_debug_section (info
, file
)
2210 && process_debug_info (&debug_displays
[info
].section
, file
, 1, 0))
2211 return num_debug_info_entries
;
2213 num_debug_info_entries
= DEBUG_INFO_UNAVAILABLE
;
2218 display_debug_lines_raw (struct dwarf_section
*section
,
2219 unsigned char *data
,
2222 unsigned char *start
= section
->start
;
2224 printf (_("Raw dump of debug contents of section %s:\n\n"),
2229 DWARF2_Internal_LineInfo linfo
;
2230 unsigned char *standard_opcodes
;
2231 unsigned char *end_of_sequence
;
2232 unsigned char *hdrptr
;
2233 unsigned long hdroff
;
2234 int initial_length_size
;
2239 hdroff
= hdrptr
- start
;
2241 /* Check the length of the block. */
2242 linfo
.li_length
= byte_get (hdrptr
, 4);
2245 if (linfo
.li_length
== 0xffffffff)
2247 /* This section is 64-bit DWARF 3. */
2248 linfo
.li_length
= byte_get (hdrptr
, 8);
2251 initial_length_size
= 12;
2256 initial_length_size
= 4;
2259 if (linfo
.li_length
+ initial_length_size
> section
->size
)
2262 (_("The information in section %s appears to be corrupt - the section is too small\n"),
2267 /* Check its version number. */
2268 linfo
.li_version
= byte_get (hdrptr
, 2);
2270 if (linfo
.li_version
!= 2 && linfo
.li_version
!= 3)
2272 warn (_("Only DWARF version 2 and 3 line info is currently supported.\n"));
2276 linfo
.li_prologue_length
= byte_get (hdrptr
, offset_size
);
2277 hdrptr
+= offset_size
;
2278 linfo
.li_min_insn_length
= byte_get (hdrptr
, 1);
2280 linfo
.li_default_is_stmt
= byte_get (hdrptr
, 1);
2282 linfo
.li_line_base
= byte_get (hdrptr
, 1);
2284 linfo
.li_line_range
= byte_get (hdrptr
, 1);
2286 linfo
.li_opcode_base
= byte_get (hdrptr
, 1);
2289 /* Sign extend the line base field. */
2290 linfo
.li_line_base
<<= 24;
2291 linfo
.li_line_base
>>= 24;
2293 printf (_(" Offset: 0x%lx\n"), hdroff
);
2294 printf (_(" Length: %ld\n"), linfo
.li_length
);
2295 printf (_(" DWARF Version: %d\n"), linfo
.li_version
);
2296 printf (_(" Prologue Length: %d\n"), linfo
.li_prologue_length
);
2297 printf (_(" Minimum Instruction Length: %d\n"), linfo
.li_min_insn_length
);
2298 printf (_(" Initial value of 'is_stmt': %d\n"), linfo
.li_default_is_stmt
);
2299 printf (_(" Line Base: %d\n"), linfo
.li_line_base
);
2300 printf (_(" Line Range: %d\n"), linfo
.li_line_range
);
2301 printf (_(" Opcode Base: %d\n"), linfo
.li_opcode_base
);
2303 end_of_sequence
= data
+ linfo
.li_length
+ initial_length_size
;
2305 reset_state_machine (linfo
.li_default_is_stmt
);
2307 /* Display the contents of the Opcodes table. */
2308 standard_opcodes
= hdrptr
;
2310 printf (_("\n Opcodes:\n"));
2312 for (i
= 1; i
< linfo
.li_opcode_base
; i
++)
2313 printf (_(" Opcode %d has %d args\n"), i
, standard_opcodes
[i
- 1]);
2315 /* Display the contents of the Directory table. */
2316 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
2319 printf (_("\n The Directory Table is empty.\n"));
2322 printf (_("\n The Directory Table:\n"));
2326 printf (_(" %s\n"), data
);
2328 data
+= strlen ((char *) data
) + 1;
2332 /* Skip the NUL at the end of the table. */
2335 /* Display the contents of the File Name table. */
2337 printf (_("\n The File Name Table is empty.\n"));
2340 printf (_("\n The File Name Table:\n"));
2341 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
2345 unsigned char *name
;
2346 unsigned int bytes_read
;
2348 printf (_(" %d\t"), ++state_machine_regs
.last_file_entry
);
2351 data
+= strlen ((char *) data
) + 1;
2353 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
2355 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
2357 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
2359 printf (_("%s\n"), name
);
2363 /* Skip the NUL at the end of the table. */
2366 /* Now display the statements. */
2367 printf (_("\n Line Number Statements:\n"));
2369 while (data
< end_of_sequence
)
2371 unsigned char op_code
;
2373 unsigned long int uladv
;
2374 unsigned int bytes_read
;
2378 if (op_code
>= linfo
.li_opcode_base
)
2380 op_code
-= linfo
.li_opcode_base
;
2381 uladv
= (op_code
/ linfo
.li_line_range
) * linfo
.li_min_insn_length
;
2382 state_machine_regs
.address
+= uladv
;
2383 printf (_(" Special opcode %d: advance Address by %lu to 0x%lx"),
2384 op_code
, uladv
, state_machine_regs
.address
);
2385 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
2386 state_machine_regs
.line
+= adv
;
2387 printf (_(" and Line by %d to %d\n"),
2388 adv
, state_machine_regs
.line
);
2390 else switch (op_code
)
2392 case DW_LNS_extended_op
:
2393 data
+= process_extended_line_op (data
, linfo
.li_default_is_stmt
);
2397 printf (_(" Copy\n"));
2400 case DW_LNS_advance_pc
:
2401 uladv
= read_leb128 (data
, & bytes_read
, 0);
2402 uladv
*= linfo
.li_min_insn_length
;
2404 state_machine_regs
.address
+= uladv
;
2405 printf (_(" Advance PC by %lu to 0x%lx\n"), uladv
,
2406 state_machine_regs
.address
);
2409 case DW_LNS_advance_line
:
2410 adv
= read_leb128 (data
, & bytes_read
, 1);
2412 state_machine_regs
.line
+= adv
;
2413 printf (_(" Advance Line by %d to %d\n"), adv
,
2414 state_machine_regs
.line
);
2417 case DW_LNS_set_file
:
2418 adv
= read_leb128 (data
, & bytes_read
, 0);
2420 printf (_(" Set File Name to entry %d in the File Name Table\n"),
2422 state_machine_regs
.file
= adv
;
2425 case DW_LNS_set_column
:
2426 uladv
= read_leb128 (data
, & bytes_read
, 0);
2428 printf (_(" Set column to %lu\n"), uladv
);
2429 state_machine_regs
.column
= uladv
;
2432 case DW_LNS_negate_stmt
:
2433 adv
= state_machine_regs
.is_stmt
;
2435 printf (_(" Set is_stmt to %d\n"), adv
);
2436 state_machine_regs
.is_stmt
= adv
;
2439 case DW_LNS_set_basic_block
:
2440 printf (_(" Set basic block\n"));
2441 state_machine_regs
.basic_block
= 1;
2444 case DW_LNS_const_add_pc
:
2445 uladv
= (((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
)
2446 * linfo
.li_min_insn_length
);
2447 state_machine_regs
.address
+= uladv
;
2448 printf (_(" Advance PC by constant %lu to 0x%lx\n"), uladv
,
2449 state_machine_regs
.address
);
2452 case DW_LNS_fixed_advance_pc
:
2453 uladv
= byte_get (data
, 2);
2455 state_machine_regs
.address
+= uladv
;
2456 printf (_(" Advance PC by fixed size amount %lu to 0x%lx\n"),
2457 uladv
, state_machine_regs
.address
);
2460 case DW_LNS_set_prologue_end
:
2461 printf (_(" Set prologue_end to true\n"));
2464 case DW_LNS_set_epilogue_begin
:
2465 printf (_(" Set epilogue_begin to true\n"));
2468 case DW_LNS_set_isa
:
2469 uladv
= read_leb128 (data
, & bytes_read
, 0);
2471 printf (_(" Set ISA to %lu\n"), uladv
);
2475 printf (_(" Unknown opcode %d with operands: "), op_code
);
2477 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
2479 printf ("0x%lx%s", read_leb128 (data
, &bytes_read
, 0),
2480 i
== 1 ? "" : ", ");
2495 unsigned char *name
;
2496 unsigned int directory_index
;
2497 unsigned int modification_date
;
2498 unsigned int length
;
2501 /* Output a decoded representation of the .debug_line section. */
2504 display_debug_lines_decoded (struct dwarf_section
*section
,
2505 unsigned char *data
,
2508 printf (_("Decoded dump of debug contents of section %s:\n\n"),
2513 /* This loop amounts to one iteration per compilation unit. */
2514 DWARF2_Internal_LineInfo linfo
;
2515 unsigned char *standard_opcodes
;
2516 unsigned char *end_of_sequence
;
2517 unsigned char *hdrptr
;
2518 int initial_length_size
;
2521 File_Entry
*file_table
= NULL
;
2522 unsigned char **directory_table
= NULL
;
2523 unsigned int prev_line
= 0;
2527 /* Extract information from the Line Number Program Header.
2528 (section 6.2.4 in the Dwarf3 doc). */
2530 /* Get the length of this CU's line number information block. */
2531 linfo
.li_length
= byte_get (hdrptr
, 4);
2534 if (linfo
.li_length
== 0xffffffff)
2536 /* This section is 64-bit DWARF 3. */
2537 linfo
.li_length
= byte_get (hdrptr
, 8);
2540 initial_length_size
= 12;
2545 initial_length_size
= 4;
2548 if (linfo
.li_length
+ initial_length_size
> section
->size
)
2550 warn (_("The line info appears to be corrupt - "
2551 "the section is too small\n"));
2555 /* Get this CU's Line Number Block version number. */
2556 linfo
.li_version
= byte_get (hdrptr
, 2);
2558 if (linfo
.li_version
!= 2 && linfo
.li_version
!= 3)
2560 warn (_("Only DWARF version 2 and 3 line info is currently "
2565 linfo
.li_prologue_length
= byte_get (hdrptr
, offset_size
);
2566 hdrptr
+= offset_size
;
2567 linfo
.li_min_insn_length
= byte_get (hdrptr
, 1);
2569 linfo
.li_default_is_stmt
= byte_get (hdrptr
, 1);
2571 linfo
.li_line_base
= byte_get (hdrptr
, 1);
2573 linfo
.li_line_range
= byte_get (hdrptr
, 1);
2575 linfo
.li_opcode_base
= byte_get (hdrptr
, 1);
2578 /* Sign extend the line base field. */
2579 linfo
.li_line_base
<<= 24;
2580 linfo
.li_line_base
>>= 24;
2582 /* Find the end of this CU's Line Number Information Block. */
2583 end_of_sequence
= data
+ linfo
.li_length
+ initial_length_size
;
2585 reset_state_machine (linfo
.li_default_is_stmt
);
2587 /* Save a pointer to the contents of the Opcodes table. */
2588 standard_opcodes
= hdrptr
;
2590 /* Traverse the Directory table just to count entries. */
2591 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
2594 unsigned int n_directories
= 0;
2595 unsigned char *ptr_directory_table
= data
;
2599 data
+= strlen ((char *) data
) + 1;
2603 /* Go through the directory table again to save the directories. */
2604 directory_table
= (unsigned char **)
2605 xmalloc (n_directories
* sizeof (unsigned char *));
2608 while (*ptr_directory_table
!= 0)
2610 directory_table
[i
] = ptr_directory_table
;
2611 ptr_directory_table
+= strlen ((char *) ptr_directory_table
) + 1;
2615 /* Skip the NUL at the end of the table. */
2618 /* Traverse the File Name table just to count the entries. */
2621 unsigned int n_files
= 0;
2622 unsigned char *ptr_file_name_table
= data
;
2626 unsigned int bytes_read
;
2628 /* Skip Name, directory index, last modification time and length
2630 data
+= strlen ((char *) data
) + 1;
2631 read_leb128 (data
, & bytes_read
, 0);
2633 read_leb128 (data
, & bytes_read
, 0);
2635 read_leb128 (data
, & bytes_read
, 0);
2641 /* Go through the file table again to save the strings. */
2642 file_table
= (File_Entry
*) xmalloc (n_files
* sizeof (File_Entry
));
2645 while (*ptr_file_name_table
!= 0)
2647 unsigned int bytes_read
;
2649 file_table
[i
].name
= ptr_file_name_table
;
2650 ptr_file_name_table
+= strlen ((char *) ptr_file_name_table
) + 1;
2652 /* We are not interested in directory, time or size. */
2653 file_table
[i
].directory_index
= read_leb128 (ptr_file_name_table
,
2655 ptr_file_name_table
+= bytes_read
;
2656 file_table
[i
].modification_date
= read_leb128 (ptr_file_name_table
,
2658 ptr_file_name_table
+= bytes_read
;
2659 file_table
[i
].length
= read_leb128 (ptr_file_name_table
, & bytes_read
, 0);
2660 ptr_file_name_table
+= bytes_read
;
2665 /* Print the Compilation Unit's name and a header. */
2666 if (directory_table
== NULL
)
2668 printf (_("CU: %s:\n"), file_table
[0].name
);
2669 printf (_("File name Line number Starting address\n"));
2673 if (do_wide
|| strlen ((char *) directory_table
[0]) < 76)
2675 printf (_("CU: %s/%s:\n"), directory_table
[0],
2676 file_table
[0].name
);
2680 printf (_("%s:\n"), file_table
[0].name
);
2682 printf (_("File name Line number Starting address\n"));
2686 /* Skip the NUL at the end of the table. */
2689 /* This loop iterates through the Dwarf Line Number Program. */
2690 while (data
< end_of_sequence
)
2692 unsigned char op_code
;
2694 unsigned long int uladv
;
2695 unsigned int bytes_read
;
2696 int is_special_opcode
= 0;
2699 prev_line
= state_machine_regs
.line
;
2701 if (op_code
>= linfo
.li_opcode_base
)
2703 op_code
-= linfo
.li_opcode_base
;
2704 uladv
= (op_code
/ linfo
.li_line_range
) * linfo
.li_min_insn_length
;
2705 state_machine_regs
.address
+= uladv
;
2707 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
2708 state_machine_regs
.line
+= adv
;
2709 is_special_opcode
= 1;
2711 else switch (op_code
)
2713 case DW_LNS_extended_op
:
2715 unsigned int ext_op_code_len
;
2716 unsigned char ext_op_code
;
2717 unsigned char *op_code_data
= data
;
2719 ext_op_code_len
= read_leb128 (op_code_data
, &bytes_read
, 0);
2720 op_code_data
+= bytes_read
;
2722 if (ext_op_code_len
== 0)
2724 warn (_("badly formed extended line op encountered!\n"));
2727 ext_op_code_len
+= bytes_read
;
2728 ext_op_code
= *op_code_data
++;
2730 switch (ext_op_code
)
2732 case DW_LNE_end_sequence
:
2733 reset_state_machine (linfo
.li_default_is_stmt
);
2735 case DW_LNE_set_address
:
2736 state_machine_regs
.address
=
2737 byte_get (op_code_data
, ext_op_code_len
- bytes_read
- 1);
2739 case DW_LNE_define_file
:
2741 unsigned int dir_index
= 0;
2743 ++state_machine_regs
.last_file_entry
;
2744 op_code_data
+= strlen ((char *) op_code_data
) + 1;
2745 dir_index
= read_leb128 (op_code_data
, & bytes_read
, 0);
2746 op_code_data
+= bytes_read
;
2747 read_leb128 (op_code_data
, & bytes_read
, 0);
2748 op_code_data
+= bytes_read
;
2749 read_leb128 (op_code_data
, & bytes_read
, 0);
2751 printf (_("%s:\n"), directory_table
[dir_index
]);
2755 printf (_("UNKNOWN: length %d\n"), ext_op_code_len
- bytes_read
);
2758 data
+= ext_op_code_len
;
2764 case DW_LNS_advance_pc
:
2765 uladv
= read_leb128 (data
, & bytes_read
, 0);
2766 uladv
*= linfo
.li_min_insn_length
;
2768 state_machine_regs
.address
+= uladv
;
2771 case DW_LNS_advance_line
:
2772 adv
= read_leb128 (data
, & bytes_read
, 1);
2774 state_machine_regs
.line
+= adv
;
2777 case DW_LNS_set_file
:
2778 adv
= read_leb128 (data
, & bytes_read
, 0);
2780 state_machine_regs
.file
= adv
;
2781 if (file_table
[state_machine_regs
.file
- 1].directory_index
== 0)
2783 /* If directory index is 0, that means current directory. */
2784 printf (_("\n./%s:[++]\n"),
2785 file_table
[state_machine_regs
.file
- 1].name
);
2789 /* The directory index starts counting at 1. */
2790 printf (_("\n%s/%s:\n"),
2791 directory_table
[file_table
[state_machine_regs
.file
- 1].directory_index
- 1],
2792 file_table
[state_machine_regs
.file
- 1].name
);
2796 case DW_LNS_set_column
:
2797 uladv
= read_leb128 (data
, & bytes_read
, 0);
2799 state_machine_regs
.column
= uladv
;
2802 case DW_LNS_negate_stmt
:
2803 adv
= state_machine_regs
.is_stmt
;
2805 state_machine_regs
.is_stmt
= adv
;
2808 case DW_LNS_set_basic_block
:
2809 state_machine_regs
.basic_block
= 1;
2812 case DW_LNS_const_add_pc
:
2813 uladv
= (((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
)
2814 * linfo
.li_min_insn_length
);
2815 state_machine_regs
.address
+= uladv
;
2818 case DW_LNS_fixed_advance_pc
:
2819 uladv
= byte_get (data
, 2);
2821 state_machine_regs
.address
+= uladv
;
2824 case DW_LNS_set_prologue_end
:
2827 case DW_LNS_set_epilogue_begin
:
2830 case DW_LNS_set_isa
:
2831 uladv
= read_leb128 (data
, & bytes_read
, 0);
2833 printf (_(" Set ISA to %lu\n"), uladv
);
2837 printf (_(" Unknown opcode %d with operands: "), op_code
);
2839 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
2841 printf ("0x%lx%s", read_leb128 (data
, &bytes_read
, 0),
2842 i
== 1 ? "" : ", ");
2849 /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row
2850 to the DWARF address/line matrix. */
2851 if ((is_special_opcode
) || (op_code
== DW_LNE_end_sequence
)
2852 || (op_code
== DW_LNS_copy
))
2854 const unsigned int MAX_FILENAME_LENGTH
= 35;
2855 char *fileName
= (char *)file_table
[state_machine_regs
.file
- 1].name
;
2856 char *newFileName
= NULL
;
2857 size_t fileNameLength
= strlen (fileName
);
2859 if ((fileNameLength
> MAX_FILENAME_LENGTH
) && (!do_wide
))
2861 newFileName
= (char *) xmalloc (MAX_FILENAME_LENGTH
+ 1);
2862 /* Truncate file name */
2863 strncpy (newFileName
,
2864 fileName
+ fileNameLength
- MAX_FILENAME_LENGTH
,
2865 MAX_FILENAME_LENGTH
+ 1);
2869 newFileName
= (char *) xmalloc (fileNameLength
+ 1);
2870 strncpy (newFileName
, fileName
, fileNameLength
+ 1);
2873 if (!do_wide
|| (fileNameLength
<= MAX_FILENAME_LENGTH
))
2875 printf (_("%-35s %11d %#18lx\n"), newFileName
,
2876 state_machine_regs
.line
, state_machine_regs
.address
);
2880 printf (_("%s %11d %#18lx\n"), newFileName
,
2881 state_machine_regs
.line
, state_machine_regs
.address
);
2884 if (op_code
== DW_LNE_end_sequence
)
2892 free (directory_table
);
2893 directory_table
= NULL
;
2901 display_debug_lines (struct dwarf_section
*section
, void *file
)
2903 unsigned char *data
= section
->start
;
2904 unsigned char *end
= data
+ section
->size
;
2906 int retValDecoded
= 1;
2908 if (load_debug_info (file
) == 0)
2910 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
2915 if (do_debug_lines
== 0)
2916 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
2918 if (do_debug_lines
& FLAG_DEBUG_LINES_RAW
)
2919 retValRaw
= display_debug_lines_raw (section
, data
, end
);
2921 if (do_debug_lines
& FLAG_DEBUG_LINES_DECODED
)
2922 retValDecoded
= display_debug_lines_decoded (section
, data
, end
);
2924 if (!retValRaw
|| !retValDecoded
)
2931 find_debug_info_for_offset (unsigned long offset
)
2935 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
2938 for (i
= 0; i
< num_debug_info_entries
; i
++)
2939 if (debug_information
[i
].cu_offset
== offset
)
2940 return debug_information
+ i
;
2946 display_debug_pubnames (struct dwarf_section
*section
,
2947 void *file ATTRIBUTE_UNUSED
)
2949 DWARF2_Internal_PubNames names
;
2950 unsigned char *start
= section
->start
;
2951 unsigned char *end
= start
+ section
->size
;
2953 /* It does not matter if this load fails,
2954 we test for that later on. */
2955 load_debug_info (file
);
2957 printf (_("Contents of the %s section:\n\n"), section
->name
);
2961 unsigned char *data
;
2962 unsigned long offset
;
2963 int offset_size
, initial_length_size
;
2967 names
.pn_length
= byte_get (data
, 4);
2969 if (names
.pn_length
== 0xffffffff)
2971 names
.pn_length
= byte_get (data
, 8);
2974 initial_length_size
= 12;
2979 initial_length_size
= 4;
2982 names
.pn_version
= byte_get (data
, 2);
2985 names
.pn_offset
= byte_get (data
, offset_size
);
2986 data
+= offset_size
;
2988 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
2989 && num_debug_info_entries
> 0
2990 && find_debug_info_for_offset (names
.pn_offset
) == NULL
)
2991 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
2992 names
.pn_offset
, section
->name
);
2994 names
.pn_size
= byte_get (data
, offset_size
);
2995 data
+= offset_size
;
2997 start
+= names
.pn_length
+ initial_length_size
;
2999 if (names
.pn_version
!= 2 && names
.pn_version
!= 3)
3001 static int warned
= 0;
3005 warn (_("Only DWARF 2 and 3 pubnames are currently supported\n"));
3012 printf (_(" Length: %ld\n"),
3014 printf (_(" Version: %d\n"),
3016 printf (_(" Offset into .debug_info section: 0x%lx\n"),
3018 printf (_(" Size of area in .debug_info section: %ld\n"),
3021 printf (_("\n Offset\tName\n"));
3025 offset
= byte_get (data
, offset_size
);
3029 data
+= offset_size
;
3030 printf (" %-6lx\t%s\n", offset
, data
);
3031 data
+= strlen ((char *) data
) + 1;
3034 while (offset
!= 0);
3042 display_debug_macinfo (struct dwarf_section
*section
,
3043 void *file ATTRIBUTE_UNUSED
)
3045 unsigned char *start
= section
->start
;
3046 unsigned char *end
= start
+ section
->size
;
3047 unsigned char *curr
= start
;
3048 unsigned int bytes_read
;
3049 enum dwarf_macinfo_record_type op
;
3051 printf (_("Contents of the %s section:\n\n"), section
->name
);
3055 unsigned int lineno
;
3058 op
= (enum dwarf_macinfo_record_type
) *curr
;
3063 case DW_MACINFO_start_file
:
3065 unsigned int filenum
;
3067 lineno
= read_leb128 (curr
, & bytes_read
, 0);
3069 filenum
= read_leb128 (curr
, & bytes_read
, 0);
3072 printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"),
3077 case DW_MACINFO_end_file
:
3078 printf (_(" DW_MACINFO_end_file\n"));
3081 case DW_MACINFO_define
:
3082 lineno
= read_leb128 (curr
, & bytes_read
, 0);
3084 string
= (char *) curr
;
3085 curr
+= strlen (string
) + 1;
3086 printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"),
3090 case DW_MACINFO_undef
:
3091 lineno
= read_leb128 (curr
, & bytes_read
, 0);
3093 string
= (char *) curr
;
3094 curr
+= strlen (string
) + 1;
3095 printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"),
3099 case DW_MACINFO_vendor_ext
:
3101 unsigned int constant
;
3103 constant
= read_leb128 (curr
, & bytes_read
, 0);
3105 string
= (char *) curr
;
3106 curr
+= strlen (string
) + 1;
3107 printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"),
3118 display_debug_abbrev (struct dwarf_section
*section
,
3119 void *file ATTRIBUTE_UNUSED
)
3121 abbrev_entry
*entry
;
3122 unsigned char *start
= section
->start
;
3123 unsigned char *end
= start
+ section
->size
;
3125 printf (_("Contents of the %s section:\n\n"), section
->name
);
3131 start
= process_abbrev_section (start
, end
);
3133 if (first_abbrev
== NULL
)
3136 printf (_(" Number TAG\n"));
3138 for (entry
= first_abbrev
; entry
; entry
= entry
->next
)
3142 printf (_(" %ld %s [%s]\n"),
3144 get_TAG_name (entry
->tag
),
3145 entry
->children
? _("has children") : _("no children"));
3147 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
3148 printf (_(" %-18s %s\n"),
3149 get_AT_name (attr
->attribute
),
3150 get_FORM_name (attr
->form
));
3161 display_debug_loc (struct dwarf_section
*section
, void *file
)
3163 unsigned char *start
= section
->start
;
3164 unsigned char *section_end
;
3165 unsigned long bytes
;
3166 unsigned char *section_begin
= start
;
3167 unsigned int num_loc_list
= 0;
3168 unsigned long last_offset
= 0;
3169 unsigned int first
= 0;
3172 int seen_first_offset
= 0;
3173 int use_debug_info
= 1;
3174 unsigned char *next
;
3176 bytes
= section
->size
;
3177 section_end
= start
+ bytes
;
3181 printf (_("\nThe %s section is empty.\n"), section
->name
);
3185 if (load_debug_info (file
) == 0)
3187 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
3192 /* Check the order of location list in .debug_info section. If
3193 offsets of location lists are in the ascending order, we can
3194 use `debug_information' directly. */
3195 for (i
= 0; i
< num_debug_info_entries
; i
++)
3199 num
= debug_information
[i
].num_loc_offsets
;
3200 num_loc_list
+= num
;
3202 /* Check if we can use `debug_information' directly. */
3203 if (use_debug_info
&& num
!= 0)
3205 if (!seen_first_offset
)
3207 /* This is the first location list. */
3208 last_offset
= debug_information
[i
].loc_offsets
[0];
3210 seen_first_offset
= 1;
3216 for (; j
< num
; j
++)
3219 debug_information
[i
].loc_offsets
[j
])
3224 last_offset
= debug_information
[i
].loc_offsets
[j
];
3229 if (!use_debug_info
)
3230 /* FIXME: Should we handle this case? */
3231 error (_("Location lists in .debug_info section aren't in ascending order!\n"));
3233 if (!seen_first_offset
)
3234 error (_("No location lists in .debug_info section!\n"));
3236 /* DWARF sections under Mach-O have non-zero addresses. */
3237 if (debug_information
[first
].num_loc_offsets
> 0
3238 && debug_information
[first
].loc_offsets
[0] != section
->address
)
3239 warn (_("Location lists in %s section start at 0x%lx\n"),
3240 section
->name
, debug_information
[first
].loc_offsets
[0]);
3242 printf (_("Contents of the %s section:\n\n"), section
->name
);
3243 printf (_(" Offset Begin End Expression\n"));
3245 seen_first_offset
= 0;
3246 for (i
= first
; i
< num_debug_info_entries
; i
++)
3250 unsigned short length
;
3251 unsigned long offset
;
3252 unsigned int pointer_size
;
3253 unsigned long cu_offset
;
3254 unsigned long base_address
;
3255 int need_frame_base
;
3258 pointer_size
= debug_information
[i
].pointer_size
;
3259 cu_offset
= debug_information
[i
].cu_offset
;
3261 for (j
= 0; j
< debug_information
[i
].num_loc_offsets
; j
++)
3263 has_frame_base
= debug_information
[i
].have_frame_base
[j
];
3264 /* DWARF sections under Mach-O have non-zero addresses. */
3265 offset
= debug_information
[i
].loc_offsets
[j
] - section
->address
;
3266 next
= section_begin
+ offset
;
3267 base_address
= debug_information
[i
].base_address
;
3269 if (!seen_first_offset
)
3270 seen_first_offset
= 1;
3274 warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"),
3275 (unsigned long) (start
- section_begin
),
3276 (unsigned long) (next
- section_begin
));
3277 else if (start
> next
)
3278 warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"),
3279 (unsigned long) (start
- section_begin
),
3280 (unsigned long) (next
- section_begin
));
3284 if (offset
>= bytes
)
3286 warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"),
3293 if (start
+ 2 * pointer_size
> section_end
)
3295 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3300 /* Note: we use sign extension here in order to be sure that
3301 we can detect the -1 escape value. Sign extension into the
3302 top 32 bits of a 32-bit address will not affect the values
3303 that we display since we always show hex values, and always
3304 the bottom 32-bits. */
3305 begin
= byte_get_signed (start
, pointer_size
);
3306 start
+= pointer_size
;
3307 end
= byte_get_signed (start
, pointer_size
);
3308 start
+= pointer_size
;
3310 printf (" %8.8lx ", offset
);
3312 if (begin
== 0 && end
== 0)
3314 printf (_("<End of list>\n"));
3318 /* Check base address specifiers. */
3319 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
3322 print_dwarf_vma (begin
, pointer_size
);
3323 print_dwarf_vma (end
, pointer_size
);
3324 printf (_("(base address)\n"));
3328 if (start
+ 2 > section_end
)
3330 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3335 length
= byte_get (start
, 2);
3338 if (start
+ length
> section_end
)
3340 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3345 print_dwarf_vma (begin
+ base_address
, pointer_size
);
3346 print_dwarf_vma (end
+ base_address
, pointer_size
);
3349 need_frame_base
= decode_location_expression (start
,
3352 cu_offset
, section
);
3355 if (need_frame_base
&& !has_frame_base
)
3356 printf (_(" [without DW_AT_frame_base]"));
3359 fputs (_(" (start == end)"), stdout
);
3360 else if (begin
> end
)
3361 fputs (_(" (start > end)"), stdout
);
3370 if (start
< section_end
)
3371 warn (_("There are %ld unused bytes at the end of section %s\n"),
3372 (long) (section_end
- start
), section
->name
);
3378 display_debug_str (struct dwarf_section
*section
,
3379 void *file ATTRIBUTE_UNUSED
)
3381 unsigned char *start
= section
->start
;
3382 unsigned long bytes
= section
->size
;
3383 dwarf_vma addr
= section
->address
;
3387 printf (_("\nThe %s section is empty.\n"), section
->name
);
3391 printf (_("Contents of the %s section:\n\n"), section
->name
);
3399 lbytes
= (bytes
> 16 ? 16 : bytes
);
3401 printf (" 0x%8.8lx ", (unsigned long) addr
);
3403 for (j
= 0; j
< 16; j
++)
3406 printf ("%2.2x", start
[j
]);
3414 for (j
= 0; j
< lbytes
; j
++)
3417 if (k
>= ' ' && k
< 0x80)
3436 display_debug_info (struct dwarf_section
*section
, void *file
)
3438 return process_debug_info (section
, file
, 0, 0);
3442 display_debug_types (struct dwarf_section
*section
, void *file
)
3444 return process_debug_info (section
, file
, 0, 1);
3448 display_debug_aranges (struct dwarf_section
*section
,
3449 void *file ATTRIBUTE_UNUSED
)
3451 unsigned char *start
= section
->start
;
3452 unsigned char *end
= start
+ section
->size
;
3454 printf (_("Contents of the %s section:\n\n"), section
->name
);
3456 /* It does not matter if this load fails,
3457 we test for that later on. */
3458 load_debug_info (file
);
3462 unsigned char *hdrptr
;
3463 DWARF2_Internal_ARange arange
;
3464 unsigned char *addr_ranges
;
3467 unsigned char address_size
;
3470 int initial_length_size
;
3474 arange
.ar_length
= byte_get (hdrptr
, 4);
3477 if (arange
.ar_length
== 0xffffffff)
3479 arange
.ar_length
= byte_get (hdrptr
, 8);
3482 initial_length_size
= 12;
3487 initial_length_size
= 4;
3490 arange
.ar_version
= byte_get (hdrptr
, 2);
3493 arange
.ar_info_offset
= byte_get (hdrptr
, offset_size
);
3494 hdrptr
+= offset_size
;
3496 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
3497 && num_debug_info_entries
> 0
3498 && find_debug_info_for_offset (arange
.ar_info_offset
) == NULL
)
3499 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
3500 arange
.ar_info_offset
, section
->name
);
3502 arange
.ar_pointer_size
= byte_get (hdrptr
, 1);
3505 arange
.ar_segment_size
= byte_get (hdrptr
, 1);
3508 if (arange
.ar_version
!= 2 && arange
.ar_version
!= 3)
3510 warn (_("Only DWARF 2 and 3 aranges are currently supported.\n"));
3514 printf (_(" Length: %ld\n"), arange
.ar_length
);
3515 printf (_(" Version: %d\n"), arange
.ar_version
);
3516 printf (_(" Offset into .debug_info: 0x%lx\n"), arange
.ar_info_offset
);
3517 printf (_(" Pointer Size: %d\n"), arange
.ar_pointer_size
);
3518 printf (_(" Segment Size: %d\n"), arange
.ar_segment_size
);
3520 address_size
= arange
.ar_pointer_size
+ arange
.ar_segment_size
;
3522 /* The DWARF spec does not require that the address size be a power
3523 of two, but we do. This will have to change if we ever encounter
3524 an uneven architecture. */
3525 if ((address_size
& (address_size
- 1)) != 0)
3527 warn (_("Pointer size + Segment size is not a power of two.\n"));
3531 if (address_size
> 4)
3532 printf (_("\n Address Length\n"));
3534 printf (_("\n Address Length\n"));
3536 addr_ranges
= hdrptr
;
3538 /* Must pad to an alignment boundary that is twice the address size. */
3539 excess
= (hdrptr
- start
) % (2 * address_size
);
3541 addr_ranges
+= (2 * address_size
) - excess
;
3543 start
+= arange
.ar_length
+ initial_length_size
;
3545 while (addr_ranges
+ 2 * address_size
<= start
)
3547 address
= byte_get (addr_ranges
, address_size
);
3549 addr_ranges
+= address_size
;
3551 length
= byte_get (addr_ranges
, address_size
);
3553 addr_ranges
+= address_size
;
3556 print_dwarf_vma (address
, address_size
);
3557 print_dwarf_vma (length
, address_size
);
3567 /* Each debug_information[x].range_lists[y] gets this representation for
3568 sorting purposes. */
3572 /* The debug_information[x].range_lists[y] value. */
3573 unsigned long ranges_offset
;
3575 /* Original debug_information to find parameters of the data. */
3576 debug_info
*debug_info_p
;
3579 /* Sort struct range_entry in ascending order of its RANGES_OFFSET. */
3582 range_entry_compar (const void *ap
, const void *bp
)
3584 const struct range_entry
*a_re
= (const struct range_entry
*) ap
;
3585 const struct range_entry
*b_re
= (const struct range_entry
*) bp
;
3586 const unsigned long a
= a_re
->ranges_offset
;
3587 const unsigned long b
= b_re
->ranges_offset
;
3589 return (a
> b
) - (b
> a
);
3593 display_debug_ranges (struct dwarf_section
*section
,
3594 void *file ATTRIBUTE_UNUSED
)
3596 unsigned char *start
= section
->start
;
3597 unsigned char *section_end
;
3598 unsigned long bytes
;
3599 unsigned char *section_begin
= start
;
3600 unsigned int num_range_list
, i
;
3601 struct range_entry
*range_entries
, *range_entry_fill
;
3603 bytes
= section
->size
;
3604 section_end
= start
+ bytes
;
3608 printf (_("\nThe %s section is empty.\n"), section
->name
);
3612 if (load_debug_info (file
) == 0)
3614 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
3620 for (i
= 0; i
< num_debug_info_entries
; i
++)
3621 num_range_list
+= debug_information
[i
].num_range_lists
;
3623 if (num_range_list
== 0)
3624 error (_("No range lists in .debug_info section!\n"));
3626 range_entries
= (struct range_entry
*)
3627 xmalloc (sizeof (*range_entries
) * num_range_list
);
3628 range_entry_fill
= range_entries
;
3630 for (i
= 0; i
< num_debug_info_entries
; i
++)
3632 debug_info
*debug_info_p
= &debug_information
[i
];
3635 for (j
= 0; j
< debug_info_p
->num_range_lists
; j
++)
3637 range_entry_fill
->ranges_offset
= debug_info_p
->range_lists
[j
];
3638 range_entry_fill
->debug_info_p
= debug_info_p
;
3643 qsort (range_entries
, num_range_list
, sizeof (*range_entries
),
3644 range_entry_compar
);
3646 /* DWARF sections under Mach-O have non-zero addresses. */
3647 if (range_entries
[0].ranges_offset
!= section
->address
)
3648 warn (_("Range lists in %s section start at 0x%lx\n"),
3649 section
->name
, range_entries
[0].ranges_offset
);
3651 printf (_("Contents of the %s section:\n\n"), section
->name
);
3652 printf (_(" Offset Begin End\n"));
3654 for (i
= 0; i
< num_range_list
; i
++)
3656 struct range_entry
*range_entry
= &range_entries
[i
];
3657 debug_info
*debug_info_p
= range_entry
->debug_info_p
;
3658 unsigned int pointer_size
;
3659 unsigned long offset
;
3660 unsigned char *next
;
3661 unsigned long base_address
;
3663 pointer_size
= debug_info_p
->pointer_size
;
3665 /* DWARF sections under Mach-O have non-zero addresses. */
3666 offset
= range_entry
->ranges_offset
- section
->address
;
3667 next
= section_begin
+ offset
;
3668 base_address
= debug_info_p
->base_address
;
3673 warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"),
3674 (unsigned long) (start
- section_begin
),
3675 (unsigned long) (next
- section_begin
), section
->name
);
3676 else if (start
> next
)
3677 warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"),
3678 (unsigned long) (start
- section_begin
),
3679 (unsigned long) (next
- section_begin
), section
->name
);
3688 /* Note: we use sign extension here in order to be sure that
3689 we can detect the -1 escape value. Sign extension into the
3690 top 32 bits of a 32-bit address will not affect the values
3691 that we display since we always show hex values, and always
3692 the bottom 32-bits. */
3693 begin
= byte_get_signed (start
, pointer_size
);
3694 start
+= pointer_size
;
3695 end
= byte_get_signed (start
, pointer_size
);
3696 start
+= pointer_size
;
3698 printf (" %8.8lx ", offset
);
3700 if (begin
== 0 && end
== 0)
3702 printf (_("<End of list>\n"));
3706 /* Check base address specifiers. */
3707 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
3710 print_dwarf_vma (begin
, pointer_size
);
3711 print_dwarf_vma (end
, pointer_size
);
3712 printf ("(base address)\n");
3716 print_dwarf_vma (begin
+ base_address
, pointer_size
);
3717 print_dwarf_vma (end
+ base_address
, pointer_size
);
3720 fputs (_("(start == end)"), stdout
);
3721 else if (begin
> end
)
3722 fputs (_("(start > end)"), stdout
);
3729 free (range_entries
);
3734 typedef struct Frame_Chunk
3736 struct Frame_Chunk
*next
;
3737 unsigned char *chunk_start
;
3739 /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
3740 short int *col_type
;
3743 unsigned int code_factor
;
3745 unsigned long pc_begin
;
3746 unsigned long pc_range
;
3750 unsigned char fde_encoding
;
3751 unsigned char cfa_exp
;
3755 static const char *const *dwarf_regnames
;
3756 static unsigned int dwarf_regnames_count
;
3758 /* A marker for a col_type that means this column was never referenced
3759 in the frame info. */
3760 #define DW_CFA_unreferenced (-1)
3762 /* Return 0 if not more space is needed, 1 if more space is needed,
3763 -1 for invalid reg. */
3766 frame_need_space (Frame_Chunk
*fc
, unsigned int reg
)
3768 int prev
= fc
->ncols
;
3770 if (reg
< (unsigned int) fc
->ncols
)
3773 if (dwarf_regnames_count
3774 && reg
> dwarf_regnames_count
)
3777 fc
->ncols
= reg
+ 1;
3778 fc
->col_type
= (short int *) xcrealloc (fc
->col_type
, fc
->ncols
,
3779 sizeof (short int));
3780 fc
->col_offset
= (int *) xcrealloc (fc
->col_offset
, fc
->ncols
, sizeof (int));
3782 while (prev
< fc
->ncols
)
3784 fc
->col_type
[prev
] = DW_CFA_unreferenced
;
3785 fc
->col_offset
[prev
] = 0;
3791 static const char *const dwarf_regnames_i386
[] =
3793 "eax", "ecx", "edx", "ebx",
3794 "esp", "ebp", "esi", "edi",
3795 "eip", "eflags", NULL
,
3796 "st0", "st1", "st2", "st3",
3797 "st4", "st5", "st6", "st7",
3799 "xmm0", "xmm1", "xmm2", "xmm3",
3800 "xmm4", "xmm5", "xmm6", "xmm7",
3801 "mm0", "mm1", "mm2", "mm3",
3802 "mm4", "mm5", "mm6", "mm7",
3803 "fcw", "fsw", "mxcsr",
3804 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
3808 static const char *const dwarf_regnames_x86_64
[] =
3810 "rax", "rdx", "rcx", "rbx",
3811 "rsi", "rdi", "rbp", "rsp",
3812 "r8", "r9", "r10", "r11",
3813 "r12", "r13", "r14", "r15",
3815 "xmm0", "xmm1", "xmm2", "xmm3",
3816 "xmm4", "xmm5", "xmm6", "xmm7",
3817 "xmm8", "xmm9", "xmm10", "xmm11",
3818 "xmm12", "xmm13", "xmm14", "xmm15",
3819 "st0", "st1", "st2", "st3",
3820 "st4", "st5", "st6", "st7",
3821 "mm0", "mm1", "mm2", "mm3",
3822 "mm4", "mm5", "mm6", "mm7",
3824 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
3825 "fs.base", "gs.base", NULL
, NULL
,
3827 "mxcsr", "fcw", "fsw"
3831 init_dwarf_regnames (unsigned int e_machine
)
3837 dwarf_regnames
= dwarf_regnames_i386
;
3838 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_i386
);
3842 dwarf_regnames
= dwarf_regnames_x86_64
;
3843 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_x86_64
);
3852 regname (unsigned int regno
, int row
)
3854 static char reg
[64];
3856 && regno
< dwarf_regnames_count
3857 && dwarf_regnames
[regno
] != NULL
)
3860 return dwarf_regnames
[regno
];
3861 snprintf (reg
, sizeof (reg
), "r%d (%s)", regno
,
3862 dwarf_regnames
[regno
]);
3865 snprintf (reg
, sizeof (reg
), "r%d", regno
);
3870 frame_display_row (Frame_Chunk
*fc
, int *need_col_headers
, int *max_regs
)
3875 if (*max_regs
< fc
->ncols
)
3876 *max_regs
= fc
->ncols
;
3878 if (*need_col_headers
)
3880 static const char *sloc
= " LOC";
3882 *need_col_headers
= 0;
3884 printf ("%-*s CFA ", eh_addr_size
* 2, sloc
);
3886 for (r
= 0; r
< *max_regs
; r
++)
3887 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
3892 printf ("%-5s ", regname (r
, 1));
3898 printf ("%0*lx ", eh_addr_size
* 2, fc
->pc_begin
);
3900 strcpy (tmp
, "exp");
3902 sprintf (tmp
, "%s%+d", regname (fc
->cfa_reg
, 1), fc
->cfa_offset
);
3903 printf ("%-8s ", tmp
);
3905 for (r
= 0; r
< fc
->ncols
; r
++)
3907 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
3909 switch (fc
->col_type
[r
])
3911 case DW_CFA_undefined
:
3914 case DW_CFA_same_value
:
3918 sprintf (tmp
, "c%+d", fc
->col_offset
[r
]);
3920 case DW_CFA_val_offset
:
3921 sprintf (tmp
, "v%+d", fc
->col_offset
[r
]);
3923 case DW_CFA_register
:
3924 sprintf (tmp
, "%s", regname (fc
->col_offset
[r
], 0));
3926 case DW_CFA_expression
:
3927 strcpy (tmp
, "exp");
3929 case DW_CFA_val_expression
:
3930 strcpy (tmp
, "vexp");
3933 strcpy (tmp
, "n/a");
3936 printf ("%-5s ", tmp
);
3942 #define GET(N) byte_get (start, N); start += N
3943 #define LEB() read_leb128 (start, & length_return, 0); start += length_return
3944 #define SLEB() read_leb128 (start, & length_return, 1); start += length_return
3947 display_debug_frames (struct dwarf_section
*section
,
3948 void *file ATTRIBUTE_UNUSED
)
3950 unsigned char *start
= section
->start
;
3951 unsigned char *end
= start
+ section
->size
;
3952 unsigned char *section_start
= start
;
3953 Frame_Chunk
*chunks
= 0;
3954 Frame_Chunk
*remembered_state
= 0;
3956 int is_eh
= strcmp (section
->name
, ".eh_frame") == 0;
3957 unsigned int length_return
;
3959 const char *bad_reg
= _("bad register: ");
3961 printf (_("Contents of the %s section:\n"), section
->name
);
3965 unsigned char *saved_start
;
3966 unsigned char *block_end
;
3967 unsigned long length
;
3968 unsigned long cie_id
;
3971 int need_col_headers
= 1;
3972 unsigned char *augmentation_data
= NULL
;
3973 unsigned long augmentation_data_len
= 0;
3974 int encoded_ptr_size
= eh_addr_size
;
3976 int initial_length_size
;
3978 saved_start
= start
;
3979 length
= byte_get (start
, 4); start
+= 4;
3983 printf ("\n%08lx ZERO terminator\n\n",
3984 (unsigned long)(saved_start
- section_start
));
3988 if (length
== 0xffffffff)
3990 length
= byte_get (start
, 8);
3993 initial_length_size
= 12;
3998 initial_length_size
= 4;
4001 block_end
= saved_start
+ length
+ initial_length_size
;
4002 if (block_end
> end
)
4004 warn ("Invalid length %#08lx in FDE at %#08lx\n",
4005 length
, (unsigned long)(saved_start
- section_start
));
4008 cie_id
= byte_get (start
, offset_size
); start
+= offset_size
;
4010 if (is_eh
? (cie_id
== 0) : (cie_id
== DW_CIE_ID
))
4014 fc
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
4015 memset (fc
, 0, sizeof (Frame_Chunk
));
4019 fc
->chunk_start
= saved_start
;
4021 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
4022 fc
->col_offset
= (int *) xmalloc (sizeof (int));
4023 frame_need_space (fc
, max_regs
- 1);
4027 fc
->augmentation
= (char *) start
;
4028 start
= (unsigned char *) strchr ((char *) start
, '\0') + 1;
4030 if (fc
->augmentation
[0] == 'z')
4032 fc
->code_factor
= LEB ();
4033 fc
->data_factor
= SLEB ();
4042 augmentation_data_len
= LEB ();
4043 augmentation_data
= start
;
4044 start
+= augmentation_data_len
;
4046 else if (strcmp (fc
->augmentation
, "eh") == 0)
4048 start
+= eh_addr_size
;
4049 fc
->code_factor
= LEB ();
4050 fc
->data_factor
= SLEB ();
4062 fc
->code_factor
= LEB ();
4063 fc
->data_factor
= SLEB ();
4075 if (do_debug_frames_interp
)
4076 printf ("\n%08lx %08lx %08lx CIE \"%s\" cf=%d df=%d ra=%d\n",
4077 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
4078 fc
->augmentation
, fc
->code_factor
, fc
->data_factor
,
4082 printf ("\n%08lx %08lx %08lx CIE\n",
4083 (unsigned long)(saved_start
- section_start
), length
, cie_id
);
4084 printf (" Version: %d\n", version
);
4085 printf (" Augmentation: \"%s\"\n", fc
->augmentation
);
4086 printf (" Code alignment factor: %u\n", fc
->code_factor
);
4087 printf (" Data alignment factor: %d\n", fc
->data_factor
);
4088 printf (" Return address column: %d\n", fc
->ra
);
4090 if (augmentation_data_len
)
4093 printf (" Augmentation data: ");
4094 for (i
= 0; i
< augmentation_data_len
; ++i
)
4095 printf (" %02x", augmentation_data
[i
]);
4101 if (augmentation_data_len
)
4103 unsigned char *p
, *q
;
4104 p
= (unsigned char *) fc
->augmentation
+ 1;
4105 q
= augmentation_data
;
4112 q
+= 1 + size_of_encoded_value (*q
);
4114 fc
->fde_encoding
= *q
++;
4120 if (fc
->fde_encoding
)
4121 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
4124 frame_need_space (fc
, fc
->ra
);
4128 unsigned char *look_for
;
4129 static Frame_Chunk fde_fc
;
4132 memset (fc
, 0, sizeof (Frame_Chunk
));
4134 look_for
= is_eh
? start
- 4 - cie_id
: section_start
+ cie_id
;
4136 for (cie
= chunks
; cie
; cie
= cie
->next
)
4137 if (cie
->chunk_start
== look_for
)
4142 warn ("Invalid CIE pointer %#08lx in FDE at %#08lx\n",
4143 cie_id
, (unsigned long)(saved_start
- section_start
));
4145 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
4146 fc
->col_offset
= (int *) xmalloc (sizeof (int));
4147 frame_need_space (fc
, max_regs
- 1);
4149 fc
->augmentation
= "";
4150 fc
->fde_encoding
= 0;
4154 fc
->ncols
= cie
->ncols
;
4155 fc
->col_type
= (short int *) xcmalloc (fc
->ncols
, sizeof (short int));
4156 fc
->col_offset
= (int *) xcmalloc (fc
->ncols
, sizeof (int));
4157 memcpy (fc
->col_type
, cie
->col_type
, fc
->ncols
* sizeof (short int));
4158 memcpy (fc
->col_offset
, cie
->col_offset
, fc
->ncols
* sizeof (int));
4159 fc
->augmentation
= cie
->augmentation
;
4160 fc
->code_factor
= cie
->code_factor
;
4161 fc
->data_factor
= cie
->data_factor
;
4162 fc
->cfa_reg
= cie
->cfa_reg
;
4163 fc
->cfa_offset
= cie
->cfa_offset
;
4165 frame_need_space (fc
, max_regs
- 1);
4166 fc
->fde_encoding
= cie
->fde_encoding
;
4169 if (fc
->fde_encoding
)
4170 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
4172 fc
->pc_begin
= get_encoded_value (start
, fc
->fde_encoding
);
4173 if ((fc
->fde_encoding
& 0x70) == DW_EH_PE_pcrel
)
4174 fc
->pc_begin
+= section
->address
+ (start
- section_start
);
4175 start
+= encoded_ptr_size
;
4176 fc
->pc_range
= byte_get (start
, encoded_ptr_size
);
4177 start
+= encoded_ptr_size
;
4179 if (cie
->augmentation
[0] == 'z')
4181 augmentation_data_len
= LEB ();
4182 augmentation_data
= start
;
4183 start
+= augmentation_data_len
;
4186 printf ("\n%08lx %08lx %08lx FDE cie=%08lx pc=%08lx..%08lx\n",
4187 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
4188 (unsigned long)(cie
->chunk_start
- section_start
),
4189 fc
->pc_begin
, fc
->pc_begin
+ fc
->pc_range
);
4190 if (! do_debug_frames_interp
&& augmentation_data_len
)
4194 printf (" Augmentation data: ");
4195 for (i
= 0; i
< augmentation_data_len
; ++i
)
4196 printf (" %02x", augmentation_data
[i
]);
4202 /* At this point, fc is the current chunk, cie (if any) is set, and
4203 we're about to interpret instructions for the chunk. */
4204 /* ??? At present we need to do this always, since this sizes the
4205 fc->col_type and fc->col_offset arrays, which we write into always.
4206 We should probably split the interpreted and non-interpreted bits
4207 into two different routines, since there's so much that doesn't
4208 really overlap between them. */
4209 if (1 || do_debug_frames_interp
)
4211 /* Start by making a pass over the chunk, allocating storage
4212 and taking note of what registers are used. */
4213 unsigned char *tmp
= start
;
4215 while (start
< block_end
)
4218 unsigned long reg
, temp
;
4225 /* Warning: if you add any more cases to this switch, be
4226 sure to add them to the corresponding switch below. */
4229 case DW_CFA_advance_loc
:
4233 if (frame_need_space (fc
, opa
) >= 0)
4234 fc
->col_type
[opa
] = DW_CFA_undefined
;
4236 case DW_CFA_restore
:
4237 if (frame_need_space (fc
, opa
) >= 0)
4238 fc
->col_type
[opa
] = DW_CFA_undefined
;
4240 case DW_CFA_set_loc
:
4241 start
+= encoded_ptr_size
;
4243 case DW_CFA_advance_loc1
:
4246 case DW_CFA_advance_loc2
:
4249 case DW_CFA_advance_loc4
:
4252 case DW_CFA_offset_extended
:
4253 case DW_CFA_val_offset
:
4254 reg
= LEB (); LEB ();
4255 if (frame_need_space (fc
, reg
) >= 0)
4256 fc
->col_type
[reg
] = DW_CFA_undefined
;
4258 case DW_CFA_restore_extended
:
4260 frame_need_space (fc
, reg
);
4261 if (frame_need_space (fc
, reg
) >= 0)
4262 fc
->col_type
[reg
] = DW_CFA_undefined
;
4264 case DW_CFA_undefined
:
4266 if (frame_need_space (fc
, reg
) >= 0)
4267 fc
->col_type
[reg
] = DW_CFA_undefined
;
4269 case DW_CFA_same_value
:
4271 if (frame_need_space (fc
, reg
) >= 0)
4272 fc
->col_type
[reg
] = DW_CFA_undefined
;
4274 case DW_CFA_register
:
4275 reg
= LEB (); LEB ();
4276 if (frame_need_space (fc
, reg
) >= 0)
4277 fc
->col_type
[reg
] = DW_CFA_undefined
;
4279 case DW_CFA_def_cfa
:
4282 case DW_CFA_def_cfa_register
:
4285 case DW_CFA_def_cfa_offset
:
4288 case DW_CFA_def_cfa_expression
:
4292 case DW_CFA_expression
:
4293 case DW_CFA_val_expression
:
4297 if (frame_need_space (fc
, reg
) >= 0)
4298 fc
->col_type
[reg
] = DW_CFA_undefined
;
4300 case DW_CFA_offset_extended_sf
:
4301 case DW_CFA_val_offset_sf
:
4302 reg
= LEB (); SLEB ();
4303 if (frame_need_space (fc
, reg
) >= 0)
4304 fc
->col_type
[reg
] = DW_CFA_undefined
;
4306 case DW_CFA_def_cfa_sf
:
4309 case DW_CFA_def_cfa_offset_sf
:
4312 case DW_CFA_MIPS_advance_loc8
:
4315 case DW_CFA_GNU_args_size
:
4318 case DW_CFA_GNU_negative_offset_extended
:
4319 reg
= LEB (); LEB ();
4320 if (frame_need_space (fc
, reg
) >= 0)
4321 fc
->col_type
[reg
] = DW_CFA_undefined
;
4330 /* Now we know what registers are used, make a second pass over
4331 the chunk, this time actually printing out the info. */
4333 while (start
< block_end
)
4336 unsigned long ul
, reg
, roffs
;
4339 const char *reg_prefix
= "";
4346 /* Warning: if you add any more cases to this switch, be
4347 sure to add them to the corresponding switch above. */
4350 case DW_CFA_advance_loc
:
4351 if (do_debug_frames_interp
)
4352 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4354 printf (" DW_CFA_advance_loc: %d to %08lx\n",
4355 opa
* fc
->code_factor
,
4356 fc
->pc_begin
+ opa
* fc
->code_factor
);
4357 fc
->pc_begin
+= opa
* fc
->code_factor
;
4362 if (opa
>= (unsigned int) fc
->ncols
)
4363 reg_prefix
= bad_reg
;
4364 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4365 printf (" DW_CFA_offset: %s%s at cfa%+ld\n",
4366 reg_prefix
, regname (opa
, 0),
4367 roffs
* fc
->data_factor
);
4368 if (*reg_prefix
== '\0')
4370 fc
->col_type
[opa
] = DW_CFA_offset
;
4371 fc
->col_offset
[opa
] = roffs
* fc
->data_factor
;
4375 case DW_CFA_restore
:
4376 if (opa
>= (unsigned int) cie
->ncols
4377 || opa
>= (unsigned int) fc
->ncols
)
4378 reg_prefix
= bad_reg
;
4379 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4380 printf (" DW_CFA_restore: %s%s\n",
4381 reg_prefix
, regname (opa
, 0));
4382 if (*reg_prefix
== '\0')
4384 fc
->col_type
[opa
] = cie
->col_type
[opa
];
4385 fc
->col_offset
[opa
] = cie
->col_offset
[opa
];
4389 case DW_CFA_set_loc
:
4390 vma
= get_encoded_value (start
, fc
->fde_encoding
);
4391 if ((fc
->fde_encoding
& 0x70) == DW_EH_PE_pcrel
)
4392 vma
+= section
->address
+ (start
- section_start
);
4393 start
+= encoded_ptr_size
;
4394 if (do_debug_frames_interp
)
4395 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4397 printf (" DW_CFA_set_loc: %08lx\n", (unsigned long)vma
);
4401 case DW_CFA_advance_loc1
:
4402 ofs
= byte_get (start
, 1); start
+= 1;
4403 if (do_debug_frames_interp
)
4404 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4406 printf (" DW_CFA_advance_loc1: %ld to %08lx\n",
4407 ofs
* fc
->code_factor
,
4408 fc
->pc_begin
+ ofs
* fc
->code_factor
);
4409 fc
->pc_begin
+= ofs
* fc
->code_factor
;
4412 case DW_CFA_advance_loc2
:
4413 ofs
= byte_get (start
, 2); start
+= 2;
4414 if (do_debug_frames_interp
)
4415 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4417 printf (" DW_CFA_advance_loc2: %ld to %08lx\n",
4418 ofs
* fc
->code_factor
,
4419 fc
->pc_begin
+ ofs
* fc
->code_factor
);
4420 fc
->pc_begin
+= ofs
* fc
->code_factor
;
4423 case DW_CFA_advance_loc4
:
4424 ofs
= byte_get (start
, 4); start
+= 4;
4425 if (do_debug_frames_interp
)
4426 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4428 printf (" DW_CFA_advance_loc4: %ld to %08lx\n",
4429 ofs
* fc
->code_factor
,
4430 fc
->pc_begin
+ ofs
* fc
->code_factor
);
4431 fc
->pc_begin
+= ofs
* fc
->code_factor
;
4434 case DW_CFA_offset_extended
:
4437 if (reg
>= (unsigned int) fc
->ncols
)
4438 reg_prefix
= bad_reg
;
4439 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4440 printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n",
4441 reg_prefix
, regname (reg
, 0),
4442 roffs
* fc
->data_factor
);
4443 if (*reg_prefix
== '\0')
4445 fc
->col_type
[reg
] = DW_CFA_offset
;
4446 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
4450 case DW_CFA_val_offset
:
4453 if (reg
>= (unsigned int) fc
->ncols
)
4454 reg_prefix
= bad_reg
;
4455 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4456 printf (" DW_CFA_val_offset: %s%s at cfa%+ld\n",
4457 reg_prefix
, regname (reg
, 0),
4458 roffs
* fc
->data_factor
);
4459 if (*reg_prefix
== '\0')
4461 fc
->col_type
[reg
] = DW_CFA_val_offset
;
4462 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
4466 case DW_CFA_restore_extended
:
4468 if (reg
>= (unsigned int) cie
->ncols
4469 || reg
>= (unsigned int) fc
->ncols
)
4470 reg_prefix
= bad_reg
;
4471 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4472 printf (" DW_CFA_restore_extended: %s%s\n",
4473 reg_prefix
, regname (reg
, 0));
4474 if (*reg_prefix
== '\0')
4476 fc
->col_type
[reg
] = cie
->col_type
[reg
];
4477 fc
->col_offset
[reg
] = cie
->col_offset
[reg
];
4481 case DW_CFA_undefined
:
4483 if (reg
>= (unsigned int) fc
->ncols
)
4484 reg_prefix
= bad_reg
;
4485 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4486 printf (" DW_CFA_undefined: %s%s\n",
4487 reg_prefix
, regname (reg
, 0));
4488 if (*reg_prefix
== '\0')
4490 fc
->col_type
[reg
] = DW_CFA_undefined
;
4491 fc
->col_offset
[reg
] = 0;
4495 case DW_CFA_same_value
:
4497 if (reg
>= (unsigned int) fc
->ncols
)
4498 reg_prefix
= bad_reg
;
4499 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4500 printf (" DW_CFA_same_value: %s%s\n",
4501 reg_prefix
, regname (reg
, 0));
4502 if (*reg_prefix
== '\0')
4504 fc
->col_type
[reg
] = DW_CFA_same_value
;
4505 fc
->col_offset
[reg
] = 0;
4509 case DW_CFA_register
:
4512 if (reg
>= (unsigned int) fc
->ncols
)
4513 reg_prefix
= bad_reg
;
4514 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4516 printf (" DW_CFA_register: %s%s in ",
4517 reg_prefix
, regname (reg
, 0));
4518 puts (regname (roffs
, 0));
4520 if (*reg_prefix
== '\0')
4522 fc
->col_type
[reg
] = DW_CFA_register
;
4523 fc
->col_offset
[reg
] = roffs
;
4527 case DW_CFA_remember_state
:
4528 if (! do_debug_frames_interp
)
4529 printf (" DW_CFA_remember_state\n");
4530 rs
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
4531 rs
->ncols
= fc
->ncols
;
4532 rs
->col_type
= (short int *) xcmalloc (rs
->ncols
,
4533 sizeof (short int));
4534 rs
->col_offset
= (int *) xcmalloc (rs
->ncols
, sizeof (int));
4535 memcpy (rs
->col_type
, fc
->col_type
, rs
->ncols
);
4536 memcpy (rs
->col_offset
, fc
->col_offset
, rs
->ncols
* sizeof (int));
4537 rs
->next
= remembered_state
;
4538 remembered_state
= rs
;
4541 case DW_CFA_restore_state
:
4542 if (! do_debug_frames_interp
)
4543 printf (" DW_CFA_restore_state\n");
4544 rs
= remembered_state
;
4547 remembered_state
= rs
->next
;
4548 frame_need_space (fc
, rs
->ncols
- 1);
4549 memcpy (fc
->col_type
, rs
->col_type
, rs
->ncols
);
4550 memcpy (fc
->col_offset
, rs
->col_offset
,
4551 rs
->ncols
* sizeof (int));
4552 free (rs
->col_type
);
4553 free (rs
->col_offset
);
4556 else if (do_debug_frames_interp
)
4557 printf ("Mismatched DW_CFA_restore_state\n");
4560 case DW_CFA_def_cfa
:
4561 fc
->cfa_reg
= LEB ();
4562 fc
->cfa_offset
= LEB ();
4564 if (! do_debug_frames_interp
)
4565 printf (" DW_CFA_def_cfa: %s ofs %d\n",
4566 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
4569 case DW_CFA_def_cfa_register
:
4570 fc
->cfa_reg
= LEB ();
4572 if (! do_debug_frames_interp
)
4573 printf (" DW_CFA_def_cfa_register: %s\n",
4574 regname (fc
->cfa_reg
, 0));
4577 case DW_CFA_def_cfa_offset
:
4578 fc
->cfa_offset
= LEB ();
4579 if (! do_debug_frames_interp
)
4580 printf (" DW_CFA_def_cfa_offset: %d\n", fc
->cfa_offset
);
4584 if (! do_debug_frames_interp
)
4585 printf (" DW_CFA_nop\n");
4588 case DW_CFA_def_cfa_expression
:
4590 if (! do_debug_frames_interp
)
4592 printf (" DW_CFA_def_cfa_expression (");
4593 decode_location_expression (start
, eh_addr_size
, ul
, 0,
4601 case DW_CFA_expression
:
4604 if (reg
>= (unsigned int) fc
->ncols
)
4605 reg_prefix
= bad_reg
;
4606 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4608 printf (" DW_CFA_expression: %s%s (",
4609 reg_prefix
, regname (reg
, 0));
4610 decode_location_expression (start
, eh_addr_size
,
4614 if (*reg_prefix
== '\0')
4615 fc
->col_type
[reg
] = DW_CFA_expression
;
4619 case DW_CFA_val_expression
:
4622 if (reg
>= (unsigned int) fc
->ncols
)
4623 reg_prefix
= bad_reg
;
4624 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4626 printf (" DW_CFA_val_expression: %s%s (",
4627 reg_prefix
, regname (reg
, 0));
4628 decode_location_expression (start
, eh_addr_size
, ul
, 0,
4632 if (*reg_prefix
== '\0')
4633 fc
->col_type
[reg
] = DW_CFA_val_expression
;
4637 case DW_CFA_offset_extended_sf
:
4640 if (frame_need_space (fc
, reg
) < 0)
4641 reg_prefix
= bad_reg
;
4642 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4643 printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n",
4644 reg_prefix
, regname (reg
, 0),
4645 l
* fc
->data_factor
);
4646 if (*reg_prefix
== '\0')
4648 fc
->col_type
[reg
] = DW_CFA_offset
;
4649 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
4653 case DW_CFA_val_offset_sf
:
4656 if (frame_need_space (fc
, reg
) < 0)
4657 reg_prefix
= bad_reg
;
4658 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4659 printf (" DW_CFA_val_offset_sf: %s%s at cfa%+ld\n",
4660 reg_prefix
, regname (reg
, 0),
4661 l
* fc
->data_factor
);
4662 if (*reg_prefix
== '\0')
4664 fc
->col_type
[reg
] = DW_CFA_val_offset
;
4665 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
4669 case DW_CFA_def_cfa_sf
:
4670 fc
->cfa_reg
= LEB ();
4671 fc
->cfa_offset
= SLEB ();
4672 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
4674 if (! do_debug_frames_interp
)
4675 printf (" DW_CFA_def_cfa_sf: %s ofs %d\n",
4676 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
4679 case DW_CFA_def_cfa_offset_sf
:
4680 fc
->cfa_offset
= SLEB ();
4681 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
4682 if (! do_debug_frames_interp
)
4683 printf (" DW_CFA_def_cfa_offset_sf: %d\n", fc
->cfa_offset
);
4686 case DW_CFA_MIPS_advance_loc8
:
4687 ofs
= byte_get (start
, 8); start
+= 8;
4688 if (do_debug_frames_interp
)
4689 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4691 printf (" DW_CFA_MIPS_advance_loc8: %ld to %08lx\n",
4692 ofs
* fc
->code_factor
,
4693 fc
->pc_begin
+ ofs
* fc
->code_factor
);
4694 fc
->pc_begin
+= ofs
* fc
->code_factor
;
4697 case DW_CFA_GNU_window_save
:
4698 if (! do_debug_frames_interp
)
4699 printf (" DW_CFA_GNU_window_save\n");
4702 case DW_CFA_GNU_args_size
:
4704 if (! do_debug_frames_interp
)
4705 printf (" DW_CFA_GNU_args_size: %ld\n", ul
);
4708 case DW_CFA_GNU_negative_offset_extended
:
4711 if (frame_need_space (fc
, reg
) < 0)
4712 reg_prefix
= bad_reg
;
4713 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4714 printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n",
4715 reg_prefix
, regname (reg
, 0),
4716 l
* fc
->data_factor
);
4717 if (*reg_prefix
== '\0')
4719 fc
->col_type
[reg
] = DW_CFA_offset
;
4720 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
4725 if (op
>= DW_CFA_lo_user
&& op
<= DW_CFA_hi_user
)
4726 printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op
);
4728 warn (_("unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op
);
4733 if (do_debug_frames_interp
)
4734 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4749 display_debug_not_supported (struct dwarf_section
*section
,
4750 void *file ATTRIBUTE_UNUSED
)
4752 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
4759 cmalloc (size_t nmemb
, size_t size
)
4761 /* Check for overflow. */
4762 if (nmemb
>= ~(size_t) 0 / size
)
4765 return malloc (nmemb
* size
);
4769 xcmalloc (size_t nmemb
, size_t size
)
4771 /* Check for overflow. */
4772 if (nmemb
>= ~(size_t) 0 / size
)
4775 return xmalloc (nmemb
* size
);
4779 xcrealloc (void *ptr
, size_t nmemb
, size_t size
)
4781 /* Check for overflow. */
4782 if (nmemb
>= ~(size_t) 0 / size
)
4785 return xrealloc (ptr
, nmemb
* size
);
4789 error (const char *message
, ...)
4793 va_start (args
, message
);
4794 fprintf (stderr
, _("%s: Error: "), program_name
);
4795 vfprintf (stderr
, message
, args
);
4800 warn (const char *message
, ...)
4804 va_start (args
, message
);
4805 fprintf (stderr
, _("%s: Warning: "), program_name
);
4806 vfprintf (stderr
, message
, args
);
4811 free_debug_memory (void)
4817 for (i
= 0; i
< max
; i
++)
4818 free_debug_section ((enum dwarf_section_display_enum
) i
);
4820 if (debug_information
!= NULL
)
4822 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
)
4824 for (i
= 0; i
< num_debug_info_entries
; i
++)
4826 if (!debug_information
[i
].max_loc_offsets
)
4828 free (debug_information
[i
].loc_offsets
);
4829 free (debug_information
[i
].have_frame_base
);
4831 if (!debug_information
[i
].max_range_lists
)
4832 free (debug_information
[i
].range_lists
);
4836 free (debug_information
);
4837 debug_information
= NULL
;
4838 num_debug_info_entries
= 0;
4843 dwarf_select_sections_by_names (const char *names
)
4847 const char * option
;
4851 debug_dump_long_opts
;
4853 static const debug_dump_long_opts opts_table
[] =
4855 /* Please keep this table alpha- sorted. */
4856 { "Ranges", & do_debug_ranges
, 1 },
4857 { "abbrev", & do_debug_abbrevs
, 1 },
4858 { "aranges", & do_debug_aranges
, 1 },
4859 { "frames", & do_debug_frames
, 1 },
4860 { "frames-interp", & do_debug_frames_interp
, 1 },
4861 { "info", & do_debug_info
, 1 },
4862 { "line", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
}, /* For backwards compatibility. */
4863 { "rawline", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
},
4864 { "decodedline", & do_debug_lines
, FLAG_DEBUG_LINES_DECODED
},
4865 { "loc", & do_debug_loc
, 1 },
4866 { "macro", & do_debug_macinfo
, 1 },
4867 { "pubnames", & do_debug_pubnames
, 1 },
4868 { "pubtypes", & do_debug_pubtypes
, 1 },
4869 /* This entry is for compatability
4870 with earlier versions of readelf. */
4871 { "ranges", & do_debug_aranges
, 1 },
4872 { "str", & do_debug_str
, 1 },
4881 const debug_dump_long_opts
* entry
;
4883 for (entry
= opts_table
; entry
->option
; entry
++)
4885 size_t len
= strlen (entry
->option
);
4887 if (strncmp (p
, entry
->option
, len
) == 0
4888 && (p
[len
] == ',' || p
[len
] == '\0'))
4890 * entry
->variable
|= entry
->val
;
4892 /* The --debug-dump=frames-interp option also
4893 enables the --debug-dump=frames option. */
4894 if (do_debug_frames_interp
)
4895 do_debug_frames
= 1;
4902 if (entry
->option
== NULL
)
4904 warn (_("Unrecognized debug option '%s'\n"), p
);
4905 p
= strchr (p
, ',');
4916 dwarf_select_sections_by_letters (const char *letters
)
4918 unsigned int lindex
= 0;
4920 while (letters
[lindex
])
4921 switch (letters
[lindex
++])
4928 do_debug_abbrevs
= 1;
4932 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
4936 do_debug_lines
|= FLAG_DEBUG_LINES_DECODED
;
4940 do_debug_pubnames
= 1;
4944 do_debug_pubtypes
= 1;
4948 do_debug_aranges
= 1;
4952 do_debug_ranges
= 1;
4956 do_debug_frames_interp
= 1;
4958 do_debug_frames
= 1;
4962 do_debug_macinfo
= 1;
4974 warn (_("Unrecognized debug option '%s'\n"), optarg
);
4980 dwarf_select_sections_all (void)
4983 do_debug_abbrevs
= 1;
4984 do_debug_lines
= FLAG_DEBUG_LINES_RAW
;
4985 do_debug_pubnames
= 1;
4986 do_debug_pubtypes
= 1;
4987 do_debug_aranges
= 1;
4988 do_debug_ranges
= 1;
4989 do_debug_frames
= 1;
4990 do_debug_macinfo
= 1;
4995 struct dwarf_section_display debug_displays
[] =
4997 { { ".debug_abbrev", ".zdebug_abbrev", NULL
, NULL
, 0, 0 },
4998 display_debug_abbrev
, &do_debug_abbrevs
, 0 },
4999 { { ".debug_aranges", ".zdebug_aranges", NULL
, NULL
, 0, 0 },
5000 display_debug_aranges
, &do_debug_aranges
, 1 },
5001 { { ".debug_frame", ".zdebug_frame", NULL
, NULL
, 0, 0 },
5002 display_debug_frames
, &do_debug_frames
, 1 },
5003 { { ".debug_info", ".zdebug_info", NULL
, NULL
, 0, 0 },
5004 display_debug_info
, &do_debug_info
, 1 },
5005 { { ".debug_line", ".zdebug_line", NULL
, NULL
, 0, 0 },
5006 display_debug_lines
, &do_debug_lines
, 1 },
5007 { { ".debug_pubnames", ".zdebug_pubnames", NULL
, NULL
, 0, 0 },
5008 display_debug_pubnames
, &do_debug_pubnames
, 0 },
5009 { { ".eh_frame", "", NULL
, NULL
, 0, 0 },
5010 display_debug_frames
, &do_debug_frames
, 1 },
5011 { { ".debug_macinfo", ".zdebug_macinfo", NULL
, NULL
, 0, 0 },
5012 display_debug_macinfo
, &do_debug_macinfo
, 0 },
5013 { { ".debug_str", ".zdebug_str", NULL
, NULL
, 0, 0 },
5014 display_debug_str
, &do_debug_str
, 0 },
5015 { { ".debug_loc", ".zdebug_loc", NULL
, NULL
, 0, 0 },
5016 display_debug_loc
, &do_debug_loc
, 1 },
5017 { { ".debug_pubtypes", ".zdebug_pubtypes", NULL
, NULL
, 0, 0 },
5018 display_debug_pubnames
, &do_debug_pubtypes
, 0 },
5019 { { ".debug_ranges", ".zdebug_ranges", NULL
, NULL
, 0, 0 },
5020 display_debug_ranges
, &do_debug_ranges
, 1 },
5021 { { ".debug_static_func", ".zdebug_static_func", NULL
, NULL
, 0, 0 },
5022 display_debug_not_supported
, NULL
, 0 },
5023 { { ".debug_static_vars", ".zdebug_static_vars", NULL
, NULL
, 0, 0 },
5024 display_debug_not_supported
, NULL
, 0 },
5025 { { ".debug_types", ".zdebug_types", NULL
, NULL
, 0, 0 },
5026 display_debug_types
, &do_debug_info
, 1 },
5027 { { ".debug_weaknames", ".zdebug_weaknames", NULL
, NULL
, 0, 0 },
5028 display_debug_not_supported
, NULL
, 0 }