/* * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
char* os::non_memory_address_word() { // Must never look like an address returned by reserve_memory, // even in its subfields (as defined by the CPU immediate fields, // if the CPU splits constants across multiple instructions).
return (char*) -1;
}
// Frame information (pc, sp, fp) retrieved via ucontext // always looks like a C-frame according to the frame // conventions in frame_ppc.hpp.
frame os::get_sender_for_C_frame(frame* fr) { if (*fr->sp() == NULL) { // fr is the last C frame return frame(NULL, NULL);
} return frame(fr->sender_sp(), fr->sender_pc());
}
if (thread->thread_state() == _thread_in_Java) { // Java thread running in Java code
// The following signals are used for communicating VM events: // // SIGILL: the compiler generates illegal opcodes // at places where it wishes to interrupt the VM: // Safepoints, Unreachable Code, Entry points of not entrant nmethods, // This results in a SIGILL with (*pc) == inserted illegal instruction. // // (so, SIGILLs with a pc inside the zero page are real errors) // // SIGTRAP: // The ppc trap instruction raises a SIGTRAP and is very efficient if it // does not trap. It is used for conditional branches that are expected // to be never taken. These are: // - not entrant nmethods // - IC (inline cache) misses. // - null checks leading to UncommonTraps. // - range checks leading to Uncommon Traps. // On Aix, these are especially null checks, as the ImplicitNullCheck // optimization works only in rare cases, as the page at address 0 is only // write protected. // // Note: !UseSIGTRAP is used to prevent SIGTRAPS altogether, to facilitate debugging. // // SIGSEGV: // used for safe point polling: // To notify all threads that they have to reach a safe point, safe point polling is used: // All threads poll a certain mapped memory page. Normally, this page has read access. // If the VM wants to inform the threads about impending safe points, it puts this // page to read only ("poisens" the page), and the threads then reach a safe point. // used for null checks: // If the compiler finds a store it uses it for a null check. Unfortunately this // happens rarely. In heap based and disjoint base compressd oop modes also loads // are used for null checks.
CodeBlob *cb = NULL; int stop_type = -1; // Handle signal from NativeJump::patch_verified_entry(). if (sig == SIGILL && nativeInstruction_at(pc)->is_sigill_not_entrant()) { if (TraceTraps) {
tty->print_cr("trap: not_entrant");
}
stub = SharedRuntime::get_handle_wrong_method_stub(); goto run_stub;
}
if (TraceTraps) {
tty->print_cr("trap: %s: %s (SIGTRAP, stop type %d)", msg, detail_msg, stop_type);
}
// End life with a fatal error, message and detail message and the context. // Note: no need to do any post-processing here (e.g. signal chaining)
va_list va_dummy;
VMError::report_and_die(thread, uc, NULL, 0, msg, detail_msg, va_dummy);
va_end(va_dummy);
ShouldNotReachHere();
}
elseif (sig == SIGBUS) { // BugId 4454115: A read from a MappedByteBuffer can fault here if the // underlying file has been truncated. Do not crash the VM in such a case.
CodeBlob* cb = CodeCache::find_blob(pc);
CompiledMethod* nm = cb ? cb->as_compiled_method_or_null() : NULL; bool is_unsafe_arraycopy = (thread->doing_unsafe_access() && UnsafeCopyMemory::contains_pc(pc)); if ((nm != NULL && nm->has_unsafe_access()) || is_unsafe_arraycopy) {
address next_pc = pc + 4; if (is_unsafe_arraycopy) {
next_pc = UnsafeCopyMemory::page_error_continue_pc(pc);
}
next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc);
os::Posix::ucontext_set_pc(uc, next_pc); returntrue;
}
}
}
else { // thread->thread_state() != _thread_in_Java // Detect CPU features. This is only done at the very start of the VM. Later, the // VM_Version::is_determine_features_test_running() flag should be false.
if (sig == SIGILL && VM_Version::is_determine_features_test_running()) { // SIGILL must be caused by VM_Version::determine_features().
*(int *)pc = 0; // patch instruction to 0 to indicate that it causes a SIGILL, // flushing of icache is not necessary.
stub = pc + 4; // continue with next instruction. goto run_stub;
} elseif ((thread->thread_state() == _thread_in_vm ||
thread->thread_state() == _thread_in_native) &&
sig == SIGBUS && thread->doing_unsafe_access()) {
address next_pc = pc + 4; if (UnsafeCopyMemory::contains_pc(pc)) {
next_pc = UnsafeCopyMemory::page_error_continue_pc(pc);
}
next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc);
os::Posix::ucontext_set_pc(uc, next_pc); returntrue;
}
}
// jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in // and the heap gets shrunk before the field access. if ((sig == SIGSEGV) || (sig == SIGBUS)) {
address addr = JNI_FastGetField::find_slowcase_pc(pc); if (addr != (address)-1) {
stub = addr;
}
}
}
run_stub:
// One of the above code blocks ininitalized the stub, so we want to // delegate control to that stub. if (stub != NULL) { // Save all thread context in case we need to restore it. if (thread != NULL) thread->set_saved_exception_pc(pc);
os::Posix::ucontext_set_pc(uc, stub); returntrue;
}
// Note: it may be unsafe to inspect memory near pc. For example, pc may // point to garbage if entry point in an nmethod is corrupted. Leave // this at the end, and hope for the best.
address pc = os::Posix::ucontext_get_pc(uc);
print_instructions(st, pc, /*instrsize=*/4);
st->cr();
// Try to decode the instructions.
st->print_cr("Decoded instructions: (pc=" PTR_FORMAT ")", pc);
st->print(""); // TODO: PPC port Disassembler::decode(pc, 16, 16, st);
st->cr();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.