This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[rfa/amd64] Zero fill 32-bit registers
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Thu, 26 Feb 2004 20:22:11 -0500
- Subject: [rfa/amd64] Zero fill 32-bit registers
Hello,
For a 64-bit gregset, the code was only modifying the low 32-bits of the
register field - leaving the upper 64-bits undefined. This, among other
things, would lead to mysterious 32-bit thread failures.
The attached ensures that the upper part of each fetched register is zero.
ok?
Andrew
2004-02-25 Andrew Cagney <cagney@redhat.com>
* amd64-nat.c: Include "gdb_string.h".
(amd64_collect_native_gregset): Zero fill the register.
* Makefile.in: Update dependencies.
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.517
diff -u -r1.517 Makefile.in
--- Makefile.in 26 Feb 2004 23:48:01 -0000 1.517
+++ Makefile.in 27 Feb 2004 01:19:15 -0000
@@ -1536,7 +1536,7 @@
$(regcache_h) $(osabi_h) $(gdb_string_h) $(amd64_tdep_h) \
$(amd64_linux_tdep_h)
amd64-nat.o: amd64-nat.c $(defs_h) $(gdbarch_h) $(regcache_h) \
- $(gdb_assert_h) $(i386_tdep_h) $(amd64_tdep_h)
+ $(gdb_assert_h) $(gdb_string_h) $(i386_tdep_h) $(amd64_tdep_h)
amd64nbsd-nat.o: amd64nbsd-nat.c $(defs_h) $(gdb_assert_h) $(amd64_tdep_h) \
$(amd64_nat_h)
amd64nbsd-tdep.o: amd64nbsd-tdep.c $(defs_h) $(arch_utils_h) $(frame_h) \
Index: amd64-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/amd64-nat.c,v
retrieving revision 1.4
diff -u -r1.4 amd64-nat.c
--- amd64-nat.c 25 Feb 2004 20:59:12 -0000 1.4
+++ amd64-nat.c 27 Feb 2004 01:19:15 -0000
@@ -24,6 +24,7 @@
#include "regcache.h"
#include "gdb_assert.h"
+#include "gdb_string.h"
#include "i386-tdep.h"
#include "amd64-tdep.h"
@@ -140,7 +141,12 @@
int offset = amd64_native_gregset_reg_offset (i);
if (offset != -1)
- regcache_raw_collect (regcache, i, regs + offset);
+ {
+ regcache_raw_collect (regcache, i, regs + offset);
+ if (register_size (gdbarch, i) < 8)
+ memset (regs + offset + register_size (gdbarch, i),
+ 0, 8 - register_size (gdbarch, i));
+ }
}
}
}