Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 arch/x86/signal.c |   15 +++++++++++++++
 vm/signal.c       |    5 +++--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/arch/x86/signal.c b/arch/x86/signal.c
index 6b59881..1349257 100644
--- a/arch/x86/signal.c
+++ b/arch/x86/signal.c
@@ -23,6 +23,7 @@
  *
  * Please refer to the file LICENSE for details.
  */
+#include <vm/stack-trace.h>
 
 #include <jit/cu-mapping.h>
 #include <jit/compiler.h>
@@ -51,3 +52,18 @@ struct compilation_unit *get_signal_source_cu(void *ctx)
        uc = ctx;
        return get_cu_from_native_addr(uc->uc_mcontext.gregs[REG_IP]);
 }
+
+struct object *get_stack_trace_from_ctx(void *ctx)
+{
+       struct stack_trace_elem elem;
+       ucontext_t *uc;
+
+       uc = ctx;
+
+       elem.frame = (void*)uc->uc_mcontext.gregs[REG_BP];
+       elem.addr = uc->uc_mcontext.gregs[REG_IP];
+       elem.is_native = is_native(elem.addr);
+       elem.is_trampoline = false;
+
+       return get_stack_trace(&elem);
+}
diff --git a/vm/signal.c b/vm/signal.c
index 747276a..44f86a0 100644
--- a/vm/signal.c
+++ b/vm/signal.c
@@ -26,6 +26,7 @@
 
 #include <jit/exception.h>
 
+#include <vm/stack-trace.h>
 #include <vm/backtrace.h>
 #include <vm/class.h>
 
@@ -40,7 +41,6 @@ static void sigfpe_handler(int sig, siginfo_t *si, void *ctx)
        if (signal_from_jit_method(ctx) && si->si_code == FPE_INTDIV) {
                struct object *exception;
 
-               /* TODO: exception's stack trace should be filled using ctx */
                exception = new_exception(
                        "java/lang/ArithmeticException", "division by zero");
                if (exception == NULL) {
@@ -49,6 +49,7 @@ static void sigfpe_handler(int sig, siginfo_t *si, void *ctx)
                        goto exit;
                }
 
+               set_throwable_vmstate(exception, get_stack_trace_from_ctx(ctx));
                throw_exception_from_signal(ctx, exception);
                return;
        }
@@ -72,7 +73,6 @@ static void sigsegv_handler(int sig, siginfo_t *si, void *ctx)
                if (get_signal_source_cu(ctx) == NULL)
                        goto exit;
 
-               /* TODO: exception's stack trace should be filled using ctx */
                exception = new_exception("java/lang/NullPointerException", 
NULL);
                if (exception == NULL) {
                        /* TODO: throw OutOfMemoryError */
@@ -80,6 +80,7 @@ static void sigsegv_handler(int sig, siginfo_t *si, void *ctx)
                        goto exit;
                }
 
+               set_throwable_vmstate(exception, get_stack_trace_from_ctx(ctx));
                throw_exception_from_signal(ctx, exception);
                return;
        }
-- 
1.6.0.6


------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to