aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2004-04-09 16:28:50 +0000
committerMark Kettenis <kettenis@gnu.org>2004-04-09 16:28:50 +0000
commit911bc6ee3f36711ed37e8b829ff1c5622a8b2082 (patch)
treeba085d92d9c29753d0cc9653c095ed79c6c8c208
parente083e6ec57ce717ef39cddd78bc3287606274f6f (diff)
downloadgdb-911bc6ee3f36711ed37e8b829ff1c5622a8b2082.zip
gdb-911bc6ee3f36711ed37e8b829ff1c5622a8b2082.tar.gz
gdb-911bc6ee3f36711ed37e8b829ff1c5622a8b2082.tar.bz2
* amd64-tdep.c (amd64_sigtramp_frame_sniffer): Rewrite to use new
sigtramp_p member of `struct gdbarch_tdep'. Also check whether the program counter is in the range specified by `struct gdbarch_tdep'. * amd64-linux-tdep.c: Include "symtab.h". (amd64_linux_pc_in_sigtramp): Remove function. (amd64_linux_sigtramp_p): New function. (amd64_linux_init_abi): Initialize TDEP->sigtramp_p. Don't set deprecated_pc_in_sigtramp. * amd64nbsd-tdep.c: Include "symtab.h". (amd64nbsd_sigtramp_p): New function. (amd64nbsd_init_abi): Initialize TDEP->sigtramp_p. Don't set deprecated_pc_in_sigtramp. * amd64obsd-tdep.c: Include "symtab.h" and "objfiles.h". Add a few comments. (amd64obsd_pc_in_sigtramp): Remove function. (amd64obsd_sigtramp_p): New function. (amd64obsd_init_abi): Initialize TDEP->sigtramp_p. Don't set deprecated_pc_in_sigtramp. * i386-tdep.h (struct gdbarch_tdep): Add sigtramp_p member. (i386bsd_pc_ins_sigtramp): Remove prototype. (i386bsd_sigtramp_start, i386bsd_sigtramp_end): Remove prototypes. * i386-tdep.c (i386_sigtramp_frame_sniffer): Rewrite to use new sigtramp_p member of `struct gdbarch_tdep'. Also check whether the program counter is in the range specified by `struct gdbarch_tdep'. (i386_pc_in_sigtramp, i386_svr4_pc_in_sigtramp): Remove functions. (i386_sigtramp_p, i386_svr4_sigtramp_p): New functions. (i386_go32_pc_in_sigtramp): Remove function. (i386_svr4_init_abi): Don't set deprecated_pc_in_sigtramp. Initialize TDEP->sigtramp_p. (i386_go32_init_abi): Initialize TDEP->sigtramp_p to NULL. (i386_gdbarch_init): Initialize TDEP->sigtramp_p. Don't set deprecated_pc_in_sigtramp. * i386-linux-tdep.c: Adjust comments. (i386_linux_pc_in_sigtramp): Remove function. (i386_linux_sigtramp_p): New function. (i386_linux_init_abi): Initialize TDEP->sigtramp_p. Don't set deprecated_pc_in_sigtramp. * i386-nto-tdep.c: Update copyright year. (i386nto_pc_in_sigtramp): Remove function. (i386nto_sigtramp_p): New function. (i386nto_sigcontext_addr): Use I386_ESP_REGNUM instead of SP_REGNUM. (i386nto_init_abi): Initialize TDEP->sigtramp_p. Don't set deprecated_pc_in_sigtramp. * i386-sol2-tdep.c: Update copyright year. (i386_sol2_pc_in_sigtramp): Remove function. (i386_sol2_sigtramp_p): New function. (i386_sol2_init_abi): Initialize TDEP->sigtramp_p. Don't set deprecated_pc_in_sigtramp. * i386bsd-tdep.c (i386bsd_pc_in_sigtramp): Remove function. (i386bsd_sigtramp_start, i386bsd_sigtramp_end): Remove functions. (i386bsd_init_abi): Don't set deprecated_pc_in_sigtramp, deprecated_sigtramp_start and deprecated_sigtramp_end. * i386nbsd-tdep.c: Include "frame.h" and "symtab.h". (i386nbsd_pc_in_sigtramp): Remove function. (i386nbsd_sigtramp_p): New function. (i386nbsd_init_abi): Don't set deprecated_pc_in_sigtramp, deprecated_sigtramp_start, deprecated_sigtramp_end. Initialize TDEP->sigtramp_start, TDEP->sigtramp_end and TDEP->sigtramp_p. * i386obsd-tdep.c: Include "frame.h", "symtab.h" and "objfiles.h". (i386obsd_pc_in_sigtramp): Remove function. (i386obsd_sigtramp_p): New function. (i386obsd_sigtramp_start, i386obsd_sigtramp_end): Remove functions. (i386bsd_init_abi): Don't set deprecated_pc_in_sigtramp, deprecated_sigtramp_start, deprecated_sigtramp_end. Initialize TDEP->sigtramp_p. * Makefile.in (amd64-linux-tdep.o, amd64nbsd-tdep.o, amd64obsd-tdep.o, i386nbsd-tdep.o, i386obsd-tdep.o): Update dependencies.
-rw-r--r--gdb/ChangeLog73
-rw-r--r--gdb/Makefile.in25
-rw-r--r--gdb/amd64-linux-tdep.c13
-rw-r--r--gdb/amd64-tdep.c23
-rw-r--r--gdb/amd64nbsd-tdep.c16
-rw-r--r--gdb/amd64obsd-tdep.c23
-rw-r--r--gdb/i386-linux-tdep.c25
-rw-r--r--gdb/i386-nto-tdep.c17
-rw-r--r--gdb/i386-sol2-tdep.c12
-rw-r--r--gdb/i386-tdep.c62
-rw-r--r--gdb/i386-tdep.h6
-rw-r--r--gdb/i386bsd-tdep.c32
-rw-r--r--gdb/i386nbsd-tdep.c20
-rw-r--r--gdb/i386obsd-tdep.c58
14 files changed, 252 insertions, 153 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bd9aa20..3389752 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,78 @@
2004-04-09 Mark Kettenis <kettenis@gnu.org>
+ * amd64-tdep.c (amd64_sigtramp_frame_sniffer): Rewrite to use new
+ sigtramp_p member of `struct gdbarch_tdep'. Also check whether
+ the program counter is in the range specified by `struct
+ gdbarch_tdep'.
+ * amd64-linux-tdep.c: Include "symtab.h".
+ (amd64_linux_pc_in_sigtramp): Remove function.
+ (amd64_linux_sigtramp_p): New function.
+ (amd64_linux_init_abi): Initialize TDEP->sigtramp_p. Don't set
+ deprecated_pc_in_sigtramp.
+ * amd64nbsd-tdep.c: Include "symtab.h".
+ (amd64nbsd_sigtramp_p): New function.
+ (amd64nbsd_init_abi): Initialize TDEP->sigtramp_p. Don't set
+ deprecated_pc_in_sigtramp.
+ * amd64obsd-tdep.c: Include "symtab.h" and "objfiles.h". Add a
+ few comments.
+ (amd64obsd_pc_in_sigtramp): Remove function.
+ (amd64obsd_sigtramp_p): New function.
+ (amd64obsd_init_abi): Initialize TDEP->sigtramp_p. Don't set
+ deprecated_pc_in_sigtramp.
+ * i386-tdep.h (struct gdbarch_tdep): Add sigtramp_p member.
+ (i386bsd_pc_ins_sigtramp): Remove prototype.
+ (i386bsd_sigtramp_start, i386bsd_sigtramp_end): Remove prototypes.
+ * i386-tdep.c (i386_sigtramp_frame_sniffer): Rewrite to use new
+ sigtramp_p member of `struct gdbarch_tdep'. Also check whether
+ the program counter is in the range specified by `struct
+ gdbarch_tdep'.
+ (i386_pc_in_sigtramp, i386_svr4_pc_in_sigtramp): Remove functions.
+ (i386_sigtramp_p, i386_svr4_sigtramp_p): New functions.
+ (i386_go32_pc_in_sigtramp): Remove function.
+ (i386_svr4_init_abi): Don't set deprecated_pc_in_sigtramp.
+ Initialize TDEP->sigtramp_p.
+ (i386_go32_init_abi): Initialize TDEP->sigtramp_p to NULL.
+ (i386_gdbarch_init): Initialize TDEP->sigtramp_p. Don't set
+ deprecated_pc_in_sigtramp.
+ * i386-linux-tdep.c: Adjust comments.
+ (i386_linux_pc_in_sigtramp): Remove function.
+ (i386_linux_sigtramp_p): New function.
+ (i386_linux_init_abi): Initialize TDEP->sigtramp_p. Don't set
+ deprecated_pc_in_sigtramp.
+ * i386-nto-tdep.c: Update copyright year.
+ (i386nto_pc_in_sigtramp): Remove function.
+ (i386nto_sigtramp_p): New function.
+ (i386nto_sigcontext_addr): Use I386_ESP_REGNUM instead of
+ SP_REGNUM.
+ (i386nto_init_abi): Initialize TDEP->sigtramp_p. Don't set
+ deprecated_pc_in_sigtramp.
+ * i386-sol2-tdep.c: Update copyright year.
+ (i386_sol2_pc_in_sigtramp): Remove function.
+ (i386_sol2_sigtramp_p): New function.
+ (i386_sol2_init_abi): Initialize TDEP->sigtramp_p. Don't set
+ deprecated_pc_in_sigtramp.
+ * i386bsd-tdep.c (i386bsd_pc_in_sigtramp): Remove function.
+ (i386bsd_sigtramp_start, i386bsd_sigtramp_end): Remove functions.
+ (i386bsd_init_abi): Don't set deprecated_pc_in_sigtramp,
+ deprecated_sigtramp_start and deprecated_sigtramp_end.
+ * i386nbsd-tdep.c: Include "frame.h" and "symtab.h".
+ (i386nbsd_pc_in_sigtramp): Remove function.
+ (i386nbsd_sigtramp_p): New function.
+ (i386nbsd_init_abi): Don't set deprecated_pc_in_sigtramp,
+ deprecated_sigtramp_start, deprecated_sigtramp_end. Initialize
+ TDEP->sigtramp_start, TDEP->sigtramp_end and TDEP->sigtramp_p.
+ * i386obsd-tdep.c: Include "frame.h", "symtab.h" and "objfiles.h".
+ (i386obsd_pc_in_sigtramp): Remove function.
+ (i386obsd_sigtramp_p): New function.
+ (i386obsd_sigtramp_start, i386obsd_sigtramp_end): Remove
+ functions.
+ (i386bsd_init_abi): Don't set deprecated_pc_in_sigtramp,
+ deprecated_sigtramp_start, deprecated_sigtramp_end. Initialize
+ TDEP->sigtramp_p.
+ * Makefile.in (amd64-linux-tdep.o, amd64nbsd-tdep.o,
+ amd64obsd-tdep.o, i386nbsd-tdep.o, i386obsd-tdep.o): Update
+ dependencies.
+
* config/i386/i386aout.mt: Remove file.
* configure.tgt: Remove i[34567]86-*-go32*,
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index c405138..7ca4942 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1533,20 +1533,21 @@ amd64-linux-nat.o: amd64-linux-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) \
$(gdb_proc_service_h) $(gregset_h) $(amd64_tdep_h) \
$(i386_linux_tdep_h) $(amd64_nat_h)
amd64-linux-tdep.o: amd64-linux-tdep.c $(defs_h) $(frame_h) $(gdbcore_h) \
- $(regcache_h) $(osabi_h) $(gdb_string_h) $(amd64_tdep_h) \
- $(solib_svr4_h)
+ $(regcache_h) $(osabi_h) $(symtab_h) $(gdb_string_h) \
+ $(amd64_tdep_h) $(solib_svr4_h)
amd64-nat.o: amd64-nat.c $(defs_h) $(gdbarch_h) $(regcache_h) \
$(gdb_assert_h) $(gdb_string_h) $(i386_tdep_h) $(amd64_tdep_h)
amd64nbsd-nat.o: amd64nbsd-nat.c $(defs_h) $(gdb_assert_h) $(amd64_tdep_h) \
$(amd64_nat_h)
amd64nbsd-tdep.o: amd64nbsd-tdep.c $(defs_h) $(arch_utils_h) $(frame_h) \
- $(gdbcore_h) $(osabi_h) $(gdb_assert_h) $(amd64_tdep_h) \
+ $(gdbcore_h) $(osabi_h) $(symtab_h) $(gdb_assert_h) $(amd64_tdep_h) \
$(nbsd_tdep_h) $(solib_svr4_h)
amd64obsd-nat.o: amd64obsd-nat.c $(defs_h) $(gdb_assert_h) $(amd64_tdep_h) \
$(amd64_nat_h)
amd64obsd-tdep.o: amd64obsd-tdep.c $(defs_h) $(frame_h) $(gdbcore_h) \
- $(osabi_h) $(regset_h) $(target_h) $(gdb_assert_h) $(gdb_string_h) \
- $(amd64_tdep_h) $(i387_tdep_h) $(solib_svr4_h)
+ $(symtab_h) $(objfiles_h) $(osabi_h) $(regset_h) $(target_h) \
+ $(gdb_assert_h) $(gdb_string_h) $(amd64_tdep_h) $(i387_tdep_h) \
+ $(solib_svr4_h)
amd64-tdep.o: amd64-tdep.c $(defs_h) $(arch_utils_h) $(block_h) \
$(dummy_frame_h) $(frame_h) $(frame_base_h) $(frame_unwind_h) \
$(inferior_h) $(gdbcmd_h) $(gdbcore_h) $(objfiles_h) $(regcache_h) \
@@ -1863,16 +1864,18 @@ i386-linux-tdep.o: i386-linux-tdep.c $(defs_h) $(gdbcore_h) $(frame_h) \
i386ly-tdep.o: i386ly-tdep.c $(defs_h) $(gdbcore_h) $(inferior_h) \
$(regcache_h) $(target_h) $(osabi_h) $(i386_tdep_h)
i386-nat.o: i386-nat.c $(defs_h) $(breakpoint_h) $(command_h) $(gdbcmd_h)
-i386nbsd-tdep.o: i386nbsd-tdep.c $(defs_h) $(arch_utils_h) $(gdbcore_h) \
- $(regcache_h) $(regset_h) $(osabi_h) $(gdb_assert_h) $(gdb_string_h) \
- $(i386_tdep_h) $(i387_tdep_h) $(nbsd_tdep_h) $(solib_svr4_h)
+i386nbsd-tdep.o: i386nbsd-tdep.c $(defs_h) $(arch_utils_h) $(frame_h) \
+ $(gdbcore_h) $(regcache_h) $(regset_h) $(osabi_h) $(symtab_h) \
+ $(gdb_assert_h) $(gdb_string_h) $(i386_tdep_h) $(i387_tdep_h) \
+ $(nbsd_tdep_h) $(solib_svr4_h)
i386-nto-tdep.o: i386-nto-tdep.c $(gdb_string_h) $(gdb_assert_h) $(defs_h) \
$(frame_h) $(target_h) $(regcache_h) $(solib_svr4_h) $(i386_tdep_h) \
$(nto_tdep_h) $(osabi_h) $(i387_tdep_h)
i386obsd-nat.o: i386obsd-nat.c $(defs_h) $(i386_tdep_h)
-i386obsd-tdep.o: i386obsd-tdep.c $(defs_h) $(arch_utils_h) $(gdbcore_h) \
- $(regcache_h) $(regset_h) $(osabi_h) $(target_h) $(gdb_assert_h) \
- $(gdb_string_h) $(i386_tdep_h) $(i387_tdep_h) $(solib_svr4_h)
+i386obsd-tdep.o: i386obsd-tdep.c $(defs_h) $(arch_utils_h) $(frame_h) \
+ $(gdbcore_h) $(regcache_h) $(regset_h) $(symtab_h) $(objfiles_h) \
+ $(osabi_h) $(target_h) $(gdb_assert_h) $(gdb_string_h) \
+ $(i386_tdep_h) $(i387_tdep_h) $(solib_svr4_h)
i386-sol2-tdep.o: i386-sol2-tdep.c $(defs_h) $(value_h) $(osabi_h) \
$(i386_tdep_h)
i386-stub.o: i386-stub.c
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index 843a84e..be7ace2 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -25,6 +25,7 @@
#include "gdbcore.h"
#include "regcache.h"
#include "osabi.h"
+#include "symtab.h"
#include "gdb_string.h"
@@ -116,11 +117,17 @@ amd64_linux_sigtramp_start (CORE_ADDR pc)
return pc;
}
-/* Return whether PC is in a GNU/Linux sigtramp routine. */
+/* Return whether the frame preciding NEXT_FRAME corresponds to a
+ GNU/Linux sigtramp routine. */
static int
-amd64_linux_pc_in_sigtramp (CORE_ADDR pc, char *name)
+amd64_linux_sigtramp_p (struct frame_info *next_frame)
{
+ CORE_ADDR pc = frame_pc_unwind (next_frame);
+ char *name;
+
+ find_pc_partial_function (pc, &name, NULL, NULL);
+
/* If we have NAME, we can optimize the search. The trampoline is
named __restore_rt. However, it isn't dynamically exported from
the shared C library, so the trampoline may appear to be part of
@@ -203,7 +210,7 @@ amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
amd64_init_abi (info, gdbarch);
- set_gdbarch_deprecated_pc_in_sigtramp (gdbarch, amd64_linux_pc_in_sigtramp);
+ tdep->sigtramp_p = amd64_linux_sigtramp_p;
tdep->sigcontext_addr = amd64_linux_sigcontext_addr;
tdep->sc_reg_offset = amd64_linux_sc_reg_offset;
tdep->sc_num_regs = ARRAY_SIZE (amd64_linux_sc_reg_offset);
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 1a66e45..0bec555 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -967,15 +967,26 @@ static const struct frame_unwind amd64_sigtramp_frame_unwind =
static const struct frame_unwind *
amd64_sigtramp_frame_sniffer (struct frame_info *next_frame)
{
- CORE_ADDR pc = frame_pc_unwind (next_frame);
- char *name;
+ struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (next_frame));
+
+ /* We shouldn't even bother if we don't have a sigcontext_addr
+ handler. */
+ if (tdep->sigcontext_addr == NULL)
+ return NULL;
+
+ if (tdep->sigtramp_p != NULL)
+ {
+ if (tdep->sigtramp_p (next_frame))
+ return &amd64_sigtramp_frame_unwind;
+ }
- find_pc_partial_function (pc, &name, NULL, NULL);
- if (DEPRECATED_PC_IN_SIGTRAMP (pc, name))
+ if (tdep->sigtramp_start != 0)
{
- gdb_assert (gdbarch_tdep (current_gdbarch)->sigcontext_addr);
+ CORE_ADDR pc = frame_pc_unwind (next_frame);
- return &amd64_sigtramp_frame_unwind;
+ gdb_assert (tdep->sigtramp_end != 0);
+ if (pc >= tdep->sigtramp_start && pc < tdep->sigtramp_end)
+ return &amd64_sigtramp_frame_unwind;
}
return NULL;
diff --git a/gdb/amd64nbsd-tdep.c b/gdb/amd64nbsd-tdep.c
index cb413f0..14f5052 100644
--- a/gdb/amd64nbsd-tdep.c
+++ b/gdb/amd64nbsd-tdep.c
@@ -24,6 +24,7 @@
#include "frame.h"
#include "gdbcore.h"
#include "osabi.h"
+#include "symtab.h"
#include "gdb_assert.h"
@@ -33,6 +34,19 @@
/* Support for signal handlers. */
+/* Return whether the frame preciding NEXT_FRAME corresponds to a
+ NetBSD sigtramp routine. */
+
+static int
+amd64nbsd_sigtramp_p (struct frame_info *next_frame)
+{
+ CORE_ADDR pc = frame_pc_unwind (next_frame);
+ char *name;
+
+ find_pc_partial_function (pc, &name, NULL, NULL);
+ return nbsd_pc_in_sigtramp (pc, name);
+}
+
/* Assuming NEXT_FRAME is for a frame following a BSD sigtramp
routine, return the address of the associated sigcontext structure. */
@@ -98,7 +112,7 @@ amd64nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->jb_pc_offset = 7 * 8;
/* NetBSD has its own convention for signal trampolines. */
- set_gdbarch_deprecated_pc_in_sigtramp (gdbarch, nbsd_pc_in_sigtramp);
+ tdep->sigtramp_p = amd64nbsd_sigtramp_p;
tdep->sigcontext_addr = amd64nbsd_sigcontext_addr;
/* Initialize the array with register offsets in `struct
diff --git a/gdb/amd64obsd-tdep.c b/gdb/amd64obsd-tdep.c
index 70a9da8..5ab1a47 100644
--- a/gdb/amd64obsd-tdep.c
+++ b/gdb/amd64obsd-tdep.c
@@ -22,6 +22,8 @@
#include "defs.h"
#include "frame.h"
#include "gdbcore.h"
+#include "symtab.h"
+#include "objfiles.h"
#include "osabi.h"
#include "regset.h"
#include "target.h"
@@ -75,11 +77,16 @@ amd64obsd_regset_from_core_section (struct gdbarch *gdbarch,
/* Support for signal handlers. */
+/* Default page size. */
static const int amd64obsd_page_size = 4096;
+/* Return whether the frame preciding NEXT_FRAME corresponds to an
+ OpenBSD sigtramp routine. */
+
static int
-amd64obsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
+amd64obsd_sigtramp_p (struct frame_info *next_frame)
{
+ CORE_ADDR pc = frame_pc_unwind (next_frame);
CORE_ADDR start_pc = (pc & ~(amd64obsd_page_size - 1));
const char sigreturn[] =
{
@@ -87,9 +94,17 @@ amd64obsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
0x67, 0x00, 0x00, 0x00, /* movq $SYS_sigreturn, %rax */
0xcd, 0x80 /* int $0x80 */
};
- char *buf;
+ char *name, *buf;
+
+ /* If the function has a valid symbol name, it isn't a
+ trampoline. */
+ find_pc_partial_function (pc, &name, NULL, NULL);
+ if (name != NULL)
+ return 0;
- if (name)
+ /* If the function lives in a valid section (even without a starting
+ point) it isn't a trampoline. */
+ if (find_pc_section (pc) != NULL)
return 0;
/* If we can't read the instructions at START_PC, return zero. */
@@ -195,7 +210,7 @@ amd64obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->jb_pc_offset = 7 * 8;
- set_gdbarch_deprecated_pc_in_sigtramp (gdbarch, amd64obsd_pc_in_sigtramp);
+ tdep->sigtramp_p = amd64obsd_sigtramp_p;
tdep->sigcontext_addr = amd64obsd_sigcontext_addr;
tdep->sc_reg_offset = amd64obsd_sc_reg_offset;
tdep->sc_num_regs = ARRAY_SIZE (amd64obsd_sc_reg_offset);
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index e177d59..2e02e9f 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -83,13 +83,13 @@ i386_linux_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
Checking for the code sequence should be somewhat reliable, because
the effect is to call the system call sigreturn. This is unlikely
- to occur anywhere other than a signal trampoline.
+ to occur anywhere other than in a signal trampoline.
It kind of sucks that we have to read memory from the process in
order to identify a signal trampoline, but there doesn't seem to be
- any other way. The DEPRECATED_PC_IN_SIGTRAMP macro in tm-linux.h
- arranges to only call us if no function name could be identified,
- which should be the case since the code is on the stack.
+ any other way. Therefore we only do the memory reads if no
+ function name could be identified, which should be the case since
+ the code is on the stack.
Detection of signal trampolines for handlers that set the
SA_RESTORER flag is in general not possible. Unfortunately this is
@@ -217,11 +217,17 @@ i386_linux_rt_sigtramp_start (CORE_ADDR pc)
return pc;
}
-/* Return whether PC is in a GNU/Linux sigtramp routine. */
+/* Return whether the frame preciding NEXT_FRAME corresponds to a
+ GNU/Linux sigtramp routine. */
static int
-i386_linux_pc_in_sigtramp (CORE_ADDR pc, char *name)
+i386_linux_sigtramp_p (struct frame_info *next_frame)
{
+ CORE_ADDR pc = frame_pc_unwind (next_frame);
+ char *name;
+
+ find_pc_partial_function (pc, &name, NULL, NULL);
+
/* If we have NAME, we can optimize the search. The trampolines are
named __restore and __restore_rt. However, they aren't dynamically
exported from the shared C library, so the trampoline may appear to
@@ -394,16 +400,11 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->jb_pc_offset = 20; /* From <bits/setjmp.h>. */
+ tdep->sigtramp_p = i386_linux_sigtramp_p;
tdep->sigcontext_addr = i386_linux_sigcontext_addr;
tdep->sc_reg_offset = i386_linux_sc_reg_offset;
tdep->sc_num_regs = ARRAY_SIZE (i386_linux_sc_reg_offset);
- /* When the i386 Linux kernel calls a signal handler, the return
- address points to a bit of code on the stack. This function is
- used to identify this bit of code as a signal trampoline in order
- to support backtracing through calls to signal handlers. */
- set_gdbarch_deprecated_pc_in_sigtramp (gdbarch, i386_linux_pc_in_sigtramp);
-
/* GNU/Linux uses SVR4-style shared libraries. */
set_solib_svr4_fetch_link_map_offsets
(gdbarch, svr4_ilp32_fetch_link_map_offsets);
diff --git a/gdb/i386-nto-tdep.c b/gdb/i386-nto-tdep.c
index 69a945e..8538db7 100644
--- a/gdb/i386-nto-tdep.c
+++ b/gdb/i386-nto-tdep.c
@@ -1,6 +1,6 @@
-/* i386-nto-tdep.c - i386 specific functionality for QNX Neutrino.
+/* Target-dependent code for QNX Neutrino x86.
- Copyright 2003 Free Software Foundation, Inc.
+ Copyright 2003, 2004 Free Software Foundation, Inc.
Contributed by QNX Software Systems Ltd.
@@ -225,9 +225,16 @@ i386nto_svr4_fetch_link_map_offsets (void)
return lmp;
}
+/* Return whether the frame preceding NEXT_FRAME corresponds to a QNX
+ Neutrino sigtramp routine. */
+
static int
-i386nto_pc_in_sigtramp (CORE_ADDR pc, char *name)
+i386nto_sigtramp_p (struct frame_info *next_frame)
{
+ CORE_ADDR pc = frame_pc_unwind (next_frame);
+ char *name;
+
+ find_pc_partial_function (pc, &name, NULL, NULL);
return name && strcmp ("__signalstub", name) == 0;
}
@@ -242,7 +249,7 @@ i386nto_sigcontext_addr (struct frame_info *next_frame)
char buf[4];
CORE_ADDR sp;
- frame_unwind_register (next_frame, SP_REGNUM, buf);
+ frame_unwind_register (next_frame, I386_ESP_REGNUM, buf);
sp = extract_unsigned_integer (buf, 4);
return sp + I386_NTO_SIGCONTEXT_OFFSET;
@@ -278,7 +285,7 @@ i386nto_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_in_solib_call_trampoline (gdbarch, in_plt_section);
set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
- set_gdbarch_deprecated_pc_in_sigtramp (gdbarch, i386nto_pc_in_sigtramp);
+ tdep->sigtramp_p = i386nto_sigtramp_p;
tdep->sigcontext_addr = i386nto_sigcontext_addr;
tdep->sc_pc_offset = 56;
tdep->sc_sp_offset = 68;
diff --git a/gdb/i386-sol2-tdep.c b/gdb/i386-sol2-tdep.c
index 96cd10d..e261d56 100644
--- a/gdb/i386-sol2-tdep.c
+++ b/gdb/i386-sol2-tdep.c
@@ -1,5 +1,6 @@
/* Target-dependent code for Solaris x86.
- Copyright 2002, 2003 Free Software Foundation, Inc.
+
+ Copyright 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GDB.
@@ -46,8 +47,10 @@ static int i386_sol2_gregset_reg_offset[] =
};
static int
-i386_sol2_pc_in_sigtramp (CORE_ADDR pc, char *name)
+i386_sol2_sigtramp_p (struct frame_info *next_frame)
{
+ CORE_ADDR pc = frame_pc_unwind (next_frame);
+
/* Signal handler frames under Solaris 2 are recognized by a return
address of 0xffffffff. */
return (pc == 0xffffffff);
@@ -85,12 +88,11 @@ i386_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->sizeof_gregset = 19 * 4;
tdep->sizeof_fpregset = 380;
+ /* Signal trampolines are slightly different from SVR4. */
+ tdep->sigtramp_p = i386_sol2_sigtramp_p;
tdep->sigcontext_addr = i386_sol2_mcontext_addr;
tdep->sc_reg_offset = tdep->gregset_reg_offset;
tdep->sc_num_regs = tdep->gregset_num_regs;
-
- /* Signal trampolines are slightly different from SVR4. */
- set_gdbarch_deprecated_pc_in_sigtramp (gdbarch, i386_sol2_pc_in_sigtramp);
}
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index cfe426d..a4f6fc1 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -1051,17 +1051,27 @@ static const struct frame_unwind i386_sigtramp_frame_unwind =
static const struct frame_unwind *
i386_sigtramp_frame_sniffer (struct frame_info *next_frame)
{
- CORE_ADDR pc = frame_pc_unwind (next_frame);
- char *name;
+ struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (next_frame));
- /* We shouldn't even bother to try if the OSABI didn't register
- a sigcontext_addr handler. */
- if (!gdbarch_tdep (current_gdbarch)->sigcontext_addr)
+ /* We shouldn't even bother if we don't have a sigcontext_addr
+ handler. */
+ if (tdep->sigcontext_addr == NULL)
return NULL;
- find_pc_partial_function (pc, &name, NULL, NULL);
- if (DEPRECATED_PC_IN_SIGTRAMP (pc, name))
- return &i386_sigtramp_frame_unwind;
+ if (tdep->sigtramp_p != NULL)
+ {
+ if (tdep->sigtramp_p (next_frame))
+ return &i386_sigtramp_frame_unwind;
+ }
+
+ if (tdep->sigtramp_start != 0)
+ {
+ CORE_ADDR pc = frame_pc_unwind (next_frame);
+
+ gdb_assert (tdep->sigtramp_end != 0);
+ if (pc >= tdep->sigtramp_start && pc < tdep->sigtramp_end)
+ return &i386_sigtramp_frame_unwind;
+ }
return NULL;
}
@@ -1731,12 +1741,16 @@ i386_pe_skip_trampoline_code (CORE_ADDR pc, char *name)
}
-/* Return non-zero if PC and NAME show that we are in a signal
- trampoline. */
+/* Return whether the frame preciding NEXT_FRAME corresponds to a
+ sigtramp routine. */
static int
-i386_pc_in_sigtramp (CORE_ADDR pc, char *name)
+i386_sigtramp_p (struct frame_info *next_frame)
{
+ CORE_ADDR pc = frame_pc_unwind (next_frame);
+ char *name;
+
+ find_pc_partial_function (pc, &name, NULL, NULL);
return (name && strcmp ("_sigtramp", name) == 0);
}
@@ -1766,11 +1780,18 @@ i386_print_insn (bfd_vma pc, struct disassemble_info *info)
/* System V Release 4 (SVR4). */
+/* Return whether the frame preciding NEXT_FRAME corresponds to a SVR4
+ sigtramp routine. */
+
static int
-i386_svr4_pc_in_sigtramp (CORE_ADDR pc, char *name)
+i386_svr4_sigtramp_p (struct frame_info *next_frame)
{
+ CORE_ADDR pc = frame_pc_unwind (next_frame);
+ char *name;
+
/* UnixWare uses _sigacthandler. The origin of the other symbols is
currently unknown. */
+ find_pc_partial_function (pc, &name, NULL, NULL);
return (name && (strcmp ("_sigreturn", name) == 0
|| strcmp ("_sigacthandler", name) == 0
|| strcmp ("sigvechandler", name) == 0));
@@ -1793,16 +1814,6 @@ i386_svr4_sigcontext_addr (struct frame_info *next_frame)
}
-/* DJGPP. */
-
-static int
-i386_go32_pc_in_sigtramp (CORE_ADDR pc, char *name)
-{
- /* DJGPP doesn't have any special frames for signal handlers. */
- return 0;
-}
-
-
/* Generic ELF. */
void
@@ -1826,7 +1837,7 @@ i386_svr4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_in_solib_call_trampoline (gdbarch, in_plt_section);
set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
- set_gdbarch_deprecated_pc_in_sigtramp (gdbarch, i386_svr4_pc_in_sigtramp);
+ tdep->sigtramp_p = i386_svr4_sigtramp_p;
tdep->sigcontext_addr = i386_svr4_sigcontext_addr;
tdep->sc_pc_offset = 36 + 14 * 4;
tdep->sc_sp_offset = 36 + 17 * 4;
@@ -1841,7 +1852,8 @@ i386_go32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
- set_gdbarch_deprecated_pc_in_sigtramp (gdbarch, i386_go32_pc_in_sigtramp);
+ /* DJGPP doesn't have any special frames for signal handlers. */
+ tdep->sigtramp_p = NULL;
tdep->jb_pc_offset = 36;
}
@@ -1973,6 +1985,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
tdep->struct_return = pcc_struct_return;
tdep->sigtramp_start = 0;
tdep->sigtramp_end = 0;
+ tdep->sigtramp_p = i386_sigtramp_p;
tdep->sigcontext_addr = NULL;
tdep->sc_reg_offset = NULL;
tdep->sc_pc_offset = -1;
@@ -2034,7 +2047,6 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_decr_pc_after_break (gdbarch, 1);
set_gdbarch_frame_args_skip (gdbarch, 8);
- set_gdbarch_deprecated_pc_in_sigtramp (gdbarch, i386_pc_in_sigtramp);
/* Wire in the MMX registers. */
set_gdbarch_num_pseudo_regs (gdbarch, i386_num_mmx_regs);
diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
index 9cb8765..32ef049 100644
--- a/gdb/i386-tdep.h
+++ b/gdb/i386-tdep.h
@@ -89,6 +89,9 @@ struct gdbarch_tdep
CORE_ADDR sigtramp_start;
CORE_ADDR sigtramp_end;
+ /* Detect sigtramp. */
+ int (*sigtramp_p) (struct frame_info *);
+
/* Get address of sigcontext for sigtramp. */
CORE_ADDR (*sigcontext_addr) (struct frame_info *);
@@ -217,9 +220,6 @@ extern void i386_svr4_init_abi (struct gdbarch_info, struct gdbarch *);
/* Functions and variables exported from i386bsd-tdep.c. */
extern void i386bsd_init_abi (struct gdbarch_info, struct gdbarch *);
-extern int i386bsd_pc_in_sigtramp (CORE_ADDR pc, char *name);
-extern CORE_ADDR i386bsd_sigtramp_start (CORE_ADDR pc);
-extern CORE_ADDR i386bsd_sigtramp_end (CORE_ADDR pc);
extern CORE_ADDR i386fbsd_sigtramp_start_addr;
extern CORE_ADDR i386fbsd_sigtramp_end_addr;
extern CORE_ADDR i386obsd_sigtramp_start_addr;
diff --git a/gdb/i386bsd-tdep.c b/gdb/i386bsd-tdep.c
index d501f73..4b4bffb 100644
--- a/gdb/i386bsd-tdep.c
+++ b/gdb/i386bsd-tdep.c
@@ -32,16 +32,6 @@
/* Support for signal handlers. */
-/* Return whether PC is in a BSD sigtramp routine. */
-
-int
-i386bsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
-{
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
-
- return (pc >= tdep->sigtramp_start && pc < tdep->sigtramp_end);
-}
-
/* Assuming NEXT_FRAME is for a frame following a BSD sigtramp
routine, return the address of the associated sigcontext structure. */
@@ -56,22 +46,6 @@ i386bsd_sigcontext_addr (struct frame_info *next_frame)
return read_memory_unsigned_integer (sp + 8, 4);
}
-
-/* Return the start address of the sigtramp routine. */
-
-CORE_ADDR
-i386bsd_sigtramp_start (CORE_ADDR pc)
-{
- return gdbarch_tdep (current_gdbarch)->sigtramp_start;
-}
-
-/* Return the end address of the sigtramp routine. */
-
-CORE_ADDR
-i386bsd_sigtramp_end (CORE_ADDR pc)
-{
- return gdbarch_tdep (current_gdbarch)->sigtramp_end;
-}
/* Support for shared libraries. */
@@ -112,12 +86,6 @@ i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
- set_gdbarch_deprecated_pc_in_sigtramp (gdbarch, i386bsd_pc_in_sigtramp);
-
- /* Allow the recognition of sigtramps as a function named <sigtramp>. */
- set_gdbarch_deprecated_sigtramp_start (gdbarch, i386bsd_sigtramp_start);
- set_gdbarch_deprecated_sigtramp_end (gdbarch, i386bsd_sigtramp_end);
-
/* Assume SunOS-style shared libraries. */
set_gdbarch_in_solib_call_trampoline (gdbarch,
i386bsd_aout_in_solib_call_trampoline);
diff --git a/gdb/i386nbsd-tdep.c b/gdb/i386nbsd-tdep.c
index e1e05aa..53eb1c2 100644
--- a/gdb/i386nbsd-tdep.c
+++ b/gdb/i386nbsd-tdep.c
@@ -23,10 +23,12 @@
#include "defs.h"
#include "arch-utils.h"
+#include "frame.h"
#include "gdbcore.h"
#include "regcache.h"
#include "regset.h"
#include "osabi.h"
+#include "symtab.h"
#include "gdb_assert.h"
#include "gdb_string.h"
@@ -183,9 +185,16 @@ i386nbsd_sigtramp_offset (CORE_ADDR pc)
return -1;
}
+/* Return whether the frame preciding NEXT_FRAME corresponds to a
+ NetBSD sigtramp routine. */
+
static int
-i386nbsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
+i386nbsd_sigtramp_p (struct frame_info *next_frame)
{
+ CORE_ADDR pc = frame_pc_unwind (next_frame);
+ char *name;
+
+ find_pc_partial_function (pc, &name, NULL, NULL);
return (nbsd_pc_in_sigtramp (pc, name)
|| i386nbsd_sigtramp_offset (pc) >= 0);
}
@@ -225,12 +234,9 @@ i386nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->sizeof_gregset = 16 * 4;
/* NetBSD has different signal trampoline conventions. */
- set_gdbarch_deprecated_pc_in_sigtramp (gdbarch, i386nbsd_pc_in_sigtramp);
- /* FIXME: kettenis/20020906: We should probably provide
- NetBSD-specific versions of these functions if we want to
- recognize signal trampolines that live on the stack. */
- set_gdbarch_deprecated_sigtramp_start (gdbarch, NULL);
- set_gdbarch_deprecated_sigtramp_end (gdbarch, NULL);
+ tdep->sigtramp_start = 0;
+ tdep->sigtramp_end = 0;
+ tdep->sigtramp_p = i386nbsd_sigtramp_p;
/* NetBSD uses -freg-struct-return by default. */
tdep->struct_return = reg_struct_return;
diff --git a/gdb/i386obsd-tdep.c b/gdb/i386obsd-tdep.c
index 740bae3..17f2f5e 100644
--- a/gdb/i386obsd-tdep.c
+++ b/gdb/i386obsd-tdep.c
@@ -23,9 +23,12 @@
#include "defs.h"
#include "arch-utils.h"
+#include "frame.h"
#include "gdbcore.h"
#include "regcache.h"
#include "regset.h"
+#include "symtab.h"
+#include "objfiles.h"
#include "osabi.h"
#include "target.h"
@@ -48,11 +51,13 @@
/* Default page size. */
static const int i386obsd_page_size = 4096;
-/* Return whether PC is in an OpenBSD sigtramp routine. */
+/* Return whether the frame preciding NEXT_FRAME corresponds to an
+ OpenBSD sigtramp routine. */
static int
-i386obsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
+i386obsd_sigtramp_p (struct frame_info *next_frame)
{
+ CORE_ADDR pc = frame_pc_unwind (next_frame);
CORE_ADDR start_pc = (pc & ~(i386obsd_page_size - 1));
const char sigreturn[] =
{
@@ -60,13 +65,17 @@ i386obsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
0x67, 0x00, 0x00, 0x00, /* movl $SYS_sigreturn, %eax */
0xcd, 0x80 /* int $0x80 */
};
- char *buf;
+ char *name, *buf;
- /* Avoid reading memory from the target if possible. If we're in a
- named function, we're certainly not in a sigtramp routine
- provided by the kernel. Take synthetic function names into
- account though. */
- if (name && name[0] != '<')
+ /* If the function has a valid symbol name, it isn't a
+ trampoline. */
+ find_pc_partial_function (pc, &name, NULL, NULL);
+ if (name != NULL)
+ return 0;
+
+ /* If the function lives in a valid section (even without a starting
+ point) it isn't a trampoline. */
+ if (find_pc_section (pc) != NULL)
return 0;
/* If we can't read the instructions at START_PC, return zero. */
@@ -78,34 +87,7 @@ i386obsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
if (memcmp (buf, sigreturn, sizeof sigreturn) == 0)
return 1;
- /* Check for a traditional BSD sigtramp routine. */
- return i386bsd_pc_in_sigtramp (pc, name);
-}
-
-/* Return the start address of the sigtramp routine. */
-
-static CORE_ADDR
-i386obsd_sigtramp_start (CORE_ADDR pc)
-{
- CORE_ADDR start_pc = (pc & ~(i386obsd_page_size - 1));
-
- if (i386bsd_pc_in_sigtramp (pc, NULL))
- return i386bsd_sigtramp_start (pc);
-
- return start_pc;
-}
-
-/* Return the end address of the sigtramp routine. */
-
-static CORE_ADDR
-i386obsd_sigtramp_end (CORE_ADDR pc)
-{
- CORE_ADDR start_pc = (pc & ~(i386obsd_page_size - 1));
-
- if (i386bsd_pc_in_sigtramp (pc, NULL))
- return i386bsd_sigtramp_end (pc);
-
- return start_pc + 0x22;
+ return 0;
}
/* Mapping between the general-purpose registers in `struct reg'
@@ -215,9 +197,7 @@ i386obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* OpenBSD uses a different memory layout. */
tdep->sigtramp_start = i386obsd_sigtramp_start_addr;
tdep->sigtramp_end = i386obsd_sigtramp_end_addr;
- set_gdbarch_deprecated_pc_in_sigtramp (gdbarch, i386obsd_pc_in_sigtramp);
- set_gdbarch_deprecated_sigtramp_start (gdbarch, i386obsd_sigtramp_start);
- set_gdbarch_deprecated_sigtramp_end (gdbarch, i386obsd_sigtramp_end);
+ tdep->sigtramp_p = i386obsd_sigtramp_p;
/* OpenBSD has a `struct sigcontext' that's different from the
original 4.3 BSD. */