* [RFA] Re: Analyzing AMD64 corefiles on i386
[not found] ` <200307081445.h68EjBWJ000503@elgar.kettenis.dyndns.org>
@ 2003-07-09 11:03 ` Michal Ludvig
2003-07-09 11:56 ` Andreas Schwab
2003-07-09 13:38 ` Mark Kettenis
0 siblings, 2 replies; 10+ messages in thread
From: Michal Ludvig @ 2003-07-09 11:03 UTC (permalink / raw)
To: Mark Kettenis; +Cc: GDB Patches
[-- Attachment #1: Type: text/plain, Size: 917 bytes --]
Mark Kettenis told me that:
> Date: Tue, 08 Jul 2003 14:43:49 +0200
> From: Michal Ludvig <mludvig@suse.cz>
>
> Hi,
> what must be done to enable reading of AMD64 corefiles in a gdb running
> on i386 with --target=amd64?
>
> The necessary support for corefiles needs to be added to
> x86-64-linux-tdep.c. Take a look at i386nbsd-tdep.c for an example.
> You'll need to create a `struct core_fns' together with the necessary
> support functions, and register it with add_core_fns. Note that for
> the support functions you can't rely on definitions in header files
> and such since this is target code. You'll also need to drop
> core-regset.o from NATDEPFILES in x86-64-linux.mh.
How about the attached one? Works for me on cross-gdb i386->amd64 as
well as in native amd64 gdb. Can I apply it?
Michal Ludvig
--
* SuSE CR, s.r.o * mludvig@suse.cz
* (+420) 296.545.373 * http://www.suse.cz
[-- Attachment #2: crosscore-2.diff --]
[-- Type: text/plain, Size: 7610 bytes --]
2003-07-09 Michal Ludvig <mludvig@suse.cz>
* x86-64-linux-nat.c (regmap, supply_gregset, fill_gregset):
Moved to x86-64-linux-tdep.c.
* x86-64-linux-tdep.c (regmap, supply_gregset, fill_gregset):
Moved from x86-64-linux-nat.c.
(REGNR_*): New defines from <sys/reg.h>
(fetch_core_registers, x86_64_core_fns): New.
(_initialize_x86_64_linux_tdep): Call add_core_fns().
* config/i386/x86-64linux.mh (NATDEPFILES): Remove corelow.o
and core-regset.o.
* config/i386/x86-64linux.mt (TDEPFILES): Add corelow.o.
Index: x86-64-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-linux-nat.c,v
retrieving revision 1.23
diff -u -p -r1.23 x86-64-linux-nat.c
--- x86-64-linux-nat.c 31 May 2003 18:00:04 -0000 1.23
+++ x86-64-linux-nat.c 9 Jul 2003 10:56:13 -0000
@@ -39,24 +39,6 @@
#include "x86-64-tdep.h"
-/* The register sets used in GNU/Linux ELF core-dumps are identical to
- the register sets used by `ptrace'. The corresponding types are
- `elf_gregset_t' for the general-purpose registers (with
- `elf_greg_t' the type of a single GP register) and `elf_fpregset_t'
- for the floating-point registers. */
-
-/* Mapping between the general-purpose registers in `struct user'
- format and GDB's register array layout. */
-static int regmap[] =
-{
- RAX, RBX, RCX, RDX,
- RSI, RDI, RBP, RSP,
- R8, R9, R10, R11,
- R12, R13, R14, R15,
- RIP, EFLAGS, CS, SS,
- DS, ES, FS, GS
-};
-
/* Which ptrace request retrieves which registers?
These apply to the corresponding SET requests as well. */
@@ -69,34 +51,6 @@ static int regmap[] =
/* Transfering the general-purpose registers between GDB, inferiors
and core files. */
-
-/* Fill GDB's register array with the general-purpose register values
- in *GREGSETP. */
-
-void
-supply_gregset (elf_gregset_t *gregsetp)
-{
- elf_greg_t *regp = (elf_greg_t *) gregsetp;
- int i;
-
- for (i = 0; i < X86_64_NUM_GREGS; i++)
- supply_register (i, regp + regmap[i]);
-}
-
-/* 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. */
-
-void
-fill_gregset (elf_gregset_t *gregsetp, int regno)
-{
- elf_greg_t *regp = (elf_greg_t *) gregsetp;
- int i;
-
- for (i = 0; i < X86_64_NUM_GREGS; i++)
- if (regno == -1 || regno == i)
- regcache_collect (i, regp + regmap[i]);
-}
/* Fetch all general-purpose registers from process/thread TID and
store their values in GDB's register array. */
Index: x86-64-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-linux-tdep.c,v
retrieving revision 1.19
diff -u -p -r1.19 x86-64-linux-tdep.c
--- x86-64-linux-tdep.c 31 May 2003 16:11:47 -0000 1.19
+++ x86-64-linux-tdep.c 9 Jul 2003 10:56:13 -0000
@@ -31,6 +31,113 @@
#include "x86-64-tdep.h"
+/* The register sets used in GNU/Linux ELF core-dumps are identical to
+ the register sets used by `ptrace'. The corresponding types are
+ `elf_gregset_t' for the general-purpose registers (with
+ `elf_greg_t' the type of a single GP register) and `elf_fpregset_t'
+ for the floating-point registers. */
+
+/* Register indexes from <sys/reg.h>. */
+#define REGNR_R15 0
+#define REGNR_R14 1
+#define REGNR_R13 2
+#define REGNR_R12 3
+#define REGNR_RBP 4
+#define REGNR_RBX 5
+#define REGNR_R11 6
+#define REGNR_R10 7
+#define REGNR_R9 8
+#define REGNR_R8 9
+#define REGNR_RAX 10
+#define REGNR_RCX 11
+#define REGNR_RDX 12
+#define REGNR_RSI 13
+#define REGNR_RDI 14
+#define REGNR_RIP 16
+#define REGNR_CS 17
+#define REGNR_EFLAGS 18
+#define REGNR_RSP 19
+#define REGNR_SS 20
+#define REGNR_DS 23
+#define REGNR_ES 24
+#define REGNR_FS 25
+#define REGNR_GS 26
+
+/* Mapping between the general-purpose registers in `struct user'
+ format and GDB's register array layout. */
+static int regmap[] =
+{
+ REGNR_RAX, REGNR_RBX, REGNR_RCX, REGNR_RDX,
+ REGNR_RSI, REGNR_RDI, REGNR_RBP, REGNR_RSP,
+ REGNR_R8, REGNR_R9, REGNR_R10, REGNR_R11,
+ REGNR_R12, REGNR_R13, REGNR_R14, REGNR_R15,
+ REGNR_RIP, REGNR_EFLAGS, REGNR_CS, REGNR_SS,
+ REGNR_DS, REGNR_ES, REGNR_FS, REGNR_GS
+};
+
+/* Fill GDB's register array with the general-purpose register values
+ in *GREGSETP. */
+
+void
+supply_gregset (char *regp)
+{
+ int i;
+
+ for (i = 0; i < X86_64_NUM_GREGS; i++)
+ supply_register (i, regp + (regmap[i] * 8));
+}
+
+/* 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. */
+
+void
+fill_gregset (char *regp, int regno)
+{
+ int i;
+
+ for (i = 0; i < X86_64_NUM_GREGS; i++)
+ if (regno == -1 || regno == i)
+ regcache_collect (i, regp + (regmap[i] * 8));
+}
+
+static void
+fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
+ int which, CORE_ADDR ignore)
+{
+ switch (which)
+ {
+ case 0: /* Integer registers. */
+ if (core_reg_size != 216)
+ warning ("Wrong size register set in core file.");
+ else
+ supply_gregset (core_reg_sect);
+ break;
+
+ case 2: /* Floating point registers. */
+ case 3: /* "Extended" floating point registers. This is gdb-speak
+ for SSE/SSE2. */
+ if (core_reg_size != 512)
+ warning ("Wrong size XMM register set in core file.");
+ else
+ x86_64_supply_fxsave (core_reg_sect);
+ break;
+
+ default:
+ /* Don't know what kind of register request this is; just ignore it. */
+ break;
+ }
+}
+
+static struct core_fns x86_64_core_fns =
+{
+ bfd_target_elf_flavour, /* core_flavour */
+ default_check_format, /* check_format */
+ default_core_sniffer, /* core_sniffer */
+ fetch_core_registers, /* core_read_registers */
+ NULL /* next */
+};
+
#define LINUX_SIGTRAMP_INSN0 0x48 /* mov $NNNNNNNN, %rax */
#define LINUX_SIGTRAMP_OFFSET0 0
#define LINUX_SIGTRAMP_INSN1 0x0f /* syscall */
@@ -175,6 +282,8 @@ extern void _initialize_x86_64_linux_tde
void
_initialize_x86_64_linux_tdep (void)
{
+ add_core_fns (&x86_64_core_fns);
+
gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, GDB_OSABI_LINUX,
x86_64_linux_init_abi);
}
Index: config/i386/x86-64linux.mh
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/x86-64linux.mh,v
retrieving revision 1.9
diff -u -p -r1.9 x86-64linux.mh
--- config/i386/x86-64linux.mh 15 Jun 2003 20:56:47 -0000 1.9
+++ config/i386/x86-64linux.mh 9 Jul 2003 10:56:13 -0000
@@ -3,8 +3,8 @@
XM_FILE= xm-i386.h
NAT_FILE= nm-x86-64linux.h
-NATDEPFILES= infptrace.o inftarg.o fork-child.o corelow.o \
- core-regset.o i386-nat.o x86-64-linux-nat.o \
+NATDEPFILES= infptrace.o inftarg.o fork-child.o \
+ i386-nat.o x86-64-linux-nat.o \
linux-nat.o \
proc-service.o thread-db.o lin-lwp.o linux-proc.o gcore.o
Index: config/i386/x86-64linux.mt
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/x86-64linux.mt,v
retrieving revision 1.7
diff -u -p -r1.7 x86-64linux.mt
--- config/i386/x86-64linux.mt 31 May 2003 08:15:38 -0000 1.7
+++ config/i386/x86-64linux.mt 9 Jul 2003 10:56:13 -0000
@@ -1,7 +1,7 @@
# Target: AMD x86-64 running GNU/Linux
TDEPFILES= x86-64-tdep.o x86-64-linux-tdep.o \
i386-tdep.o i387-tdep.o i386-linux-tdep.o \
- solib.o solib-svr4.o solib-legacy.o
+ solib.o solib-svr4.o solib-legacy.o corelow.o
GDB_MULTI_ARCH=GDB_MULTI_ARCH_TM
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFA] Re: Analyzing AMD64 corefiles on i386
2003-07-09 11:03 ` [RFA] Re: Analyzing AMD64 corefiles on i386 Michal Ludvig
@ 2003-07-09 11:56 ` Andreas Schwab
2003-07-09 13:40 ` Mark Kettenis
2003-07-09 13:38 ` Mark Kettenis
1 sibling, 1 reply; 10+ messages in thread
From: Andreas Schwab @ 2003-07-09 11:56 UTC (permalink / raw)
To: Michal Ludvig; +Cc: Mark Kettenis, GDB Patches
Michal Ludvig <mludvig@suse.cz> writes:
|> 2003-07-09 Michal Ludvig <mludvig@suse.cz>
|>
|> * x86-64-linux-nat.c (regmap, supply_gregset, fill_gregset):
|> Moved to x86-64-linux-tdep.c.
|> * x86-64-linux-tdep.c (regmap, supply_gregset, fill_gregset):
|> Moved from x86-64-linux-nat.c.
Hmm, m68klinux-nat.c has this comment:
/* Note both m68k-tdep.c and m68klinux-nat.c contain definitions
for supply_gregset and supply_fpregset. The definitions
in m68k-tdep.c are valid if USE_PROC_FS is defined. Otherwise,
the definitions in m68klinux-nat.c will be used. This is a
bit of a hack. The supply_* routines do not belong in
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*_tdep.c files. But, there are several lynx ports that currently
^^^^^^^^^^^^^^
depend on these definitions. */
What's the current wisdom about that?
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFA] Re: Analyzing AMD64 corefiles on i386
2003-07-09 11:03 ` [RFA] Re: Analyzing AMD64 corefiles on i386 Michal Ludvig
2003-07-09 11:56 ` Andreas Schwab
@ 2003-07-09 13:38 ` Mark Kettenis
2003-07-09 18:08 ` Daniel Jacobowitz
2003-07-10 10:05 ` Michal Ludvig
1 sibling, 2 replies; 10+ messages in thread
From: Mark Kettenis @ 2003-07-09 13:38 UTC (permalink / raw)
To: mludvig; +Cc: gdb-patches
Date: Wed, 09 Jul 2003 13:03:06 +0200
From: Michal Ludvig <mludvig@suse.cz>
This is a multi-part message in MIME format.
--------------050406070409000508090803
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Mark Kettenis told me that:
> Date: Tue, 08 Jul 2003 14:43:49 +0200
> From: Michal Ludvig <mludvig@suse.cz>
>
> Hi,
> what must be done to enable reading of AMD64 corefiles in a gdb running
> on i386 with --target=amd64?
>
> The necessary support for corefiles needs to be added to
> x86-64-linux-tdep.c. Take a look at i386nbsd-tdep.c for an example.
> You'll need to create a `struct core_fns' together with the necessary
> support functions, and register it with add_core_fns. Note that for
> the support functions you can't rely on definitions in header files
> and such since this is target code. You'll also need to drop
> core-regset.o from NATDEPFILES in x86-64-linux.mh.
How about the attached one? Works for me on cross-gdb i386->amd64 as
well as in native amd64 gdb. Can I apply it?
Not as such. We can't allow public functions with the names
supply_gregset and fill_gregset in *-tdep.c files. Therefore these
functions should be renamed, and supply_gregset and fill_gregset
should be kept in your *-nat.c file. You'll probably want to rewrite
those functions such that they call the new functions in *-tdep.c.
Personally I wouldn't define all those constants if the only place
where they'll be used is the regmap array, but that's a matter of
taste.
Mark
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFA] Re: Analyzing AMD64 corefiles on i386
2003-07-09 11:56 ` Andreas Schwab
@ 2003-07-09 13:40 ` Mark Kettenis
0 siblings, 0 replies; 10+ messages in thread
From: Mark Kettenis @ 2003-07-09 13:40 UTC (permalink / raw)
To: schwab; +Cc: mludvig, gdb-patches
From: Andreas Schwab <schwab@suse.de>
Date: Wed, 09 Jul 2003 13:56:44 +0200
Michal Ludvig <mludvig@suse.cz> writes:
|> 2003-07-09 Michal Ludvig <mludvig@suse.cz>
|>
|> * x86-64-linux-nat.c (regmap, supply_gregset, fill_gregset):
|> Moved to x86-64-linux-tdep.c.
|> * x86-64-linux-tdep.c (regmap, supply_gregset, fill_gregset):
|> Moved from x86-64-linux-nat.c.
Hmm, m68klinux-nat.c has this comment:
/* Note both m68k-tdep.c and m68klinux-nat.c contain definitions
for supply_gregset and supply_fpregset. The definitions
in m68k-tdep.c are valid if USE_PROC_FS is defined. Otherwise,
the definitions in m68klinux-nat.c will be used. This is a
bit of a hack. The supply_* routines do not belong in
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*_tdep.c files. But, there are several lynx ports that currently
^^^^^^^^^^^^^^
depend on these definitions. */
What's the current wisdom about that?
It's still true. If register conversion functions are implemented in
*-tdep.c files, they should not be named supply_gregset/fill_gregset.
Mark
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFA] Re: Analyzing AMD64 corefiles on i386
2003-07-09 13:38 ` Mark Kettenis
@ 2003-07-09 18:08 ` Daniel Jacobowitz
2003-07-09 19:52 ` Andrew Cagney
2003-07-09 21:46 ` Mark Kettenis
2003-07-10 10:05 ` Michal Ludvig
1 sibling, 2 replies; 10+ messages in thread
From: Daniel Jacobowitz @ 2003-07-09 18:08 UTC (permalink / raw)
To: Mark Kettenis; +Cc: mludvig, gdb-patches
On Wed, Jul 09, 2003 at 03:38:08PM +0200, Mark Kettenis wrote:
> Date: Wed, 09 Jul 2003 13:03:06 +0200
> From: Michal Ludvig <mludvig@suse.cz>
>
> This is a multi-part message in MIME format.
> --------------050406070409000508090803
> Content-Type: text/plain; charset=us-ascii; format=flowed
> Content-Transfer-Encoding: 7bit
>
> Mark Kettenis told me that:
> > Date: Tue, 08 Jul 2003 14:43:49 +0200
> > From: Michal Ludvig <mludvig@suse.cz>
> >
> > Hi,
> > what must be done to enable reading of AMD64 corefiles in a gdb running
> > on i386 with --target=amd64?
> >
> > The necessary support for corefiles needs to be added to
> > x86-64-linux-tdep.c. Take a look at i386nbsd-tdep.c for an example.
> > You'll need to create a `struct core_fns' together with the necessary
> > support functions, and register it with add_core_fns. Note that for
> > the support functions you can't rely on definitions in header files
> > and such since this is target code. You'll also need to drop
> > core-regset.o from NATDEPFILES in x86-64-linux.mh.
>
> How about the attached one? Works for me on cross-gdb i386->amd64 as
> well as in native amd64 gdb. Can I apply it?
>
> Not as such. We can't allow public functions with the names
> supply_gregset and fill_gregset in *-tdep.c files. Therefore these
> functions should be renamed, and supply_gregset and fill_gregset
> should be kept in your *-nat.c file. You'll probably want to rewrite
> those functions such that they call the new functions in *-tdep.c.
I don't see the harm. They need to be multi-arched instead of called
by name, eventually, but it's no extra work to rename them at that
time.
But that's just my personal opinion.
> Personally I wouldn't define all those constants if the only place
> where they'll be used is the regmap array, but that's a matter of
> taste.
I'm guessing it makes it easier to at-a-glance compare with
<sys/reg.h>. I did the same thing.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFA] Re: Analyzing AMD64 corefiles on i386
2003-07-09 18:08 ` Daniel Jacobowitz
@ 2003-07-09 19:52 ` Andrew Cagney
2003-07-09 21:46 ` Mark Kettenis
1 sibling, 0 replies; 10+ messages in thread
From: Andrew Cagney @ 2003-07-09 19:52 UTC (permalink / raw)
To: Daniel Jacobowitz, Mark Kettenis, mludvig; +Cc: gdb-patches
> Not as such. We can't allow public functions with the names
>> supply_gregset and fill_gregset in *-tdep.c files. Therefore these
>> functions should be renamed, and supply_gregset and fill_gregset
>> should be kept in your *-nat.c file. You'll probably want to rewrite
>> those functions such that they call the new functions in *-tdep.c.
That makes sense.
Andrew
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFA] Re: Analyzing AMD64 corefiles on i386
2003-07-09 18:08 ` Daniel Jacobowitz
2003-07-09 19:52 ` Andrew Cagney
@ 2003-07-09 21:46 ` Mark Kettenis
1 sibling, 0 replies; 10+ messages in thread
From: Mark Kettenis @ 2003-07-09 21:46 UTC (permalink / raw)
To: drow; +Cc: mludvig, gdb-patches
Date: Wed, 9 Jul 2003 14:08:01 -0400
From: Daniel Jacobowitz <drow@mvista.com>
> Not as such. We can't allow public functions with the names
> supply_gregset and fill_gregset in *-tdep.c files. Therefore these
> functions should be renamed, and supply_gregset and fill_gregset
> should be kept in your *-nat.c file. You'll probably want to rewrite
> those functions such that they call the new functions in *-tdep.c.
I don't see the harm. They need to be multi-arched instead of called
by name, eventually, but it's no extra work to rename them at that
time.
Not renaming them makes it impossible to build an i386 native GDB that
can also debug amd64.
> Personally I wouldn't define all those constants if the only place
> where they'll be used is the regmap array, but that's a matter of
> taste.
I'm guessing it makes it easier to at-a-glance compare with
<sys/reg.h>. I did the same thing.
That's a valid reason. Probably deserves a comment such that nobody
gratuitously re-orders the defines.
Mark
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFA] Re: Analyzing AMD64 corefiles on i386
2003-07-09 13:38 ` Mark Kettenis
2003-07-09 18:08 ` Daniel Jacobowitz
@ 2003-07-10 10:05 ` Michal Ludvig
2003-07-14 19:26 ` Mark Kettenis
1 sibling, 1 reply; 10+ messages in thread
From: Michal Ludvig @ 2003-07-10 10:05 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 878 bytes --]
Mark Kettenis told me that:
> > From: Michal Ludvig <mludvig@suse.cz>
> > what must be done to enable reading of AMD64 corefiles in a gdb running
> > on i386 with --target=amd64?
> >
> Not as such. We can't allow public functions with the names
> supply_gregset and fill_gregset in *-tdep.c files. Therefore these
> functions should be renamed, and supply_gregset and fill_gregset
> should be kept in your *-nat.c file. You'll probably want to rewrite
> those functions such that they call the new functions in *-tdep.c.
OK, I renamed them to x86_64_linux_(supply,fill)_gregset.
Where should I put the prototypes? I created a new file
x86-64-linux-tdep.h but you may prefer to put them to x86-64-tdep.h or
directly to x86-64-linux-nat.c.
Comments?
Michal Ludvig
--
* SuSE CR, s.r.o * mludvig@suse.cz
* (+420) 296.545.373 * http://www.suse.cz
[-- Attachment #2: crosscore-3.diff --]
[-- Type: text/plain, Size: 9280 bytes --]
2003-07-10 Michal Ludvig <mludvig@suse.cz>
* x86-64-linux-nat.c (regmap): Removed.
(supply_gregset, fill_gregset): Call
x86_64_linux_(fill,supply)_gregset functions.
* x86-64-linux-tdep.c (USER_*): New defines.
(user_to_gdb_regmap, x86_64_core_fns): New structure.
(x86_64_linux_supply_gregset, x86_64_linux_fill_gregset):
New functions.
(fetch_core_registers): Ditto.
(_initialize_x86_64_linux_tdep): Call add_core_fns().
* x86-64-linux-tdep.h: New file.
* config/i386/x86-64linux.mh (NATDEPFILES): Remove corelow.o
and core-regset.o.
* config/i386/x86-64linux.mt (TDEPFILES): Add corelow.o.
Index: x86-64-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-linux-nat.c,v
retrieving revision 1.23
diff -u -p -r1.23 x86-64-linux-nat.c
--- x86-64-linux-nat.c 31 May 2003 18:00:04 -0000 1.23
+++ x86-64-linux-nat.c 10 Jul 2003 09:52:33 -0000
@@ -38,24 +38,7 @@
#include "gregset.h"
#include "x86-64-tdep.h"
-
-/* The register sets used in GNU/Linux ELF core-dumps are identical to
- the register sets used by `ptrace'. The corresponding types are
- `elf_gregset_t' for the general-purpose registers (with
- `elf_greg_t' the type of a single GP register) and `elf_fpregset_t'
- for the floating-point registers. */
-
-/* Mapping between the general-purpose registers in `struct user'
- format and GDB's register array layout. */
-static int regmap[] =
-{
- RAX, RBX, RCX, RDX,
- RSI, RDI, RBP, RSP,
- R8, R9, R10, R11,
- R12, R13, R14, R15,
- RIP, EFLAGS, CS, SS,
- DS, ES, FS, GS
-};
+#include "x86-64-linux-tdep.h"
/* Which ptrace request retrieves which registers?
These apply to the corresponding SET requests as well. */
@@ -76,11 +59,7 @@ static int regmap[] =
void
supply_gregset (elf_gregset_t *gregsetp)
{
- elf_greg_t *regp = (elf_greg_t *) gregsetp;
- int i;
-
- for (i = 0; i < X86_64_NUM_GREGS; i++)
- supply_register (i, regp + regmap[i]);
+ x86_64_linux_supply_gregset ((char *) gregsetp);
}
/* Fill register REGNO (if it is a general-purpose register) in
@@ -90,12 +69,7 @@ supply_gregset (elf_gregset_t *gregsetp)
void
fill_gregset (elf_gregset_t *gregsetp, int regno)
{
- elf_greg_t *regp = (elf_greg_t *) gregsetp;
- int i;
-
- for (i = 0; i < X86_64_NUM_GREGS; i++)
- if (regno == -1 || regno == i)
- regcache_collect (i, regp + regmap[i]);
+ x86_64_linux_fill_gregset ((char *) gregsetp, regno);
}
/* Fetch all general-purpose registers from process/thread TID and
Index: x86-64-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-linux-tdep.c,v
retrieving revision 1.19
diff -u -p -r1.19 x86-64-linux-tdep.c
--- x86-64-linux-tdep.c 31 May 2003 16:11:47 -0000 1.19
+++ x86-64-linux-tdep.c 10 Jul 2003 09:52:33 -0000
@@ -30,6 +30,116 @@
#include "gdb_string.h"
#include "x86-64-tdep.h"
+#include "x86-64-linux-tdep.h"
+
+/* Register indexes to 'struct user' come from <sys/reg.h>. */
+
+#define USER_R15 0
+#define USER_R14 1
+#define USER_R13 2
+#define USER_R12 3
+#define USER_RBP 4
+#define USER_RBX 5
+#define USER_R11 6
+#define USER_R10 7
+#define USER_R9 8
+#define USER_R8 9
+#define USER_RAX 10
+#define USER_RCX 11
+#define USER_RDX 12
+#define USER_RSI 13
+#define USER_RDI 14
+#define USER_RIP 16
+#define USER_CS 17
+#define USER_EFLAGS 18
+#define USER_RSP 19
+#define USER_SS 20
+#define USER_DS 23
+#define USER_ES 24
+#define USER_FS 25
+#define USER_GS 26
+
+/* Mapping between the general-purpose registers in `struct user'
+ format and GDB's register array layout. */
+
+static int user_to_gdb_regmap[] =
+{
+ USER_RAX, USER_RBX, USER_RCX, USER_RDX,
+ USER_RSI, USER_RDI, USER_RBP, USER_RSP,
+ USER_R8, USER_R9, USER_R10, USER_R11,
+ USER_R12, USER_R13, USER_R14, USER_R15,
+ USER_RIP, USER_EFLAGS, USER_CS, USER_SS,
+ USER_DS, USER_ES, USER_FS, USER_GS
+};
+
+/* Fill GDB's register array with the general-purpose register values
+ in *GREGSETP. */
+
+void
+x86_64_linux_supply_gregset (char *regp)
+{
+ int i;
+
+ for (i = 0; i < X86_64_NUM_GREGS; i++)
+ supply_register (i, regp + (user_to_gdb_regmap[i] * 8));
+}
+
+/* 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. */
+
+void
+x86_64_linux_fill_gregset (char *regp, int regno)
+{
+ int i;
+
+ for (i = 0; i < X86_64_NUM_GREGS; i++)
+ if (regno == -1 || regno == i)
+ regcache_collect (i, regp + (user_to_gdb_regmap[i] * 8));
+}
+
+/* The register sets used in GNU/Linux ELF core-dumps are identical to
+ the register sets used by `ptrace'. The corresponding types are
+ `elf_gregset_t' for the general-purpose registers (with
+ `elf_greg_t' the type of a single GP register) and `elf_fpregset_t'
+ for the floating-point registers. */
+
+static void
+fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
+ int which, CORE_ADDR ignore)
+{
+ switch (which)
+ {
+ case 0: /* Integer registers. */
+ if (core_reg_size != 216)
+ warning ("Wrong size register set in core file.");
+ else
+ x86_64_linux_supply_gregset (core_reg_sect);
+ break;
+
+ case 2: /* Floating point registers. */
+ case 3: /* "Extended" floating point registers. This is gdb-speak
+ for SSE/SSE2. */
+ if (core_reg_size != 512)
+ warning ("Wrong size XMM register set in core file.");
+ else
+ x86_64_supply_fxsave (core_reg_sect);
+ break;
+
+ default:
+ /* Don't know what kind of register request this is; just ignore it. */
+ break;
+ }
+}
+
+static struct core_fns x86_64_core_fns =
+{
+ bfd_target_elf_flavour, /* core_flavour */
+ default_check_format, /* check_format */
+ default_core_sniffer, /* core_sniffer */
+ fetch_core_registers, /* core_read_registers */
+ NULL /* next */
+};
#define LINUX_SIGTRAMP_INSN0 0x48 /* mov $NNNNNNNN, %rax */
#define LINUX_SIGTRAMP_OFFSET0 0
@@ -175,6 +285,8 @@ extern void _initialize_x86_64_linux_tde
void
_initialize_x86_64_linux_tdep (void)
{
+ add_core_fns (&x86_64_core_fns);
+
gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, GDB_OSABI_LINUX,
x86_64_linux_init_abi);
}
Index: config/i386/x86-64linux.mh
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/x86-64linux.mh,v
retrieving revision 1.9
diff -u -p -r1.9 x86-64linux.mh
--- config/i386/x86-64linux.mh 15 Jun 2003 20:56:47 -0000 1.9
+++ config/i386/x86-64linux.mh 10 Jul 2003 09:52:33 -0000
@@ -3,8 +3,8 @@
XM_FILE= xm-i386.h
NAT_FILE= nm-x86-64linux.h
-NATDEPFILES= infptrace.o inftarg.o fork-child.o corelow.o \
- core-regset.o i386-nat.o x86-64-linux-nat.o \
+NATDEPFILES= infptrace.o inftarg.o fork-child.o \
+ i386-nat.o x86-64-linux-nat.o \
linux-nat.o \
proc-service.o thread-db.o lin-lwp.o linux-proc.o gcore.o
Index: config/i386/x86-64linux.mt
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/x86-64linux.mt,v
retrieving revision 1.7
diff -u -p -r1.7 x86-64linux.mt
--- config/i386/x86-64linux.mt 31 May 2003 08:15:38 -0000 1.7
+++ config/i386/x86-64linux.mt 10 Jul 2003 09:52:33 -0000
@@ -1,7 +1,7 @@
# Target: AMD x86-64 running GNU/Linux
TDEPFILES= x86-64-tdep.o x86-64-linux-tdep.o \
i386-tdep.o i387-tdep.o i386-linux-tdep.o \
- solib.o solib-svr4.o solib-legacy.o
+ solib.o solib-svr4.o solib-legacy.o corelow.o
GDB_MULTI_ARCH=GDB_MULTI_ARCH_TM
Index: x86-64-linux-tdep.h
===================================================================
RCS file: x86-64-linux-tdep.h
diff -N x86-64-linux-tdep.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ x86-64-linux-tdep.h 10 Jul 2003 09:58:04 -0000
@@ -0,0 +1,39 @@
+/* Target-dependent code for the x86-64.
+
+ Copyright 2003
+ Free Software Foundation, Inc.
+
+ Contributed by Michal Ludvig, SuSE AG.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef X86_64_LINUX_TDEP_H
+#define X86_64_LINUX_TDEP_H
+
+/* Fill GDB's register array with the general-purpose register values
+ in *GREGSETP. */
+
+void x86_64_linux_supply_gregset (char *regp);
+
+/* 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. */
+
+void x86_64_linux_fill_gregset (char *regp, int regno);
+
+#endif /* x86-64-linux-tdep.h */
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFA] Re: Analyzing AMD64 corefiles on i386
2003-07-10 10:05 ` Michal Ludvig
@ 2003-07-14 19:26 ` Mark Kettenis
2003-07-15 11:34 ` Michal Ludvig
0 siblings, 1 reply; 10+ messages in thread
From: Mark Kettenis @ 2003-07-14 19:26 UTC (permalink / raw)
To: mludvig; +Cc: gdb-patches
Date: Thu, 10 Jul 2003 12:05:19 +0200
From: Michal Ludvig <mludvig@suse.cz>
2003-07-10 Michal Ludvig <mludvig@suse.cz>
* x86-64-linux-nat.c (regmap): Removed.
(supply_gregset, fill_gregset): Call
x86_64_linux_(fill,supply)_gregset functions.
* x86-64-linux-tdep.c (USER_*): New defines.
(user_to_gdb_regmap, x86_64_core_fns): New structure.
(x86_64_linux_supply_gregset, x86_64_linux_fill_gregset):
New functions.
(fetch_core_registers): Ditto.
(_initialize_x86_64_linux_tdep): Call add_core_fns().
* x86-64-linux-tdep.h: New file.
* config/i386/x86-64linux.mh (NATDEPFILES): Remove corelow.o
and core-regset.o.
* config/i386/x86-64linux.mt (TDEPFILES): Add corelow.o.
This is fine. Please go ahead and check this in.
Thanks,
Mark
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFA] Re: Analyzing AMD64 corefiles on i386
2003-07-14 19:26 ` Mark Kettenis
@ 2003-07-15 11:34 ` Michal Ludvig
0 siblings, 0 replies; 10+ messages in thread
From: Michal Ludvig @ 2003-07-15 11:34 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
Mark Kettenis told me that:
> Date: Thu, 10 Jul 2003 12:05:19 +0200
> From: Michal Ludvig <mludvig@suse.cz>
>
> 2003-07-10 Michal Ludvig <mludvig@suse.cz>
>
> * x86-64-linux-nat.c (regmap): Removed.
> (supply_gregset, fill_gregset): Call
> x86_64_linux_(fill,supply)_gregset functions.
> * x86-64-linux-tdep.c (USER_*): New defines.
> (user_to_gdb_regmap, x86_64_core_fns): New structure.
> (x86_64_linux_supply_gregset, x86_64_linux_fill_gregset):
> New functions.
> (fetch_core_registers): Ditto.
> (_initialize_x86_64_linux_tdep): Call add_core_fns().
> * x86-64-linux-tdep.h: New file.
> * config/i386/x86-64linux.mh (NATDEPFILES): Remove corelow.o
> and core-regset.o.
> * config/i386/x86-64linux.mt (TDEPFILES): Add corelow.o.
>
> This is fine. Please go ahead and check this in.
Thanks, committed to both mainline and branch.
Michal Ludvig
--
* SuSE CR, s.r.o * mludvig@suse.cz
* (+420) 296.545.373 * http://www.suse.cz
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2003-07-15 11:34 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <3F0ABC85.1080700@suse.cz>
[not found] ` <200307081445.h68EjBWJ000503@elgar.kettenis.dyndns.org>
2003-07-09 11:03 ` [RFA] Re: Analyzing AMD64 corefiles on i386 Michal Ludvig
2003-07-09 11:56 ` Andreas Schwab
2003-07-09 13:40 ` Mark Kettenis
2003-07-09 13:38 ` Mark Kettenis
2003-07-09 18:08 ` Daniel Jacobowitz
2003-07-09 19:52 ` Andrew Cagney
2003-07-09 21:46 ` Mark Kettenis
2003-07-10 10:05 ` Michal Ludvig
2003-07-14 19:26 ` Mark Kettenis
2003-07-15 11:34 ` Michal Ludvig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox