This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] Fix printing of flags from 64-bit registers
- From: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- To: gdb-patches at sourceware dot org
- Date: Tue, 22 Aug 2006 22:32:42 +0200 (CEST)
- Subject: [commit] Fix printing of flags from 64-bit registers
Printing flags from 64-bit registers showed some random set bits.
(gdb) print /x $pstate
$1 = 0x82
(gdb) print $pstate
$2 = [ IE #7 #33 #39 ]
Obviously bit #33 and #39 are not set. Turns out the code that prints
this invoked undefined behaviour by shifting the constant 1 (typically
a 32-bit integer) over more than 32 bits.
The attached patch fixes this by adding the right cast.
Mark
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* valprint.c (val_print_type_code_flags): Fix for bitfields larger
than 32 bits.
Index: valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/valprint.c,v
retrieving revision 1.60
diff -u -p -r1.60 valprint.c
--- valprint.c 15 May 2006 16:53:38 -0000 1.60
+++ valprint.c 22 Aug 2006 20:28:09 -0000
@@ -341,13 +341,14 @@ void
val_print_type_code_flags (struct type *type, const gdb_byte *valaddr,
struct ui_file *stream)
{
- LONGEST val = unpack_long (type, valaddr);
+ ULONGEST val = unpack_long (type, valaddr);
int bitpos, nfields = TYPE_NFIELDS (type);
fputs_filtered ("[ ", stream);
for (bitpos = 0; bitpos < nfields; bitpos++)
{
- if (TYPE_FIELD_BITPOS (type, bitpos) != -1 && (val & (1 << bitpos)))
+ if (TYPE_FIELD_BITPOS (type, bitpos) != -1 &&
+ (val & ((ULONGEST)1 << bitpos)))
{
if (TYPE_FIELD_NAME (type, bitpos))
fprintf_filtered (stream, "%s ", TYPE_FIELD_NAME (type, bitpos));