summaryrefslogtreecommitdiff
path: root/gdb/s390-tdep.c
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2004-03-22 22:33:33 +0000
committerAndrew Cagney <cagney@redhat.com>2004-03-22 22:33:33 +0000
commit2922cdf905ab9ac73f05358d28f0f333c64f5633 (patch)
tree05296f41994ddbae405d11b883cb93530820b0c1 /gdb/s390-tdep.c
parent7ac99afb834036059d9fbf06ea7acda65e007875 (diff)
downloadgdb-2922cdf905ab9ac73f05358d28f0f333c64f5633.tar.gz
2004-03-22 Andrew Cagney <cagney@redhat.com>
* s390-tdep.c (struct s390_stub_unwind_cache): Rename s390_pltstub_unwind_cache. (s390_stub_frame_unwind_cache): Rename s390_pltstub_frame_unwind_cache. (s390_stub_frame_this_id): Rename s390_pltstub_frame_this_id. (s390_stub_frame_prev_register): Rename s390_pltstub_frame_prev_register. (s390_stub_frame_unwind): Rename s390_pltstub_frame_unwind. (s390_stub_frame_sniffer): Rename s390_stub_frame_sniffer. From Ulrich Weigand: * s390-tdep.c (s390_pltstub_frame_sniffer): Handle invalid function pointer calls like PLT calls.
Diffstat (limited to 'gdb/s390-tdep.c')
-rw-r--r--gdb/s390-tdep.c68
1 files changed, 38 insertions, 30 deletions
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index 7e3463e1fb2..0f8f65d2f76 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -2037,27 +2037,29 @@ s390_frame_sniffer (struct frame_info *next_frame)
}
-/* PLT stub stack frames. */
-
-struct s390_pltstub_unwind_cache {
+/* Code stubs and their stack frames. For things like PLTs and NULL
+ function calls (where there is no true frame and the return address
+ is in the RETADDR register). */
+struct s390_stub_unwind_cache
+{
CORE_ADDR frame_base;
struct trad_frame_saved_reg *saved_regs;
};
-static struct s390_pltstub_unwind_cache *
-s390_pltstub_frame_unwind_cache (struct frame_info *next_frame,
- void **this_prologue_cache)
+static struct s390_stub_unwind_cache *
+s390_stub_frame_unwind_cache (struct frame_info *next_frame,
+ void **this_prologue_cache)
{
struct gdbarch *gdbarch = get_frame_arch (next_frame);
int word_size = gdbarch_ptr_bit (gdbarch) / 8;
- struct s390_pltstub_unwind_cache *info;
+ struct s390_stub_unwind_cache *info;
ULONGEST reg;
if (*this_prologue_cache)
return *this_prologue_cache;
- info = FRAME_OBSTACK_ZALLOC (struct s390_pltstub_unwind_cache);
+ info = FRAME_OBSTACK_ZALLOC (struct s390_stub_unwind_cache);
*this_prologue_cache = info;
info->saved_regs = trad_frame_alloc_saved_regs (next_frame);
@@ -2072,41 +2074,47 @@ s390_pltstub_frame_unwind_cache (struct frame_info *next_frame,
}
static void
-s390_pltstub_frame_this_id (struct frame_info *next_frame,
- void **this_prologue_cache,
- struct frame_id *this_id)
+s390_stub_frame_this_id (struct frame_info *next_frame,
+ void **this_prologue_cache,
+ struct frame_id *this_id)
{
- struct s390_pltstub_unwind_cache *info
- = s390_pltstub_frame_unwind_cache (next_frame, this_prologue_cache);
+ struct s390_stub_unwind_cache *info
+ = s390_stub_frame_unwind_cache (next_frame, this_prologue_cache);
*this_id = frame_id_build (info->frame_base, frame_pc_unwind (next_frame));
}
static void
-s390_pltstub_frame_prev_register (struct frame_info *next_frame,
- void **this_prologue_cache,
- int regnum, int *optimizedp,
- enum lval_type *lvalp, CORE_ADDR *addrp,
- int *realnump, void *bufferp)
-{
- struct s390_pltstub_unwind_cache *info
- = s390_pltstub_frame_unwind_cache (next_frame, this_prologue_cache);
+s390_stub_frame_prev_register (struct frame_info *next_frame,
+ void **this_prologue_cache,
+ int regnum, int *optimizedp,
+ enum lval_type *lvalp, CORE_ADDR *addrp,
+ int *realnump, void *bufferp)
+{
+ struct s390_stub_unwind_cache *info
+ = s390_stub_frame_unwind_cache (next_frame, this_prologue_cache);
trad_frame_prev_register (next_frame, info->saved_regs, regnum,
optimizedp, lvalp, addrp, realnump, bufferp);
}
-static const struct frame_unwind s390_pltstub_frame_unwind = {
+static const struct frame_unwind s390_stub_frame_unwind = {
NORMAL_FRAME,
- s390_pltstub_frame_this_id,
- s390_pltstub_frame_prev_register
+ s390_stub_frame_this_id,
+ s390_stub_frame_prev_register
};
static const struct frame_unwind *
-s390_pltstub_frame_sniffer (struct frame_info *next_frame)
+s390_stub_frame_sniffer (struct frame_info *next_frame)
{
- if (!in_plt_section (frame_pc_unwind (next_frame), NULL))
- return NULL;
-
- return &s390_pltstub_frame_unwind;
+ CORE_ADDR pc = frame_pc_unwind (next_frame);
+ bfd_byte insn[S390_MAX_INSTR_SIZE];
+
+ /* If the current PC points to non-readable memory, we assume we
+ have trapped due to an invalid function pointer call. We handle
+ the non-existing current function like a PLT stub. */
+ if (in_plt_section (pc, NULL)
+ || s390_readinstruction (insn, pc) < 0)
+ return &s390_stub_frame_unwind;
+ return NULL;
}
@@ -3028,7 +3036,7 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
dwarf2_frame_set_init_reg (gdbarch, s390_dwarf2_frame_init_reg);
frame_unwind_append_sniffer (gdbarch, dwarf2_frame_sniffer);
frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer);
- frame_unwind_append_sniffer (gdbarch, s390_pltstub_frame_sniffer);
+ frame_unwind_append_sniffer (gdbarch, s390_stub_frame_sniffer);
frame_unwind_append_sniffer (gdbarch, s390_sigtramp_frame_sniffer);
frame_unwind_append_sniffer (gdbarch, s390_frame_sniffer);
frame_base_set_default (gdbarch, &s390_frame_base);