summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2002-07-01 21:16:32 +0000
committerMark Kettenis <kettenis@gnu.org>2002-07-01 21:16:32 +0000
commit2eae7bdf8b9733bfc8f12ff5ec20fe1274514a7e (patch)
tree9d72a486ee85044323551d515049c24096ac3bf2
parent6725ef7e8b5f88aad1fcba6d047af337f6b8bea0 (diff)
downloadgdb-2eae7bdf8b9733bfc8f12ff5ec20fe1274514a7e.tar.gz
* i386-tdep.h (struct gdbarch_tdep): Replace sigtramp_saved_pc
with sigcontext_addr. Add sc_sp_offset. (i386bsd_sigtramp_saved_pc): Remove prototype. (i386bsd_sicontext_addr): Add prototype. * i386-tdep.c (i386_sigtramp_saved_pc): New function. (i386_frame_saved_pc): Rewrite to call i386_sigtramp_saved_pc. (i386_svr4_sigtramp_saved_pc): Removed. (i386_svr4_sigcontext_addr): New function. (i386_svr4_init_abi): Don't initialize tdep->sigtramp_saved_pc. Initialize tdep->sigcontext_addr instead. Initialize tdep->sc_pc_offset and tdep->sc_sp_offset. (i386_gdbarch_init): Likewise. * i386bsd-tdep.c (i386bsd_sigcontext_addr): Don't make it static any more. (i386bsd_sigtramp_saved_pc): Remove function. (i386bsd_init_abi): Don't initialize tdep->sigtramp_saved_pc. Initialize tdep->sigcontext_addr instead. Initialize tdep->sc_pc_offset. * i386-linux-tdep.c (i386_linux_init_abi): Remove initialization of tdep->sigtramp_saved_pc. * i386-sol2-tdep.c (i386_sol2_init_abi): Don't initialize tdep->sigtramp_saved_pc. Initialize tdep->sigcontext_addr instead.
-rw-r--r--gdb/ChangeLog24
-rw-r--r--gdb/i386-linux-tdep.c1
-rw-r--r--gdb/i386-sol2-tdep.c2
-rw-r--r--gdb/i386-tdep.c52
-rw-r--r--gdb/i386-tdep.h11
-rw-r--r--gdb/i386bsd-tdep.c25
6 files changed, 69 insertions, 46 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7d99b7fc62e..1f2e5ce251a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,29 @@
2002-07-01 Mark Kettenis <kettenis@gnu.org>
+ * i386-tdep.h (struct gdbarch_tdep): Replace sigtramp_saved_pc
+ with sigcontext_addr. Add sc_sp_offset.
+ (i386bsd_sigtramp_saved_pc): Remove prototype.
+ (i386bsd_sicontext_addr): Add prototype.
+ * i386-tdep.c (i386_sigtramp_saved_pc): New function.
+ (i386_frame_saved_pc): Rewrite to call i386_sigtramp_saved_pc.
+ (i386_svr4_sigtramp_saved_pc): Removed.
+ (i386_svr4_sigcontext_addr): New function.
+ (i386_svr4_init_abi): Don't initialize tdep->sigtramp_saved_pc.
+ Initialize tdep->sigcontext_addr instead. Initialize
+ tdep->sc_pc_offset and tdep->sc_sp_offset.
+ (i386_gdbarch_init): Likewise.
+ * i386bsd-tdep.c (i386bsd_sigcontext_addr): Don't make it static
+ any more.
+ (i386bsd_sigtramp_saved_pc): Remove function.
+ (i386bsd_init_abi): Don't initialize tdep->sigtramp_saved_pc.
+ Initialize tdep->sigcontext_addr instead. Initialize
+ tdep->sc_pc_offset.
+ * i386-linux-tdep.c (i386_linux_init_abi): Remove initialization
+ of tdep->sigtramp_saved_pc.
+ * i386-sol2-tdep.c (i386_sol2_init_abi): Don't initialize
+ tdep->sigtramp_saved_pc. Initialize tdep->sigcontext_addr
+ instead.
+
* i386-tdep.c (i386_frameless_function_invocation,
i386_frame_num_args, i386_frame_init_saved_regs,
i386_skip_prologue, i386_push_dummy_frame, i386_fix_call_dummy,
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index 8fa9261e3c3..1a69e0be24e 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -566,7 +566,6 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_frame_chain (gdbarch, i386_linux_frame_chain);
set_gdbarch_frame_saved_pc (gdbarch, i386_linux_frame_saved_pc);
set_gdbarch_saved_pc_after_call (gdbarch, i386_linux_saved_pc_after_call);
- tdep->sigtramp_saved_pc = i386_linux_sigtramp_saved_pc;
set_solib_svr4_fetch_link_map_offsets (gdbarch,
i386_linux_svr4_fetch_link_map_offsets);
diff --git a/gdb/i386-sol2-tdep.c b/gdb/i386-sol2-tdep.c
index 2244643adff..84257ee0b40 100644
--- a/gdb/i386-sol2-tdep.c
+++ b/gdb/i386-sol2-tdep.c
@@ -44,7 +44,7 @@ i386_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* Signal trampolines are different from SVR4, in fact they're
rather similar to BSD. */
set_gdbarch_pc_in_sigtramp (gdbarch, i386_sol2_pc_in_sigtramp);
- tdep->sigtramp_saved_pc = i386bsd_sigtramp_saved_pc;
+ tdep->sigcontext_addr = i386bsd_sigcontext_addr;
tdep->sc_pc_offset = 36 + 14 * 4;
/* Assume that the prototype flag can be trusted. */
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 7c11b60d68b..c45c2712dc7 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -481,19 +481,26 @@ i386_frameless_function_invocation (struct frame_info *frame)
return frameless_look_for_prologue (frame);
}
+/* Assuming FRAME is for a sigtramp routine, return the saved program
+ counter. */
+
+static CORE_ADDR
+i386_sigtramp_saved_pc (struct frame_info *frame)
+{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+ CORE_ADDR addr;
+
+ addr = tdep->sigcontext_addr (frame);
+ return read_memory_unsigned_integer (addr + tdep->sc_pc_offset, 4);
+}
+
/* Return the saved program counter for FRAME. */
static CORE_ADDR
i386_frame_saved_pc (struct frame_info *frame)
{
if (frame->signal_handler_caller)
- {
- CORE_ADDR (*sigtramp_saved_pc) (struct frame_info *);
- sigtramp_saved_pc = gdbarch_tdep (current_gdbarch)->sigtramp_saved_pc;
-
- gdb_assert (sigtramp_saved_pc != NULL);
- return sigtramp_saved_pc (frame);
- }
+ return i386_sigtramp_saved_pc (frame);
return read_memory_unsigned_integer (frame->frame + 4, 4);
}
@@ -1244,29 +1251,31 @@ i386_svr4_pc_in_sigtramp (CORE_ADDR pc, char *name)
|| strcmp ("sigvechandler", name) == 0));
}
-/* Get saved user PC for sigtramp from the pushed ucontext on the
- stack for all three variants of SVR4 sigtramps. */
+/* Get address of the pushed ucontext (sigcontext) on the stack for
+ all three variants of SVR4 sigtramps. */
static CORE_ADDR
-i386_svr4_sigtramp_saved_pc (struct frame_info *frame)
+i386_svr4_sigcontext_addr (struct frame_info *frame)
{
- CORE_ADDR saved_pc_offset = 4;
+ int sigcontext_offset = -1;
char *name = NULL;
find_pc_partial_function (frame->pc, &name, NULL, NULL);
if (name)
{
if (strcmp (name, "_sigreturn") == 0)
- saved_pc_offset = 132 + 14 * 4;
+ sigcontext_offset = 132;
else if (strcmp (name, "_sigacthandler") == 0)
- saved_pc_offset = 80 + 14 * 4;
+ sigcontext_offset = 80;
else if (strcmp (name, "sigvechandler") == 0)
- saved_pc_offset = 120 + 14 * 4;
+ sigcontext_offset = 120;
}
+ gdb_assert (sigcontext_offset != -1);
+
if (frame->next)
- return read_memory_integer (frame->next->frame + saved_pc_offset, 4);
- return read_memory_integer (read_register (SP_REGNUM) + saved_pc_offset, 4);
+ return frame->next->frame + sigcontext_offset;
+ return read_register (SP_REGNUM) + sigcontext_offset;
}
@@ -1303,7 +1312,9 @@ i386_svr4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_frame_chain_valid (gdbarch, func_frame_chain_valid);
set_gdbarch_pc_in_sigtramp (gdbarch, i386_svr4_pc_in_sigtramp);
- tdep->sigtramp_saved_pc = i386_svr4_sigtramp_saved_pc;
+ tdep->sigcontext_addr = i386_svr4_sigcontext_addr;
+ tdep->sc_pc_offset = 14 * 4;
+ tdep->sc_sp_offset = 7 * 4;
tdep->jb_pc_offset = 20;
}
@@ -1369,17 +1380,18 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
tdep->jb_pc_offset = -1;
tdep->struct_return = pcc_struct_return;
- tdep->sigtramp_saved_pc = NULL;
tdep->sigtramp_start = 0;
tdep->sigtramp_end = 0;
+ tdep->sigcontext_addr = NULL;
tdep->sc_pc_offset = -1;
+ tdep->sc_sp_offset = -1;
/* The format used for `long double' on almost all i386 targets is
the i387 extended floating-point format. In fact, of all targets
in the GCC 2.95 tree, only OSF/1 does it different, and insists
on having a `long double' that's not `long' at all. */
set_gdbarch_long_double_format (gdbarch, &floatformat_i387_ext);
-
+
/* Although the i386 extended floating-point has only 80 significant
bits, a `long double' actually takes up 96, probably to enforce
alignment. */
@@ -1388,7 +1400,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
/* NOTE: tm-i386aix.h, tm-i386bsd.h, tm-i386os9k.h, tm-ptx.h,
tm-symmetry.h currently override this. Sigh. */
set_gdbarch_num_regs (gdbarch, I386_NUM_GREGS + I386_NUM_FREGS);
-
+
set_gdbarch_sp_regnum (gdbarch, 4);
set_gdbarch_fp_regnum (gdbarch, 5);
set_gdbarch_pc_regnum (gdbarch, 8);
diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
index 61a817822c4..d255c40ca0e 100644
--- a/gdb/i386-tdep.h
+++ b/gdb/i386-tdep.h
@@ -65,15 +65,16 @@ struct gdbarch_tdep
/* Convention for returning structures. */
enum struct_return struct_return;
- /* Get saved PC for sigtramp. */
- CORE_ADDR (*sigtramp_saved_pc) (struct frame_info *);
-
/* Address range where sigtramp lives. */
CORE_ADDR sigtramp_start;
CORE_ADDR sigtramp_end;
- /* Offset of saved PC in `struct sigcontext'. */
+ /* Get address of sigcontext for sigtramp. */
+ CORE_ADDR (*sigcontext_addr) (struct frame_info *);
+
+ /* Offset of saved PC and SP in `struct sigcontext'. */
int sc_pc_offset;
+ int sc_sp_offset;
};
/* Floating-point registers. */
@@ -175,6 +176,6 @@ extern void i386_svr4_init_abi (struct gdbarch_info, struct gdbarch *);
/* Functions exported from i386bsd-tdep.c. */
-extern CORE_ADDR i386bsd_sigtramp_saved_pc (struct frame_info *frame);
+extern CORE_ADDR i386bsd_sigcontext_addr (struct frame_info *frame);
#endif /* i386-tdep.h */
diff --git a/gdb/i386bsd-tdep.c b/gdb/i386bsd-tdep.c
index a82733de5e5..a419cab87d3 100644
--- a/gdb/i386bsd-tdep.c
+++ b/gdb/i386bsd-tdep.c
@@ -39,9 +39,12 @@ i386bsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
}
/* Assuming FRAME is for a BSD sigtramp routine, return the address of
- the associated sigcontext structure. */
+ the associated sigcontext structure.
-static CORE_ADDR
+ Note: This function is used for Solaris 2 too, so don't make it
+ static. */
+
+CORE_ADDR
i386bsd_sigcontext_addr (struct frame_info *frame)
{
if (frame->next)
@@ -55,22 +58,6 @@ i386bsd_sigcontext_addr (struct frame_info *frame)
return read_memory_unsigned_integer (read_register (SP_REGNUM) + 8, 4);
}
-/* Assuming FRAME is for a BSD sigtramp routine, return the saved
- program counter.
-
- Note: This function is used for Solaris 2 too, so don't make it
- static. */
-
-CORE_ADDR
-i386bsd_sigtramp_saved_pc (struct frame_info *frame)
-{
- int sc_pc_offset = gdbarch_tdep (current_gdbarch)->sc_pc_offset;
- CORE_ADDR addr;
-
- addr = i386bsd_sigcontext_addr (frame);
- return read_memory_unsigned_integer (addr + sc_pc_offset, 4);
-}
-
/* Return the start address of the sigtramp routine. */
CORE_ADDR
@@ -116,9 +103,9 @@ i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->jb_pc_offset = 0;
- tdep->sigtramp_saved_pc = i386bsd_sigtramp_saved_pc;
tdep->sigtramp_start = 0xfdbfdfc0;
tdep->sigtramp_end = 0xfdbfe000;
+ tdep->sigcontext_addr = i386bsd_sigcontext_addr;
tdep->sc_pc_offset = i386bsd_sc_pc_offset;
}