This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit] OpenBSD/m68k signal trampoline recognition


Had to increase the number of instruction slots in `struct
tramp_frame'.  Bumped it to the next power of 2.

Committed,

Mark

Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* tramp-frame.h (struct tramp_frame): Allow for 16 instructions
	instead of 8.
	* m68kbsd-tdep.c: Include "frame.h", "trad-frame.h" and
	"tramp-frame.h".
	(m68kobsd_sigtramp_cache_init): New function.
	(m68kbsd_aout_init_abi): Prepend m68kobsd_sigtramp unwinder.

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.741
diff -u -p -r1.741 Makefile.in
--- Makefile.in 15 Jul 2005 20:10:18 -0000 1.741
+++ Makefile.in 8 Aug 2005 20:57:33 -0000
@@ -2218,9 +2218,10 @@ m68hc11-tdep.o: m68hc11-tdep.c $(defs_h)
 m68kbsd-nat.o: m68kbsd-nat.c $(defs_h) $(gdbcore_h) $(inferior_h) \
 	$(regcache_h) $(gdb_assert_h) $(m68k_tdep_h) $(inf_ptrace_h) \
 	$(bsd_kvm_h)
-m68kbsd-tdep.o: m68kbsd-tdep.c $(defs_h) $(arch_utils_h) $(osabi_h) \
-	$(regcache_h) $(regset_h) $(gdb_assert_h) $(gdb_string_h) \
-	$(m68k_tdep_h) $(solib_svr4_h)
+m68kbsd-tdep.o: m68kbsd-tdep.c $(defs_h) $(arch_utils_h) $(frame_h) \
+	$(osabi_h) $(regcache_h) $(regset_h) $(trad_frame_h) \
+	$(tramp_frame_h)$(gdb_assert_h) $(gdb_string_h) $(m68k_tdep_h) \
+	$(solib_svr4_h)
 m68klinux-nat.o: m68klinux-nat.c $(defs_h) $(frame_h) $(inferior_h) \
 	$(language_h) $(gdbcore_h) $(gdb_string_h) $(regcache_h) \
 	$(m68k_tdep_h) $(gdb_stat_h) $(floatformat_h) $(target_h) \
Index: m68kbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/m68kbsd-tdep.c,v
retrieving revision 1.5
diff -u -p -r1.5 m68kbsd-tdep.c
--- m68kbsd-tdep.c 14 May 2005 13:14:00 -0000 1.5
+++ m68kbsd-tdep.c 8 Aug 2005 20:57:33 -0000
@@ -21,9 +21,12 @@
 
 #include "defs.h"
 #include "arch-utils.h"
+#include "frame.h"
 #include "osabi.h"
 #include "regcache.h"
 #include "regset.h"
+#include "trad-frame.h"
+#include "tramp-frame.h"
 
 #include "gdb_assert.h"
 #include "gdb_string.h"
@@ -126,6 +129,61 @@ m68kbsd_regset_from_core_section (struct
 
   return NULL;
 }
+
+
+/* Signal trampolines.  */
+
+static void
+m68kobsd_sigtramp_cache_init (const struct tramp_frame *self,
+			      struct frame_info *next_frame,
+			      struct trad_frame_cache *this_cache,
+			      CORE_ADDR func)
+{
+  CORE_ADDR addr, base, pc;
+  int regnum;
+
+  base = frame_unwind_register_unsigned (next_frame, M68K_SP_REGNUM);
+
+  /* The 'addql #4,%sp' instruction at offset 8 adjusts the stack
+     pointer.  Adjust the frame base accordingly.  */
+  pc = frame_unwind_register_unsigned (next_frame, M68K_PC_REGNUM);
+  if ((pc - func) > 8)
+    base -= 4;
+
+  /* Get frame pointer, stack pointer, program counter and processor
+     state from `struct sigcontext'.  */
+  addr = get_frame_memory_unsigned (next_frame, base + 8, 4);
+  trad_frame_set_reg_addr (this_cache, M68K_FP_REGNUM, addr + 8);
+  trad_frame_set_reg_addr (this_cache, M68K_SP_REGNUM, addr + 12);
+  trad_frame_set_reg_addr (this_cache, M68K_PC_REGNUM, addr + 20);
+  trad_frame_set_reg_addr (this_cache, M68K_PS_REGNUM, addr + 24);
+
+  /* The sc_ap member of `struct sigcontext' points to additional
+     hardware state.  Here we find the missing registers.  */
+  addr = get_frame_memory_unsigned (next_frame, addr + 16, 4) + 4;
+  for (regnum = M68K_D0_REGNUM; regnum < M68K_FP_REGNUM; regnum++, addr += 4)
+    trad_frame_set_reg_addr (this_cache, regnum, addr);
+
+  /* Construct the frame ID using the function start.  */
+  trad_frame_set_id (this_cache, frame_id_build (base, func));
+}
+
+static const struct tramp_frame m68kobsd_sigtramp = {
+  SIGTRAMP_FRAME,
+  2,
+  {
+    { 0x206f, -1 }, { 0x000c, -1},	/* moveal %sp@(12),%a0 */
+    { 0x4e90, -1 },			/* jsr %a0@ */
+    { 0x588f, -1 },			/* addql #4,%sp */
+    { 0x4e41, -1 },			/* trap #1 */
+    { 0x2f40, -1 }, { 0x0004, -1 },	/* moveal %d0,%sp@(4) */
+    { 0x7001, -1 },			/* moveq #SYS_exit,%d0 */
+    { 0x4e40, -1 },			/* trap #0 */
+    { TRAMP_SENTINEL_INSN, -1 }
+  },
+  m68kobsd_sigtramp_cache_init
+};
+
 
 static void
 m68kbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
@@ -149,6 +207,8 @@ m68kbsd_aout_init_abi (struct gdbarch_in
   m68kbsd_init_abi (info, gdbarch);
 
   tdep->struct_return = reg_struct_return;
+
+  tramp_frame_prepend_unwinder (gdbarch, &m68kobsd_sigtramp);
 }
 
 /* NetBSD ELF.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]