Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: md.c 7249 2007-01-29 19:32:52Z twisti $
-
*/
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include <stdlib.h>
#include <ucontext.h>
void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
{
- ucontext_t *_uc;
- mcontext_t *_mc;
- u1 *sp;
- u1 *ra;
- u1 *xpc;
- u1 opc;
- u1 mod;
- u1 rm;
- s4 d;
- s4 disp;
- s4 type;
- ptrint val;
- java_objectheader *o;
+ stackframeinfo sfi;
+ ucontext_t *_uc;
+ mcontext_t *_mc;
+ u1 *sp;
+ u1 *ra;
+ u1 *xpc;
+ u1 opc;
+ u1 mod;
+ u1 rm;
+ s4 d;
+ s4 disp;
+ int type;
+ intptr_t val;
+ void *p;
_uc = (ucontext_t *) _p;
_mc = &_uc->uc_mcontext;
/* this was a normal NPE */
type = EXCEPTION_HARDWARE_NULLPOINTER;
+ val = 0;
}
- /* generate appropriate exception */
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, NULL, sp, ra, xpc);
+
+ /* Handle the type. */
+
+ p = signal_handle(xpc, type, val);
- o = exceptions_new_hardware_exception(NULL, sp, ra, xpc, type, val);
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
/* set registers */
- _mc->gregs[REG_RAX] = (ptrint) o;
- _mc->gregs[REG_R10] = (ptrint) xpc; /* REG_ITMP2_XPC */
- _mc->gregs[REG_RIP] = (ptrint) asm_handle_exception;
+ _mc->gregs[REG_RAX] = (intptr_t) p;
+ _mc->gregs[REG_R10] = (intptr_t) xpc; /* REG_ITMP2_XPC */
+ _mc->gregs[REG_RIP] = (intptr_t) asm_handle_exception;
}
void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
{
- ucontext_t *_uc;
- mcontext_t *_mc;
- u1 *pv;
- u1 *sp;
- u1 *ra;
- u1 *xpc;
- s4 type;
- ptrint val;
- java_objectheader *o;
+ stackframeinfo sfi;
+ ucontext_t *_uc;
+ mcontext_t *_mc;
+ u1 *pv;
+ u1 *sp;
+ u1 *ra;
+ u1 *xpc;
+ int type;
+ intptr_t val;
+ void *p;
_uc = (ucontext_t *) _p;
_mc = &_uc->uc_mcontext;
type = EXCEPTION_HARDWARE_ARITHMETIC;
val = 0;
- /* generate appropriate exception */
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
+ /* Handle the type. */
+
+ p = signal_handle(xpc, type, val);
- o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val);
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
/* set registers */
- _mc->gregs[REG_RAX] = (ptrint) o;
- _mc->gregs[REG_R10] = (ptrint) xpc; /* REG_ITMP2_XPC */
- _mc->gregs[REG_RIP] = (ptrint) asm_handle_exception;
+ _mc->gregs[REG_RAX] = (intptr_t) p;
+ _mc->gregs[REG_R10] = (intptr_t) xpc; /* REG_ITMP2_XPC */
+ _mc->gregs[REG_RIP] = (intptr_t) asm_handle_exception;
}
#endif
+/* md_critical_section_restart *************************************************
+
+ Search the critical sections tree for a matching section and set
+ the PC to the restart point, if necessary.
+
+*******************************************************************************/
+
#if defined(ENABLE_THREADS)
-void thread_restartcriticalsection(ucontext_t *_uc)
+void md_critical_section_restart(ucontext_t *_uc)
{
mcontext_t *_mc;
u1 *pc;
- void *critical;
+ u1 *npc;
_mc = &_uc->uc_mcontext;
+ /* ATTENTION: Don't use CACAO's internal REG_* defines as they are
+ different to the ones in <ucontext.h>. */
+
pc = (u1 *) _mc->gregs[REG_RIP];
- critical = critical_find_restart_point(pc);
+ npc = critical_find_restart_point(pc);
- if (critical != NULL)
- _mc->gregs[REG_RIP] = (ptrint) critical;
+ if (npc != NULL)
+ _mc->gregs[REG_RIP] = (ptrint) npc;
}
#endif