* patch for 7.2.1? dwarf2read.c (dwarf2_const_value_data): Never sign extend.
@ 2010-11-13 2:15 Doug Evans
2010-11-20 5:25 ` Joel Brobecker
0 siblings, 1 reply; 3+ messages in thread
From: Doug Evans @ 2010-11-13 2:15 UTC (permalink / raw)
To: gdb-patches
This is rather nasty.
class test
{
static const int k128 = 128;
};
test foo;
int
main ()
{
return 0;
}
$ gdb a.out
(gdb) start
(gdb) p test::k128
-128
I propose adding this patch to the 7.2.1 branch.
[I haven't run a regression test.
If there are changes needed I'll check for those before checking in.]
2010-07-27 Tom Tromey <tromey@redhat.com>
* dwarf2read.c (dwarf2_const_value_data): Never sign extend.
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.431
retrieving revision 1.432
diff -u -p -r1.431 -r1.432
--- dwarf2read.c 28 Jul 2010 19:04:07 -0000 1.431
+++ dwarf2read.c 28 Jul 2010 20:05:03 -0000 1.432
@@ -10485,8 +10485,13 @@ dwarf2_const_value (struct attribute *at
}
-/* 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. The DWARF
+ standard (v4) is not entirely clear about the meaning of using
+ DW_FORM_dataN for a constant with a signed type, where the type is
+ wider than the data. The conclusion of a discussion on the DWARF
+ list was that this is unspecified. We choose to always zero-extend
+ because that is the interpretation long in use by GCC. */
static void
dwarf2_const_value_data (struct attribute *attr,
struct symbol *sym,
@@ -10495,12 +10500,7 @@ dwarf2_const_value_data (struct attribut
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
* Re: patch for 7.2.1? dwarf2read.c (dwarf2_const_value_data): Never sign extend.
2010-11-13 2:15 patch for 7.2.1? dwarf2read.c (dwarf2_const_value_data): Never sign extend Doug Evans
@ 2010-11-20 5:25 ` Joel Brobecker
2010-11-25 19:43 ` Doug Evans
0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2010-11-20 5:25 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
> 2010-07-27 Tom Tromey <tromey@redhat.com>
>
> * dwarf2read.c (dwarf2_const_value_data): Never sign extend.
>
> I propose adding this patch to the 7.2.1 branch.
Sounds like a good idea to me.
--
Joel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: patch for 7.2.1? dwarf2read.c (dwarf2_const_value_data): Never sign extend.
2010-11-20 5:25 ` Joel Brobecker
@ 2010-11-25 19:43 ` Doug Evans
0 siblings, 0 replies; 3+ messages in thread
From: Doug Evans @ 2010-11-25 19:43 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
On Fri, Nov 19, 2010 at 9:25 PM, Joel Brobecker <brobecker@adacore.com> wrote:
>> 2010-07-27 Tom Tromey <tromey@redhat.com>
>>
>> * dwarf2read.c (dwarf2_const_value_data): Never sign extend.
>>
>> I propose adding this patch to the 7.2.1 branch.
>
> Sounds like a good idea to me.
Tested on amd64-linux, no regressions.
Checked in.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-11-25 19:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-13 2:15 patch for 7.2.1? dwarf2read.c (dwarf2_const_value_data): Never sign extend Doug Evans
2010-11-20 5:25 ` Joel Brobecker
2010-11-25 19:43 ` Doug Evans
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).