From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16228 invoked by alias); 29 Jul 2002 21:01:25 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 16206 invoked from network); 29 Jul 2002 21:01:24 -0000 Received: from unknown (HELO exchange.colubris.com) (206.162.167.230) by sources.redhat.com with SMTP; 29 Jul 2002 21:01:24 -0000 Received: from colubris.com ([192.168.30.124]) by exchange.colubris.com with Microsoft SMTPSVC(5.0.2195.3779); Mon, 29 Jul 2002 16:57:57 -0400 Message-ID: <3D45ACCC.9040803@colubris.com> Date: Mon, 29 Jul 2002 14:06:00 -0000 From: Martin Gadbois Organization: Colubris Networks Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [PATCH] Cross target core debugging: host=i386, Target=PPC X-Enigmail-Version: 0.49.5.0 Content-Type: multipart/mixed; boundary="------------040800080502070403050805" X-OriginalArrivalTime: 29 Jul 2002 20:57:57.0578 (UTC) FILETIME=[9DDEAAA0:01C23742] X-SW-Source: 2002-07/txt/msg00561.txt.bz2 This is a multi-part message in MIME format. --------------040800080502070403050805 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 703 -----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----- --------------040800080502070403050805 Content-Type: text/plain; name="gdb-5.2-ppc-cross-core.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="gdb-5.2-ppc-cross-core.patch" Content-length: 4311 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 -#ifdef HAVE_SYS_PROCFS_H -#include -#endif -#include -#include #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... --------------040800080502070403050805--