/* dwarf.c -- display DWARF contents of a BFD binary file
- Copyright 2005, 2006, 2007, 2008, 2009
+ Copyright 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
This file is part of GNU Binutils.
#include "dwarf2.h"
#include "dwarf.h"
+static const char *regname (unsigned int regno, int row);
+
static int have_frame_base;
static int need_base_address;
int do_debug_macinfo;
int do_debug_str;
int do_debug_loc;
+int do_trace_info;
+int do_trace_abbrevs;
+int do_trace_aranges;
int do_wide;
/* Values for do_debug_lines. */
}
}
-static dwarf_vma
+dwarf_vma
byte_get_signed (unsigned char *field, int size)
{
dwarf_vma x = byte_get (field, size);
fputs (buff + (byte_size == 4 ? 8 : 0), stdout);
}
-static unsigned long int
+unsigned long int
read_leb128 (unsigned char *data, unsigned int *length_return, int sign)
{
unsigned long int result = 0;
unsigned int column;
int is_stmt;
int basic_block;
- int end_sequence;
+ unsigned char op_index;
+ unsigned char end_sequence;
/* This variable hold the number of the last entry seen
in the File Table. */
unsigned int last_file_entry;
reset_state_machine (int is_stmt)
{
state_machine_regs.address = 0;
+ state_machine_regs.op_index = 0;
state_machine_regs.file = 1;
state_machine_regs.line = 1;
state_machine_regs.column = 0;
adr = byte_get (data, len - bytes_read - 1);
printf (_("set Address to 0x%lx\n"), adr);
state_machine_regs.address = adr;
+ state_machine_regs.op_index = 0;
break;
case DW_LNE_define_file:
printf (_(" define new File Table entry\n"));
printf (_(" Entry\tDir\tTime\tSize\tName\n"));
- printf (_(" %d\t"), ++state_machine_regs.last_file_entry);
+ printf (" %d\t", ++state_machine_regs.last_file_entry);
name = data;
data += strlen ((char *) data) + 1;
- printf (_("%lu\t"), read_leb128 (data, & bytes_read, 0));
+ printf ("%lu\t", read_leb128 (data, & bytes_read, 0));
data += bytes_read;
- printf (_("%lu\t"), read_leb128 (data, & bytes_read, 0));
+ printf ("%lu\t", read_leb128 (data, & bytes_read, 0));
data += bytes_read;
- printf (_("%lu\t"), read_leb128 (data, & bytes_read, 0));
- printf (_("%s\n\n"), name);
+ printf ("%lu\t", read_leb128 (data, & bytes_read, 0));
+ printf ("%s\n\n", name);
break;
case DW_LNE_set_discriminator:
static int
decode_location_expression (unsigned char * data,
unsigned int pointer_size,
+ unsigned int offset_size,
+ int dwarf_version,
unsigned long length,
unsigned long cu_offset,
struct dwarf_section * section)
case DW_OP_reg29:
case DW_OP_reg30:
case DW_OP_reg31:
- printf ("DW_OP_reg%d", op - DW_OP_reg0);
+ printf ("DW_OP_reg%d (%s)", op - DW_OP_reg0,
+ regname (op - DW_OP_reg0, 1));
break;
case DW_OP_breg0:
case DW_OP_breg29:
case DW_OP_breg30:
case DW_OP_breg31:
- printf ("DW_OP_breg%d: %ld", op - DW_OP_breg0,
+ printf ("DW_OP_breg%d (%s): %ld", op - DW_OP_breg0,
+ regname (op - DW_OP_breg0, 1),
read_leb128 (data, &bytes_read, 1));
data += bytes_read;
break;
case DW_OP_regx:
- printf ("DW_OP_regx: %lu", read_leb128 (data, &bytes_read, 0));
+ uvalue = read_leb128 (data, &bytes_read, 0);
data += bytes_read;
+ printf ("DW_OP_regx: %lu (%s)", uvalue, regname (uvalue, 1));
break;
case DW_OP_fbreg:
need_frame_base = 1;
case DW_OP_bregx:
uvalue = read_leb128 (data, &bytes_read, 0);
data += bytes_read;
- printf ("DW_OP_bregx: %lu %ld", uvalue,
+ printf ("DW_OP_bregx: %lu (%s) %ld", uvalue, regname (uvalue, 1),
read_leb128 (data, &bytes_read, 1));
data += bytes_read;
break;
case DW_OP_call2:
/* XXX: Strictly speaking for 64-bit DWARF3 files
this ought to be an 8-byte wide computation. */
- printf ("DW_OP_call2: <%lx>", (long) byte_get (data, 2) + cu_offset);
+ printf ("DW_OP_call2: <0x%lx>", (long) byte_get (data, 2) + cu_offset);
data += 2;
break;
case DW_OP_call4:
/* XXX: Strictly speaking for 64-bit DWARF3 files
this ought to be an 8-byte wide computation. */
- printf ("DW_OP_call4: <%lx>", (long) byte_get (data, 4) + cu_offset);
+ printf ("DW_OP_call4: <0x%lx>", (long) byte_get (data, 4) + cu_offset);
data += 4;
break;
case DW_OP_call_ref:
/* XXX: Strictly speaking for 64-bit DWARF3 files
this ought to be an 8-byte wide computation. */
- printf ("DW_OP_call_ref: <%lx>", (long) byte_get (data, 4) + cu_offset);
- data += 4;
+ if (dwarf_version == -1)
+ {
+ printf (_("(DW_OP_call_ref in frame info)"));
+ /* No way to tell where the next op is, so just bail. */
+ return need_frame_base;
+ }
+ if (dwarf_version == 2)
+ {
+ printf ("DW_OP_call_ref: <0x%lx>",
+ (long) byte_get (data, pointer_size));
+ data += pointer_size;
+ }
+ else
+ {
+ printf ("DW_OP_call_ref: <0x%lx>",
+ (long) byte_get (data, offset_size));
+ data += offset_size;
+ }
break;
case DW_OP_form_tls_address:
printf ("DW_OP_form_tls_address");
print_dwarf_vma (addr, pointer_size);
}
break;
+ case DW_OP_GNU_implicit_pointer:
+ /* XXX: Strictly speaking for 64-bit DWARF3 files
+ this ought to be an 8-byte wide computation. */
+ if (dwarf_version == -1)
+ {
+ printf (_("(DW_OP_GNU_implicit_pointer in frame info)"));
+ /* No way to tell where the next op is, so just bail. */
+ return need_frame_base;
+ }
+ if (dwarf_version == 2)
+ {
+ printf ("DW_OP_GNU_implicit_pointer: <0x%lx> %ld",
+ (long) byte_get (data, pointer_size),
+ read_leb128 (data + pointer_size, &bytes_read, 1));
+ data += pointer_size + bytes_read;
+ }
+ else
+ {
+ printf ("DW_OP_GNU_implicit_pointer: <0x%lx> %ld",
+ (long) byte_get (data, offset_size),
+ read_leb128 (data + offset_size, &bytes_read, 1));
+ data += offset_size + bytes_read;
+ }
+ break;
/* HP extensions. */
case DW_OP_HP_is_value:
uvalue = byte_get (data, pointer_size);
data += pointer_size;
}
- else if (dwarf_version == 3)
+ else if (dwarf_version == 3 || dwarf_version == 4)
{
uvalue = byte_get (data, offset_size);
data += offset_size;
}
else
{
- error (_("Internal error: DWARF version is not 2 or 3.\n"));
+ error (_("Internal error: DWARF version is not 2, 3 or 4.\n"));
}
break;
break;
case DW_FORM_strp:
+ case DW_FORM_sec_offset:
uvalue = byte_get (data, offset_size);
data += offset_size;
break;
+ case DW_FORM_flag_present:
+ uvalue = 1;
+ break;
+
case DW_FORM_ref1:
case DW_FORM_flag:
case DW_FORM_data1:
case DW_FORM_data4:
case DW_FORM_addr:
+ case DW_FORM_sec_offset:
if (!do_loc)
printf (" 0x%lx", uvalue);
break;
+ case DW_FORM_flag_present:
case DW_FORM_flag:
case DW_FORM_data1:
case DW_FORM_data2:
break;
case DW_FORM_block:
+ case DW_FORM_exprloc:
uvalue = read_leb128 (data, & bytes_read, 0);
block_start = data + bytes_read;
if (do_loc)
case DW_AT_segment:
case DW_AT_static_link:
case DW_AT_use_location:
- if (form == DW_FORM_data4 || form == DW_FORM_data8)
+ if (form == DW_FORM_data4
+ || form == DW_FORM_data8
+ || form == DW_FORM_sec_offset)
{
/* Process location list. */
unsigned int lmax = debug_info_p->max_loc_offsets;
break;
case DW_AT_ranges:
- if (form == DW_FORM_data4 || form == DW_FORM_data8)
+ if (form == DW_FORM_data4
+ || form == DW_FORM_data8
+ || form == DW_FORM_sec_offset)
{
/* Process range list. */
unsigned int lmax = debug_info_p->max_range_lists;
case DW_AT_segment:
case DW_AT_static_link:
case DW_AT_use_location:
- if (form == DW_FORM_data4 || form == DW_FORM_data8)
+ if (form == DW_FORM_data4
+ || form == DW_FORM_data8
+ || form == DW_FORM_sec_offset)
printf (_("(location list)"));
/* Fall through. */
case DW_AT_allocated:
printf ("(");
need_frame_base = decode_location_expression (block_start,
pointer_size,
+ offset_size,
+ dwarf_version,
uvalue,
cu_offset, section);
printf (")");
static int
process_debug_info (struct dwarf_section *section,
void *file,
+ enum dwarf_section_display_enum abbrev_sec,
int do_loc,
int do_types)
{
load_debug_section (str, file);
}
- load_debug_section (abbrev, file);
- if (debug_displays [abbrev].section.start == NULL)
+ load_debug_section (abbrev_sec, file);
+ if (debug_displays [abbrev_sec].section.start == NULL)
{
warn (_("Unable to locate %s section!\n"),
- debug_displays [abbrev].section.name);
+ debug_displays [abbrev_sec].section.name);
return 0;
}
{
DWARF2_Internal_CompUnit compunit;
unsigned char *hdrptr;
- unsigned char *cu_abbrev_offset_ptr;
unsigned char *tags;
int level;
unsigned long cu_offset;
int offset_size;
int initial_length_size;
- unsigned char signature[8];
+ unsigned char signature[8] = { 0 };
unsigned long type_offset = 0;
hdrptr = start;
cu_offset = start - section_begin;
- cu_abbrev_offset_ptr = hdrptr;
compunit.cu_abbrev_offset = byte_get (hdrptr, offset_size);
hdrptr += offset_size;
debug_information [unit].cu_offset = cu_offset;
debug_information [unit].pointer_size
= compunit.cu_pointer_size;
+ debug_information [unit].offset_size = offset_size;
+ debug_information [unit].dwarf_version = compunit.cu_version;
debug_information [unit].base_address = 0;
debug_information [unit].loc_offsets = NULL;
debug_information [unit].have_frame_base = NULL;
tags = hdrptr;
start += compunit.cu_length + initial_length_size;
- if (compunit.cu_version != 2 && compunit.cu_version != 3)
+ if (compunit.cu_version != 2
+ && compunit.cu_version != 3
+ && compunit.cu_version != 4)
{
warn (_("CU at offset %lx contains corrupt or unsupported version number: %d.\n"),
cu_offset, compunit.cu_version);
/* Process the abbrevs used by this compilation unit. DWARF
sections under Mach-O have non-zero addresses. */
- if (compunit.cu_abbrev_offset >= debug_displays [abbrev].section.size)
+ if (compunit.cu_abbrev_offset >= debug_displays [abbrev_sec].section.size)
warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"),
(unsigned long) compunit.cu_abbrev_offset,
- (unsigned long) debug_displays [abbrev].section.size);
+ (unsigned long) debug_displays [abbrev_sec].section.size);
else
process_abbrev_section
- ((unsigned char *) debug_displays [abbrev].section.start
- + compunit.cu_abbrev_offset - debug_displays [abbrev].section.address,
- (unsigned char *) debug_displays [abbrev].section.start
- + debug_displays [abbrev].section.size);
+ ((unsigned char *) debug_displays [abbrev_sec].section.start
+ + compunit.cu_abbrev_offset,
+ (unsigned char *) debug_displays [abbrev_sec].section.start
+ + debug_displays [abbrev_sec].section.size);
level = 0;
while (tags < start)
}
if (!do_loc)
- printf (_(" (%s)\n"), get_TAG_name (entry->tag));
+ printf (" (%s)\n", get_TAG_name (entry->tag));
switch (entry->tag)
{
return num_debug_info_entries;
if (load_debug_section (info, file)
- && process_debug_info (&debug_displays [info].section, file, 1, 0))
+ && process_debug_info (&debug_displays [info].section, file, abbrev, 1, 0))
return num_debug_info_entries;
num_debug_info_entries = DEBUG_INFO_UNAVAILABLE;
/* Check its version number. */
linfo.li_version = byte_get (hdrptr, 2);
hdrptr += 2;
- if (linfo.li_version != 2 && linfo.li_version != 3)
+ if (linfo.li_version != 2
+ && linfo.li_version != 3
+ && linfo.li_version != 4)
{
- warn (_("Only DWARF version 2 and 3 line info is currently supported.\n"));
+ warn (_("Only DWARF version 2, 3 and 4 line info is currently supported.\n"));
return 0;
}
hdrptr += offset_size;
linfo.li_min_insn_length = byte_get (hdrptr, 1);
hdrptr++;
+ if (linfo.li_version >= 4)
+ {
+ linfo.li_max_ops_per_insn = byte_get (hdrptr, 1);
+ hdrptr++;
+ if (linfo.li_max_ops_per_insn == 0)
+ {
+ warn (_("Invalid maximum operations per insn.\n"));
+ return 0;
+ }
+ }
+ else
+ linfo.li_max_ops_per_insn = 1;
linfo.li_default_is_stmt = byte_get (hdrptr, 1);
hdrptr++;
linfo.li_line_base = byte_get (hdrptr, 1);
printf (_(" DWARF Version: %d\n"), linfo.li_version);
printf (_(" Prologue Length: %d\n"), linfo.li_prologue_length);
printf (_(" Minimum Instruction Length: %d\n"), linfo.li_min_insn_length);
+ if (linfo.li_version >= 4)
+ printf (_(" Maximum Ops per Instruction: %d\n"), linfo.li_max_ops_per_insn);
printf (_(" Initial value of 'is_stmt': %d\n"), linfo.li_default_is_stmt);
printf (_(" Line Base: %d\n"), linfo.li_line_base);
printf (_(" Line Range: %d\n"), linfo.li_line_range);
while (*data != 0)
{
- printf (_(" %s\n"), data);
+ printf (" %s\n", data);
data += strlen ((char *) data) + 1;
}
unsigned char *name;
unsigned int bytes_read;
- printf (_(" %d\t"), ++state_machine_regs.last_file_entry);
+ printf (" %d\t", ++state_machine_regs.last_file_entry);
name = data;
data += strlen ((char *) data) + 1;
- printf (_("%lu\t"), read_leb128 (data, & bytes_read, 0));
+ printf ("%lu\t", read_leb128 (data, & bytes_read, 0));
data += bytes_read;
- printf (_("%lu\t"), read_leb128 (data, & bytes_read, 0));
+ printf ("%lu\t", read_leb128 (data, & bytes_read, 0));
data += bytes_read;
- printf (_("%lu\t"), read_leb128 (data, & bytes_read, 0));
+ printf ("%lu\t", read_leb128 (data, & bytes_read, 0));
data += bytes_read;
- printf (_("%s\n"), name);
+ printf ("%s\n", name);
}
}
if (op_code >= linfo.li_opcode_base)
{
op_code -= linfo.li_opcode_base;
- uladv = (op_code / linfo.li_line_range) * linfo.li_min_insn_length;
- state_machine_regs.address += uladv;
- printf (_(" Special opcode %d: advance Address by %lu to 0x%lx"),
- op_code, uladv, state_machine_regs.address);
+ uladv = (op_code / linfo.li_line_range);
+ if (linfo.li_max_ops_per_insn == 1)
+ {
+ uladv *= linfo.li_min_insn_length;
+ state_machine_regs.address += uladv;
+ printf (_(" Special opcode %d: advance Address by %lu to 0x%lx"),
+ op_code, uladv, state_machine_regs.address);
+ }
+ else
+ {
+ state_machine_regs.address
+ += ((state_machine_regs.op_index + uladv)
+ / linfo.li_max_ops_per_insn)
+ * linfo.li_min_insn_length;
+ state_machine_regs.op_index
+ = (state_machine_regs.op_index + uladv)
+ % linfo.li_max_ops_per_insn;
+ printf (_(" Special opcode %d: advance Address by %lu to 0x%lx[%d]"),
+ op_code, uladv, state_machine_regs.address,
+ state_machine_regs.op_index);
+ }
adv = (op_code % linfo.li_line_range) + linfo.li_line_base;
state_machine_regs.line += adv;
printf (_(" and Line by %d to %d\n"),
case DW_LNS_advance_pc:
uladv = read_leb128 (data, & bytes_read, 0);
- uladv *= linfo.li_min_insn_length;
data += bytes_read;
- state_machine_regs.address += uladv;
- printf (_(" Advance PC by %lu to 0x%lx\n"), uladv,
- state_machine_regs.address);
+ if (linfo.li_max_ops_per_insn == 1)
+ {
+ uladv *= linfo.li_min_insn_length;
+ state_machine_regs.address += uladv;
+ printf (_(" Advance PC by %lu to 0x%lx\n"), uladv,
+ state_machine_regs.address);
+ }
+ else
+ {
+ state_machine_regs.address
+ += ((state_machine_regs.op_index + uladv)
+ / linfo.li_max_ops_per_insn)
+ * linfo.li_min_insn_length;
+ state_machine_regs.op_index
+ = (state_machine_regs.op_index + uladv)
+ % linfo.li_max_ops_per_insn;
+ printf (_(" Advance PC by %lu to 0x%lx[%d]\n"), uladv,
+ state_machine_regs.address,
+ state_machine_regs.op_index);
+ }
break;
case DW_LNS_advance_line:
break;
case DW_LNS_const_add_pc:
- uladv = (((255 - linfo.li_opcode_base) / linfo.li_line_range)
- * linfo.li_min_insn_length);
- state_machine_regs.address += uladv;
- printf (_(" Advance PC by constant %lu to 0x%lx\n"), uladv,
- state_machine_regs.address);
+ uladv = ((255 - linfo.li_opcode_base) / linfo.li_line_range);
+ if (linfo.li_max_ops_per_insn)
+ {
+ uladv *= linfo.li_min_insn_length;
+ state_machine_regs.address += uladv;
+ printf (_(" Advance PC by constant %lu to 0x%lx\n"), uladv,
+ state_machine_regs.address);
+ }
+ else
+ {
+ state_machine_regs.address
+ += ((state_machine_regs.op_index + uladv)
+ / linfo.li_max_ops_per_insn)
+ * linfo.li_min_insn_length;
+ state_machine_regs.op_index
+ = (state_machine_regs.op_index + uladv)
+ % linfo.li_max_ops_per_insn;
+ printf (_(" Advance PC by constant %lu to 0x%lx[%d]\n"),
+ uladv, state_machine_regs.address,
+ state_machine_regs.op_index);
+ }
break;
case DW_LNS_fixed_advance_pc:
uladv = byte_get (data, 2);
data += 2;
state_machine_regs.address += uladv;
+ state_machine_regs.op_index = 0;
printf (_(" Advance PC by fixed size amount %lu to 0x%lx\n"),
uladv, state_machine_regs.address);
break;
int i;
File_Entry *file_table = NULL;
unsigned char **directory_table = NULL;
- unsigned int prev_line = 0;
hdrptr = data;
/* Get this CU's Line Number Block version number. */
linfo.li_version = byte_get (hdrptr, 2);
hdrptr += 2;
- if (linfo.li_version != 2 && linfo.li_version != 3)
+ if (linfo.li_version != 2
+ && linfo.li_version != 3
+ && linfo.li_version != 4)
{
- warn (_("Only DWARF version 2 and 3 line info is currently "
+ warn (_("Only DWARF version 2, 3 and 4 line info is currently "
"supported.\n"));
return 0;
}
hdrptr += offset_size;
linfo.li_min_insn_length = byte_get (hdrptr, 1);
hdrptr++;
+ if (linfo.li_version >= 4)
+ {
+ linfo.li_max_ops_per_insn = byte_get (hdrptr, 1);
+ hdrptr++;
+ if (linfo.li_max_ops_per_insn == 0)
+ {
+ warn (_("Invalid maximum operations per insn.\n"));
+ return 0;
+ }
+ }
+ else
+ linfo.li_max_ops_per_insn = 1;
linfo.li_default_is_stmt = byte_get (hdrptr, 1);
hdrptr++;
linfo.li_line_base = byte_get (hdrptr, 1);
else
{
if (do_wide || strlen ((char *) directory_table[0]) < 76)
- {
- printf (_("CU: %s/%s:\n"), directory_table[0],
- file_table[0].name);
- }
+ printf (_("CU: %s/%s:\n"), directory_table[0],
+ file_table[0].name);
else
- {
- printf (_("%s:\n"), file_table[0].name);
- }
+ printf ("%s:\n", file_table[0].name);
+
printf (_("File name Line number Starting address\n"));
}
}
int is_special_opcode = 0;
op_code = *data++;
- prev_line = state_machine_regs.line;
if (op_code >= linfo.li_opcode_base)
{
op_code -= linfo.li_opcode_base;
- uladv = (op_code / linfo.li_line_range) * linfo.li_min_insn_length;
- state_machine_regs.address += uladv;
+ uladv = (op_code / linfo.li_line_range);
+ if (linfo.li_max_ops_per_insn == 1)
+ {
+ uladv *= linfo.li_min_insn_length;
+ state_machine_regs.address += uladv;
+ }
+ else
+ {
+ state_machine_regs.address
+ += ((state_machine_regs.op_index + uladv)
+ / linfo.li_max_ops_per_insn)
+ * linfo.li_min_insn_length;
+ state_machine_regs.op_index
+ = (state_machine_regs.op_index + uladv)
+ % linfo.li_max_ops_per_insn;
+ }
adv = (op_code % linfo.li_line_range) + linfo.li_line_base;
state_machine_regs.line += adv;
case DW_LNE_set_address:
state_machine_regs.address =
byte_get (op_code_data, ext_op_code_len - bytes_read - 1);
+ state_machine_regs.op_index = 0;
break;
case DW_LNE_define_file:
{
op_code_data += bytes_read;
read_leb128 (op_code_data, & bytes_read, 0);
- printf (_("%s:\n"), directory_table[dir_index]);
+ printf ("%s:\n", directory_table[dir_index]);
break;
}
default:
case DW_LNS_advance_pc:
uladv = read_leb128 (data, & bytes_read, 0);
- uladv *= linfo.li_min_insn_length;
data += bytes_read;
- state_machine_regs.address += uladv;
+ if (linfo.li_max_ops_per_insn == 1)
+ {
+ uladv *= linfo.li_min_insn_length;
+ state_machine_regs.address += uladv;
+ }
+ else
+ {
+ state_machine_regs.address
+ += ((state_machine_regs.op_index + uladv)
+ / linfo.li_max_ops_per_insn)
+ * linfo.li_min_insn_length;
+ state_machine_regs.op_index
+ = (state_machine_regs.op_index + uladv)
+ % linfo.li_max_ops_per_insn;
+ }
break;
case DW_LNS_advance_line:
if (file_table[state_machine_regs.file - 1].directory_index == 0)
{
/* If directory index is 0, that means current directory. */
- printf (_("\n./%s:[++]\n"),
+ printf ("\n./%s:[++]\n",
file_table[state_machine_regs.file - 1].name);
}
else
{
/* The directory index starts counting at 1. */
- printf (_("\n%s/%s:\n"),
+ printf ("\n%s/%s:\n",
directory_table[file_table[state_machine_regs.file - 1].directory_index - 1],
file_table[state_machine_regs.file - 1].name);
}
break;
case DW_LNS_const_add_pc:
- uladv = (((255 - linfo.li_opcode_base) / linfo.li_line_range)
- * linfo.li_min_insn_length);
- state_machine_regs.address += uladv;
+ uladv = ((255 - linfo.li_opcode_base) / linfo.li_line_range);
+ if (linfo.li_max_ops_per_insn == 1)
+ {
+ uladv *= linfo.li_min_insn_length;
+ state_machine_regs.address += uladv;
+ }
+ else
+ {
+ state_machine_regs.address
+ += ((state_machine_regs.op_index + uladv)
+ / linfo.li_max_ops_per_insn)
+ * linfo.li_min_insn_length;
+ state_machine_regs.op_index
+ = (state_machine_regs.op_index + uladv)
+ % linfo.li_max_ops_per_insn;
+ }
break;
case DW_LNS_fixed_advance_pc:
uladv = byte_get (data, 2);
data += 2;
state_machine_regs.address += uladv;
+ state_machine_regs.op_index = 0;
break;
case DW_LNS_set_prologue_end:
if (!do_wide || (fileNameLength <= MAX_FILENAME_LENGTH))
{
- printf (_("%-35s %11d %#18lx\n"), newFileName,
- state_machine_regs.line, state_machine_regs.address);
+ if (linfo.li_max_ops_per_insn == 1)
+ printf ("%-35s %11d %#18lx\n", newFileName,
+ state_machine_regs.line,
+ state_machine_regs.address);
+ else
+ printf ("%-35s %11d %#18lx[%d]\n", newFileName,
+ state_machine_regs.line,
+ state_machine_regs.address,
+ state_machine_regs.op_index);
}
else
{
- printf (_("%s %11d %#18lx\n"), newFileName,
- state_machine_regs.line, state_machine_regs.address);
+ if (linfo.li_max_ops_per_insn == 1)
+ printf ("%s %11d %#18lx\n", newFileName,
+ state_machine_regs.line,
+ state_machine_regs.address);
+ else
+ printf ("%s %11d %#18lx[%d]\n", newFileName,
+ state_machine_regs.line,
+ state_machine_regs.address,
+ state_machine_regs.op_index);
}
if (op_code == DW_LNE_end_sequence)
}
static int
-display_debug_lines (struct dwarf_section *section, void *file)
+display_debug_lines (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED)
{
unsigned char *data = section->start;
unsigned char *end = data + section->size;
int retValRaw = 1;
int retValDecoded = 1;
- if (load_debug_info (file) == 0)
- {
- warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
- section->name);
- return 0;
- }
-
if (do_debug_lines == 0)
do_debug_lines |= FLAG_DEBUG_LINES_RAW;
{
abbrev_attr *attr;
- printf (_(" %ld %s [%s]\n"),
+ printf (" %ld %s [%s]\n",
entry->entry,
get_TAG_name (entry->tag),
entry->children ? _("has children") : _("no children"));
for (attr = entry->first_attr; attr; attr = attr->next)
- printf (_(" %-18s %s\n"),
+ printf (" %-18s %s\n",
get_AT_name (attr->attribute),
get_FORM_name (attr->form));
}
unsigned short length;
unsigned long offset;
unsigned int pointer_size;
+ unsigned int offset_size;
+ int dwarf_version;
unsigned long cu_offset;
unsigned long base_address;
int need_frame_base;
pointer_size = debug_information [i].pointer_size;
cu_offset = debug_information [i].cu_offset;
+ offset_size = debug_information [i].offset_size;
+ dwarf_version = debug_information [i].dwarf_version;
for (j = 0; j < debug_information [i].num_loc_offsets; j++)
{
putchar ('(');
need_frame_base = decode_location_expression (start,
pointer_size,
+ offset_size,
+ dwarf_version,
length,
cu_offset, section);
putchar (')');
static int
display_debug_info (struct dwarf_section *section, void *file)
{
- return process_debug_info (section, file, 0, 0);
+ return process_debug_info (section, file, abbrev, 0, 0);
}
static int
display_debug_types (struct dwarf_section *section, void *file)
{
- return process_debug_info (section, file, 0, 1);
+ return process_debug_info (section, file, abbrev, 0, 1);
+}
+
+static int
+display_trace_info (struct dwarf_section *section, void *file)
+{
+ return process_debug_info (section, file, trace_abbrev, 0, 0);
}
static int
void *file ATTRIBUTE_UNUSED)
{
unsigned char *start = section->start;
- unsigned char *section_end;
unsigned long bytes;
unsigned char *section_begin = start;
unsigned int num_range_list, i;
struct range_entry *range_entries, *range_entry_fill;
bytes = section->size;
- section_end = start + bytes;
if (bytes == 0)
{
int ra;
unsigned char fde_encoding;
unsigned char cfa_exp;
+ unsigned char ptr_size;
+ unsigned char segment_size;
}
Frame_Chunk;
"tr", "ldtr"
};
+void
+init_dwarf_regnames_i386 (void)
+{
+ dwarf_regnames = dwarf_regnames_i386;
+ dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_i386);
+}
+
static const char *const dwarf_regnames_x86_64[] =
{
"rax", "rdx", "rcx", "rbx",
"mxcsr", "fcw", "fsw"
};
+void
+init_dwarf_regnames_x86_64 (void)
+{
+ dwarf_regnames = dwarf_regnames_x86_64;
+ dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_x86_64);
+}
+
void
init_dwarf_regnames (unsigned int e_machine)
{
{
case EM_386:
case EM_486:
- dwarf_regnames = dwarf_regnames_i386;
- dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_i386);
+ init_dwarf_regnames_i386 ();
break;
case EM_X86_64:
- dwarf_regnames = dwarf_regnames_x86_64;
- dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_x86_64);
+ case EM_L1OM:
+ init_dwarf_regnames_x86_64 ();
break;
default:
unsigned int length_return;
int max_regs = 0;
const char *bad_reg = _("bad register: ");
+ int saved_eh_addr_size = eh_addr_size;
printf (_("Contents of the %s section:\n"), section->name);
int need_col_headers = 1;
unsigned char *augmentation_data = NULL;
unsigned long augmentation_data_len = 0;
- int encoded_ptr_size = eh_addr_size;
+ int encoded_ptr_size = saved_eh_addr_size;
int offset_size;
int initial_length_size;
fc->augmentation = (char *) start;
start = (unsigned char *) strchr ((char *) start, '\0') + 1;
- if (fc->augmentation[0] == 'z')
+ if (strcmp (fc->augmentation, "eh") == 0)
+ start += eh_addr_size;
+
+ if (version >= 4)
{
- fc->code_factor = LEB ();
- fc->data_factor = SLEB ();
- if (version == 1)
- {
- fc->ra = GET (1);
- }
- else
- {
- fc->ra = LEB ();
- }
- augmentation_data_len = LEB ();
- augmentation_data = start;
- start += augmentation_data_len;
+ fc->ptr_size = GET (1);
+ fc->segment_size = GET (1);
+ eh_addr_size = fc->ptr_size;
}
- else if (strcmp (fc->augmentation, "eh") == 0)
+ else
{
- start += eh_addr_size;
- fc->code_factor = LEB ();
- fc->data_factor = SLEB ();
- if (version == 1)
- {
- fc->ra = GET (1);
- }
- else
- {
- fc->ra = LEB ();
- }
+ fc->ptr_size = eh_addr_size;
+ fc->segment_size = 0;
+ }
+ fc->code_factor = LEB ();
+ fc->data_factor = SLEB ();
+ if (version == 1)
+ {
+ fc->ra = GET (1);
}
else
{
- fc->code_factor = LEB ();
- fc->data_factor = SLEB ();
- if (version == 1)
- {
- fc->ra = GET (1);
- }
- else
- {
- fc->ra = LEB ();
- }
+ fc->ra = LEB ();
+ }
+
+ if (fc->augmentation[0] == 'z')
+ {
+ augmentation_data_len = LEB ();
+ augmentation_data = start;
+ start += augmentation_data_len;
}
cie = fc;
(unsigned long)(saved_start - section_start), length, cie_id);
printf (" Version: %d\n", version);
printf (" Augmentation: \"%s\"\n", fc->augmentation);
+ if (version >= 4)
+ {
+ printf (" Pointer Size: %u\n", fc->ptr_size);
+ printf (" Segment Size: %u\n", fc->segment_size);
+ }
printf (" Code alignment factor: %u\n", fc->code_factor);
printf (" Data alignment factor: %d\n", fc->data_factor);
printf (" Return address column: %d\n", fc->ra);
{
unsigned char *look_for;
static Frame_Chunk fde_fc;
+ unsigned long segment_selector;
fc = & fde_fc;
memset (fc, 0, sizeof (Frame_Chunk));
cie = fc;
fc->augmentation = "";
fc->fde_encoding = 0;
+ fc->ptr_size = eh_addr_size;
+ fc->segment_size = 0;
}
else
{
memcpy (fc->col_type, cie->col_type, fc->ncols * sizeof (short int));
memcpy (fc->col_offset, cie->col_offset, fc->ncols * sizeof (int));
fc->augmentation = cie->augmentation;
+ fc->ptr_size = cie->ptr_size;
+ eh_addr_size = cie->ptr_size;
+ fc->segment_size = cie->segment_size;
fc->code_factor = cie->code_factor;
fc->data_factor = cie->data_factor;
fc->cfa_reg = cie->cfa_reg;
if (fc->fde_encoding)
encoded_ptr_size = size_of_encoded_value (fc->fde_encoding);
+ segment_selector = 0;
+ if (fc->segment_size)
+ {
+ segment_selector = byte_get (start, fc->segment_size);
+ start += fc->segment_size;
+ }
fc->pc_begin = get_encoded_value (start, fc->fde_encoding);
if ((fc->fde_encoding & 0x70) == DW_EH_PE_pcrel)
fc->pc_begin += section->address + (start - section_start);
start += augmentation_data_len;
}
- printf ("\n%08lx %08lx %08lx FDE cie=%08lx pc=%08lx..%08lx\n",
+ printf ("\n%08lx %08lx %08lx FDE cie=%08lx pc=",
(unsigned long)(saved_start - section_start), length, cie_id,
- (unsigned long)(cie->chunk_start - section_start),
- fc->pc_begin, fc->pc_begin + fc->pc_range);
+ (unsigned long)(cie->chunk_start - section_start));
+ if (fc->segment_size)
+ printf ("%04lx:", segment_selector);
+ printf ("%08lx..%08lx\n", fc->pc_begin, fc->pc_begin + fc->pc_range);
if (! do_debug_frames_interp && augmentation_data_len)
{
unsigned long i;
if (! do_debug_frames_interp)
{
printf (" DW_CFA_def_cfa_expression (");
- decode_location_expression (start, eh_addr_size, ul, 0,
- section);
+ decode_location_expression (start, eh_addr_size, 0, -1,
+ ul, 0, section);
printf (")\n");
}
fc->cfa_exp = 1;
{
printf (" DW_CFA_expression: %s%s (",
reg_prefix, regname (reg, 0));
- decode_location_expression (start, eh_addr_size,
+ decode_location_expression (start, eh_addr_size, 0, -1,
ul, 0, section);
printf (")\n");
}
{
printf (" DW_CFA_val_expression: %s%s (",
reg_prefix, regname (reg, 0));
- decode_location_expression (start, eh_addr_size, ul, 0,
- section);
+ decode_location_expression (start, eh_addr_size, 0, -1,
+ ul, 0, section);
printf (")\n");
}
if (*reg_prefix == '\0')
frame_display_row (fc, &need_col_headers, &max_regs);
start = block_end;
+ eh_addr_size = saved_eh_addr_size;
}
printf ("\n");
with earlier versions of readelf. */
{ "ranges", & do_debug_aranges, 1 },
{ "str", & do_debug_str, 1 },
+ /* These trace_* sections are used by Itanium VMS. */
+ { "trace_abbrev", & do_trace_abbrevs, 1 },
+ { "trace_aranges", & do_trace_aranges, 1 },
+ { "trace_info", & do_trace_info, 1 },
{ NULL, NULL, 0 }
};
do_debug_macinfo = 1;
do_debug_str = 1;
do_debug_loc = 1;
+ do_trace_info = 1;
+ do_trace_abbrevs = 1;
+ do_trace_aranges = 1;
}
struct dwarf_section_display debug_displays[] =
{
- { { ".debug_abbrev", ".zdebug_abbrev", NULL, NULL, 0, 0 },
+ { { ".debug_abbrev", ".zdebug_abbrev", NULL, NULL, 0, 0 },
display_debug_abbrev, &do_debug_abbrevs, 0 },
- { { ".debug_aranges", ".zdebug_aranges", NULL, NULL, 0, 0 },
+ { { ".debug_aranges", ".zdebug_aranges", NULL, NULL, 0, 0 },
display_debug_aranges, &do_debug_aranges, 1 },
- { { ".debug_frame", ".zdebug_frame", NULL, NULL, 0, 0 },
+ { { ".debug_frame", ".zdebug_frame", NULL, NULL, 0, 0 },
display_debug_frames, &do_debug_frames, 1 },
- { { ".debug_info", ".zdebug_info", NULL, NULL, 0, 0 },
+ { { ".debug_info", ".zdebug_info", NULL, NULL, 0, 0 },
display_debug_info, &do_debug_info, 1 },
- { { ".debug_line", ".zdebug_line", NULL, NULL, 0, 0 },
+ { { ".debug_line", ".zdebug_line", NULL, NULL, 0, 0 },
display_debug_lines, &do_debug_lines, 1 },
- { { ".debug_pubnames", ".zdebug_pubnames", NULL, NULL, 0, 0 },
+ { { ".debug_pubnames", ".zdebug_pubnames", NULL, NULL, 0, 0 },
display_debug_pubnames, &do_debug_pubnames, 0 },
- { { ".eh_frame", "", NULL, NULL, 0, 0 },
+ { { ".eh_frame", "", NULL, NULL, 0, 0 },
display_debug_frames, &do_debug_frames, 1 },
- { { ".debug_macinfo", ".zdebug_macinfo", NULL, NULL, 0, 0 },
+ { { ".debug_macinfo", ".zdebug_macinfo", NULL, NULL, 0, 0 },
display_debug_macinfo, &do_debug_macinfo, 0 },
- { { ".debug_str", ".zdebug_str", NULL, NULL, 0, 0 },
+ { { ".debug_str", ".zdebug_str", NULL, NULL, 0, 0 },
display_debug_str, &do_debug_str, 0 },
- { { ".debug_loc", ".zdebug_loc", NULL, NULL, 0, 0 },
+ { { ".debug_loc", ".zdebug_loc", NULL, NULL, 0, 0 },
display_debug_loc, &do_debug_loc, 1 },
- { { ".debug_pubtypes", ".zdebug_pubtypes", NULL, NULL, 0, 0 },
+ { { ".debug_pubtypes", ".zdebug_pubtypes", NULL, NULL, 0, 0 },
display_debug_pubnames, &do_debug_pubtypes, 0 },
- { { ".debug_ranges", ".zdebug_ranges", NULL, NULL, 0, 0 },
+ { { ".debug_ranges", ".zdebug_ranges", NULL, NULL, 0, 0 },
display_debug_ranges, &do_debug_ranges, 1 },
- { { ".debug_static_func", ".zdebug_static_func", NULL, NULL, 0, 0 },
+ { { ".debug_static_func", ".zdebug_static_func", NULL, NULL, 0, 0 },
display_debug_not_supported, NULL, 0 },
- { { ".debug_static_vars", ".zdebug_static_vars", NULL, NULL, 0, 0 },
+ { { ".debug_static_vars", ".zdebug_static_vars", NULL, NULL, 0, 0 },
display_debug_not_supported, NULL, 0 },
- { { ".debug_types", ".zdebug_types", NULL, NULL, 0, 0 },
+ { { ".debug_types", ".zdebug_types", NULL, NULL, 0, 0 },
display_debug_types, &do_debug_info, 1 },
- { { ".debug_weaknames", ".zdebug_weaknames", NULL, NULL, 0, 0 },
- display_debug_not_supported, NULL, 0 }
+ { { ".debug_weaknames", ".zdebug_weaknames", NULL, NULL, 0, 0 },
+ display_debug_not_supported, NULL, 0 },
+ { { ".trace_info", "", NULL, NULL, 0, 0 },
+ display_trace_info, &do_trace_info, 1 },
+ { { ".trace_abbrev", "", NULL, NULL, 0, 0 },
+ display_debug_abbrev, &do_trace_abbrevs, 0 },
+ { { ".trace_aranges", "", NULL, NULL, 0, 0 },
+ display_debug_aranges, &do_trace_aranges, 0 }
};