Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* 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
* [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

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 15:00 [RFC] x86-64 targeted gdb and corefiles Mark Kettenis
  -- strict thread matches above, loose matches on Subject: below --
2002-05-27  8:58 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox