[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: working xfree86 4.1.0?



Richard Zidlicky <Richard.Zidlicky@stud.informatik.uni-erlangen.de> writes:

|> I have gdb 5.0 though coredump reading doesn't work yet.

Could you please try this patch?

Index: src/gdb/config/m68k/tm-m68k.h
===================================================================
RCS file: /cvs/src/src/gdb/config/m68k/tm-m68k.h,v
retrieving revision 1.8
diff -u -a -u -r1.8 src/gdb/config/m68k/tm-m68k.h
--- src/gdb/config/m68k/tm-m68k.h	2002/01/05 04:30:34	1.8
+++ src/gdb/config/m68k/tm-m68k.h	2002/01/19 22:29:37
@@ -194,6 +194,7 @@
 #define FPC_REGNUM 26		/* 68881 control register */
 #define FPS_REGNUM 27		/* 68881 status register */
 #define FPI_REGNUM 28		/* 68881 iaddr register */
+#define LAST_FPU_CTRL_REGNUM 28
 
 /* Store the address of the place in which to copy the structure the
    subroutine will return.  This is called from call_function. */
Index: src/gdb/m68klinux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/m68klinux-nat.c,v
retrieving revision 1.6
diff -u -a -u -r1.6 src/gdb/m68klinux-nat.c
--- src/gdb/m68klinux-nat.c	2001/07/11 18:39:11	1.6
+++ src/gdb/m68klinux-nat.c	2002/01/19 22:27:53
@@ -32,11 +32,16 @@
 #include <sys/param.h>
 #include <sys/dir.h>
 #include <signal.h>
+#include <sys/ptrace.h>
 #include <sys/user.h>
 #include <sys/ioctl.h>
 #include <fcntl.h>
 #include <sys/procfs.h>
 
+#ifdef HAVE_SYS_REG_H
+#include <sys/reg.h>
+#endif
+
 #include <sys/file.h>
 #include "gdb_stat.h"
 
@@ -57,6 +62,26 @@
   45, 46, 47
 };
 
+/* Which ptrace request retrieves which registers?
+   These apply to the corresponding SET requests as well.  */
+#define NUM_GREGS (18)
+#define MAX_NUM_REGS (NUM_GREGS + 11)
+#define GETREGS_SUPPLIES(regno) \
+  (0 <= (regno) && (regno) < NUM_GREGS)
+#define GETFPREGS_SUPPLIES(regno) \
+  (FP0_REGNUM <= (regno) && (regno) <= LAST_FPU_CTRL_REGNUM)
+
+/* Does the current host support the GETREGS request?  */
+int have_ptrace_getregs =
+#ifdef HAVE_PTRACE_GETREGS
+  1
+#else
+  0
+#endif
+;
+
+
+
 /* BLOCKEND is the value of u.u_ar0, and points to the place where GS
    is stored.  */
 
@@ -87,32 +112,240 @@
 void
 supply_gregset (elf_gregset_t *gregsetp)
 {
+  elf_greg_t *regp = (elf_greg_t *) gregsetp;
   int regi;
 
   for (regi = D0_REGNUM; regi <= SP_REGNUM; regi++)
-    supply_register (regi, (char *) (*gregsetp + regmap[regi]));
-  supply_register (PS_REGNUM, (char *) (*gregsetp + PT_SR));
-  supply_register (PC_REGNUM, (char *) (*gregsetp + PT_PC));
+    supply_register (regi, (char *) &regp[regmap[regi]]);
+  supply_register (PS_REGNUM, (char *) &regp[PT_SR]);
+  supply_register (PC_REGNUM, (char *) &regp[PT_PC]);
 }
+
+/* Convert the valid general-purpose register values in GDB's register
+   array to `struct user' format and store them in *GREGSETP.  The
+   array VALID indicates which register values are valid.  If VALID is
+   NULL, all registers are assumed to be valid.  */
 
-/*  Given a pointer to a floating point register set in /proc format
-   (fpregset_t *), unpack the register contents and supply them as gdb's
-   idea of the current floating point register values. */
+static void
+convert_to_gregset (elf_gregset_t *gregsetp, char *valid)
+{
+  elf_greg_t *regp = (elf_greg_t *) gregsetp;
+  int regi;
 
+  for (regi = 0; regi < NUM_GREGS; regi++)
+    if (! valid || valid[regi])
+      regp[regmap[regi]] = *(int *) &registers[REGISTER_BYTE (regi)];
+}
+
+/* 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)
+{
+  if (regno == -1)
+    {
+      convert_to_gregset (gregsetp, NULL);
+      return;
+    }
+
+  if (GETREGS_SUPPLIES (regno))
+    {
+      char valid[NUM_GREGS];
+
+      memset (valid, 0, sizeof (valid));
+      valid[regno] = 1;
+
+      convert_to_gregset (gregsetp, valid);
+    }
+}
+
+#ifdef HAVE_PTRACE_GETREGS
+
+/* Fetch all general-purpose registers from process/thread TID and
+   store their values in GDB's register array.  */
+
+static void
+fetch_regs (int tid)
+{
+  elf_gregset_t regs;
+  int ret;
+
+  ret = ptrace (PTRACE_GETREGS, tid, 0, (int) &regs);
+  if (ret < 0)
+    {
+      if (errno == EIO)
+	{
+	  /* The kernel we're running on doesn't support the GETREGS
+             request.  Reset `have_ptrace_getregs'.  */
+	  have_ptrace_getregs = 0;
+	  return;
+	}
+
+      warning ("Couldn't get registers.");
+      return;
+    }
+
+  supply_gregset (&regs);
+}
+
+/* Store all valid general-purpose registers in GDB's register array
+   into the process/thread specified by TID.  */
+
+static void
+store_regs (int tid)
+{
+  elf_gregset_t regs;
+  int ret;
+
+  ret = ptrace (PTRACE_GETREGS, tid, 0, (int) &regs);
+  if (ret < 0)
+    {
+      warning ("Couldn't get registers.");
+      return;
+    }
+
+  convert_to_gregset (&regs, register_valid);
+
+  ret = ptrace (PTRACE_SETREGS, tid, 0, (int) &regs);
+  if (ret < 0)
+    {
+      warning ("Couldn't write registers.");
+      return;
+    }
+}
+
+#else
+
+static void fetch_regs (int tid) {}
+static void store_regs (int tid) {}
+
+#endif
+
+
+/* Transfering floating-point registers between GDB, inferiors and cores.  */
+
+/* What is the address of fpN within the floating-point register set F?  */
+#define FPREG_ADDR(f, n) ((char *) &(f)->fpregs[(n) * 3])
+
+/* Fill GDB's register array with the floating-point register values in
+   *FPREGSETP.  */
+
+void
 supply_fpregset (elf_fpregset_t *fpregsetp)
 {
   int regi;
 
   for (regi = FP0_REGNUM; regi < FPC_REGNUM; regi++)
-    supply_register (regi, (char *) &fpregsetp->fpregs[(regi - FP0_REGNUM) * 3]);
+    supply_register (regi, FPREG_ADDR (fpregsetp, regi - FP0_REGNUM));
   supply_register (FPC_REGNUM, (char *) &fpregsetp->fpcntl[0]);
   supply_register (FPS_REGNUM, (char *) &fpregsetp->fpcntl[1]);
   supply_register (FPI_REGNUM, (char *) &fpregsetp->fpcntl[2]);
 }
 
+/* Convert the valid floating-point register values in GDB's register
+   array to `struct user' format and store them in *FPREGSETP.  The
+   array VALID indicates which register values are valid.  If VALID is
+   NULL, all registers are assumed to be valid.  */
+
+static void
+convert_to_fpregset (elf_fpregset_t *fpregsetp, char *valid)
+{
+  int reg;
+
+  /* Fill in the floating-point registers.  */
+  for (reg = 0; reg < 8; reg++)
+    if (!valid || valid[FP0_REGNUM + reg])
+      memcpy (FPREG_ADDR (fpregsetp, reg),
+	      &registers[REGISTER_BYTE (FP0_REGNUM + reg)],
+	      REGISTER_RAW_SIZE(FP0_REGNUM + reg));
+
+  /* Fill in the floating-point control registers.  */
+  for (reg = 0; reg < 3; reg++)
+    if (!valid || valid[FPC_REGNUM + reg])
+      fpregsetp->fpcntl[reg]
+	= *(int *) &registers[REGISTER_BYTE (FPC_REGNUM + reg)];
+}
+
+/* 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)
+{
+  if (regno == -1)
+    {
+      convert_to_fpregset (fpregsetp, NULL);
+      return;
+    }
+
+  if (GETFPREGS_SUPPLIES (regno))
+    {
+      char valid[MAX_NUM_REGS];
+      
+      memset (valid, 0, sizeof (valid));
+      valid[regno] = 1;
+	      
+      convert_to_fpregset (fpregsetp, valid);
+    }
+}
+
+#ifdef HAVE_PTRACE_GETREGS
+
+/* Fetch all floating-point registers from process/thread TID and store
+   thier values in GDB's register array.  */
+
+static void
+fetch_fpregs (int tid)
+{
+  elf_fpregset_t fpregs;
+  int ret;
+
+  ret = ptrace (PTRACE_GETFPREGS, tid, 0, (int) &fpregs);
+  if (ret < 0)
+    {
+      warning ("Couldn't get floating point status.");
+      return;
+    }
+
+  supply_fpregset (&fpregs);
+}
+
+/* Store all valid floating-point registers in GDB's register array
+   into the process/thread specified by TID.  */
+
+static void
+store_fpregs (int tid)
+{
+  elf_fpregset_t fpregs;
+  int ret;
+
+  ret = ptrace (PTRACE_GETFPREGS, tid, 0, (int) &fpregs);
+  if (ret < 0)
+    {
+      warning ("Couldn't get floating point status.");
+      return;
+    }
+
+  convert_to_fpregset (&fpregs, register_valid);
+
+  ret = ptrace (PTRACE_SETFPREGS, tid, 0, (int) &fpregs);
+  if (ret < 0)
+    {
+      warning ("Couldn't write floating point status.");
+      return;
+    }
+}
+
+#else
+
+static void fetch_fpregs (int tid) {}
+static void store_fpregs (int tid) {}
+
 #endif
 
+#endif

 /* Interpreting register set info found in core files.  */
 

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE GmbH, 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."



Reply to: