From: Klaus Treichel Date: Thu, 23 Mar 2006 18:56:52 +0000 (+0000) Subject: 2006-03-23 Klaus Treichel X-Git-Tag: before.move.to.git~262 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=fcdd7cb1b014a30672069e604cb49c07c0103bf3;p=francis%2Flibjit.git 2006-03-23 Klaus Treichel * jit/jitc-except.c: Walk the stack to build the stack trace in jit_exception_get_stack_trace when the frame is not broken. --- diff --git a/ChangeLog b/ChangeLog index 9dc4185..2413bdc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-03-23 Klaus Treichel + + * jit/jitc-except.c: Walk the stack to build the stack trace in + jit_exception_get_stack_trace when the frame is not broken. + 2006-03-23 Aleksey Demakov * tools/Makefile.am: diff --git a/jit/jit-except.c b/jit/jit-except.c index 5183d85..0f1d2a0 100644 --- a/jit/jit-except.c +++ b/jit/jit-except.c @@ -303,11 +303,12 @@ struct jit_stack_trace @*/ jit_stack_trace_t jit_exception_get_stack_trace(void) { + jit_stack_trace_t trace = 0; + unsigned int size = 0; +#if JIT_APPLY_BROKEN_FRAME_BUILTINS != 0 jit_thread_control_t control; jit_backtrace_t top; jit_backtrace_t item; - unsigned int size; - jit_stack_trace_t trace; /* Count the number of items in the current thread's call stack */ control = _jit_thread_get_control(); @@ -343,6 +344,36 @@ jit_stack_trace_t jit_exception_get_stack_trace(void) ++size; item = item->parent; } +#else + void *frame = jit_get_current_frame(); + + /* Count the number of items in the current thread's call stack */ + while(frame != 0) + { + frame = jit_get_next_frame_address(frame); + ++size; + } + + /* Allocate memory for the stack trace */ + trace = (jit_stack_trace_t)jit_malloc + (sizeof(struct jit_stack_trace) + + size * sizeof(void *) - sizeof(void *)); + if(!trace) + { + return 0; + } + trace->size = size; + + /* Populate the stack trace with the items we counted earlier */ + size = 0; + frame = jit_get_current_frame(); + while(frame != 0) + { + trace->items[size] = jit_get_return_address(frame); + frame = jit_get_next_frame_address(frame); + ++size; + } +#endif return trace; }