This patch lets gdb understand the linux signal handler tramponline,
for both standard kernels and kernels modified by Solar Designer's
no-exec stack patch.  With this, the "where" command is properly able
to walk up the stack past a trampoline.

Dean

diff -r -u gdb-4.17/gdb/config/i386/tm-linux.h gdb-4.17.local/gdb/config/i386/tm-linux.h
--- gdb-4.17/gdb/config/i386/tm-linux.h	Tue Apr 21 18:23:17 1998
+++ gdb-4.17.local/gdb/config/i386/tm-linux.h	Wed Sep 16 22:43:24 1998
@@ -25,8 +25,18 @@
 
 #include "i386/tm-i386.h"
 
-/* Offset to saved PC in sigcontext, from <linux/signal.h>.  */
-#define SIGCONTEXT_PC_OFFSET 38
+/* need custom routine to extract the saved pc from sigcontext */
+#define I386LINUX_SIGTRAMP_SAVED_PC 1
+
+/* 0xC0DE0001 is the magic constant used by the secure stack trampoline
+ * 0x0077b858 0x80cd0000 are the words used by the standard stack
+ * trampoline
+ */
+#undef IN_SIGTRAMP
+#define IN_SIGTRAMP(pc, name) \
+	((pc) == 0xC0DE0001ul \
+	  || (read_memory_unsigned_integer ((pc), 4) == 0x0077b858ul 	\
+	  && read_memory_unsigned_integer ((pc)+4, 4) == 0x80cd0000ul))	\
 
 /* We need this file for the SOLIB_TRAMPOLINE stuff. */
 
diff -r -u gdb-4.17/gdb/i386-tdep.c gdb-4.17.local/gdb/i386-tdep.c
--- gdb-4.17/gdb/i386-tdep.c	Fri Apr 10 22:39:37 1998
+++ gdb-4.17.local/gdb/i386-tdep.c	Tue Sep 15 14:34:54 1998
@@ -660,6 +660,31 @@
 }
 #endif /* I386V4_SIGTRAMP_SAVED_PC */
 
+#ifdef I386LINUX_SIGTRAMP_SAVED_PC
+/* Get saved user PC for the signal trampoline written on the stack */
+
+CORE_ADDR
+sigtramp_saved_pc (frame)
+    struct frame_info *frame;
+{
+  CORE_ADDR sigcontext_addr;
+  char buf[TARGET_PTR_BIT / TARGET_CHAR_BIT];
+  int ptrbytes = TARGET_PTR_BIT / TARGET_CHAR_BIT;
+
+  if (frame->next)
+    sigcontext_addr = FRAME_ARGS_ADDRESS (frame->next)
+    			+ FRAME_ARGS_SKIP
+			+ TARGET_INT_BIT / TARGET_CHAR_BIT;
+  else
+    sigcontext_addr = read_register (SP_REGNUM)
+    			+ 2 * TARGET_INT_BIT / TARGET_CHAR_BIT;
+
+  target_read_memory (sigcontext_addr + 14 * TARGET_PTR_BIT / TARGET_CHAR_BIT,
+			buf, ptrbytes);
+  return extract_unsigned_integer (buf, ptrbytes);
+}
+#endif
+
 #ifdef STATIC_TRANSFORM_NAME
 /* SunPRO encodes the static variables.  This is not related to C++ mangling,
    it is done for C too.  */
