Source-Changes-HG archive

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

[src/trunk]: src/gnu/dist/toolchain/gdb merge nathanw_sa



details:   https://anonhg.NetBSD.org/src/rev/cbf8f19ffaa0
branches:  trunk
changeset: 541819:cbf8f19ffaa0
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jan 18 21:42:07 2003 +0000

description:
merge nathanw_sa

diffstat:

 gnu/dist/toolchain/gdb/alphanbsd-nat.c  |   64 ++++++++-
 gnu/dist/toolchain/gdb/armnbsd-nat.c    |   91 ++++++++++--
 gnu/dist/toolchain/gdb/config/nm-nbsd.h |   10 +
 gnu/dist/toolchain/gdb/configure.in     |   11 +
 gnu/dist/toolchain/gdb/corelow.c        |    3 +-
 gnu/dist/toolchain/gdb/i386nbsd-nat.c   |  215 +++++++++++++++++++------------
 gnu/dist/toolchain/gdb/kcore-nbsd.c     |    3 +-
 gnu/dist/toolchain/gdb/ppcnbsd-nat.c    |   88 +++++++++---
 8 files changed, 346 insertions(+), 139 deletions(-)

diffs (truncated from 712 to 300 lines):

diff -r bba1fd4a6a75 -r cbf8f19ffaa0 gnu/dist/toolchain/gdb/alphanbsd-nat.c
--- a/gnu/dist/toolchain/gdb/alphanbsd-nat.c    Sat Jan 18 21:38:03 2003 +0000
+++ b/gnu/dist/toolchain/gdb/alphanbsd-nat.c    Sat Jan 18 21:42:07 2003 +0000
@@ -91,6 +91,14 @@
 }
 
 static void
+unsupply_regs (regs)
+     struct reg *regs;
+{
+  memcpy (&regs->r_regs[0], &registers[REGISTER_BYTE (V0_REGNUM)], 31 * 8);
+  memcpy (&regs->r_regs[31], &registers[REGISTER_BYTE (PC_REGNUM)], 8);
+}
+
+static void
 supply_fpregs (fregs)
      char *fregs;
 {
@@ -102,6 +110,42 @@
   supply_register (FPCR_REGNUM, fregs + (32 * 8));
 }
 
+static void
+unsupply_fpregs (fregs)
+     struct fpreg *fregs;
+{
+  memcpy (&fregs->fpr_regs[0], &registers[REGISTER_BYTE (FP0_REGNUM)], 31 * 8);
+  memcpy (&fregs->fpr_cr, &registers[REGISTER_BYTE (FPCR_REGNUM)], 8);
+}
+
+void
+nbsd_reg_to_internal (regs)
+     char *regs;
+{
+  supply_regs (regs);
+}
+
+void
+nbsd_fpreg_to_internal (fregs)
+     char *fregs;
+{
+  supply_fpregs (fregs);
+}
+
+void
+nbsd_internal_to_reg (regs)
+     char *regs;
+{
+       unsupply_regs (regs);
+}
+
+void
+nbsd_internal_to_fpreg (fregs)
+     char *fregs;
+{
+       unsupply_fpregs (fregs);
+}
+
 void
 fetch_inferior_registers (regno)
      int regno;
@@ -111,15 +155,15 @@
 
   if (regno == -1 || GETREGS_SUPPLIES (regno))
     {
-      ptrace (PT_GETREGS, inferior_pid,
-              (PTRACE_ARG3_TYPE) &inferior_registers, 0);
+      ptrace (PT_GETREGS, GET_PROCESS (inferior_pid),
+              (PTRACE_ARG3_TYPE) &inferior_registers, GET_LWP (inferior_pid));
       supply_regs ((char *) &inferior_registers);
     }
 
   if (regno == -1 || regno >= FP0_REGNUM)
     {
-      ptrace (PT_GETFPREGS, inferior_pid,
-              (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0);
+      ptrace (PT_GETFPREGS, GET_PROCESS (inferior_pid),
+              (PTRACE_ARG3_TYPE) &inferior_fp_registers, GET_LWP (inferior_pid));
       supply_fpregs ((char *) &inferior_fp_registers);
     }
 
@@ -144,20 +188,20 @@
       inferior_registers.r_regs[R_ZERO] =
         *(long *) &registers[REGISTER_BYTE (PC_REGNUM)];    
 
-      ptrace (PT_SETREGS, inferior_pid,
-             (PTRACE_ARG3_TYPE) &inferior_registers, 0);
+      ptrace (PT_SETREGS, GET_PROCESS (inferior_pid),
+             (PTRACE_ARG3_TYPE) &inferior_registers, GET_LWP (inferior_pid));
     }
 
   if (regno == -1 || regno >= FP0_REGNUM)
     {
       memcpy (&inferior_fp_registers.fpr_regs[0],
              &registers[REGISTER_BYTE (FP0_REGNUM)],
-             sizeof(inferior_fp_registers.fpr_regs));
+             sizeof (inferior_fp_registers.fpr_regs));
       memcpy (&inferior_fp_registers.fpr_cr,
              &registers[REGISTER_BYTE (FPCR_REGNUM)],
-             sizeof(inferior_fp_registers.fpr_cr));
-      ptrace (PT_SETFPREGS, inferior_pid,
-             (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0);
+             sizeof (inferior_fp_registers.fpr_cr));
+      ptrace (PT_SETFPREGS, GET_PROCESS (inferior_pid),
+             (PTRACE_ARG3_TYPE) &inferior_fp_registers, GET_LWP (inferior_pid));
     }
 }
 
diff -r bba1fd4a6a75 -r cbf8f19ffaa0 gnu/dist/toolchain/gdb/armnbsd-nat.c
--- a/gnu/dist/toolchain/gdb/armnbsd-nat.c      Sat Jan 18 21:38:03 2003 +0000
+++ b/gnu/dist/toolchain/gdb/armnbsd-nat.c      Sat Jan 18 21:42:07 2003 +0000
@@ -59,44 +59,97 @@
   arm_apcs_32 = (read_register (PS_REGNUM) & PSR_MODE_32) != 0;
 }
 
+static void
+unsupply_struct_reg (struct reg *reg)
+{
+  int i;
+
+  for (i = 0; i < 13; i++)
+    read_register_gen (A1_REGNUM + i, (char *)&reg->r[i]);
+  read_register_gen (SP_REGNUM, (char *)&reg->r_sp);
+  read_register_gen (LR_REGNUM, (char *)&reg->r_lr);
+  read_register_gen (PS_REGNUM, (char *)&reg->r_cpsr);
+  if ((reg->r_cpsr & PSR_MODE_32))
+    read_register_gen (PC_REGNUM, (char *)&reg->r_pc);
+  else
+    arm_read_26bit_r15 ((char *)&reg->r_pc);
+}
+
+static void
+supply_struct_fpreg (struct fpreg *freg)
+{
+  int i;
+
+  for (i = 0; i < 8; i++)
+    supply_register (F0_REGNUM + i, (char *)&freg->fpr[i]);
+  supply_register (FPS_REGNUM, (char *)&freg->fpr_fpsr);
+}
+
+static void
+unsupply_struct_fpreg (struct fpreg *freg)
+{
+  memcpy (&freg->fpr[0], &registers[REGISTER_BYTE (F0_REGNUM)], sizeof (freg->fpr));
+  memcpy (&freg->fpr_fpsr, &registers[REGISTER_BYTE (FPS_REGNUM)], sizeof (freg->fpr_fpsr));
+}
+
+void
+nbsd_reg_to_internal (regs)
+     char *regs;
+{
+  supply_struct_reg ((struct reg *)regs);
+}
+
+void
+nbsd_fpreg_to_internal (fregs)
+     char *fregs;
+{
+  supply_struct_fpreg ((struct fpreg *)fregs);
+}
+
+void
+nbsd_internal_to_reg (regs)
+     char *regs;
+{
+  unsupply_struct_reg ((struct reg *)regs);
+}
+
+void
+nbsd_internal_to_fpreg (fregs)
+     char *fregs;
+{
+  unsupply_struct_fpreg ((struct fpreg *)fregs);
+}
 
 void
 fetch_inferior_registers (int regno)
 {
   struct reg inferior_registers;
   struct fpreg inferior_fpregisters;
-  int i;
 
   /* Integer registers */
-  ptrace (PT_GETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &inferior_registers, 0);
+  ptrace (PT_GETREGS, GET_PROCESS(inferior_pid),
+         (PTRACE_ARG3_TYPE) &inferior_registers, GET_LWP(inferior_pid));
   supply_struct_reg (&inferior_registers);
 
   /* FPA registers */
-  ptrace (PT_GETFPREGS, inferior_pid, (PTRACE_ARG3_TYPE) &inferior_fpregisters,
-         0);
-  for (i = 0; i < 8; i++)
-    supply_register (F0_REGNUM + i, (char *)&inferior_fpregisters.fpr[i]);
-  supply_register (FPS_REGNUM, (char *)&inferior_fpregisters.fpr_fpsr);
+  ptrace (PT_GETFPREGS, GET_PROCESS(inferior_pid),
+         (PTRACE_ARG3_TYPE) &inferior_fpregisters, GET_LWP(inferior_pid));
+  supply_struct_fpreg(&inferior_fpregisters);
 }
 
 void
 store_inferior_registers (int regno)
 {
   struct reg inferior_registers;
-  int i;
+  struct fpreg inferior_fpregisters;
 
-  for (i = 0; i < 13; i++)
-    read_register_gen (A1_REGNUM + i, (char *)&inferior_registers.r[i]);
-  read_register_gen (SP_REGNUM, (char *)&inferior_registers.r_sp);
-  read_register_gen (LR_REGNUM, (char *)&inferior_registers.r_lr);
-  if ((inferior_registers.r_cpsr & PSR_MODE_32))
-    read_register_gen (PC_REGNUM, (char *)&inferior_registers.r_pc);
-  else
-    arm_read_26bit_r15 ((char *)&inferior_registers.r_pc);
-  read_register_gen (PS_REGNUM, (char *)&inferior_registers.r_cpsr);
-  ptrace (PT_SETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &inferior_registers, 0);
+  unsupply_struct_reg (&inferior_registers);
+  ptrace (PT_SETREGS, GET_PROCESS(inferior_pid),
+         (PTRACE_ARG3_TYPE) &inferior_registers, GET_LWP(inferior_pid));
 
-  /* XXX Set FP regs. */
+  unsupply_struct_fpreg (&inferior_fpregisters);
+  ptrace (PT_SETFPREGS, GET_PROCESS(inferior_pid),
+         (PTRACE_ARG3_TYPE) &inferior_registers, GET_LWP(inferior_pid));
 }
 
 struct md_core
diff -r bba1fd4a6a75 -r cbf8f19ffaa0 gnu/dist/toolchain/gdb/config/nm-nbsd.h
--- a/gnu/dist/toolchain/gdb/config/nm-nbsd.h   Sat Jan 18 21:38:03 2003 +0000
+++ b/gnu/dist/toolchain/gdb/config/nm-nbsd.h   Sat Jan 18 21:42:07 2003 +0000
@@ -38,6 +38,16 @@
 
 #define PTRACE_ARG3_TYPE char*
 
+/* Macros for manipulating pid/lwpid/threadid aggregates in archnbsd-nat.c and
+   nbsd-thread.c */
+#define THREAD_FLAG            0x80000000
+#define IS_THREAD(ARG)         (((ARG) & THREAD_FLAG) != 0)
+#define GET_THREAD(PID)                (((PID) >> 16) & 0x7fff)
+#define GET_LWP(PID)           (((PID) >> 16) & 0x7fff)
+#define GET_PROCESS(PID)       ((PID) & 0xffff)
+#define BUILD_THREAD(TID, PID) ((TID) << 16 | (PID) | THREAD_FLAG)
+#define BUILD_LWP(TID, PID)    ((TID) << 16 | (PID))
+
 #if !defined(NO_SOLIB)
 #include "solib.h"             /* Support for shared libraries. */
 
diff -r bba1fd4a6a75 -r cbf8f19ffaa0 gnu/dist/toolchain/gdb/configure.in
--- a/gnu/dist/toolchain/gdb/configure.in       Sat Jan 18 21:38:03 2003 +0000
+++ b/gnu/dist/toolchain/gdb/configure.in       Sat Jan 18 21:42:07 2003 +0000
@@ -409,6 +409,17 @@
          AC_MSG_RESULT(no)
       fi
       ;;
+   netbsd*)
+      AC_MSG_CHECKING(for NetBSD thread debugging library)
+      if test -f /usr/include/pthread_dbg.h ; then
+         AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_THREAD_DB_LIB)
+         CONFIG_OBS="${CONFIG_OBS} nbsd-thread.o"
+         CONFIG_SRCS="${CONFIG_SRCS} nbsd-thread.c"
+        CONFIG_LDFLAGS="${CONFIG_LDFLAGS} -lpthread_dbg"
+      else
+         AC_MSG_RESULT(no)
+      fi
    esac
    AC_SUBST(CONFIG_LDFLAGS)
 fi
diff -r bba1fd4a6a75 -r cbf8f19ffaa0 gnu/dist/toolchain/gdb/corelow.c
--- a/gnu/dist/toolchain/gdb/corelow.c  Sat Jan 18 21:38:03 2003 +0000
+++ b/gnu/dist/toolchain/gdb/corelow.c  Sat Jan 18 21:42:07 2003 +0000
@@ -333,9 +333,10 @@
   /* Build up thread list from BFD sections. */
 
   init_thread_list ();
+#if 0 /* XXX nathanw */
   bfd_map_over_sections (core_bfd, add_to_thread_list,
                         bfd_get_section_by_name (core_bfd, ".reg"));
-
+#endif
   if (ontop)
     {
       /* Fetch all registers from core file.  */
diff -r bba1fd4a6a75 -r cbf8f19ffaa0 gnu/dist/toolchain/gdb/i386nbsd-nat.c
--- a/gnu/dist/toolchain/gdb/i386nbsd-nat.c     Sat Jan 18 21:38:03 2003 +0000
+++ b/gnu/dist/toolchain/gdb/i386nbsd-nat.c     Sat Jan 18 21:42:07 2003 +0000
@@ -59,8 +59,8 @@
   {
     unsigned short control;
     unsigned short status;
+    unsigned char r0;
     unsigned char tag;        /* abridged */
-    unsigned char r0;
     unsigned short opcode;
     unsigned long eip;
     unsigned short code_seg;
@@ -106,6 +106,28 @@
 }
 



Home | Main Index | Thread Index | Old Index