This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] Unbreak s390x and ppc64 gdbserver
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 14 Jun 2010 15:53:47 +0200 (CEST)
- Subject: [commit] Unbreak s390x and ppc64 gdbserver
Hello,
gdbserver on 64-bit PowerPC and S/390 is now failing because of changes in
register cache handling. The problem is the use of a regcache during the
arch_setup routine in order to detect whether the inferior is in 64-bit
or 32-bit / 31-bit mode. When resetting the register set after that
detection is made, the common regcache code now wants to *write back*
that initial regcache. As this regcache is actually in the wrong format
(because we hadn't switched to the correct format yet!), this fails
(with an internal assertion on ppc64, and by breaking the inferior
on s390x).
The patch below fixes this by not using a thread regcache, but a private
regcache which is specially allocated for this purpose. As this cache
is then simply freed, no attempt is made to write back registers. This
fixes the problem both on ppc64 and on s390x.
Tested on powerpc64-linux and s390x-linux. Committed to mainline.
Bye,
Ulrich
ChangeLog:
* linux-ppc-low.c (ppc_arch_setup): Use private regcache to test MSR.
* linux-s390-low.c (ppc_arch_setup): Use private regcache to test PSW.
Index: gdb/gdbserver/linux-ppc-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/linux-ppc-low.c,v
retrieving revision 1.29
diff -u -p -r1.29 linux-ppc-low.c
--- gdb/gdbserver/linux-ppc-low.c 7 Apr 2010 18:49:46 -0000 1.29
+++ gdb/gdbserver/linux-ppc-low.c 14 Jun 2010 13:27:01 -0000
@@ -345,8 +345,10 @@ ppc_arch_setup (void)
/* Only if the high bit of the MSR is set, we actually have
a 64-bit inferior. */
- regcache = get_thread_regcache (current_inferior, 1);
+ regcache = new_register_cache ();
+ fetch_inferior_registers (regcache, find_regno ("msr"));
collect_register_by_name (regcache, "msr", &msr);
+ free_register_cache (regcache);
if (msr < 0)
{
ppc_get_hwcap (&ppc_hwcap);
Index: gdb/gdbserver/linux-s390-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/linux-s390-low.c,v
retrieving revision 1.21
diff -u -p -r1.21 linux-s390-low.c
--- gdb/gdbserver/linux-s390-low.c 7 Apr 2010 18:49:46 -0000 1.21
+++ gdb/gdbserver/linux-s390-low.c 14 Jun 2010 13:27:01 -0000
@@ -270,8 +270,11 @@ s390_arch_setup (void)
#ifdef __s390x__
{
unsigned int pswm;
- struct regcache *regcache = get_thread_regcache (current_inferior, 1);
+ struct regcache *regcache = new_register_cache ();
+ fetch_inferior_registers (regcache, find_regno ("pswm"));
collect_register_by_name (regcache, "pswm", &pswm);
+ free_register_cache (regcache);
+
if (pswm & 1)
init_registers_s390x_linux64 ();
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com