public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* RFC: fix another regression w/ gcc svn trunk
@ 2010-07-27 17:23 Tom Tromey
  2010-07-28 17:45 ` Joel Brobecker
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2010-07-27 17:23 UTC (permalink / raw)
  To: gdb-patches

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;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-07-28 19:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-27 17:23 RFC: fix another regression w/ gcc svn trunk Tom Tromey
2010-07-28 17:45 ` Joel Brobecker
2010-07-28 19:59   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).