#include "threads/thread.hpp"
#include "vm/jit/builtin.hpp"
-#include "vm/signallocal.h"
+#include "vm/signallocal.hpp"
#include "vm/jit/asmpart.h"
#include "vm/jit/executionstate.h"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
#include "vm/jit/stacktrace.hpp"
int type;
intptr_t val;
void *p;
- java_object_t *o;
_uc = (ucontext_t *) _p;
_mc = &_uc->uc_mcontext;
if (type == TRAP_COMPILER) {
if (p == NULL) {
- o = builtin_retrieve_exception();
-
_mc->gregs[REG_RSP] = (uintptr_t) sp; /* Remove RA from stack. */
-
- _mc->gregs[REG_RAX] = (uintptr_t) o;
- _mc->gregs[REG_R10] = (uintptr_t) xpc; /* REG_ITMP2_XPC */
- _mc->gregs[REG_RIP] = (uintptr_t) asm_handle_exception;
- }
- else {
- _mc->gregs[REG_RIP] = (uintptr_t) p;
}
}
- else {
- _mc->gregs[REG_RAX] = (uintptr_t) p;
- _mc->gregs[REG_R10] = (uintptr_t) xpc; /* REG_ITMP2_XPC */
- _mc->gregs[REG_RIP] = (uintptr_t) asm_handle_exception;
- }
}
u1 *xpc;
int type;
intptr_t val;
- void *p;
_uc = (ucontext_t *) _p;
_mc = &_uc->uc_mcontext;
/* Handle the trap. */
- p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
- /* set registers */
-
- _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;
+ trap_handle(type, val, pv, sp, ra, xpc, _p);
}
u1 *xpc;
int type;
intptr_t val;
- void *p;
_uc = (ucontext_t *) _p;
_mc = &_uc->uc_mcontext;
xpc = (u1 *) _mc->gregs[REG_RIP];
ra = xpc; /* return address is equal to xpc */
+ // Check if the trap instruction is valid.
+ // TODO Move this into patcher_handler.
+ if (patcher_is_valid_trap_instruction_at(xpc) == false) {
+ // Check if the PC has been patched during our way to this
+ // signal handler (see PR85).
+ if (patcher_is_patched_at(xpc) == true)
+ return;
+
+ // We have a problem...
+ log_println("md_signal_handler_sigill: Unknown illegal instruction at 0x%lx", xpc);
+#if defined(ENABLE_DISASSEMBLER)
+ (void) disassinstr(xpc);
+#endif
+ vm_abort("Aborting...");
+ }
+
/* This is a patcher. */
type = TRAP_PATCHER;
/* Handle the trap. */
- p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
- /* set registers */
-
- if (p != NULL) {
- _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;
- }
+ trap_handle(type, val, pv, sp, ra, xpc, _p);
}