diff options
author | Pedro Alves <pedro@codesourcery.com> | 2011-03-18 18:52:28 +0000 |
---|---|---|
committer | Pedro Alves <pedro@codesourcery.com> | 2011-03-18 18:52:28 +0000 |
commit | e67dca4a095f4db1022fd0753ef0bda3873dc1bc (patch) | |
tree | 61bd548a5fcdc0100d20772179202cb426e8e6ff /gdb/dwarf2-frame.c | |
parent | 661cfd57e3fe0db53f638ef5a2defcfa07657788 (diff) | |
download | gdb-e67dca4a095f4db1022fd0753ef0bda3873dc1bc.tar.gz |
gdb/
* frame.c (frame_unwind_register): Throw an error if unwinding the
register failed.
* get_prev_frame_1 (get_prev_frame_1): Ask the unwinder if there's
an unwind stop reason.
(frame_stop_reason_string): Handle UNWIND_UNAVAILABLE.
* frame.h (enum unwind_stop_reason) <UNWIND_OUTERMOST,
UNWIND_UNAVAILABLE>: New.
* inline-frame.c (inline_frame_unwind): Install
default_frame_unwind_stop_reason.
* frame-unwind.c: Include "exceptions.h".
(frame_unwind_find_by_frame): Swallow NOT_AVAILABLE_ERROR errors.
(default_frame_unwind_stop_reason): New.
* frame-unwind.h (frame_unwind_stop_reason_ftype): New typedef.
(default_frame_unwind_stop_reason): Declare.
(struct frame_unwind) <stop_reason>: New function pointer.
* dummy-frame.c: Install default_frame_unwind_stop_reason.
* dwarf2-frame.c: Include exceptions.h.
(struct dwarf2_frame_cache) <unavailable_retaddr>: New field.
(dwarf2_frame_cache): Swallow NOT_AVAILABLE_ERROR errors when
computing the CFA. If such an error was thrown, set
unavailable_retaddr.
(dwarf2_frame_unwind_stop_reason): New.
(dwarf2_frame_this_id): Don't build a frame id if the CFA was
unavailable.
(dwarf2_frame_unwind): Install dwarf2_frame_unwind_stop_reason.
(dwarf2_signal_frame_unwind): Ditto.
* amd64-tdep.c: Include "exceptions.h".
(struct amd64_frame_cache): New field "base_p".
(amd64_init_frame_cache): Clear it.
(amd64_frame_cache_1): New, factored out from amd64_frame_cache.
Avoid reading registers with functions that throw if the register
is not necessary to compute the frame base.
(amd64_frame_cache): Reimplement wrapping amd64_frame_cache_1, and
swallowing NOT_AVAILABLE_ERROR.
(amd64_frame_unwind_stop_reason): New.
(amd64_frame_this_id): Don't build a frame id if the frame base
was unavailable.
(amd64_frame_unwind): Install amd64_frame_unwind_stop_reason.
(amd64_sigtramp_frame_cache): Swallow NOT_AVAILABLE_ERROR, and set
base_p if the frame base was computable.
(amd64_sigtramp_frame_unwind_stop_reason): New.
(amd64_sigtramp_frame_this_id): Don't build a frame id if the
frame base was unavailable.
(amd64_sigtramp_frame_unwind): Install
amd64_sigtramp_frame_unwind_stop_reason.
(amd64_epilogue_frame_cache): Swallow NOT_AVAILABLE_ERROR, and set
base_p if the frame base was computable.
(amd64_epilogue_frame_unwind_stop_reason): New.
(amd64_epilogue_frame_this_id): Don't build a frame id if the
frame base was unavailable.
(amd64_epilogue_frame_unwind): Install
amd64_epilogue_frame_unwind_stop_reason.
* i386-tdep.c: Include "exceptions.h".
(struct i386_frame_cache): New field "base_p".
(i386_init_frame_cache): Clear it.
(i386_frame_cache_1): New, factored out from amd64_frame_cache.
Avoid reading registers with functions that throw if the register
is not necessary to compute the frame base.
(i386_frame_cache): Reimplement wrapping amd64_frame_cache_1, and
swallowing NOT_AVAILABLE_ERROR.
(i386_frame_unwind_stop_reason): New.
(i386_frame_this_id): Don't build a frame id if the frame base was
unavailable.
(i386_frame_prev_register): Handle unavailable SP.
(i386_frame_unwind): Install i386_frame_unwind_stop_reason.
(i386_epilogue_frame_cache): Swallow NOT_AVAILABLE_ERROR, and set
base_p if the frame base was computable.
(i386_epilogue_frame_unwind_stop_reason): New.
(i386_epilogue_frame_this_id): Don't build a frame id if the frame
base was unavailable.
(i386_epilogue_frame_unwind): Install
i386_epilogue_frame_unwind_stop_reason.
(i386_sigtramp_frame_cache): Swallow NOT_AVAILABLE_ERROR, and set
base_p if the frame base was computable.
(i386_sigtramp_frame_unwind_stop_reason): New.
(i386_sigtramp_frame_this_id): Don't build a frame id if the frame
base was unavailable.
(i386_sigtramp_frame_unwind): Install
i386_sigtramp_frame_unwind_stop_reason.
* sentinel-frame.c (sentinel_frame_prev_register): Use the value
type's size, not the register's.
(sentinel_frame_unwind): Install default_frame_unwind_stop_reason.
* alpha-mdebug-tdep.c (alpha_mdebug_frame_unwind): Install
default_frame_unwind_stop_reason.
* alpha-tdep.c (alpha_sigtramp_frame_unwind)
(alpha_heuristic_frame_unwind): Ditto.
* amd64obsd-tdep.c (amd64obsd_trapframe_unwind): Ditto.
* arm-tdep.c (arm_prologue_unwind, arm_stub_unwind): Ditto.
* avr-tdep.c (avr_frame_unwind): Ditto.
* cris-tdep.c (cris_sigtramp_frame_unwind, cris_frame_unwind):
Ditto.
* frv-linux-tdep.c (frv_linux_sigtramp_frame_unwind): Ditto.
* frv-tdep.c (frv_frame_unwind): Ditto.
* h8300-tdep.c (h8300_frame_unwind): Ditto.
* hppa-hpux-tdep.c (hppa_hpux_sigtramp_frame_unwind): Ditto.
* hppa-linux-tdep.c (hppa_linux_sigtramp_frame_unwind): Ditto.
* hppa-tdep.c (hppa_frame_unwind, hppa_fallback_frame_unwind)
(hppa_stub_frame_unwind): Ditto.
* i386obsd-tdep.c (i386obsd_trapframe_unwind): Ditto.
* ia64-tdep.c (ia64_frame_unwind, ia64_sigtramp_frame_unwind)
(ia64_libunwind_frame_unwind)
(ia64_libunwind_sigtramp_frame_unwind): Ditto.
* iq2000-tdep.c (iq2000_frame_unwind): Ditto.
* lm32-tdep.c (lm32_frame_unwind): Ditto.
* m32c-tdep.c (m32c_unwind): Ditto.
* m32r-linux-tdep.c (m32r_linux_sigtramp_frame_unwind): Ditto.
* m32r-tdep.c (m32r_frame_unwind): Ditto.
* m68hc11-tdep.c (m68hc11_frame_unwind): Ditto.
* m68k-tdep.c (m68k_frame_unwind): Ditto.
* m68klinux-tdep.c (m68k_linux_sigtramp_frame_unwind): Ditto.
* m88k-tdep.c (m88k_frame_unwind): Ditto.
* mep-tdep.c (mep_frame_unwind): Ditto.
* microblaze-tdep.c (microblaze_frame_unwind): Ditto.
* mips-tdep.c (mips_insn16_frame_unwind, mips_insn32_frame_unwind)
(mips_stub_frame_unwind): Ditto.
* mn10300-tdep.c (mn10300_frame_unwind): Ditto.
* moxie-tdep.c (moxie_frame_unwind): Ditto.
* mt-tdep.c (mt_frame_unwind): Ditto.
* ppc-linux-tdep.c (ppu2spu_unwind): Ditto.
* ppcobsd-tdep.c (ppcobsd_sigtramp_frame_unwind): Ditto.
* rs6000-tdep.c (rs6000_frame_unwind): Ditto.
* s390-tdep.c (s390_frame_unwind, s390_stub_frame_unwind)
(s390_sigtramp_frame_unwind): Ditto.
* score-tdep.c (score_prologue_unwind): Ditto.
* sh-tdep.c (sh_frame_unwind): Ditto.
* sh64-tdep.c (sh64_frame_unwind): Ditto.
* sparc-sol2-tdep.c (sparc32_sol2_sigtramp_frame_unwind): Ditto.
* sparc-tdep.c (sparc32_frame_unwind): Ditto.
* sparc64-sol2-tdep.c (sparc64_sol2_sigtramp_frame_unwind): Ditto.
* sparc64-tdep.c (sparc64_frame_unwind): Ditto.
* sparc64fbsd-tdep.c (sparc64fbsd_sigtramp_frame_unwind): Ditto.
* sparc64nbsd-tdep.c (sparc64nbsd_sigcontext_frame_unwind): Ditto.
* sparc64obsd-tdep.c (sparc64obsd_frame_unwind)
(sparc64obsd_trapframe_unwind): Ditto.
* sparcnbsd-tdep.c (sparc32nbsd_sigcontext_frame_unwind): Ditto.
* sparcobsd-tdep.c (sparc32obsd_sigtramp_frame_unwind): Ditto.
* spu-tdep.c (spu_frame_unwind, spu2ppu_unwind): Ditto.
* v850-tdep.c (v850_frame_unwind): Ditto.
* vax-tdep.c (vax_frame_unwind): Ditto.
* vaxobsd-tdep.c (vaxobsd_sigtramp_frame_unwind): Ditto.
* xstormy16-tdep.c (frame_unwind xstormy16_frame_unwind): Ditto.
* xtensa-tdep.c (xtensa_unwind): Ditto.
Diffstat (limited to 'gdb/dwarf2-frame.c')
-rw-r--r-- | gdb/dwarf2-frame.c | 81 |
1 files changed, 60 insertions, 21 deletions
diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c index edd6a9c5267..e78c3284ade 100644 --- a/gdb/dwarf2-frame.c +++ b/gdb/dwarf2-frame.c @@ -40,6 +40,7 @@ #include "dwarf2-frame.h" #include "ax.h" #include "dwarf2loc.h" +#include "exceptions.h" struct comp_unit; @@ -986,6 +987,10 @@ struct dwarf2_frame_cache /* DWARF Call Frame Address. */ CORE_ADDR cfa; + /* Set if the return address column was marked as unavailable + (required non-collected memory or registers to compute). */ + int unavailable_retaddr; + /* Set if the return address column was marked as undefined. */ int undefined_retaddr; @@ -1013,6 +1018,7 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache) struct dwarf2_frame_cache *cache; struct dwarf2_frame_state *fs; struct dwarf2_fde *fde; + volatile struct gdb_exception ex; if (*this_cache) return *this_cache; @@ -1020,10 +1026,10 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache) /* Allocate a new cache. */ cache = FRAME_OBSTACK_ZALLOC (struct dwarf2_frame_cache); cache->reg = FRAME_OBSTACK_CALLOC (num_regs, struct dwarf2_frame_state_reg); + *this_cache = cache; /* Allocate and initialize the frame state. */ - fs = XMALLOC (struct dwarf2_frame_state); - memset (fs, 0, sizeof (struct dwarf2_frame_state)); + fs = XZALLOC (struct dwarf2_frame_state); old_chain = make_cleanup (dwarf2_frame_state_free, fs); /* Unwind the PC. @@ -1068,26 +1074,39 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache) execute_cfa_program (fde, fde->instructions, fde->end, gdbarch, get_frame_pc (this_frame), fs); - /* Calculate the CFA. */ - switch (fs->regs.cfa_how) + TRY_CATCH (ex, RETURN_MASK_ERROR) { - case CFA_REG_OFFSET: - cache->cfa = read_reg (this_frame, fs->regs.cfa_reg); - if (fs->armcc_cfa_offsets_reversed) - cache->cfa -= fs->regs.cfa_offset; - else - cache->cfa += fs->regs.cfa_offset; - break; - - case CFA_EXP: - cache->cfa = - execute_stack_op (fs->regs.cfa_exp, fs->regs.cfa_exp_len, - cache->addr_size, cache->text_offset, - this_frame, 0, 0); - break; + /* Calculate the CFA. */ + switch (fs->regs.cfa_how) + { + case CFA_REG_OFFSET: + cache->cfa = read_reg (this_frame, fs->regs.cfa_reg); + if (fs->armcc_cfa_offsets_reversed) + cache->cfa -= fs->regs.cfa_offset; + else + cache->cfa += fs->regs.cfa_offset; + break; + + case CFA_EXP: + cache->cfa = + execute_stack_op (fs->regs.cfa_exp, fs->regs.cfa_exp_len, + cache->addr_size, cache->text_offset, + this_frame, 0, 0); + break; + + default: + internal_error (__FILE__, __LINE__, _("Unknown CFA rule.")); + } + } + if (ex.reason < 0) + { + if (ex.error == NOT_AVAILABLE_ERROR) + { + cache->unavailable_retaddr = 1; + return cache; + } - default: - internal_error (__FILE__, __LINE__, _("Unknown CFA rule.")); + throw_exception (ex); } /* Initialize the register state. */ @@ -1193,10 +1212,25 @@ incomplete CFI data; unspecified registers (e.g., %s) at %s"), do_cleanups (old_chain); - *this_cache = cache; return cache; } +static enum unwind_stop_reason +dwarf2_frame_unwind_stop_reason (struct frame_info *this_frame, + void **this_cache) +{ + struct dwarf2_frame_cache *cache + = dwarf2_frame_cache (this_frame, this_cache); + + if (cache->unavailable_retaddr) + return UNWIND_UNAVAILABLE; + + if (cache->undefined_retaddr) + return UNWIND_OUTERMOST; + + return UNWIND_NO_REASON; +} + static void dwarf2_frame_this_id (struct frame_info *this_frame, void **this_cache, struct frame_id *this_id) @@ -1204,6 +1238,9 @@ dwarf2_frame_this_id (struct frame_info *this_frame, void **this_cache, struct dwarf2_frame_cache *cache = dwarf2_frame_cache (this_frame, this_cache); + if (cache->unavailable_retaddr) + return; + if (cache->undefined_retaddr) return; @@ -1321,6 +1358,7 @@ dwarf2_frame_sniffer (const struct frame_unwind *self, static const struct frame_unwind dwarf2_frame_unwind = { NORMAL_FRAME, + dwarf2_frame_unwind_stop_reason, dwarf2_frame_this_id, dwarf2_frame_prev_register, NULL, @@ -1330,6 +1368,7 @@ static const struct frame_unwind dwarf2_frame_unwind = static const struct frame_unwind dwarf2_signal_frame_unwind = { SIGTRAMP_FRAME, + dwarf2_frame_unwind_stop_reason, dwarf2_frame_this_id, dwarf2_frame_prev_register, NULL, |