|
|
078093a |
2005-09-27 Jeff Johnston <jjohnstn@redhat.com>
|
|
|
078093a |
|
|
|
078093a |
* libunwind-frame.c (libunwind_frame_cache): Save the current
|
|
|
078093a |
stack pointer in the cache.
|
|
|
078093a |
(libunwind_sigtramp_frame_this_id): New function.
|
|
|
078093a |
(libunwind_sigtramp_frame_unwind): New unwinder.
|
|
|
078093a |
(libunwind_sigtramp_frame_sniffer): Return
|
|
|
078093a |
libunwind_sigtramp_frame_unwind address.
|
|
|
078093a |
* libunwind-frame.h (libunwind_sigtramp_frame_this_id): New
|
|
|
078093a |
prototype.
|
|
|
078093a |
* ia64-tdep.c (ia64_libunwind_sigtramp_frame_this_id): Calculate
|
|
|
078093a |
the base address using the current stack pointer plus a fixed
|
|
|
078093a |
offset.
|
|
|
078093a |
|
|
|
9231e41 |
Index: gdb-6.5/gdb/libunwind-frame.c
|
|
|
9231e41 |
===================================================================
|
|
|
9231e41 |
--- gdb-6.5.orig/gdb/libunwind-frame.c 2006-07-07 03:04:32.000000000 -0300
|
|
|
9231e41 |
+++ gdb-6.5/gdb/libunwind-frame.c 2006-07-07 03:07:33.000000000 -0300
|
|
|
078093a |
@@ -62,6 +62,7 @@ static unw_word_t (*unw_find_dyn_list_p)
|
|
|
078093a |
struct libunwind_frame_cache
|
|
|
078093a |
{
|
|
|
078093a |
CORE_ADDR base;
|
|
|
078093a |
+ CORE_ADDR sp;
|
|
|
078093a |
CORE_ADDR func_addr;
|
|
|
078093a |
unw_cursor_t cursor;
|
|
|
078093a |
};
|
|
|
078093a |
@@ -131,7 +132,7 @@ libunwind_frame_cache (struct frame_info
|
|
|
078093a |
unw_accessors_t *acc;
|
|
|
078093a |
unw_addr_space_t as;
|
|
|
078093a |
unw_cursor_t *cursor_addr;
|
|
|
078093a |
- unw_word_t fp;
|
|
|
078093a |
+ unw_word_t fp, sp;
|
|
|
078093a |
unw_regnum_t uw_sp_regnum;
|
|
|
078093a |
struct libunwind_frame_cache *cache;
|
|
|
078093a |
struct libunwind_descr *descr;
|
|
|
078093a |
@@ -176,15 +177,28 @@ libunwind_frame_cache (struct frame_info
|
|
|
078093a |
else /* make copy */
|
|
|
078093a |
cache->cursor = *cursor_addr;
|
|
|
078093a |
|
|
|
078093a |
+ /* For the base address, we have a small problem. The majority
|
|
|
078093a |
+ of the time, we can get the stack pointer of the previous
|
|
|
078093a |
+ frame to use as a frame pointer. In the case where we have
|
|
|
078093a |
+ a signal trampoline, the stack may change due to a sigaltstack
|
|
|
078093a |
+ being set up. In that case, the normal mechanism will give us
|
|
|
078093a |
+ an address in the regular stack which is not at the end of the
|
|
|
078093a |
+ sigaltstack as we want. To handle this, we record the stack
|
|
|
078093a |
+ address so the caller may calculate a more correct base address
|
|
|
078093a |
+ to use. */
|
|
|
078093a |
+ uw_sp_regnum = descr->gdb2uw (SP_REGNUM);
|
|
|
078093a |
+ ret = unw_get_reg_p (&cache->cursor, uw_sp_regnum, &sp);
|
|
|
078093a |
+ if (ret < 0)
|
|
|
078093a |
+ error ("Can't get libunwind sp register.");
|
|
|
078093a |
+
|
|
|
078093a |
if (unw_step_p (&cache->cursor) < 0)
|
|
|
078093a |
return NULL;
|
|
|
078093a |
|
|
|
078093a |
- /* To get base address, get sp from previous frame. */
|
|
|
078093a |
- uw_sp_regnum = descr->gdb2uw (SP_REGNUM);
|
|
|
078093a |
ret = unw_get_reg_p (&cache->cursor, uw_sp_regnum, &fp);
|
|
|
078093a |
if (ret < 0)
|
|
|
9231e41 |
error (_("Can't get libunwind sp register."));
|
|
|
078093a |
|
|
|
078093a |
+ cache->sp = (CORE_ADDR)sp;
|
|
|
078093a |
cache->base = (CORE_ADDR)fp;
|
|
|
078093a |
|
|
|
078093a |
*this_cache = cache;
|
|
|
078093a |
@@ -371,6 +385,31 @@ libunwind_search_unwind_table (void *as,
|
|
|
078093a |
di, pi, need_unwind_info, args);
|
|
|
078093a |
}
|
|
|
078093a |
|
|
|
078093a |
+void
|
|
|
078093a |
+libunwind_sigtramp_frame_this_id (struct frame_info *next_frame,
|
|
|
078093a |
+ void **this_cache,
|
|
|
078093a |
+ struct frame_id *this_id)
|
|
|
078093a |
+{
|
|
|
078093a |
+ struct libunwind_frame_cache *cache =
|
|
|
078093a |
+ libunwind_frame_cache (next_frame, this_cache);
|
|
|
078093a |
+
|
|
|
078093a |
+ /* Unlike a regular frame, we can't use the normal frame pointer
|
|
|
078093a |
+ mechanism because a sigaltstack may have been used. Instead,
|
|
|
078093a |
+ we return the current stack pointer for the caller to use
|
|
|
078093a |
+ to calculate the base address. */
|
|
|
078093a |
+ if (cache != NULL)
|
|
|
078093a |
+ (*this_id) = frame_id_build (cache->sp, cache->func_addr);
|
|
|
078093a |
+ else
|
|
|
078093a |
+ (*this_id) = null_frame_id;
|
|
|
078093a |
+}
|
|
|
078093a |
+
|
|
|
078093a |
+static const struct frame_unwind libunwind_sigtramp_frame_unwind =
|
|
|
078093a |
+{
|
|
|
078093a |
+ SIGTRAMP_FRAME,
|
|
|
078093a |
+ libunwind_sigtramp_frame_this_id,
|
|
|
078093a |
+ libunwind_frame_prev_register
|
|
|
078093a |
+};
|
|
|
078093a |
+
|
|
|
078093a |
/* Verify if we are in a sigtramp frame and we can use libunwind to unwind. */
|
|
|
078093a |
const struct frame_unwind *
|
|
|
078093a |
libunwind_sigtramp_frame_sniffer (struct frame_info *next_frame)
|
|
|
078093a |
@@ -403,7 +442,7 @@ libunwind_sigtramp_frame_sniffer (struct
|
|
|
078093a |
/* Check to see if we are in a signal frame. */
|
|
|
078093a |
ret = unw_is_signal_frame_p (&cursor);
|
|
|
078093a |
if (ret > 0)
|
|
|
078093a |
- return &libunwind_frame_unwind;
|
|
|
078093a |
+ return &libunwind_sigtramp_frame_unwind;
|
|
|
078093a |
|
|
|
078093a |
return NULL;
|
|
|
078093a |
}
|
|
|
9231e41 |
Index: gdb-6.5/gdb/libunwind-frame.h
|
|
|
9231e41 |
===================================================================
|
|
|
9231e41 |
--- gdb-6.5.orig/gdb/libunwind-frame.h 2006-07-07 02:51:32.000000000 -0300
|
|
|
9231e41 |
+++ gdb-6.5/gdb/libunwind-frame.h 2006-07-07 03:05:49.000000000 -0300
|
|
|
078093a |
@@ -49,6 +49,9 @@ void libunwind_frame_set_descr (struct g
|
|
|
078093a |
|
|
|
078093a |
void libunwind_frame_this_id (struct frame_info *next_frame, void **this_cache,
|
|
|
078093a |
struct frame_id *this_id);
|
|
|
078093a |
+void libunwind_sigtramp_frame_this_id (struct frame_info *next_frame,
|
|
|
078093a |
+ void **this_cache,
|
|
|
078093a |
+ struct frame_id *this_id);
|
|
|
078093a |
void libunwind_frame_prev_register (struct frame_info *next_frame, void **this_cache,
|
|
|
078093a |
int regnum, int *optimizedp,
|
|
|
078093a |
enum lval_type *lvalp, CORE_ADDR *addrp,
|
|
|
9231e41 |
Index: gdb-6.5/gdb/ia64-tdep.c
|
|
|
9231e41 |
===================================================================
|
|
|
9231e41 |
--- gdb-6.5.orig/gdb/ia64-tdep.c 2006-07-07 02:51:32.000000000 -0300
|
|
|
9231e41 |
+++ gdb-6.5/gdb/ia64-tdep.c 2006-07-07 03:05:49.000000000 -0300
|
|
|
9231e41 |
@@ -3031,7 +3031,7 @@ ia64_libunwind_sigtramp_frame_this_id (s
|
|
|
078093a |
struct frame_id id;
|
|
|
078093a |
CORE_ADDR prev_ip;
|
|
|
078093a |
|
|
|
078093a |
- libunwind_frame_this_id (next_frame, this_cache, &id;;
|
|
|
078093a |
+ libunwind_sigtramp_frame_this_id (next_frame, this_cache, &id;;
|
|
|
078093a |
if (frame_id_eq (id, null_frame_id))
|
|
|
078093a |
{
|
|
|
078093a |
(*this_id) = null_frame_id;
|
|
|
9231e41 |
@@ -3043,8 +3043,14 @@ ia64_libunwind_sigtramp_frame_this_id (s
|
|
|
078093a |
frame_unwind_register (next_frame, IA64_BSP_REGNUM, buf);
|
|
|
078093a |
bsp = extract_unsigned_integer (buf, 8);
|
|
|
078093a |
|
|
|
078093a |
- /* For a sigtramp frame, we don't make the check for previous ip being 0. */
|
|
|
078093a |
- (*this_id) = frame_id_build_special (id.stack_addr, id.code_addr, bsp);
|
|
|
078093a |
+ /* For a sigtramp frame, we don't make the check for previous ip being 0.
|
|
|
078093a |
+ We also must calculate the frame pointer because libunwind will give
|
|
|
078093a |
+ us back the current stack pointer instead of the frame pointer since
|
|
|
078093a |
+ it cannot figure this out when in a sigaltstack. We make a basic
|
|
|
078093a |
+ assumption of 16 (default size) + 8 bytes for sigcontext address.
|
|
|
078093a |
+ FIXME: if libunwind were to export the frame pointer address, we
|
|
|
078093a |
+ could eliminate the assumption and get the actual value. */
|
|
|
078093a |
+ (*this_id) = frame_id_build_special (id.stack_addr + 24, id.code_addr, bsp);
|
|
|
078093a |
|
|
|
078093a |
if (gdbarch_debug >= 1)
|
|
|
078093a |
fprintf_unfiltered (gdb_stdlog,
|