]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
2006-03-23 Klaus Treichel <ktreichel@web.de>
authorKlaus Treichel <ktreichel@web.de>
Thu, 23 Mar 2006 18:56:52 +0000 (18:56 +0000)
committerKlaus Treichel <ktreichel@web.de>
Thu, 23 Mar 2006 18:56:52 +0000 (18:56 +0000)
* jit/jitc-except.c: Walk the stack to build the stack trace in
jit_exception_get_stack_trace when the frame is not broken.

ChangeLog
jit/jit-except.c

index 9dc4185a445720a0ac86eb6901fa1177fe26a4bb..2413bdc4cbe6ce0c44cb0afd2b914647c64c02e8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-03-23  Klaus Treichel  <ktreichel@web.de>
+
+       * 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  <ademakov@gmail.com>
 
        * tools/Makefile.am: 
index 5183d85b4089916543cf96d5dee109024e206072..0f1d2a06e7322083aabdc1e13721850c99653c9c 100644 (file)
@@ -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;
 }