1 /* dwarf.c -- display DWARF contents of a BFD binary file
2 Copyright 2005, 2006, 2007, 2008, 2009, 2010
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"
27 #include "elf/common.h"
31 static const char *regname (unsigned int regno
, int row
);
33 static int have_frame_base
;
34 static int need_base_address
;
36 static unsigned int last_pointer_size
= 0;
37 static int warned_about_missing_comp_units
= FALSE
;
39 static unsigned int num_debug_info_entries
= 0;
40 static debug_info
*debug_information
= NULL
;
41 /* Special value for num_debug_info_entries to indicate
42 that the .debug_info section could not be loaded/parsed. */
43 #define DEBUG_INFO_UNAVAILABLE (unsigned int) -1
50 int do_debug_pubnames
;
51 int do_debug_pubtypes
;
55 int do_debug_frames_interp
;
64 /* Values for do_debug_lines. */
65 #define FLAG_DEBUG_LINES_RAW 1
66 #define FLAG_DEBUG_LINES_DECODED 2
69 size_of_encoded_value (int encoding
)
71 switch (encoding
& 0x7)
74 case 0: return eh_addr_size
;
82 get_encoded_value (unsigned char *data
,
84 struct dwarf_section
*section
)
86 int size
= size_of_encoded_value (encoding
);
89 if (encoding
& DW_EH_PE_signed
)
90 val
= byte_get_signed (data
, size
);
92 val
= byte_get (data
, size
);
94 if ((encoding
& 0x70) == DW_EH_PE_pcrel
)
95 val
+= section
->address
+ (data
- section
->start
);
99 /* Print a dwarf_vma value (typically an address, offset or length) in
100 hexadecimal format, followed by a space. The length of the value (and
101 hence the precision displayed) is determined by the byte_size parameter. */
104 print_dwarf_vma (dwarf_vma val
, unsigned byte_size
)
106 static char buff
[18];
108 /* Printf does not have a way of specifiying a maximum field width for an
109 integer value, so we print the full value into a buffer and then select
110 the precision we need. */
111 #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
113 snprintf (buff
, sizeof (buff
), "%16.16llx ", val
);
115 snprintf (buff
, sizeof (buff
), "%016I64x ", val
);
118 snprintf (buff
, sizeof (buff
), "%16.16lx ", val
);
121 fputs (buff
+ (byte_size
== 4 ? 8 : 0), stdout
);
125 read_leb128 (unsigned char *data
, unsigned int *length_return
, int sign
)
127 unsigned long int result
= 0;
128 unsigned int num_read
= 0;
129 unsigned int shift
= 0;
137 result
|= ((unsigned long int) (byte
& 0x7f)) << shift
;
144 if (length_return
!= NULL
)
145 *length_return
= num_read
;
147 if (sign
&& (shift
< 8 * sizeof (result
)) && (byte
& 0x40))
148 result
|= -1L << shift
;
153 typedef struct State_Machine_Registers
155 unsigned long address
;
161 unsigned char op_index
;
162 unsigned char end_sequence
;
163 /* This variable hold the number of the last entry seen
164 in the File Table. */
165 unsigned int last_file_entry
;
168 static SMR state_machine_regs
;
171 reset_state_machine (int is_stmt
)
173 state_machine_regs
.address
= 0;
174 state_machine_regs
.op_index
= 0;
175 state_machine_regs
.file
= 1;
176 state_machine_regs
.line
= 1;
177 state_machine_regs
.column
= 0;
178 state_machine_regs
.is_stmt
= is_stmt
;
179 state_machine_regs
.basic_block
= 0;
180 state_machine_regs
.end_sequence
= 0;
181 state_machine_regs
.last_file_entry
= 0;
184 /* Handled an extend line op.
185 Returns the number of bytes read. */
188 process_extended_line_op (unsigned char *data
, int is_stmt
)
190 unsigned char op_code
;
191 unsigned int bytes_read
;
196 len
= read_leb128 (data
, & bytes_read
, 0);
201 warn (_("badly formed extended line op encountered!\n"));
208 printf (_(" Extended opcode %d: "), op_code
);
212 case DW_LNE_end_sequence
:
213 printf (_("End of Sequence\n\n"));
214 reset_state_machine (is_stmt
);
217 case DW_LNE_set_address
:
218 adr
= byte_get (data
, len
- bytes_read
- 1);
219 printf (_("set Address to 0x%lx\n"), adr
);
220 state_machine_regs
.address
= adr
;
221 state_machine_regs
.op_index
= 0;
224 case DW_LNE_define_file
:
225 printf (_(" define new File Table entry\n"));
226 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
228 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
230 data
+= strlen ((char *) data
) + 1;
231 printf ("%lu\t", read_leb128 (data
, & bytes_read
, 0));
233 printf ("%lu\t", read_leb128 (data
, & bytes_read
, 0));
235 printf ("%lu\t", read_leb128 (data
, & bytes_read
, 0));
236 printf ("%s\n\n", name
);
239 case DW_LNE_set_discriminator
:
240 printf (_("set Discriminator to %lu\n"),
241 read_leb128 (data
, & bytes_read
, 0));
245 case DW_LNE_HP_negate_is_UV_update
:
246 printf ("DW_LNE_HP_negate_is_UV_update\n");
248 case DW_LNE_HP_push_context
:
249 printf ("DW_LNE_HP_push_context\n");
251 case DW_LNE_HP_pop_context
:
252 printf ("DW_LNE_HP_pop_context\n");
254 case DW_LNE_HP_set_file_line_column
:
255 printf ("DW_LNE_HP_set_file_line_column\n");
257 case DW_LNE_HP_set_routine_name
:
258 printf ("DW_LNE_HP_set_routine_name\n");
260 case DW_LNE_HP_set_sequence
:
261 printf ("DW_LNE_HP_set_sequence\n");
263 case DW_LNE_HP_negate_post_semantics
:
264 printf ("DW_LNE_HP_negate_post_semantics\n");
266 case DW_LNE_HP_negate_function_exit
:
267 printf ("DW_LNE_HP_negate_function_exit\n");
269 case DW_LNE_HP_negate_front_end_logical
:
270 printf ("DW_LNE_HP_negate_front_end_logical\n");
272 case DW_LNE_HP_define_proc
:
273 printf ("DW_LNE_HP_define_proc\n");
277 if (op_code
>= DW_LNE_lo_user
278 /* The test against DW_LNW_hi_user is redundant due to
279 the limited range of the unsigned char data type used
281 /*&& op_code <= DW_LNE_hi_user*/)
282 printf (_("user defined: length %d\n"), len
- bytes_read
);
284 printf (_("UNKNOWN: length %d\n"), len
- bytes_read
);
292 fetch_indirect_string (unsigned long offset
)
294 struct dwarf_section
*section
= &debug_displays
[str
].section
;
296 if (section
->start
== NULL
)
297 return _("<no .debug_str section>");
299 /* DWARF sections under Mach-O have non-zero addresses. */
300 offset
-= section
->address
;
301 if (offset
> section
->size
)
303 warn (_("DW_FORM_strp offset too big: %lx\n"), offset
);
304 return _("<offset is too big>");
307 return (const char *) section
->start
+ offset
;
310 /* FIXME: There are better and more efficient ways to handle
311 these structures. For now though, I just want something that
312 is simple to implement. */
313 typedef struct abbrev_attr
315 unsigned long attribute
;
317 struct abbrev_attr
*next
;
321 typedef struct abbrev_entry
326 struct abbrev_attr
*first_attr
;
327 struct abbrev_attr
*last_attr
;
328 struct abbrev_entry
*next
;
332 static abbrev_entry
*first_abbrev
= NULL
;
333 static abbrev_entry
*last_abbrev
= NULL
;
340 for (abbrv
= first_abbrev
; abbrv
;)
342 abbrev_entry
*next_abbrev
= abbrv
->next
;
345 for (attr
= abbrv
->first_attr
; attr
;)
347 abbrev_attr
*next_attr
= attr
->next
;
357 last_abbrev
= first_abbrev
= NULL
;
361 add_abbrev (unsigned long number
, unsigned long tag
, int children
)
365 entry
= (abbrev_entry
*) malloc (sizeof (*entry
));
371 entry
->entry
= number
;
373 entry
->children
= children
;
374 entry
->first_attr
= NULL
;
375 entry
->last_attr
= NULL
;
378 if (first_abbrev
== NULL
)
379 first_abbrev
= entry
;
381 last_abbrev
->next
= entry
;
387 add_abbrev_attr (unsigned long attribute
, unsigned long form
)
391 attr
= (abbrev_attr
*) malloc (sizeof (*attr
));
397 attr
->attribute
= attribute
;
401 if (last_abbrev
->first_attr
== NULL
)
402 last_abbrev
->first_attr
= attr
;
404 last_abbrev
->last_attr
->next
= attr
;
406 last_abbrev
->last_attr
= attr
;
409 /* Processes the (partial) contents of a .debug_abbrev section.
410 Returns NULL if the end of the section was encountered.
411 Returns the address after the last byte read if the end of
412 an abbreviation set was found. */
414 static unsigned char *
415 process_abbrev_section (unsigned char *start
, unsigned char *end
)
417 if (first_abbrev
!= NULL
)
422 unsigned int bytes_read
;
425 unsigned long attribute
;
428 entry
= read_leb128 (start
, & bytes_read
, 0);
431 /* A single zero is supposed to end the section according
432 to the standard. If there's more, then signal that to
435 return start
== end
? NULL
: start
;
437 tag
= read_leb128 (start
, & bytes_read
, 0);
442 add_abbrev (entry
, tag
, children
);
448 attribute
= read_leb128 (start
, & bytes_read
, 0);
451 form
= read_leb128 (start
, & bytes_read
, 0);
455 add_abbrev_attr (attribute
, form
);
457 while (attribute
!= 0);
464 get_TAG_name (unsigned long tag
)
468 case DW_TAG_padding
: return "DW_TAG_padding";
469 case DW_TAG_array_type
: return "DW_TAG_array_type";
470 case DW_TAG_class_type
: return "DW_TAG_class_type";
471 case DW_TAG_entry_point
: return "DW_TAG_entry_point";
472 case DW_TAG_enumeration_type
: return "DW_TAG_enumeration_type";
473 case DW_TAG_formal_parameter
: return "DW_TAG_formal_parameter";
474 case DW_TAG_imported_declaration
: return "DW_TAG_imported_declaration";
475 case DW_TAG_label
: return "DW_TAG_label";
476 case DW_TAG_lexical_block
: return "DW_TAG_lexical_block";
477 case DW_TAG_member
: return "DW_TAG_member";
478 case DW_TAG_pointer_type
: return "DW_TAG_pointer_type";
479 case DW_TAG_reference_type
: return "DW_TAG_reference_type";
480 case DW_TAG_compile_unit
: return "DW_TAG_compile_unit";
481 case DW_TAG_string_type
: return "DW_TAG_string_type";
482 case DW_TAG_structure_type
: return "DW_TAG_structure_type";
483 case DW_TAG_subroutine_type
: return "DW_TAG_subroutine_type";
484 case DW_TAG_typedef
: return "DW_TAG_typedef";
485 case DW_TAG_union_type
: return "DW_TAG_union_type";
486 case DW_TAG_unspecified_parameters
: return "DW_TAG_unspecified_parameters";
487 case DW_TAG_variant
: return "DW_TAG_variant";
488 case DW_TAG_common_block
: return "DW_TAG_common_block";
489 case DW_TAG_common_inclusion
: return "DW_TAG_common_inclusion";
490 case DW_TAG_inheritance
: return "DW_TAG_inheritance";
491 case DW_TAG_inlined_subroutine
: return "DW_TAG_inlined_subroutine";
492 case DW_TAG_module
: return "DW_TAG_module";
493 case DW_TAG_ptr_to_member_type
: return "DW_TAG_ptr_to_member_type";
494 case DW_TAG_set_type
: return "DW_TAG_set_type";
495 case DW_TAG_subrange_type
: return "DW_TAG_subrange_type";
496 case DW_TAG_with_stmt
: return "DW_TAG_with_stmt";
497 case DW_TAG_access_declaration
: return "DW_TAG_access_declaration";
498 case DW_TAG_base_type
: return "DW_TAG_base_type";
499 case DW_TAG_catch_block
: return "DW_TAG_catch_block";
500 case DW_TAG_const_type
: return "DW_TAG_const_type";
501 case DW_TAG_constant
: return "DW_TAG_constant";
502 case DW_TAG_enumerator
: return "DW_TAG_enumerator";
503 case DW_TAG_file_type
: return "DW_TAG_file_type";
504 case DW_TAG_friend
: return "DW_TAG_friend";
505 case DW_TAG_namelist
: return "DW_TAG_namelist";
506 case DW_TAG_namelist_item
: return "DW_TAG_namelist_item";
507 case DW_TAG_packed_type
: return "DW_TAG_packed_type";
508 case DW_TAG_subprogram
: return "DW_TAG_subprogram";
509 case DW_TAG_template_type_param
: return "DW_TAG_template_type_param";
510 case DW_TAG_template_value_param
: return "DW_TAG_template_value_param";
511 case DW_TAG_thrown_type
: return "DW_TAG_thrown_type";
512 case DW_TAG_try_block
: return "DW_TAG_try_block";
513 case DW_TAG_variant_part
: return "DW_TAG_variant_part";
514 case DW_TAG_variable
: return "DW_TAG_variable";
515 case DW_TAG_volatile_type
: return "DW_TAG_volatile_type";
516 case DW_TAG_MIPS_loop
: return "DW_TAG_MIPS_loop";
517 case DW_TAG_format_label
: return "DW_TAG_format_label";
518 case DW_TAG_function_template
: return "DW_TAG_function_template";
519 case DW_TAG_class_template
: return "DW_TAG_class_template";
520 /* DWARF 2.1 values. */
521 case DW_TAG_dwarf_procedure
: return "DW_TAG_dwarf_procedure";
522 case DW_TAG_restrict_type
: return "DW_TAG_restrict_type";
523 case DW_TAG_interface_type
: return "DW_TAG_interface_type";
524 case DW_TAG_namespace
: return "DW_TAG_namespace";
525 case DW_TAG_imported_module
: return "DW_TAG_imported_module";
526 case DW_TAG_unspecified_type
: return "DW_TAG_unspecified_type";
527 case DW_TAG_partial_unit
: return "DW_TAG_partial_unit";
528 case DW_TAG_imported_unit
: return "DW_TAG_imported_unit";
529 case DW_TAG_condition
: return "DW_TAG_condition";
530 case DW_TAG_shared_type
: return "DW_TAG_shared_type";
531 /* DWARF 4 values. */
532 case DW_TAG_type_unit
: return "DW_TAG_type_unit";
533 case DW_TAG_rvalue_reference_type
: return "DW_TAG_rvalue_reference_type";
534 case DW_TAG_template_alias
: return "DW_TAG_template_alias";
536 case DW_TAG_upc_shared_type
: return "DW_TAG_upc_shared_type";
537 case DW_TAG_upc_strict_type
: return "DW_TAG_upc_strict_type";
538 case DW_TAG_upc_relaxed_type
: return "DW_TAG_upc_relaxed_type";
541 static char buffer
[100];
543 snprintf (buffer
, sizeof (buffer
), _("Unknown TAG value: %lx"), tag
);
550 get_FORM_name (unsigned long form
)
554 case DW_FORM_addr
: return "DW_FORM_addr";
555 case DW_FORM_block2
: return "DW_FORM_block2";
556 case DW_FORM_block4
: return "DW_FORM_block4";
557 case DW_FORM_data2
: return "DW_FORM_data2";
558 case DW_FORM_data4
: return "DW_FORM_data4";
559 case DW_FORM_data8
: return "DW_FORM_data8";
560 case DW_FORM_string
: return "DW_FORM_string";
561 case DW_FORM_block
: return "DW_FORM_block";
562 case DW_FORM_block1
: return "DW_FORM_block1";
563 case DW_FORM_data1
: return "DW_FORM_data1";
564 case DW_FORM_flag
: return "DW_FORM_flag";
565 case DW_FORM_sdata
: return "DW_FORM_sdata";
566 case DW_FORM_strp
: return "DW_FORM_strp";
567 case DW_FORM_udata
: return "DW_FORM_udata";
568 case DW_FORM_ref_addr
: return "DW_FORM_ref_addr";
569 case DW_FORM_ref1
: return "DW_FORM_ref1";
570 case DW_FORM_ref2
: return "DW_FORM_ref2";
571 case DW_FORM_ref4
: return "DW_FORM_ref4";
572 case DW_FORM_ref8
: return "DW_FORM_ref8";
573 case DW_FORM_ref_udata
: return "DW_FORM_ref_udata";
574 case DW_FORM_indirect
: return "DW_FORM_indirect";
575 /* DWARF 4 values. */
576 case DW_FORM_sec_offset
: return "DW_FORM_sec_offset";
577 case DW_FORM_exprloc
: return "DW_FORM_exprloc";
578 case DW_FORM_flag_present
: return "DW_FORM_flag_present";
579 case DW_FORM_ref_sig8
: return "DW_FORM_ref_sig8";
582 static char buffer
[100];
584 snprintf (buffer
, sizeof (buffer
), _("Unknown FORM value: %lx"), form
);
590 static unsigned char *
591 display_block (unsigned char *data
, unsigned long length
)
593 printf (_(" %lu byte block: "), length
);
596 printf ("%lx ", (unsigned long) byte_get (data
++, 1));
602 decode_location_expression (unsigned char * data
,
603 unsigned int pointer_size
,
604 unsigned int offset_size
,
606 unsigned long length
,
607 unsigned long cu_offset
,
608 struct dwarf_section
* section
)
611 unsigned int bytes_read
;
612 unsigned long uvalue
;
613 unsigned char *end
= data
+ length
;
614 int need_frame_base
= 0;
623 printf ("DW_OP_addr: %lx",
624 (unsigned long) byte_get (data
, pointer_size
));
625 data
+= pointer_size
;
628 printf ("DW_OP_deref");
631 printf ("DW_OP_const1u: %lu", (unsigned long) byte_get (data
++, 1));
634 printf ("DW_OP_const1s: %ld", (long) byte_get_signed (data
++, 1));
637 printf ("DW_OP_const2u: %lu", (unsigned long) byte_get (data
, 2));
641 printf ("DW_OP_const2s: %ld", (long) byte_get_signed (data
, 2));
645 printf ("DW_OP_const4u: %lu", (unsigned long) byte_get (data
, 4));
649 printf ("DW_OP_const4s: %ld", (long) byte_get_signed (data
, 4));
653 printf ("DW_OP_const8u: %lu %lu", (unsigned long) byte_get (data
, 4),
654 (unsigned long) byte_get (data
+ 4, 4));
658 printf ("DW_OP_const8s: %ld %ld", (long) byte_get (data
, 4),
659 (long) byte_get (data
+ 4, 4));
663 printf ("DW_OP_constu: %lu", read_leb128 (data
, &bytes_read
, 0));
667 printf ("DW_OP_consts: %ld", read_leb128 (data
, &bytes_read
, 1));
671 printf ("DW_OP_dup");
674 printf ("DW_OP_drop");
677 printf ("DW_OP_over");
680 printf ("DW_OP_pick: %ld", (unsigned long) byte_get (data
++, 1));
683 printf ("DW_OP_swap");
686 printf ("DW_OP_rot");
689 printf ("DW_OP_xderef");
692 printf ("DW_OP_abs");
695 printf ("DW_OP_and");
698 printf ("DW_OP_div");
701 printf ("DW_OP_minus");
704 printf ("DW_OP_mod");
707 printf ("DW_OP_mul");
710 printf ("DW_OP_neg");
713 printf ("DW_OP_not");
719 printf ("DW_OP_plus");
721 case DW_OP_plus_uconst
:
722 printf ("DW_OP_plus_uconst: %lu",
723 read_leb128 (data
, &bytes_read
, 0));
727 printf ("DW_OP_shl");
730 printf ("DW_OP_shr");
733 printf ("DW_OP_shra");
736 printf ("DW_OP_xor");
739 printf ("DW_OP_bra: %ld", (long) byte_get_signed (data
, 2));
761 printf ("DW_OP_skip: %ld", (long) byte_get_signed (data
, 2));
797 printf ("DW_OP_lit%d", op
- DW_OP_lit0
);
832 printf ("DW_OP_reg%d (%s)", op
- DW_OP_reg0
,
833 regname (op
- DW_OP_reg0
, 1));
868 printf ("DW_OP_breg%d (%s): %ld", op
- DW_OP_breg0
,
869 regname (op
- DW_OP_breg0
, 1),
870 read_leb128 (data
, &bytes_read
, 1));
875 uvalue
= read_leb128 (data
, &bytes_read
, 0);
877 printf ("DW_OP_regx: %lu (%s)", uvalue
, regname (uvalue
, 1));
881 printf ("DW_OP_fbreg: %ld", read_leb128 (data
, &bytes_read
, 1));
885 uvalue
= read_leb128 (data
, &bytes_read
, 0);
887 printf ("DW_OP_bregx: %lu (%s) %ld", uvalue
, regname (uvalue
, 1),
888 read_leb128 (data
, &bytes_read
, 1));
892 printf ("DW_OP_piece: %lu", read_leb128 (data
, &bytes_read
, 0));
895 case DW_OP_deref_size
:
896 printf ("DW_OP_deref_size: %ld", (long) byte_get (data
++, 1));
898 case DW_OP_xderef_size
:
899 printf ("DW_OP_xderef_size: %ld", (long) byte_get (data
++, 1));
902 printf ("DW_OP_nop");
905 /* DWARF 3 extensions. */
906 case DW_OP_push_object_address
:
907 printf ("DW_OP_push_object_address");
910 /* XXX: Strictly speaking for 64-bit DWARF3 files
911 this ought to be an 8-byte wide computation. */
912 printf ("DW_OP_call2: <0x%lx>", (long) byte_get (data
, 2) + cu_offset
);
916 /* XXX: Strictly speaking for 64-bit DWARF3 files
917 this ought to be an 8-byte wide computation. */
918 printf ("DW_OP_call4: <0x%lx>", (long) byte_get (data
, 4) + cu_offset
);
922 /* XXX: Strictly speaking for 64-bit DWARF3 files
923 this ought to be an 8-byte wide computation. */
924 if (dwarf_version
== -1)
926 printf (_("(DW_OP_call_ref in frame info)"));
927 /* No way to tell where the next op is, so just bail. */
928 return need_frame_base
;
930 if (dwarf_version
== 2)
932 printf ("DW_OP_call_ref: <0x%lx>",
933 (long) byte_get (data
, pointer_size
));
934 data
+= pointer_size
;
938 printf ("DW_OP_call_ref: <0x%lx>",
939 (long) byte_get (data
, offset_size
));
943 case DW_OP_form_tls_address
:
944 printf ("DW_OP_form_tls_address");
946 case DW_OP_call_frame_cfa
:
947 printf ("DW_OP_call_frame_cfa");
949 case DW_OP_bit_piece
:
950 printf ("DW_OP_bit_piece: ");
951 printf ("size: %lu ", read_leb128 (data
, &bytes_read
, 0));
953 printf ("offset: %lu ", read_leb128 (data
, &bytes_read
, 0));
957 /* DWARF 4 extensions. */
958 case DW_OP_stack_value
:
959 printf ("DW_OP_stack_value");
962 case DW_OP_implicit_value
:
963 printf ("DW_OP_implicit_value");
964 uvalue
= read_leb128 (data
, &bytes_read
, 0);
966 display_block (data
, uvalue
);
970 /* GNU extensions. */
971 case DW_OP_GNU_push_tls_address
:
972 printf ("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown");
974 case DW_OP_GNU_uninit
:
975 printf ("DW_OP_GNU_uninit");
976 /* FIXME: Is there data associated with this OP ? */
978 case DW_OP_GNU_encoded_addr
:
984 addr
= get_encoded_value (data
, encoding
, section
);
985 data
+= size_of_encoded_value (encoding
);
987 printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding
);
988 print_dwarf_vma (addr
, pointer_size
);
991 case DW_OP_GNU_implicit_pointer
:
992 /* XXX: Strictly speaking for 64-bit DWARF3 files
993 this ought to be an 8-byte wide computation. */
994 if (dwarf_version
== -1)
996 printf (_("(DW_OP_GNU_implicit_pointer in frame info)"));
997 /* No way to tell where the next op is, so just bail. */
998 return need_frame_base
;
1000 if (dwarf_version
== 2)
1002 printf ("DW_OP_GNU_implicit_pointer: <0x%lx> %ld",
1003 (long) byte_get (data
, pointer_size
),
1004 read_leb128 (data
+ pointer_size
, &bytes_read
, 1));
1005 data
+= pointer_size
+ bytes_read
;
1009 printf ("DW_OP_GNU_implicit_pointer: <0x%lx> %ld",
1010 (long) byte_get (data
, offset_size
),
1011 read_leb128 (data
+ offset_size
, &bytes_read
, 1));
1012 data
+= offset_size
+ bytes_read
;
1016 /* HP extensions. */
1017 case DW_OP_HP_is_value
:
1018 printf ("DW_OP_HP_is_value");
1019 /* FIXME: Is there data associated with this OP ? */
1021 case DW_OP_HP_fltconst4
:
1022 printf ("DW_OP_HP_fltconst4");
1023 /* FIXME: Is there data associated with this OP ? */
1025 case DW_OP_HP_fltconst8
:
1026 printf ("DW_OP_HP_fltconst8");
1027 /* FIXME: Is there data associated with this OP ? */
1029 case DW_OP_HP_mod_range
:
1030 printf ("DW_OP_HP_mod_range");
1031 /* FIXME: Is there data associated with this OP ? */
1033 case DW_OP_HP_unmod_range
:
1034 printf ("DW_OP_HP_unmod_range");
1035 /* FIXME: Is there data associated with this OP ? */
1038 printf ("DW_OP_HP_tls");
1039 /* FIXME: Is there data associated with this OP ? */
1042 /* PGI (STMicroelectronics) extensions. */
1043 case DW_OP_PGI_omp_thread_num
:
1044 /* Pushes the thread number for the current thread as it would be
1045 returned by the standard OpenMP library function:
1046 omp_get_thread_num(). The "current thread" is the thread for
1047 which the expression is being evaluated. */
1048 printf ("DW_OP_PGI_omp_thread_num");
1052 if (op
>= DW_OP_lo_user
1053 && op
<= DW_OP_hi_user
)
1054 printf (_("(User defined location op)"));
1056 printf (_("(Unknown location op)"));
1057 /* No way to tell where the next op is, so just bail. */
1058 return need_frame_base
;
1061 /* Separate the ops. */
1066 return need_frame_base
;
1069 static unsigned char *
1070 read_and_display_attr_value (unsigned long attribute
,
1072 unsigned char * data
,
1073 unsigned long cu_offset
,
1074 unsigned long pointer_size
,
1075 unsigned long offset_size
,
1077 debug_info
* debug_info_p
,
1079 struct dwarf_section
* section
)
1081 unsigned long uvalue
= 0;
1082 unsigned char *block_start
= NULL
;
1083 unsigned char * orig_data
= data
;
1084 unsigned int bytes_read
;
1091 case DW_FORM_ref_addr
:
1092 if (dwarf_version
== 2)
1094 uvalue
= byte_get (data
, pointer_size
);
1095 data
+= pointer_size
;
1097 else if (dwarf_version
== 3 || dwarf_version
== 4)
1099 uvalue
= byte_get (data
, offset_size
);
1100 data
+= offset_size
;
1104 error (_("Internal error: DWARF version is not 2, 3 or 4.\n"));
1109 uvalue
= byte_get (data
, pointer_size
);
1110 data
+= pointer_size
;
1114 case DW_FORM_sec_offset
:
1115 uvalue
= byte_get (data
, offset_size
);
1116 data
+= offset_size
;
1119 case DW_FORM_flag_present
:
1126 uvalue
= byte_get (data
++, 1);
1131 uvalue
= byte_get (data
, 2);
1137 uvalue
= byte_get (data
, 4);
1142 uvalue
= read_leb128 (data
, & bytes_read
, 1);
1146 case DW_FORM_ref_udata
:
1148 uvalue
= read_leb128 (data
, & bytes_read
, 0);
1152 case DW_FORM_indirect
:
1153 form
= read_leb128 (data
, & bytes_read
, 0);
1156 printf (" %s", get_FORM_name (form
));
1157 return read_and_display_attr_value (attribute
, form
, data
,
1158 cu_offset
, pointer_size
,
1159 offset_size
, dwarf_version
,
1160 debug_info_p
, do_loc
,
1166 case DW_FORM_ref_addr
:
1168 printf (" <0x%lx>", uvalue
);
1174 case DW_FORM_ref_udata
:
1176 printf (" <0x%lx>", uvalue
+ cu_offset
);
1181 case DW_FORM_sec_offset
:
1183 printf (" 0x%lx", uvalue
);
1186 case DW_FORM_flag_present
:
1193 printf (" %ld", uvalue
);
1200 uvalue
= byte_get (data
, 4);
1201 printf (" 0x%lx", uvalue
);
1202 printf (" 0x%lx", (unsigned long) byte_get (data
+ 4, 4));
1204 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1205 && num_debug_info_entries
== 0)
1207 if (sizeof (uvalue
) == 8)
1208 uvalue
= byte_get (data
, 8);
1210 error (_("DW_FORM_data8 is unsupported when sizeof (unsigned long) != 8\n"));
1215 case DW_FORM_string
:
1217 printf (" %s", data
);
1218 data
+= strlen ((char *) data
) + 1;
1222 case DW_FORM_exprloc
:
1223 uvalue
= read_leb128 (data
, & bytes_read
, 0);
1224 block_start
= data
+ bytes_read
;
1226 data
= block_start
+ uvalue
;
1228 data
= display_block (block_start
, uvalue
);
1231 case DW_FORM_block1
:
1232 uvalue
= byte_get (data
, 1);
1233 block_start
= data
+ 1;
1235 data
= block_start
+ uvalue
;
1237 data
= display_block (block_start
, uvalue
);
1240 case DW_FORM_block2
:
1241 uvalue
= byte_get (data
, 2);
1242 block_start
= data
+ 2;
1244 data
= block_start
+ uvalue
;
1246 data
= display_block (block_start
, uvalue
);
1249 case DW_FORM_block4
:
1250 uvalue
= byte_get (data
, 4);
1251 block_start
= data
+ 4;
1253 data
= block_start
+ uvalue
;
1255 data
= display_block (block_start
, uvalue
);
1260 printf (_(" (indirect string, offset: 0x%lx): %s"),
1261 uvalue
, fetch_indirect_string (uvalue
));
1264 case DW_FORM_indirect
:
1265 /* Handled above. */
1268 case DW_FORM_ref_sig8
:
1272 printf (" signature: ");
1273 for (i
= 0; i
< 8; i
++)
1275 printf ("%02x", (unsigned) byte_get (data
, 1));
1284 warn (_("Unrecognized form: %lu\n"), form
);
1288 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1289 && num_debug_info_entries
== 0)
1293 case DW_AT_frame_base
:
1294 have_frame_base
= 1;
1295 case DW_AT_location
:
1296 case DW_AT_string_length
:
1297 case DW_AT_return_addr
:
1298 case DW_AT_data_member_location
:
1299 case DW_AT_vtable_elem_location
:
1301 case DW_AT_static_link
:
1302 case DW_AT_use_location
:
1303 if (form
== DW_FORM_data4
1304 || form
== DW_FORM_data8
1305 || form
== DW_FORM_sec_offset
)
1307 /* Process location list. */
1308 unsigned int lmax
= debug_info_p
->max_loc_offsets
;
1309 unsigned int num
= debug_info_p
->num_loc_offsets
;
1311 if (lmax
== 0 || num
>= lmax
)
1314 debug_info_p
->loc_offsets
= (long unsigned int *)
1315 xcrealloc (debug_info_p
->loc_offsets
,
1316 lmax
, sizeof (*debug_info_p
->loc_offsets
));
1317 debug_info_p
->have_frame_base
= (int *)
1318 xcrealloc (debug_info_p
->have_frame_base
,
1319 lmax
, sizeof (*debug_info_p
->have_frame_base
));
1320 debug_info_p
->max_loc_offsets
= lmax
;
1322 debug_info_p
->loc_offsets
[num
] = uvalue
;
1323 debug_info_p
->have_frame_base
[num
] = have_frame_base
;
1324 debug_info_p
->num_loc_offsets
++;
1329 if (need_base_address
)
1330 debug_info_p
->base_address
= uvalue
;
1334 if (form
== DW_FORM_data4
1335 || form
== DW_FORM_data8
1336 || form
== DW_FORM_sec_offset
)
1338 /* Process range list. */
1339 unsigned int lmax
= debug_info_p
->max_range_lists
;
1340 unsigned int num
= debug_info_p
->num_range_lists
;
1342 if (lmax
== 0 || num
>= lmax
)
1345 debug_info_p
->range_lists
= (long unsigned int *)
1346 xcrealloc (debug_info_p
->range_lists
,
1347 lmax
, sizeof (*debug_info_p
->range_lists
));
1348 debug_info_p
->max_range_lists
= lmax
;
1350 debug_info_p
->range_lists
[num
] = uvalue
;
1351 debug_info_p
->num_range_lists
++;
1363 /* For some attributes we can display further information. */
1371 case DW_INL_not_inlined
:
1372 printf (_("(not inlined)"));
1374 case DW_INL_inlined
:
1375 printf (_("(inlined)"));
1377 case DW_INL_declared_not_inlined
:
1378 printf (_("(declared as inline but ignored)"));
1380 case DW_INL_declared_inlined
:
1381 printf (_("(declared as inline and inlined)"));
1384 printf (_(" (Unknown inline attribute value: %lx)"), uvalue
);
1389 case DW_AT_language
:
1392 /* Ordered by the numeric value of these constants. */
1393 case DW_LANG_C89
: printf ("(ANSI C)"); break;
1394 case DW_LANG_C
: printf ("(non-ANSI C)"); break;
1395 case DW_LANG_Ada83
: printf ("(Ada)"); break;
1396 case DW_LANG_C_plus_plus
: printf ("(C++)"); break;
1397 case DW_LANG_Cobol74
: printf ("(Cobol 74)"); break;
1398 case DW_LANG_Cobol85
: printf ("(Cobol 85)"); break;
1399 case DW_LANG_Fortran77
: printf ("(FORTRAN 77)"); break;
1400 case DW_LANG_Fortran90
: printf ("(Fortran 90)"); break;
1401 case DW_LANG_Pascal83
: printf ("(ANSI Pascal)"); break;
1402 case DW_LANG_Modula2
: printf ("(Modula 2)"); break;
1403 /* DWARF 2.1 values. */
1404 case DW_LANG_Java
: printf ("(Java)"); break;
1405 case DW_LANG_C99
: printf ("(ANSI C99)"); break;
1406 case DW_LANG_Ada95
: printf ("(ADA 95)"); break;
1407 case DW_LANG_Fortran95
: printf ("(Fortran 95)"); break;
1408 /* DWARF 3 values. */
1409 case DW_LANG_PLI
: printf ("(PLI)"); break;
1410 case DW_LANG_ObjC
: printf ("(Objective C)"); break;
1411 case DW_LANG_ObjC_plus_plus
: printf ("(Objective C++)"); break;
1412 case DW_LANG_UPC
: printf ("(Unified Parallel C)"); break;
1413 case DW_LANG_D
: printf ("(D)"); break;
1414 /* DWARF 4 values. */
1415 case DW_LANG_Python
: printf ("(Python)"); break;
1416 /* MIPS extension. */
1417 case DW_LANG_Mips_Assembler
: printf ("(MIPS assembler)"); break;
1418 /* UPC extension. */
1419 case DW_LANG_Upc
: printf ("(Unified Parallel C)"); break;
1421 if (uvalue
>= DW_LANG_lo_user
&& uvalue
<= DW_LANG_hi_user
)
1422 printf ("(implementation defined: %lx)", uvalue
);
1424 printf ("(Unknown: %lx)", uvalue
);
1429 case DW_AT_encoding
:
1432 case DW_ATE_void
: printf ("(void)"); break;
1433 case DW_ATE_address
: printf ("(machine address)"); break;
1434 case DW_ATE_boolean
: printf ("(boolean)"); break;
1435 case DW_ATE_complex_float
: printf ("(complex float)"); break;
1436 case DW_ATE_float
: printf ("(float)"); break;
1437 case DW_ATE_signed
: printf ("(signed)"); break;
1438 case DW_ATE_signed_char
: printf ("(signed char)"); break;
1439 case DW_ATE_unsigned
: printf ("(unsigned)"); break;
1440 case DW_ATE_unsigned_char
: printf ("(unsigned char)"); break;
1441 /* DWARF 2.1 values: */
1442 case DW_ATE_imaginary_float
: printf ("(imaginary float)"); break;
1443 case DW_ATE_decimal_float
: printf ("(decimal float)"); break;
1444 /* DWARF 3 values: */
1445 case DW_ATE_packed_decimal
: printf ("(packed_decimal)"); break;
1446 case DW_ATE_numeric_string
: printf ("(numeric_string)"); break;
1447 case DW_ATE_edited
: printf ("(edited)"); break;
1448 case DW_ATE_signed_fixed
: printf ("(signed_fixed)"); break;
1449 case DW_ATE_unsigned_fixed
: printf ("(unsigned_fixed)"); break;
1450 /* HP extensions: */
1451 case DW_ATE_HP_float80
: printf ("(HP_float80)"); break;
1452 case DW_ATE_HP_complex_float80
: printf ("(HP_complex_float80)"); break;
1453 case DW_ATE_HP_float128
: printf ("(HP_float128)"); break;
1454 case DW_ATE_HP_complex_float128
:printf ("(HP_complex_float128)"); break;
1455 case DW_ATE_HP_floathpintel
: printf ("(HP_floathpintel)"); break;
1456 case DW_ATE_HP_imaginary_float80
: printf ("(HP_imaginary_float80)"); break;
1457 case DW_ATE_HP_imaginary_float128
: printf ("(HP_imaginary_float128)"); break;
1460 if (uvalue
>= DW_ATE_lo_user
1461 && uvalue
<= DW_ATE_hi_user
)
1462 printf ("(user defined type)");
1464 printf ("(unknown type)");
1469 case DW_AT_accessibility
:
1472 case DW_ACCESS_public
: printf ("(public)"); break;
1473 case DW_ACCESS_protected
: printf ("(protected)"); break;
1474 case DW_ACCESS_private
: printf ("(private)"); break;
1476 printf ("(unknown accessibility)");
1481 case DW_AT_visibility
:
1484 case DW_VIS_local
: printf ("(local)"); break;
1485 case DW_VIS_exported
: printf ("(exported)"); break;
1486 case DW_VIS_qualified
: printf ("(qualified)"); break;
1487 default: printf ("(unknown visibility)"); break;
1491 case DW_AT_virtuality
:
1494 case DW_VIRTUALITY_none
: printf ("(none)"); break;
1495 case DW_VIRTUALITY_virtual
: printf ("(virtual)"); break;
1496 case DW_VIRTUALITY_pure_virtual
:printf ("(pure_virtual)"); break;
1497 default: printf ("(unknown virtuality)"); break;
1501 case DW_AT_identifier_case
:
1504 case DW_ID_case_sensitive
: printf ("(case_sensitive)"); break;
1505 case DW_ID_up_case
: printf ("(up_case)"); break;
1506 case DW_ID_down_case
: printf ("(down_case)"); break;
1507 case DW_ID_case_insensitive
: printf ("(case_insensitive)"); break;
1508 default: printf ("(unknown case)"); break;
1512 case DW_AT_calling_convention
:
1515 case DW_CC_normal
: printf ("(normal)"); break;
1516 case DW_CC_program
: printf ("(program)"); break;
1517 case DW_CC_nocall
: printf ("(nocall)"); break;
1519 if (uvalue
>= DW_CC_lo_user
1520 && uvalue
<= DW_CC_hi_user
)
1521 printf ("(user defined)");
1523 printf ("(unknown convention)");
1527 case DW_AT_ordering
:
1530 case -1: printf ("(undefined)"); break;
1531 case 0: printf ("(row major)"); break;
1532 case 1: printf ("(column major)"); break;
1536 case DW_AT_frame_base
:
1537 have_frame_base
= 1;
1538 case DW_AT_location
:
1539 case DW_AT_string_length
:
1540 case DW_AT_return_addr
:
1541 case DW_AT_data_member_location
:
1542 case DW_AT_vtable_elem_location
:
1544 case DW_AT_static_link
:
1545 case DW_AT_use_location
:
1546 if (form
== DW_FORM_data4
1547 || form
== DW_FORM_data8
1548 || form
== DW_FORM_sec_offset
)
1549 printf (_("(location list)"));
1551 case DW_AT_allocated
:
1552 case DW_AT_associated
:
1553 case DW_AT_data_location
:
1555 case DW_AT_upper_bound
:
1556 case DW_AT_lower_bound
:
1559 int need_frame_base
;
1562 need_frame_base
= decode_location_expression (block_start
,
1567 cu_offset
, section
);
1569 if (need_frame_base
&& !have_frame_base
)
1570 printf (_(" [without DW_AT_frame_base]"));
1576 if (form
== DW_FORM_ref_sig8
)
1579 if (form
== DW_FORM_ref1
1580 || form
== DW_FORM_ref2
1581 || form
== DW_FORM_ref4
)
1582 uvalue
+= cu_offset
;
1584 if (uvalue
>= section
->size
)
1585 warn (_("Offset %lx used as value for DW_AT_import attribute of DIE at offset %lx is too big.\n"),
1586 uvalue
, (unsigned long) (orig_data
- section
->start
));
1589 unsigned long abbrev_number
;
1590 abbrev_entry
* entry
;
1592 abbrev_number
= read_leb128 (section
->start
+ uvalue
, NULL
, 0);
1594 printf ("[Abbrev Number: %ld", abbrev_number
);
1595 for (entry
= first_abbrev
; entry
!= NULL
; entry
= entry
->next
)
1596 if (entry
->entry
== abbrev_number
)
1599 printf (" (%s)", get_TAG_name (entry
->tag
));
1613 get_AT_name (unsigned long attribute
)
1617 case DW_AT_sibling
: return "DW_AT_sibling";
1618 case DW_AT_location
: return "DW_AT_location";
1619 case DW_AT_name
: return "DW_AT_name";
1620 case DW_AT_ordering
: return "DW_AT_ordering";
1621 case DW_AT_subscr_data
: return "DW_AT_subscr_data";
1622 case DW_AT_byte_size
: return "DW_AT_byte_size";
1623 case DW_AT_bit_offset
: return "DW_AT_bit_offset";
1624 case DW_AT_bit_size
: return "DW_AT_bit_size";
1625 case DW_AT_element_list
: return "DW_AT_element_list";
1626 case DW_AT_stmt_list
: return "DW_AT_stmt_list";
1627 case DW_AT_low_pc
: return "DW_AT_low_pc";
1628 case DW_AT_high_pc
: return "DW_AT_high_pc";
1629 case DW_AT_language
: return "DW_AT_language";
1630 case DW_AT_member
: return "DW_AT_member";
1631 case DW_AT_discr
: return "DW_AT_discr";
1632 case DW_AT_discr_value
: return "DW_AT_discr_value";
1633 case DW_AT_visibility
: return "DW_AT_visibility";
1634 case DW_AT_import
: return "DW_AT_import";
1635 case DW_AT_string_length
: return "DW_AT_string_length";
1636 case DW_AT_common_reference
: return "DW_AT_common_reference";
1637 case DW_AT_comp_dir
: return "DW_AT_comp_dir";
1638 case DW_AT_const_value
: return "DW_AT_const_value";
1639 case DW_AT_containing_type
: return "DW_AT_containing_type";
1640 case DW_AT_default_value
: return "DW_AT_default_value";
1641 case DW_AT_inline
: return "DW_AT_inline";
1642 case DW_AT_is_optional
: return "DW_AT_is_optional";
1643 case DW_AT_lower_bound
: return "DW_AT_lower_bound";
1644 case DW_AT_producer
: return "DW_AT_producer";
1645 case DW_AT_prototyped
: return "DW_AT_prototyped";
1646 case DW_AT_return_addr
: return "DW_AT_return_addr";
1647 case DW_AT_start_scope
: return "DW_AT_start_scope";
1648 case DW_AT_stride_size
: return "DW_AT_stride_size";
1649 case DW_AT_upper_bound
: return "DW_AT_upper_bound";
1650 case DW_AT_abstract_origin
: return "DW_AT_abstract_origin";
1651 case DW_AT_accessibility
: return "DW_AT_accessibility";
1652 case DW_AT_address_class
: return "DW_AT_address_class";
1653 case DW_AT_artificial
: return "DW_AT_artificial";
1654 case DW_AT_base_types
: return "DW_AT_base_types";
1655 case DW_AT_calling_convention
: return "DW_AT_calling_convention";
1656 case DW_AT_count
: return "DW_AT_count";
1657 case DW_AT_data_member_location
: return "DW_AT_data_member_location";
1658 case DW_AT_decl_column
: return "DW_AT_decl_column";
1659 case DW_AT_decl_file
: return "DW_AT_decl_file";
1660 case DW_AT_decl_line
: return "DW_AT_decl_line";
1661 case DW_AT_declaration
: return "DW_AT_declaration";
1662 case DW_AT_discr_list
: return "DW_AT_discr_list";
1663 case DW_AT_encoding
: return "DW_AT_encoding";
1664 case DW_AT_external
: return "DW_AT_external";
1665 case DW_AT_frame_base
: return "DW_AT_frame_base";
1666 case DW_AT_friend
: return "DW_AT_friend";
1667 case DW_AT_identifier_case
: return "DW_AT_identifier_case";
1668 case DW_AT_macro_info
: return "DW_AT_macro_info";
1669 case DW_AT_namelist_items
: return "DW_AT_namelist_items";
1670 case DW_AT_priority
: return "DW_AT_priority";
1671 case DW_AT_segment
: return "DW_AT_segment";
1672 case DW_AT_specification
: return "DW_AT_specification";
1673 case DW_AT_static_link
: return "DW_AT_static_link";
1674 case DW_AT_type
: return "DW_AT_type";
1675 case DW_AT_use_location
: return "DW_AT_use_location";
1676 case DW_AT_variable_parameter
: return "DW_AT_variable_parameter";
1677 case DW_AT_virtuality
: return "DW_AT_virtuality";
1678 case DW_AT_vtable_elem_location
: return "DW_AT_vtable_elem_location";
1679 /* DWARF 2.1 values. */
1680 case DW_AT_allocated
: return "DW_AT_allocated";
1681 case DW_AT_associated
: return "DW_AT_associated";
1682 case DW_AT_data_location
: return "DW_AT_data_location";
1683 case DW_AT_stride
: return "DW_AT_stride";
1684 case DW_AT_entry_pc
: return "DW_AT_entry_pc";
1685 case DW_AT_use_UTF8
: return "DW_AT_use_UTF8";
1686 case DW_AT_extension
: return "DW_AT_extension";
1687 case DW_AT_ranges
: return "DW_AT_ranges";
1688 case DW_AT_trampoline
: return "DW_AT_trampoline";
1689 case DW_AT_call_column
: return "DW_AT_call_column";
1690 case DW_AT_call_file
: return "DW_AT_call_file";
1691 case DW_AT_call_line
: return "DW_AT_call_line";
1692 case DW_AT_description
: return "DW_AT_description";
1693 case DW_AT_binary_scale
: return "DW_AT_binary_scale";
1694 case DW_AT_decimal_scale
: return "DW_AT_decimal_scale";
1695 case DW_AT_small
: return "DW_AT_small";
1696 case DW_AT_decimal_sign
: return "DW_AT_decimal_sign";
1697 case DW_AT_digit_count
: return "DW_AT_digit_count";
1698 case DW_AT_picture_string
: return "DW_AT_picture_string";
1699 case DW_AT_mutable
: return "DW_AT_mutable";
1700 case DW_AT_threads_scaled
: return "DW_AT_threads_scaled";
1701 case DW_AT_explicit
: return "DW_AT_explicit";
1702 case DW_AT_object_pointer
: return "DW_AT_object_pointer";
1703 case DW_AT_endianity
: return "DW_AT_endianity";
1704 case DW_AT_elemental
: return "DW_AT_elemental";
1705 case DW_AT_pure
: return "DW_AT_pure";
1706 case DW_AT_recursive
: return "DW_AT_recursive";
1707 /* DWARF 4 values. */
1708 case DW_AT_signature
: return "DW_AT_signature";
1709 case DW_AT_main_subprogram
: return "DW_AT_main_subprogram";
1710 case DW_AT_data_bit_offset
: return "DW_AT_data_bit_offset";
1711 case DW_AT_const_expr
: return "DW_AT_const_expr";
1712 case DW_AT_enum_class
: return "DW_AT_enum_class";
1713 case DW_AT_linkage_name
: return "DW_AT_linkage_name";
1715 /* HP and SGI/MIPS extensions. */
1716 case DW_AT_MIPS_loop_begin
: return "DW_AT_MIPS_loop_begin";
1717 case DW_AT_MIPS_tail_loop_begin
: return "DW_AT_MIPS_tail_loop_begin";
1718 case DW_AT_MIPS_epilog_begin
: return "DW_AT_MIPS_epilog_begin";
1719 case DW_AT_MIPS_loop_unroll_factor
: return "DW_AT_MIPS_loop_unroll_factor";
1720 case DW_AT_MIPS_software_pipeline_depth
: return "DW_AT_MIPS_software_pipeline_depth";
1721 case DW_AT_MIPS_linkage_name
: return "DW_AT_MIPS_linkage_name";
1722 case DW_AT_MIPS_stride
: return "DW_AT_MIPS_stride";
1723 case DW_AT_MIPS_abstract_name
: return "DW_AT_MIPS_abstract_name";
1724 case DW_AT_MIPS_clone_origin
: return "DW_AT_MIPS_clone_origin";
1725 case DW_AT_MIPS_has_inlines
: return "DW_AT_MIPS_has_inlines";
1727 /* HP Extensions. */
1728 case DW_AT_HP_block_index
: return "DW_AT_HP_block_index";
1729 case DW_AT_HP_actuals_stmt_list
: return "DW_AT_HP_actuals_stmt_list";
1730 case DW_AT_HP_proc_per_section
: return "DW_AT_HP_proc_per_section";
1731 case DW_AT_HP_raw_data_ptr
: return "DW_AT_HP_raw_data_ptr";
1732 case DW_AT_HP_pass_by_reference
: return "DW_AT_HP_pass_by_reference";
1733 case DW_AT_HP_opt_level
: return "DW_AT_HP_opt_level";
1734 case DW_AT_HP_prof_version_id
: return "DW_AT_HP_prof_version_id";
1735 case DW_AT_HP_opt_flags
: return "DW_AT_HP_opt_flags";
1736 case DW_AT_HP_cold_region_low_pc
: return "DW_AT_HP_cold_region_low_pc";
1737 case DW_AT_HP_cold_region_high_pc
: return "DW_AT_HP_cold_region_high_pc";
1738 case DW_AT_HP_all_variables_modifiable
: return "DW_AT_HP_all_variables_modifiable";
1739 case DW_AT_HP_linkage_name
: return "DW_AT_HP_linkage_name";
1740 case DW_AT_HP_prof_flags
: return "DW_AT_HP_prof_flags";
1742 /* One value is shared by the MIPS and HP extensions: */
1743 case DW_AT_MIPS_fde
: return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable";
1745 /* GNU extensions. */
1746 case DW_AT_sf_names
: return "DW_AT_sf_names";
1747 case DW_AT_src_info
: return "DW_AT_src_info";
1748 case DW_AT_mac_info
: return "DW_AT_mac_info";
1749 case DW_AT_src_coords
: return "DW_AT_src_coords";
1750 case DW_AT_body_begin
: return "DW_AT_body_begin";
1751 case DW_AT_body_end
: return "DW_AT_body_end";
1752 case DW_AT_GNU_vector
: return "DW_AT_GNU_vector";
1753 case DW_AT_GNU_guarded_by
: return "DW_AT_GNU_guarded_by";
1754 case DW_AT_GNU_pt_guarded_by
: return "DW_AT_GNU_pt_guarded_by";
1755 case DW_AT_GNU_guarded
: return "DW_AT_GNU_guarded";
1756 case DW_AT_GNU_pt_guarded
: return "DW_AT_GNU_pt_guarded";
1757 case DW_AT_GNU_locks_excluded
: return "DW_AT_GNU_locks_excluded";
1758 case DW_AT_GNU_exclusive_locks_required
: return "DW_AT_GNU_exclusive_locks_required";
1759 case DW_AT_GNU_shared_locks_required
: return "DW_AT_GNU_shared_locks_required";
1760 case DW_AT_GNU_odr_signature
: return "DW_AT_GNU_odr_signature";
1761 case DW_AT_use_GNAT_descriptive_type
: return "DW_AT_use_GNAT_descriptive_type";
1762 case DW_AT_GNAT_descriptive_type
: return "DW_AT_GNAT_descriptive_type";
1764 /* UPC extension. */
1765 case DW_AT_upc_threads_scaled
: return "DW_AT_upc_threads_scaled";
1767 /* PGI (STMicroelectronics) extensions. */
1768 case DW_AT_PGI_lbase
: return "DW_AT_PGI_lbase";
1769 case DW_AT_PGI_soffset
: return "DW_AT_PGI_soffset";
1770 case DW_AT_PGI_lstride
: return "DW_AT_PGI_lstride";
1774 static char buffer
[100];
1776 snprintf (buffer
, sizeof (buffer
), _("Unknown AT value: %lx"),
1783 static unsigned char *
1784 read_and_display_attr (unsigned long attribute
,
1786 unsigned char * data
,
1787 unsigned long cu_offset
,
1788 unsigned long pointer_size
,
1789 unsigned long offset_size
,
1791 debug_info
* debug_info_p
,
1793 struct dwarf_section
* section
)
1796 printf (" %-18s:", get_AT_name (attribute
));
1797 data
= read_and_display_attr_value (attribute
, form
, data
, cu_offset
,
1798 pointer_size
, offset_size
,
1799 dwarf_version
, debug_info_p
,
1807 /* Process the contents of a .debug_info section. If do_loc is non-zero
1808 then we are scanning for location lists and we do not want to display
1809 anything to the user. If do_types is non-zero, we are processing
1810 a .debug_types section instead of a .debug_info section. */
1813 process_debug_info (struct dwarf_section
*section
,
1815 enum dwarf_section_display_enum abbrev_sec
,
1819 unsigned char *start
= section
->start
;
1820 unsigned char *end
= start
+ section
->size
;
1821 unsigned char *section_begin
;
1823 unsigned int num_units
= 0;
1825 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1826 && num_debug_info_entries
== 0
1829 unsigned long length
;
1831 /* First scan the section to get the number of comp units. */
1832 for (section_begin
= start
, num_units
= 0; section_begin
< end
;
1835 /* Read the first 4 bytes. For a 32-bit DWARF section, this
1836 will be the length. For a 64-bit DWARF section, it'll be
1837 the escape code 0xffffffff followed by an 8 byte length. */
1838 length
= byte_get (section_begin
, 4);
1840 if (length
== 0xffffffff)
1842 length
= byte_get (section_begin
+ 4, 8);
1843 section_begin
+= length
+ 12;
1845 else if (length
>= 0xfffffff0 && length
< 0xffffffff)
1847 warn (_("Reserved length value (%lx) found in section %s\n"), length
, section
->name
);
1851 section_begin
+= length
+ 4;
1853 /* Negative values are illegal, they may even cause infinite
1854 looping. This can happen if we can't accurately apply
1855 relocations to an object file. */
1856 if ((signed long) length
<= 0)
1858 warn (_("Corrupt unit length (%lx) found in section %s\n"), length
, section
->name
);
1865 error (_("No comp units in %s section ?"), section
->name
);
1869 /* Then allocate an array to hold the information. */
1870 debug_information
= (debug_info
*) cmalloc (num_units
,
1871 sizeof (* debug_information
));
1872 if (debug_information
== NULL
)
1874 error (_("Not enough memory for a debug info array of %u entries"),
1882 printf (_("Contents of the %s section:\n\n"), section
->name
);
1884 load_debug_section (str
, file
);
1887 load_debug_section (abbrev_sec
, file
);
1888 if (debug_displays
[abbrev_sec
].section
.start
== NULL
)
1890 warn (_("Unable to locate %s section!\n"),
1891 debug_displays
[abbrev_sec
].section
.name
);
1895 for (section_begin
= start
, unit
= 0; start
< end
; unit
++)
1897 DWARF2_Internal_CompUnit compunit
;
1898 unsigned char *hdrptr
;
1899 unsigned char *tags
;
1901 unsigned long cu_offset
;
1903 int initial_length_size
;
1904 unsigned char signature
[8] = { 0 };
1905 unsigned long type_offset
= 0;
1909 compunit
.cu_length
= byte_get (hdrptr
, 4);
1912 if (compunit
.cu_length
== 0xffffffff)
1914 compunit
.cu_length
= byte_get (hdrptr
, 8);
1917 initial_length_size
= 12;
1922 initial_length_size
= 4;
1925 compunit
.cu_version
= byte_get (hdrptr
, 2);
1928 cu_offset
= start
- section_begin
;
1930 compunit
.cu_abbrev_offset
= byte_get (hdrptr
, offset_size
);
1931 hdrptr
+= offset_size
;
1933 compunit
.cu_pointer_size
= byte_get (hdrptr
, 1);
1940 for (i
= 0; i
< 8; i
++)
1942 signature
[i
] = byte_get (hdrptr
, 1);
1946 type_offset
= byte_get (hdrptr
, offset_size
);
1947 hdrptr
+= offset_size
;
1950 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1951 && num_debug_info_entries
== 0
1954 debug_information
[unit
].cu_offset
= cu_offset
;
1955 debug_information
[unit
].pointer_size
1956 = compunit
.cu_pointer_size
;
1957 debug_information
[unit
].offset_size
= offset_size
;
1958 debug_information
[unit
].dwarf_version
= compunit
.cu_version
;
1959 debug_information
[unit
].base_address
= 0;
1960 debug_information
[unit
].loc_offsets
= NULL
;
1961 debug_information
[unit
].have_frame_base
= NULL
;
1962 debug_information
[unit
].max_loc_offsets
= 0;
1963 debug_information
[unit
].num_loc_offsets
= 0;
1964 debug_information
[unit
].range_lists
= NULL
;
1965 debug_information
[unit
].max_range_lists
= 0;
1966 debug_information
[unit
].num_range_lists
= 0;
1971 printf (_(" Compilation Unit @ offset 0x%lx:\n"), cu_offset
);
1972 printf (_(" Length: 0x%lx (%s)\n"), compunit
.cu_length
,
1973 initial_length_size
== 8 ? "64-bit" : "32-bit");
1974 printf (_(" Version: %d\n"), compunit
.cu_version
);
1975 printf (_(" Abbrev Offset: %ld\n"), compunit
.cu_abbrev_offset
);
1976 printf (_(" Pointer Size: %d\n"), compunit
.cu_pointer_size
);
1980 printf (_(" Signature: "));
1981 for (i
= 0; i
< 8; i
++)
1982 printf ("%02x", signature
[i
]);
1984 printf (_(" Type Offset: 0x%lx\n"), type_offset
);
1988 if (cu_offset
+ compunit
.cu_length
+ initial_length_size
1991 warn (_("Debug info is corrupted, length of CU at %lx extends beyond end of section (length = %lx)\n"),
1992 cu_offset
, compunit
.cu_length
);
1996 start
+= compunit
.cu_length
+ initial_length_size
;
1998 if (compunit
.cu_version
!= 2
1999 && compunit
.cu_version
!= 3
2000 && compunit
.cu_version
!= 4)
2002 warn (_("CU at offset %lx contains corrupt or unsupported version number: %d.\n"),
2003 cu_offset
, compunit
.cu_version
);
2009 /* Process the abbrevs used by this compilation unit. DWARF
2010 sections under Mach-O have non-zero addresses. */
2011 if (compunit
.cu_abbrev_offset
>= debug_displays
[abbrev_sec
].section
.size
)
2012 warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"),
2013 (unsigned long) compunit
.cu_abbrev_offset
,
2014 (unsigned long) debug_displays
[abbrev_sec
].section
.size
);
2016 process_abbrev_section
2017 ((unsigned char *) debug_displays
[abbrev_sec
].section
.start
2018 + compunit
.cu_abbrev_offset
,
2019 (unsigned char *) debug_displays
[abbrev_sec
].section
.start
2020 + debug_displays
[abbrev_sec
].section
.size
);
2023 while (tags
< start
)
2025 unsigned int bytes_read
;
2026 unsigned long abbrev_number
;
2027 unsigned long die_offset
;
2028 abbrev_entry
*entry
;
2031 die_offset
= tags
- section_begin
;
2033 abbrev_number
= read_leb128 (tags
, & bytes_read
, 0);
2036 /* A null DIE marks the end of a list of siblings or it may also be
2037 a section padding. */
2038 if (abbrev_number
== 0)
2040 /* Check if it can be a section padding for the last CU. */
2041 if (level
== 0 && start
== end
)
2045 for (chk
= tags
; chk
< start
; chk
++)
2055 static unsigned num_bogus_warns
= 0;
2057 if (num_bogus_warns
< 3)
2059 warn (_("Bogus end-of-siblings marker detected at offset %lx in .debug_info section\n"),
2062 if (num_bogus_warns
== 3)
2063 warn (_("Further warnings about bogus end-of-sibling markers suppressed\n"));
2070 printf (_(" <%d><%lx>: Abbrev Number: %lu"),
2071 level
, die_offset
, abbrev_number
);
2073 /* Scan through the abbreviation list until we reach the
2075 for (entry
= first_abbrev
;
2076 entry
&& entry
->entry
!= abbrev_number
;
2077 entry
= entry
->next
)
2087 warn (_("DIE at offset %lx refers to abbreviation number %lu which does not exist\n"),
2088 die_offset
, abbrev_number
);
2093 printf (" (%s)\n", get_TAG_name (entry
->tag
));
2098 need_base_address
= 0;
2100 case DW_TAG_compile_unit
:
2101 need_base_address
= 1;
2103 case DW_TAG_entry_point
:
2104 case DW_TAG_subprogram
:
2105 need_base_address
= 0;
2106 /* Assuming that there is no DW_AT_frame_base. */
2107 have_frame_base
= 0;
2111 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
2114 /* Show the offset from where the tag was extracted. */
2115 printf (" <%2lx>", (unsigned long)(tags
- section_begin
));
2117 tags
= read_and_display_attr (attr
->attribute
,
2120 compunit
.cu_pointer_size
,
2122 compunit
.cu_version
,
2123 debug_information
+ unit
,
2127 if (entry
->children
)
2132 /* Set num_debug_info_entries here so that it can be used to check if
2133 we need to process .debug_loc and .debug_ranges sections. */
2134 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2135 && num_debug_info_entries
== 0
2137 num_debug_info_entries
= num_units
;
2147 /* Locate and scan the .debug_info section in the file and record the pointer
2148 sizes and offsets for the compilation units in it. Usually an executable
2149 will have just one pointer size, but this is not guaranteed, and so we try
2150 not to make any assumptions. Returns zero upon failure, or the number of
2151 compilation units upon success. */
2154 load_debug_info (void * file
)
2156 /* Reset the last pointer size so that we can issue correct error
2157 messages if we are displaying the contents of more than one section. */
2158 last_pointer_size
= 0;
2159 warned_about_missing_comp_units
= FALSE
;
2161 /* If we have already tried and failed to load the .debug_info
2162 section then do not bother to repear the task. */
2163 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
2166 /* If we already have the information there is nothing else to do. */
2167 if (num_debug_info_entries
> 0)
2168 return num_debug_info_entries
;
2170 if (load_debug_section (info
, file
)
2171 && process_debug_info (&debug_displays
[info
].section
, file
, abbrev
, 1, 0))
2172 return num_debug_info_entries
;
2174 num_debug_info_entries
= DEBUG_INFO_UNAVAILABLE
;
2179 display_debug_lines_raw (struct dwarf_section
*section
,
2180 unsigned char *data
,
2183 unsigned char *start
= section
->start
;
2185 printf (_("Raw dump of debug contents of section %s:\n\n"),
2190 DWARF2_Internal_LineInfo linfo
;
2191 unsigned char *standard_opcodes
;
2192 unsigned char *end_of_sequence
;
2193 unsigned char *hdrptr
;
2194 unsigned long hdroff
;
2195 int initial_length_size
;
2200 hdroff
= hdrptr
- start
;
2202 /* Check the length of the block. */
2203 linfo
.li_length
= byte_get (hdrptr
, 4);
2206 if (linfo
.li_length
== 0xffffffff)
2208 /* This section is 64-bit DWARF 3. */
2209 linfo
.li_length
= byte_get (hdrptr
, 8);
2212 initial_length_size
= 12;
2217 initial_length_size
= 4;
2220 if (linfo
.li_length
+ initial_length_size
> section
->size
)
2223 (_("The information in section %s appears to be corrupt - the section is too small\n"),
2228 /* Check its version number. */
2229 linfo
.li_version
= byte_get (hdrptr
, 2);
2231 if (linfo
.li_version
!= 2
2232 && linfo
.li_version
!= 3
2233 && linfo
.li_version
!= 4)
2235 warn (_("Only DWARF version 2, 3 and 4 line info is currently supported.\n"));
2239 linfo
.li_prologue_length
= byte_get (hdrptr
, offset_size
);
2240 hdrptr
+= offset_size
;
2241 linfo
.li_min_insn_length
= byte_get (hdrptr
, 1);
2243 if (linfo
.li_version
>= 4)
2245 linfo
.li_max_ops_per_insn
= byte_get (hdrptr
, 1);
2247 if (linfo
.li_max_ops_per_insn
== 0)
2249 warn (_("Invalid maximum operations per insn.\n"));
2254 linfo
.li_max_ops_per_insn
= 1;
2255 linfo
.li_default_is_stmt
= byte_get (hdrptr
, 1);
2257 linfo
.li_line_base
= byte_get (hdrptr
, 1);
2259 linfo
.li_line_range
= byte_get (hdrptr
, 1);
2261 linfo
.li_opcode_base
= byte_get (hdrptr
, 1);
2264 /* Sign extend the line base field. */
2265 linfo
.li_line_base
<<= 24;
2266 linfo
.li_line_base
>>= 24;
2268 printf (_(" Offset: 0x%lx\n"), hdroff
);
2269 printf (_(" Length: %ld\n"), linfo
.li_length
);
2270 printf (_(" DWARF Version: %d\n"), linfo
.li_version
);
2271 printf (_(" Prologue Length: %d\n"), linfo
.li_prologue_length
);
2272 printf (_(" Minimum Instruction Length: %d\n"), linfo
.li_min_insn_length
);
2273 if (linfo
.li_version
>= 4)
2274 printf (_(" Maximum Ops per Instruction: %d\n"), linfo
.li_max_ops_per_insn
);
2275 printf (_(" Initial value of 'is_stmt': %d\n"), linfo
.li_default_is_stmt
);
2276 printf (_(" Line Base: %d\n"), linfo
.li_line_base
);
2277 printf (_(" Line Range: %d\n"), linfo
.li_line_range
);
2278 printf (_(" Opcode Base: %d\n"), linfo
.li_opcode_base
);
2280 end_of_sequence
= data
+ linfo
.li_length
+ initial_length_size
;
2282 reset_state_machine (linfo
.li_default_is_stmt
);
2284 /* Display the contents of the Opcodes table. */
2285 standard_opcodes
= hdrptr
;
2287 printf (_("\n Opcodes:\n"));
2289 for (i
= 1; i
< linfo
.li_opcode_base
; i
++)
2290 printf (_(" Opcode %d has %d args\n"), i
, standard_opcodes
[i
- 1]);
2292 /* Display the contents of the Directory table. */
2293 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
2296 printf (_("\n The Directory Table is empty.\n"));
2299 printf (_("\n The Directory Table:\n"));
2303 printf (" %s\n", data
);
2305 data
+= strlen ((char *) data
) + 1;
2309 /* Skip the NUL at the end of the table. */
2312 /* Display the contents of the File Name table. */
2314 printf (_("\n The File Name Table is empty.\n"));
2317 printf (_("\n The File Name Table:\n"));
2318 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
2322 unsigned char *name
;
2323 unsigned int bytes_read
;
2325 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
2328 data
+= strlen ((char *) data
) + 1;
2330 printf ("%lu\t", read_leb128 (data
, & bytes_read
, 0));
2332 printf ("%lu\t", read_leb128 (data
, & bytes_read
, 0));
2334 printf ("%lu\t", read_leb128 (data
, & bytes_read
, 0));
2336 printf ("%s\n", name
);
2340 /* Skip the NUL at the end of the table. */
2343 /* Now display the statements. */
2344 printf (_("\n Line Number Statements:\n"));
2346 while (data
< end_of_sequence
)
2348 unsigned char op_code
;
2350 unsigned long int uladv
;
2351 unsigned int bytes_read
;
2355 if (op_code
>= linfo
.li_opcode_base
)
2357 op_code
-= linfo
.li_opcode_base
;
2358 uladv
= (op_code
/ linfo
.li_line_range
);
2359 if (linfo
.li_max_ops_per_insn
== 1)
2361 uladv
*= linfo
.li_min_insn_length
;
2362 state_machine_regs
.address
+= uladv
;
2363 printf (_(" Special opcode %d: advance Address by %lu to 0x%lx"),
2364 op_code
, uladv
, state_machine_regs
.address
);
2368 state_machine_regs
.address
2369 += ((state_machine_regs
.op_index
+ uladv
)
2370 / linfo
.li_max_ops_per_insn
)
2371 * linfo
.li_min_insn_length
;
2372 state_machine_regs
.op_index
2373 = (state_machine_regs
.op_index
+ uladv
)
2374 % linfo
.li_max_ops_per_insn
;
2375 printf (_(" Special opcode %d: advance Address by %lu to 0x%lx[%d]"),
2376 op_code
, uladv
, state_machine_regs
.address
,
2377 state_machine_regs
.op_index
);
2379 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
2380 state_machine_regs
.line
+= adv
;
2381 printf (_(" and Line by %d to %d\n"),
2382 adv
, state_machine_regs
.line
);
2384 else switch (op_code
)
2386 case DW_LNS_extended_op
:
2387 data
+= process_extended_line_op (data
, linfo
.li_default_is_stmt
);
2391 printf (_(" Copy\n"));
2394 case DW_LNS_advance_pc
:
2395 uladv
= read_leb128 (data
, & bytes_read
, 0);
2397 if (linfo
.li_max_ops_per_insn
== 1)
2399 uladv
*= linfo
.li_min_insn_length
;
2400 state_machine_regs
.address
+= uladv
;
2401 printf (_(" Advance PC by %lu to 0x%lx\n"), uladv
,
2402 state_machine_regs
.address
);
2406 state_machine_regs
.address
2407 += ((state_machine_regs
.op_index
+ uladv
)
2408 / linfo
.li_max_ops_per_insn
)
2409 * linfo
.li_min_insn_length
;
2410 state_machine_regs
.op_index
2411 = (state_machine_regs
.op_index
+ uladv
)
2412 % linfo
.li_max_ops_per_insn
;
2413 printf (_(" Advance PC by %lu to 0x%lx[%d]\n"), uladv
,
2414 state_machine_regs
.address
,
2415 state_machine_regs
.op_index
);
2419 case DW_LNS_advance_line
:
2420 adv
= read_leb128 (data
, & bytes_read
, 1);
2422 state_machine_regs
.line
+= adv
;
2423 printf (_(" Advance Line by %d to %d\n"), adv
,
2424 state_machine_regs
.line
);
2427 case DW_LNS_set_file
:
2428 adv
= read_leb128 (data
, & bytes_read
, 0);
2430 printf (_(" Set File Name to entry %d in the File Name Table\n"),
2432 state_machine_regs
.file
= adv
;
2435 case DW_LNS_set_column
:
2436 uladv
= read_leb128 (data
, & bytes_read
, 0);
2438 printf (_(" Set column to %lu\n"), uladv
);
2439 state_machine_regs
.column
= uladv
;
2442 case DW_LNS_negate_stmt
:
2443 adv
= state_machine_regs
.is_stmt
;
2445 printf (_(" Set is_stmt to %d\n"), adv
);
2446 state_machine_regs
.is_stmt
= adv
;
2449 case DW_LNS_set_basic_block
:
2450 printf (_(" Set basic block\n"));
2451 state_machine_regs
.basic_block
= 1;
2454 case DW_LNS_const_add_pc
:
2455 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
2456 if (linfo
.li_max_ops_per_insn
)
2458 uladv
*= linfo
.li_min_insn_length
;
2459 state_machine_regs
.address
+= uladv
;
2460 printf (_(" Advance PC by constant %lu to 0x%lx\n"), uladv
,
2461 state_machine_regs
.address
);
2465 state_machine_regs
.address
2466 += ((state_machine_regs
.op_index
+ uladv
)
2467 / linfo
.li_max_ops_per_insn
)
2468 * linfo
.li_min_insn_length
;
2469 state_machine_regs
.op_index
2470 = (state_machine_regs
.op_index
+ uladv
)
2471 % linfo
.li_max_ops_per_insn
;
2472 printf (_(" Advance PC by constant %lu to 0x%lx[%d]\n"),
2473 uladv
, state_machine_regs
.address
,
2474 state_machine_regs
.op_index
);
2478 case DW_LNS_fixed_advance_pc
:
2479 uladv
= byte_get (data
, 2);
2481 state_machine_regs
.address
+= uladv
;
2482 state_machine_regs
.op_index
= 0;
2483 printf (_(" Advance PC by fixed size amount %lu to 0x%lx\n"),
2484 uladv
, state_machine_regs
.address
);
2487 case DW_LNS_set_prologue_end
:
2488 printf (_(" Set prologue_end to true\n"));
2491 case DW_LNS_set_epilogue_begin
:
2492 printf (_(" Set epilogue_begin to true\n"));
2495 case DW_LNS_set_isa
:
2496 uladv
= read_leb128 (data
, & bytes_read
, 0);
2498 printf (_(" Set ISA to %lu\n"), uladv
);
2502 printf (_(" Unknown opcode %d with operands: "), op_code
);
2504 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
2506 printf ("0x%lx%s", read_leb128 (data
, &bytes_read
, 0),
2507 i
== 1 ? "" : ", ");
2522 unsigned char *name
;
2523 unsigned int directory_index
;
2524 unsigned int modification_date
;
2525 unsigned int length
;
2528 /* Output a decoded representation of the .debug_line section. */
2531 display_debug_lines_decoded (struct dwarf_section
*section
,
2532 unsigned char *data
,
2535 printf (_("Decoded dump of debug contents of section %s:\n\n"),
2540 /* This loop amounts to one iteration per compilation unit. */
2541 DWARF2_Internal_LineInfo linfo
;
2542 unsigned char *standard_opcodes
;
2543 unsigned char *end_of_sequence
;
2544 unsigned char *hdrptr
;
2545 int initial_length_size
;
2548 File_Entry
*file_table
= NULL
;
2549 unsigned char **directory_table
= NULL
;
2553 /* Extract information from the Line Number Program Header.
2554 (section 6.2.4 in the Dwarf3 doc). */
2556 /* Get the length of this CU's line number information block. */
2557 linfo
.li_length
= byte_get (hdrptr
, 4);
2560 if (linfo
.li_length
== 0xffffffff)
2562 /* This section is 64-bit DWARF 3. */
2563 linfo
.li_length
= byte_get (hdrptr
, 8);
2566 initial_length_size
= 12;
2571 initial_length_size
= 4;
2574 if (linfo
.li_length
+ initial_length_size
> section
->size
)
2576 warn (_("The line info appears to be corrupt - "
2577 "the section is too small\n"));
2581 /* Get this CU's Line Number Block version number. */
2582 linfo
.li_version
= byte_get (hdrptr
, 2);
2584 if (linfo
.li_version
!= 2
2585 && linfo
.li_version
!= 3
2586 && linfo
.li_version
!= 4)
2588 warn (_("Only DWARF version 2, 3 and 4 line info is currently "
2593 linfo
.li_prologue_length
= byte_get (hdrptr
, offset_size
);
2594 hdrptr
+= offset_size
;
2595 linfo
.li_min_insn_length
= byte_get (hdrptr
, 1);
2597 if (linfo
.li_version
>= 4)
2599 linfo
.li_max_ops_per_insn
= byte_get (hdrptr
, 1);
2601 if (linfo
.li_max_ops_per_insn
== 0)
2603 warn (_("Invalid maximum operations per insn.\n"));
2608 linfo
.li_max_ops_per_insn
= 1;
2609 linfo
.li_default_is_stmt
= byte_get (hdrptr
, 1);
2611 linfo
.li_line_base
= byte_get (hdrptr
, 1);
2613 linfo
.li_line_range
= byte_get (hdrptr
, 1);
2615 linfo
.li_opcode_base
= byte_get (hdrptr
, 1);
2618 /* Sign extend the line base field. */
2619 linfo
.li_line_base
<<= 24;
2620 linfo
.li_line_base
>>= 24;
2622 /* Find the end of this CU's Line Number Information Block. */
2623 end_of_sequence
= data
+ linfo
.li_length
+ initial_length_size
;
2625 reset_state_machine (linfo
.li_default_is_stmt
);
2627 /* Save a pointer to the contents of the Opcodes table. */
2628 standard_opcodes
= hdrptr
;
2630 /* Traverse the Directory table just to count entries. */
2631 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
2634 unsigned int n_directories
= 0;
2635 unsigned char *ptr_directory_table
= data
;
2639 data
+= strlen ((char *) data
) + 1;
2643 /* Go through the directory table again to save the directories. */
2644 directory_table
= (unsigned char **)
2645 xmalloc (n_directories
* sizeof (unsigned char *));
2648 while (*ptr_directory_table
!= 0)
2650 directory_table
[i
] = ptr_directory_table
;
2651 ptr_directory_table
+= strlen ((char *) ptr_directory_table
) + 1;
2655 /* Skip the NUL at the end of the table. */
2658 /* Traverse the File Name table just to count the entries. */
2661 unsigned int n_files
= 0;
2662 unsigned char *ptr_file_name_table
= data
;
2666 unsigned int bytes_read
;
2668 /* Skip Name, directory index, last modification time and length
2670 data
+= strlen ((char *) data
) + 1;
2671 read_leb128 (data
, & bytes_read
, 0);
2673 read_leb128 (data
, & bytes_read
, 0);
2675 read_leb128 (data
, & bytes_read
, 0);
2681 /* Go through the file table again to save the strings. */
2682 file_table
= (File_Entry
*) xmalloc (n_files
* sizeof (File_Entry
));
2685 while (*ptr_file_name_table
!= 0)
2687 unsigned int bytes_read
;
2689 file_table
[i
].name
= ptr_file_name_table
;
2690 ptr_file_name_table
+= strlen ((char *) ptr_file_name_table
) + 1;
2692 /* We are not interested in directory, time or size. */
2693 file_table
[i
].directory_index
= read_leb128 (ptr_file_name_table
,
2695 ptr_file_name_table
+= bytes_read
;
2696 file_table
[i
].modification_date
= read_leb128 (ptr_file_name_table
,
2698 ptr_file_name_table
+= bytes_read
;
2699 file_table
[i
].length
= read_leb128 (ptr_file_name_table
, & bytes_read
, 0);
2700 ptr_file_name_table
+= bytes_read
;
2705 /* Print the Compilation Unit's name and a header. */
2706 if (directory_table
== NULL
)
2708 printf (_("CU: %s:\n"), file_table
[0].name
);
2709 printf (_("File name Line number Starting address\n"));
2713 if (do_wide
|| strlen ((char *) directory_table
[0]) < 76)
2714 printf (_("CU: %s/%s:\n"), directory_table
[0],
2715 file_table
[0].name
);
2717 printf ("%s:\n", file_table
[0].name
);
2719 printf (_("File name Line number Starting address\n"));
2723 /* Skip the NUL at the end of the table. */
2726 /* This loop iterates through the Dwarf Line Number Program. */
2727 while (data
< end_of_sequence
)
2729 unsigned char op_code
;
2731 unsigned long int uladv
;
2732 unsigned int bytes_read
;
2733 int is_special_opcode
= 0;
2737 if (op_code
>= linfo
.li_opcode_base
)
2739 op_code
-= linfo
.li_opcode_base
;
2740 uladv
= (op_code
/ linfo
.li_line_range
);
2741 if (linfo
.li_max_ops_per_insn
== 1)
2743 uladv
*= linfo
.li_min_insn_length
;
2744 state_machine_regs
.address
+= uladv
;
2748 state_machine_regs
.address
2749 += ((state_machine_regs
.op_index
+ uladv
)
2750 / linfo
.li_max_ops_per_insn
)
2751 * linfo
.li_min_insn_length
;
2752 state_machine_regs
.op_index
2753 = (state_machine_regs
.op_index
+ uladv
)
2754 % linfo
.li_max_ops_per_insn
;
2757 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
2758 state_machine_regs
.line
+= adv
;
2759 is_special_opcode
= 1;
2761 else switch (op_code
)
2763 case DW_LNS_extended_op
:
2765 unsigned int ext_op_code_len
;
2766 unsigned char ext_op_code
;
2767 unsigned char *op_code_data
= data
;
2769 ext_op_code_len
= read_leb128 (op_code_data
, &bytes_read
, 0);
2770 op_code_data
+= bytes_read
;
2772 if (ext_op_code_len
== 0)
2774 warn (_("badly formed extended line op encountered!\n"));
2777 ext_op_code_len
+= bytes_read
;
2778 ext_op_code
= *op_code_data
++;
2780 switch (ext_op_code
)
2782 case DW_LNE_end_sequence
:
2783 reset_state_machine (linfo
.li_default_is_stmt
);
2785 case DW_LNE_set_address
:
2786 state_machine_regs
.address
=
2787 byte_get (op_code_data
, ext_op_code_len
- bytes_read
- 1);
2788 state_machine_regs
.op_index
= 0;
2790 case DW_LNE_define_file
:
2792 unsigned int dir_index
= 0;
2794 ++state_machine_regs
.last_file_entry
;
2795 op_code_data
+= strlen ((char *) op_code_data
) + 1;
2796 dir_index
= read_leb128 (op_code_data
, & bytes_read
, 0);
2797 op_code_data
+= bytes_read
;
2798 read_leb128 (op_code_data
, & bytes_read
, 0);
2799 op_code_data
+= bytes_read
;
2800 read_leb128 (op_code_data
, & bytes_read
, 0);
2802 printf ("%s:\n", directory_table
[dir_index
]);
2806 printf (_("UNKNOWN: length %d\n"), ext_op_code_len
- bytes_read
);
2809 data
+= ext_op_code_len
;
2815 case DW_LNS_advance_pc
:
2816 uladv
= read_leb128 (data
, & bytes_read
, 0);
2818 if (linfo
.li_max_ops_per_insn
== 1)
2820 uladv
*= linfo
.li_min_insn_length
;
2821 state_machine_regs
.address
+= uladv
;
2825 state_machine_regs
.address
2826 += ((state_machine_regs
.op_index
+ uladv
)
2827 / linfo
.li_max_ops_per_insn
)
2828 * linfo
.li_min_insn_length
;
2829 state_machine_regs
.op_index
2830 = (state_machine_regs
.op_index
+ uladv
)
2831 % linfo
.li_max_ops_per_insn
;
2835 case DW_LNS_advance_line
:
2836 adv
= read_leb128 (data
, & bytes_read
, 1);
2838 state_machine_regs
.line
+= adv
;
2841 case DW_LNS_set_file
:
2842 adv
= read_leb128 (data
, & bytes_read
, 0);
2844 state_machine_regs
.file
= adv
;
2845 if (file_table
[state_machine_regs
.file
- 1].directory_index
== 0)
2847 /* If directory index is 0, that means current directory. */
2848 printf ("\n./%s:[++]\n",
2849 file_table
[state_machine_regs
.file
- 1].name
);
2853 /* The directory index starts counting at 1. */
2854 printf ("\n%s/%s:\n",
2855 directory_table
[file_table
[state_machine_regs
.file
- 1].directory_index
- 1],
2856 file_table
[state_machine_regs
.file
- 1].name
);
2860 case DW_LNS_set_column
:
2861 uladv
= read_leb128 (data
, & bytes_read
, 0);
2863 state_machine_regs
.column
= uladv
;
2866 case DW_LNS_negate_stmt
:
2867 adv
= state_machine_regs
.is_stmt
;
2869 state_machine_regs
.is_stmt
= adv
;
2872 case DW_LNS_set_basic_block
:
2873 state_machine_regs
.basic_block
= 1;
2876 case DW_LNS_const_add_pc
:
2877 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
2878 if (linfo
.li_max_ops_per_insn
== 1)
2880 uladv
*= linfo
.li_min_insn_length
;
2881 state_machine_regs
.address
+= uladv
;
2885 state_machine_regs
.address
2886 += ((state_machine_regs
.op_index
+ uladv
)
2887 / linfo
.li_max_ops_per_insn
)
2888 * linfo
.li_min_insn_length
;
2889 state_machine_regs
.op_index
2890 = (state_machine_regs
.op_index
+ uladv
)
2891 % linfo
.li_max_ops_per_insn
;
2895 case DW_LNS_fixed_advance_pc
:
2896 uladv
= byte_get (data
, 2);
2898 state_machine_regs
.address
+= uladv
;
2899 state_machine_regs
.op_index
= 0;
2902 case DW_LNS_set_prologue_end
:
2905 case DW_LNS_set_epilogue_begin
:
2908 case DW_LNS_set_isa
:
2909 uladv
= read_leb128 (data
, & bytes_read
, 0);
2911 printf (_(" Set ISA to %lu\n"), uladv
);
2915 printf (_(" Unknown opcode %d with operands: "), op_code
);
2917 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
2919 printf ("0x%lx%s", read_leb128 (data
, &bytes_read
, 0),
2920 i
== 1 ? "" : ", ");
2927 /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row
2928 to the DWARF address/line matrix. */
2929 if ((is_special_opcode
) || (op_code
== DW_LNE_end_sequence
)
2930 || (op_code
== DW_LNS_copy
))
2932 const unsigned int MAX_FILENAME_LENGTH
= 35;
2933 char *fileName
= (char *)file_table
[state_machine_regs
.file
- 1].name
;
2934 char *newFileName
= NULL
;
2935 size_t fileNameLength
= strlen (fileName
);
2937 if ((fileNameLength
> MAX_FILENAME_LENGTH
) && (!do_wide
))
2939 newFileName
= (char *) xmalloc (MAX_FILENAME_LENGTH
+ 1);
2940 /* Truncate file name */
2941 strncpy (newFileName
,
2942 fileName
+ fileNameLength
- MAX_FILENAME_LENGTH
,
2943 MAX_FILENAME_LENGTH
+ 1);
2947 newFileName
= (char *) xmalloc (fileNameLength
+ 1);
2948 strncpy (newFileName
, fileName
, fileNameLength
+ 1);
2951 if (!do_wide
|| (fileNameLength
<= MAX_FILENAME_LENGTH
))
2953 if (linfo
.li_max_ops_per_insn
== 1)
2954 printf ("%-35s %11d %#18lx\n", newFileName
,
2955 state_machine_regs
.line
,
2956 state_machine_regs
.address
);
2958 printf ("%-35s %11d %#18lx[%d]\n", newFileName
,
2959 state_machine_regs
.line
,
2960 state_machine_regs
.address
,
2961 state_machine_regs
.op_index
);
2965 if (linfo
.li_max_ops_per_insn
== 1)
2966 printf ("%s %11d %#18lx\n", newFileName
,
2967 state_machine_regs
.line
,
2968 state_machine_regs
.address
);
2970 printf ("%s %11d %#18lx[%d]\n", newFileName
,
2971 state_machine_regs
.line
,
2972 state_machine_regs
.address
,
2973 state_machine_regs
.op_index
);
2976 if (op_code
== DW_LNE_end_sequence
)
2984 free (directory_table
);
2985 directory_table
= NULL
;
2993 display_debug_lines (struct dwarf_section
*section
, void *file ATTRIBUTE_UNUSED
)
2995 unsigned char *data
= section
->start
;
2996 unsigned char *end
= data
+ section
->size
;
2998 int retValDecoded
= 1;
3000 if (do_debug_lines
== 0)
3001 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
3003 if (do_debug_lines
& FLAG_DEBUG_LINES_RAW
)
3004 retValRaw
= display_debug_lines_raw (section
, data
, end
);
3006 if (do_debug_lines
& FLAG_DEBUG_LINES_DECODED
)
3007 retValDecoded
= display_debug_lines_decoded (section
, data
, end
);
3009 if (!retValRaw
|| !retValDecoded
)
3016 find_debug_info_for_offset (unsigned long offset
)
3020 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
3023 for (i
= 0; i
< num_debug_info_entries
; i
++)
3024 if (debug_information
[i
].cu_offset
== offset
)
3025 return debug_information
+ i
;
3031 display_debug_pubnames (struct dwarf_section
*section
,
3032 void *file ATTRIBUTE_UNUSED
)
3034 DWARF2_Internal_PubNames names
;
3035 unsigned char *start
= section
->start
;
3036 unsigned char *end
= start
+ section
->size
;
3038 /* It does not matter if this load fails,
3039 we test for that later on. */
3040 load_debug_info (file
);
3042 printf (_("Contents of the %s section:\n\n"), section
->name
);
3046 unsigned char *data
;
3047 unsigned long offset
;
3048 int offset_size
, initial_length_size
;
3052 names
.pn_length
= byte_get (data
, 4);
3054 if (names
.pn_length
== 0xffffffff)
3056 names
.pn_length
= byte_get (data
, 8);
3059 initial_length_size
= 12;
3064 initial_length_size
= 4;
3067 names
.pn_version
= byte_get (data
, 2);
3070 names
.pn_offset
= byte_get (data
, offset_size
);
3071 data
+= offset_size
;
3073 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
3074 && num_debug_info_entries
> 0
3075 && find_debug_info_for_offset (names
.pn_offset
) == NULL
)
3076 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
3077 names
.pn_offset
, section
->name
);
3079 names
.pn_size
= byte_get (data
, offset_size
);
3080 data
+= offset_size
;
3082 start
+= names
.pn_length
+ initial_length_size
;
3084 if (names
.pn_version
!= 2 && names
.pn_version
!= 3)
3086 static int warned
= 0;
3090 warn (_("Only DWARF 2 and 3 pubnames are currently supported\n"));
3097 printf (_(" Length: %ld\n"),
3099 printf (_(" Version: %d\n"),
3101 printf (_(" Offset into .debug_info section: 0x%lx\n"),
3103 printf (_(" Size of area in .debug_info section: %ld\n"),
3106 printf (_("\n Offset\tName\n"));
3110 offset
= byte_get (data
, offset_size
);
3114 data
+= offset_size
;
3115 printf (" %-6lx\t%s\n", offset
, data
);
3116 data
+= strlen ((char *) data
) + 1;
3119 while (offset
!= 0);
3127 display_debug_macinfo (struct dwarf_section
*section
,
3128 void *file ATTRIBUTE_UNUSED
)
3130 unsigned char *start
= section
->start
;
3131 unsigned char *end
= start
+ section
->size
;
3132 unsigned char *curr
= start
;
3133 unsigned int bytes_read
;
3134 enum dwarf_macinfo_record_type op
;
3136 printf (_("Contents of the %s section:\n\n"), section
->name
);
3140 unsigned int lineno
;
3143 op
= (enum dwarf_macinfo_record_type
) *curr
;
3148 case DW_MACINFO_start_file
:
3150 unsigned int filenum
;
3152 lineno
= read_leb128 (curr
, & bytes_read
, 0);
3154 filenum
= read_leb128 (curr
, & bytes_read
, 0);
3157 printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"),
3162 case DW_MACINFO_end_file
:
3163 printf (_(" DW_MACINFO_end_file\n"));
3166 case DW_MACINFO_define
:
3167 lineno
= read_leb128 (curr
, & bytes_read
, 0);
3169 string
= (char *) curr
;
3170 curr
+= strlen (string
) + 1;
3171 printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"),
3175 case DW_MACINFO_undef
:
3176 lineno
= read_leb128 (curr
, & bytes_read
, 0);
3178 string
= (char *) curr
;
3179 curr
+= strlen (string
) + 1;
3180 printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"),
3184 case DW_MACINFO_vendor_ext
:
3186 unsigned int constant
;
3188 constant
= read_leb128 (curr
, & bytes_read
, 0);
3190 string
= (char *) curr
;
3191 curr
+= strlen (string
) + 1;
3192 printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"),
3203 display_debug_abbrev (struct dwarf_section
*section
,
3204 void *file ATTRIBUTE_UNUSED
)
3206 abbrev_entry
*entry
;
3207 unsigned char *start
= section
->start
;
3208 unsigned char *end
= start
+ section
->size
;
3210 printf (_("Contents of the %s section:\n\n"), section
->name
);
3216 start
= process_abbrev_section (start
, end
);
3218 if (first_abbrev
== NULL
)
3221 printf (_(" Number TAG\n"));
3223 for (entry
= first_abbrev
; entry
; entry
= entry
->next
)
3227 printf (" %ld %s [%s]\n",
3229 get_TAG_name (entry
->tag
),
3230 entry
->children
? _("has children") : _("no children"));
3232 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
3233 printf (" %-18s %s\n",
3234 get_AT_name (attr
->attribute
),
3235 get_FORM_name (attr
->form
));
3246 display_debug_loc (struct dwarf_section
*section
, void *file
)
3248 unsigned char *start
= section
->start
;
3249 unsigned char *section_end
;
3250 unsigned long bytes
;
3251 unsigned char *section_begin
= start
;
3252 unsigned int num_loc_list
= 0;
3253 unsigned long last_offset
= 0;
3254 unsigned int first
= 0;
3257 int seen_first_offset
= 0;
3258 int use_debug_info
= 1;
3259 unsigned char *next
;
3261 bytes
= section
->size
;
3262 section_end
= start
+ bytes
;
3266 printf (_("\nThe %s section is empty.\n"), section
->name
);
3270 if (load_debug_info (file
) == 0)
3272 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
3277 /* Check the order of location list in .debug_info section. If
3278 offsets of location lists are in the ascending order, we can
3279 use `debug_information' directly. */
3280 for (i
= 0; i
< num_debug_info_entries
; i
++)
3284 num
= debug_information
[i
].num_loc_offsets
;
3285 num_loc_list
+= num
;
3287 /* Check if we can use `debug_information' directly. */
3288 if (use_debug_info
&& num
!= 0)
3290 if (!seen_first_offset
)
3292 /* This is the first location list. */
3293 last_offset
= debug_information
[i
].loc_offsets
[0];
3295 seen_first_offset
= 1;
3301 for (; j
< num
; j
++)
3304 debug_information
[i
].loc_offsets
[j
])
3309 last_offset
= debug_information
[i
].loc_offsets
[j
];
3314 if (!use_debug_info
)
3315 /* FIXME: Should we handle this case? */
3316 error (_("Location lists in .debug_info section aren't in ascending order!\n"));
3318 if (!seen_first_offset
)
3319 error (_("No location lists in .debug_info section!\n"));
3321 /* DWARF sections under Mach-O have non-zero addresses. */
3322 if (debug_information
[first
].num_loc_offsets
> 0
3323 && debug_information
[first
].loc_offsets
[0] != section
->address
)
3324 warn (_("Location lists in %s section start at 0x%lx\n"),
3325 section
->name
, debug_information
[first
].loc_offsets
[0]);
3327 printf (_("Contents of the %s section:\n\n"), section
->name
);
3328 printf (_(" Offset Begin End Expression\n"));
3330 seen_first_offset
= 0;
3331 for (i
= first
; i
< num_debug_info_entries
; i
++)
3335 unsigned short length
;
3336 unsigned long offset
;
3337 unsigned int pointer_size
;
3338 unsigned int offset_size
;
3340 unsigned long cu_offset
;
3341 unsigned long base_address
;
3342 int need_frame_base
;
3345 pointer_size
= debug_information
[i
].pointer_size
;
3346 cu_offset
= debug_information
[i
].cu_offset
;
3347 offset_size
= debug_information
[i
].offset_size
;
3348 dwarf_version
= debug_information
[i
].dwarf_version
;
3350 for (j
= 0; j
< debug_information
[i
].num_loc_offsets
; j
++)
3352 has_frame_base
= debug_information
[i
].have_frame_base
[j
];
3353 /* DWARF sections under Mach-O have non-zero addresses. */
3354 offset
= debug_information
[i
].loc_offsets
[j
] - section
->address
;
3355 next
= section_begin
+ offset
;
3356 base_address
= debug_information
[i
].base_address
;
3358 if (!seen_first_offset
)
3359 seen_first_offset
= 1;
3363 warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"),
3364 (unsigned long) (start
- section_begin
),
3365 (unsigned long) (next
- section_begin
));
3366 else if (start
> next
)
3367 warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"),
3368 (unsigned long) (start
- section_begin
),
3369 (unsigned long) (next
- section_begin
));
3373 if (offset
>= bytes
)
3375 warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"),
3382 if (start
+ 2 * pointer_size
> section_end
)
3384 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3389 /* Note: we use sign extension here in order to be sure that
3390 we can detect the -1 escape value. Sign extension into the
3391 top 32 bits of a 32-bit address will not affect the values
3392 that we display since we always show hex values, and always
3393 the bottom 32-bits. */
3394 begin
= byte_get_signed (start
, pointer_size
);
3395 start
+= pointer_size
;
3396 end
= byte_get_signed (start
, pointer_size
);
3397 start
+= pointer_size
;
3399 printf (" %8.8lx ", offset
);
3401 if (begin
== 0 && end
== 0)
3403 printf (_("<End of list>\n"));
3407 /* Check base address specifiers. */
3408 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
3411 print_dwarf_vma (begin
, pointer_size
);
3412 print_dwarf_vma (end
, pointer_size
);
3413 printf (_("(base address)\n"));
3417 if (start
+ 2 > section_end
)
3419 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3424 length
= byte_get (start
, 2);
3427 if (start
+ length
> section_end
)
3429 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3434 print_dwarf_vma (begin
+ base_address
, pointer_size
);
3435 print_dwarf_vma (end
+ base_address
, pointer_size
);
3438 need_frame_base
= decode_location_expression (start
,
3443 cu_offset
, section
);
3446 if (need_frame_base
&& !has_frame_base
)
3447 printf (_(" [without DW_AT_frame_base]"));
3450 fputs (_(" (start == end)"), stdout
);
3451 else if (begin
> end
)
3452 fputs (_(" (start > end)"), stdout
);
3461 if (start
< section_end
)
3462 warn (_("There are %ld unused bytes at the end of section %s\n"),
3463 (long) (section_end
- start
), section
->name
);
3469 display_debug_str (struct dwarf_section
*section
,
3470 void *file ATTRIBUTE_UNUSED
)
3472 unsigned char *start
= section
->start
;
3473 unsigned long bytes
= section
->size
;
3474 dwarf_vma addr
= section
->address
;
3478 printf (_("\nThe %s section is empty.\n"), section
->name
);
3482 printf (_("Contents of the %s section:\n\n"), section
->name
);
3490 lbytes
= (bytes
> 16 ? 16 : bytes
);
3492 printf (" 0x%8.8lx ", (unsigned long) addr
);
3494 for (j
= 0; j
< 16; j
++)
3497 printf ("%2.2x", start
[j
]);
3505 for (j
= 0; j
< lbytes
; j
++)
3508 if (k
>= ' ' && k
< 0x80)
3527 display_debug_info (struct dwarf_section
*section
, void *file
)
3529 return process_debug_info (section
, file
, abbrev
, 0, 0);
3533 display_debug_types (struct dwarf_section
*section
, void *file
)
3535 return process_debug_info (section
, file
, abbrev
, 0, 1);
3539 display_trace_info (struct dwarf_section
*section
, void *file
)
3541 return process_debug_info (section
, file
, trace_abbrev
, 0, 0);
3545 display_debug_aranges (struct dwarf_section
*section
,
3546 void *file ATTRIBUTE_UNUSED
)
3548 unsigned char *start
= section
->start
;
3549 unsigned char *end
= start
+ section
->size
;
3551 printf (_("Contents of the %s section:\n\n"), section
->name
);
3553 /* It does not matter if this load fails,
3554 we test for that later on. */
3555 load_debug_info (file
);
3559 unsigned char *hdrptr
;
3560 DWARF2_Internal_ARange arange
;
3561 unsigned char *addr_ranges
;
3564 unsigned char address_size
;
3567 int initial_length_size
;
3571 arange
.ar_length
= byte_get (hdrptr
, 4);
3574 if (arange
.ar_length
== 0xffffffff)
3576 arange
.ar_length
= byte_get (hdrptr
, 8);
3579 initial_length_size
= 12;
3584 initial_length_size
= 4;
3587 arange
.ar_version
= byte_get (hdrptr
, 2);
3590 arange
.ar_info_offset
= byte_get (hdrptr
, offset_size
);
3591 hdrptr
+= offset_size
;
3593 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
3594 && num_debug_info_entries
> 0
3595 && find_debug_info_for_offset (arange
.ar_info_offset
) == NULL
)
3596 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
3597 arange
.ar_info_offset
, section
->name
);
3599 arange
.ar_pointer_size
= byte_get (hdrptr
, 1);
3602 arange
.ar_segment_size
= byte_get (hdrptr
, 1);
3605 if (arange
.ar_version
!= 2 && arange
.ar_version
!= 3)
3607 warn (_("Only DWARF 2 and 3 aranges are currently supported.\n"));
3611 printf (_(" Length: %ld\n"), arange
.ar_length
);
3612 printf (_(" Version: %d\n"), arange
.ar_version
);
3613 printf (_(" Offset into .debug_info: 0x%lx\n"), arange
.ar_info_offset
);
3614 printf (_(" Pointer Size: %d\n"), arange
.ar_pointer_size
);
3615 printf (_(" Segment Size: %d\n"), arange
.ar_segment_size
);
3617 address_size
= arange
.ar_pointer_size
+ arange
.ar_segment_size
;
3619 /* The DWARF spec does not require that the address size be a power
3620 of two, but we do. This will have to change if we ever encounter
3621 an uneven architecture. */
3622 if ((address_size
& (address_size
- 1)) != 0)
3624 warn (_("Pointer size + Segment size is not a power of two.\n"));
3628 if (address_size
> 4)
3629 printf (_("\n Address Length\n"));
3631 printf (_("\n Address Length\n"));
3633 addr_ranges
= hdrptr
;
3635 /* Must pad to an alignment boundary that is twice the address size. */
3636 excess
= (hdrptr
- start
) % (2 * address_size
);
3638 addr_ranges
+= (2 * address_size
) - excess
;
3640 start
+= arange
.ar_length
+ initial_length_size
;
3642 while (addr_ranges
+ 2 * address_size
<= start
)
3644 address
= byte_get (addr_ranges
, address_size
);
3646 addr_ranges
+= address_size
;
3648 length
= byte_get (addr_ranges
, address_size
);
3650 addr_ranges
+= address_size
;
3653 print_dwarf_vma (address
, address_size
);
3654 print_dwarf_vma (length
, address_size
);
3664 /* Each debug_information[x].range_lists[y] gets this representation for
3665 sorting purposes. */
3669 /* The debug_information[x].range_lists[y] value. */
3670 unsigned long ranges_offset
;
3672 /* Original debug_information to find parameters of the data. */
3673 debug_info
*debug_info_p
;
3676 /* Sort struct range_entry in ascending order of its RANGES_OFFSET. */
3679 range_entry_compar (const void *ap
, const void *bp
)
3681 const struct range_entry
*a_re
= (const struct range_entry
*) ap
;
3682 const struct range_entry
*b_re
= (const struct range_entry
*) bp
;
3683 const unsigned long a
= a_re
->ranges_offset
;
3684 const unsigned long b
= b_re
->ranges_offset
;
3686 return (a
> b
) - (b
> a
);
3690 display_debug_ranges (struct dwarf_section
*section
,
3691 void *file ATTRIBUTE_UNUSED
)
3693 unsigned char *start
= section
->start
;
3694 unsigned long bytes
;
3695 unsigned char *section_begin
= start
;
3696 unsigned int num_range_list
, i
;
3697 struct range_entry
*range_entries
, *range_entry_fill
;
3699 bytes
= section
->size
;
3703 printf (_("\nThe %s section is empty.\n"), section
->name
);
3707 if (load_debug_info (file
) == 0)
3709 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
3715 for (i
= 0; i
< num_debug_info_entries
; i
++)
3716 num_range_list
+= debug_information
[i
].num_range_lists
;
3718 if (num_range_list
== 0)
3719 error (_("No range lists in .debug_info section!\n"));
3721 range_entries
= (struct range_entry
*)
3722 xmalloc (sizeof (*range_entries
) * num_range_list
);
3723 range_entry_fill
= range_entries
;
3725 for (i
= 0; i
< num_debug_info_entries
; i
++)
3727 debug_info
*debug_info_p
= &debug_information
[i
];
3730 for (j
= 0; j
< debug_info_p
->num_range_lists
; j
++)
3732 range_entry_fill
->ranges_offset
= debug_info_p
->range_lists
[j
];
3733 range_entry_fill
->debug_info_p
= debug_info_p
;
3738 qsort (range_entries
, num_range_list
, sizeof (*range_entries
),
3739 range_entry_compar
);
3741 /* DWARF sections under Mach-O have non-zero addresses. */
3742 if (range_entries
[0].ranges_offset
!= section
->address
)
3743 warn (_("Range lists in %s section start at 0x%lx\n"),
3744 section
->name
, range_entries
[0].ranges_offset
);
3746 printf (_("Contents of the %s section:\n\n"), section
->name
);
3747 printf (_(" Offset Begin End\n"));
3749 for (i
= 0; i
< num_range_list
; i
++)
3751 struct range_entry
*range_entry
= &range_entries
[i
];
3752 debug_info
*debug_info_p
= range_entry
->debug_info_p
;
3753 unsigned int pointer_size
;
3754 unsigned long offset
;
3755 unsigned char *next
;
3756 unsigned long base_address
;
3758 pointer_size
= debug_info_p
->pointer_size
;
3760 /* DWARF sections under Mach-O have non-zero addresses. */
3761 offset
= range_entry
->ranges_offset
- section
->address
;
3762 next
= section_begin
+ offset
;
3763 base_address
= debug_info_p
->base_address
;
3768 warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"),
3769 (unsigned long) (start
- section_begin
),
3770 (unsigned long) (next
- section_begin
), section
->name
);
3771 else if (start
> next
)
3772 warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"),
3773 (unsigned long) (start
- section_begin
),
3774 (unsigned long) (next
- section_begin
), section
->name
);
3783 /* Note: we use sign extension here in order to be sure that
3784 we can detect the -1 escape value. Sign extension into the
3785 top 32 bits of a 32-bit address will not affect the values
3786 that we display since we always show hex values, and always
3787 the bottom 32-bits. */
3788 begin
= byte_get_signed (start
, pointer_size
);
3789 start
+= pointer_size
;
3790 end
= byte_get_signed (start
, pointer_size
);
3791 start
+= pointer_size
;
3793 printf (" %8.8lx ", offset
);
3795 if (begin
== 0 && end
== 0)
3797 printf (_("<End of list>\n"));
3801 /* Check base address specifiers. */
3802 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
3805 print_dwarf_vma (begin
, pointer_size
);
3806 print_dwarf_vma (end
, pointer_size
);
3807 printf ("(base address)\n");
3811 print_dwarf_vma (begin
+ base_address
, pointer_size
);
3812 print_dwarf_vma (end
+ base_address
, pointer_size
);
3815 fputs (_("(start == end)"), stdout
);
3816 else if (begin
> end
)
3817 fputs (_("(start > end)"), stdout
);
3824 free (range_entries
);
3829 typedef struct Frame_Chunk
3831 struct Frame_Chunk
*next
;
3832 unsigned char *chunk_start
;
3834 /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
3835 short int *col_type
;
3838 unsigned int code_factor
;
3840 unsigned long pc_begin
;
3841 unsigned long pc_range
;
3845 unsigned char fde_encoding
;
3846 unsigned char cfa_exp
;
3847 unsigned char ptr_size
;
3848 unsigned char segment_size
;
3852 static const char *const *dwarf_regnames
;
3853 static unsigned int dwarf_regnames_count
;
3855 /* A marker for a col_type that means this column was never referenced
3856 in the frame info. */
3857 #define DW_CFA_unreferenced (-1)
3859 /* Return 0 if not more space is needed, 1 if more space is needed,
3860 -1 for invalid reg. */
3863 frame_need_space (Frame_Chunk
*fc
, unsigned int reg
)
3865 int prev
= fc
->ncols
;
3867 if (reg
< (unsigned int) fc
->ncols
)
3870 if (dwarf_regnames_count
3871 && reg
> dwarf_regnames_count
)
3874 fc
->ncols
= reg
+ 1;
3875 fc
->col_type
= (short int *) xcrealloc (fc
->col_type
, fc
->ncols
,
3876 sizeof (short int));
3877 fc
->col_offset
= (int *) xcrealloc (fc
->col_offset
, fc
->ncols
, sizeof (int));
3879 while (prev
< fc
->ncols
)
3881 fc
->col_type
[prev
] = DW_CFA_unreferenced
;
3882 fc
->col_offset
[prev
] = 0;
3888 static const char *const dwarf_regnames_i386
[] =
3890 "eax", "ecx", "edx", "ebx",
3891 "esp", "ebp", "esi", "edi",
3892 "eip", "eflags", NULL
,
3893 "st0", "st1", "st2", "st3",
3894 "st4", "st5", "st6", "st7",
3896 "xmm0", "xmm1", "xmm2", "xmm3",
3897 "xmm4", "xmm5", "xmm6", "xmm7",
3898 "mm0", "mm1", "mm2", "mm3",
3899 "mm4", "mm5", "mm6", "mm7",
3900 "fcw", "fsw", "mxcsr",
3901 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
3906 init_dwarf_regnames_i386 (void)
3908 dwarf_regnames
= dwarf_regnames_i386
;
3909 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_i386
);
3912 static const char *const dwarf_regnames_x86_64
[] =
3914 "rax", "rdx", "rcx", "rbx",
3915 "rsi", "rdi", "rbp", "rsp",
3916 "r8", "r9", "r10", "r11",
3917 "r12", "r13", "r14", "r15",
3919 "xmm0", "xmm1", "xmm2", "xmm3",
3920 "xmm4", "xmm5", "xmm6", "xmm7",
3921 "xmm8", "xmm9", "xmm10", "xmm11",
3922 "xmm12", "xmm13", "xmm14", "xmm15",
3923 "st0", "st1", "st2", "st3",
3924 "st4", "st5", "st6", "st7",
3925 "mm0", "mm1", "mm2", "mm3",
3926 "mm4", "mm5", "mm6", "mm7",
3928 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
3929 "fs.base", "gs.base", NULL
, NULL
,
3931 "mxcsr", "fcw", "fsw"
3935 init_dwarf_regnames_x86_64 (void)
3937 dwarf_regnames
= dwarf_regnames_x86_64
;
3938 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_x86_64
);
3942 init_dwarf_regnames (unsigned int e_machine
)
3948 init_dwarf_regnames_i386 ();
3953 init_dwarf_regnames_x86_64 ();
3962 regname (unsigned int regno
, int row
)
3964 static char reg
[64];
3966 && regno
< dwarf_regnames_count
3967 && dwarf_regnames
[regno
] != NULL
)
3970 return dwarf_regnames
[regno
];
3971 snprintf (reg
, sizeof (reg
), "r%d (%s)", regno
,
3972 dwarf_regnames
[regno
]);
3975 snprintf (reg
, sizeof (reg
), "r%d", regno
);
3980 frame_display_row (Frame_Chunk
*fc
, int *need_col_headers
, int *max_regs
)
3985 if (*max_regs
< fc
->ncols
)
3986 *max_regs
= fc
->ncols
;
3988 if (*need_col_headers
)
3990 static const char *sloc
= " LOC";
3992 *need_col_headers
= 0;
3994 printf ("%-*s CFA ", eh_addr_size
* 2, sloc
);
3996 for (r
= 0; r
< *max_regs
; r
++)
3997 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
4002 printf ("%-5s ", regname (r
, 1));
4008 printf ("%0*lx ", eh_addr_size
* 2, fc
->pc_begin
);
4010 strcpy (tmp
, "exp");
4012 sprintf (tmp
, "%s%+d", regname (fc
->cfa_reg
, 1), fc
->cfa_offset
);
4013 printf ("%-8s ", tmp
);
4015 for (r
= 0; r
< fc
->ncols
; r
++)
4017 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
4019 switch (fc
->col_type
[r
])
4021 case DW_CFA_undefined
:
4024 case DW_CFA_same_value
:
4028 sprintf (tmp
, "c%+d", fc
->col_offset
[r
]);
4030 case DW_CFA_val_offset
:
4031 sprintf (tmp
, "v%+d", fc
->col_offset
[r
]);
4033 case DW_CFA_register
:
4034 sprintf (tmp
, "%s", regname (fc
->col_offset
[r
], 0));
4036 case DW_CFA_expression
:
4037 strcpy (tmp
, "exp");
4039 case DW_CFA_val_expression
:
4040 strcpy (tmp
, "vexp");
4043 strcpy (tmp
, "n/a");
4046 printf ("%-5s ", tmp
);
4052 #define GET(N) byte_get (start, N); start += N
4053 #define LEB() read_leb128 (start, & length_return, 0); start += length_return
4054 #define SLEB() read_leb128 (start, & length_return, 1); start += length_return
4057 display_debug_frames (struct dwarf_section
*section
,
4058 void *file ATTRIBUTE_UNUSED
)
4060 unsigned char *start
= section
->start
;
4061 unsigned char *end
= start
+ section
->size
;
4062 unsigned char *section_start
= start
;
4063 Frame_Chunk
*chunks
= 0;
4064 Frame_Chunk
*remembered_state
= 0;
4066 int is_eh
= strcmp (section
->name
, ".eh_frame") == 0;
4067 unsigned int length_return
;
4069 const char *bad_reg
= _("bad register: ");
4070 int saved_eh_addr_size
= eh_addr_size
;
4072 printf (_("Contents of the %s section:\n"), section
->name
);
4076 unsigned char *saved_start
;
4077 unsigned char *block_end
;
4078 unsigned long length
;
4079 unsigned long cie_id
;
4082 int need_col_headers
= 1;
4083 unsigned char *augmentation_data
= NULL
;
4084 unsigned long augmentation_data_len
= 0;
4085 int encoded_ptr_size
= saved_eh_addr_size
;
4087 int initial_length_size
;
4089 saved_start
= start
;
4090 length
= byte_get (start
, 4); start
+= 4;
4094 printf ("\n%08lx ZERO terminator\n\n",
4095 (unsigned long)(saved_start
- section_start
));
4099 if (length
== 0xffffffff)
4101 length
= byte_get (start
, 8);
4104 initial_length_size
= 12;
4109 initial_length_size
= 4;
4112 block_end
= saved_start
+ length
+ initial_length_size
;
4113 if (block_end
> end
)
4115 warn ("Invalid length %#08lx in FDE at %#08lx\n",
4116 length
, (unsigned long)(saved_start
- section_start
));
4119 cie_id
= byte_get (start
, offset_size
); start
+= offset_size
;
4121 if (is_eh
? (cie_id
== 0) : (cie_id
== DW_CIE_ID
))
4125 fc
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
4126 memset (fc
, 0, sizeof (Frame_Chunk
));
4130 fc
->chunk_start
= saved_start
;
4132 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
4133 fc
->col_offset
= (int *) xmalloc (sizeof (int));
4134 frame_need_space (fc
, max_regs
- 1);
4138 fc
->augmentation
= (char *) start
;
4139 start
= (unsigned char *) strchr ((char *) start
, '\0') + 1;
4141 if (strcmp (fc
->augmentation
, "eh") == 0)
4142 start
+= eh_addr_size
;
4146 fc
->ptr_size
= GET (1);
4147 fc
->segment_size
= GET (1);
4148 eh_addr_size
= fc
->ptr_size
;
4152 fc
->ptr_size
= eh_addr_size
;
4153 fc
->segment_size
= 0;
4155 fc
->code_factor
= LEB ();
4156 fc
->data_factor
= SLEB ();
4166 if (fc
->augmentation
[0] == 'z')
4168 augmentation_data_len
= LEB ();
4169 augmentation_data
= start
;
4170 start
+= augmentation_data_len
;
4174 if (do_debug_frames_interp
)
4175 printf ("\n%08lx %08lx %08lx CIE \"%s\" cf=%d df=%d ra=%d\n",
4176 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
4177 fc
->augmentation
, fc
->code_factor
, fc
->data_factor
,
4181 printf ("\n%08lx %08lx %08lx CIE\n",
4182 (unsigned long)(saved_start
- section_start
), length
, cie_id
);
4183 printf (" Version: %d\n", version
);
4184 printf (" Augmentation: \"%s\"\n", fc
->augmentation
);
4187 printf (" Pointer Size: %u\n", fc
->ptr_size
);
4188 printf (" Segment Size: %u\n", fc
->segment_size
);
4190 printf (" Code alignment factor: %u\n", fc
->code_factor
);
4191 printf (" Data alignment factor: %d\n", fc
->data_factor
);
4192 printf (" Return address column: %d\n", fc
->ra
);
4194 if (augmentation_data_len
)
4197 printf (" Augmentation data: ");
4198 for (i
= 0; i
< augmentation_data_len
; ++i
)
4199 printf (" %02x", augmentation_data
[i
]);
4205 if (augmentation_data_len
)
4207 unsigned char *p
, *q
;
4208 p
= (unsigned char *) fc
->augmentation
+ 1;
4209 q
= augmentation_data
;
4216 q
+= 1 + size_of_encoded_value (*q
);
4218 fc
->fde_encoding
= *q
++;
4226 if (fc
->fde_encoding
)
4227 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
4230 frame_need_space (fc
, fc
->ra
);
4234 unsigned char *look_for
;
4235 static Frame_Chunk fde_fc
;
4236 unsigned long segment_selector
;
4239 memset (fc
, 0, sizeof (Frame_Chunk
));
4241 look_for
= is_eh
? start
- 4 - cie_id
: section_start
+ cie_id
;
4243 for (cie
= chunks
; cie
; cie
= cie
->next
)
4244 if (cie
->chunk_start
== look_for
)
4249 warn ("Invalid CIE pointer %#08lx in FDE at %#08lx\n",
4250 cie_id
, (unsigned long)(saved_start
- section_start
));
4252 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
4253 fc
->col_offset
= (int *) xmalloc (sizeof (int));
4254 frame_need_space (fc
, max_regs
- 1);
4256 fc
->augmentation
= "";
4257 fc
->fde_encoding
= 0;
4258 fc
->ptr_size
= eh_addr_size
;
4259 fc
->segment_size
= 0;
4263 fc
->ncols
= cie
->ncols
;
4264 fc
->col_type
= (short int *) xcmalloc (fc
->ncols
, sizeof (short int));
4265 fc
->col_offset
= (int *) xcmalloc (fc
->ncols
, sizeof (int));
4266 memcpy (fc
->col_type
, cie
->col_type
, fc
->ncols
* sizeof (short int));
4267 memcpy (fc
->col_offset
, cie
->col_offset
, fc
->ncols
* sizeof (int));
4268 fc
->augmentation
= cie
->augmentation
;
4269 fc
->ptr_size
= cie
->ptr_size
;
4270 eh_addr_size
= cie
->ptr_size
;
4271 fc
->segment_size
= cie
->segment_size
;
4272 fc
->code_factor
= cie
->code_factor
;
4273 fc
->data_factor
= cie
->data_factor
;
4274 fc
->cfa_reg
= cie
->cfa_reg
;
4275 fc
->cfa_offset
= cie
->cfa_offset
;
4277 frame_need_space (fc
, max_regs
- 1);
4278 fc
->fde_encoding
= cie
->fde_encoding
;
4281 if (fc
->fde_encoding
)
4282 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
4284 segment_selector
= 0;
4285 if (fc
->segment_size
)
4287 segment_selector
= byte_get (start
, fc
->segment_size
);
4288 start
+= fc
->segment_size
;
4290 fc
->pc_begin
= get_encoded_value (start
, fc
->fde_encoding
, section
);
4291 start
+= encoded_ptr_size
;
4292 fc
->pc_range
= byte_get (start
, encoded_ptr_size
);
4293 start
+= encoded_ptr_size
;
4295 if (cie
->augmentation
[0] == 'z')
4297 augmentation_data_len
= LEB ();
4298 augmentation_data
= start
;
4299 start
+= augmentation_data_len
;
4302 printf ("\n%08lx %08lx %08lx FDE cie=%08lx pc=",
4303 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
4304 (unsigned long)(cie
->chunk_start
- section_start
));
4305 if (fc
->segment_size
)
4306 printf ("%04lx:", segment_selector
);
4307 printf ("%08lx..%08lx\n", fc
->pc_begin
, fc
->pc_begin
+ fc
->pc_range
);
4308 if (! do_debug_frames_interp
&& augmentation_data_len
)
4312 printf (" Augmentation data: ");
4313 for (i
= 0; i
< augmentation_data_len
; ++i
)
4314 printf (" %02x", augmentation_data
[i
]);
4320 /* At this point, fc is the current chunk, cie (if any) is set, and
4321 we're about to interpret instructions for the chunk. */
4322 /* ??? At present we need to do this always, since this sizes the
4323 fc->col_type and fc->col_offset arrays, which we write into always.
4324 We should probably split the interpreted and non-interpreted bits
4325 into two different routines, since there's so much that doesn't
4326 really overlap between them. */
4327 if (1 || do_debug_frames_interp
)
4329 /* Start by making a pass over the chunk, allocating storage
4330 and taking note of what registers are used. */
4331 unsigned char *tmp
= start
;
4333 while (start
< block_end
)
4336 unsigned long reg
, temp
;
4343 /* Warning: if you add any more cases to this switch, be
4344 sure to add them to the corresponding switch below. */
4347 case DW_CFA_advance_loc
:
4351 if (frame_need_space (fc
, opa
) >= 0)
4352 fc
->col_type
[opa
] = DW_CFA_undefined
;
4354 case DW_CFA_restore
:
4355 if (frame_need_space (fc
, opa
) >= 0)
4356 fc
->col_type
[opa
] = DW_CFA_undefined
;
4358 case DW_CFA_set_loc
:
4359 start
+= encoded_ptr_size
;
4361 case DW_CFA_advance_loc1
:
4364 case DW_CFA_advance_loc2
:
4367 case DW_CFA_advance_loc4
:
4370 case DW_CFA_offset_extended
:
4371 case DW_CFA_val_offset
:
4372 reg
= LEB (); LEB ();
4373 if (frame_need_space (fc
, reg
) >= 0)
4374 fc
->col_type
[reg
] = DW_CFA_undefined
;
4376 case DW_CFA_restore_extended
:
4378 frame_need_space (fc
, reg
);
4379 if (frame_need_space (fc
, reg
) >= 0)
4380 fc
->col_type
[reg
] = DW_CFA_undefined
;
4382 case DW_CFA_undefined
:
4384 if (frame_need_space (fc
, reg
) >= 0)
4385 fc
->col_type
[reg
] = DW_CFA_undefined
;
4387 case DW_CFA_same_value
:
4389 if (frame_need_space (fc
, reg
) >= 0)
4390 fc
->col_type
[reg
] = DW_CFA_undefined
;
4392 case DW_CFA_register
:
4393 reg
= LEB (); LEB ();
4394 if (frame_need_space (fc
, reg
) >= 0)
4395 fc
->col_type
[reg
] = DW_CFA_undefined
;
4397 case DW_CFA_def_cfa
:
4400 case DW_CFA_def_cfa_register
:
4403 case DW_CFA_def_cfa_offset
:
4406 case DW_CFA_def_cfa_expression
:
4410 case DW_CFA_expression
:
4411 case DW_CFA_val_expression
:
4415 if (frame_need_space (fc
, reg
) >= 0)
4416 fc
->col_type
[reg
] = DW_CFA_undefined
;
4418 case DW_CFA_offset_extended_sf
:
4419 case DW_CFA_val_offset_sf
:
4420 reg
= LEB (); SLEB ();
4421 if (frame_need_space (fc
, reg
) >= 0)
4422 fc
->col_type
[reg
] = DW_CFA_undefined
;
4424 case DW_CFA_def_cfa_sf
:
4427 case DW_CFA_def_cfa_offset_sf
:
4430 case DW_CFA_MIPS_advance_loc8
:
4433 case DW_CFA_GNU_args_size
:
4436 case DW_CFA_GNU_negative_offset_extended
:
4437 reg
= LEB (); LEB ();
4438 if (frame_need_space (fc
, reg
) >= 0)
4439 fc
->col_type
[reg
] = DW_CFA_undefined
;
4448 /* Now we know what registers are used, make a second pass over
4449 the chunk, this time actually printing out the info. */
4451 while (start
< block_end
)
4454 unsigned long ul
, reg
, roffs
;
4457 const char *reg_prefix
= "";
4464 /* Warning: if you add any more cases to this switch, be
4465 sure to add them to the corresponding switch above. */
4468 case DW_CFA_advance_loc
:
4469 if (do_debug_frames_interp
)
4470 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4472 printf (" DW_CFA_advance_loc: %d to %08lx\n",
4473 opa
* fc
->code_factor
,
4474 fc
->pc_begin
+ opa
* fc
->code_factor
);
4475 fc
->pc_begin
+= opa
* fc
->code_factor
;
4480 if (opa
>= (unsigned int) fc
->ncols
)
4481 reg_prefix
= bad_reg
;
4482 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4483 printf (" DW_CFA_offset: %s%s at cfa%+ld\n",
4484 reg_prefix
, regname (opa
, 0),
4485 roffs
* fc
->data_factor
);
4486 if (*reg_prefix
== '\0')
4488 fc
->col_type
[opa
] = DW_CFA_offset
;
4489 fc
->col_offset
[opa
] = roffs
* fc
->data_factor
;
4493 case DW_CFA_restore
:
4494 if (opa
>= (unsigned int) cie
->ncols
4495 || opa
>= (unsigned int) fc
->ncols
)
4496 reg_prefix
= bad_reg
;
4497 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4498 printf (" DW_CFA_restore: %s%s\n",
4499 reg_prefix
, regname (opa
, 0));
4500 if (*reg_prefix
== '\0')
4502 fc
->col_type
[opa
] = cie
->col_type
[opa
];
4503 fc
->col_offset
[opa
] = cie
->col_offset
[opa
];
4507 case DW_CFA_set_loc
:
4508 vma
= get_encoded_value (start
, fc
->fde_encoding
, section
);
4509 start
+= encoded_ptr_size
;
4510 if (do_debug_frames_interp
)
4511 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4513 printf (" DW_CFA_set_loc: %08lx\n", (unsigned long)vma
);
4517 case DW_CFA_advance_loc1
:
4518 ofs
= byte_get (start
, 1); start
+= 1;
4519 if (do_debug_frames_interp
)
4520 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4522 printf (" DW_CFA_advance_loc1: %ld to %08lx\n",
4523 ofs
* fc
->code_factor
,
4524 fc
->pc_begin
+ ofs
* fc
->code_factor
);
4525 fc
->pc_begin
+= ofs
* fc
->code_factor
;
4528 case DW_CFA_advance_loc2
:
4529 ofs
= byte_get (start
, 2); start
+= 2;
4530 if (do_debug_frames_interp
)
4531 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4533 printf (" DW_CFA_advance_loc2: %ld to %08lx\n",
4534 ofs
* fc
->code_factor
,
4535 fc
->pc_begin
+ ofs
* fc
->code_factor
);
4536 fc
->pc_begin
+= ofs
* fc
->code_factor
;
4539 case DW_CFA_advance_loc4
:
4540 ofs
= byte_get (start
, 4); start
+= 4;
4541 if (do_debug_frames_interp
)
4542 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4544 printf (" DW_CFA_advance_loc4: %ld to %08lx\n",
4545 ofs
* fc
->code_factor
,
4546 fc
->pc_begin
+ ofs
* fc
->code_factor
);
4547 fc
->pc_begin
+= ofs
* fc
->code_factor
;
4550 case DW_CFA_offset_extended
:
4553 if (reg
>= (unsigned int) fc
->ncols
)
4554 reg_prefix
= bad_reg
;
4555 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4556 printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n",
4557 reg_prefix
, regname (reg
, 0),
4558 roffs
* fc
->data_factor
);
4559 if (*reg_prefix
== '\0')
4561 fc
->col_type
[reg
] = DW_CFA_offset
;
4562 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
4566 case DW_CFA_val_offset
:
4569 if (reg
>= (unsigned int) fc
->ncols
)
4570 reg_prefix
= bad_reg
;
4571 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4572 printf (" DW_CFA_val_offset: %s%s at cfa%+ld\n",
4573 reg_prefix
, regname (reg
, 0),
4574 roffs
* fc
->data_factor
);
4575 if (*reg_prefix
== '\0')
4577 fc
->col_type
[reg
] = DW_CFA_val_offset
;
4578 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
4582 case DW_CFA_restore_extended
:
4584 if (reg
>= (unsigned int) cie
->ncols
4585 || reg
>= (unsigned int) fc
->ncols
)
4586 reg_prefix
= bad_reg
;
4587 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4588 printf (" DW_CFA_restore_extended: %s%s\n",
4589 reg_prefix
, regname (reg
, 0));
4590 if (*reg_prefix
== '\0')
4592 fc
->col_type
[reg
] = cie
->col_type
[reg
];
4593 fc
->col_offset
[reg
] = cie
->col_offset
[reg
];
4597 case DW_CFA_undefined
:
4599 if (reg
>= (unsigned int) fc
->ncols
)
4600 reg_prefix
= bad_reg
;
4601 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4602 printf (" DW_CFA_undefined: %s%s\n",
4603 reg_prefix
, regname (reg
, 0));
4604 if (*reg_prefix
== '\0')
4606 fc
->col_type
[reg
] = DW_CFA_undefined
;
4607 fc
->col_offset
[reg
] = 0;
4611 case DW_CFA_same_value
:
4613 if (reg
>= (unsigned int) fc
->ncols
)
4614 reg_prefix
= bad_reg
;
4615 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4616 printf (" DW_CFA_same_value: %s%s\n",
4617 reg_prefix
, regname (reg
, 0));
4618 if (*reg_prefix
== '\0')
4620 fc
->col_type
[reg
] = DW_CFA_same_value
;
4621 fc
->col_offset
[reg
] = 0;
4625 case DW_CFA_register
:
4628 if (reg
>= (unsigned int) fc
->ncols
)
4629 reg_prefix
= bad_reg
;
4630 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4632 printf (" DW_CFA_register: %s%s in ",
4633 reg_prefix
, regname (reg
, 0));
4634 puts (regname (roffs
, 0));
4636 if (*reg_prefix
== '\0')
4638 fc
->col_type
[reg
] = DW_CFA_register
;
4639 fc
->col_offset
[reg
] = roffs
;
4643 case DW_CFA_remember_state
:
4644 if (! do_debug_frames_interp
)
4645 printf (" DW_CFA_remember_state\n");
4646 rs
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
4647 rs
->ncols
= fc
->ncols
;
4648 rs
->col_type
= (short int *) xcmalloc (rs
->ncols
,
4649 sizeof (short int));
4650 rs
->col_offset
= (int *) xcmalloc (rs
->ncols
, sizeof (int));
4651 memcpy (rs
->col_type
, fc
->col_type
, rs
->ncols
);
4652 memcpy (rs
->col_offset
, fc
->col_offset
, rs
->ncols
* sizeof (int));
4653 rs
->next
= remembered_state
;
4654 remembered_state
= rs
;
4657 case DW_CFA_restore_state
:
4658 if (! do_debug_frames_interp
)
4659 printf (" DW_CFA_restore_state\n");
4660 rs
= remembered_state
;
4663 remembered_state
= rs
->next
;
4664 frame_need_space (fc
, rs
->ncols
- 1);
4665 memcpy (fc
->col_type
, rs
->col_type
, rs
->ncols
);
4666 memcpy (fc
->col_offset
, rs
->col_offset
,
4667 rs
->ncols
* sizeof (int));
4668 free (rs
->col_type
);
4669 free (rs
->col_offset
);
4672 else if (do_debug_frames_interp
)
4673 printf ("Mismatched DW_CFA_restore_state\n");
4676 case DW_CFA_def_cfa
:
4677 fc
->cfa_reg
= LEB ();
4678 fc
->cfa_offset
= LEB ();
4680 if (! do_debug_frames_interp
)
4681 printf (" DW_CFA_def_cfa: %s ofs %d\n",
4682 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
4685 case DW_CFA_def_cfa_register
:
4686 fc
->cfa_reg
= LEB ();
4688 if (! do_debug_frames_interp
)
4689 printf (" DW_CFA_def_cfa_register: %s\n",
4690 regname (fc
->cfa_reg
, 0));
4693 case DW_CFA_def_cfa_offset
:
4694 fc
->cfa_offset
= LEB ();
4695 if (! do_debug_frames_interp
)
4696 printf (" DW_CFA_def_cfa_offset: %d\n", fc
->cfa_offset
);
4700 if (! do_debug_frames_interp
)
4701 printf (" DW_CFA_nop\n");
4704 case DW_CFA_def_cfa_expression
:
4706 if (! do_debug_frames_interp
)
4708 printf (" DW_CFA_def_cfa_expression (");
4709 decode_location_expression (start
, eh_addr_size
, 0, -1,
4717 case DW_CFA_expression
:
4720 if (reg
>= (unsigned int) fc
->ncols
)
4721 reg_prefix
= bad_reg
;
4722 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4724 printf (" DW_CFA_expression: %s%s (",
4725 reg_prefix
, regname (reg
, 0));
4726 decode_location_expression (start
, eh_addr_size
, 0, -1,
4730 if (*reg_prefix
== '\0')
4731 fc
->col_type
[reg
] = DW_CFA_expression
;
4735 case DW_CFA_val_expression
:
4738 if (reg
>= (unsigned int) fc
->ncols
)
4739 reg_prefix
= bad_reg
;
4740 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4742 printf (" DW_CFA_val_expression: %s%s (",
4743 reg_prefix
, regname (reg
, 0));
4744 decode_location_expression (start
, eh_addr_size
, 0, -1,
4748 if (*reg_prefix
== '\0')
4749 fc
->col_type
[reg
] = DW_CFA_val_expression
;
4753 case DW_CFA_offset_extended_sf
:
4756 if (frame_need_space (fc
, reg
) < 0)
4757 reg_prefix
= bad_reg
;
4758 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4759 printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n",
4760 reg_prefix
, regname (reg
, 0),
4761 l
* fc
->data_factor
);
4762 if (*reg_prefix
== '\0')
4764 fc
->col_type
[reg
] = DW_CFA_offset
;
4765 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
4769 case DW_CFA_val_offset_sf
:
4772 if (frame_need_space (fc
, reg
) < 0)
4773 reg_prefix
= bad_reg
;
4774 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4775 printf (" DW_CFA_val_offset_sf: %s%s at cfa%+ld\n",
4776 reg_prefix
, regname (reg
, 0),
4777 l
* fc
->data_factor
);
4778 if (*reg_prefix
== '\0')
4780 fc
->col_type
[reg
] = DW_CFA_val_offset
;
4781 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
4785 case DW_CFA_def_cfa_sf
:
4786 fc
->cfa_reg
= LEB ();
4787 fc
->cfa_offset
= SLEB ();
4788 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
4790 if (! do_debug_frames_interp
)
4791 printf (" DW_CFA_def_cfa_sf: %s ofs %d\n",
4792 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
4795 case DW_CFA_def_cfa_offset_sf
:
4796 fc
->cfa_offset
= SLEB ();
4797 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
4798 if (! do_debug_frames_interp
)
4799 printf (" DW_CFA_def_cfa_offset_sf: %d\n", fc
->cfa_offset
);
4802 case DW_CFA_MIPS_advance_loc8
:
4803 ofs
= byte_get (start
, 8); start
+= 8;
4804 if (do_debug_frames_interp
)
4805 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4807 printf (" DW_CFA_MIPS_advance_loc8: %ld to %08lx\n",
4808 ofs
* fc
->code_factor
,
4809 fc
->pc_begin
+ ofs
* fc
->code_factor
);
4810 fc
->pc_begin
+= ofs
* fc
->code_factor
;
4813 case DW_CFA_GNU_window_save
:
4814 if (! do_debug_frames_interp
)
4815 printf (" DW_CFA_GNU_window_save\n");
4818 case DW_CFA_GNU_args_size
:
4820 if (! do_debug_frames_interp
)
4821 printf (" DW_CFA_GNU_args_size: %ld\n", ul
);
4824 case DW_CFA_GNU_negative_offset_extended
:
4827 if (frame_need_space (fc
, reg
) < 0)
4828 reg_prefix
= bad_reg
;
4829 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4830 printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n",
4831 reg_prefix
, regname (reg
, 0),
4832 l
* fc
->data_factor
);
4833 if (*reg_prefix
== '\0')
4835 fc
->col_type
[reg
] = DW_CFA_offset
;
4836 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
4841 if (op
>= DW_CFA_lo_user
&& op
<= DW_CFA_hi_user
)
4842 printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op
);
4844 warn (_("unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op
);
4849 if (do_debug_frames_interp
)
4850 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4853 eh_addr_size
= saved_eh_addr_size
;
4866 display_debug_not_supported (struct dwarf_section
*section
,
4867 void *file ATTRIBUTE_UNUSED
)
4869 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
4876 cmalloc (size_t nmemb
, size_t size
)
4878 /* Check for overflow. */
4879 if (nmemb
>= ~(size_t) 0 / size
)
4882 return malloc (nmemb
* size
);
4886 xcmalloc (size_t nmemb
, size_t size
)
4888 /* Check for overflow. */
4889 if (nmemb
>= ~(size_t) 0 / size
)
4892 return xmalloc (nmemb
* size
);
4896 xcrealloc (void *ptr
, size_t nmemb
, size_t size
)
4898 /* Check for overflow. */
4899 if (nmemb
>= ~(size_t) 0 / size
)
4902 return xrealloc (ptr
, nmemb
* size
);
4906 free_debug_memory (void)
4912 for (i
= 0; i
< max
; i
++)
4913 free_debug_section ((enum dwarf_section_display_enum
) i
);
4915 if (debug_information
!= NULL
)
4917 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
)
4919 for (i
= 0; i
< num_debug_info_entries
; i
++)
4921 if (!debug_information
[i
].max_loc_offsets
)
4923 free (debug_information
[i
].loc_offsets
);
4924 free (debug_information
[i
].have_frame_base
);
4926 if (!debug_information
[i
].max_range_lists
)
4927 free (debug_information
[i
].range_lists
);
4931 free (debug_information
);
4932 debug_information
= NULL
;
4933 num_debug_info_entries
= 0;
4938 dwarf_select_sections_by_names (const char *names
)
4942 const char * option
;
4946 debug_dump_long_opts
;
4948 static const debug_dump_long_opts opts_table
[] =
4950 /* Please keep this table alpha- sorted. */
4951 { "Ranges", & do_debug_ranges
, 1 },
4952 { "abbrev", & do_debug_abbrevs
, 1 },
4953 { "aranges", & do_debug_aranges
, 1 },
4954 { "frames", & do_debug_frames
, 1 },
4955 { "frames-interp", & do_debug_frames_interp
, 1 },
4956 { "info", & do_debug_info
, 1 },
4957 { "line", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
}, /* For backwards compatibility. */
4958 { "rawline", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
},
4959 { "decodedline", & do_debug_lines
, FLAG_DEBUG_LINES_DECODED
},
4960 { "loc", & do_debug_loc
, 1 },
4961 { "macro", & do_debug_macinfo
, 1 },
4962 { "pubnames", & do_debug_pubnames
, 1 },
4963 { "pubtypes", & do_debug_pubtypes
, 1 },
4964 /* This entry is for compatability
4965 with earlier versions of readelf. */
4966 { "ranges", & do_debug_aranges
, 1 },
4967 { "str", & do_debug_str
, 1 },
4968 /* These trace_* sections are used by Itanium VMS. */
4969 { "trace_abbrev", & do_trace_abbrevs
, 1 },
4970 { "trace_aranges", & do_trace_aranges
, 1 },
4971 { "trace_info", & do_trace_info
, 1 },
4980 const debug_dump_long_opts
* entry
;
4982 for (entry
= opts_table
; entry
->option
; entry
++)
4984 size_t len
= strlen (entry
->option
);
4986 if (strncmp (p
, entry
->option
, len
) == 0
4987 && (p
[len
] == ',' || p
[len
] == '\0'))
4989 * entry
->variable
|= entry
->val
;
4991 /* The --debug-dump=frames-interp option also
4992 enables the --debug-dump=frames option. */
4993 if (do_debug_frames_interp
)
4994 do_debug_frames
= 1;
5001 if (entry
->option
== NULL
)
5003 warn (_("Unrecognized debug option '%s'\n"), p
);
5004 p
= strchr (p
, ',');
5015 dwarf_select_sections_by_letters (const char *letters
)
5017 unsigned int lindex
= 0;
5019 while (letters
[lindex
])
5020 switch (letters
[lindex
++])
5027 do_debug_abbrevs
= 1;
5031 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
5035 do_debug_lines
|= FLAG_DEBUG_LINES_DECODED
;
5039 do_debug_pubnames
= 1;
5043 do_debug_pubtypes
= 1;
5047 do_debug_aranges
= 1;
5051 do_debug_ranges
= 1;
5055 do_debug_frames_interp
= 1;
5057 do_debug_frames
= 1;
5061 do_debug_macinfo
= 1;
5073 warn (_("Unrecognized debug option '%s'\n"), optarg
);
5079 dwarf_select_sections_all (void)
5082 do_debug_abbrevs
= 1;
5083 do_debug_lines
= FLAG_DEBUG_LINES_RAW
;
5084 do_debug_pubnames
= 1;
5085 do_debug_pubtypes
= 1;
5086 do_debug_aranges
= 1;
5087 do_debug_ranges
= 1;
5088 do_debug_frames
= 1;
5089 do_debug_macinfo
= 1;
5093 do_trace_abbrevs
= 1;
5094 do_trace_aranges
= 1;
5097 struct dwarf_section_display debug_displays
[] =
5099 { { ".debug_abbrev", ".zdebug_abbrev", NULL
, NULL
, 0, 0 },
5100 display_debug_abbrev
, &do_debug_abbrevs
, 0 },
5101 { { ".debug_aranges", ".zdebug_aranges", NULL
, NULL
, 0, 0 },
5102 display_debug_aranges
, &do_debug_aranges
, 1 },
5103 { { ".debug_frame", ".zdebug_frame", NULL
, NULL
, 0, 0 },
5104 display_debug_frames
, &do_debug_frames
, 1 },
5105 { { ".debug_info", ".zdebug_info", NULL
, NULL
, 0, 0 },
5106 display_debug_info
, &do_debug_info
, 1 },
5107 { { ".debug_line", ".zdebug_line", NULL
, NULL
, 0, 0 },
5108 display_debug_lines
, &do_debug_lines
, 1 },
5109 { { ".debug_pubnames", ".zdebug_pubnames", NULL
, NULL
, 0, 0 },
5110 display_debug_pubnames
, &do_debug_pubnames
, 0 },
5111 { { ".eh_frame", "", NULL
, NULL
, 0, 0 },
5112 display_debug_frames
, &do_debug_frames
, 1 },
5113 { { ".debug_macinfo", ".zdebug_macinfo", NULL
, NULL
, 0, 0 },
5114 display_debug_macinfo
, &do_debug_macinfo
, 0 },
5115 { { ".debug_str", ".zdebug_str", NULL
, NULL
, 0, 0 },
5116 display_debug_str
, &do_debug_str
, 0 },
5117 { { ".debug_loc", ".zdebug_loc", NULL
, NULL
, 0, 0 },
5118 display_debug_loc
, &do_debug_loc
, 1 },
5119 { { ".debug_pubtypes", ".zdebug_pubtypes", NULL
, NULL
, 0, 0 },
5120 display_debug_pubnames
, &do_debug_pubtypes
, 0 },
5121 { { ".debug_ranges", ".zdebug_ranges", NULL
, NULL
, 0, 0 },
5122 display_debug_ranges
, &do_debug_ranges
, 1 },
5123 { { ".debug_static_func", ".zdebug_static_func", NULL
, NULL
, 0, 0 },
5124 display_debug_not_supported
, NULL
, 0 },
5125 { { ".debug_static_vars", ".zdebug_static_vars", NULL
, NULL
, 0, 0 },
5126 display_debug_not_supported
, NULL
, 0 },
5127 { { ".debug_types", ".zdebug_types", NULL
, NULL
, 0, 0 },
5128 display_debug_types
, &do_debug_info
, 1 },
5129 { { ".debug_weaknames", ".zdebug_weaknames", NULL
, NULL
, 0, 0 },
5130 display_debug_not_supported
, NULL
, 0 },
5131 { { ".trace_info", "", NULL
, NULL
, 0, 0 },
5132 display_trace_info
, &do_trace_info
, 1 },
5133 { { ".trace_abbrev", "", NULL
, NULL
, 0, 0 },
5134 display_debug_abbrev
, &do_trace_abbrevs
, 0 },
5135 { { ".trace_aranges", "", NULL
, NULL
, 0, 0 },
5136 display_debug_aranges
, &do_trace_aranges
, 0 }