RFC: fix another regression w/ gcc svn trunk
Tom Tromey
tromey@redhat.com
Tue Jul 27 17:23:00 GMT 2010
I would appreciate comments on this patch.
GCC svn trunk apparently emits DW_FORM_data1 a little more aggressively
now. This caused a regression in scope.exp:
print foo::funclocal_ro
$15 = -53
(gdb) FAIL: gdb.base/scope.exp: print foo::funclocal_ro
The correct answer is 203, but gdb sign-extends this to get -53.
Both GCC and elfutils agreed that DW_FORM_data* are "just bits" -- no
sign extension is to be applied. This is not clear from the DWARF
specification, so I asked on the DWARF list, and the answer there was
that this is unspecified. (I would link to the list archives here, but
they are closed to non-subscribers -- and if you are a subscriber you
already saw or have the thread.)
Since GCC has apparently been assuming its interpretation for some time,
I think it is best to simply follow GCC. That is what this patch does.
Built and regtested on x86-64 (compile farm). Also I tested this test
case locally using gcc svn. I plan to run the whole gdb test suite
again with this fix in place.
In the absence of comments I am going to check this in.
I am undecided as to whether this belongs in 7.2.
Tom
2010-07-27 Tom Tromey <tromey@redhat.com>
* dwarf2read.c (dwarf2_const_value_data): Never sign extend.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 0d63fe3..de516dc 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -10157,8 +10157,8 @@ dwarf2_const_value (struct attribute *attr, struct symbol *sym,
}
-/* Given an attr with a DW_FORM_dataN value in host byte order, sign-
- or zero-extend it as appropriate for the symbol's type. */
+/* Given an attr with a DW_FORM_dataN value in host byte order,
+ zero-extend it as appropriate for the symbol's type. */
static void
dwarf2_const_value_data (struct attribute *attr,
struct symbol *sym,
@@ -10167,12 +10167,7 @@ dwarf2_const_value_data (struct attribute *attr,
LONGEST l = DW_UNSND (attr);
if (bits < sizeof (l) * 8)
- {
- if (TYPE_UNSIGNED (SYMBOL_TYPE (sym)))
- l &= ((LONGEST) 1 << bits) - 1;
- else
- l = (l << (sizeof (l) * 8 - bits)) >> (sizeof (l) * 8 - bits);
- }
+ l &= ((LONGEST) 1 << bits) - 1;
SYMBOL_VALUE (sym) = l;
SYMBOL_CLASS (sym) = LOC_CONST;
More information about the Gdb-patches
mailing list