last bit of prep for x86_64 backtrace (might even work)
svn: r12622
This commit is contained in:
parent
84f52ab704
commit
8412e85b64
|
@ -41,6 +41,9 @@
|
||||||
|
|
||||||
#include "schpriv.h"
|
#include "schpriv.h"
|
||||||
#include "schmach.h"
|
#include "schmach.h"
|
||||||
|
#ifdef USE_DWARF_LIBUNWIND
|
||||||
|
# include "unwind/libunwind.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef MZ_USE_JIT
|
#ifdef MZ_USE_JIT
|
||||||
|
|
||||||
|
@ -8113,6 +8116,11 @@ Scheme_Object *scheme_native_stack_trace(void)
|
||||||
Get_Stack_Proc gs;
|
Get_Stack_Proc gs;
|
||||||
Scheme_Object *name, *last = NULL, *first = NULL, *tail;
|
Scheme_Object *name, *last = NULL, *first = NULL, *tail;
|
||||||
int set_next_push = 0, prev_had_name = 0;
|
int set_next_push = 0, prev_had_name = 0;
|
||||||
|
#ifdef USE_DWARF_LIBUNWIND
|
||||||
|
unw_context_t cx;
|
||||||
|
unw_cursor_t c;
|
||||||
|
#endif
|
||||||
|
int use_unw = 0;
|
||||||
|
|
||||||
if (!get_stack_pointer_code)
|
if (!get_stack_pointer_code)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -8121,8 +8129,15 @@ Scheme_Object *scheme_native_stack_trace(void)
|
||||||
check_stack();
|
check_stack();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_DWARF_LIBUNWIND
|
||||||
|
unw_getcontext(&cx);
|
||||||
|
unw_init_local(&c, &cx);
|
||||||
|
use_unw = 1;
|
||||||
|
#else
|
||||||
gs = (Get_Stack_Proc)get_stack_pointer_code;
|
gs = (Get_Stack_Proc)get_stack_pointer_code;
|
||||||
p = gs();
|
p = gs();
|
||||||
|
#endif
|
||||||
|
|
||||||
stack_start = scheme_approx_sp();
|
stack_start = scheme_approx_sp();
|
||||||
|
|
||||||
if (stack_cache_stack_pos) {
|
if (stack_cache_stack_pos) {
|
||||||
|
@ -8145,9 +8160,21 @@ Scheme_Object *scheme_native_stack_trace(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
while (STK_COMP((unsigned long)p, stack_end)
|
while (1) {
|
||||||
&& STK_COMP(stack_start, (unsigned long)p)) {
|
#ifdef USE_DWARF_LIBUNWIND
|
||||||
q = ((void **)p)[RETURN_ADDRESS_OFFSET];
|
if (use_unw) {
|
||||||
|
p = unw_get_frame_pointer(&c);
|
||||||
|
q = unw_get_ip(&c);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!use_unw) {
|
||||||
|
if (!(STK_COMP((unsigned long)p, stack_end)
|
||||||
|
&& STK_COMP(stack_start, (unsigned long)p)))
|
||||||
|
break;
|
||||||
|
|
||||||
|
q = ((void **)p)[RETURN_ADDRESS_OFFSET];
|
||||||
|
}
|
||||||
|
|
||||||
name = find_symbol((unsigned long)q);
|
name = find_symbol((unsigned long)q);
|
||||||
if (SCHEME_FALSEP(name) || SCHEME_VOIDP(name)) {
|
if (SCHEME_FALSEP(name) || SCHEME_VOIDP(name)) {
|
||||||
|
@ -8223,10 +8250,28 @@ Scheme_Object *scheme_native_stack_trace(void)
|
||||||
|
|
||||||
prev_had_name = !!name;
|
prev_had_name = !!name;
|
||||||
|
|
||||||
q = *(void **)p;
|
#ifdef USE_DWARF_LIBUNWIND
|
||||||
if (STK_COMP((unsigned long)q, (unsigned long)p))
|
if (use_unw) {
|
||||||
break;
|
if (name) {
|
||||||
p = q;
|
/* A JIT-generated function, so we unwind ourselves... */
|
||||||
|
/* For now, once we cross into JIT world, stay there. */
|
||||||
|
use_uwn = 0;
|
||||||
|
} else {
|
||||||
|
void *prev_q = q;
|
||||||
|
unw_step(&c);
|
||||||
|
q = unw_get_ip(&c);
|
||||||
|
if (q == prev_q)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!use_unw) {
|
||||||
|
q = *(void **)p;
|
||||||
|
if (STK_COMP((unsigned long)q, (unsigned long)p))
|
||||||
|
break;
|
||||||
|
p = q;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last)
|
if (last)
|
||||||
|
@ -8256,9 +8301,7 @@ void scheme_dump_stack_trace(void)
|
||||||
stack_end = (unsigned long)scheme_current_thread->stack_start;
|
stack_end = (unsigned long)scheme_current_thread->stack_start;
|
||||||
|
|
||||||
while (STK_COMP((unsigned long)p, stack_end)
|
while (STK_COMP((unsigned long)p, stack_end)
|
||||||
&& STK_COMP(stack_start, (unsigned long)p)) {
|
&& STK_COMP(stack_start, (unsigned long)p)) {
|
||||||
q = ((void **)p)[RETURN_ADDRESS_OFFSET];
|
|
||||||
|
|
||||||
name = find_symbol((unsigned long)q);
|
name = find_symbol((unsigned long)q);
|
||||||
if (SCHEME_FALSEP(name)) {
|
if (SCHEME_FALSEP(name)) {
|
||||||
/* Code uses special calling convention */
|
/* Code uses special calling convention */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user