* [RFC] x86-64 targeted gdb and corefiles
@ 2002-05-27 8:58 Michal Ludvig
2002-05-27 11:27 ` Jason R Thorpe
0 siblings, 1 reply; 8+ messages in thread
From: Michal Ludvig @ 2002-05-27 8:58 UTC (permalink / raw)
To: GDB Patches
[-- Attachment #1: Type: text/plain, Size: 545 bytes --]
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
[-- Attachment #2: core.diff --]
[-- Type: text/plain, Size: 5902 bytes --]
Index: gregset.h
===================================================================
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
+ /* We can't include x86-64's <asm/elf.h> directly,
+ 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];
+
+ /* 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];
+
+
+ #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
Index: x86-64-linux-nat.c
===================================================================
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 <= (regno) && (regno) <= MXCSR_REGNUM)
\f
- /* 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, (char *) (regp + x86_64_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))
- read_register_gen (i, (char *) (regp + x86_64_regmap[i]));
- }
-
/* Fetch all general-purpose registers from process/thread TID and
store their values in GDB's register array. */
--- 130,135 ----
*************** store_regs (int tid, int regno)
*** 192,218 ****
perror_with_name ("Couldn't write registers");
}
\f
-
- /* Transfering floating-point registers between GDB, inferiors and cores. */
-
- /* Fill GDB's register array with the floating-point register values in
- *FPREGSETP. */
-
- void
- supply_fpregset (elf_fpregset_t * fpregsetp)
- {
- i387_supply_fxsave ((char *) fpregsetp);
- }
-
- /* 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. */
-
- void
- fill_fpregset (elf_fpregset_t * fpregsetp, int regno)
- {
- i387_fill_fxsave ((char *) fpregsetp, regno);
- }
/* 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
===================================================================
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"
+
+ static int x86_64_regmap[] = {
+ 10, 5, 11, 12,
+ 13, 14, 4, 19,
+ 9, 8, 7, 6,
+ 3, 2, 1, 0,
+ 16, 18,
+ 23, 24, 25, 26
+ };
#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);
}
+
+ /* 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, (char *) (regp + x86_64_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))
+ read_register_gen (i, (char *) (regp + x86_64_regmap[i]));
+ }
+
+ /* Transfering floating-point registers between GDB, inferiors and cores. */
+
+ /* Fill GDB's register array with the floating-point register values in
+ *FPREGSETP. */
+
+ void
+ supply_fpregset (elf_fpregset_t * fpregsetp)
+ {
+ i387_supply_fxsave ((char *) fpregsetp);
+ }
+
+ /* 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. */
+
+ void
+ fill_fpregset (elf_fpregset_t * fpregsetp, int regno)
+ {
+ i387_fill_fxsave ((char *) fpregsetp, regno);
+ }
+
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC] x86-64 targeted gdb and corefiles
2002-05-27 8:58 [RFC] x86-64 targeted gdb and corefiles Michal Ludvig
@ 2002-05-27 11:27 ` Jason R Thorpe
2002-05-27 12:01 ` Daniel Jacobowitz
0 siblings, 1 reply; 8+ messages in thread
From: Jason R Thorpe @ 2002-05-27 11:27 UTC (permalink / raw)
To: Michal Ludvig; +Cc: GDB Patches
On Mon, May 27, 2002 at 05:05:14PM +0200, Michal Ludvig wrote:
> 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?
Take a look at e.g. mipsnbsd-nat.c and mipsnbsd-tdep.c (I'm slowly
making all NetBSD configurations fully cross-debug'able, and MIPS
and SH are good examples of my strategy).
As far as I'm concerned, it's simply not appropriate to be using generic
"regset" routines, because the names of those routines inherently make
them impossible to use for cross-debugging, especially in a truly multi-arch
environment (or even one as simple as "32-bit code running on x86-64").
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC] x86-64 targeted gdb and corefiles
2002-05-27 11:27 ` Jason R Thorpe
@ 2002-05-27 12:01 ` Daniel Jacobowitz
2002-05-27 12:24 ` Jason R Thorpe
2002-05-28 19:30 ` Andrew Cagney
0 siblings, 2 replies; 8+ messages in thread
From: Daniel Jacobowitz @ 2002-05-27 12:01 UTC (permalink / raw)
To: Jason R Thorpe, Michal Ludvig, GDB Patches
On Mon, May 27, 2002 at 11:11:57AM -0700, Jason R Thorpe wrote:
> On Mon, May 27, 2002 at 05:05:14PM +0200, Michal Ludvig wrote:
>
> > 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?
>
> Take a look at e.g. mipsnbsd-nat.c and mipsnbsd-tdep.c (I'm slowly
> making all NetBSD configurations fully cross-debug'able, and MIPS
> and SH are good examples of my strategy).
>
> As far as I'm concerned, it's simply not appropriate to be using generic
> "regset" routines, because the names of those routines inherently make
> them impossible to use for cross-debugging, especially in a truly multi-arch
> environment (or even one as simple as "32-bit code running on x86-64").
Seconded; perhaps with all the attention cross cores have been getting
lately it's time for a better framework for this? I was thinking
something like:
struct regset_handler {
enum type regset_kind; /* general, FP, extended */
int size;
void (*supply)();
void (*fetch)();
};
See gdbserver's regset handling for a more concrete example of this.
This could be used to kill all the duplicate copies of core-regset.c
that have made their way into i386 and powerpc tdep files.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC] x86-64 targeted gdb and corefiles
2002-05-27 12:01 ` Daniel Jacobowitz
@ 2002-05-27 12:24 ` Jason R Thorpe
2002-05-28 3:50 ` Daniel Jacobowitz
2002-05-28 19:30 ` Andrew Cagney
1 sibling, 1 reply; 8+ messages in thread
From: Jason R Thorpe @ 2002-05-27 12:24 UTC (permalink / raw)
To: Michal Ludvig, GDB Patches
On Mon, May 27, 2002 at 02:40:29PM -0400, Daniel Jacobowitz wrote:
> Seconded; perhaps with all the attention cross cores have been getting
> lately it's time for a better framework for this? I was thinking
> something like:
>
> struct regset_handler {
> enum type regset_kind; /* general, FP, extended */
> int size;
> void (*supply)();
> void (*fetch)();
> };
>
> See gdbserver's regset handling for a more concrete example of this.
> This could be used to kill all the duplicate copies of core-regset.c
> that have made their way into i386 and powerpc tdep files.
Yah, probably not a bad idea. My only concern would be how do you
register and look up these regset handlers. They need to be tied
to the OS ABI somehow.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC] x86-64 targeted gdb and corefiles
2002-05-27 12:24 ` Jason R Thorpe
@ 2002-05-28 3:50 ` Daniel Jacobowitz
2002-05-28 8:33 ` Jason R Thorpe
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2002-05-28 3:50 UTC (permalink / raw)
To: Jason R Thorpe, Michal Ludvig, GDB Patches
On Mon, May 27, 2002 at 12:01:11PM -0700, Jason R Thorpe wrote:
> On Mon, May 27, 2002 at 02:40:29PM -0400, Daniel Jacobowitz wrote:
>
> > Seconded; perhaps with all the attention cross cores have been getting
> > lately it's time for a better framework for this? I was thinking
> > something like:
> >
> > struct regset_handler {
> > enum type regset_kind; /* general, FP, extended */
> > int size;
> > void (*supply)();
> > void (*fetch)();
> > };
> >
> > See gdbserver's regset handling for a more concrete example of this.
> > This could be used to kill all the duplicate copies of core-regset.c
> > that have made their way into i386 and powerpc tdep files.
>
> Yah, probably not a bad idea. My only concern would be how do you
> register and look up these regset handlers. They need to be tied
> to the OS ABI somehow.
You just said the "how" yourself :)
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC] x86-64 targeted gdb and corefiles
2002-05-28 3:50 ` Daniel Jacobowitz
@ 2002-05-28 8:33 ` Jason R Thorpe
0 siblings, 0 replies; 8+ messages in thread
From: Jason R Thorpe @ 2002-05-28 8:33 UTC (permalink / raw)
To: Michal Ludvig, GDB Patches
On Tue, May 28, 2002 at 04:11:03AM -0400, Daniel Jacobowitz wrote:
> You just said the "how" yourself :)
Heh.
Actually, I was walking back to my house from the grocery store yesterday
and had a brainstorm on how it would be implemented. I might have some
time to churn out a proof-of-concept implementation in a week, or so.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] x86-64 targeted gdb and corefiles
2002-05-27 12:01 ` Daniel Jacobowitz
2002-05-27 12:24 ` Jason R Thorpe
@ 2002-05-28 19:30 ` Andrew Cagney
1 sibling, 0 replies; 8+ messages in thread
From: Andrew Cagney @ 2002-05-28 19:30 UTC (permalink / raw)
To: Daniel Jacobowitz, Jason R Thorpe, Michal Ludvig; +Cc: GDB Patches
> As far as I'm concerned, it's simply not appropriate to be using generic
>> "regset" routines, because the names of those routines inherently make
>> them impossible to use for cross-debugging, especially in a truly multi-arch
>> environment (or even one as simple as "32-bit code running on x86-64").
>
>
> Seconded; perhaps with all the attention cross cores have been getting
> lately it's time for a better framework for this? I was thinking
> something like:
>
> struct regset_handler {
> enum type regset_kind; /* general, FP, extended */
> int size;
> void (*supply)();
> void (*fetch)();
> };
While something like this is definitly needed, I think it is getting
slightly beyond the bounds of what MichaelL needs to do - get core files
working, using current mechanisms, for x86-64.
enjoy,
Andrew
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] x86-64 targeted gdb and corefiles
@ 2002-05-27 15:00 Mark Kettenis
0 siblings, 0 replies; 8+ messages in thread
From: Mark Kettenis @ 2002-05-27 15:00 UTC (permalink / raw)
To: Michal Ludvig; +Cc: GDB Patches
Michal Ludvig <mludvig@suse.cz> writes:
> 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?
Take a look at how this is done for various NetBSD targets (sh, alpha,
i386). Basically, get rid of the elf_gregset_t type and adapt the
functions that "parse" the register set to handle a "raw" buffer.
Since all registers are of the same size, that shouldn't be too
complicated.
Mark
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2002-05-29 2:19 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-27 8:58 [RFC] x86-64 targeted gdb and corefiles Michal Ludvig
2002-05-27 11:27 ` Jason R Thorpe
2002-05-27 12:01 ` Daniel Jacobowitz
2002-05-27 12:24 ` Jason R Thorpe
2002-05-28 3:50 ` Daniel Jacobowitz
2002-05-28 8:33 ` Jason R Thorpe
2002-05-28 19:30 ` Andrew Cagney
2002-05-27 15:00 Mark Kettenis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox