* [commit] Fix printing of flags from 64-bit registers
@ 2006-08-22 20:41 Mark Kettenis
0 siblings, 0 replies; only message in thread
From: Mark Kettenis @ 2006-08-22 20:41 UTC (permalink / raw)
To: gdb-patches
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));
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-08-22 20:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-22 20:41 [commit] Fix printing of flags from 64-bit registers Mark Kettenis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox