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
, int encoding
)
84 int size
= size_of_encoded_value (encoding
);
86 if (encoding
& DW_EH_PE_signed
)
87 return byte_get_signed (data
, size
);
89 return byte_get (data
, size
);
92 /* Print a dwarf_vma value (typically an address, offset or length) in
93 hexadecimal format, followed by a space. The length of the value (and
94 hence the precision displayed) is determined by the byte_size parameter. */
97 print_dwarf_vma (dwarf_vma val
, unsigned byte_size
)
101 /* Printf does not have a way of specifiying a maximum field width for an
102 integer value, so we print the full value into a buffer and then select
103 the precision we need. */
104 #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
106 snprintf (buff
, sizeof (buff
), "%16.16llx ", val
);
108 snprintf (buff
, sizeof (buff
), "%016I64x ", val
);
111 snprintf (buff
, sizeof (buff
), "%16.16lx ", val
);
114 fputs (buff
+ (byte_size
== 4 ? 8 : 0), stdout
);
118 read_leb128 (unsigned char *data
, unsigned int *length_return
, int sign
)
120 unsigned long int result
= 0;
121 unsigned int num_read
= 0;
122 unsigned int shift
= 0;
130 result
|= ((unsigned long int) (byte
& 0x7f)) << shift
;
137 if (length_return
!= NULL
)
138 *length_return
= num_read
;
140 if (sign
&& (shift
< 8 * sizeof (result
)) && (byte
& 0x40))
141 result
|= -1L << shift
;
146 typedef struct State_Machine_Registers
148 unsigned long address
;
154 unsigned char op_index
;
155 unsigned char end_sequence
;
156 /* This variable hold the number of the last entry seen
157 in the File Table. */
158 unsigned int last_file_entry
;
161 static SMR state_machine_regs
;
164 reset_state_machine (int is_stmt
)
166 state_machine_regs
.address
= 0;
167 state_machine_regs
.op_index
= 0;
168 state_machine_regs
.file
= 1;
169 state_machine_regs
.line
= 1;
170 state_machine_regs
.column
= 0;
171 state_machine_regs
.is_stmt
= is_stmt
;
172 state_machine_regs
.basic_block
= 0;
173 state_machine_regs
.end_sequence
= 0;
174 state_machine_regs
.last_file_entry
= 0;
177 /* Handled an extend line op.
178 Returns the number of bytes read. */
181 process_extended_line_op (unsigned char *data
, int is_stmt
)
183 unsigned char op_code
;
184 unsigned int bytes_read
;
189 len
= read_leb128 (data
, & bytes_read
, 0);
194 warn (_("badly formed extended line op encountered!\n"));
201 printf (_(" Extended opcode %d: "), op_code
);
205 case DW_LNE_end_sequence
:
206 printf (_("End of Sequence\n\n"));
207 reset_state_machine (is_stmt
);
210 case DW_LNE_set_address
:
211 adr
= byte_get (data
, len
- bytes_read
- 1);
212 printf (_("set Address to 0x%lx\n"), adr
);
213 state_machine_regs
.address
= adr
;
214 state_machine_regs
.op_index
= 0;
217 case DW_LNE_define_file
:
218 printf (_(" define new File Table entry\n"));
219 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
221 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
223 data
+= strlen ((char *) data
) + 1;
224 printf ("%lu\t", read_leb128 (data
, & bytes_read
, 0));
226 printf ("%lu\t", read_leb128 (data
, & bytes_read
, 0));
228 printf ("%lu\t", read_leb128 (data
, & bytes_read
, 0));
229 printf ("%s\n\n", name
);
232 case DW_LNE_set_discriminator
:
233 printf (_("set Discriminator to %lu\n"),
234 read_leb128 (data
, & bytes_read
, 0));
238 case DW_LNE_HP_negate_is_UV_update
:
239 printf ("DW_LNE_HP_negate_is_UV_update\n");
241 case DW_LNE_HP_push_context
:
242 printf ("DW_LNE_HP_push_context\n");
244 case DW_LNE_HP_pop_context
:
245 printf ("DW_LNE_HP_pop_context\n");
247 case DW_LNE_HP_set_file_line_column
:
248 printf ("DW_LNE_HP_set_file_line_column\n");
250 case DW_LNE_HP_set_routine_name
:
251 printf ("DW_LNE_HP_set_routine_name\n");
253 case DW_LNE_HP_set_sequence
:
254 printf ("DW_LNE_HP_set_sequence\n");
256 case DW_LNE_HP_negate_post_semantics
:
257 printf ("DW_LNE_HP_negate_post_semantics\n");
259 case DW_LNE_HP_negate_function_exit
:
260 printf ("DW_LNE_HP_negate_function_exit\n");
262 case DW_LNE_HP_negate_front_end_logical
:
263 printf ("DW_LNE_HP_negate_front_end_logical\n");
265 case DW_LNE_HP_define_proc
:
266 printf ("DW_LNE_HP_define_proc\n");
270 if (op_code
>= DW_LNE_lo_user
271 /* The test against DW_LNW_hi_user is redundant due to
272 the limited range of the unsigned char data type used
274 /*&& op_code <= DW_LNE_hi_user*/)
275 printf (_("user defined: length %d\n"), len
- bytes_read
);
277 printf (_("UNKNOWN: length %d\n"), len
- bytes_read
);
285 fetch_indirect_string (unsigned long offset
)
287 struct dwarf_section
*section
= &debug_displays
[str
].section
;
289 if (section
->start
== NULL
)
290 return _("<no .debug_str section>");
292 /* DWARF sections under Mach-O have non-zero addresses. */
293 offset
-= section
->address
;
294 if (offset
> section
->size
)
296 warn (_("DW_FORM_strp offset too big: %lx\n"), offset
);
297 return _("<offset is too big>");
300 return (const char *) section
->start
+ offset
;
303 /* FIXME: There are better and more efficient ways to handle
304 these structures. For now though, I just want something that
305 is simple to implement. */
306 typedef struct abbrev_attr
308 unsigned long attribute
;
310 struct abbrev_attr
*next
;
314 typedef struct abbrev_entry
319 struct abbrev_attr
*first_attr
;
320 struct abbrev_attr
*last_attr
;
321 struct abbrev_entry
*next
;
325 static abbrev_entry
*first_abbrev
= NULL
;
326 static abbrev_entry
*last_abbrev
= NULL
;
333 for (abbrv
= first_abbrev
; abbrv
;)
335 abbrev_entry
*next_abbrev
= abbrv
->next
;
338 for (attr
= abbrv
->first_attr
; attr
;)
340 abbrev_attr
*next_attr
= attr
->next
;
350 last_abbrev
= first_abbrev
= NULL
;
354 add_abbrev (unsigned long number
, unsigned long tag
, int children
)
358 entry
= (abbrev_entry
*) malloc (sizeof (*entry
));
364 entry
->entry
= number
;
366 entry
->children
= children
;
367 entry
->first_attr
= NULL
;
368 entry
->last_attr
= NULL
;
371 if (first_abbrev
== NULL
)
372 first_abbrev
= entry
;
374 last_abbrev
->next
= entry
;
380 add_abbrev_attr (unsigned long attribute
, unsigned long form
)
384 attr
= (abbrev_attr
*) malloc (sizeof (*attr
));
390 attr
->attribute
= attribute
;
394 if (last_abbrev
->first_attr
== NULL
)
395 last_abbrev
->first_attr
= attr
;
397 last_abbrev
->last_attr
->next
= attr
;
399 last_abbrev
->last_attr
= attr
;
402 /* Processes the (partial) contents of a .debug_abbrev section.
403 Returns NULL if the end of the section was encountered.
404 Returns the address after the last byte read if the end of
405 an abbreviation set was found. */
407 static unsigned char *
408 process_abbrev_section (unsigned char *start
, unsigned char *end
)
410 if (first_abbrev
!= NULL
)
415 unsigned int bytes_read
;
418 unsigned long attribute
;
421 entry
= read_leb128 (start
, & bytes_read
, 0);
424 /* A single zero is supposed to end the section according
425 to the standard. If there's more, then signal that to
428 return start
== end
? NULL
: start
;
430 tag
= read_leb128 (start
, & bytes_read
, 0);
435 add_abbrev (entry
, tag
, children
);
441 attribute
= read_leb128 (start
, & bytes_read
, 0);
444 form
= read_leb128 (start
, & bytes_read
, 0);
448 add_abbrev_attr (attribute
, form
);
450 while (attribute
!= 0);
457 get_TAG_name (unsigned long tag
)
461 case DW_TAG_padding
: return "DW_TAG_padding";
462 case DW_TAG_array_type
: return "DW_TAG_array_type";
463 case DW_TAG_class_type
: return "DW_TAG_class_type";
464 case DW_TAG_entry_point
: return "DW_TAG_entry_point";
465 case DW_TAG_enumeration_type
: return "DW_TAG_enumeration_type";
466 case DW_TAG_formal_parameter
: return "DW_TAG_formal_parameter";
467 case DW_TAG_imported_declaration
: return "DW_TAG_imported_declaration";
468 case DW_TAG_label
: return "DW_TAG_label";
469 case DW_TAG_lexical_block
: return "DW_TAG_lexical_block";
470 case DW_TAG_member
: return "DW_TAG_member";
471 case DW_TAG_pointer_type
: return "DW_TAG_pointer_type";
472 case DW_TAG_reference_type
: return "DW_TAG_reference_type";
473 case DW_TAG_compile_unit
: return "DW_TAG_compile_unit";
474 case DW_TAG_string_type
: return "DW_TAG_string_type";
475 case DW_TAG_structure_type
: return "DW_TAG_structure_type";
476 case DW_TAG_subroutine_type
: return "DW_TAG_subroutine_type";
477 case DW_TAG_typedef
: return "DW_TAG_typedef";
478 case DW_TAG_union_type
: return "DW_TAG_union_type";
479 case DW_TAG_unspecified_parameters
: return "DW_TAG_unspecified_parameters";
480 case DW_TAG_variant
: return "DW_TAG_variant";
481 case DW_TAG_common_block
: return "DW_TAG_common_block";
482 case DW_TAG_common_inclusion
: return "DW_TAG_common_inclusion";
483 case DW_TAG_inheritance
: return "DW_TAG_inheritance";
484 case DW_TAG_inlined_subroutine
: return "DW_TAG_inlined_subroutine";
485 case DW_TAG_module
: return "DW_TAG_module";
486 case DW_TAG_ptr_to_member_type
: return "DW_TAG_ptr_to_member_type";
487 case DW_TAG_set_type
: return "DW_TAG_set_type";
488 case DW_TAG_subrange_type
: return "DW_TAG_subrange_type";
489 case DW_TAG_with_stmt
: return "DW_TAG_with_stmt";
490 case DW_TAG_access_declaration
: return "DW_TAG_access_declaration";
491 case DW_TAG_base_type
: return "DW_TAG_base_type";
492 case DW_TAG_catch_block
: return "DW_TAG_catch_block";
493 case DW_TAG_const_type
: return "DW_TAG_const_type";
494 case DW_TAG_constant
: return "DW_TAG_constant";
495 case DW_TAG_enumerator
: return "DW_TAG_enumerator";
496 case DW_TAG_file_type
: return "DW_TAG_file_type";
497 case DW_TAG_friend
: return "DW_TAG_friend";
498 case DW_TAG_namelist
: return "DW_TAG_namelist";
499 case DW_TAG_namelist_item
: return "DW_TAG_namelist_item";
500 case DW_TAG_packed_type
: return "DW_TAG_packed_type";
501 case DW_TAG_subprogram
: return "DW_TAG_subprogram";
502 case DW_TAG_template_type_param
: return "DW_TAG_template_type_param";
503 case DW_TAG_template_value_param
: return "DW_TAG_template_value_param";
504 case DW_TAG_thrown_type
: return "DW_TAG_thrown_type";
505 case DW_TAG_try_block
: return "DW_TAG_try_block";
506 case DW_TAG_variant_part
: return "DW_TAG_variant_part";
507 case DW_TAG_variable
: return "DW_TAG_variable";
508 case DW_TAG_volatile_type
: return "DW_TAG_volatile_type";
509 case DW_TAG_MIPS_loop
: return "DW_TAG_MIPS_loop";
510 case DW_TAG_format_label
: return "DW_TAG_format_label";
511 case DW_TAG_function_template
: return "DW_TAG_function_template";
512 case DW_TAG_class_template
: return "DW_TAG_class_template";
513 /* DWARF 2.1 values. */
514 case DW_TAG_dwarf_procedure
: return "DW_TAG_dwarf_procedure";
515 case DW_TAG_restrict_type
: return "DW_TAG_restrict_type";
516 case DW_TAG_interface_type
: return "DW_TAG_interface_type";
517 case DW_TAG_namespace
: return "DW_TAG_namespace";
518 case DW_TAG_imported_module
: return "DW_TAG_imported_module";
519 case DW_TAG_unspecified_type
: return "DW_TAG_unspecified_type";
520 case DW_TAG_partial_unit
: return "DW_TAG_partial_unit";
521 case DW_TAG_imported_unit
: return "DW_TAG_imported_unit";
522 case DW_TAG_condition
: return "DW_TAG_condition";
523 case DW_TAG_shared_type
: return "DW_TAG_shared_type";
524 /* DWARF 4 values. */
525 case DW_TAG_type_unit
: return "DW_TAG_type_unit";
526 case DW_TAG_rvalue_reference_type
: return "DW_TAG_rvalue_reference_type";
527 case DW_TAG_template_alias
: return "DW_TAG_template_alias";
529 case DW_TAG_upc_shared_type
: return "DW_TAG_upc_shared_type";
530 case DW_TAG_upc_strict_type
: return "DW_TAG_upc_strict_type";
531 case DW_TAG_upc_relaxed_type
: return "DW_TAG_upc_relaxed_type";
534 static char buffer
[100];
536 snprintf (buffer
, sizeof (buffer
), _("Unknown TAG value: %lx"), tag
);
543 get_FORM_name (unsigned long form
)
547 case DW_FORM_addr
: return "DW_FORM_addr";
548 case DW_FORM_block2
: return "DW_FORM_block2";
549 case DW_FORM_block4
: return "DW_FORM_block4";
550 case DW_FORM_data2
: return "DW_FORM_data2";
551 case DW_FORM_data4
: return "DW_FORM_data4";
552 case DW_FORM_data8
: return "DW_FORM_data8";
553 case DW_FORM_string
: return "DW_FORM_string";
554 case DW_FORM_block
: return "DW_FORM_block";
555 case DW_FORM_block1
: return "DW_FORM_block1";
556 case DW_FORM_data1
: return "DW_FORM_data1";
557 case DW_FORM_flag
: return "DW_FORM_flag";
558 case DW_FORM_sdata
: return "DW_FORM_sdata";
559 case DW_FORM_strp
: return "DW_FORM_strp";
560 case DW_FORM_udata
: return "DW_FORM_udata";
561 case DW_FORM_ref_addr
: return "DW_FORM_ref_addr";
562 case DW_FORM_ref1
: return "DW_FORM_ref1";
563 case DW_FORM_ref2
: return "DW_FORM_ref2";
564 case DW_FORM_ref4
: return "DW_FORM_ref4";
565 case DW_FORM_ref8
: return "DW_FORM_ref8";
566 case DW_FORM_ref_udata
: return "DW_FORM_ref_udata";
567 case DW_FORM_indirect
: return "DW_FORM_indirect";
568 /* DWARF 4 values. */
569 case DW_FORM_sec_offset
: return "DW_FORM_sec_offset";
570 case DW_FORM_exprloc
: return "DW_FORM_exprloc";
571 case DW_FORM_flag_present
: return "DW_FORM_flag_present";
572 case DW_FORM_ref_sig8
: return "DW_FORM_ref_sig8";
575 static char buffer
[100];
577 snprintf (buffer
, sizeof (buffer
), _("Unknown FORM value: %lx"), form
);
583 static unsigned char *
584 display_block (unsigned char *data
, unsigned long length
)
586 printf (_(" %lu byte block: "), length
);
589 printf ("%lx ", (unsigned long) byte_get (data
++, 1));
595 decode_location_expression (unsigned char * data
,
596 unsigned int pointer_size
,
597 unsigned int offset_size
,
599 unsigned long length
,
600 unsigned long cu_offset
,
601 struct dwarf_section
* section
)
604 unsigned int bytes_read
;
605 unsigned long uvalue
;
606 unsigned char *end
= data
+ length
;
607 int need_frame_base
= 0;
616 printf ("DW_OP_addr: %lx",
617 (unsigned long) byte_get (data
, pointer_size
));
618 data
+= pointer_size
;
621 printf ("DW_OP_deref");
624 printf ("DW_OP_const1u: %lu", (unsigned long) byte_get (data
++, 1));
627 printf ("DW_OP_const1s: %ld", (long) byte_get_signed (data
++, 1));
630 printf ("DW_OP_const2u: %lu", (unsigned long) byte_get (data
, 2));
634 printf ("DW_OP_const2s: %ld", (long) byte_get_signed (data
, 2));
638 printf ("DW_OP_const4u: %lu", (unsigned long) byte_get (data
, 4));
642 printf ("DW_OP_const4s: %ld", (long) byte_get_signed (data
, 4));
646 printf ("DW_OP_const8u: %lu %lu", (unsigned long) byte_get (data
, 4),
647 (unsigned long) byte_get (data
+ 4, 4));
651 printf ("DW_OP_const8s: %ld %ld", (long) byte_get (data
, 4),
652 (long) byte_get (data
+ 4, 4));
656 printf ("DW_OP_constu: %lu", read_leb128 (data
, &bytes_read
, 0));
660 printf ("DW_OP_consts: %ld", read_leb128 (data
, &bytes_read
, 1));
664 printf ("DW_OP_dup");
667 printf ("DW_OP_drop");
670 printf ("DW_OP_over");
673 printf ("DW_OP_pick: %ld", (unsigned long) byte_get (data
++, 1));
676 printf ("DW_OP_swap");
679 printf ("DW_OP_rot");
682 printf ("DW_OP_xderef");
685 printf ("DW_OP_abs");
688 printf ("DW_OP_and");
691 printf ("DW_OP_div");
694 printf ("DW_OP_minus");
697 printf ("DW_OP_mod");
700 printf ("DW_OP_mul");
703 printf ("DW_OP_neg");
706 printf ("DW_OP_not");
712 printf ("DW_OP_plus");
714 case DW_OP_plus_uconst
:
715 printf ("DW_OP_plus_uconst: %lu",
716 read_leb128 (data
, &bytes_read
, 0));
720 printf ("DW_OP_shl");
723 printf ("DW_OP_shr");
726 printf ("DW_OP_shra");
729 printf ("DW_OP_xor");
732 printf ("DW_OP_bra: %ld", (long) byte_get_signed (data
, 2));
754 printf ("DW_OP_skip: %ld", (long) byte_get_signed (data
, 2));
790 printf ("DW_OP_lit%d", op
- DW_OP_lit0
);
825 printf ("DW_OP_reg%d (%s)", op
- DW_OP_reg0
,
826 regname (op
- DW_OP_reg0
, 1));
861 printf ("DW_OP_breg%d (%s): %ld", op
- DW_OP_breg0
,
862 regname (op
- DW_OP_breg0
, 1),
863 read_leb128 (data
, &bytes_read
, 1));
868 uvalue
= read_leb128 (data
, &bytes_read
, 0);
870 printf ("DW_OP_regx: %lu (%s)", uvalue
, regname (uvalue
, 1));
874 printf ("DW_OP_fbreg: %ld", read_leb128 (data
, &bytes_read
, 1));
878 uvalue
= read_leb128 (data
, &bytes_read
, 0);
880 printf ("DW_OP_bregx: %lu (%s) %ld", uvalue
, regname (uvalue
, 1),
881 read_leb128 (data
, &bytes_read
, 1));
885 printf ("DW_OP_piece: %lu", read_leb128 (data
, &bytes_read
, 0));
888 case DW_OP_deref_size
:
889 printf ("DW_OP_deref_size: %ld", (long) byte_get (data
++, 1));
891 case DW_OP_xderef_size
:
892 printf ("DW_OP_xderef_size: %ld", (long) byte_get (data
++, 1));
895 printf ("DW_OP_nop");
898 /* DWARF 3 extensions. */
899 case DW_OP_push_object_address
:
900 printf ("DW_OP_push_object_address");
903 /* XXX: Strictly speaking for 64-bit DWARF3 files
904 this ought to be an 8-byte wide computation. */
905 printf ("DW_OP_call2: <0x%lx>", (long) byte_get (data
, 2) + cu_offset
);
909 /* XXX: Strictly speaking for 64-bit DWARF3 files
910 this ought to be an 8-byte wide computation. */
911 printf ("DW_OP_call4: <0x%lx>", (long) byte_get (data
, 4) + cu_offset
);
915 /* XXX: Strictly speaking for 64-bit DWARF3 files
916 this ought to be an 8-byte wide computation. */
917 if (dwarf_version
== -1)
919 printf (_("(DW_OP_call_ref in frame info)"));
920 /* No way to tell where the next op is, so just bail. */
921 return need_frame_base
;
923 if (dwarf_version
== 2)
925 printf ("DW_OP_call_ref: <0x%lx>",
926 (long) byte_get (data
, pointer_size
));
927 data
+= pointer_size
;
931 printf ("DW_OP_call_ref: <0x%lx>",
932 (long) byte_get (data
, offset_size
));
936 case DW_OP_form_tls_address
:
937 printf ("DW_OP_form_tls_address");
939 case DW_OP_call_frame_cfa
:
940 printf ("DW_OP_call_frame_cfa");
942 case DW_OP_bit_piece
:
943 printf ("DW_OP_bit_piece: ");
944 printf ("size: %lu ", read_leb128 (data
, &bytes_read
, 0));
946 printf ("offset: %lu ", read_leb128 (data
, &bytes_read
, 0));
950 /* DWARF 4 extensions. */
951 case DW_OP_stack_value
:
952 printf ("DW_OP_stack_value");
955 case DW_OP_implicit_value
:
956 printf ("DW_OP_implicit_value");
957 uvalue
= read_leb128 (data
, &bytes_read
, 0);
959 display_block (data
, uvalue
);
963 /* GNU extensions. */
964 case DW_OP_GNU_push_tls_address
:
965 printf ("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown");
967 case DW_OP_GNU_uninit
:
968 printf ("DW_OP_GNU_uninit");
969 /* FIXME: Is there data associated with this OP ? */
971 case DW_OP_GNU_encoded_addr
:
977 addr
= get_encoded_value (data
, encoding
);
978 if ((encoding
& 0x70) == DW_EH_PE_pcrel
)
979 addr
+= section
->address
+ (data
- section
->start
);
980 data
+= size_of_encoded_value (encoding
);
982 printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding
);
983 print_dwarf_vma (addr
, pointer_size
);
986 case DW_OP_GNU_implicit_pointer
:
987 /* XXX: Strictly speaking for 64-bit DWARF3 files
988 this ought to be an 8-byte wide computation. */
989 if (dwarf_version
== -1)
991 printf (_("(DW_OP_GNU_implicit_pointer in frame info)"));
992 /* No way to tell where the next op is, so just bail. */
993 return need_frame_base
;
995 if (dwarf_version
== 2)
997 printf ("DW_OP_GNU_implicit_pointer: <0x%lx> %ld",
998 (long) byte_get (data
, pointer_size
),
999 read_leb128 (data
+ pointer_size
, &bytes_read
, 1));
1000 data
+= pointer_size
+ bytes_read
;
1004 printf ("DW_OP_GNU_implicit_pointer: <0x%lx> %ld",
1005 (long) byte_get (data
, offset_size
),
1006 read_leb128 (data
+ offset_size
, &bytes_read
, 1));
1007 data
+= offset_size
+ bytes_read
;
1011 /* HP extensions. */
1012 case DW_OP_HP_is_value
:
1013 printf ("DW_OP_HP_is_value");
1014 /* FIXME: Is there data associated with this OP ? */
1016 case DW_OP_HP_fltconst4
:
1017 printf ("DW_OP_HP_fltconst4");
1018 /* FIXME: Is there data associated with this OP ? */
1020 case DW_OP_HP_fltconst8
:
1021 printf ("DW_OP_HP_fltconst8");
1022 /* FIXME: Is there data associated with this OP ? */
1024 case DW_OP_HP_mod_range
:
1025 printf ("DW_OP_HP_mod_range");
1026 /* FIXME: Is there data associated with this OP ? */
1028 case DW_OP_HP_unmod_range
:
1029 printf ("DW_OP_HP_unmod_range");
1030 /* FIXME: Is there data associated with this OP ? */
1033 printf ("DW_OP_HP_tls");
1034 /* FIXME: Is there data associated with this OP ? */
1037 /* PGI (STMicroelectronics) extensions. */
1038 case DW_OP_PGI_omp_thread_num
:
1039 /* Pushes the thread number for the current thread as it would be
1040 returned by the standard OpenMP library function:
1041 omp_get_thread_num(). The "current thread" is the thread for
1042 which the expression is being evaluated. */
1043 printf ("DW_OP_PGI_omp_thread_num");
1047 if (op
>= DW_OP_lo_user
1048 && op
<= DW_OP_hi_user
)
1049 printf (_("(User defined location op)"));
1051 printf (_("(Unknown location op)"));
1052 /* No way to tell where the next op is, so just bail. */
1053 return need_frame_base
;
1056 /* Separate the ops. */
1061 return need_frame_base
;
1064 static unsigned char *
1065 read_and_display_attr_value (unsigned long attribute
,
1067 unsigned char * data
,
1068 unsigned long cu_offset
,
1069 unsigned long pointer_size
,
1070 unsigned long offset_size
,
1072 debug_info
* debug_info_p
,
1074 struct dwarf_section
* section
)
1076 unsigned long uvalue
= 0;
1077 unsigned char *block_start
= NULL
;
1078 unsigned char * orig_data
= data
;
1079 unsigned int bytes_read
;
1086 case DW_FORM_ref_addr
:
1087 if (dwarf_version
== 2)
1089 uvalue
= byte_get (data
, pointer_size
);
1090 data
+= pointer_size
;
1092 else if (dwarf_version
== 3 || dwarf_version
== 4)
1094 uvalue
= byte_get (data
, offset_size
);
1095 data
+= offset_size
;
1099 error (_("Internal error: DWARF version is not 2, 3 or 4.\n"));
1104 uvalue
= byte_get (data
, pointer_size
);
1105 data
+= pointer_size
;
1109 case DW_FORM_sec_offset
:
1110 uvalue
= byte_get (data
, offset_size
);
1111 data
+= offset_size
;
1114 case DW_FORM_flag_present
:
1121 uvalue
= byte_get (data
++, 1);
1126 uvalue
= byte_get (data
, 2);
1132 uvalue
= byte_get (data
, 4);
1137 uvalue
= read_leb128 (data
, & bytes_read
, 1);
1141 case DW_FORM_ref_udata
:
1143 uvalue
= read_leb128 (data
, & bytes_read
, 0);
1147 case DW_FORM_indirect
:
1148 form
= read_leb128 (data
, & bytes_read
, 0);
1151 printf (" %s", get_FORM_name (form
));
1152 return read_and_display_attr_value (attribute
, form
, data
,
1153 cu_offset
, pointer_size
,
1154 offset_size
, dwarf_version
,
1155 debug_info_p
, do_loc
,
1161 case DW_FORM_ref_addr
:
1163 printf (" <0x%lx>", uvalue
);
1169 case DW_FORM_ref_udata
:
1171 printf (" <0x%lx>", uvalue
+ cu_offset
);
1176 case DW_FORM_sec_offset
:
1178 printf (" 0x%lx", uvalue
);
1181 case DW_FORM_flag_present
:
1188 printf (" %ld", uvalue
);
1195 uvalue
= byte_get (data
, 4);
1196 printf (" 0x%lx", uvalue
);
1197 printf (" 0x%lx", (unsigned long) byte_get (data
+ 4, 4));
1199 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1200 && num_debug_info_entries
== 0)
1202 if (sizeof (uvalue
) == 8)
1203 uvalue
= byte_get (data
, 8);
1205 error (_("DW_FORM_data8 is unsupported when sizeof (unsigned long) != 8\n"));
1210 case DW_FORM_string
:
1212 printf (" %s", data
);
1213 data
+= strlen ((char *) data
) + 1;
1217 case DW_FORM_exprloc
:
1218 uvalue
= read_leb128 (data
, & bytes_read
, 0);
1219 block_start
= data
+ bytes_read
;
1221 data
= block_start
+ uvalue
;
1223 data
= display_block (block_start
, uvalue
);
1226 case DW_FORM_block1
:
1227 uvalue
= byte_get (data
, 1);
1228 block_start
= data
+ 1;
1230 data
= block_start
+ uvalue
;
1232 data
= display_block (block_start
, uvalue
);
1235 case DW_FORM_block2
:
1236 uvalue
= byte_get (data
, 2);
1237 block_start
= data
+ 2;
1239 data
= block_start
+ uvalue
;
1241 data
= display_block (block_start
, uvalue
);
1244 case DW_FORM_block4
:
1245 uvalue
= byte_get (data
, 4);
1246 block_start
= data
+ 4;
1248 data
= block_start
+ uvalue
;
1250 data
= display_block (block_start
, uvalue
);
1255 printf (_(" (indirect string, offset: 0x%lx): %s"),
1256 uvalue
, fetch_indirect_string (uvalue
));
1259 case DW_FORM_indirect
:
1260 /* Handled above. */
1263 case DW_FORM_ref_sig8
:
1267 printf (" signature: ");
1268 for (i
= 0; i
< 8; i
++)
1270 printf ("%02x", (unsigned) byte_get (data
, 1));
1279 warn (_("Unrecognized form: %lu\n"), form
);
1283 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1284 && num_debug_info_entries
== 0)
1288 case DW_AT_frame_base
:
1289 have_frame_base
= 1;
1290 case DW_AT_location
:
1291 case DW_AT_string_length
:
1292 case DW_AT_return_addr
:
1293 case DW_AT_data_member_location
:
1294 case DW_AT_vtable_elem_location
:
1296 case DW_AT_static_link
:
1297 case DW_AT_use_location
:
1298 if (form
== DW_FORM_data4
1299 || form
== DW_FORM_data8
1300 || form
== DW_FORM_sec_offset
)
1302 /* Process location list. */
1303 unsigned int lmax
= debug_info_p
->max_loc_offsets
;
1304 unsigned int num
= debug_info_p
->num_loc_offsets
;
1306 if (lmax
== 0 || num
>= lmax
)
1309 debug_info_p
->loc_offsets
= (long unsigned int *)
1310 xcrealloc (debug_info_p
->loc_offsets
,
1311 lmax
, sizeof (*debug_info_p
->loc_offsets
));
1312 debug_info_p
->have_frame_base
= (int *)
1313 xcrealloc (debug_info_p
->have_frame_base
,
1314 lmax
, sizeof (*debug_info_p
->have_frame_base
));
1315 debug_info_p
->max_loc_offsets
= lmax
;
1317 debug_info_p
->loc_offsets
[num
] = uvalue
;
1318 debug_info_p
->have_frame_base
[num
] = have_frame_base
;
1319 debug_info_p
->num_loc_offsets
++;
1324 if (need_base_address
)
1325 debug_info_p
->base_address
= uvalue
;
1329 if (form
== DW_FORM_data4
1330 || form
== DW_FORM_data8
1331 || form
== DW_FORM_sec_offset
)
1333 /* Process range list. */
1334 unsigned int lmax
= debug_info_p
->max_range_lists
;
1335 unsigned int num
= debug_info_p
->num_range_lists
;
1337 if (lmax
== 0 || num
>= lmax
)
1340 debug_info_p
->range_lists
= (long unsigned int *)
1341 xcrealloc (debug_info_p
->range_lists
,
1342 lmax
, sizeof (*debug_info_p
->range_lists
));
1343 debug_info_p
->max_range_lists
= lmax
;
1345 debug_info_p
->range_lists
[num
] = uvalue
;
1346 debug_info_p
->num_range_lists
++;
1358 /* For some attributes we can display further information. */
1366 case DW_INL_not_inlined
:
1367 printf (_("(not inlined)"));
1369 case DW_INL_inlined
:
1370 printf (_("(inlined)"));
1372 case DW_INL_declared_not_inlined
:
1373 printf (_("(declared as inline but ignored)"));
1375 case DW_INL_declared_inlined
:
1376 printf (_("(declared as inline and inlined)"));
1379 printf (_(" (Unknown inline attribute value: %lx)"), uvalue
);
1384 case DW_AT_language
:
1387 /* Ordered by the numeric value of these constants. */
1388 case DW_LANG_C89
: printf ("(ANSI C)"); break;
1389 case DW_LANG_C
: printf ("(non-ANSI C)"); break;
1390 case DW_LANG_Ada83
: printf ("(Ada)"); break;
1391 case DW_LANG_C_plus_plus
: printf ("(C++)"); break;
1392 case DW_LANG_Cobol74
: printf ("(Cobol 74)"); break;
1393 case DW_LANG_Cobol85
: printf ("(Cobol 85)"); break;
1394 case DW_LANG_Fortran77
: printf ("(FORTRAN 77)"); break;
1395 case DW_LANG_Fortran90
: printf ("(Fortran 90)"); break;
1396 case DW_LANG_Pascal83
: printf ("(ANSI Pascal)"); break;
1397 case DW_LANG_Modula2
: printf ("(Modula 2)"); break;
1398 /* DWARF 2.1 values. */
1399 case DW_LANG_Java
: printf ("(Java)"); break;
1400 case DW_LANG_C99
: printf ("(ANSI C99)"); break;
1401 case DW_LANG_Ada95
: printf ("(ADA 95)"); break;
1402 case DW_LANG_Fortran95
: printf ("(Fortran 95)"); break;
1403 /* DWARF 3 values. */
1404 case DW_LANG_PLI
: printf ("(PLI)"); break;
1405 case DW_LANG_ObjC
: printf ("(Objective C)"); break;
1406 case DW_LANG_ObjC_plus_plus
: printf ("(Objective C++)"); break;
1407 case DW_LANG_UPC
: printf ("(Unified Parallel C)"); break;
1408 case DW_LANG_D
: printf ("(D)"); break;
1409 /* DWARF 4 values. */
1410 case DW_LANG_Python
: printf ("(Python)"); break;
1411 /* MIPS extension. */
1412 case DW_LANG_Mips_Assembler
: printf ("(MIPS assembler)"); break;
1413 /* UPC extension. */
1414 case DW_LANG_Upc
: printf ("(Unified Parallel C)"); break;
1416 if (uvalue
>= DW_LANG_lo_user
&& uvalue
<= DW_LANG_hi_user
)
1417 printf ("(implementation defined: %lx)", uvalue
);
1419 printf ("(Unknown: %lx)", uvalue
);
1424 case DW_AT_encoding
:
1427 case DW_ATE_void
: printf ("(void)"); break;
1428 case DW_ATE_address
: printf ("(machine address)"); break;
1429 case DW_ATE_boolean
: printf ("(boolean)"); break;
1430 case DW_ATE_complex_float
: printf ("(complex float)"); break;
1431 case DW_ATE_float
: printf ("(float)"); break;
1432 case DW_ATE_signed
: printf ("(signed)"); break;
1433 case DW_ATE_signed_char
: printf ("(signed char)"); break;
1434 case DW_ATE_unsigned
: printf ("(unsigned)"); break;
1435 case DW_ATE_unsigned_char
: printf ("(unsigned char)"); break;
1436 /* DWARF 2.1 values: */
1437 case DW_ATE_imaginary_float
: printf ("(imaginary float)"); break;
1438 case DW_ATE_decimal_float
: printf ("(decimal float)"); break;
1439 /* DWARF 3 values: */
1440 case DW_ATE_packed_decimal
: printf ("(packed_decimal)"); break;
1441 case DW_ATE_numeric_string
: printf ("(numeric_string)"); break;
1442 case DW_ATE_edited
: printf ("(edited)"); break;
1443 case DW_ATE_signed_fixed
: printf ("(signed_fixed)"); break;
1444 case DW_ATE_unsigned_fixed
: printf ("(unsigned_fixed)"); break;
1445 /* HP extensions: */
1446 case DW_ATE_HP_float80
: printf ("(HP_float80)"); break;
1447 case DW_ATE_HP_complex_float80
: printf ("(HP_complex_float80)"); break;
1448 case DW_ATE_HP_float128
: printf ("(HP_float128)"); break;
1449 case DW_ATE_HP_complex_float128
:printf ("(HP_complex_float128)"); break;
1450 case DW_ATE_HP_floathpintel
: printf ("(HP_floathpintel)"); break;
1451 case DW_ATE_HP_imaginary_float80
: printf ("(HP_imaginary_float80)"); break;
1452 case DW_ATE_HP_imaginary_float128
: printf ("(HP_imaginary_float128)"); break;
1455 if (uvalue
>= DW_ATE_lo_user
1456 && uvalue
<= DW_ATE_hi_user
)
1457 printf ("(user defined type)");
1459 printf ("(unknown type)");
1464 case DW_AT_accessibility
:
1467 case DW_ACCESS_public
: printf ("(public)"); break;
1468 case DW_ACCESS_protected
: printf ("(protected)"); break;
1469 case DW_ACCESS_private
: printf ("(private)"); break;
1471 printf ("(unknown accessibility)");
1476 case DW_AT_visibility
:
1479 case DW_VIS_local
: printf ("(local)"); break;
1480 case DW_VIS_exported
: printf ("(exported)"); break;
1481 case DW_VIS_qualified
: printf ("(qualified)"); break;
1482 default: printf ("(unknown visibility)"); break;
1486 case DW_AT_virtuality
:
1489 case DW_VIRTUALITY_none
: printf ("(none)"); break;
1490 case DW_VIRTUALITY_virtual
: printf ("(virtual)"); break;
1491 case DW_VIRTUALITY_pure_virtual
:printf ("(pure_virtual)"); break;
1492 default: printf ("(unknown virtuality)"); break;
1496 case DW_AT_identifier_case
:
1499 case DW_ID_case_sensitive
: printf ("(case_sensitive)"); break;
1500 case DW_ID_up_case
: printf ("(up_case)"); break;
1501 case DW_ID_down_case
: printf ("(down_case)"); break;
1502 case DW_ID_case_insensitive
: printf ("(case_insensitive)"); break;
1503 default: printf ("(unknown case)"); break;
1507 case DW_AT_calling_convention
:
1510 case DW_CC_normal
: printf ("(normal)"); break;
1511 case DW_CC_program
: printf ("(program)"); break;
1512 case DW_CC_nocall
: printf ("(nocall)"); break;
1514 if (uvalue
>= DW_CC_lo_user
1515 && uvalue
<= DW_CC_hi_user
)
1516 printf ("(user defined)");
1518 printf ("(unknown convention)");
1522 case DW_AT_ordering
:
1525 case -1: printf ("(undefined)"); break;
1526 case 0: printf ("(row major)"); break;
1527 case 1: printf ("(column major)"); break;
1531 case DW_AT_frame_base
:
1532 have_frame_base
= 1;
1533 case DW_AT_location
:
1534 case DW_AT_string_length
:
1535 case DW_AT_return_addr
:
1536 case DW_AT_data_member_location
:
1537 case DW_AT_vtable_elem_location
:
1539 case DW_AT_static_link
:
1540 case DW_AT_use_location
:
1541 if (form
== DW_FORM_data4
1542 || form
== DW_FORM_data8
1543 || form
== DW_FORM_sec_offset
)
1544 printf (_("(location list)"));
1546 case DW_AT_allocated
:
1547 case DW_AT_associated
:
1548 case DW_AT_data_location
:
1550 case DW_AT_upper_bound
:
1551 case DW_AT_lower_bound
:
1554 int need_frame_base
;
1557 need_frame_base
= decode_location_expression (block_start
,
1562 cu_offset
, section
);
1564 if (need_frame_base
&& !have_frame_base
)
1565 printf (_(" [without DW_AT_frame_base]"));
1571 if (form
== DW_FORM_ref_sig8
)
1574 if (form
== DW_FORM_ref1
1575 || form
== DW_FORM_ref2
1576 || form
== DW_FORM_ref4
)
1577 uvalue
+= cu_offset
;
1579 if (uvalue
>= section
->size
)
1580 warn (_("Offset %lx used as value for DW_AT_import attribute of DIE at offset %lx is too big.\n"),
1581 uvalue
, (unsigned long) (orig_data
- section
->start
));
1584 unsigned long abbrev_number
;
1585 abbrev_entry
* entry
;
1587 abbrev_number
= read_leb128 (section
->start
+ uvalue
, NULL
, 0);
1589 printf ("[Abbrev Number: %ld", abbrev_number
);
1590 for (entry
= first_abbrev
; entry
!= NULL
; entry
= entry
->next
)
1591 if (entry
->entry
== abbrev_number
)
1594 printf (" (%s)", get_TAG_name (entry
->tag
));
1608 get_AT_name (unsigned long attribute
)
1612 case DW_AT_sibling
: return "DW_AT_sibling";
1613 case DW_AT_location
: return "DW_AT_location";
1614 case DW_AT_name
: return "DW_AT_name";
1615 case DW_AT_ordering
: return "DW_AT_ordering";
1616 case DW_AT_subscr_data
: return "DW_AT_subscr_data";
1617 case DW_AT_byte_size
: return "DW_AT_byte_size";
1618 case DW_AT_bit_offset
: return "DW_AT_bit_offset";
1619 case DW_AT_bit_size
: return "DW_AT_bit_size";
1620 case DW_AT_element_list
: return "DW_AT_element_list";
1621 case DW_AT_stmt_list
: return "DW_AT_stmt_list";
1622 case DW_AT_low_pc
: return "DW_AT_low_pc";
1623 case DW_AT_high_pc
: return "DW_AT_high_pc";
1624 case DW_AT_language
: return "DW_AT_language";
1625 case DW_AT_member
: return "DW_AT_member";
1626 case DW_AT_discr
: return "DW_AT_discr";
1627 case DW_AT_discr_value
: return "DW_AT_discr_value";
1628 case DW_AT_visibility
: return "DW_AT_visibility";
1629 case DW_AT_import
: return "DW_AT_import";
1630 case DW_AT_string_length
: return "DW_AT_string_length";
1631 case DW_AT_common_reference
: return "DW_AT_common_reference";
1632 case DW_AT_comp_dir
: return "DW_AT_comp_dir";
1633 case DW_AT_const_value
: return "DW_AT_const_value";
1634 case DW_AT_containing_type
: return "DW_AT_containing_type";
1635 case DW_AT_default_value
: return "DW_AT_default_value";
1636 case DW_AT_inline
: return "DW_AT_inline";
1637 case DW_AT_is_optional
: return "DW_AT_is_optional";
1638 case DW_AT_lower_bound
: return "DW_AT_lower_bound";
1639 case DW_AT_producer
: return "DW_AT_producer";
1640 case DW_AT_prototyped
: return "DW_AT_prototyped";
1641 case DW_AT_return_addr
: return "DW_AT_return_addr";
1642 case DW_AT_start_scope
: return "DW_AT_start_scope";
1643 case DW_AT_stride_size
: return "DW_AT_stride_size";
1644 case DW_AT_upper_bound
: return "DW_AT_upper_bound";
1645 case DW_AT_abstract_origin
: return "DW_AT_abstract_origin";
1646 case DW_AT_accessibility
: return "DW_AT_accessibility";
1647 case DW_AT_address_class
: return "DW_AT_address_class";
1648 case DW_AT_artificial
: return "DW_AT_artificial";
1649 case DW_AT_base_types
: return "DW_AT_base_types";
1650 case DW_AT_calling_convention
: return "DW_AT_calling_convention";
1651 case DW_AT_count
: return "DW_AT_count";
1652 case DW_AT_data_member_location
: return "DW_AT_data_member_location";
1653 case DW_AT_decl_column
: return "DW_AT_decl_column";
1654 case DW_AT_decl_file
: return "DW_AT_decl_file";
1655 case DW_AT_decl_line
: return "DW_AT_decl_line";
1656 case DW_AT_declaration
: return "DW_AT_declaration";
1657 case DW_AT_discr_list
: return "DW_AT_discr_list";
1658 case DW_AT_encoding
: return "DW_AT_encoding";
1659 case DW_AT_external
: return "DW_AT_external";
1660 case DW_AT_frame_base
: return "DW_AT_frame_base";
1661 case DW_AT_friend
: return "DW_AT_friend";
1662 case DW_AT_identifier_case
: return "DW_AT_identifier_case";
1663 case DW_AT_macro_info
: return "DW_AT_macro_info";
1664 case DW_AT_namelist_items
: return "DW_AT_namelist_items";
1665 case DW_AT_priority
: return "DW_AT_priority";
1666 case DW_AT_segment
: return "DW_AT_segment";
1667 case DW_AT_specification
: return "DW_AT_specification";
1668 case DW_AT_static_link
: return "DW_AT_static_link";
1669 case DW_AT_type
: return "DW_AT_type";
1670 case DW_AT_use_location
: return "DW_AT_use_location";
1671 case DW_AT_variable_parameter
: return "DW_AT_variable_parameter";
1672 case DW_AT_virtuality
: return "DW_AT_virtuality";
1673 case DW_AT_vtable_elem_location
: return "DW_AT_vtable_elem_location";
1674 /* DWARF 2.1 values. */
1675 case DW_AT_allocated
: return "DW_AT_allocated";
1676 case DW_AT_associated
: return "DW_AT_associated";
1677 case DW_AT_data_location
: return "DW_AT_data_location";
1678 case DW_AT_stride
: return "DW_AT_stride";
1679 case DW_AT_entry_pc
: return "DW_AT_entry_pc";
1680 case DW_AT_use_UTF8
: return "DW_AT_use_UTF8";
1681 case DW_AT_extension
: return "DW_AT_extension";
1682 case DW_AT_ranges
: return "DW_AT_ranges";
1683 case DW_AT_trampoline
: return "DW_AT_trampoline";
1684 case DW_AT_call_column
: return "DW_AT_call_column";
1685 case DW_AT_call_file
: return "DW_AT_call_file";
1686 case DW_AT_call_line
: return "DW_AT_call_line";
1687 case DW_AT_description
: return "DW_AT_description";
1688 case DW_AT_binary_scale
: return "DW_AT_binary_scale";
1689 case DW_AT_decimal_scale
: return "DW_AT_decimal_scale";
1690 case DW_AT_small
: return "DW_AT_small";
1691 case DW_AT_decimal_sign
: return "DW_AT_decimal_sign";
1692 case DW_AT_digit_count
: return "DW_AT_digit_count";
1693 case DW_AT_picture_string
: return "DW_AT_picture_string";
1694 case DW_AT_mutable
: return "DW_AT_mutable";
1695 case DW_AT_threads_scaled
: return "DW_AT_threads_scaled";
1696 case DW_AT_explicit
: return "DW_AT_explicit";
1697 case DW_AT_object_pointer
: return "DW_AT_object_pointer";
1698 case DW_AT_endianity
: return "DW_AT_endianity";
1699 case DW_AT_elemental
: return "DW_AT_elemental";
1700 case DW_AT_pure
: return "DW_AT_pure";
1701 case DW_AT_recursive
: return "DW_AT_recursive";
1702 /* DWARF 4 values. */
1703 case DW_AT_signature
: return "DW_AT_signature";
1704 case DW_AT_main_subprogram
: return "DW_AT_main_subprogram";
1705 case DW_AT_data_bit_offset
: return "DW_AT_data_bit_offset";
1706 case DW_AT_const_expr
: return "DW_AT_const_expr";
1707 case DW_AT_enum_class
: return "DW_AT_enum_class";
1708 case DW_AT_linkage_name
: return "DW_AT_linkage_name";
1710 /* HP and SGI/MIPS extensions. */
1711 case DW_AT_MIPS_loop_begin
: return "DW_AT_MIPS_loop_begin";
1712 case DW_AT_MIPS_tail_loop_begin
: return "DW_AT_MIPS_tail_loop_begin";
1713 case DW_AT_MIPS_epilog_begin
: return "DW_AT_MIPS_epilog_begin";
1714 case DW_AT_MIPS_loop_unroll_factor
: return "DW_AT_MIPS_loop_unroll_factor";
1715 case DW_AT_MIPS_software_pipeline_depth
: return "DW_AT_MIPS_software_pipeline_depth";
1716 case DW_AT_MIPS_linkage_name
: return "DW_AT_MIPS_linkage_name";
1717 case DW_AT_MIPS_stride
: return "DW_AT_MIPS_stride";
1718 case DW_AT_MIPS_abstract_name
: return "DW_AT_MIPS_abstract_name";
1719 case DW_AT_MIPS_clone_origin
: return "DW_AT_MIPS_clone_origin";
1720 case DW_AT_MIPS_has_inlines
: return "DW_AT_MIPS_has_inlines";
1722 /* HP Extensions. */
1723 case DW_AT_HP_block_index
: return "DW_AT_HP_block_index";
1724 case DW_AT_HP_actuals_stmt_list
: return "DW_AT_HP_actuals_stmt_list";
1725 case DW_AT_HP_proc_per_section
: return "DW_AT_HP_proc_per_section";
1726 case DW_AT_HP_raw_data_ptr
: return "DW_AT_HP_raw_data_ptr";
1727 case DW_AT_HP_pass_by_reference
: return "DW_AT_HP_pass_by_reference";
1728 case DW_AT_HP_opt_level
: return "DW_AT_HP_opt_level";
1729 case DW_AT_HP_prof_version_id
: return "DW_AT_HP_prof_version_id";
1730 case DW_AT_HP_opt_flags
: return "DW_AT_HP_opt_flags";
1731 case DW_AT_HP_cold_region_low_pc
: return "DW_AT_HP_cold_region_low_pc";
1732 case DW_AT_HP_cold_region_high_pc
: return "DW_AT_HP_cold_region_high_pc";
1733 case DW_AT_HP_all_variables_modifiable
: return "DW_AT_HP_all_variables_modifiable";
1734 case DW_AT_HP_linkage_name
: return "DW_AT_HP_linkage_name";
1735 case DW_AT_HP_prof_flags
: return "DW_AT_HP_prof_flags";
1737 /* One value is shared by the MIPS and HP extensions: */
1738 case DW_AT_MIPS_fde
: return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable";
1740 /* GNU extensions. */
1741 case DW_AT_sf_names
: return "DW_AT_sf_names";
1742 case DW_AT_src_info
: return "DW_AT_src_info";
1743 case DW_AT_mac_info
: return "DW_AT_mac_info";
1744 case DW_AT_src_coords
: return "DW_AT_src_coords";
1745 case DW_AT_body_begin
: return "DW_AT_body_begin";
1746 case DW_AT_body_end
: return "DW_AT_body_end";
1747 case DW_AT_GNU_vector
: return "DW_AT_GNU_vector";
1748 case DW_AT_GNU_guarded_by
: return "DW_AT_GNU_guarded_by";
1749 case DW_AT_GNU_pt_guarded_by
: return "DW_AT_GNU_pt_guarded_by";
1750 case DW_AT_GNU_guarded
: return "DW_AT_GNU_guarded";
1751 case DW_AT_GNU_pt_guarded
: return "DW_AT_GNU_pt_guarded";
1752 case DW_AT_GNU_locks_excluded
: return "DW_AT_GNU_locks_excluded";
1753 case DW_AT_GNU_exclusive_locks_required
: return "DW_AT_GNU_exclusive_locks_required";
1754 case DW_AT_GNU_shared_locks_required
: return "DW_AT_GNU_shared_locks_required";
1755 case DW_AT_GNU_odr_signature
: return "DW_AT_GNU_odr_signature";
1756 case DW_AT_use_GNAT_descriptive_type
: return "DW_AT_use_GNAT_descriptive_type";
1757 case DW_AT_GNAT_descriptive_type
: return "DW_AT_GNAT_descriptive_type";
1759 /* UPC extension. */
1760 case DW_AT_upc_threads_scaled
: return "DW_AT_upc_threads_scaled";
1762 /* PGI (STMicroelectronics) extensions. */
1763 case DW_AT_PGI_lbase
: return "DW_AT_PGI_lbase";
1764 case DW_AT_PGI_soffset
: return "DW_AT_PGI_soffset";
1765 case DW_AT_PGI_lstride
: return "DW_AT_PGI_lstride";
1769 static char buffer
[100];
1771 snprintf (buffer
, sizeof (buffer
), _("Unknown AT value: %lx"),
1778 static unsigned char *
1779 read_and_display_attr (unsigned long attribute
,
1781 unsigned char * data
,
1782 unsigned long cu_offset
,
1783 unsigned long pointer_size
,
1784 unsigned long offset_size
,
1786 debug_info
* debug_info_p
,
1788 struct dwarf_section
* section
)
1791 printf (" %-18s:", get_AT_name (attribute
));
1792 data
= read_and_display_attr_value (attribute
, form
, data
, cu_offset
,
1793 pointer_size
, offset_size
,
1794 dwarf_version
, debug_info_p
,
1802 /* Process the contents of a .debug_info section. If do_loc is non-zero
1803 then we are scanning for location lists and we do not want to display
1804 anything to the user. If do_types is non-zero, we are processing
1805 a .debug_types section instead of a .debug_info section. */
1808 process_debug_info (struct dwarf_section
*section
,
1810 enum dwarf_section_display_enum abbrev_sec
,
1814 unsigned char *start
= section
->start
;
1815 unsigned char *end
= start
+ section
->size
;
1816 unsigned char *section_begin
;
1818 unsigned int num_units
= 0;
1820 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1821 && num_debug_info_entries
== 0
1824 unsigned long length
;
1826 /* First scan the section to get the number of comp units. */
1827 for (section_begin
= start
, num_units
= 0; section_begin
< end
;
1830 /* Read the first 4 bytes. For a 32-bit DWARF section, this
1831 will be the length. For a 64-bit DWARF section, it'll be
1832 the escape code 0xffffffff followed by an 8 byte length. */
1833 length
= byte_get (section_begin
, 4);
1835 if (length
== 0xffffffff)
1837 length
= byte_get (section_begin
+ 4, 8);
1838 section_begin
+= length
+ 12;
1840 else if (length
>= 0xfffffff0 && length
< 0xffffffff)
1842 warn (_("Reserved length value (%lx) found in section %s\n"), length
, section
->name
);
1846 section_begin
+= length
+ 4;
1848 /* Negative values are illegal, they may even cause infinite
1849 looping. This can happen if we can't accurately apply
1850 relocations to an object file. */
1851 if ((signed long) length
<= 0)
1853 warn (_("Corrupt unit length (%lx) found in section %s\n"), length
, section
->name
);
1860 error (_("No comp units in %s section ?"), section
->name
);
1864 /* Then allocate an array to hold the information. */
1865 debug_information
= (debug_info
*) cmalloc (num_units
,
1866 sizeof (* debug_information
));
1867 if (debug_information
== NULL
)
1869 error (_("Not enough memory for a debug info array of %u entries"),
1877 printf (_("Contents of the %s section:\n\n"), section
->name
);
1879 load_debug_section (str
, file
);
1882 load_debug_section (abbrev_sec
, file
);
1883 if (debug_displays
[abbrev_sec
].section
.start
== NULL
)
1885 warn (_("Unable to locate %s section!\n"),
1886 debug_displays
[abbrev_sec
].section
.name
);
1890 for (section_begin
= start
, unit
= 0; start
< end
; unit
++)
1892 DWARF2_Internal_CompUnit compunit
;
1893 unsigned char *hdrptr
;
1894 unsigned char *tags
;
1896 unsigned long cu_offset
;
1898 int initial_length_size
;
1899 unsigned char signature
[8] = { 0 };
1900 unsigned long type_offset
= 0;
1904 compunit
.cu_length
= byte_get (hdrptr
, 4);
1907 if (compunit
.cu_length
== 0xffffffff)
1909 compunit
.cu_length
= byte_get (hdrptr
, 8);
1912 initial_length_size
= 12;
1917 initial_length_size
= 4;
1920 compunit
.cu_version
= byte_get (hdrptr
, 2);
1923 cu_offset
= start
- section_begin
;
1925 compunit
.cu_abbrev_offset
= byte_get (hdrptr
, offset_size
);
1926 hdrptr
+= offset_size
;
1928 compunit
.cu_pointer_size
= byte_get (hdrptr
, 1);
1935 for (i
= 0; i
< 8; i
++)
1937 signature
[i
] = byte_get (hdrptr
, 1);
1941 type_offset
= byte_get (hdrptr
, offset_size
);
1942 hdrptr
+= offset_size
;
1945 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
1946 && num_debug_info_entries
== 0
1949 debug_information
[unit
].cu_offset
= cu_offset
;
1950 debug_information
[unit
].pointer_size
1951 = compunit
.cu_pointer_size
;
1952 debug_information
[unit
].offset_size
= offset_size
;
1953 debug_information
[unit
].dwarf_version
= compunit
.cu_version
;
1954 debug_information
[unit
].base_address
= 0;
1955 debug_information
[unit
].loc_offsets
= NULL
;
1956 debug_information
[unit
].have_frame_base
= NULL
;
1957 debug_information
[unit
].max_loc_offsets
= 0;
1958 debug_information
[unit
].num_loc_offsets
= 0;
1959 debug_information
[unit
].range_lists
= NULL
;
1960 debug_information
[unit
].max_range_lists
= 0;
1961 debug_information
[unit
].num_range_lists
= 0;
1966 printf (_(" Compilation Unit @ offset 0x%lx:\n"), cu_offset
);
1967 printf (_(" Length: 0x%lx (%s)\n"), compunit
.cu_length
,
1968 initial_length_size
== 8 ? "64-bit" : "32-bit");
1969 printf (_(" Version: %d\n"), compunit
.cu_version
);
1970 printf (_(" Abbrev Offset: %ld\n"), compunit
.cu_abbrev_offset
);
1971 printf (_(" Pointer Size: %d\n"), compunit
.cu_pointer_size
);
1975 printf (_(" Signature: "));
1976 for (i
= 0; i
< 8; i
++)
1977 printf ("%02x", signature
[i
]);
1979 printf (_(" Type Offset: 0x%lx\n"), type_offset
);
1983 if (cu_offset
+ compunit
.cu_length
+ initial_length_size
1986 warn (_("Debug info is corrupted, length of CU at %lx extends beyond end of section (length = %lx)\n"),
1987 cu_offset
, compunit
.cu_length
);
1991 start
+= compunit
.cu_length
+ initial_length_size
;
1993 if (compunit
.cu_version
!= 2
1994 && compunit
.cu_version
!= 3
1995 && compunit
.cu_version
!= 4)
1997 warn (_("CU at offset %lx contains corrupt or unsupported version number: %d.\n"),
1998 cu_offset
, compunit
.cu_version
);
2004 /* Process the abbrevs used by this compilation unit. DWARF
2005 sections under Mach-O have non-zero addresses. */
2006 if (compunit
.cu_abbrev_offset
>= debug_displays
[abbrev_sec
].section
.size
)
2007 warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"),
2008 (unsigned long) compunit
.cu_abbrev_offset
,
2009 (unsigned long) debug_displays
[abbrev_sec
].section
.size
);
2011 process_abbrev_section
2012 ((unsigned char *) debug_displays
[abbrev_sec
].section
.start
2013 + compunit
.cu_abbrev_offset
,
2014 (unsigned char *) debug_displays
[abbrev_sec
].section
.start
2015 + debug_displays
[abbrev_sec
].section
.size
);
2018 while (tags
< start
)
2020 unsigned int bytes_read
;
2021 unsigned long abbrev_number
;
2022 unsigned long die_offset
;
2023 abbrev_entry
*entry
;
2026 die_offset
= tags
- section_begin
;
2028 abbrev_number
= read_leb128 (tags
, & bytes_read
, 0);
2031 /* A null DIE marks the end of a list of siblings or it may also be
2032 a section padding. */
2033 if (abbrev_number
== 0)
2035 /* Check if it can be a section padding for the last CU. */
2036 if (level
== 0 && start
== end
)
2040 for (chk
= tags
; chk
< start
; chk
++)
2050 static unsigned num_bogus_warns
= 0;
2052 if (num_bogus_warns
< 3)
2054 warn (_("Bogus end-of-siblings marker detected at offset %lx in .debug_info section\n"),
2057 if (num_bogus_warns
== 3)
2058 warn (_("Further warnings about bogus end-of-sibling markers suppressed\n"));
2065 printf (_(" <%d><%lx>: Abbrev Number: %lu"),
2066 level
, die_offset
, abbrev_number
);
2068 /* Scan through the abbreviation list until we reach the
2070 for (entry
= first_abbrev
;
2071 entry
&& entry
->entry
!= abbrev_number
;
2072 entry
= entry
->next
)
2082 warn (_("DIE at offset %lx refers to abbreviation number %lu which does not exist\n"),
2083 die_offset
, abbrev_number
);
2088 printf (" (%s)\n", get_TAG_name (entry
->tag
));
2093 need_base_address
= 0;
2095 case DW_TAG_compile_unit
:
2096 need_base_address
= 1;
2098 case DW_TAG_entry_point
:
2099 case DW_TAG_subprogram
:
2100 need_base_address
= 0;
2101 /* Assuming that there is no DW_AT_frame_base. */
2102 have_frame_base
= 0;
2106 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
2109 /* Show the offset from where the tag was extracted. */
2110 printf (" <%2lx>", (unsigned long)(tags
- section_begin
));
2112 tags
= read_and_display_attr (attr
->attribute
,
2115 compunit
.cu_pointer_size
,
2117 compunit
.cu_version
,
2118 debug_information
+ unit
,
2122 if (entry
->children
)
2127 /* Set num_debug_info_entries here so that it can be used to check if
2128 we need to process .debug_loc and .debug_ranges sections. */
2129 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2130 && num_debug_info_entries
== 0
2132 num_debug_info_entries
= num_units
;
2142 /* Locate and scan the .debug_info section in the file and record the pointer
2143 sizes and offsets for the compilation units in it. Usually an executable
2144 will have just one pointer size, but this is not guaranteed, and so we try
2145 not to make any assumptions. Returns zero upon failure, or the number of
2146 compilation units upon success. */
2149 load_debug_info (void * file
)
2151 /* Reset the last pointer size so that we can issue correct error
2152 messages if we are displaying the contents of more than one section. */
2153 last_pointer_size
= 0;
2154 warned_about_missing_comp_units
= FALSE
;
2156 /* If we have already tried and failed to load the .debug_info
2157 section then do not bother to repear the task. */
2158 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
2161 /* If we already have the information there is nothing else to do. */
2162 if (num_debug_info_entries
> 0)
2163 return num_debug_info_entries
;
2165 if (load_debug_section (info
, file
)
2166 && process_debug_info (&debug_displays
[info
].section
, file
, abbrev
, 1, 0))
2167 return num_debug_info_entries
;
2169 num_debug_info_entries
= DEBUG_INFO_UNAVAILABLE
;
2174 display_debug_lines_raw (struct dwarf_section
*section
,
2175 unsigned char *data
,
2178 unsigned char *start
= section
->start
;
2180 printf (_("Raw dump of debug contents of section %s:\n\n"),
2185 DWARF2_Internal_LineInfo linfo
;
2186 unsigned char *standard_opcodes
;
2187 unsigned char *end_of_sequence
;
2188 unsigned char *hdrptr
;
2189 unsigned long hdroff
;
2190 int initial_length_size
;
2195 hdroff
= hdrptr
- start
;
2197 /* Check the length of the block. */
2198 linfo
.li_length
= byte_get (hdrptr
, 4);
2201 if (linfo
.li_length
== 0xffffffff)
2203 /* This section is 64-bit DWARF 3. */
2204 linfo
.li_length
= byte_get (hdrptr
, 8);
2207 initial_length_size
= 12;
2212 initial_length_size
= 4;
2215 if (linfo
.li_length
+ initial_length_size
> section
->size
)
2218 (_("The information in section %s appears to be corrupt - the section is too small\n"),
2223 /* Check its version number. */
2224 linfo
.li_version
= byte_get (hdrptr
, 2);
2226 if (linfo
.li_version
!= 2
2227 && linfo
.li_version
!= 3
2228 && linfo
.li_version
!= 4)
2230 warn (_("Only DWARF version 2, 3 and 4 line info is currently supported.\n"));
2234 linfo
.li_prologue_length
= byte_get (hdrptr
, offset_size
);
2235 hdrptr
+= offset_size
;
2236 linfo
.li_min_insn_length
= byte_get (hdrptr
, 1);
2238 if (linfo
.li_version
>= 4)
2240 linfo
.li_max_ops_per_insn
= byte_get (hdrptr
, 1);
2242 if (linfo
.li_max_ops_per_insn
== 0)
2244 warn (_("Invalid maximum operations per insn.\n"));
2249 linfo
.li_max_ops_per_insn
= 1;
2250 linfo
.li_default_is_stmt
= byte_get (hdrptr
, 1);
2252 linfo
.li_line_base
= byte_get (hdrptr
, 1);
2254 linfo
.li_line_range
= byte_get (hdrptr
, 1);
2256 linfo
.li_opcode_base
= byte_get (hdrptr
, 1);
2259 /* Sign extend the line base field. */
2260 linfo
.li_line_base
<<= 24;
2261 linfo
.li_line_base
>>= 24;
2263 printf (_(" Offset: 0x%lx\n"), hdroff
);
2264 printf (_(" Length: %ld\n"), linfo
.li_length
);
2265 printf (_(" DWARF Version: %d\n"), linfo
.li_version
);
2266 printf (_(" Prologue Length: %d\n"), linfo
.li_prologue_length
);
2267 printf (_(" Minimum Instruction Length: %d\n"), linfo
.li_min_insn_length
);
2268 if (linfo
.li_version
>= 4)
2269 printf (_(" Maximum Ops per Instruction: %d\n"), linfo
.li_max_ops_per_insn
);
2270 printf (_(" Initial value of 'is_stmt': %d\n"), linfo
.li_default_is_stmt
);
2271 printf (_(" Line Base: %d\n"), linfo
.li_line_base
);
2272 printf (_(" Line Range: %d\n"), linfo
.li_line_range
);
2273 printf (_(" Opcode Base: %d\n"), linfo
.li_opcode_base
);
2275 end_of_sequence
= data
+ linfo
.li_length
+ initial_length_size
;
2277 reset_state_machine (linfo
.li_default_is_stmt
);
2279 /* Display the contents of the Opcodes table. */
2280 standard_opcodes
= hdrptr
;
2282 printf (_("\n Opcodes:\n"));
2284 for (i
= 1; i
< linfo
.li_opcode_base
; i
++)
2285 printf (_(" Opcode %d has %d args\n"), i
, standard_opcodes
[i
- 1]);
2287 /* Display the contents of the Directory table. */
2288 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
2291 printf (_("\n The Directory Table is empty.\n"));
2294 printf (_("\n The Directory Table:\n"));
2298 printf (" %s\n", data
);
2300 data
+= strlen ((char *) data
) + 1;
2304 /* Skip the NUL at the end of the table. */
2307 /* Display the contents of the File Name table. */
2309 printf (_("\n The File Name Table is empty.\n"));
2312 printf (_("\n The File Name Table:\n"));
2313 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
2317 unsigned char *name
;
2318 unsigned int bytes_read
;
2320 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
2323 data
+= strlen ((char *) data
) + 1;
2325 printf ("%lu\t", read_leb128 (data
, & bytes_read
, 0));
2327 printf ("%lu\t", read_leb128 (data
, & bytes_read
, 0));
2329 printf ("%lu\t", read_leb128 (data
, & bytes_read
, 0));
2331 printf ("%s\n", name
);
2335 /* Skip the NUL at the end of the table. */
2338 /* Now display the statements. */
2339 printf (_("\n Line Number Statements:\n"));
2341 while (data
< end_of_sequence
)
2343 unsigned char op_code
;
2345 unsigned long int uladv
;
2346 unsigned int bytes_read
;
2350 if (op_code
>= linfo
.li_opcode_base
)
2352 op_code
-= linfo
.li_opcode_base
;
2353 uladv
= (op_code
/ linfo
.li_line_range
);
2354 if (linfo
.li_max_ops_per_insn
== 1)
2356 uladv
*= linfo
.li_min_insn_length
;
2357 state_machine_regs
.address
+= uladv
;
2358 printf (_(" Special opcode %d: advance Address by %lu to 0x%lx"),
2359 op_code
, uladv
, state_machine_regs
.address
);
2363 state_machine_regs
.address
2364 += ((state_machine_regs
.op_index
+ uladv
)
2365 / linfo
.li_max_ops_per_insn
)
2366 * linfo
.li_min_insn_length
;
2367 state_machine_regs
.op_index
2368 = (state_machine_regs
.op_index
+ uladv
)
2369 % linfo
.li_max_ops_per_insn
;
2370 printf (_(" Special opcode %d: advance Address by %lu to 0x%lx[%d]"),
2371 op_code
, uladv
, state_machine_regs
.address
,
2372 state_machine_regs
.op_index
);
2374 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
2375 state_machine_regs
.line
+= adv
;
2376 printf (_(" and Line by %d to %d\n"),
2377 adv
, state_machine_regs
.line
);
2379 else switch (op_code
)
2381 case DW_LNS_extended_op
:
2382 data
+= process_extended_line_op (data
, linfo
.li_default_is_stmt
);
2386 printf (_(" Copy\n"));
2389 case DW_LNS_advance_pc
:
2390 uladv
= read_leb128 (data
, & bytes_read
, 0);
2392 if (linfo
.li_max_ops_per_insn
== 1)
2394 uladv
*= linfo
.li_min_insn_length
;
2395 state_machine_regs
.address
+= uladv
;
2396 printf (_(" Advance PC by %lu to 0x%lx\n"), uladv
,
2397 state_machine_regs
.address
);
2401 state_machine_regs
.address
2402 += ((state_machine_regs
.op_index
+ uladv
)
2403 / linfo
.li_max_ops_per_insn
)
2404 * linfo
.li_min_insn_length
;
2405 state_machine_regs
.op_index
2406 = (state_machine_regs
.op_index
+ uladv
)
2407 % linfo
.li_max_ops_per_insn
;
2408 printf (_(" Advance PC by %lu to 0x%lx[%d]\n"), uladv
,
2409 state_machine_regs
.address
,
2410 state_machine_regs
.op_index
);
2414 case DW_LNS_advance_line
:
2415 adv
= read_leb128 (data
, & bytes_read
, 1);
2417 state_machine_regs
.line
+= adv
;
2418 printf (_(" Advance Line by %d to %d\n"), adv
,
2419 state_machine_regs
.line
);
2422 case DW_LNS_set_file
:
2423 adv
= read_leb128 (data
, & bytes_read
, 0);
2425 printf (_(" Set File Name to entry %d in the File Name Table\n"),
2427 state_machine_regs
.file
= adv
;
2430 case DW_LNS_set_column
:
2431 uladv
= read_leb128 (data
, & bytes_read
, 0);
2433 printf (_(" Set column to %lu\n"), uladv
);
2434 state_machine_regs
.column
= uladv
;
2437 case DW_LNS_negate_stmt
:
2438 adv
= state_machine_regs
.is_stmt
;
2440 printf (_(" Set is_stmt to %d\n"), adv
);
2441 state_machine_regs
.is_stmt
= adv
;
2444 case DW_LNS_set_basic_block
:
2445 printf (_(" Set basic block\n"));
2446 state_machine_regs
.basic_block
= 1;
2449 case DW_LNS_const_add_pc
:
2450 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
2451 if (linfo
.li_max_ops_per_insn
)
2453 uladv
*= linfo
.li_min_insn_length
;
2454 state_machine_regs
.address
+= uladv
;
2455 printf (_(" Advance PC by constant %lu to 0x%lx\n"), uladv
,
2456 state_machine_regs
.address
);
2460 state_machine_regs
.address
2461 += ((state_machine_regs
.op_index
+ uladv
)
2462 / linfo
.li_max_ops_per_insn
)
2463 * linfo
.li_min_insn_length
;
2464 state_machine_regs
.op_index
2465 = (state_machine_regs
.op_index
+ uladv
)
2466 % linfo
.li_max_ops_per_insn
;
2467 printf (_(" Advance PC by constant %lu to 0x%lx[%d]\n"),
2468 uladv
, state_machine_regs
.address
,
2469 state_machine_regs
.op_index
);
2473 case DW_LNS_fixed_advance_pc
:
2474 uladv
= byte_get (data
, 2);
2476 state_machine_regs
.address
+= uladv
;
2477 state_machine_regs
.op_index
= 0;
2478 printf (_(" Advance PC by fixed size amount %lu to 0x%lx\n"),
2479 uladv
, state_machine_regs
.address
);
2482 case DW_LNS_set_prologue_end
:
2483 printf (_(" Set prologue_end to true\n"));
2486 case DW_LNS_set_epilogue_begin
:
2487 printf (_(" Set epilogue_begin to true\n"));
2490 case DW_LNS_set_isa
:
2491 uladv
= read_leb128 (data
, & bytes_read
, 0);
2493 printf (_(" Set ISA to %lu\n"), uladv
);
2497 printf (_(" Unknown opcode %d with operands: "), op_code
);
2499 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
2501 printf ("0x%lx%s", read_leb128 (data
, &bytes_read
, 0),
2502 i
== 1 ? "" : ", ");
2517 unsigned char *name
;
2518 unsigned int directory_index
;
2519 unsigned int modification_date
;
2520 unsigned int length
;
2523 /* Output a decoded representation of the .debug_line section. */
2526 display_debug_lines_decoded (struct dwarf_section
*section
,
2527 unsigned char *data
,
2530 printf (_("Decoded dump of debug contents of section %s:\n\n"),
2535 /* This loop amounts to one iteration per compilation unit. */
2536 DWARF2_Internal_LineInfo linfo
;
2537 unsigned char *standard_opcodes
;
2538 unsigned char *end_of_sequence
;
2539 unsigned char *hdrptr
;
2540 int initial_length_size
;
2543 File_Entry
*file_table
= NULL
;
2544 unsigned char **directory_table
= NULL
;
2548 /* Extract information from the Line Number Program Header.
2549 (section 6.2.4 in the Dwarf3 doc). */
2551 /* Get the length of this CU's line number information block. */
2552 linfo
.li_length
= byte_get (hdrptr
, 4);
2555 if (linfo
.li_length
== 0xffffffff)
2557 /* This section is 64-bit DWARF 3. */
2558 linfo
.li_length
= byte_get (hdrptr
, 8);
2561 initial_length_size
= 12;
2566 initial_length_size
= 4;
2569 if (linfo
.li_length
+ initial_length_size
> section
->size
)
2571 warn (_("The line info appears to be corrupt - "
2572 "the section is too small\n"));
2576 /* Get this CU's Line Number Block version number. */
2577 linfo
.li_version
= byte_get (hdrptr
, 2);
2579 if (linfo
.li_version
!= 2
2580 && linfo
.li_version
!= 3
2581 && linfo
.li_version
!= 4)
2583 warn (_("Only DWARF version 2, 3 and 4 line info is currently "
2588 linfo
.li_prologue_length
= byte_get (hdrptr
, offset_size
);
2589 hdrptr
+= offset_size
;
2590 linfo
.li_min_insn_length
= byte_get (hdrptr
, 1);
2592 if (linfo
.li_version
>= 4)
2594 linfo
.li_max_ops_per_insn
= byte_get (hdrptr
, 1);
2596 if (linfo
.li_max_ops_per_insn
== 0)
2598 warn (_("Invalid maximum operations per insn.\n"));
2603 linfo
.li_max_ops_per_insn
= 1;
2604 linfo
.li_default_is_stmt
= byte_get (hdrptr
, 1);
2606 linfo
.li_line_base
= byte_get (hdrptr
, 1);
2608 linfo
.li_line_range
= byte_get (hdrptr
, 1);
2610 linfo
.li_opcode_base
= byte_get (hdrptr
, 1);
2613 /* Sign extend the line base field. */
2614 linfo
.li_line_base
<<= 24;
2615 linfo
.li_line_base
>>= 24;
2617 /* Find the end of this CU's Line Number Information Block. */
2618 end_of_sequence
= data
+ linfo
.li_length
+ initial_length_size
;
2620 reset_state_machine (linfo
.li_default_is_stmt
);
2622 /* Save a pointer to the contents of the Opcodes table. */
2623 standard_opcodes
= hdrptr
;
2625 /* Traverse the Directory table just to count entries. */
2626 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
2629 unsigned int n_directories
= 0;
2630 unsigned char *ptr_directory_table
= data
;
2634 data
+= strlen ((char *) data
) + 1;
2638 /* Go through the directory table again to save the directories. */
2639 directory_table
= (unsigned char **)
2640 xmalloc (n_directories
* sizeof (unsigned char *));
2643 while (*ptr_directory_table
!= 0)
2645 directory_table
[i
] = ptr_directory_table
;
2646 ptr_directory_table
+= strlen ((char *) ptr_directory_table
) + 1;
2650 /* Skip the NUL at the end of the table. */
2653 /* Traverse the File Name table just to count the entries. */
2656 unsigned int n_files
= 0;
2657 unsigned char *ptr_file_name_table
= data
;
2661 unsigned int bytes_read
;
2663 /* Skip Name, directory index, last modification time and length
2665 data
+= strlen ((char *) data
) + 1;
2666 read_leb128 (data
, & bytes_read
, 0);
2668 read_leb128 (data
, & bytes_read
, 0);
2670 read_leb128 (data
, & bytes_read
, 0);
2676 /* Go through the file table again to save the strings. */
2677 file_table
= (File_Entry
*) xmalloc (n_files
* sizeof (File_Entry
));
2680 while (*ptr_file_name_table
!= 0)
2682 unsigned int bytes_read
;
2684 file_table
[i
].name
= ptr_file_name_table
;
2685 ptr_file_name_table
+= strlen ((char *) ptr_file_name_table
) + 1;
2687 /* We are not interested in directory, time or size. */
2688 file_table
[i
].directory_index
= read_leb128 (ptr_file_name_table
,
2690 ptr_file_name_table
+= bytes_read
;
2691 file_table
[i
].modification_date
= read_leb128 (ptr_file_name_table
,
2693 ptr_file_name_table
+= bytes_read
;
2694 file_table
[i
].length
= read_leb128 (ptr_file_name_table
, & bytes_read
, 0);
2695 ptr_file_name_table
+= bytes_read
;
2700 /* Print the Compilation Unit's name and a header. */
2701 if (directory_table
== NULL
)
2703 printf (_("CU: %s:\n"), file_table
[0].name
);
2704 printf (_("File name Line number Starting address\n"));
2708 if (do_wide
|| strlen ((char *) directory_table
[0]) < 76)
2709 printf (_("CU: %s/%s:\n"), directory_table
[0],
2710 file_table
[0].name
);
2712 printf ("%s:\n", file_table
[0].name
);
2714 printf (_("File name Line number Starting address\n"));
2718 /* Skip the NUL at the end of the table. */
2721 /* This loop iterates through the Dwarf Line Number Program. */
2722 while (data
< end_of_sequence
)
2724 unsigned char op_code
;
2726 unsigned long int uladv
;
2727 unsigned int bytes_read
;
2728 int is_special_opcode
= 0;
2732 if (op_code
>= linfo
.li_opcode_base
)
2734 op_code
-= linfo
.li_opcode_base
;
2735 uladv
= (op_code
/ linfo
.li_line_range
);
2736 if (linfo
.li_max_ops_per_insn
== 1)
2738 uladv
*= linfo
.li_min_insn_length
;
2739 state_machine_regs
.address
+= uladv
;
2743 state_machine_regs
.address
2744 += ((state_machine_regs
.op_index
+ uladv
)
2745 / linfo
.li_max_ops_per_insn
)
2746 * linfo
.li_min_insn_length
;
2747 state_machine_regs
.op_index
2748 = (state_machine_regs
.op_index
+ uladv
)
2749 % linfo
.li_max_ops_per_insn
;
2752 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
2753 state_machine_regs
.line
+= adv
;
2754 is_special_opcode
= 1;
2756 else switch (op_code
)
2758 case DW_LNS_extended_op
:
2760 unsigned int ext_op_code_len
;
2761 unsigned char ext_op_code
;
2762 unsigned char *op_code_data
= data
;
2764 ext_op_code_len
= read_leb128 (op_code_data
, &bytes_read
, 0);
2765 op_code_data
+= bytes_read
;
2767 if (ext_op_code_len
== 0)
2769 warn (_("badly formed extended line op encountered!\n"));
2772 ext_op_code_len
+= bytes_read
;
2773 ext_op_code
= *op_code_data
++;
2775 switch (ext_op_code
)
2777 case DW_LNE_end_sequence
:
2778 reset_state_machine (linfo
.li_default_is_stmt
);
2780 case DW_LNE_set_address
:
2781 state_machine_regs
.address
=
2782 byte_get (op_code_data
, ext_op_code_len
- bytes_read
- 1);
2783 state_machine_regs
.op_index
= 0;
2785 case DW_LNE_define_file
:
2787 unsigned int dir_index
= 0;
2789 ++state_machine_regs
.last_file_entry
;
2790 op_code_data
+= strlen ((char *) op_code_data
) + 1;
2791 dir_index
= read_leb128 (op_code_data
, & bytes_read
, 0);
2792 op_code_data
+= bytes_read
;
2793 read_leb128 (op_code_data
, & bytes_read
, 0);
2794 op_code_data
+= bytes_read
;
2795 read_leb128 (op_code_data
, & bytes_read
, 0);
2797 printf ("%s:\n", directory_table
[dir_index
]);
2801 printf (_("UNKNOWN: length %d\n"), ext_op_code_len
- bytes_read
);
2804 data
+= ext_op_code_len
;
2810 case DW_LNS_advance_pc
:
2811 uladv
= read_leb128 (data
, & bytes_read
, 0);
2813 if (linfo
.li_max_ops_per_insn
== 1)
2815 uladv
*= linfo
.li_min_insn_length
;
2816 state_machine_regs
.address
+= uladv
;
2820 state_machine_regs
.address
2821 += ((state_machine_regs
.op_index
+ uladv
)
2822 / linfo
.li_max_ops_per_insn
)
2823 * linfo
.li_min_insn_length
;
2824 state_machine_regs
.op_index
2825 = (state_machine_regs
.op_index
+ uladv
)
2826 % linfo
.li_max_ops_per_insn
;
2830 case DW_LNS_advance_line
:
2831 adv
= read_leb128 (data
, & bytes_read
, 1);
2833 state_machine_regs
.line
+= adv
;
2836 case DW_LNS_set_file
:
2837 adv
= read_leb128 (data
, & bytes_read
, 0);
2839 state_machine_regs
.file
= adv
;
2840 if (file_table
[state_machine_regs
.file
- 1].directory_index
== 0)
2842 /* If directory index is 0, that means current directory. */
2843 printf ("\n./%s:[++]\n",
2844 file_table
[state_machine_regs
.file
- 1].name
);
2848 /* The directory index starts counting at 1. */
2849 printf ("\n%s/%s:\n",
2850 directory_table
[file_table
[state_machine_regs
.file
- 1].directory_index
- 1],
2851 file_table
[state_machine_regs
.file
- 1].name
);
2855 case DW_LNS_set_column
:
2856 uladv
= read_leb128 (data
, & bytes_read
, 0);
2858 state_machine_regs
.column
= uladv
;
2861 case DW_LNS_negate_stmt
:
2862 adv
= state_machine_regs
.is_stmt
;
2864 state_machine_regs
.is_stmt
= adv
;
2867 case DW_LNS_set_basic_block
:
2868 state_machine_regs
.basic_block
= 1;
2871 case DW_LNS_const_add_pc
:
2872 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
2873 if (linfo
.li_max_ops_per_insn
== 1)
2875 uladv
*= linfo
.li_min_insn_length
;
2876 state_machine_regs
.address
+= uladv
;
2880 state_machine_regs
.address
2881 += ((state_machine_regs
.op_index
+ uladv
)
2882 / linfo
.li_max_ops_per_insn
)
2883 * linfo
.li_min_insn_length
;
2884 state_machine_regs
.op_index
2885 = (state_machine_regs
.op_index
+ uladv
)
2886 % linfo
.li_max_ops_per_insn
;
2890 case DW_LNS_fixed_advance_pc
:
2891 uladv
= byte_get (data
, 2);
2893 state_machine_regs
.address
+= uladv
;
2894 state_machine_regs
.op_index
= 0;
2897 case DW_LNS_set_prologue_end
:
2900 case DW_LNS_set_epilogue_begin
:
2903 case DW_LNS_set_isa
:
2904 uladv
= read_leb128 (data
, & bytes_read
, 0);
2906 printf (_(" Set ISA to %lu\n"), uladv
);
2910 printf (_(" Unknown opcode %d with operands: "), op_code
);
2912 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
2914 printf ("0x%lx%s", read_leb128 (data
, &bytes_read
, 0),
2915 i
== 1 ? "" : ", ");
2922 /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row
2923 to the DWARF address/line matrix. */
2924 if ((is_special_opcode
) || (op_code
== DW_LNE_end_sequence
)
2925 || (op_code
== DW_LNS_copy
))
2927 const unsigned int MAX_FILENAME_LENGTH
= 35;
2928 char *fileName
= (char *)file_table
[state_machine_regs
.file
- 1].name
;
2929 char *newFileName
= NULL
;
2930 size_t fileNameLength
= strlen (fileName
);
2932 if ((fileNameLength
> MAX_FILENAME_LENGTH
) && (!do_wide
))
2934 newFileName
= (char *) xmalloc (MAX_FILENAME_LENGTH
+ 1);
2935 /* Truncate file name */
2936 strncpy (newFileName
,
2937 fileName
+ fileNameLength
- MAX_FILENAME_LENGTH
,
2938 MAX_FILENAME_LENGTH
+ 1);
2942 newFileName
= (char *) xmalloc (fileNameLength
+ 1);
2943 strncpy (newFileName
, fileName
, fileNameLength
+ 1);
2946 if (!do_wide
|| (fileNameLength
<= MAX_FILENAME_LENGTH
))
2948 if (linfo
.li_max_ops_per_insn
== 1)
2949 printf ("%-35s %11d %#18lx\n", newFileName
,
2950 state_machine_regs
.line
,
2951 state_machine_regs
.address
);
2953 printf ("%-35s %11d %#18lx[%d]\n", newFileName
,
2954 state_machine_regs
.line
,
2955 state_machine_regs
.address
,
2956 state_machine_regs
.op_index
);
2960 if (linfo
.li_max_ops_per_insn
== 1)
2961 printf ("%s %11d %#18lx\n", newFileName
,
2962 state_machine_regs
.line
,
2963 state_machine_regs
.address
);
2965 printf ("%s %11d %#18lx[%d]\n", newFileName
,
2966 state_machine_regs
.line
,
2967 state_machine_regs
.address
,
2968 state_machine_regs
.op_index
);
2971 if (op_code
== DW_LNE_end_sequence
)
2979 free (directory_table
);
2980 directory_table
= NULL
;
2988 display_debug_lines (struct dwarf_section
*section
, void *file ATTRIBUTE_UNUSED
)
2990 unsigned char *data
= section
->start
;
2991 unsigned char *end
= data
+ section
->size
;
2993 int retValDecoded
= 1;
2995 if (do_debug_lines
== 0)
2996 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
2998 if (do_debug_lines
& FLAG_DEBUG_LINES_RAW
)
2999 retValRaw
= display_debug_lines_raw (section
, data
, end
);
3001 if (do_debug_lines
& FLAG_DEBUG_LINES_DECODED
)
3002 retValDecoded
= display_debug_lines_decoded (section
, data
, end
);
3004 if (!retValRaw
|| !retValDecoded
)
3011 find_debug_info_for_offset (unsigned long offset
)
3015 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
3018 for (i
= 0; i
< num_debug_info_entries
; i
++)
3019 if (debug_information
[i
].cu_offset
== offset
)
3020 return debug_information
+ i
;
3026 display_debug_pubnames (struct dwarf_section
*section
,
3027 void *file ATTRIBUTE_UNUSED
)
3029 DWARF2_Internal_PubNames names
;
3030 unsigned char *start
= section
->start
;
3031 unsigned char *end
= start
+ section
->size
;
3033 /* It does not matter if this load fails,
3034 we test for that later on. */
3035 load_debug_info (file
);
3037 printf (_("Contents of the %s section:\n\n"), section
->name
);
3041 unsigned char *data
;
3042 unsigned long offset
;
3043 int offset_size
, initial_length_size
;
3047 names
.pn_length
= byte_get (data
, 4);
3049 if (names
.pn_length
== 0xffffffff)
3051 names
.pn_length
= byte_get (data
, 8);
3054 initial_length_size
= 12;
3059 initial_length_size
= 4;
3062 names
.pn_version
= byte_get (data
, 2);
3065 names
.pn_offset
= byte_get (data
, offset_size
);
3066 data
+= offset_size
;
3068 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
3069 && num_debug_info_entries
> 0
3070 && find_debug_info_for_offset (names
.pn_offset
) == NULL
)
3071 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
3072 names
.pn_offset
, section
->name
);
3074 names
.pn_size
= byte_get (data
, offset_size
);
3075 data
+= offset_size
;
3077 start
+= names
.pn_length
+ initial_length_size
;
3079 if (names
.pn_version
!= 2 && names
.pn_version
!= 3)
3081 static int warned
= 0;
3085 warn (_("Only DWARF 2 and 3 pubnames are currently supported\n"));
3092 printf (_(" Length: %ld\n"),
3094 printf (_(" Version: %d\n"),
3096 printf (_(" Offset into .debug_info section: 0x%lx\n"),
3098 printf (_(" Size of area in .debug_info section: %ld\n"),
3101 printf (_("\n Offset\tName\n"));
3105 offset
= byte_get (data
, offset_size
);
3109 data
+= offset_size
;
3110 printf (" %-6lx\t%s\n", offset
, data
);
3111 data
+= strlen ((char *) data
) + 1;
3114 while (offset
!= 0);
3122 display_debug_macinfo (struct dwarf_section
*section
,
3123 void *file ATTRIBUTE_UNUSED
)
3125 unsigned char *start
= section
->start
;
3126 unsigned char *end
= start
+ section
->size
;
3127 unsigned char *curr
= start
;
3128 unsigned int bytes_read
;
3129 enum dwarf_macinfo_record_type op
;
3131 printf (_("Contents of the %s section:\n\n"), section
->name
);
3135 unsigned int lineno
;
3138 op
= (enum dwarf_macinfo_record_type
) *curr
;
3143 case DW_MACINFO_start_file
:
3145 unsigned int filenum
;
3147 lineno
= read_leb128 (curr
, & bytes_read
, 0);
3149 filenum
= read_leb128 (curr
, & bytes_read
, 0);
3152 printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"),
3157 case DW_MACINFO_end_file
:
3158 printf (_(" DW_MACINFO_end_file\n"));
3161 case DW_MACINFO_define
:
3162 lineno
= read_leb128 (curr
, & bytes_read
, 0);
3164 string
= (char *) curr
;
3165 curr
+= strlen (string
) + 1;
3166 printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"),
3170 case DW_MACINFO_undef
:
3171 lineno
= read_leb128 (curr
, & bytes_read
, 0);
3173 string
= (char *) curr
;
3174 curr
+= strlen (string
) + 1;
3175 printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"),
3179 case DW_MACINFO_vendor_ext
:
3181 unsigned int constant
;
3183 constant
= read_leb128 (curr
, & bytes_read
, 0);
3185 string
= (char *) curr
;
3186 curr
+= strlen (string
) + 1;
3187 printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"),
3198 display_debug_abbrev (struct dwarf_section
*section
,
3199 void *file ATTRIBUTE_UNUSED
)
3201 abbrev_entry
*entry
;
3202 unsigned char *start
= section
->start
;
3203 unsigned char *end
= start
+ section
->size
;
3205 printf (_("Contents of the %s section:\n\n"), section
->name
);
3211 start
= process_abbrev_section (start
, end
);
3213 if (first_abbrev
== NULL
)
3216 printf (_(" Number TAG\n"));
3218 for (entry
= first_abbrev
; entry
; entry
= entry
->next
)
3222 printf (" %ld %s [%s]\n",
3224 get_TAG_name (entry
->tag
),
3225 entry
->children
? _("has children") : _("no children"));
3227 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
3228 printf (" %-18s %s\n",
3229 get_AT_name (attr
->attribute
),
3230 get_FORM_name (attr
->form
));
3241 display_debug_loc (struct dwarf_section
*section
, void *file
)
3243 unsigned char *start
= section
->start
;
3244 unsigned char *section_end
;
3245 unsigned long bytes
;
3246 unsigned char *section_begin
= start
;
3247 unsigned int num_loc_list
= 0;
3248 unsigned long last_offset
= 0;
3249 unsigned int first
= 0;
3252 int seen_first_offset
= 0;
3253 int use_debug_info
= 1;
3254 unsigned char *next
;
3256 bytes
= section
->size
;
3257 section_end
= start
+ bytes
;
3261 printf (_("\nThe %s section is empty.\n"), section
->name
);
3265 if (load_debug_info (file
) == 0)
3267 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
3272 /* Check the order of location list in .debug_info section. If
3273 offsets of location lists are in the ascending order, we can
3274 use `debug_information' directly. */
3275 for (i
= 0; i
< num_debug_info_entries
; i
++)
3279 num
= debug_information
[i
].num_loc_offsets
;
3280 num_loc_list
+= num
;
3282 /* Check if we can use `debug_information' directly. */
3283 if (use_debug_info
&& num
!= 0)
3285 if (!seen_first_offset
)
3287 /* This is the first location list. */
3288 last_offset
= debug_information
[i
].loc_offsets
[0];
3290 seen_first_offset
= 1;
3296 for (; j
< num
; j
++)
3299 debug_information
[i
].loc_offsets
[j
])
3304 last_offset
= debug_information
[i
].loc_offsets
[j
];
3309 if (!use_debug_info
)
3310 /* FIXME: Should we handle this case? */
3311 error (_("Location lists in .debug_info section aren't in ascending order!\n"));
3313 if (!seen_first_offset
)
3314 error (_("No location lists in .debug_info section!\n"));
3316 /* DWARF sections under Mach-O have non-zero addresses. */
3317 if (debug_information
[first
].num_loc_offsets
> 0
3318 && debug_information
[first
].loc_offsets
[0] != section
->address
)
3319 warn (_("Location lists in %s section start at 0x%lx\n"),
3320 section
->name
, debug_information
[first
].loc_offsets
[0]);
3322 printf (_("Contents of the %s section:\n\n"), section
->name
);
3323 printf (_(" Offset Begin End Expression\n"));
3325 seen_first_offset
= 0;
3326 for (i
= first
; i
< num_debug_info_entries
; i
++)
3330 unsigned short length
;
3331 unsigned long offset
;
3332 unsigned int pointer_size
;
3333 unsigned int offset_size
;
3335 unsigned long cu_offset
;
3336 unsigned long base_address
;
3337 int need_frame_base
;
3340 pointer_size
= debug_information
[i
].pointer_size
;
3341 cu_offset
= debug_information
[i
].cu_offset
;
3342 offset_size
= debug_information
[i
].offset_size
;
3343 dwarf_version
= debug_information
[i
].dwarf_version
;
3345 for (j
= 0; j
< debug_information
[i
].num_loc_offsets
; j
++)
3347 has_frame_base
= debug_information
[i
].have_frame_base
[j
];
3348 /* DWARF sections under Mach-O have non-zero addresses. */
3349 offset
= debug_information
[i
].loc_offsets
[j
] - section
->address
;
3350 next
= section_begin
+ offset
;
3351 base_address
= debug_information
[i
].base_address
;
3353 if (!seen_first_offset
)
3354 seen_first_offset
= 1;
3358 warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"),
3359 (unsigned long) (start
- section_begin
),
3360 (unsigned long) (next
- section_begin
));
3361 else if (start
> next
)
3362 warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"),
3363 (unsigned long) (start
- section_begin
),
3364 (unsigned long) (next
- section_begin
));
3368 if (offset
>= bytes
)
3370 warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"),
3377 if (start
+ 2 * pointer_size
> section_end
)
3379 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3384 /* Note: we use sign extension here in order to be sure that
3385 we can detect the -1 escape value. Sign extension into the
3386 top 32 bits of a 32-bit address will not affect the values
3387 that we display since we always show hex values, and always
3388 the bottom 32-bits. */
3389 begin
= byte_get_signed (start
, pointer_size
);
3390 start
+= pointer_size
;
3391 end
= byte_get_signed (start
, pointer_size
);
3392 start
+= pointer_size
;
3394 printf (" %8.8lx ", offset
);
3396 if (begin
== 0 && end
== 0)
3398 printf (_("<End of list>\n"));
3402 /* Check base address specifiers. */
3403 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
3406 print_dwarf_vma (begin
, pointer_size
);
3407 print_dwarf_vma (end
, pointer_size
);
3408 printf (_("(base address)\n"));
3412 if (start
+ 2 > section_end
)
3414 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3419 length
= byte_get (start
, 2);
3422 if (start
+ length
> section_end
)
3424 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3429 print_dwarf_vma (begin
+ base_address
, pointer_size
);
3430 print_dwarf_vma (end
+ base_address
, pointer_size
);
3433 need_frame_base
= decode_location_expression (start
,
3438 cu_offset
, section
);
3441 if (need_frame_base
&& !has_frame_base
)
3442 printf (_(" [without DW_AT_frame_base]"));
3445 fputs (_(" (start == end)"), stdout
);
3446 else if (begin
> end
)
3447 fputs (_(" (start > end)"), stdout
);
3456 if (start
< section_end
)
3457 warn (_("There are %ld unused bytes at the end of section %s\n"),
3458 (long) (section_end
- start
), section
->name
);
3464 display_debug_str (struct dwarf_section
*section
,
3465 void *file ATTRIBUTE_UNUSED
)
3467 unsigned char *start
= section
->start
;
3468 unsigned long bytes
= section
->size
;
3469 dwarf_vma addr
= section
->address
;
3473 printf (_("\nThe %s section is empty.\n"), section
->name
);
3477 printf (_("Contents of the %s section:\n\n"), section
->name
);
3485 lbytes
= (bytes
> 16 ? 16 : bytes
);
3487 printf (" 0x%8.8lx ", (unsigned long) addr
);
3489 for (j
= 0; j
< 16; j
++)
3492 printf ("%2.2x", start
[j
]);
3500 for (j
= 0; j
< lbytes
; j
++)
3503 if (k
>= ' ' && k
< 0x80)
3522 display_debug_info (struct dwarf_section
*section
, void *file
)
3524 return process_debug_info (section
, file
, abbrev
, 0, 0);
3528 display_debug_types (struct dwarf_section
*section
, void *file
)
3530 return process_debug_info (section
, file
, abbrev
, 0, 1);
3534 display_trace_info (struct dwarf_section
*section
, void *file
)
3536 return process_debug_info (section
, file
, trace_abbrev
, 0, 0);
3540 display_debug_aranges (struct dwarf_section
*section
,
3541 void *file ATTRIBUTE_UNUSED
)
3543 unsigned char *start
= section
->start
;
3544 unsigned char *end
= start
+ section
->size
;
3546 printf (_("Contents of the %s section:\n\n"), section
->name
);
3548 /* It does not matter if this load fails,
3549 we test for that later on. */
3550 load_debug_info (file
);
3554 unsigned char *hdrptr
;
3555 DWARF2_Internal_ARange arange
;
3556 unsigned char *addr_ranges
;
3559 unsigned char address_size
;
3562 int initial_length_size
;
3566 arange
.ar_length
= byte_get (hdrptr
, 4);
3569 if (arange
.ar_length
== 0xffffffff)
3571 arange
.ar_length
= byte_get (hdrptr
, 8);
3574 initial_length_size
= 12;
3579 initial_length_size
= 4;
3582 arange
.ar_version
= byte_get (hdrptr
, 2);
3585 arange
.ar_info_offset
= byte_get (hdrptr
, offset_size
);
3586 hdrptr
+= offset_size
;
3588 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
3589 && num_debug_info_entries
> 0
3590 && find_debug_info_for_offset (arange
.ar_info_offset
) == NULL
)
3591 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
3592 arange
.ar_info_offset
, section
->name
);
3594 arange
.ar_pointer_size
= byte_get (hdrptr
, 1);
3597 arange
.ar_segment_size
= byte_get (hdrptr
, 1);
3600 if (arange
.ar_version
!= 2 && arange
.ar_version
!= 3)
3602 warn (_("Only DWARF 2 and 3 aranges are currently supported.\n"));
3606 printf (_(" Length: %ld\n"), arange
.ar_length
);
3607 printf (_(" Version: %d\n"), arange
.ar_version
);
3608 printf (_(" Offset into .debug_info: 0x%lx\n"), arange
.ar_info_offset
);
3609 printf (_(" Pointer Size: %d\n"), arange
.ar_pointer_size
);
3610 printf (_(" Segment Size: %d\n"), arange
.ar_segment_size
);
3612 address_size
= arange
.ar_pointer_size
+ arange
.ar_segment_size
;
3614 /* The DWARF spec does not require that the address size be a power
3615 of two, but we do. This will have to change if we ever encounter
3616 an uneven architecture. */
3617 if ((address_size
& (address_size
- 1)) != 0)
3619 warn (_("Pointer size + Segment size is not a power of two.\n"));
3623 if (address_size
> 4)
3624 printf (_("\n Address Length\n"));
3626 printf (_("\n Address Length\n"));
3628 addr_ranges
= hdrptr
;
3630 /* Must pad to an alignment boundary that is twice the address size. */
3631 excess
= (hdrptr
- start
) % (2 * address_size
);
3633 addr_ranges
+= (2 * address_size
) - excess
;
3635 start
+= arange
.ar_length
+ initial_length_size
;
3637 while (addr_ranges
+ 2 * address_size
<= start
)
3639 address
= byte_get (addr_ranges
, address_size
);
3641 addr_ranges
+= address_size
;
3643 length
= byte_get (addr_ranges
, address_size
);
3645 addr_ranges
+= address_size
;
3648 print_dwarf_vma (address
, address_size
);
3649 print_dwarf_vma (length
, address_size
);
3659 /* Each debug_information[x].range_lists[y] gets this representation for
3660 sorting purposes. */
3664 /* The debug_information[x].range_lists[y] value. */
3665 unsigned long ranges_offset
;
3667 /* Original debug_information to find parameters of the data. */
3668 debug_info
*debug_info_p
;
3671 /* Sort struct range_entry in ascending order of its RANGES_OFFSET. */
3674 range_entry_compar (const void *ap
, const void *bp
)
3676 const struct range_entry
*a_re
= (const struct range_entry
*) ap
;
3677 const struct range_entry
*b_re
= (const struct range_entry
*) bp
;
3678 const unsigned long a
= a_re
->ranges_offset
;
3679 const unsigned long b
= b_re
->ranges_offset
;
3681 return (a
> b
) - (b
> a
);
3685 display_debug_ranges (struct dwarf_section
*section
,
3686 void *file ATTRIBUTE_UNUSED
)
3688 unsigned char *start
= section
->start
;
3689 unsigned long bytes
;
3690 unsigned char *section_begin
= start
;
3691 unsigned int num_range_list
, i
;
3692 struct range_entry
*range_entries
, *range_entry_fill
;
3694 bytes
= section
->size
;
3698 printf (_("\nThe %s section is empty.\n"), section
->name
);
3702 if (load_debug_info (file
) == 0)
3704 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
3710 for (i
= 0; i
< num_debug_info_entries
; i
++)
3711 num_range_list
+= debug_information
[i
].num_range_lists
;
3713 if (num_range_list
== 0)
3714 error (_("No range lists in .debug_info section!\n"));
3716 range_entries
= (struct range_entry
*)
3717 xmalloc (sizeof (*range_entries
) * num_range_list
);
3718 range_entry_fill
= range_entries
;
3720 for (i
= 0; i
< num_debug_info_entries
; i
++)
3722 debug_info
*debug_info_p
= &debug_information
[i
];
3725 for (j
= 0; j
< debug_info_p
->num_range_lists
; j
++)
3727 range_entry_fill
->ranges_offset
= debug_info_p
->range_lists
[j
];
3728 range_entry_fill
->debug_info_p
= debug_info_p
;
3733 qsort (range_entries
, num_range_list
, sizeof (*range_entries
),
3734 range_entry_compar
);
3736 /* DWARF sections under Mach-O have non-zero addresses. */
3737 if (range_entries
[0].ranges_offset
!= section
->address
)
3738 warn (_("Range lists in %s section start at 0x%lx\n"),
3739 section
->name
, range_entries
[0].ranges_offset
);
3741 printf (_("Contents of the %s section:\n\n"), section
->name
);
3742 printf (_(" Offset Begin End\n"));
3744 for (i
= 0; i
< num_range_list
; i
++)
3746 struct range_entry
*range_entry
= &range_entries
[i
];
3747 debug_info
*debug_info_p
= range_entry
->debug_info_p
;
3748 unsigned int pointer_size
;
3749 unsigned long offset
;
3750 unsigned char *next
;
3751 unsigned long base_address
;
3753 pointer_size
= debug_info_p
->pointer_size
;
3755 /* DWARF sections under Mach-O have non-zero addresses. */
3756 offset
= range_entry
->ranges_offset
- section
->address
;
3757 next
= section_begin
+ offset
;
3758 base_address
= debug_info_p
->base_address
;
3763 warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"),
3764 (unsigned long) (start
- section_begin
),
3765 (unsigned long) (next
- section_begin
), section
->name
);
3766 else if (start
> next
)
3767 warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"),
3768 (unsigned long) (start
- section_begin
),
3769 (unsigned long) (next
- section_begin
), section
->name
);
3778 /* Note: we use sign extension here in order to be sure that
3779 we can detect the -1 escape value. Sign extension into the
3780 top 32 bits of a 32-bit address will not affect the values
3781 that we display since we always show hex values, and always
3782 the bottom 32-bits. */
3783 begin
= byte_get_signed (start
, pointer_size
);
3784 start
+= pointer_size
;
3785 end
= byte_get_signed (start
, pointer_size
);
3786 start
+= pointer_size
;
3788 printf (" %8.8lx ", offset
);
3790 if (begin
== 0 && end
== 0)
3792 printf (_("<End of list>\n"));
3796 /* Check base address specifiers. */
3797 if (begin
== (dwarf_vma
) -1 && end
!= (dwarf_vma
) -1)
3800 print_dwarf_vma (begin
, pointer_size
);
3801 print_dwarf_vma (end
, pointer_size
);
3802 printf ("(base address)\n");
3806 print_dwarf_vma (begin
+ base_address
, pointer_size
);
3807 print_dwarf_vma (end
+ base_address
, pointer_size
);
3810 fputs (_("(start == end)"), stdout
);
3811 else if (begin
> end
)
3812 fputs (_("(start > end)"), stdout
);
3819 free (range_entries
);
3824 typedef struct Frame_Chunk
3826 struct Frame_Chunk
*next
;
3827 unsigned char *chunk_start
;
3829 /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
3830 short int *col_type
;
3833 unsigned int code_factor
;
3835 unsigned long pc_begin
;
3836 unsigned long pc_range
;
3840 unsigned char fde_encoding
;
3841 unsigned char cfa_exp
;
3842 unsigned char ptr_size
;
3843 unsigned char segment_size
;
3847 static const char *const *dwarf_regnames
;
3848 static unsigned int dwarf_regnames_count
;
3850 /* A marker for a col_type that means this column was never referenced
3851 in the frame info. */
3852 #define DW_CFA_unreferenced (-1)
3854 /* Return 0 if not more space is needed, 1 if more space is needed,
3855 -1 for invalid reg. */
3858 frame_need_space (Frame_Chunk
*fc
, unsigned int reg
)
3860 int prev
= fc
->ncols
;
3862 if (reg
< (unsigned int) fc
->ncols
)
3865 if (dwarf_regnames_count
3866 && reg
> dwarf_regnames_count
)
3869 fc
->ncols
= reg
+ 1;
3870 fc
->col_type
= (short int *) xcrealloc (fc
->col_type
, fc
->ncols
,
3871 sizeof (short int));
3872 fc
->col_offset
= (int *) xcrealloc (fc
->col_offset
, fc
->ncols
, sizeof (int));
3874 while (prev
< fc
->ncols
)
3876 fc
->col_type
[prev
] = DW_CFA_unreferenced
;
3877 fc
->col_offset
[prev
] = 0;
3883 static const char *const dwarf_regnames_i386
[] =
3885 "eax", "ecx", "edx", "ebx",
3886 "esp", "ebp", "esi", "edi",
3887 "eip", "eflags", NULL
,
3888 "st0", "st1", "st2", "st3",
3889 "st4", "st5", "st6", "st7",
3891 "xmm0", "xmm1", "xmm2", "xmm3",
3892 "xmm4", "xmm5", "xmm6", "xmm7",
3893 "mm0", "mm1", "mm2", "mm3",
3894 "mm4", "mm5", "mm6", "mm7",
3895 "fcw", "fsw", "mxcsr",
3896 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
3901 init_dwarf_regnames_i386 (void)
3903 dwarf_regnames
= dwarf_regnames_i386
;
3904 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_i386
);
3907 static const char *const dwarf_regnames_x86_64
[] =
3909 "rax", "rdx", "rcx", "rbx",
3910 "rsi", "rdi", "rbp", "rsp",
3911 "r8", "r9", "r10", "r11",
3912 "r12", "r13", "r14", "r15",
3914 "xmm0", "xmm1", "xmm2", "xmm3",
3915 "xmm4", "xmm5", "xmm6", "xmm7",
3916 "xmm8", "xmm9", "xmm10", "xmm11",
3917 "xmm12", "xmm13", "xmm14", "xmm15",
3918 "st0", "st1", "st2", "st3",
3919 "st4", "st5", "st6", "st7",
3920 "mm0", "mm1", "mm2", "mm3",
3921 "mm4", "mm5", "mm6", "mm7",
3923 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
3924 "fs.base", "gs.base", NULL
, NULL
,
3926 "mxcsr", "fcw", "fsw"
3930 init_dwarf_regnames_x86_64 (void)
3932 dwarf_regnames
= dwarf_regnames_x86_64
;
3933 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_x86_64
);
3937 init_dwarf_regnames (unsigned int e_machine
)
3943 init_dwarf_regnames_i386 ();
3948 init_dwarf_regnames_x86_64 ();
3957 regname (unsigned int regno
, int row
)
3959 static char reg
[64];
3961 && regno
< dwarf_regnames_count
3962 && dwarf_regnames
[regno
] != NULL
)
3965 return dwarf_regnames
[regno
];
3966 snprintf (reg
, sizeof (reg
), "r%d (%s)", regno
,
3967 dwarf_regnames
[regno
]);
3970 snprintf (reg
, sizeof (reg
), "r%d", regno
);
3975 frame_display_row (Frame_Chunk
*fc
, int *need_col_headers
, int *max_regs
)
3980 if (*max_regs
< fc
->ncols
)
3981 *max_regs
= fc
->ncols
;
3983 if (*need_col_headers
)
3985 static const char *sloc
= " LOC";
3987 *need_col_headers
= 0;
3989 printf ("%-*s CFA ", eh_addr_size
* 2, sloc
);
3991 for (r
= 0; r
< *max_regs
; r
++)
3992 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
3997 printf ("%-5s ", regname (r
, 1));
4003 printf ("%0*lx ", eh_addr_size
* 2, fc
->pc_begin
);
4005 strcpy (tmp
, "exp");
4007 sprintf (tmp
, "%s%+d", regname (fc
->cfa_reg
, 1), fc
->cfa_offset
);
4008 printf ("%-8s ", tmp
);
4010 for (r
= 0; r
< fc
->ncols
; r
++)
4012 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
4014 switch (fc
->col_type
[r
])
4016 case DW_CFA_undefined
:
4019 case DW_CFA_same_value
:
4023 sprintf (tmp
, "c%+d", fc
->col_offset
[r
]);
4025 case DW_CFA_val_offset
:
4026 sprintf (tmp
, "v%+d", fc
->col_offset
[r
]);
4028 case DW_CFA_register
:
4029 sprintf (tmp
, "%s", regname (fc
->col_offset
[r
], 0));
4031 case DW_CFA_expression
:
4032 strcpy (tmp
, "exp");
4034 case DW_CFA_val_expression
:
4035 strcpy (tmp
, "vexp");
4038 strcpy (tmp
, "n/a");
4041 printf ("%-5s ", tmp
);
4047 #define GET(N) byte_get (start, N); start += N
4048 #define LEB() read_leb128 (start, & length_return, 0); start += length_return
4049 #define SLEB() read_leb128 (start, & length_return, 1); start += length_return
4052 display_debug_frames (struct dwarf_section
*section
,
4053 void *file ATTRIBUTE_UNUSED
)
4055 unsigned char *start
= section
->start
;
4056 unsigned char *end
= start
+ section
->size
;
4057 unsigned char *section_start
= start
;
4058 Frame_Chunk
*chunks
= 0;
4059 Frame_Chunk
*remembered_state
= 0;
4061 int is_eh
= strcmp (section
->name
, ".eh_frame") == 0;
4062 unsigned int length_return
;
4064 const char *bad_reg
= _("bad register: ");
4065 int saved_eh_addr_size
= eh_addr_size
;
4067 printf (_("Contents of the %s section:\n"), section
->name
);
4071 unsigned char *saved_start
;
4072 unsigned char *block_end
;
4073 unsigned long length
;
4074 unsigned long cie_id
;
4077 int need_col_headers
= 1;
4078 unsigned char *augmentation_data
= NULL
;
4079 unsigned long augmentation_data_len
= 0;
4080 int encoded_ptr_size
= saved_eh_addr_size
;
4082 int initial_length_size
;
4084 saved_start
= start
;
4085 length
= byte_get (start
, 4); start
+= 4;
4089 printf ("\n%08lx ZERO terminator\n\n",
4090 (unsigned long)(saved_start
- section_start
));
4094 if (length
== 0xffffffff)
4096 length
= byte_get (start
, 8);
4099 initial_length_size
= 12;
4104 initial_length_size
= 4;
4107 block_end
= saved_start
+ length
+ initial_length_size
;
4108 if (block_end
> end
)
4110 warn ("Invalid length %#08lx in FDE at %#08lx\n",
4111 length
, (unsigned long)(saved_start
- section_start
));
4114 cie_id
= byte_get (start
, offset_size
); start
+= offset_size
;
4116 if (is_eh
? (cie_id
== 0) : (cie_id
== DW_CIE_ID
))
4120 fc
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
4121 memset (fc
, 0, sizeof (Frame_Chunk
));
4125 fc
->chunk_start
= saved_start
;
4127 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
4128 fc
->col_offset
= (int *) xmalloc (sizeof (int));
4129 frame_need_space (fc
, max_regs
- 1);
4133 fc
->augmentation
= (char *) start
;
4134 start
= (unsigned char *) strchr ((char *) start
, '\0') + 1;
4136 if (strcmp (fc
->augmentation
, "eh") == 0)
4137 start
+= eh_addr_size
;
4141 fc
->ptr_size
= GET (1);
4142 fc
->segment_size
= GET (1);
4143 eh_addr_size
= fc
->ptr_size
;
4147 fc
->ptr_size
= eh_addr_size
;
4148 fc
->segment_size
= 0;
4150 fc
->code_factor
= LEB ();
4151 fc
->data_factor
= SLEB ();
4161 if (fc
->augmentation
[0] == 'z')
4163 augmentation_data_len
= LEB ();
4164 augmentation_data
= start
;
4165 start
+= augmentation_data_len
;
4169 if (do_debug_frames_interp
)
4170 printf ("\n%08lx %08lx %08lx CIE \"%s\" cf=%d df=%d ra=%d\n",
4171 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
4172 fc
->augmentation
, fc
->code_factor
, fc
->data_factor
,
4176 printf ("\n%08lx %08lx %08lx CIE\n",
4177 (unsigned long)(saved_start
- section_start
), length
, cie_id
);
4178 printf (" Version: %d\n", version
);
4179 printf (" Augmentation: \"%s\"\n", fc
->augmentation
);
4182 printf (" Pointer Size: %u\n", fc
->ptr_size
);
4183 printf (" Segment Size: %u\n", fc
->segment_size
);
4185 printf (" Code alignment factor: %u\n", fc
->code_factor
);
4186 printf (" Data alignment factor: %d\n", fc
->data_factor
);
4187 printf (" Return address column: %d\n", fc
->ra
);
4189 if (augmentation_data_len
)
4192 printf (" Augmentation data: ");
4193 for (i
= 0; i
< augmentation_data_len
; ++i
)
4194 printf (" %02x", augmentation_data
[i
]);
4200 if (augmentation_data_len
)
4202 unsigned char *p
, *q
;
4203 p
= (unsigned char *) fc
->augmentation
+ 1;
4204 q
= augmentation_data
;
4211 q
+= 1 + size_of_encoded_value (*q
);
4213 fc
->fde_encoding
= *q
++;
4221 if (fc
->fde_encoding
)
4222 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
4225 frame_need_space (fc
, fc
->ra
);
4229 unsigned char *look_for
;
4230 static Frame_Chunk fde_fc
;
4231 unsigned long segment_selector
;
4234 memset (fc
, 0, sizeof (Frame_Chunk
));
4236 look_for
= is_eh
? start
- 4 - cie_id
: section_start
+ cie_id
;
4238 for (cie
= chunks
; cie
; cie
= cie
->next
)
4239 if (cie
->chunk_start
== look_for
)
4244 warn ("Invalid CIE pointer %#08lx in FDE at %#08lx\n",
4245 cie_id
, (unsigned long)(saved_start
- section_start
));
4247 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
4248 fc
->col_offset
= (int *) xmalloc (sizeof (int));
4249 frame_need_space (fc
, max_regs
- 1);
4251 fc
->augmentation
= "";
4252 fc
->fde_encoding
= 0;
4253 fc
->ptr_size
= eh_addr_size
;
4254 fc
->segment_size
= 0;
4258 fc
->ncols
= cie
->ncols
;
4259 fc
->col_type
= (short int *) xcmalloc (fc
->ncols
, sizeof (short int));
4260 fc
->col_offset
= (int *) xcmalloc (fc
->ncols
, sizeof (int));
4261 memcpy (fc
->col_type
, cie
->col_type
, fc
->ncols
* sizeof (short int));
4262 memcpy (fc
->col_offset
, cie
->col_offset
, fc
->ncols
* sizeof (int));
4263 fc
->augmentation
= cie
->augmentation
;
4264 fc
->ptr_size
= cie
->ptr_size
;
4265 eh_addr_size
= cie
->ptr_size
;
4266 fc
->segment_size
= cie
->segment_size
;
4267 fc
->code_factor
= cie
->code_factor
;
4268 fc
->data_factor
= cie
->data_factor
;
4269 fc
->cfa_reg
= cie
->cfa_reg
;
4270 fc
->cfa_offset
= cie
->cfa_offset
;
4272 frame_need_space (fc
, max_regs
- 1);
4273 fc
->fde_encoding
= cie
->fde_encoding
;
4276 if (fc
->fde_encoding
)
4277 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
4279 segment_selector
= 0;
4280 if (fc
->segment_size
)
4282 segment_selector
= byte_get (start
, fc
->segment_size
);
4283 start
+= fc
->segment_size
;
4285 fc
->pc_begin
= get_encoded_value (start
, fc
->fde_encoding
);
4286 if ((fc
->fde_encoding
& 0x70) == DW_EH_PE_pcrel
)
4287 fc
->pc_begin
+= section
->address
+ (start
- section_start
);
4288 start
+= encoded_ptr_size
;
4289 fc
->pc_range
= byte_get (start
, encoded_ptr_size
);
4290 start
+= encoded_ptr_size
;
4292 if (cie
->augmentation
[0] == 'z')
4294 augmentation_data_len
= LEB ();
4295 augmentation_data
= start
;
4296 start
+= augmentation_data_len
;
4299 printf ("\n%08lx %08lx %08lx FDE cie=%08lx pc=",
4300 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
4301 (unsigned long)(cie
->chunk_start
- section_start
));
4302 if (fc
->segment_size
)
4303 printf ("%04lx:", segment_selector
);
4304 printf ("%08lx..%08lx\n", fc
->pc_begin
, fc
->pc_begin
+ fc
->pc_range
);
4305 if (! do_debug_frames_interp
&& augmentation_data_len
)
4309 printf (" Augmentation data: ");
4310 for (i
= 0; i
< augmentation_data_len
; ++i
)
4311 printf (" %02x", augmentation_data
[i
]);
4317 /* At this point, fc is the current chunk, cie (if any) is set, and
4318 we're about to interpret instructions for the chunk. */
4319 /* ??? At present we need to do this always, since this sizes the
4320 fc->col_type and fc->col_offset arrays, which we write into always.
4321 We should probably split the interpreted and non-interpreted bits
4322 into two different routines, since there's so much that doesn't
4323 really overlap between them. */
4324 if (1 || do_debug_frames_interp
)
4326 /* Start by making a pass over the chunk, allocating storage
4327 and taking note of what registers are used. */
4328 unsigned char *tmp
= start
;
4330 while (start
< block_end
)
4333 unsigned long reg
, temp
;
4340 /* Warning: if you add any more cases to this switch, be
4341 sure to add them to the corresponding switch below. */
4344 case DW_CFA_advance_loc
:
4348 if (frame_need_space (fc
, opa
) >= 0)
4349 fc
->col_type
[opa
] = DW_CFA_undefined
;
4351 case DW_CFA_restore
:
4352 if (frame_need_space (fc
, opa
) >= 0)
4353 fc
->col_type
[opa
] = DW_CFA_undefined
;
4355 case DW_CFA_set_loc
:
4356 start
+= encoded_ptr_size
;
4358 case DW_CFA_advance_loc1
:
4361 case DW_CFA_advance_loc2
:
4364 case DW_CFA_advance_loc4
:
4367 case DW_CFA_offset_extended
:
4368 case DW_CFA_val_offset
:
4369 reg
= LEB (); LEB ();
4370 if (frame_need_space (fc
, reg
) >= 0)
4371 fc
->col_type
[reg
] = DW_CFA_undefined
;
4373 case DW_CFA_restore_extended
:
4375 frame_need_space (fc
, reg
);
4376 if (frame_need_space (fc
, reg
) >= 0)
4377 fc
->col_type
[reg
] = DW_CFA_undefined
;
4379 case DW_CFA_undefined
:
4381 if (frame_need_space (fc
, reg
) >= 0)
4382 fc
->col_type
[reg
] = DW_CFA_undefined
;
4384 case DW_CFA_same_value
:
4386 if (frame_need_space (fc
, reg
) >= 0)
4387 fc
->col_type
[reg
] = DW_CFA_undefined
;
4389 case DW_CFA_register
:
4390 reg
= LEB (); LEB ();
4391 if (frame_need_space (fc
, reg
) >= 0)
4392 fc
->col_type
[reg
] = DW_CFA_undefined
;
4394 case DW_CFA_def_cfa
:
4397 case DW_CFA_def_cfa_register
:
4400 case DW_CFA_def_cfa_offset
:
4403 case DW_CFA_def_cfa_expression
:
4407 case DW_CFA_expression
:
4408 case DW_CFA_val_expression
:
4412 if (frame_need_space (fc
, reg
) >= 0)
4413 fc
->col_type
[reg
] = DW_CFA_undefined
;
4415 case DW_CFA_offset_extended_sf
:
4416 case DW_CFA_val_offset_sf
:
4417 reg
= LEB (); SLEB ();
4418 if (frame_need_space (fc
, reg
) >= 0)
4419 fc
->col_type
[reg
] = DW_CFA_undefined
;
4421 case DW_CFA_def_cfa_sf
:
4424 case DW_CFA_def_cfa_offset_sf
:
4427 case DW_CFA_MIPS_advance_loc8
:
4430 case DW_CFA_GNU_args_size
:
4433 case DW_CFA_GNU_negative_offset_extended
:
4434 reg
= LEB (); LEB ();
4435 if (frame_need_space (fc
, reg
) >= 0)
4436 fc
->col_type
[reg
] = DW_CFA_undefined
;
4445 /* Now we know what registers are used, make a second pass over
4446 the chunk, this time actually printing out the info. */
4448 while (start
< block_end
)
4451 unsigned long ul
, reg
, roffs
;
4454 const char *reg_prefix
= "";
4461 /* Warning: if you add any more cases to this switch, be
4462 sure to add them to the corresponding switch above. */
4465 case DW_CFA_advance_loc
:
4466 if (do_debug_frames_interp
)
4467 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4469 printf (" DW_CFA_advance_loc: %d to %08lx\n",
4470 opa
* fc
->code_factor
,
4471 fc
->pc_begin
+ opa
* fc
->code_factor
);
4472 fc
->pc_begin
+= opa
* fc
->code_factor
;
4477 if (opa
>= (unsigned int) fc
->ncols
)
4478 reg_prefix
= bad_reg
;
4479 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4480 printf (" DW_CFA_offset: %s%s at cfa%+ld\n",
4481 reg_prefix
, regname (opa
, 0),
4482 roffs
* fc
->data_factor
);
4483 if (*reg_prefix
== '\0')
4485 fc
->col_type
[opa
] = DW_CFA_offset
;
4486 fc
->col_offset
[opa
] = roffs
* fc
->data_factor
;
4490 case DW_CFA_restore
:
4491 if (opa
>= (unsigned int) cie
->ncols
4492 || opa
>= (unsigned int) fc
->ncols
)
4493 reg_prefix
= bad_reg
;
4494 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4495 printf (" DW_CFA_restore: %s%s\n",
4496 reg_prefix
, regname (opa
, 0));
4497 if (*reg_prefix
== '\0')
4499 fc
->col_type
[opa
] = cie
->col_type
[opa
];
4500 fc
->col_offset
[opa
] = cie
->col_offset
[opa
];
4504 case DW_CFA_set_loc
:
4505 vma
= get_encoded_value (start
, fc
->fde_encoding
);
4506 if ((fc
->fde_encoding
& 0x70) == DW_EH_PE_pcrel
)
4507 vma
+= section
->address
+ (start
- section_start
);
4508 start
+= encoded_ptr_size
;
4509 if (do_debug_frames_interp
)
4510 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4512 printf (" DW_CFA_set_loc: %08lx\n", (unsigned long)vma
);
4516 case DW_CFA_advance_loc1
:
4517 ofs
= byte_get (start
, 1); start
+= 1;
4518 if (do_debug_frames_interp
)
4519 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4521 printf (" DW_CFA_advance_loc1: %ld to %08lx\n",
4522 ofs
* fc
->code_factor
,
4523 fc
->pc_begin
+ ofs
* fc
->code_factor
);
4524 fc
->pc_begin
+= ofs
* fc
->code_factor
;
4527 case DW_CFA_advance_loc2
:
4528 ofs
= byte_get (start
, 2); start
+= 2;
4529 if (do_debug_frames_interp
)
4530 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4532 printf (" DW_CFA_advance_loc2: %ld to %08lx\n",
4533 ofs
* fc
->code_factor
,
4534 fc
->pc_begin
+ ofs
* fc
->code_factor
);
4535 fc
->pc_begin
+= ofs
* fc
->code_factor
;
4538 case DW_CFA_advance_loc4
:
4539 ofs
= byte_get (start
, 4); start
+= 4;
4540 if (do_debug_frames_interp
)
4541 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4543 printf (" DW_CFA_advance_loc4: %ld to %08lx\n",
4544 ofs
* fc
->code_factor
,
4545 fc
->pc_begin
+ ofs
* fc
->code_factor
);
4546 fc
->pc_begin
+= ofs
* fc
->code_factor
;
4549 case DW_CFA_offset_extended
:
4552 if (reg
>= (unsigned int) fc
->ncols
)
4553 reg_prefix
= bad_reg
;
4554 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4555 printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n",
4556 reg_prefix
, regname (reg
, 0),
4557 roffs
* fc
->data_factor
);
4558 if (*reg_prefix
== '\0')
4560 fc
->col_type
[reg
] = DW_CFA_offset
;
4561 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
4565 case DW_CFA_val_offset
:
4568 if (reg
>= (unsigned int) fc
->ncols
)
4569 reg_prefix
= bad_reg
;
4570 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4571 printf (" DW_CFA_val_offset: %s%s at cfa%+ld\n",
4572 reg_prefix
, regname (reg
, 0),
4573 roffs
* fc
->data_factor
);
4574 if (*reg_prefix
== '\0')
4576 fc
->col_type
[reg
] = DW_CFA_val_offset
;
4577 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
4581 case DW_CFA_restore_extended
:
4583 if (reg
>= (unsigned int) cie
->ncols
4584 || reg
>= (unsigned int) fc
->ncols
)
4585 reg_prefix
= bad_reg
;
4586 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4587 printf (" DW_CFA_restore_extended: %s%s\n",
4588 reg_prefix
, regname (reg
, 0));
4589 if (*reg_prefix
== '\0')
4591 fc
->col_type
[reg
] = cie
->col_type
[reg
];
4592 fc
->col_offset
[reg
] = cie
->col_offset
[reg
];
4596 case DW_CFA_undefined
:
4598 if (reg
>= (unsigned int) fc
->ncols
)
4599 reg_prefix
= bad_reg
;
4600 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4601 printf (" DW_CFA_undefined: %s%s\n",
4602 reg_prefix
, regname (reg
, 0));
4603 if (*reg_prefix
== '\0')
4605 fc
->col_type
[reg
] = DW_CFA_undefined
;
4606 fc
->col_offset
[reg
] = 0;
4610 case DW_CFA_same_value
:
4612 if (reg
>= (unsigned int) fc
->ncols
)
4613 reg_prefix
= bad_reg
;
4614 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4615 printf (" DW_CFA_same_value: %s%s\n",
4616 reg_prefix
, regname (reg
, 0));
4617 if (*reg_prefix
== '\0')
4619 fc
->col_type
[reg
] = DW_CFA_same_value
;
4620 fc
->col_offset
[reg
] = 0;
4624 case DW_CFA_register
:
4627 if (reg
>= (unsigned int) fc
->ncols
)
4628 reg_prefix
= bad_reg
;
4629 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4631 printf (" DW_CFA_register: %s%s in ",
4632 reg_prefix
, regname (reg
, 0));
4633 puts (regname (roffs
, 0));
4635 if (*reg_prefix
== '\0')
4637 fc
->col_type
[reg
] = DW_CFA_register
;
4638 fc
->col_offset
[reg
] = roffs
;
4642 case DW_CFA_remember_state
:
4643 if (! do_debug_frames_interp
)
4644 printf (" DW_CFA_remember_state\n");
4645 rs
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
4646 rs
->ncols
= fc
->ncols
;
4647 rs
->col_type
= (short int *) xcmalloc (rs
->ncols
,
4648 sizeof (short int));
4649 rs
->col_offset
= (int *) xcmalloc (rs
->ncols
, sizeof (int));
4650 memcpy (rs
->col_type
, fc
->col_type
, rs
->ncols
);
4651 memcpy (rs
->col_offset
, fc
->col_offset
, rs
->ncols
* sizeof (int));
4652 rs
->next
= remembered_state
;
4653 remembered_state
= rs
;
4656 case DW_CFA_restore_state
:
4657 if (! do_debug_frames_interp
)
4658 printf (" DW_CFA_restore_state\n");
4659 rs
= remembered_state
;
4662 remembered_state
= rs
->next
;
4663 frame_need_space (fc
, rs
->ncols
- 1);
4664 memcpy (fc
->col_type
, rs
->col_type
, rs
->ncols
);
4665 memcpy (fc
->col_offset
, rs
->col_offset
,
4666 rs
->ncols
* sizeof (int));
4667 free (rs
->col_type
);
4668 free (rs
->col_offset
);
4671 else if (do_debug_frames_interp
)
4672 printf ("Mismatched DW_CFA_restore_state\n");
4675 case DW_CFA_def_cfa
:
4676 fc
->cfa_reg
= LEB ();
4677 fc
->cfa_offset
= LEB ();
4679 if (! do_debug_frames_interp
)
4680 printf (" DW_CFA_def_cfa: %s ofs %d\n",
4681 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
4684 case DW_CFA_def_cfa_register
:
4685 fc
->cfa_reg
= LEB ();
4687 if (! do_debug_frames_interp
)
4688 printf (" DW_CFA_def_cfa_register: %s\n",
4689 regname (fc
->cfa_reg
, 0));
4692 case DW_CFA_def_cfa_offset
:
4693 fc
->cfa_offset
= LEB ();
4694 if (! do_debug_frames_interp
)
4695 printf (" DW_CFA_def_cfa_offset: %d\n", fc
->cfa_offset
);
4699 if (! do_debug_frames_interp
)
4700 printf (" DW_CFA_nop\n");
4703 case DW_CFA_def_cfa_expression
:
4705 if (! do_debug_frames_interp
)
4707 printf (" DW_CFA_def_cfa_expression (");
4708 decode_location_expression (start
, eh_addr_size
, 0, -1,
4716 case DW_CFA_expression
:
4719 if (reg
>= (unsigned int) fc
->ncols
)
4720 reg_prefix
= bad_reg
;
4721 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4723 printf (" DW_CFA_expression: %s%s (",
4724 reg_prefix
, regname (reg
, 0));
4725 decode_location_expression (start
, eh_addr_size
, 0, -1,
4729 if (*reg_prefix
== '\0')
4730 fc
->col_type
[reg
] = DW_CFA_expression
;
4734 case DW_CFA_val_expression
:
4737 if (reg
>= (unsigned int) fc
->ncols
)
4738 reg_prefix
= bad_reg
;
4739 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4741 printf (" DW_CFA_val_expression: %s%s (",
4742 reg_prefix
, regname (reg
, 0));
4743 decode_location_expression (start
, eh_addr_size
, 0, -1,
4747 if (*reg_prefix
== '\0')
4748 fc
->col_type
[reg
] = DW_CFA_val_expression
;
4752 case DW_CFA_offset_extended_sf
:
4755 if (frame_need_space (fc
, reg
) < 0)
4756 reg_prefix
= bad_reg
;
4757 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4758 printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n",
4759 reg_prefix
, regname (reg
, 0),
4760 l
* fc
->data_factor
);
4761 if (*reg_prefix
== '\0')
4763 fc
->col_type
[reg
] = DW_CFA_offset
;
4764 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
4768 case DW_CFA_val_offset_sf
:
4771 if (frame_need_space (fc
, reg
) < 0)
4772 reg_prefix
= bad_reg
;
4773 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4774 printf (" DW_CFA_val_offset_sf: %s%s at cfa%+ld\n",
4775 reg_prefix
, regname (reg
, 0),
4776 l
* fc
->data_factor
);
4777 if (*reg_prefix
== '\0')
4779 fc
->col_type
[reg
] = DW_CFA_val_offset
;
4780 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
4784 case DW_CFA_def_cfa_sf
:
4785 fc
->cfa_reg
= LEB ();
4786 fc
->cfa_offset
= SLEB ();
4787 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
4789 if (! do_debug_frames_interp
)
4790 printf (" DW_CFA_def_cfa_sf: %s ofs %d\n",
4791 regname (fc
->cfa_reg
, 0), fc
->cfa_offset
);
4794 case DW_CFA_def_cfa_offset_sf
:
4795 fc
->cfa_offset
= SLEB ();
4796 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
4797 if (! do_debug_frames_interp
)
4798 printf (" DW_CFA_def_cfa_offset_sf: %d\n", fc
->cfa_offset
);
4801 case DW_CFA_MIPS_advance_loc8
:
4802 ofs
= byte_get (start
, 8); start
+= 8;
4803 if (do_debug_frames_interp
)
4804 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4806 printf (" DW_CFA_MIPS_advance_loc8: %ld to %08lx\n",
4807 ofs
* fc
->code_factor
,
4808 fc
->pc_begin
+ ofs
* fc
->code_factor
);
4809 fc
->pc_begin
+= ofs
* fc
->code_factor
;
4812 case DW_CFA_GNU_window_save
:
4813 if (! do_debug_frames_interp
)
4814 printf (" DW_CFA_GNU_window_save\n");
4817 case DW_CFA_GNU_args_size
:
4819 if (! do_debug_frames_interp
)
4820 printf (" DW_CFA_GNU_args_size: %ld\n", ul
);
4823 case DW_CFA_GNU_negative_offset_extended
:
4826 if (frame_need_space (fc
, reg
) < 0)
4827 reg_prefix
= bad_reg
;
4828 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
4829 printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n",
4830 reg_prefix
, regname (reg
, 0),
4831 l
* fc
->data_factor
);
4832 if (*reg_prefix
== '\0')
4834 fc
->col_type
[reg
] = DW_CFA_offset
;
4835 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
4840 if (op
>= DW_CFA_lo_user
&& op
<= DW_CFA_hi_user
)
4841 printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op
);
4843 warn (_("unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op
);
4848 if (do_debug_frames_interp
)
4849 frame_display_row (fc
, &need_col_headers
, &max_regs
);
4852 eh_addr_size
= saved_eh_addr_size
;
4865 display_debug_not_supported (struct dwarf_section
*section
,
4866 void *file ATTRIBUTE_UNUSED
)
4868 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
4875 cmalloc (size_t nmemb
, size_t size
)
4877 /* Check for overflow. */
4878 if (nmemb
>= ~(size_t) 0 / size
)
4881 return malloc (nmemb
* size
);
4885 xcmalloc (size_t nmemb
, size_t size
)
4887 /* Check for overflow. */
4888 if (nmemb
>= ~(size_t) 0 / size
)
4891 return xmalloc (nmemb
* size
);
4895 xcrealloc (void *ptr
, size_t nmemb
, size_t size
)
4897 /* Check for overflow. */
4898 if (nmemb
>= ~(size_t) 0 / size
)
4901 return xrealloc (ptr
, nmemb
* size
);
4905 free_debug_memory (void)
4911 for (i
= 0; i
< max
; i
++)
4912 free_debug_section ((enum dwarf_section_display_enum
) i
);
4914 if (debug_information
!= NULL
)
4916 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
)
4918 for (i
= 0; i
< num_debug_info_entries
; i
++)
4920 if (!debug_information
[i
].max_loc_offsets
)
4922 free (debug_information
[i
].loc_offsets
);
4923 free (debug_information
[i
].have_frame_base
);
4925 if (!debug_information
[i
].max_range_lists
)
4926 free (debug_information
[i
].range_lists
);
4930 free (debug_information
);
4931 debug_information
= NULL
;
4932 num_debug_info_entries
= 0;
4937 dwarf_select_sections_by_names (const char *names
)
4941 const char * option
;
4945 debug_dump_long_opts
;
4947 static const debug_dump_long_opts opts_table
[] =
4949 /* Please keep this table alpha- sorted. */
4950 { "Ranges", & do_debug_ranges
, 1 },
4951 { "abbrev", & do_debug_abbrevs
, 1 },
4952 { "aranges", & do_debug_aranges
, 1 },
4953 { "frames", & do_debug_frames
, 1 },
4954 { "frames-interp", & do_debug_frames_interp
, 1 },
4955 { "info", & do_debug_info
, 1 },
4956 { "line", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
}, /* For backwards compatibility. */
4957 { "rawline", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
},
4958 { "decodedline", & do_debug_lines
, FLAG_DEBUG_LINES_DECODED
},
4959 { "loc", & do_debug_loc
, 1 },
4960 { "macro", & do_debug_macinfo
, 1 },
4961 { "pubnames", & do_debug_pubnames
, 1 },
4962 { "pubtypes", & do_debug_pubtypes
, 1 },
4963 /* This entry is for compatability
4964 with earlier versions of readelf. */
4965 { "ranges", & do_debug_aranges
, 1 },
4966 { "str", & do_debug_str
, 1 },
4967 /* These trace_* sections are used by Itanium VMS. */
4968 { "trace_abbrev", & do_trace_abbrevs
, 1 },
4969 { "trace_aranges", & do_trace_aranges
, 1 },
4970 { "trace_info", & do_trace_info
, 1 },
4979 const debug_dump_long_opts
* entry
;
4981 for (entry
= opts_table
; entry
->option
; entry
++)
4983 size_t len
= strlen (entry
->option
);
4985 if (strncmp (p
, entry
->option
, len
) == 0
4986 && (p
[len
] == ',' || p
[len
] == '\0'))
4988 * entry
->variable
|= entry
->val
;
4990 /* The --debug-dump=frames-interp option also
4991 enables the --debug-dump=frames option. */
4992 if (do_debug_frames_interp
)
4993 do_debug_frames
= 1;
5000 if (entry
->option
== NULL
)
5002 warn (_("Unrecognized debug option '%s'\n"), p
);
5003 p
= strchr (p
, ',');
5014 dwarf_select_sections_by_letters (const char *letters
)
5016 unsigned int lindex
= 0;
5018 while (letters
[lindex
])
5019 switch (letters
[lindex
++])
5026 do_debug_abbrevs
= 1;
5030 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
5034 do_debug_lines
|= FLAG_DEBUG_LINES_DECODED
;
5038 do_debug_pubnames
= 1;
5042 do_debug_pubtypes
= 1;
5046 do_debug_aranges
= 1;
5050 do_debug_ranges
= 1;
5054 do_debug_frames_interp
= 1;
5056 do_debug_frames
= 1;
5060 do_debug_macinfo
= 1;
5072 warn (_("Unrecognized debug option '%s'\n"), optarg
);
5078 dwarf_select_sections_all (void)
5081 do_debug_abbrevs
= 1;
5082 do_debug_lines
= FLAG_DEBUG_LINES_RAW
;
5083 do_debug_pubnames
= 1;
5084 do_debug_pubtypes
= 1;
5085 do_debug_aranges
= 1;
5086 do_debug_ranges
= 1;
5087 do_debug_frames
= 1;
5088 do_debug_macinfo
= 1;
5092 do_trace_abbrevs
= 1;
5093 do_trace_aranges
= 1;
5096 struct dwarf_section_display debug_displays
[] =
5098 { { ".debug_abbrev", ".zdebug_abbrev", NULL
, NULL
, 0, 0 },
5099 display_debug_abbrev
, &do_debug_abbrevs
, 0 },
5100 { { ".debug_aranges", ".zdebug_aranges", NULL
, NULL
, 0, 0 },
5101 display_debug_aranges
, &do_debug_aranges
, 1 },
5102 { { ".debug_frame", ".zdebug_frame", NULL
, NULL
, 0, 0 },
5103 display_debug_frames
, &do_debug_frames
, 1 },
5104 { { ".debug_info", ".zdebug_info", NULL
, NULL
, 0, 0 },
5105 display_debug_info
, &do_debug_info
, 1 },
5106 { { ".debug_line", ".zdebug_line", NULL
, NULL
, 0, 0 },
5107 display_debug_lines
, &do_debug_lines
, 1 },
5108 { { ".debug_pubnames", ".zdebug_pubnames", NULL
, NULL
, 0, 0 },
5109 display_debug_pubnames
, &do_debug_pubnames
, 0 },
5110 { { ".eh_frame", "", NULL
, NULL
, 0, 0 },
5111 display_debug_frames
, &do_debug_frames
, 1 },
5112 { { ".debug_macinfo", ".zdebug_macinfo", NULL
, NULL
, 0, 0 },
5113 display_debug_macinfo
, &do_debug_macinfo
, 0 },
5114 { { ".debug_str", ".zdebug_str", NULL
, NULL
, 0, 0 },
5115 display_debug_str
, &do_debug_str
, 0 },
5116 { { ".debug_loc", ".zdebug_loc", NULL
, NULL
, 0, 0 },
5117 display_debug_loc
, &do_debug_loc
, 1 },
5118 { { ".debug_pubtypes", ".zdebug_pubtypes", NULL
, NULL
, 0, 0 },
5119 display_debug_pubnames
, &do_debug_pubtypes
, 0 },
5120 { { ".debug_ranges", ".zdebug_ranges", NULL
, NULL
, 0, 0 },
5121 display_debug_ranges
, &do_debug_ranges
, 1 },
5122 { { ".debug_static_func", ".zdebug_static_func", NULL
, NULL
, 0, 0 },
5123 display_debug_not_supported
, NULL
, 0 },
5124 { { ".debug_static_vars", ".zdebug_static_vars", NULL
, NULL
, 0, 0 },
5125 display_debug_not_supported
, NULL
, 0 },
5126 { { ".debug_types", ".zdebug_types", NULL
, NULL
, 0, 0 },
5127 display_debug_types
, &do_debug_info
, 1 },
5128 { { ".debug_weaknames", ".zdebug_weaknames", NULL
, NULL
, 0, 0 },
5129 display_debug_not_supported
, NULL
, 0 },
5130 { { ".trace_info", "", NULL
, NULL
, 0, 0 },
5131 display_trace_info
, &do_trace_info
, 1 },
5132 { { ".trace_abbrev", "", NULL
, NULL
, 0, 0 },
5133 display_debug_abbrev
, &do_trace_abbrevs
, 0 },
5134 { { ".trace_aranges", "", NULL
, NULL
, 0, 0 },
5135 display_debug_aranges
, &do_trace_aranges
, 0 }