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/rfc] Add frame type and mask to tramp-frame


Hello,

This patch tweaks the tramp-frame code so that:

- the frame's type is part of the trampoline description
Lets the code be used for more than just signal trampolines.

- the instructions are paired with a simple mask
So that some more general instruction sequences can be matched.

I'll look to commit in a few days,
Andrew
2004-05-11  Andrew Cagney  <cagney@redhat.com>

	* tramp-frame.h (struct tramp_frame): Change "insn" to a struct
	containing both bytes and mask.  Add "frame_type".
	* tramp-frame.c (tramp_frame_start): Update.
	(tramp_frame_prepend_unwinder): Update.
	* mips-linux-tdep.c (mips_linux_o32_sigframe)
	(mips_linux_o32_rt_sigframe, mips_linux_n32_rt_sigframe)
	(mips_linux_n64_rt_sigframe): Update.  Make "static const".
	* ppcnbsd-tdep.c (tramp_frame ppcnbsd_sigtramp): Update.

Index: mips-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-linux-tdep.c,v
retrieving revision 1.24
diff -p -u -r1.24 mips-linux-tdep.c
--- mips-linux-tdep.c	29 Apr 2004 18:28:42 -0000	1.24
+++ mips-linux-tdep.c	14 Jun 2004 23:25:45 -0000
@@ -830,25 +830,40 @@ static void mips_linux_n32n64_sigframe_i
 #define MIPS_INST_LI_V0_N32_RT_SIGRETURN 0x24020000 + MIPS_NR_N32_rt_sigreturn
 #define MIPS_INST_SYSCALL 0x0000000c
 
-struct tramp_frame mips_linux_o32_sigframe = {
+static const struct tramp_frame mips_linux_o32_sigframe = {
+  SIGTRAMP_FRAME,
   4,
-  { MIPS_INST_LI_V0_SIGRETURN, MIPS_INST_SYSCALL, TRAMP_SENTINEL_INSN },
+  {
+    { MIPS_INST_LI_V0_SIGRETURN, -1 },
+    { MIPS_INST_SYSCALL, -1 },
+    { TRAMP_SENTINEL_INSN, -1 }
+  },
   mips_linux_o32_sigframe_init
 };
 
-struct tramp_frame mips_linux_o32_rt_sigframe = {
+static const struct tramp_frame mips_linux_o32_rt_sigframe = {
+  SIGTRAMP_FRAME,
   4,
-  { MIPS_INST_LI_V0_RT_SIGRETURN, MIPS_INST_SYSCALL, TRAMP_SENTINEL_INSN },
+  {
+    { MIPS_INST_LI_V0_RT_SIGRETURN, -1 },
+    { MIPS_INST_SYSCALL, -1 },
+    { TRAMP_SENTINEL_INSN, -1 } },
   mips_linux_o32_sigframe_init
 };
 
-struct tramp_frame mips_linux_n32_rt_sigframe = {
+static const struct tramp_frame mips_linux_n32_rt_sigframe = {
+  SIGTRAMP_FRAME,
   4,
-  { MIPS_INST_LI_V0_N32_RT_SIGRETURN, MIPS_INST_SYSCALL, TRAMP_SENTINEL_INSN },
+  {
+    { MIPS_INST_LI_V0_N32_RT_SIGRETURN, -1 },
+    { MIPS_INST_SYSCALL, -1 },
+    { TRAMP_SENTINEL_INSN, -1 }
+  },
   mips_linux_n32n64_sigframe_init
 };
 
-struct tramp_frame mips_linux_n64_rt_sigframe = {
+static const struct tramp_frame mips_linux_n64_rt_sigframe = {
+  SIGTRAMP_FRAME,
   4,
   { MIPS_INST_LI_V0_N64_RT_SIGRETURN, MIPS_INST_SYSCALL, TRAMP_SENTINEL_INSN },
   mips_linux_n32n64_sigframe_init
Index: ppcnbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppcnbsd-tdep.c,v
retrieving revision 1.22
diff -p -u -r1.22 ppcnbsd-tdep.c
--- ppcnbsd-tdep.c	13 May 2004 19:36:05 -0000	1.22
+++ ppcnbsd-tdep.c	14 Jun 2004 23:25:45 -0000
@@ -293,14 +293,15 @@ ppcnbsd_sigtramp_cache_init (const struc
    instruction, or zero if it isn't a signal trampoline.  */
 
 static const struct tramp_frame ppcnbsd_sigtramp = {
+  SIGTRAMP_FRAME,
   4, /* insn size */
   { /* insn */
-    0x38610018, /* addi r3,r1,24 */
-    0x38000127, /* li r0,295 */
-    0x44000002, /* sc */
-    0x38000001, /* li r0,1 */
-    0x44000002, /* sc */
-    TRAMP_SENTINEL_INSN
+    { 0x38610018, -1 }, /* addi r3,r1,24 */
+    { 0x38000127, -1 }, /* li r0,295 */
+    { 0x44000002, -1 }, /* sc */
+    { 0x38000001, -1 }, /* li r0,1 */
+    { 0x44000002, -1 }, /* sc */
+    { TRAMP_SENTINEL_INSN, -1 }
   },
   ppcnbsd_sigtramp_cache_init
 };
Index: tramp-frame.c
===================================================================
RCS file: /cvs/src/src/gdb/tramp-frame.c,v
retrieving revision 1.5
diff -p -u -r1.5 tramp-frame.c
--- tramp-frame.c	8 Apr 2004 20:03:52 -0000	1.5
+++ tramp-frame.c	14 Jun 2004 23:25:45 -0000
@@ -91,7 +91,7 @@ tramp_frame_start (const struct tramp_fr
   int ti;
   /* Search through the trampoline for one that matches the
      instruction sequence around PC.  */
-  for (ti = 0; tramp->insn[ti] != TRAMP_SENTINEL_INSN; ti++)
+  for (ti = 0; tramp->insn[ti].bytes != TRAMP_SENTINEL_INSN; ti++)
     {
       CORE_ADDR func = pc - tramp->insn_size * ti;
       int i;
@@ -99,14 +99,14 @@ tramp_frame_start (const struct tramp_fr
 	{
 	  bfd_byte buf[sizeof (tramp->insn[0])];
 	  ULONGEST insn;
-	  if (tramp->insn[i] == TRAMP_SENTINEL_INSN)
+	  if (tramp->insn[i].bytes == TRAMP_SENTINEL_INSN)
 	    return func;
 	  if (!safe_frame_unwind_memory (next_frame,
 					 func + i * tramp->insn_size,
 					 buf, tramp->insn_size))
 	    break;
 	  insn = extract_unsigned_integer (buf, tramp->insn_size);
-	  if (tramp->insn[i] != insn)
+	  if (tramp->insn[i].bytes != (insn & tramp->insn[i].mask))
 	    break;
 	}
     }
@@ -156,11 +156,11 @@ tramp_frame_prepend_unwinder (struct gdb
   /* Check that the instruction sequence contains a sentinel.  */
   for (i = 0; i < ARRAY_SIZE (tramp_frame->insn); i++)
     {
-      if (tramp_frame->insn[i] == TRAMP_SENTINEL_INSN)
+      if (tramp_frame->insn[i].bytes == TRAMP_SENTINEL_INSN)
 	break;
     }
   gdb_assert (i < ARRAY_SIZE (tramp_frame->insn));
-  gdb_assert (tramp_frame->insn_size <= sizeof (tramp_frame->insn[0]));
+  gdb_assert (tramp_frame->insn_size <= sizeof (tramp_frame->insn[0].bytes));
 
   data = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_data);
   unwinder = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_unwind);
Index: tramp-frame.h
===================================================================
RCS file: /cvs/src/src/gdb/tramp-frame.h,v
retrieving revision 1.4
diff -p -u -r1.4 tramp-frame.h
--- tramp-frame.h	8 Apr 2004 20:03:52 -0000	1.4
+++ tramp-frame.h	14 Jun 2004 23:25:45 -0000
@@ -22,6 +22,8 @@
 #ifndef TRAMP_FRAME_H
 #define TRAMP_FRAME_H
 
+#include "frame.h"		/* For "enum frame_type".  */
+
 struct trad_frame;
 struct frame_info;
 struct trad_frame_cache;
@@ -45,16 +47,24 @@ struct trad_frame_cache;
 
 struct tramp_frame
 {
-  /* The trampoline's entire instruction sequence.  Search for this in
-     the inferior at or around the frame's PC.  It is assumed that the
-     PC is INSN_SIZE aligned, and that each element of TRAMP contains
-     one INSN_SIZE instruction.  It is also assumed that TRAMP[0]
-     contains the first instruction of the trampoline and hence the
-     address of the instruction matching TRAMP[0] is the trampoline's
-     "func" address.  The instruction sequence shall be terminated by
+  /* The trampoline's type, some a signal trampolines, some are normal
+     call-frame trampolines (aka thunks).  */
+  enum frame_type frame_type;
+  /* The trampoline's entire instruction sequence.  It consists of a
+     bytes/mask pair.  Search for this in the inferior at or around
+     the frame's PC.  It is assumed that the PC is INSN_SIZE aligned,
+     and that each element of TRAMP contains one INSN_SIZE
+     instruction.  It is also assumed that TRAMP[0] contains the first
+     instruction of the trampoline and hence the address of the
+     instruction matching TRAMP[0] is the trampoline's "func" address.
+     The instruction sequence shall be terminated by
      TRAMP_SENTINEL_INSN.  */
   int insn_size;
-  ULONGEST insn[8];
+  struct
+  {
+    ULONGEST bytes;
+    ULONGEST mask;
+  } insn[8];
   /* Initialize a trad-frame cache corresponding to the tramp-frame.
      FUNC is the address of the instruction TRAMP[0] in memory.  */
   void (*init) (const struct tramp_frame *self,

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