This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH] Cross target core debugging: host=i386, Target=PPC
- From: Martin Gadbois <martin dot gadbois at colubris dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Mon, 29 Jul 2002 16:59:56 -0400
- Subject: [PATCH] Cross target core debugging: host=i386, Target=PPC
- Organization: Colubris Networks Inc.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Here's the result of the mailing list posting http://sources.redhat.com/ml/gdb/2002-05/msg00191.html
applied for PPC.
Apply patch against GDB 5.2, and you'll be able to debug core dumps on a Intel host from a PowerPC
target.
The OS for both is Linux.
PS: Please reply to me directly, as I am not a member of this list.
- --
==============
Martin Gadbois
S/W Developper
Colubris Networks Inc.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAj1FrMwACgkQ9Y3/iTTCEDnPJwCfYF9zY+QXN31wPM5dMQh2+cfX
Zx8AoKBo3dVSqRQx2en0gZUoJea/OhNI
=nrPR
-----END PGP SIGNATURE-----
diff -Naur gdb-5.2/gdb/config/powerpc/linux.mt gdb-5.2-ppc-core/gdb/config/powerpc/linux.mt
--- gdb-5.2/gdb/config/powerpc/linux.mt Fri Oct 19 20:16:44 2001
+++ gdb-5.2-ppc-core/gdb/config/powerpc/linux.mt Mon Jul 29 16:25:49 2002
@@ -1,5 +1,5 @@
# Target: Motorola PPC on Linux
-TDEPFILES= rs6000-tdep.o ppc-linux-tdep.o solib.o solib-svr4.o solib-legacy.o
+TDEPFILES= rs6000-tdep.o ppc-linux-tdep.o solib.o solib-svr4.o solib-legacy.o corelow.o core-regset.o
TM_FILE= tm-linux.h
SIM_OBS = remote-sim.o
diff -Naur gdb-5.2/gdb/core-regset.c gdb-5.2-ppc-core/gdb/core-regset.c
--- gdb-5.2/gdb/core-regset.c Fri Aug 3 17:34:01 2001
+++ gdb-5.2-ppc-core/gdb/core-regset.c Mon Jul 29 15:45:28 2002
@@ -35,13 +35,6 @@
*/
#include "defs.h"
-
-#include <time.h>
-#ifdef HAVE_SYS_PROCFS_H
-#include <sys/procfs.h>
-#endif
-#include <fcntl.h>
-#include <errno.h>
#include "gdb_string.h"
#include "inferior.h"
diff -Naur gdb-5.2/gdb/gregset.h gdb-5.2-ppc-core/gdb/gregset.h
--- gdb-5.2/gdb/gregset.h Sun Feb 24 17:14:33 2002
+++ gdb-5.2-ppc-core/gdb/gregset.h Mon Jul 29 15:45:43 2002
@@ -21,6 +21,20 @@
#ifndef GREGSET_H
#define GREGSET_H
+
+#define ELF_NGREG 48 /* includes nip, msr, lr, etc. */
+#define ELF_NFPREG 33 /* includes fpscr */
+#define ELF_NVRREG 33 /* includes vscr */
+
+typedef unsigned long elf_greg_t;
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+typedef double elf_fpreg_t;
+typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
+
+#define GDB_GREGSET_T elf_gregset_t
+#define GDB_FPREGSET_T elf_fpregset_t
+
#ifndef GDB_GREGSET_T
#define GDB_GREGSET_T gregset_t
#endif
diff -Naur gdb-5.2/gdb/ppc-linux-tdep.c gdb-5.2-ppc-core/gdb/ppc-linux-tdep.c
--- gdb-5.2/gdb/ppc-linux-tdep.c Sun Feb 24 17:31:19 2002
+++ gdb-5.2-ppc-core/gdb/ppc-linux-tdep.c Mon Jul 29 14:59:24 2002
@@ -35,6 +35,7 @@
#include "solib-svr4.h"
#include "ppc-tdep.h"
+#include "gregset.h"
/* The following two instructions are used in the signal trampoline
code on GNU/Linux PPC. */
#define INSTR_LI_R0_0x7777 0x38007777
@@ -101,7 +102,61 @@
#define PPC_LINUX_PT_FPR31 (PPC_LINUX_PT_FPR0 + 2*31)
#define PPC_LINUX_PT_FPSCR (PPC_LINUX_PT_FPR0 + 2*32 + 1)
+#define FP0_REGNUM 32 /* FPR (Floating point) register 0 */
static int ppc_linux_at_sigtramp_return_path (CORE_ADDR pc);
+
+#define SIZEOF_VRREGS 33*16+4
+typedef char gdb_vrregset_t[SIZEOF_VRREGS];
+
+
+static void
+supply_vrregset (gdb_vrregset_t *vrregsetp)
+{
+ int i;
+ struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+ int num_of_vrregs = tdep->ppc_vrsave_regnum - tdep->ppc_vr0_regnum + 1;
+ int vrregsize = REGISTER_RAW_SIZE (tdep->ppc_vr0_regnum);
+ int offset = vrregsize - REGISTER_RAW_SIZE (tdep->ppc_vrsave_regnum);
+
+ for (i = 0; i < num_of_vrregs; i++)
+ {
+ /* The last 2 registers of this set are only 32 bit long, not
+ 128. However an offset is necessary only for VSCR because it
+ occupies a whole vector, while VRSAVE occupies a full 4 bytes
+ slot. */
+ if (i == (num_of_vrregs - 2))
+ supply_register (tdep->ppc_vr0_regnum + i,
+ *vrregsetp + i * vrregsize + offset);
+ else
+ supply_register (tdep->ppc_vr0_regnum + i, *vrregsetp + i * vrregsize);
+ }
+}
+void
+supply_gregset (gdb_gregset_t *gregsetp)
+{
+ int regi;
+ register elf_greg_t *regp = (elf_greg_t *) gregsetp;
+ struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+
+ for (regi = 0; regi < 32; regi++)
+ supply_register (regi, (char *) (regp + regi));
+
+ supply_register (PC_REGNUM, (char *) (regp + PPC_LINUX_PT_NIP));
+ supply_register (tdep->ppc_lr_regnum, (char *) (regp + PPC_LINUX_PT_LNK));
+ supply_register (tdep->ppc_cr_regnum, (char *) (regp + PPC_LINUX_PT_CCR));
+ supply_register (tdep->ppc_xer_regnum, (char *) (regp + PPC_LINUX_PT_XER));
+ supply_register (tdep->ppc_ctr_regnum, (char *) (regp + PPC_LINUX_PT_CTR));
+ supply_register (tdep->ppc_mq_regnum, (char *) (regp + PPC_LINUX_PT_MQ));
+ supply_register (tdep->ppc_ps_regnum, (char *) (regp + PPC_LINUX_PT_MSR));
+}
+void
+supply_fpregset (gdb_fpregset_t * fpregsetp)
+{
+ int regi;
+
+ for (regi = 0; regi < 32; regi++)
+ supply_register (FP0_REGNUM + regi, (char *) (*fpregsetp + regi));
+}
/* Determine if pc is in a signal trampoline...