From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30897 invoked by alias); 27 May 2002 15:05:21 -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 30866 invoked from network); 27 May 2002 15:05:15 -0000 Received: from unknown (HELO kerberos.suse.cz) (195.47.106.10) by sources.redhat.com with SMTP; 27 May 2002 15:05:15 -0000 Received: from chimera.suse.cz (chimera.suse.cz [10.20.0.2]) by kerberos.suse.cz (SuSE SMTP server) with ESMTP id E4D2B59D34C for ; Mon, 27 May 2002 17:05:14 +0200 (CEST) Received: from suse.cz (naga.suse.cz [10.20.1.16]) by chimera.suse.cz (8.11.0/8.11.0/SuSE Linux 8.11.0-0.4) with ESMTP id g4RF5El14829 for ; Mon, 27 May 2002 17:05:14 +0200 X-Authentication-Warning: chimera.suse.cz: Host naga.suse.cz [10.20.1.16] claimed to be suse.cz Message-ID: <3CF24B2A.3070305@suse.cz> Date: Mon, 27 May 2002 08:58:00 -0000 From: Michal Ludvig Organization: SuSE CR User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0rc2) Gecko/20020510 X-Accept-Language: cs, cz, en MIME-Version: 1.0 To: GDB Patches Subject: [RFC] x86-64 targeted gdb and corefiles Content-Type: multipart/mixed; boundary="------------000705010708030008070308" X-SW-Source: 2002-05/txt/msg00938.txt.bz2 This is a multi-part message in MIME format. --------------000705010708030008070308 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit Content-length: 545 Hi all, this patch allows reading of coredumps on non-native gdb configured for x86-64 target. It works pretty well in this form, but I had to modify gregset.h, what is unwise. I know I have to move the modifications somewhere else, but ... where? Can someone give me an advice, please? BTW If anyone would like to apply this patch, please update bfd to current CVS as well, since I fixed there some stuff related to this issue on friady. Michal Ludvig -- * SuSE CR, s.r.o * mludvig@suse.cz * +420 2 9654 5373 * http://www.suse.cz --------------000705010708030008070308 Content-Type: text/plain; name="core.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="core.diff" Content-length: 6260 Index: gregset.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/gregset.h,v retrieving revision 1.7 diff -c -3 -p -r1.7 gregset.h *** gregset.h 8 May 2002 23:29:11 -0000 1.7 --- gregset.h 27 May 2002 12:22:24 -0000 *************** *** 21,26 **** --- 21,41 ---- #ifndef GREGSET_H #define GREGSET_H =20=20 + /* We can't include x86-64's directly,=20 + so we must copy appropriate typedefs here. */ + #define ELF_NGREG 27 + typedef unsigned long long elf_greg_t; + typedef elf_greg_t elf_gregset_t[ELF_NGREG]; +=20 + /* Register set for the extended floating-point registers. Includes + the Pentium III SSE registers in addition to the classic + floating-point stuff. */ + typedef unsigned char elf_fpregset_t[512]; +=20=20=20=20=20=20=20 +=20 + #define GDB_GREGSET_T elf_gregset_t + #define GDB_FPREGSET_T elf_fpregset_t +=20 #ifndef GDB_GREGSET_T #define GDB_GREGSET_T gregset_t #endif Index: x86-64-linux-nat.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/x86-64-linux-nat.c,v retrieving revision 1.12 diff -c -3 -p -r1.12 x86-64-linux-nat.c *** x86-64-linux-nat.c 11 May 2002 17:22:26 -0000 1.12 --- x86-64-linux-nat.c 27 May 2002 12:22:26 -0000 *************** x86_64_linux_dr_get_status (void) *** 130,166 **** (FP0_REGNUM <=3D (regno) && (regno) <=3D MXCSR_REGNUM) =0C =20=20 - /* Transfering the general-purpose registers between GDB, inferiors - and core files. */ -=20 - /* Fill GDB's register array with the general-purpose register values - in *GREGSETP. */ -=20 - void - supply_gregset (elf_gregset_t * gregsetp) - { - elf_greg_t *regp =3D (elf_greg_t *) gregsetp; - int i; -=20 - for (i =3D 0; i < x86_64_num_gregs; i++) - supply_register (i, (char *) (regp + x86_64_regmap[i])); - } -=20 - /* Fill register REGNO (if it is a general-purpose register) in - *GREGSETPS with the value in GDB's register array. If REGNO is -1, - do this for all registers. */ -=20 - void - fill_gregset (elf_gregset_t * gregsetp, int regno) - { - elf_greg_t *regp =3D (elf_greg_t *) gregsetp; - int i; -=20 - for (i =3D 0; i < x86_64_num_gregs; i++) - if ((regno =3D=3D -1 || regno =3D=3D i)) - read_register_gen (i, (char *) (regp + x86_64_regmap[i])); - } -=20 /* Fetch all general-purpose registers from process/thread TID and store their values in GDB's register array. */ =20=20 --- 130,135 ---- *************** store_regs (int tid, int regno) *** 192,218 **** perror_with_name ("Couldn't write registers"); } =0C -=20 - /* Transfering floating-point registers between GDB, inferiors and cores.= */ -=20 - /* Fill GDB's register array with the floating-point register values in - *FPREGSETP. */ -=20 - void - supply_fpregset (elf_fpregset_t * fpregsetp) - { - i387_supply_fxsave ((char *) fpregsetp); - } -=20 - /* Fill register REGNO (if it is a floating-point register) in - *FPREGSETP with the value in GDB's register array. If REGNO is -1, - do this for all registers. */ -=20 - void - fill_fpregset (elf_fpregset_t * fpregsetp, int regno) - { - i387_fill_fxsave ((char *) fpregsetp, regno); - } =20=20 /* Fetch all floating-point registers from process/thread TID and store thier values in GDB's register array. */ --- 161,166 ---- Index: x86-64-linux-tdep.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/x86-64-linux-tdep.c,v retrieving revision 1.4 diff -c -3 -p -r1.4 x86-64-linux-tdep.c *** x86-64-linux-tdep.c 24 Feb 2002 22:14:33 -0000 1.4 --- x86-64-linux-tdep.c 27 May 2002 12:22:26 -0000 *************** *** 25,32 **** --- 25,43 ---- #include "inferior.h" #include "gdbcore.h" #include "regcache.h" + #include "i387-tdep.h" #include "x86-64-tdep.h" #include "dwarf2cfi.h" + #include "gregset.h" +=20 + static int x86_64_regmap[] =3D { + 10, 5, 11, 12, + 13, 14, 4, 19, + 9, 8, 7, 6, + 3, 2, 1, 0, + 16, 18, + 23, 24, 25, 26 + }; =20=20 #define LINUX_SIGTRAMP_INSN0 (0x48) /* mov $NNNNNNNN,%rax */ #define LINUX_SIGTRAMP_OFFSET0 (0) *************** x86_64_linux_frame_saved_pc (struct fram *** 134,136 **** --- 145,200 ---- return x86_64_linux_sigtramp_saved_pc (frame); return cfi_get_ra (frame); } +=20 + /* Transfering the general-purpose registers between GDB, inferiors + and core files. */ +=20 + /* Fill GDB's register array with the general-purpose register values + in *GREGSETP. */ +=20 + void + supply_gregset (elf_gregset_t * gregsetp) + { + elf_greg_t *regp =3D (elf_greg_t *) gregsetp; + int i; +=20 + for (i =3D 0; i < x86_64_num_gregs; i++) + supply_register (i, (char *) (regp + x86_64_regmap[i])); + } +=20 + /* Fill register REGNO (if it is a general-purpose register) in + *GREGSETPS with the value in GDB's register array. If REGNO is -1, + do this for all registers. */ +=20 + void + fill_gregset (elf_gregset_t * gregsetp, int regno) + { + elf_greg_t *regp =3D (elf_greg_t *) gregsetp; + int i; +=20 + for (i =3D 0; i < x86_64_num_gregs; i++) + if ((regno =3D=3D -1 || regno =3D=3D i)) + read_register_gen (i, (char *) (regp + x86_64_regmap[i])); + } +=20 + /* Transfering floating-point registers between GDB, inferiors and cores.= */ +=20 + /* Fill GDB's register array with the floating-point register values in + *FPREGSETP. */ +=20 + void + supply_fpregset (elf_fpregset_t * fpregsetp) + { + i387_supply_fxsave ((char *) fpregsetp); + } +=20 + /* Fill register REGNO (if it is a floating-point register) in + *FPREGSETP with the value in GDB's register array. If REGNO is -1, + do this for all registers. */ +=20 + void + fill_fpregset (elf_fpregset_t * fpregsetp, int regno) + { + i387_fill_fxsave ((char *) fpregsetp, regno); + } +=20 --------------000705010708030008070308--