* src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigsegv): Use
authortwisti <none@none>
Tue, 3 Apr 2007 13:47:39 +0000 (13:47 +0000)
committertwisti <none@none>
Tue, 3 Apr 2007 13:47:39 +0000 (13:47 +0000)
exceptions_new_hardware_exception.
[ENABLE_THREADS] (md_signal_handler_sigusr2): New function.

src/vm/jit/arm/linux/md-os.c

index b169ff45436b5062379cf58d97dd5aa6aa6288ca..3bc9af9fe5f5be21a0b6cc6623ef35cb4978065e 100644 (file)
@@ -67,46 +67,52 @@ typedef struct ucontext {
 
 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 {
-       ucontext_t *_uc;
-       /*mcontext_t *_mc;*/
-       scontext_t *_sc;
-       u4          instr;
-       ptrint      addr;
-       ptrint      base;
-       u1          *pv;
-       u1          *sp;
-       u1          *ra;
-       u1          *xpc;
+       ucontext_t        *_uc;
+       scontext_t        *_sc;
+       u1                *pv;
+       u1                *sp;
+       u1                *ra;
+       u1                *xpc;
+       u4                 mcode;
+       ptrint             addr;
+       s4                 type;
+       ptrint             val;
+       java_objectheader *o;
 
        _uc = (ucontext_t*) _p;
        _sc = &_uc->uc_mcontext;
 
-       /* ATTENTION: glibc included messed up kernel headers */
-       /* we needed a workaround for the ucontext structure */
+       /* ATTENTION: glibc included messed up kernel headers we needed a
+          workaround for the ucontext structure. */
+
+       pv  = (u1 *) _sc->arm_ip;
+       sp  = (u1 *) _sc->arm_sp;
+       ra  = (u1 *) _sc->arm_lr;                    /* this is correct for leafs */
+       xpc = (u1 *) _sc->arm_pc;
+
+       /* get exception-throwing instruction */
+
+       mcode = *((s4 *) xpc);
 
-       addr = (ptrint) siginfo->si_addr;
-       /*xpc = (u1*) _mc->gregs[REG_PC];*/
-       xpc = (u1*) _sc->arm_pc;
+       /* this is a NullPointerException */
 
-       instr = *((s4*) xpc);
-       base = *((s4*) _sc + OFFSET(scontext_t, arm_r0)/4 + ((instr >> 16) & 0x0f));
+/*     addr = _mc->gregs[s1]; */
+       addr = *((s4 *) _sc + OFFSET(scontext_t, arm_r0)/4 + ((mcode >> 16) & 0x0f));
+       type = EXCEPTION_HARDWARE_NULLPOINTER;
+       val  = 0;
 
-       if (base == 0) {
-               pv  = (u1*) _sc->arm_ip;
-               sp  = (u1*) _sc->arm_sp;
-               ra  = (u1*) _sc->arm_lr; /* this is correct for leafs */
+       if (addr != 0)
+               vm_abort("md_signal_handler_sigsegv: faulting address is not NULL: addr=%p", addr);
 
-               _sc->arm_r10 = (ptrint) stacktrace_hardware_nullpointerexception(pv, sp, ra, xpc);
-               _sc->arm_fp = (ptrint) xpc;
-               _sc->arm_pc = (ptrint) asm_handle_exception;
-       }
-       else {
-               codegen_get_pv_from_pc(xpc);
+       /* generate appropriate exception */
+
+       o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val);
 
-               /* this should not happen */
+       /* set registers */
 
-               assert(0);
-       }
+       _sc->arm_r10 = (ptrint) o;
+       _sc->arm_fp  = (ptrint) xpc;
+       _sc->arm_pc  = (ptrint) asm_handle_exception;
 }
 
 
@@ -135,10 +141,10 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
        /* ATTENTION: glibc included messed up kernel headers we needed a
           workaround for the ucontext structure. */
 
-       pv  = (u1*) _sc->arm_ip;
-       sp  = (u1*) _sc->arm_sp;
-       ra  = (u1*) _sc->arm_lr;                     /* this is correct for leafs */
-       xpc = (u1*) _sc->arm_pc;
+       pv  = (u1 *) _sc->arm_ip;
+       sp  = (u1 *) _sc->arm_sp;
+       ra  = (u1 *) _sc->arm_lr;                    /* this is correct for leafs */
+       xpc = (u1 *) _sc->arm_pc;
 
        /* get exception-throwing instruction */
 
@@ -164,6 +170,32 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
 }
 
 
+/* md_signal_handler_sigusr2 ***************************************************
+
+   Signal handler for profiling sampling.
+
+*******************************************************************************/
+
+#if defined(ENABLE_THREADS)
+void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
+{
+       threadobject *thread;
+       ucontext_t   *_uc;
+       scontext_t   *_sc;
+       u1           *pc;
+
+       thread = THREADOBJECT;
+
+       _uc = (ucontext_t*) _p;
+       _sc = &_uc->uc_mcontext;
+
+       pc = (u1 *) _sc->arm_pc;
+
+       thread->pc = pc;
+}
+#endif
+
+
 /* thread_restartcriticalsection ***********************************************
 
    TODO: document me