aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2011-03-25 15:15:52 +0000
committerNick Clifton <nickc@redhat.com>2011-03-25 15:15:52 +0000
commit467c65bce26d4c5739239809564a7c81a7b1eba2 (patch)
treefe45cb16e3d2f93f81a2c46fa203ada2b0abd2d2
parent0377a422afbedee36dbf205f3681ea2b5ac67b13 (diff)
downloadgdb-467c65bce26d4c5739239809564a7c81a7b1eba2.zip
gdb-467c65bce26d4c5739239809564a7c81a7b1eba2.tar.gz
gdb-467c65bce26d4c5739239809564a7c81a7b1eba2.tar.bz2
Replace bfd_vma type and analog types by dwarf_vma and analogs.
Use dwarf specific print functions to display these type values. * dwarf.h (dwarf_signed_vma): New type; (DWARF2_External_LineInfo): Replace bfd_vma by dwarf_vma. (DWARF2_External_PubNames): Likewise. (DWARF2_External_CompUnit): Likewise. (DWARF2_External_ARange): Likewise. (read_leb128): Change return type to dwarf_vma. * dwarf.c (print_dwarf_vma): Use __MINGW32__ conditional and check byte_size values. (dwarf_vmatoa): Change parameter type to dwarf_vma. (dwarf_svmatoa): New static function. (read_leb128): Change return type to dwarf_vma. (read_sleb128): New static function. (struct State_Machine_Registers): Change address field type to dwarf_vma. (process_extended_line_op): Adapt to type changes. (fetch_indirect_string): Likewise. (idisplay_block): Likewise. (decode_location_expression): Likewise. (read_and_display_attr_value): Likewise. (process_debug_info): Likewise. (display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise. (SLEB macro): Use new read_sleb128 function.
-rw-r--r--binutils/ChangeLog28
-rw-r--r--binutils/dwarf.c362
-rw-r--r--binutils/dwarf.h45
3 files changed, 248 insertions, 187 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 6c481c1..6716013 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,31 @@
+2011-03-25 Pierre Muller <muller@ics.u-strasbg.fr>
+
+ Replace bfd_vma type and analog types by dwarf_vma and analogs.
+ Use dwarf specific print functions to display these type values.
+ * dwarf.h (dwarf_signed_vma): New type;
+ (DWARF2_External_LineInfo): Replace bfd_vma by dwarf_vma.
+ (DWARF2_External_PubNames): Likewise.
+ (DWARF2_External_CompUnit): Likewise.
+ (DWARF2_External_ARange): Likewise.
+ (read_leb128): Change return type to dwarf_vma.
+ * dwarf.c (print_dwarf_vma): Use __MINGW32__ conditional and
+ check byte_size values.
+ (dwarf_vmatoa): Change parameter type to dwarf_vma.
+ (dwarf_svmatoa): New static function.
+ (read_leb128): Change return type to dwarf_vma.
+ (read_sleb128): New static function.
+ (struct State_Machine_Registers): Change address field type to
+ dwarf_vma.
+ (process_extended_line_op): Adapt to type changes.
+ (fetch_indirect_string): Likewise.
+ (idisplay_block): Likewise.
+ (decode_location_expression): Likewise.
+ (read_and_display_attr_value): Likewise.
+ (process_debug_info): Likewise.
+ (display_debug_lines_raw): Likewise.
+ (display_debug_lines_decoded): Likewise.
+ (SLEB macro): Use new read_sleb128 function.
+
2011-03-17 Alan Modra <amodra@gmail.com>
PR 12590
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 130a295..d204537 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -106,12 +106,13 @@ static void
print_dwarf_vma (dwarf_vma val, unsigned byte_size)
{
static char buff[18];
+ int offset = 0;
/* Printf does not have a way of specifiying a maximum field width for an
integer value, so we print the full value into a buffer and then select
the precision we need. */
#if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
-#ifndef __MSVCRT__
+#ifndef __MINGW32__
snprintf (buff, sizeof (buff), "%16.16llx ", val);
#else
snprintf (buff, sizeof (buff), "%016I64x ", val);
@@ -120,36 +121,55 @@ print_dwarf_vma (dwarf_vma val, unsigned byte_size)
snprintf (buff, sizeof (buff), "%16.16lx ", val);
#endif
- fputs (buff + (byte_size == 4 ? 8 : 0), stdout);
+ if (byte_size != 0)
+ {
+ if (byte_size > 0 && byte_size <= 8)
+ offset = 16 - 2 * byte_size;
+ else
+ error ("Wrong size in print_dwarf_vma");
+ }
+
+ fputs (buff + offset, stdout);
}
+#if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
+#ifndef __MINGW32__
+#define DWARF_VMA_FMT "ll"
+#else
+#define DWARF_VMA_FMT "I64"
+#endif
+#else
+#define DWARF_VMA_FMT "l"
+#endif
+
static const char *
-dwarf_vmatoa (const char *fmtch, bfd_vma value)
+dwarf_vmatoa (const char *fmtch, dwarf_vma value)
{
/* As dwarf_vmatoa is used more then once in a printf call
for output, we are cycling through an fixed array of pointers
for return address. */
static int buf_pos = 0;
- static struct dwarf_vmatoa_buf {
+ static struct dwarf_vmatoa_buf
+ {
char place[64];
} buf[16];
char fmt[32];
char *ret;
- sprintf (fmt, "%%%s%s", BFD_VMA_FMT, fmtch);
+ sprintf (fmt, "%%%s%s", DWARF_VMA_FMT, fmtch);
ret = buf[buf_pos++].place;
- buf_pos %= ARRAY_SIZE(buf);
+ buf_pos %= ARRAY_SIZE (buf);
snprintf (ret, sizeof (buf[0].place), fmt, value);
return ret;
}
-bfd_vma
+dwarf_vma
read_leb128 (unsigned char *data, unsigned int *length_return, int sign)
{
- bfd_vma result = 0;
+ dwarf_vma result = 0;
unsigned int num_read = 0;
unsigned int shift = 0;
unsigned char byte;
@@ -159,7 +179,7 @@ read_leb128 (unsigned char *data, unsigned int *length_return, int sign)
byte = *data++;
num_read++;
- result |= ((bfd_vma) (byte & 0x7f)) << shift;
+ result |= ((dwarf_vma) (byte & 0x7f)) << shift;
shift += 7;
@@ -175,9 +195,16 @@ read_leb128 (unsigned char *data, unsigned int *length_return, int sign)
return result;
}
+/* Create a signed version to avoid painful typecasts. */
+static dwarf_signed_vma
+read_sleb128 (unsigned char *data, unsigned int *length_return)
+{
+ return (dwarf_signed_vma) read_leb128 (data, length_return, 1);
+}
+
typedef struct State_Machine_Registers
{
- unsigned long address;
+ dwarf_vma address;
unsigned int file;
unsigned int line;
unsigned int column;
@@ -216,7 +243,7 @@ process_extended_line_op (unsigned char *data, int is_stmt)
unsigned int bytes_read;
unsigned int len;
unsigned char *name;
- bfd_vma adr;
+ dwarf_vma adr;
len = read_leb128 (data, & bytes_read, 0);
data += bytes_read;
@@ -253,19 +280,17 @@ process_extended_line_op (unsigned char *data, int is_stmt)
printf (" %d\t", ++state_machine_regs.last_file_entry);
name = data;
data += strlen ((char *) data) + 1;
- printf ("%" BFD_VMA_FMT "u\t", read_leb128 (data, & bytes_read, 0));
+ printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
data += bytes_read;
- printf ("%" BFD_VMA_FMT "u\t",
- read_leb128 (data, & bytes_read, 0));
+ printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
data += bytes_read;
- printf ("%" BFD_VMA_FMT "u\t", read_leb128 (data, & bytes_read, 0));
+ printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
printf ("%s\n\n", name);
break;
case DW_LNE_set_discriminator:
printf (_("set Discriminator to %s\n"),
- dwarf_vmatoa ("u",
- read_leb128 (data, & bytes_read, 0)));
+ dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
break;
/* HP extensions. */
@@ -316,7 +341,7 @@ process_extended_line_op (unsigned char *data, int is_stmt)
}
static const char *
-fetch_indirect_string (bfd_vma offset)
+fetch_indirect_string (dwarf_vma offset)
{
struct dwarf_section *section = &debug_displays [str].section;
@@ -327,7 +352,8 @@ fetch_indirect_string (bfd_vma offset)
offset -= section->address;
if (offset > section->size)
{
- warn (_("DW_FORM_strp offset too big: %lx\n"), (long) offset);
+ warn (_("DW_FORM_strp offset too big: %s\n"),
+ dwarf_vmatoa ("x", offset));
return _("<offset is too big>");
}
@@ -390,7 +416,6 @@ add_abbrev (unsigned long number, unsigned long tag, int children)
abbrev_entry *entry;
entry = (abbrev_entry *) malloc (sizeof (*entry));
-
if (entry == NULL)
/* ugg */
return;
@@ -416,7 +441,6 @@ add_abbrev_attr (unsigned long attribute, unsigned long form)
abbrev_attr *attr;
attr = (abbrev_attr *) malloc (sizeof (*attr));
-
if (attr == NULL)
/* ugg */
return;
@@ -618,9 +642,9 @@ get_FORM_name (unsigned long form)
}
static unsigned char *
-display_block (unsigned char *data, unsigned long length)
+display_block (unsigned char *data, dwarf_vma length)
{
- printf (_(" %lu byte block: "), length);
+ printf (_(" %s byte block: "), dwarf_vmatoa ("u", length));
while (length --)
printf ("%lx ", (unsigned long) byte_get (data++, 1));
@@ -633,13 +657,13 @@ decode_location_expression (unsigned char * data,
unsigned int pointer_size,
unsigned int offset_size,
int dwarf_version,
- bfd_vma length,
- bfd_vma cu_offset,
+ dwarf_vma length,
+ dwarf_vma cu_offset,
struct dwarf_section * section)
{
unsigned op;
unsigned int bytes_read;
- bfd_vma uvalue;
+ dwarf_vma uvalue;
unsigned char *end = data + length;
int need_frame_base = 0;
@@ -690,13 +714,13 @@ decode_location_expression (unsigned char * data,
data += 8;
break;
case DW_OP_constu:
- printf ("DW_OP_constu: %" BFD_VMA_FMT "u",
- read_leb128 (data, &bytes_read, 0));
+ printf ("DW_OP_constu: %s",
+ dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0)));
data += bytes_read;
break;
case DW_OP_consts:
- printf ("DW_OP_consts: %" BFD_VMA_FMT "d",
- read_leb128 (data, &bytes_read, 1));
+ printf ("DW_OP_consts: %s",
+ dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read)));
data += bytes_read;
break;
case DW_OP_dup:
@@ -751,8 +775,8 @@ decode_location_expression (unsigned char * data,
printf ("DW_OP_plus");
break;
case DW_OP_plus_uconst:
- printf ("DW_OP_plus_uconst: %" BFD_VMA_FMT "u",
- read_leb128 (data, &bytes_read, 0));
+ printf ("DW_OP_plus_uconst: %s",
+ dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0)));
data += bytes_read;
break;
case DW_OP_shl:
@@ -897,36 +921,37 @@ decode_location_expression (unsigned char * data,
case DW_OP_breg29:
case DW_OP_breg30:
case DW_OP_breg31:
- printf ("DW_OP_breg%d (%s): %" BFD_VMA_FMT "d",
+ printf ("DW_OP_breg%d (%s): %s",
op - DW_OP_breg0,
regname (op - DW_OP_breg0, 1),
- read_leb128 (data, &bytes_read, 1));
+ dwarf_vmatoa ("d", (dwarf_signed_vma)
+ read_leb128 (data, &bytes_read, 1)));
data += bytes_read;
break;
case DW_OP_regx:
uvalue = read_leb128 (data, &bytes_read, 0);
data += bytes_read;
- printf ("DW_OP_regx: %" BFD_VMA_FMT "u (%s)",
- uvalue, regname (uvalue, 1));
+ printf ("DW_OP_regx: %s (%s)",
+ dwarf_vmatoa ("u", uvalue), regname (uvalue, 1));
break;
case DW_OP_fbreg:
need_frame_base = 1;
- printf ("DW_OP_fbreg: %" BFD_VMA_FMT "d",
- read_leb128 (data, &bytes_read, 1));
+ printf ("DW_OP_fbreg: %s",
+ dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read)));
data += bytes_read;
break;
case DW_OP_bregx:
uvalue = read_leb128 (data, &bytes_read, 0);
data += bytes_read;
- printf ("DW_OP_bregx: %" BFD_VMA_FMT "u (%s) %" BFD_VMA_FMT "d",
- uvalue, regname (uvalue, 1),
- read_leb128 (data, &bytes_read, 1));
+ printf ("DW_OP_bregx: %s (%s) %s",
+ dwarf_vmatoa ("u", uvalue), regname (uvalue, 1),
+ dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read)));
data += bytes_read;
break;
case DW_OP_piece:
- printf ("DW_OP_piece: %" BFD_VMA_FMT "u",
- read_leb128 (data, &bytes_read, 0));
+ printf ("DW_OP_piece: %s",
+ dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0)));
data += bytes_read;
break;
case DW_OP_deref_size:
@@ -946,15 +971,17 @@ decode_location_expression (unsigned char * data,
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: <0x%" BFD_VMA_FMT "x>",
- (bfd_signed_vma) byte_get (data, 2) + cu_offset);
+ printf ("DW_OP_call2: <0x%s>",
+ dwarf_vmatoa ("x", (dwarf_signed_vma) 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: <0x%" BFD_VMA_FMT "x>",
- (bfd_signed_vma) byte_get (data, 4) + cu_offset);
+ printf ("DW_OP_call4: <0x%s>",
+ dwarf_vmatoa ("x", (dwarf_signed_vma) byte_get (data, 4)
+ + cu_offset));
data += 4;
break;
case DW_OP_call_ref:
@@ -968,14 +995,14 @@ decode_location_expression (unsigned char * data,
}
if (dwarf_version == 2)
{
- printf ("DW_OP_call_ref: <0x%lx>",
- (long) byte_get (data, pointer_size));
+ printf ("DW_OP_call_ref: <0x%s>",
+ dwarf_vmatoa ("x", byte_get (data, pointer_size)));
data += pointer_size;
}
else
{
- printf ("DW_OP_call_ref: <0x%lx>",
- (long) byte_get (data, offset_size));
+ printf ("DW_OP_call_ref: <0x%s>",
+ dwarf_vmatoa ("x", byte_get (data, offset_size)));
data += offset_size;
}
break;
@@ -987,11 +1014,11 @@ decode_location_expression (unsigned char * data,
break;
case DW_OP_bit_piece:
printf ("DW_OP_bit_piece: ");
- printf ("size: %" BFD_VMA_FMT "u ",
- read_leb128 (data, &bytes_read, 0));
+ printf ("size: %s ",
+ dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0)));
data += bytes_read;
- printf ("offset: %" BFD_VMA_FMT "u ",
- read_leb128 (data, &bytes_read, 0));
+ printf ("offset: %s ",
+ dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0)));
data += bytes_read;
break;
@@ -1031,7 +1058,7 @@ decode_location_expression (unsigned char * data,
{
int encoding;
dwarf_vma addr;
-
+
encoding = *data++;
addr = get_encoded_value (data, encoding, section);
data += size_of_encoded_value (encoding);
@@ -1051,20 +1078,18 @@ decode_location_expression (unsigned char * data,
}
if (dwarf_version == 2)
{
- printf ("DW_OP_GNU_implicit_pointer: "
- "<0x%" BFD_VMA_FMT "x> %" BFD_VMA_FMT "d",
- (bfd_vma) byte_get (data, pointer_size),
- (bfd_signed_vma) read_leb128 (data + pointer_size,
- &bytes_read, 1));
+ printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s",
+ dwarf_vmatoa ("x", byte_get (data, pointer_size)),
+ dwarf_vmatoa ("d", read_sleb128 (data + pointer_size,
+ &bytes_read)));
data += pointer_size + bytes_read;
}
else
{
- printf ("DW_OP_GNU_implicit_pointer: "
- "<0x%" BFD_VMA_FMT "x> %" BFD_VMA_FMT "d",
- (bfd_vma) byte_get (data, offset_size),
- (bfd_signed_vma) read_leb128 (data + offset_size,
- &bytes_read, 1));
+ printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s",
+ dwarf_vmatoa ("x", byte_get (data, offset_size)),
+ dwarf_vmatoa ("d", read_sleb128 (data + offset_size,
+ &bytes_read)));
data += offset_size + bytes_read;
}
break;
@@ -1126,15 +1151,15 @@ static unsigned char *
read_and_display_attr_value (unsigned long attribute,
unsigned long form,
unsigned char * data,
- bfd_vma cu_offset,
- bfd_vma pointer_size,
- bfd_vma offset_size,
+ dwarf_vma cu_offset,
+ dwarf_vma pointer_size,
+ dwarf_vma offset_size,
int dwarf_version,
debug_info * debug_info_p,
int do_loc,
struct dwarf_section * section)
{
- bfd_vma uvalue = 0;
+ dwarf_vma uvalue = 0;
unsigned char *block_start = NULL;
unsigned char * orig_data = data;
unsigned int bytes_read;
@@ -1156,9 +1181,8 @@ read_and_display_attr_value (unsigned long attribute,
data += offset_size;
}
else
- {
- error (_("Internal error: DWARF version is not 2, 3 or 4.\n"));
- }
+ error (_("Internal error: DWARF version is not 2, 3 or 4.\n"));
+
break;
case DW_FORM_addr:
@@ -1221,7 +1245,7 @@ read_and_display_attr_value (unsigned long attribute,
{
case DW_FORM_ref_addr:
if (!do_loc)
- printf (" <0x%" BFD_VMA_FMT "x>", uvalue);
+ printf (" <0x%s>", dwarf_vmatoa ("x",uvalue));
break;
case DW_FORM_ref1:
@@ -1229,14 +1253,14 @@ read_and_display_attr_value (unsigned long attribute,
case DW_FORM_ref4:
case DW_FORM_ref_udata:
if (!do_loc)
- printf (" <0x%" BFD_VMA_FMT "x>", uvalue + cu_offset);
+ printf (" <0x%s>", dwarf_vmatoa ("x", uvalue + cu_offset));
break;
case DW_FORM_data4:
case DW_FORM_addr:
case DW_FORM_sec_offset:
if (!do_loc)
- printf (" 0x%" BFD_VMA_FMT "x", uvalue);
+ printf (" 0x%s", dwarf_vmatoa ("x", uvalue));
break;
case DW_FORM_flag_present:
@@ -1246,7 +1270,7 @@ read_and_display_attr_value (unsigned long attribute,
case DW_FORM_sdata:
case DW_FORM_udata:
if (!do_loc)
- printf (" %" BFD_VMA_FMT "d", uvalue);
+ printf (" %s", dwarf_vmatoa ("d", uvalue));
break;
case DW_FORM_ref8:
@@ -1254,7 +1278,7 @@ read_and_display_attr_value (unsigned long attribute,
if (!do_loc)
{
uvalue = byte_get (data, 4);
- printf (" 0x%" BFD_VMA_FMT "x", uvalue);
+ printf (" 0x%s", dwarf_vmatoa ("x", uvalue));
printf (" 0x%lx", (unsigned long) byte_get (data + 4, 4));
}
if ((do_loc || do_debug_loc || do_debug_ranges)
@@ -1263,7 +1287,7 @@ read_and_display_attr_value (unsigned long attribute,
if (sizeof (uvalue) == 8)
uvalue = byte_get (data, 8);
else
- error (_("DW_FORM_data8 is unsupported when sizeof (bfd_vma) != 8\n"));
+ error (_("DW_FORM_data8 is unsupported when sizeof (dwarf_vma) != 8\n"));
}
data += 8;
break;
@@ -1372,7 +1396,7 @@ read_and_display_attr_value (unsigned long attribute,
if (lmax == 0 || num >= lmax)
{
lmax += 1024;
- debug_info_p->loc_offsets = (bfd_vma *)
+ debug_info_p->loc_offsets = (dwarf_vma *)
xcrealloc (debug_info_p->loc_offsets,
lmax, sizeof (*debug_info_p->loc_offsets));
debug_info_p->have_frame_base = (int *)
@@ -1403,7 +1427,7 @@ read_and_display_attr_value (unsigned long attribute,
if (lmax == 0 || num >= lmax)
{
lmax += 1024;
- debug_info_p->range_lists = (bfd_vma *)
+ debug_info_p->range_lists = (dwarf_vma *)
xcrealloc (debug_info_p->range_lists,
lmax, sizeof (*debug_info_p->range_lists));
debug_info_p->max_range_lists = lmax;
@@ -1481,9 +1505,10 @@ read_and_display_attr_value (unsigned long attribute,
case DW_LANG_Upc: printf ("(Unified Parallel C)"); break;
default:
if (uvalue >= DW_LANG_lo_user && uvalue <= DW_LANG_hi_user)
- printf ("(implementation defined: %" BFD_VMA_FMT "x)", uvalue);
+ printf ("(implementation defined: %s)",
+ dwarf_vmatoa ("x", uvalue));
else
- printf ("(Unknown: %" BFD_VMA_FMT "x)", uvalue);
+ printf ("(Unknown: %s)", dwarf_vmatoa ("x", uvalue));
break;
}
break;
@@ -1859,9 +1884,9 @@ static unsigned char *
read_and_display_attr (unsigned long attribute,
unsigned long form,
unsigned char * data,
- bfd_vma cu_offset,
- bfd_vma pointer_size,
- bfd_vma offset_size,
+ dwarf_vma cu_offset,
+ dwarf_vma pointer_size,
+ dwarf_vma offset_size,
int dwarf_version,
debug_info * debug_info_p,
int do_loc,
@@ -1973,7 +1998,7 @@ process_debug_info (struct dwarf_section *section,
unsigned char *hdrptr;
unsigned char *tags;
int level;
- bfd_vma cu_offset;
+ dwarf_vma cu_offset;
int offset_size;
int initial_length_size;
unsigned char signature[8] = { 0 };
@@ -2218,9 +2243,7 @@ process_debug_info (struct dwarf_section *section,
num_debug_info_entries = num_units;
if (!do_loc)
- {
- printf ("\n");
- }
+ printf ("\n");
return 1;
}
@@ -2408,14 +2431,14 @@ display_debug_lines_raw (struct dwarf_section *section,
data += strlen ((char *) data) + 1;
- printf ("%" BFD_VMA_FMT "u\t",
- read_leb128 (data, & bytes_read, 0));
+ printf ("%s\t",
+ dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
data += bytes_read;
- printf ("%" BFD_VMA_FMT "u\t",
- read_leb128 (data, & bytes_read, 0));
+ printf ("%s\t",
+ dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
data += bytes_read;
- printf ("%" BFD_VMA_FMT "u\t",
- read_leb128 (data, & bytes_read, 0));
+ printf ("%s\t",
+ dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
data += bytes_read;
printf ("%s\n", name);
}
@@ -2430,8 +2453,8 @@ display_debug_lines_raw (struct dwarf_section *section,
while (data < end_of_sequence)
{
unsigned char op_code;
- int adv;
- unsigned long int uladv;
+ dwarf_signed_vma adv;
+ dwarf_vma uladv;
unsigned int bytes_read;
op_code = *data++;
@@ -2444,8 +2467,10 @@ display_debug_lines_raw (struct dwarf_section *section,
{
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);
+ printf (_(" Special opcode %d: "
+ "advance Address by %s to 0x%s"),
+ op_code, dwarf_vmatoa ("u", uladv),
+ dwarf_vmatoa ("x", state_machine_regs.address));
}
else
{
@@ -2456,14 +2481,16 @@ display_debug_lines_raw (struct dwarf_section *section,
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,
+ printf (_(" Special opcode %d: "
+ "advance Address by %s to 0x%s[%d]"),
+ op_code, dwarf_vmatoa ("u", uladv),
+ dwarf_vmatoa ("x", 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"),
- adv, state_machine_regs.line);
+ printf (_(" and Line by %s to %d\n"),
+ dwarf_vmatoa ("d", adv), state_machine_regs.line);
}
else switch (op_code)
{
@@ -2482,8 +2509,9 @@ display_debug_lines_raw (struct dwarf_section *section,
{
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);
+ printf (_(" Advance PC by %s to 0x%s\n"),
+ dwarf_vmatoa ("u", uladv),
+ dwarf_vmatoa ("x", state_machine_regs.address));
}
else
{
@@ -2494,39 +2522,42 @@ display_debug_lines_raw (struct dwarf_section *section,
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,
+ printf (_(" Advance PC by %s to 0x%s[%d]\n"),
+ dwarf_vmatoa ("u", uladv),
+ dwarf_vmatoa ("x", state_machine_regs.address),
state_machine_regs.op_index);
}
break;
case DW_LNS_advance_line:
- adv = read_leb128 (data, & bytes_read, 1);
+ adv = read_sleb128 (data, & bytes_read);
data += bytes_read;
state_machine_regs.line += adv;
- printf (_(" Advance Line by %d to %d\n"), adv,
- state_machine_regs.line);
+ printf (_(" Advance Line by %s to %d\n"),
+ dwarf_vmatoa ("d", adv),
+ state_machine_regs.line);
break;
case DW_LNS_set_file:
adv = read_leb128 (data, & bytes_read, 0);
data += bytes_read;
- printf (_(" Set File Name to entry %d in the File Name Table\n"),
- adv);
+ printf (_(" Set File Name to entry %s in the File Name Table\n"),
+ dwarf_vmatoa ("d", adv));
state_machine_regs.file = adv;
break;
case DW_LNS_set_column:
uladv = read_leb128 (data, & bytes_read, 0);
data += bytes_read;
- printf (_(" Set column to %lu\n"), uladv);
+ printf (_(" Set column to %s\n"),
+ dwarf_vmatoa ("u", uladv));
state_machine_regs.column = uladv;
break;
case DW_LNS_negate_stmt:
adv = state_machine_regs.is_stmt;
adv = ! adv;
- printf (_(" Set is_stmt to %d\n"), adv);
+ printf (_(" Set is_stmt to %s\n"), dwarf_vmatoa ("d", adv));
state_machine_regs.is_stmt = adv;
break;
@@ -2541,8 +2572,9 @@ display_debug_lines_raw (struct dwarf_section *section,
{
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);
+ printf (_(" Advance PC by constant %s to 0x%s\n"),
+ dwarf_vmatoa ("u", uladv),
+ dwarf_vmatoa ("x", state_machine_regs.address));
}
else
{
@@ -2553,8 +2585,9 @@ display_debug_lines_raw (struct dwarf_section *section,
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,
+ printf (_(" Advance PC by constant %s to 0x%s[%d]\n"),
+ dwarf_vmatoa ("u", uladv),
+ dwarf_vmatoa ("x", state_machine_regs.address),
state_machine_regs.op_index);
}
break;
@@ -2564,8 +2597,9 @@ display_debug_lines_raw (struct dwarf_section *section,
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);
+ printf (_(" Advance PC by fixed size amount %s to 0x%s\n"),
+ dwarf_vmatoa ("u", uladv),
+ dwarf_vmatoa ("x", state_machine_regs.address));
break;
case DW_LNS_set_prologue_end:
@@ -2579,7 +2613,7 @@ display_debug_lines_raw (struct dwarf_section *section,
case DW_LNS_set_isa:
uladv = read_leb128 (data, & bytes_read, 0);
data += bytes_read;
- printf (_(" Set ISA to %lu\n"), uladv);
+ printf (_(" Set ISA to %s\n"), dwarf_vmatoa ("u", uladv));
break;
default:
@@ -2587,8 +2621,8 @@ display_debug_lines_raw (struct dwarf_section *section,
for (i = standard_opcodes[op_code - 1]; i > 0 ; --i)
{
- printf ("0x%" BFD_VMA_FMT "x%s",
- read_leb128 (data, &bytes_read, 0),
+ printf ("0x%s%s", dwarf_vmatoa ("x", read_leb128 (data,
+ &bytes_read, 0)),
i == 1 ? "" : ", ");
data += bytes_read;
}
@@ -2604,10 +2638,10 @@ display_debug_lines_raw (struct dwarf_section *section,
typedef struct
{
- unsigned char *name;
- unsigned int directory_index;
- unsigned int modification_date;
- unsigned int length;
+ unsigned char *name;
+ unsigned int directory_index;
+ unsigned int modification_date;
+ unsigned int length;
} File_Entry;
/* Output a decoded representation of the .debug_line section. */
@@ -2918,7 +2952,7 @@ display_debug_lines_decoded (struct dwarf_section *section,
break;
case DW_LNS_advance_line:
- adv = read_leb128 (data, & bytes_read, 1);
+ adv = read_sleb128 (data, & bytes_read);
data += bytes_read;
state_machine_regs.line += adv;
break;
@@ -3001,8 +3035,8 @@ display_debug_lines_decoded (struct dwarf_section *section,
for (i = standard_opcodes[op_code - 1]; i > 0 ; --i)
{
- printf ("0x%" BFD_VMA_FMT "x%s",
- read_leb128 (data, &bytes_read, 0),
+ printf ("0x%s%s", dwarf_vmatoa ("x", read_leb128 (data,
+ &bytes_read, 0)),
i == 1 ? "" : ", ");
data += bytes_read;
}
@@ -3037,24 +3071,24 @@ display_debug_lines_decoded (struct dwarf_section *section,
if (!do_wide || (fileNameLength <= MAX_FILENAME_LENGTH))
{
if (linfo.li_max_ops_per_insn == 1)
- printf ("%-35s %11d %#18lx\n", newFileName,
- state_machine_regs.line,
+ printf ("%-35s %11d %#18" DWARF_VMA_FMT "x\n",
+ newFileName, state_machine_regs.line,
state_machine_regs.address);
else
- printf ("%-35s %11d %#18lx[%d]\n", newFileName,
- state_machine_regs.line,
+ printf ("%-35s %11d %#18" DWARF_VMA_FMT "x[%d]\n",
+ newFileName, state_machine_regs.line,
state_machine_regs.address,
state_machine_regs.op_index);
}
else
{
if (linfo.li_max_ops_per_insn == 1)
- printf ("%s %11d %#18lx\n", newFileName,
- state_machine_regs.line,
+ printf ("%s %11d %#18" DWARF_VMA_FMT "x\n",
+ newFileName, state_machine_regs.line,
state_machine_regs.address);
else
- printf ("%s %11d %#18lx[%d]\n", newFileName,
- state_machine_regs.line,
+ printf ("%s %11d %#18" DWARF_VMA_FMT "x[%d]\n",
+ newFileName, state_machine_regs.line,
state_machine_regs.address,
state_machine_regs.op_index);
}
@@ -3754,13 +3788,13 @@ display_debug_aranges (struct dwarf_section *section,
sorting purposes. */
struct range_entry
- {
- /* The debug_information[x].range_lists[y] value. */
- unsigned long ranges_offset;
+{
+ /* The debug_information[x].range_lists[y] value. */
+ unsigned long ranges_offset;
- /* Original debug_information to find parameters of the data. */
- debug_info *debug_info_p;
- };
+ /* Original debug_information to find parameters of the data. */
+ debug_info *debug_info_p;
+};
/* Sort struct range_entry in ascending order of its RANGES_OFFSET. */
@@ -4140,7 +4174,7 @@ frame_display_row (Frame_Chunk *fc, int *need_col_headers, int *max_regs)
#define GET(N) byte_get (start, N); start += N
#define LEB() read_leb128 (start, & length_return, 0); start += length_return
-#define SLEB() read_leb128 (start, & length_return, 1); start += length_return
+#define SLEB() read_sleb128 (start, & length_return); start += length_return
static int
display_debug_frames (struct dwarf_section *section,
@@ -5199,21 +5233,21 @@ dwarf_select_sections_by_names (const char *names)
};
const char *p;
-
+
p = names;
while (*p)
{
const debug_dump_long_opts * entry;
-
+
for (entry = opts_table; entry->option; entry++)
{
size_t len = strlen (entry->option);
-
+
if (strncmp (p, entry->option, len) == 0
&& (p[len] == ',' || p[len] == '\0'))
{
* entry->variable |= entry->val;
-
+
/* The --debug-dump=frames-interp option also
enables the --debug-dump=frames option. */
if (do_debug_frames_interp)
@@ -5223,7 +5257,7 @@ dwarf_select_sections_by_names (const char *names)
break;
}
}
-
+
if (entry->option == NULL)
{
warn (_("Unrecognized debug option '%s'\n"), p);
@@ -5231,7 +5265,7 @@ dwarf_select_sections_by_names (const char *names)
if (p == NULL)
break;
}
-
+
if (*p == ',')
p++;
}
@@ -5248,53 +5282,53 @@ dwarf_select_sections_by_letters (const char *letters)
case 'i':
do_debug_info = 1;
break;
-
+
case 'a':
do_debug_abbrevs = 1;
break;
-
+
case 'l':
do_debug_lines |= FLAG_DEBUG_LINES_RAW;
break;
-
+
case 'L':
do_debug_lines |= FLAG_DEBUG_LINES_DECODED;
break;
-
+
case 'p':
do_debug_pubnames = 1;
break;
-
+
case 't':
do_debug_pubtypes = 1;
break;
-
+
case 'r':
do_debug_aranges = 1;
break;
-
+
case 'R':
do_debug_ranges = 1;
break;
-
+
case 'F':
do_debug_frames_interp = 1;
case 'f':
do_debug_frames = 1;
break;
-
+
case 'm':
do_debug_macinfo = 1;
break;
-
+
case 's':
do_debug_str = 1;
break;
-
+
case 'o':
do_debug_loc = 1;
break;
-
+
default:
warn (_("Unrecognized debug option '%s'\n"), optarg);
break;
diff --git a/binutils/dwarf.h b/binutils/dwarf.h
index 344cc42..62b57a6 100644
--- a/binutils/dwarf.h
+++ b/binutils/dwarf.h
@@ -1,5 +1,5 @@
/* dwarf.h - DWARF support header file
- Copyright 2005, 2007, 2008, 2009, 2010
+ Copyright 2005, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
This file is part of GNU Binutils.
@@ -19,8 +19,9 @@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
-typedef unsigned HOST_WIDEST_INT dwarf_vma;
-typedef unsigned HOST_WIDEST_INT dwarf_size_type;
+typedef unsigned HOST_WIDEST_INT dwarf_vma;
+typedef HOST_WIDEST_INT dwarf_signed_vma;
+typedef unsigned HOST_WIDEST_INT dwarf_size_type;
/* Structure found in the .debug_line section. */
typedef struct
@@ -38,7 +39,7 @@ DWARF2_External_LineInfo;
typedef struct
{
- bfd_vma li_length;
+ dwarf_vma li_length;
unsigned short li_version;
unsigned int li_prologue_length;
unsigned char li_min_insn_length;
@@ -62,10 +63,10 @@ DWARF2_External_PubNames;
typedef struct
{
- bfd_vma pn_length;
+ dwarf_vma pn_length;
unsigned short pn_version;
- bfd_vma pn_offset;
- bfd_vma pn_size;
+ dwarf_vma pn_offset;
+ dwarf_vma pn_size;
}
DWARF2_Internal_PubNames;
@@ -81,9 +82,9 @@ DWARF2_External_CompUnit;
typedef struct
{
- bfd_vma cu_length;
+ dwarf_vma cu_length;
unsigned short cu_version;
- bfd_vma cu_abbrev_offset;
+ dwarf_vma cu_abbrev_offset;
unsigned char cu_pointer_size;
}
DWARF2_Internal_CompUnit;
@@ -100,9 +101,9 @@ DWARF2_External_ARange;
typedef struct
{
- bfd_vma ar_length;
+ dwarf_vma ar_length;
unsigned short ar_version;
- bfd_vma ar_info_offset;
+ dwarf_vma ar_info_offset;
unsigned char ar_pointer_size;
unsigned char ar_segment_size;
}
@@ -165,15 +166,15 @@ typedef struct
unsigned int pointer_size;
unsigned int offset_size;
int dwarf_version;
- bfd_vma cu_offset;
- bfd_vma base_address;
+ dwarf_vma cu_offset;
+ dwarf_vma base_address;
/* This is an array of offsets to the location list table. */
- bfd_vma *loc_offsets;
- int *have_frame_base;
+ dwarf_vma * loc_offsets;
+ int * have_frame_base;
unsigned int num_loc_offsets;
unsigned int max_loc_offsets;
/* List of .debug_ranges offsets seen in this .debug_info. */
- bfd_vma *range_lists;
+ dwarf_vma * range_lists;
unsigned int num_range_lists;
unsigned int max_range_lists;
}
@@ -203,8 +204,7 @@ extern void init_dwarf_regnames (unsigned int);
extern void init_dwarf_regnames_i386 (void);
extern void init_dwarf_regnames_x86_64 (void);
-extern int load_debug_section (enum dwarf_section_display_enum,
- void *);
+extern int load_debug_section (enum dwarf_section_display_enum, void *);
extern void free_debug_section (enum dwarf_section_display_enum);
extern void free_debug_memory (void);
@@ -213,9 +213,8 @@ extern void dwarf_select_sections_by_names (const char *);
extern void dwarf_select_sections_by_letters (const char *);
extern void dwarf_select_sections_all (void);
-void *cmalloc (size_t, size_t);
-void *xcmalloc (size_t, size_t);
-void *xcrealloc (void *, size_t, size_t);
+void * cmalloc (size_t, size_t);
+void * xcmalloc (size_t, size_t);
+void * xcrealloc (void *, size_t, size_t);
-bfd_vma read_leb128 (unsigned char *data,
- unsigned int *length_return, int sign);
+dwarf_vma read_leb128 (unsigned char *, unsigned int *, int);