This is the mail archive of the gdb-patches@sources.redhat.com 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]

[PATCH] Add sigtramp support for FreeBSD/Alpha


This adds signaltramp support for FreeBSD/Alpha, which fixes a few
failures in the testsuite.

Checked in on mainline.

Mark

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

	* alpha-tdep.h (struct gdbarch_tdep): Add members `sc_pc_offset',
	`sc_regs_offset' and `sc_fpregs_offset'.
	* alpha-tdep.c (SIGFRAME_PC_OFF, SIGFRAME_REGSAVE_OFF,
	SIGFRAME_FPREGSAVE_OFF): Remove defines.
	(alpha_sigtramp_register_address): Rewrite to use new members of
	`struct gdbarch_tdep'.
	(alpha_gdbarch_init): Initialize new members of struct
	gdbarch_tdep'.
	* alphafbsd-tdep.c (alphafbsd_use_struct_convention): Use
	ALPHA_REGISTER_SIZE instead of DEPRECATED_REGISTER_SIZE.
	(alphafbsd_sigtramp_start, alphafbsd_sigtramp_end): Nre variables.
	(alphafbsd_pc_in_sigtramp): Implement.
	(alphafbsd_sigtramp_offset): New function.
	(alphafbsd_sigcontext_addr): New function.
	(alphafbsd_init_abi): Initialize signal trampoline related members
	of `struct gdbarch_tdep'.
	(_initialize_alphafbsd_tdep): Add prototype.

Index: alpha-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/alpha-tdep.c,v
retrieving revision 1.116
diff -u -p -r1.116 alpha-tdep.c
--- alpha-tdep.c 14 Jun 2003 22:35:23 -0000 1.116
+++ alpha-tdep.c 11 Jul 2003 21:45:41 -0000
@@ -753,24 +753,20 @@ alpha_sigtramp_frame_unwind_cache (struc
   return info;
 }
 
-/* Return the address of REGNO in a sigtramp frame.  Since this is all
-   arithmetic, it doesn't seem worthwhile to cache it.  */
-
-#ifndef SIGFRAME_PC_OFF
-#define SIGFRAME_PC_OFF		(2 * 8)
-#define SIGFRAME_REGSAVE_OFF	(4 * 8)
-#define SIGFRAME_FPREGSAVE_OFF	(SIGFRAME_REGSAVE_OFF + 32 * 8 + 8)
-#endif
+/* Return the address of REGNUM in a sigtramp frame.  Since this is
+   all arithmetic, it doesn't seem worthwhile to cache it.  */
 
 static CORE_ADDR
-alpha_sigtramp_register_address (CORE_ADDR sigcontext_addr, unsigned int regno)
+alpha_sigtramp_register_address (CORE_ADDR sigcontext_addr, int regnum)
 { 
-  if (regno < 32)
-    return sigcontext_addr + SIGFRAME_REGSAVE_OFF + regno * 8;
-  if (regno >= ALPHA_FP0_REGNUM && regno < ALPHA_FP0_REGNUM + 32)
-    return sigcontext_addr + SIGFRAME_FPREGSAVE_OFF + regno * 8;
-  if (regno == ALPHA_PC_REGNUM)
-    return sigcontext_addr + SIGFRAME_PC_OFF; 
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+
+  if (regnum >= 0 && regnum < 32)
+    return sigcontext_addr + tdep->sc_regs_offset + regnum * 8;
+  else if (regnum >= ALPHA_FP0_REGNUM && regnum < ALPHA_FP0_REGNUM + 32)
+    return sigcontext_addr + tdep->sc_fpregs_offset + regnum * 8;
+  else if (regnum == ALPHA_PC_REGNUM)
+    return sigcontext_addr + tdep->sc_pc_offset; 
 
   return 0;
 }
@@ -1495,6 +1491,9 @@ alpha_gdbarch_init (struct gdbarch_info 
 
   tdep->dynamic_sigtramp_offset = NULL;
   tdep->sigcontext_addr = NULL;
+  tdep->sc_pc_offset = 2 * 8;
+  tdep->sc_regs_offset = 4 * 8;
+  tdep->sc_fpregs_offset = tdep->sc_regs_offset + 32 * 8 + 8;
 
   tdep->jb_pc = -1;	/* longjmp support not enabled by default  */
 
Index: alpha-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/alpha-tdep.h,v
retrieving revision 1.18
diff -u -p -r1.18 alpha-tdep.h
--- alpha-tdep.h 4 Jun 2003 06:22:17 -0000 1.18
+++ alpha-tdep.h 11 Jul 2003 21:45:41 -0000
@@ -82,6 +82,11 @@ struct gdbarch_tdep
      the sigcontext structure for that signal handler.  */
   CORE_ADDR (*sigcontext_addr) (struct frame_info *);
 
+  /* Offset of registers in `struct sigcontext'.  */
+  int sc_pc_offset;
+  int sc_regs_offset;
+  int sc_fpregs_offset;
+
   int jb_pc;			/* Offset to PC value in jump buffer.
 				   If htis is negative, longjmp support
 				   will be disabled.  */
Index: alphafbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/alphafbsd-tdep.c,v
retrieving revision 1.9
diff -u -p -r1.9 alphafbsd-tdep.c
--- alphafbsd-tdep.c 4 Jun 2003 06:22:17 -0000 1.9
+++ alphafbsd-tdep.c 11 Jul 2003 21:45:41 -0000
@@ -32,7 +32,7 @@ alphafbsd_use_struct_convention (int gcc
 
   /* All aggregate types that won't fit in a register must be returned
      in memory.  */
-  if (TYPE_LENGTH (type) > DEPRECATED_REGISTER_SIZE)
+  if (TYPE_LENGTH (type) > ALPHA_REGISTER_SIZE)
     return 1;
 
   /* The only aggregate types that can be returned in a register are
@@ -54,14 +54,41 @@ alphafbsd_use_struct_convention (int gcc
 
   return 0;
 }
+
+
+/* Support for signal handlers.  */
+
+/* Return whether PC is in a BSD sigtramp routine.  */
+
+CORE_ADDR alphafbsd_sigtramp_start = 0x11ffff68;
+CORE_ADDR alphafbsd_sigtramp_end = 0x11ffffe0;
 
 static int
 alphafbsd_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
 {
-  /* FIXME */
-  return 0;
+  return (pc >= alphafbsd_sigtramp_start && pc < alphafbsd_sigtramp_end);
 }
 
+static LONGEST
+alphafbsd_sigtramp_offset (CORE_ADDR pc)
+{
+  return pc - alphafbsd_sigtramp_start;
+}
+
+/* Assuming NEXT_FRAME is for a frame following a BSD sigtramp
+   routine, return the address of the associated sigcontext structure.  */
+
+static CORE_ADDR
+alphafbsd_sigcontext_addr (struct frame_info *next_frame)
+{
+  ULONGEST sp;
+
+  frame_unwind_unsigned_register (next_frame, ALPHA_SP_REGNUM, &sp);
+  return sp + 24;
+}
+
+/* FreeBSD 5.0-RELEASE or later.  */
+
 static void
 alphafbsd_init_abi (struct gdbarch_info info,
                     struct gdbarch *gdbarch)
@@ -74,13 +101,23 @@ alphafbsd_init_abi (struct gdbarch_info 
   /* Hook into the MDEBUG frame unwinder.  */
   alpha_mdebug_init_abi (info, gdbarch);
 
+  set_gdbarch_use_struct_convention (gdbarch, alphafbsd_use_struct_convention);
+
   set_gdbarch_pc_in_sigtramp (gdbarch, alphafbsd_pc_in_sigtramp);
 
-  set_gdbarch_use_struct_convention (gdbarch, alphafbsd_use_struct_convention);
+  tdep->dynamic_sigtramp_offset = alphafbsd_sigtramp_offset;
+  tdep->sigcontext_addr = alphafbsd_sigcontext_addr;
+  tdep->sc_pc_offset = 288;
+  tdep->sc_regs_offset = 24;
+  tdep->sc_fpregs_offset = 320;
 
   tdep->jb_pc = 2;
   tdep->jb_elt_size = 8;
 }
+
+
+/* Provide a prototype to silence -Wmissing-prototypes.  */
+void _initialize_alphafbsd_tdep (void);
 
 void
 _initialize_alphafbsd_tdep (void)


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