Source-Changes-HG archive

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

[src/trunk]: src/external/gpl3/gdb/dist Apply the diffs that are relevant fro...



details:   https://anonhg.NetBSD.org/src/rev/fd426c221dda
branches:  trunk
changeset: 769887:fd426c221dda
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Sep 25 16:30:24 2011 +0000

description:
Apply the diffs that are relevant from our old gdb6 source tree.

diffstat:

 external/gpl3/gdb/dist/gdb/alphabsd-nat.c         |    1 +
 external/gpl3/gdb/dist/gdb/alphanbsd-tdep.c       |  137 +++--
 external/gpl3/gdb/dist/gdb/amd64nbsd-nat.c        |   59 ++
 external/gpl3/gdb/dist/gdb/amd64nbsd-tdep.c       |  170 +++++++
 external/gpl3/gdb/dist/gdb/armnbsd-nat.c          |  124 +++++-
 external/gpl3/gdb/dist/gdb/bsd-kvm.c              |   21 +
 external/gpl3/gdb/dist/gdb/config/alpha/nbsd.mh   |    2 +-
 external/gpl3/gdb/dist/gdb/config/arm/nbsdelf.mh  |    2 +-
 external/gpl3/gdb/dist/gdb/config/i386/nbsd64.mh  |    4 +-
 external/gpl3/gdb/dist/gdb/config/m68k/nbsdelf.mh |    2 +-
 external/gpl3/gdb/dist/gdb/config/mips/nbsd.mh    |    2 +-
 external/gpl3/gdb/dist/gdb/config/pa/nbsd.mt      |    2 +
 external/gpl3/gdb/dist/gdb/config/powerpc/nbsd.mh |    2 +-
 external/gpl3/gdb/dist/gdb/config/sh/nbsd.mh      |    2 +-
 external/gpl3/gdb/dist/gdb/config/sparc/nbsd64.mh |    2 +-
 external/gpl3/gdb/dist/gdb/config/vax/nbsdelf.mh  |    2 +-
 external/gpl3/gdb/dist/gdb/configure.host         |    2 +
 external/gpl3/gdb/dist/gdb/hppa-tdep.c            |    2 +-
 external/gpl3/gdb/dist/gdb/hppa-tdep.h            |    2 +
 external/gpl3/gdb/dist/gdb/i386bsd-nat.c          |   26 +-
 external/gpl3/gdb/dist/gdb/i386nbsd-nat.c         |   55 +-
 external/gpl3/gdb/dist/gdb/i386nbsd-tdep.c        |  156 ++++++
 external/gpl3/gdb/dist/gdb/inf-ptrace.c           |    8 +-
 external/gpl3/gdb/dist/gdb/m68kbsd-nat.c          |    1 +
 external/gpl3/gdb/dist/gdb/ppcnbsd-nat.c          |   18 +-
 external/gpl3/gdb/dist/gdb/regcache.c             |    6 +-
 external/gpl3/gdb/dist/gdb/shnbsd-nat.c           |   11 +-
 external/gpl3/gdb/dist/gdb/shnbsd-tdep.c          |  508 +++++++++++++++++++--
 external/gpl3/gdb/dist/gdb/shnbsd-tdep.h          |   28 +
 external/gpl3/gdb/dist/gdb/sparc64nbsd-nat.c      |    9 +-
 external/gpl3/gdb/dist/gdb/sparcnbsd-nat.c        |    8 +-
 external/gpl3/gdb/dist/gdb/tui/tui-stack.c        |    2 +-
 external/gpl3/gdb/dist/gdb/user-regs.c            |   18 +-
 external/gpl3/gdb/dist/gdb/vaxbsd-nat.c           |    3 +
 external/gpl3/gdb/dist/libiberty/strerror.c       |    2 +-
 external/gpl3/gdb/dist/opcodes/cgen.sh            |   17 +-
 external/gpl3/gdb/dist/opcodes/configure          |    8 +
 external/gpl3/gdb/dist/opcodes/configure.in       |    8 +
 external/gpl3/gdb/dist/sim/common/callback.c      |    6 +-
 external/gpl3/gdb/dist/sim/common/cgen.sh         |   35 +-
 external/gpl3/gdb/dist/sim/configure              |    2 +-
 external/gpl3/gdb/dist/sim/mips/Makefile.in       |    2 +-
 external/gpl3/gdb/dist/sim/mn10300/Makefile.in    |    2 +-
 external/gpl3/gdb/dist/sim/ppc/emul_netbsd.c      |  368 ++++++++++++++-
 external/gpl3/gdb/dist/sim/v850/Makefile.in       |    2 +-
 45 files changed, 1592 insertions(+), 257 deletions(-)

diffs (truncated from 2925 to 300 lines):

diff -r 75a20af343a3 -r fd426c221dda external/gpl3/gdb/dist/gdb/alphabsd-nat.c
--- a/external/gpl3/gdb/dist/gdb/alphabsd-nat.c Sun Sep 25 13:42:30 2011 +0000
+++ b/external/gpl3/gdb/dist/gdb/alphabsd-nat.c Sun Sep 25 16:30:24 2011 +0000
@@ -200,6 +200,7 @@
   t = inf_ptrace_target ();
   t->to_fetch_registers = alphabsd_fetch_inferior_registers;
   t->to_store_registers = alphabsd_store_inferior_registers;
+  t->to_pid_to_exec_file = nbsd_pid_to_exec_file;
   add_target (t);
 
   /* Support debugging kernel virtual memory images.  */
diff -r 75a20af343a3 -r fd426c221dda external/gpl3/gdb/dist/gdb/alphanbsd-tdep.c
--- a/external/gpl3/gdb/dist/gdb/alphanbsd-tdep.c       Sun Sep 25 13:42:30 2011 +0000
+++ b/external/gpl3/gdb/dist/gdb/alphanbsd-tdep.c       Sun Sep 25 16:30:24 2011 +0000
@@ -184,79 +184,90 @@
 
 /* Signal trampolines.  */
 
+static void
+alphanbsd_sigtramp_cache_init (const struct tramp_frame *,
+                              struct frame_info *,
+                              struct trad_frame_cache *,
+                              CORE_ADDR);
 /* Under NetBSD/alpha, signal handler invocations can be identified by the
    designated code sequence that is used to return from a signal handler.
    In particular, the return address of a signal handler points to the
-   following code sequence:
-
-       ldq     a0, 0(sp)
-       lda     sp, 16(sp)
-       lda     v0, 295(zero)   # __sigreturn14
-       call_pal callsys
+   following code sequences: */
+static const struct tramp_frame alphanbsd_sigtramp_sc1 =
+  SIGTRAMP_FRAME,
+  4,
+  {
+    { 0xa61e0000, 0xffffffff },                /* ldq a0, 0(sp) */
+    { 0x23de0010, 0xffffffff },                /* lda sp, 16(sp) */
+    { 0x201f0127, 0xffffffff },                /* lda v0, 295 */
+    { 0x00000083, 0xffffffff },                /* call_pal callsys */
+    { TRAMP_SENTINEL_INSN, -1 }
+  },
+  alphanbsd_sigtramp_cache_init
+};
 
-   Each instruction has a unique encoding, so we simply attempt to match
-   the instruction the PC is pointing to with any of the above instructions.
-   If there is a hit, we know the offset to the start of the designated
-   sequence and can then check whether we really are executing in the
-   signal trampoline.  If not, -1 is returned, otherwise the offset from the
-   start of the return sequence is returned.  */
-static const unsigned char sigtramp_retcode[] =
+/* The siginfo signal trampoline for NetBSD/alpha introduced in 2.0 */
+static const struct tramp_frame alphanbsd_sigtramp_si2 =
+{
+  SIGTRAMP_FRAME,
+  4,
+  {
+    { 0x221e0080, -1 },                /* lda  a0,128(sp) */
+    { 0x201f0134, -1 },                /* lda  v0,308 */
+    { 0x00000083, -1 },                /* callsys */
+    { 0x47e00410, -1 },                /* mov  v0,a0 */
+    { 0x201f0001, -1 },                /* lda  v0,1 */
+    { 0x00000083, -1 },                /* callsys */
+    { TRAMP_SENTINEL_INSN, -1 }
+  },
+  alphanbsd_sigtramp_cache_init
+};
+/* The siginfo signal trampoline for NetBSD/alpha introduced in 4.0 */
+static const struct tramp_frame alphanbsd_sigtramp_si4 =
 {
-  0x00, 0x00, 0x1e, 0xa6,      /* ldq a0, 0(sp) */
-  0x10, 0x00, 0xde, 0x23,      /* lda sp, 16(sp) */
-  0x27, 0x01, 0x1f, 0x20,      /* lda v0, 295(zero) */
-  0x83, 0x00, 0x00, 0x00,      /* call_pal callsys */
+  SIGTRAMP_FRAME,
+  4,
+  {
+    { 0x27ba0000, 0xffff0000 },
+    { 0x23bd0000, 0xffff0000 },        /* ldgp gp,0(ra) */
+    { 0x221e0080, -1 },                /* lda  a0,128(sp) */
+    { 0x201f0134, -1 },                /* lda  v0,308 */
+    { 0x00000083, -1 },                /* callsys */
+    { 0x221fffff, -1 },                /* lda  a0,-1 */
+    { 0x201f0001, -1 },                /* lda  v0,1 */
+    { 0x00000083, -1 },                /* callsys */
+    { TRAMP_SENTINEL_INSN, -1 }
+  },
+  alphanbsd_sigtramp_cache_init
 };
-#define RETCODE_NWORDS         4
-#define RETCODE_SIZE           (RETCODE_NWORDS * 4)
 
-static LONGEST
-alphanbsd_sigtramp_offset (struct gdbarch *gdbarch, CORE_ADDR pc)
+static void
+alphanbsd_sigtramp_cache_init (const struct tramp_frame *self,
+                              struct frame_info *next_frame,
+                              struct trad_frame_cache *this_cache,
+                              CORE_ADDR func)
 {
-  unsigned char ret[RETCODE_SIZE], w[4];
-  LONGEST off;
+  struct gdbarch *gdbarch = get_frame_arch (next_frame);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  CORE_ADDR addr, sp;
   int i;
 
-  if (target_read_memory (pc, (char *) w, 4) != 0)
-    return -1;
-
-  for (i = 0; i < RETCODE_NWORDS; i++)
-    {
-      if (memcmp (w, sigtramp_retcode + (i * 4), 4) == 0)
-       break;
-    }
-  if (i == RETCODE_NWORDS)
-    return (-1);
-
-  off = i * 4;
-  pc -= off;
-
-  if (target_read_memory (pc, (char *) ret, sizeof (ret)) != 0)
-    return -1;
-
-  if (memcmp (ret, sigtramp_retcode, RETCODE_SIZE) == 0)
-    return off;
+  sp = frame_unwind_register_unsigned (next_frame, SP_REGNUM);
 
-  return -1;
-}
+  if (self == &alphanbsd_sigtramp_sc1) {
+    addr = sp;
+  } else {
+    addr = sp + 128 + 56;
+  }
+ 
+  for (i = 0; i < 32; i++, addr += ALPHA_REGISTER_SIZE)
+    {
+      trad_frame_set_reg_addr (this_cache, i, addr);
+    }
+  trad_frame_set_reg_addr (this_cache, ALPHA_PC_REGNUM, addr);
 
-static int
-alphanbsd_pc_in_sigtramp (struct gdbarch *gdbarch,
-                         CORE_ADDR pc, char *func_name)
-{
-  return (nbsd_pc_in_sigtramp (pc, func_name)
-         || alphanbsd_sigtramp_offset (gdbarch, pc) >= 0);
-}
-
-static CORE_ADDR
-alphanbsd_sigcontext_addr (struct frame_info *frame)
-{
-  /* FIXME: This is not correct for all versions of NetBSD/alpha.
-     We will probably need to disassemble the trampoline to figure
-     out which trampoline frame type we have.  */
-  if (!get_next_frame (frame))
-    return 0;
-  return get_frame_base (get_next_frame (frame));
+  /* Construct the frame ID using the function start.  */
+  trad_frame_set_id (this_cache, frame_id_build (sp, func));
 }
 
 
@@ -289,6 +300,10 @@
 
   set_gdbarch_regset_from_core_section
     (gdbarch, alphanbsd_regset_from_core_section);
+
+  tramp_frame_prepend_unwinder (gdbarch, &alphanbsd_sigtramp_sc1);
+  tramp_frame_prepend_unwinder (gdbarch, &alphanbsd_sigtramp_si2);
+  tramp_frame_prepend_unwinder (gdbarch, &alphanbsd_sigtramp_si4);
 }
 
 
diff -r 75a20af343a3 -r fd426c221dda external/gpl3/gdb/dist/gdb/amd64nbsd-nat.c
--- a/external/gpl3/gdb/dist/gdb/amd64nbsd-nat.c        Sun Sep 25 13:42:30 2011 +0000
+++ b/external/gpl3/gdb/dist/gdb/amd64nbsd-nat.c        Sun Sep 25 16:30:24 2011 +0000
@@ -26,6 +26,12 @@
 #include "nbsd-nat.h"
 #include "amd64-tdep.h"
 #include "amd64-nat.h"
+#include "regcache.h"
+#include "gdbcore.h"
+#include "bsd-kvm.h"
+
+#include <machine/frame.h>
+#include <machine/pcb.h>
 
 /* Mapping between the general-purpose registers in NetBSD/amd64
    `struct reg' format and GDB's register cache layout for
@@ -57,6 +63,56 @@
 };
 
 
+static int
+amd64nbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
+{
+  struct switchframe sf;
+  int regnum;
+
+  /* The following is true for NetBSD/amd64:
+
+     The pcb contains the stack pointer at the point of the context
+     switch in cpu_switchto().  At that point we have a stack frame as
+     described by `struct switchframe', which for NetBSD/amd64 has the
+     following layout:
+
+     interrupt level
+     %r15
+     %r14
+     %r13
+     %r12
+     %rbx
+     return address
+
+     Together with %rsp in the pcb, this accounts for all callee-saved
+     registers specified by the psABI.  From this information we
+     reconstruct the register state as it would look when we just
+     returned from cpu_switchto().
+
+     For kernel core dumps, dumpsys() builds a fake switchframe for us. */
+
+  /* The stack pointer shouldn't be zero.  */
+  if (pcb->pcb_rsp == 0)
+    return 0;
+
+  /* Read the stack frame, and check its validity.  */
+  read_memory (pcb->pcb_rsp, (gdb_byte *) &sf, sizeof sf);
+  pcb->pcb_rsp += sizeof (struct switchframe);
+  regcache_raw_supply (regcache, 12, &sf.sf_r12);
+  regcache_raw_supply (regcache, 13, &sf.sf_r13);
+  regcache_raw_supply (regcache, 14, &sf.sf_r14);
+  regcache_raw_supply (regcache, 15, &sf.sf_r15);
+  regcache_raw_supply (regcache, AMD64_RBX_REGNUM, &sf.sf_rbx);
+  regcache_raw_supply (regcache, AMD64_RIP_REGNUM, &sf.sf_rip);
+
+  regcache_raw_supply (regcache, AMD64_RSP_REGNUM, &pcb->pcb_rsp);
+  regcache_raw_supply (regcache, AMD64_RBP_REGNUM, &pcb->pcb_rbp);
+  regcache_raw_supply (regcache, AMD64_FS_REGNUM, &pcb->pcb_fs);
+  regcache_raw_supply (regcache, AMD64_GS_REGNUM, &pcb->pcb_gs);
+
+  return 1;
+}
+
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 void _initialize_amd64nbsd_nat (void);
 
@@ -73,4 +129,7 @@
   t = amd64bsd_target ();
   t->to_pid_to_exec_file = nbsd_pid_to_exec_file;
   add_target (t);
+
+  /* Support debugging kernel virtual memory images.  */
+  bsd_kvm_add_target (amd64nbsd_supply_pcb);
 }
diff -r 75a20af343a3 -r fd426c221dda external/gpl3/gdb/dist/gdb/amd64nbsd-tdep.c
--- a/external/gpl3/gdb/dist/gdb/amd64nbsd-tdep.c       Sun Sep 25 13:42:30 2011 +0000
+++ b/external/gpl3/gdb/dist/gdb/amd64nbsd-tdep.c       Sun Sep 25 16:30:24 2011 +0000
@@ -26,10 +26,13 @@
 #include "symtab.h"
 
 #include "gdb_assert.h"
+#include "gdb_string.h"
 
 #include "amd64-tdep.h"
 #include "nbsd-tdep.h"
 #include "solib-svr4.h"
+#include "trad-frame.h"
+#include "frame-unwind.h"
 
 /* Support for signal handlers.  */
 
@@ -96,6 +99,170 @@
   15 * 8                       /* %gs */
 };
 
+/* Kernel debugging support */
+static const int amd64nbsd_tf_reg_offset[] =
+{
+  18 * 8,                      /* %rax */
+  17 * 8,                      /* %rbx */
+  10 * 8,                      /* %rcx */
+  2 * 8,                       /* %rdx */
+  1 * 8,                       /* %rsi */
+  0 * 8,                       /* %rdi */
+  16 * 8,                      /* %rbp */
+  28 * 8,                      /* %rsp */
+  4 * 8,                       /* %r8 .. */
+  5 * 8,                       
+  3 * 8,                       
+  11 * 8,                      
+  12 * 8,                      
+  13 * 8,                      
+  14 * 8,                      
+  15 * 8,                      /* ... %r15 */
+  25 * 8,                      /* %rip */
+  27 * 8,                      /* %eflags */



Home | Main Index | Thread Index | Old Index