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 Implement software single stepping, a...



details:   https://anonhg.NetBSD.org/src/rev/5f5cc6349788
branches:  trunk
changeset: 519591:5f5cc6349788
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Dec 21 02:57:38 2001 +0000

description:
Implement software single stepping, and enable it for NetBSD/alpha.

diffstat:

 gnu/dist/toolchain/gdb/alpha-tdep.c            |  64 ++++++++++++++++++++++++++
 gnu/dist/toolchain/gdb/config/alpha/tm-alpha.h |  11 ++++
 gnu/dist/toolchain/gdb/config/alpha/tm-nbsd.h  |   5 +-
 3 files changed, 78 insertions(+), 2 deletions(-)

diffs (112 lines):

diff -r 466316b52ee7 -r 5f5cc6349788 gnu/dist/toolchain/gdb/alpha-tdep.c
--- a/gnu/dist/toolchain/gdb/alpha-tdep.c       Fri Dec 21 02:52:18 2001 +0000
+++ b/gnu/dist/toolchain/gdb/alpha-tdep.c       Fri Dec 21 02:57:38 2001 +0000
@@ -1451,3 +1451,67 @@
   c->function.sfunc = reinit_frame_cache_sfunc;
   add_show_from_set (c, &showlist);
 }
+
+#if SOFTWARE_SINGLE_STEP_P
+/* alpha_software_single_step() is called just before we want to resume
+   the inferior, if we want to single-step it but there is no hardware
+   or kernel single-step support (NetBSD on Alpha, for example).  We find
+   the target of the coming instruction and breakpoint it.
+
+   single_step is also called just after the inferior stops.  If we had
+   set up a simulated single-step, we undo our damage.  */
+
+CORE_ADDR
+alpha_next_pc (pc)
+     CORE_ADDR pc;
+{
+  unsigned int insn;
+  unsigned int op;
+  int offset;
+
+  insn = read_memory_unsigned_integer (pc, sizeof (insn));
+
+  /* Opcode is top 6 bits. */
+  op = (insn >> 26) & 0x3f;
+
+  if ((op & 0x30) == 0x30)
+    {
+      /* Branch format: target PC is:
+        (new PC) + (4 * sext(displacement))  */
+      offset = ((short)(insn & 0xffff)) * 4;
+      return (pc + 4 + offset);
+    }
+
+  if (op == 0x1a)
+    {
+      /* Jump format: target PC is:
+        RB & ~3  */
+      return (read_register ((insn >> 21) & 0x1f));
+    }
+
+  /* Not a branch; target PC is:
+     pc + 4  */
+  return (pc + 4);
+}
+
+void
+alpha_software_single_step (sig, insert_breakpoints_p)
+     int sig; /* not used */
+     int insert_breakpoints_p;
+{
+  static CORE_ADDR next_pc;
+  typedef char binsn_quantum[BREAKPOINT_MAX];
+  static binsn_quantum break_mem;
+  CORE_ADDR pc;
+
+  if (insert_breakpoints_p)
+    {
+      pc = read_register (PC_REGNUM);
+      next_pc = alpha_next_pc (pc);
+
+      target_insert_breakpoint (next_pc, break_mem);
+    }
+  else
+    target_remove_breakpoint (next_pc, break_mem);
+}
+#endif /* SOFTWARE_SINGLE_STEP_P */
diff -r 466316b52ee7 -r 5f5cc6349788 gnu/dist/toolchain/gdb/config/alpha/tm-alpha.h
--- a/gnu/dist/toolchain/gdb/config/alpha/tm-alpha.h    Fri Dec 21 02:52:18 2001 +0000
+++ b/gnu/dist/toolchain/gdb/config/alpha/tm-alpha.h    Fri Dec 21 02:57:38 2001 +0000
@@ -479,4 +479,15 @@
   (alpha_osf_skip_sigtramp_frame (frame, pc))
 extern CORE_ADDR alpha_osf_skip_sigtramp_frame PARAMS ((struct frame_info *, CORE_ADDR));
 
+/* Provide a default for sofware single-stepping (off by default).  */
+#ifndef SOFTWARE_SINGLE_STEP_P 
+#define SOFTWARE_SINGLE_STEP_P 0
+#endif
+#if SOFTWARE_SINGLE_STEP_P
+#define SOFTWARE_SINGLE_STEP(sig,bpt) alpha_software_single_step((sig), (bpt))
+void alpha_software_single_step PARAMS((int, int));
+#endif
+
+CORE_ADDR alpha_next_pc (CORE_ADDR pc);
+
 #endif /* TM_ALPHA_H */
diff -r 466316b52ee7 -r 5f5cc6349788 gnu/dist/toolchain/gdb/config/alpha/tm-nbsd.h
--- a/gnu/dist/toolchain/gdb/config/alpha/tm-nbsd.h     Fri Dec 21 02:52:18 2001 +0000
+++ b/gnu/dist/toolchain/gdb/config/alpha/tm-nbsd.h     Fri Dec 21 02:57:38 2001 +0000
@@ -20,6 +20,9 @@
 #ifndef TM_NBSD_H
 #define TM_NBSD_H
 
+/* NetBSD doesn't have single stepping support in ptrace().  */
+#define SOFTWARE_SINGLE_STEP_P 1
+
 #include "alpha/tm-alpha.h"
 #ifndef S0_REGNUM
 #define S0_REGNUM (T7_REGNUM+1)
@@ -29,8 +32,6 @@
 #undef START_INFERIOR_TRAPS_EXPECTED
 #define START_INFERIOR_TRAPS_EXPECTED 2
 
-#undef NO_SINGLE_STEP
-#define NO_SINGLE_STEP
 #undef CANNOT_STEP_BREAKPOINT 
 
 #define        SOLIB_BKPT_NAME         "__start"



Home | Main Index | Thread Index | Old Index