8253742: POSIX signal code cleanup
Reviewed-by: stuefe, dholmes
This commit is contained in:
parent
fa8dce4f77
commit
50a2c22ff7
src/hotspot
os
aix
bsd
linux
posix
os_cpu
aix_ppc
bsd_x86
bsd_zero
linux_aarch64
linux_arm
linux_ppc
linux_s390
linux_x86
linux_zero
share/runtime
@ -1440,25 +1440,6 @@ void os::pd_print_cpu_info(outputStream* st, char* buf, size_t buflen) {
|
||||
// Nothing to do beyond of what os::print_cpu_info() does.
|
||||
}
|
||||
|
||||
void os::print_signal_handlers(outputStream* st, char* buf, size_t buflen) {
|
||||
st->print_cr("Signal Handlers:");
|
||||
PosixSignals::print_signal_handler(st, SIGSEGV, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGBUS , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGFPE , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGPIPE, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGXFSZ, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGILL , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SR_signum, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SHUTDOWN1_SIGNAL, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SHUTDOWN2_SIGNAL , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SHUTDOWN3_SIGNAL , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, BREAK_SIGNAL, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGTRAP, buf, buflen);
|
||||
// We also want to know if someone else adds a SIGDANGER handler because
|
||||
// that will interfere with OOM killling.
|
||||
PosixSignals::print_signal_handler(st, SIGDANGER, buf, buflen);
|
||||
}
|
||||
|
||||
static char saved_jvm_path[MAXPATHLEN] = {0};
|
||||
|
||||
// Find the full path to the current module, libjvm.so.
|
||||
@ -2518,19 +2499,10 @@ jint os::init_2(void) {
|
||||
LoadedLibraries::print(tty);
|
||||
}
|
||||
|
||||
// initialize suspend/resume support - must do this before signal_sets_init()
|
||||
if (PosixSignals::SR_initialize() != 0) {
|
||||
perror("SR_initialize failed");
|
||||
if (PosixSignals::init() == JNI_ERR) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
PosixSignals::signal_sets_init();
|
||||
PosixSignals::install_signal_handlers();
|
||||
// Initialize data for jdk.internal.misc.Signal
|
||||
if (!ReduceSignalUsage) {
|
||||
PosixSignals::jdk_misc_signal_init();
|
||||
}
|
||||
|
||||
// Check and sets minimum stack sizes against command line options
|
||||
if (Posix::set_minimum_stack_sizes() == JNI_ERR) {
|
||||
return JNI_ERR;
|
||||
@ -2600,14 +2572,6 @@ bool os::bind_to_processor(uint processor_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void os::SuspendedThreadTask::internal_do_task() {
|
||||
if (PosixSignals::do_suspend(_thread->osthread())) {
|
||||
SuspendedThreadTaskContext context(_thread, _thread->osthread()->ucontext());
|
||||
do_task(context);
|
||||
PosixSignals::do_resume(_thread->osthread());
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// debug support
|
||||
|
||||
|
@ -92,11 +92,8 @@ class Aix {
|
||||
return _page_size;
|
||||
}
|
||||
|
||||
static address ucontext_get_pc(const ucontext_t* uc);
|
||||
static intptr_t* ucontext_get_sp(const ucontext_t* uc);
|
||||
static intptr_t* ucontext_get_fp(const ucontext_t* uc);
|
||||
// Set PC into context. Needed for continuation after signal.
|
||||
static void ucontext_set_pc(ucontext_t* uc, address pc);
|
||||
|
||||
static bool get_frame_at_stack_banging_point(JavaThread* thread, ucontext_t* uc, frame* fr);
|
||||
|
||||
|
@ -1540,21 +1540,6 @@ void os::print_memory_info(outputStream* st) {
|
||||
st->cr();
|
||||
}
|
||||
|
||||
void os::print_signal_handlers(outputStream* st, char* buf, size_t buflen) {
|
||||
st->print_cr("Signal Handlers:");
|
||||
PosixSignals::print_signal_handler(st, SIGSEGV, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGBUS , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGFPE , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGPIPE, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGXFSZ, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGILL , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SR_signum, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SHUTDOWN1_SIGNAL, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SHUTDOWN2_SIGNAL , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SHUTDOWN3_SIGNAL , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, BREAK_SIGNAL, buf, buflen);
|
||||
}
|
||||
|
||||
static char saved_jvm_path[MAXPATHLEN] = {0};
|
||||
|
||||
// Find the full path to the current module, libjvm
|
||||
@ -2139,19 +2124,10 @@ jint os::init_2(void) {
|
||||
|
||||
os::Posix::init_2();
|
||||
|
||||
// initialize suspend/resume support - must do this before signal_sets_init()
|
||||
if (PosixSignals::SR_initialize() != 0) {
|
||||
perror("SR_initialize failed");
|
||||
if (PosixSignals::init() == JNI_ERR) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
PosixSignals::signal_sets_init();
|
||||
PosixSignals::install_signal_handlers();
|
||||
// Initialize data for jdk.internal.misc.Signal
|
||||
if (!ReduceSignalUsage) {
|
||||
PosixSignals::jdk_misc_signal_init();
|
||||
}
|
||||
|
||||
// Check and sets minimum stack sizes against command line options
|
||||
if (Posix::set_minimum_stack_sizes() == JNI_ERR) {
|
||||
return JNI_ERR;
|
||||
@ -2282,14 +2258,6 @@ bool os::bind_to_processor(uint processor_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void os::SuspendedThreadTask::internal_do_task() {
|
||||
if (PosixSignals::do_suspend(_thread->osthread())) {
|
||||
SuspendedThreadTaskContext context(_thread, _thread->osthread()->ucontext());
|
||||
do_task(context);
|
||||
PosixSignals::do_resume(_thread->osthread());
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// debug support
|
||||
|
||||
|
@ -68,8 +68,6 @@ class Bsd {
|
||||
static int page_size(void) { return _page_size; }
|
||||
static void set_page_size(int val) { _page_size = val; }
|
||||
|
||||
static address ucontext_get_pc(const ucontext_t* uc);
|
||||
static void ucontext_set_pc(ucontext_t* uc, address pc);
|
||||
static intptr_t* ucontext_get_sp(const ucontext_t* uc);
|
||||
static intptr_t* ucontext_get_fp(const ucontext_t* uc);
|
||||
|
||||
|
@ -994,7 +994,7 @@ void os::free_thread(OSThread* osthread) {
|
||||
sigset_t current;
|
||||
sigemptyset(¤t);
|
||||
pthread_sigmask(SIG_SETMASK, NULL, ¤t);
|
||||
assert(!sigismember(¤t, SR_signum), "SR signal should not be blocked!");
|
||||
assert(!sigismember(¤t, PosixSignals::SR_signum), "SR signal should not be blocked!");
|
||||
#endif
|
||||
|
||||
// Restore caller's signal mask
|
||||
@ -2620,24 +2620,6 @@ void os::get_summary_cpu_info(char* cpuinfo, size_t length) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void os::print_signal_handlers(outputStream* st, char* buf, size_t buflen) {
|
||||
st->print_cr("Signal Handlers:");
|
||||
PosixSignals::print_signal_handler(st, SIGSEGV, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGBUS , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGFPE , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGPIPE, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGXFSZ, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGILL , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SR_signum, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SHUTDOWN1_SIGNAL, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SHUTDOWN2_SIGNAL , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SHUTDOWN3_SIGNAL , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, BREAK_SIGNAL, buf, buflen);
|
||||
#if defined(PPC64)
|
||||
PosixSignals::print_signal_handler(st, SIGTRAP, buf, buflen);
|
||||
#endif
|
||||
}
|
||||
|
||||
static char saved_jvm_path[MAXPATHLEN] = {0};
|
||||
|
||||
// Find the full path to the current module, libjvm.so
|
||||
@ -4543,19 +4525,10 @@ jint os::init_2(void) {
|
||||
|
||||
Linux::fast_thread_clock_init();
|
||||
|
||||
// initialize suspend/resume support - must do this before signal_sets_init()
|
||||
if (PosixSignals::SR_initialize() != 0) {
|
||||
perror("SR_initialize failed");
|
||||
if (PosixSignals::init() == JNI_ERR) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
PosixSignals::signal_sets_init();
|
||||
PosixSignals::install_signal_handlers();
|
||||
// Initialize data for jdk.internal.misc.Signal
|
||||
if (!ReduceSignalUsage) {
|
||||
PosixSignals::jdk_misc_signal_init();
|
||||
}
|
||||
|
||||
if (AdjustStackSizeForTLS) {
|
||||
get_minstack_init();
|
||||
}
|
||||
@ -4808,16 +4781,6 @@ bool os::bind_to_processor(uint processor_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
void os::SuspendedThreadTask::internal_do_task() {
|
||||
if (PosixSignals::do_suspend(_thread->osthread())) {
|
||||
SuspendedThreadTaskContext context(_thread, _thread->osthread()->ucontext());
|
||||
do_task(context);
|
||||
PosixSignals::do_resume(_thread->osthread());
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// debug support
|
||||
|
||||
|
@ -134,8 +134,6 @@ class Linux {
|
||||
static int page_size(void) { return _page_size; }
|
||||
static void set_page_size(int val) { _page_size = val; }
|
||||
|
||||
static address ucontext_get_pc(const ucontext_t* uc);
|
||||
static void ucontext_set_pc(ucontext_t* uc, address pc);
|
||||
static intptr_t* ucontext_get_sp(const ucontext_t* uc);
|
||||
static intptr_t* ucontext_get_fp(const ucontext_t* uc);
|
||||
|
||||
|
@ -88,6 +88,10 @@ public:
|
||||
|
||||
static void print_user_info(outputStream* st);
|
||||
|
||||
// Set PC into context. Needed for continuation after signal.
|
||||
static address ucontext_get_pc(const ucontext_t* ctx);
|
||||
static void ucontext_set_pc(ucontext_t* ctx, address pc);
|
||||
|
||||
#ifdef SUPPORTS_CLOCK_MONOTONIC
|
||||
|
||||
private:
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "runtime/atomic.hpp"
|
||||
#include "runtime/globals.hpp"
|
||||
#include "runtime/interfaceSupport.inline.hpp"
|
||||
#include "runtime/java.hpp"
|
||||
#include "runtime/os.hpp"
|
||||
#include "runtime/osThread.hpp"
|
||||
#include "runtime/thread.hpp"
|
||||
@ -37,6 +38,8 @@
|
||||
#include "utilities/ostream.hpp"
|
||||
#include "utilities/vmError.hpp"
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
// Various signal related mechanism are laid out in the following order:
|
||||
//
|
||||
// sun.misc.Signal
|
||||
@ -44,16 +47,6 @@
|
||||
// signal handling (except suspend/resume)
|
||||
// suspend/resume
|
||||
|
||||
// glibc on Bsd platform uses non-documented flag
|
||||
// to indicate, that some special sort of signal
|
||||
// trampoline is used.
|
||||
// We will never set this flag, and we should
|
||||
// ignore this flag in our diagnostic
|
||||
#ifdef SIGNIFICANT_SIGNAL_MASK
|
||||
#undef SIGNIFICANT_SIGNAL_MASK
|
||||
#endif
|
||||
#define SIGNIFICANT_SIGNAL_MASK (~0x04000000)
|
||||
|
||||
// Todo: provide a os::get_max_process_id() or similar. Number of processes
|
||||
// may have been configured, can be read more accurately from proc fs etc.
|
||||
#ifndef MAX_PID
|
||||
@ -91,6 +84,10 @@ int sigflags[NSIG];
|
||||
static PosixSemaphore sr_semaphore;
|
||||
#endif
|
||||
|
||||
// Signal number used to suspend/resume a thread
|
||||
// do not use any signal number less than SIGSEGV, see 4355769
|
||||
int PosixSignals::SR_signum = SIGUSR2;
|
||||
|
||||
// sun.misc.Signal support
|
||||
static Semaphore* sig_semaphore = NULL;
|
||||
// a counter for each possible signal value
|
||||
@ -263,7 +260,7 @@ static const char* get_signal_name(int sig, char* out, size_t outlen);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// sun.misc.Signal support
|
||||
|
||||
void PosixSignals::jdk_misc_signal_init() {
|
||||
void jdk_misc_signal_init() {
|
||||
// Initialize signal structures
|
||||
::memset((void*)pending_signals, 0, sizeof(pending_signals));
|
||||
|
||||
@ -574,7 +571,7 @@ int JVM_HANDLE_XXX_SIGNAL(int sig, siginfo_t* info,
|
||||
if (S390_ONLY(sig == SIGILL || sig == SIGFPE) NOT_S390(false)) {
|
||||
pc = (address)info->si_addr;
|
||||
} else {
|
||||
pc = PosixSignals::ucontext_get_pc(uc);
|
||||
pc = os::Posix::ucontext_get_pc(uc);
|
||||
}
|
||||
}
|
||||
#if defined(ZERO) && !defined(PRODUCT)
|
||||
@ -737,9 +734,6 @@ static void check_signal_handler(int sig) {
|
||||
|
||||
os_sigaction(sig, (struct sigaction*)NULL, &act);
|
||||
|
||||
|
||||
act.sa_flags &= SIGNIFICANT_SIGNAL_MASK;
|
||||
|
||||
address thisHandler = (act.sa_flags & SA_SIGINFO)
|
||||
? CAST_FROM_FN_PTR(address, act.sa_sigaction)
|
||||
: CAST_FROM_FN_PTR(address, act.sa_handler);
|
||||
@ -763,7 +757,7 @@ static void check_signal_handler(int sig) {
|
||||
break;
|
||||
|
||||
default:
|
||||
if (sig == SR_signum) {
|
||||
if (sig == PosixSignals::SR_signum) {
|
||||
jvmHandler = CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler);
|
||||
} else {
|
||||
return;
|
||||
@ -864,7 +858,7 @@ void os::run_periodic_checks() {
|
||||
do_signal_check(BREAK_SIGNAL);
|
||||
}
|
||||
|
||||
do_signal_check(SR_signum);
|
||||
do_signal_check(PosixSignals::SR_signum);
|
||||
}
|
||||
|
||||
// Helper function for PosixSignals::print_siginfo_...():
|
||||
@ -1217,8 +1211,7 @@ void set_signal_handler(int sig) {
|
||||
|
||||
// install signal handlers for signals that HotSpot needs to
|
||||
// handle in order to support Java-level exception handling.
|
||||
void PosixSignals::install_signal_handlers() {
|
||||
|
||||
void install_signal_handlers() {
|
||||
// signal-chaining
|
||||
typedef void (*signal_setting_t)();
|
||||
signal_setting_t begin_signal_setting = NULL;
|
||||
@ -1317,9 +1310,6 @@ void PosixSignals::print_signal_handler(outputStream* st, int sig,
|
||||
struct sigaction sa;
|
||||
sigaction(sig, NULL, &sa);
|
||||
|
||||
// See comment for SIGNIFICANT_SIGNAL_MASK define
|
||||
sa.sa_flags &= SIGNIFICANT_SIGNAL_MASK;
|
||||
|
||||
st->print("%s: ", os::exception_name(sig, buf, buflen));
|
||||
|
||||
address handler = (sa.sa_flags & SA_SIGINFO)
|
||||
@ -1341,7 +1331,7 @@ void PosixSignals::print_signal_handler(outputStream* st, int sig,
|
||||
// May be, handler was resetted by VMError?
|
||||
if (rh != NULL) {
|
||||
handler = rh;
|
||||
sa.sa_flags = VMError::get_resetted_sigflags(sig) & SIGNIFICANT_SIGNAL_MASK;
|
||||
sa.sa_flags = VMError::get_resetted_sigflags(sig);
|
||||
}
|
||||
|
||||
// Print textual representation of sa_flags.
|
||||
@ -1362,6 +1352,29 @@ void PosixSignals::print_signal_handler(outputStream* st, int sig,
|
||||
st->cr();
|
||||
}
|
||||
|
||||
void os::print_signal_handlers(outputStream* st, char* buf, size_t buflen) {
|
||||
st->print_cr("Signal Handlers:");
|
||||
PosixSignals::print_signal_handler(st, SIGSEGV, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGBUS , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGFPE , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGPIPE, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGXFSZ, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SIGILL , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, PosixSignals::SR_signum, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SHUTDOWN1_SIGNAL, buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SHUTDOWN2_SIGNAL , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, SHUTDOWN3_SIGNAL , buf, buflen);
|
||||
PosixSignals::print_signal_handler(st, BREAK_SIGNAL, buf, buflen);
|
||||
#if defined(SIGDANGER)
|
||||
// We also want to know if someone else adds a SIGDANGER handler because
|
||||
// that will interfere with OOM killling.
|
||||
PosixSignals::print_signal_handler(st, SIGDANGER, buf, buflen);
|
||||
#endif
|
||||
#if defined(SIGTRAP)
|
||||
PosixSignals::print_signal_handler(st, SIGTRAP, buf, buflen);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PosixSignals::is_sig_ignored(int sig) {
|
||||
struct sigaction oact;
|
||||
sigaction(sig, (struct sigaction*)NULL, &oact);
|
||||
@ -1374,31 +1387,7 @@ bool PosixSignals::is_sig_ignored(int sig) {
|
||||
}
|
||||
}
|
||||
|
||||
address PosixSignals::ucontext_get_pc(const ucontext_t* ctx) {
|
||||
#if defined(AIX)
|
||||
return os::Aix::ucontext_get_pc(ctx);
|
||||
#elif defined(BSD)
|
||||
return os::Bsd::ucontext_get_pc(ctx);
|
||||
#elif defined(LINUX)
|
||||
return os::Linux::ucontext_get_pc(ctx);
|
||||
#else
|
||||
VMError::report_and_die("unimplemented ucontext_get_pc");
|
||||
#endif
|
||||
}
|
||||
|
||||
void PosixSignals::ucontext_set_pc(ucontext_t* ctx, address pc) {
|
||||
#if defined(AIX)
|
||||
os::Aix::ucontext_set_pc(ctx, pc);
|
||||
#elif defined(BSD)
|
||||
os::Bsd::ucontext_set_pc(ctx, pc);
|
||||
#elif defined(LINUX)
|
||||
os::Linux::ucontext_set_pc(ctx, pc);
|
||||
#else
|
||||
VMError::report_and_die("unimplemented ucontext_set_pc");
|
||||
#endif
|
||||
}
|
||||
|
||||
void PosixSignals::signal_sets_init() {
|
||||
static void signal_sets_init() {
|
||||
sigemptyset(&preinstalled_sigs);
|
||||
|
||||
// Should also have an assertion stating we are still single-threaded.
|
||||
@ -1422,7 +1411,7 @@ void PosixSignals::signal_sets_init() {
|
||||
sigaddset(&unblocked_sigs, SIGBUS);
|
||||
sigaddset(&unblocked_sigs, SIGFPE);
|
||||
PPC64_ONLY(sigaddset(&unblocked_sigs, SIGTRAP);)
|
||||
sigaddset(&unblocked_sigs, SR_signum);
|
||||
sigaddset(&unblocked_sigs, PosixSignals::SR_signum);
|
||||
|
||||
if (!ReduceSignalUsage) {
|
||||
if (!PosixSignals::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
|
||||
@ -1572,7 +1561,7 @@ static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) {
|
||||
|
||||
// get current set of blocked signals and unblock resume signal
|
||||
pthread_sigmask(SIG_BLOCK, NULL, &suspend_set);
|
||||
sigdelset(&suspend_set, SR_signum);
|
||||
sigdelset(&suspend_set, PosixSignals::SR_signum);
|
||||
|
||||
sr_semaphore.signal();
|
||||
|
||||
@ -1608,7 +1597,7 @@ static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) {
|
||||
errno = old_errno;
|
||||
}
|
||||
|
||||
int PosixSignals::SR_initialize() {
|
||||
int SR_initialize() {
|
||||
struct sigaction act;
|
||||
char *s;
|
||||
// Get signal number to use for suspend/resume
|
||||
@ -1616,18 +1605,18 @@ int PosixSignals::SR_initialize() {
|
||||
int sig = ::strtol(s, 0, 10);
|
||||
if (sig > MAX2(SIGSEGV, SIGBUS) && // See 4355769.
|
||||
sig < NSIG) { // Must be legal signal and fit into sigflags[].
|
||||
SR_signum = sig;
|
||||
PosixSignals::SR_signum = sig;
|
||||
} else {
|
||||
warning("You set _JAVA_SR_SIGNUM=%d. It must be in range [%d, %d]. Using %d instead.",
|
||||
sig, MAX2(SIGSEGV, SIGBUS)+1, NSIG-1, SR_signum);
|
||||
sig, MAX2(SIGSEGV, SIGBUS)+1, NSIG-1, PosixSignals::SR_signum);
|
||||
}
|
||||
}
|
||||
|
||||
assert(SR_signum > SIGSEGV && SR_signum > SIGBUS,
|
||||
assert(PosixSignals::SR_signum > SIGSEGV && PosixSignals::SR_signum > SIGBUS,
|
||||
"SR_signum must be greater than max(SIGSEGV, SIGBUS), see 4355769");
|
||||
|
||||
sigemptyset(&SR_sigset);
|
||||
sigaddset(&SR_sigset, SR_signum);
|
||||
sigaddset(&SR_sigset, PosixSignals::SR_signum);
|
||||
|
||||
// Set up signal handler for suspend/resume
|
||||
act.sa_flags = SA_RESTART|SA_SIGINFO;
|
||||
@ -1637,17 +1626,17 @@ int PosixSignals::SR_initialize() {
|
||||
pthread_sigmask(SIG_BLOCK, NULL, &act.sa_mask);
|
||||
remove_error_signals_from_set(&(act.sa_mask));
|
||||
|
||||
if (sigaction(SR_signum, &act, 0) == -1) {
|
||||
if (sigaction(PosixSignals::SR_signum, &act, 0) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Save signal flag
|
||||
set_our_sigflags(SR_signum, act.sa_flags);
|
||||
set_our_sigflags(PosixSignals::SR_signum, act.sa_flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sr_notify(OSThread* osthread) {
|
||||
int status = pthread_kill(osthread->pthread_id(), SR_signum);
|
||||
int status = pthread_kill(osthread->pthread_id(), PosixSignals::SR_signum);
|
||||
assert_status(status == 0, status, "pthread_kill");
|
||||
return status;
|
||||
}
|
||||
@ -1717,3 +1706,30 @@ void PosixSignals::do_resume(OSThread* osthread) {
|
||||
|
||||
guarantee(osthread->sr.is_running(), "Must be running!");
|
||||
}
|
||||
|
||||
void os::SuspendedThreadTask::internal_do_task() {
|
||||
if (PosixSignals::do_suspend(_thread->osthread())) {
|
||||
os::SuspendedThreadTaskContext context(_thread, _thread->osthread()->ucontext());
|
||||
do_task(context);
|
||||
PosixSignals::do_resume(_thread->osthread());
|
||||
}
|
||||
}
|
||||
|
||||
int PosixSignals::init() {
|
||||
// initialize suspend/resume support - must do this before signal_sets_init()
|
||||
if (SR_initialize() != 0) {
|
||||
vm_exit_during_initialization("SR_initialize failed");
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
signal_sets_init();
|
||||
|
||||
install_signal_handlers();
|
||||
|
||||
// Initialize data for jdk.internal.misc.Signal
|
||||
if (!ReduceSignalUsage) {
|
||||
jdk_misc_signal_init();
|
||||
}
|
||||
|
||||
return JNI_OK;
|
||||
}
|
||||
|
@ -28,49 +28,39 @@
|
||||
#include "memory/allocation.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
// Signal number used to suspend/resume a thread
|
||||
// do not use any signal number less than SIGSEGV, see 4355769
|
||||
static int SR_signum = SIGUSR2;
|
||||
class outputStream;
|
||||
class Thread;
|
||||
class OSThread;
|
||||
|
||||
class PosixSignals : public AllStatic {
|
||||
|
||||
public:
|
||||
|
||||
// Signal number used to suspend/resume a thread
|
||||
static int SR_signum;
|
||||
|
||||
static int init();
|
||||
// The platform dependent parts of the central hotspot signal handler.
|
||||
// Returns true if the signal had been recognized and handled, false if not. If true, caller should
|
||||
// return from signal handling.
|
||||
static bool pd_hotspot_signal_handler(int sig, siginfo_t* info, ucontext_t* uc, JavaThread* thread);
|
||||
|
||||
static void install_signal_handlers();
|
||||
|
||||
static bool is_sig_ignored(int sig);
|
||||
static void signal_sets_init();
|
||||
|
||||
static void hotspot_sigmask(Thread* thread);
|
||||
|
||||
static void print_signal_handler(outputStream* st, int sig, char* buf, size_t buflen);
|
||||
|
||||
static address ucontext_get_pc(const ucontext_t* ctx);
|
||||
// Set PC into context. Needed for continuation after signal.
|
||||
static void ucontext_set_pc(ucontext_t* ctx, address pc);
|
||||
|
||||
// Suspend-resume
|
||||
static int SR_initialize();
|
||||
static bool do_suspend(OSThread* osthread);
|
||||
static void do_resume(OSThread* osthread);
|
||||
|
||||
// For signal-chaining
|
||||
static bool chained_handler(int sig, siginfo_t* siginfo, void* context);
|
||||
|
||||
// sun.misc.Signal support
|
||||
static void jdk_misc_signal_init();
|
||||
|
||||
// Unblock all signals whose delivery cannot be deferred and which, if they happen
|
||||
// while delivery is blocked, would cause crashes or hangs (see JDK-8252533).
|
||||
static void unblock_error_signals();
|
||||
|
||||
};
|
||||
|
||||
#endif // OS_POSIX_SIGNALS_POSIX_HPP
|
||||
|
@ -106,7 +106,7 @@ static void crash_handler(int sig, siginfo_t* info, void* ucVoid) {
|
||||
|
||||
// support safefetch faults in error handling
|
||||
ucontext_t* const uc = (ucontext_t*) ucVoid;
|
||||
address pc = (uc != NULL) ? PosixSignals::ucontext_get_pc(uc) : NULL;
|
||||
address pc = (uc != NULL) ? os::Posix::ucontext_get_pc(uc) : NULL;
|
||||
|
||||
// Correct pc for SIGILL, SIGFPE (see JDK-8176872)
|
||||
if (sig == SIGILL || sig == SIGFPE) {
|
||||
@ -115,7 +115,7 @@ static void crash_handler(int sig, siginfo_t* info, void* ucVoid) {
|
||||
|
||||
// Needed to make it possible to call SafeFetch.. APIs in error handling.
|
||||
if (uc && pc && StubRoutines::is_safefetch_fault(pc)) {
|
||||
PosixSignals::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
|
||||
os::Posix::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ char* os::non_memory_address_word() {
|
||||
// always looks like a C-frame according to the frame
|
||||
// conventions in frame_ppc.hpp.
|
||||
|
||||
address os::Aix::ucontext_get_pc(const ucontext_t * uc) {
|
||||
address os::Posix::ucontext_get_pc(const ucontext_t * uc) {
|
||||
return (address)uc->uc_mcontext.jmp_context.iar;
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ intptr_t* os::Aix::ucontext_get_fp(const ucontext_t * uc) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void os::Aix::ucontext_set_pc(ucontext_t* uc, address new_pc) {
|
||||
void os::Posix::ucontext_set_pc(ucontext_t* uc, address new_pc) {
|
||||
uc->uc_mcontext.jmp_context.iar = (uint64_t) new_pc;
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ address os::fetch_frame_from_context(const void* ucVoid,
|
||||
const ucontext_t* uc = (const ucontext_t*)ucVoid;
|
||||
|
||||
if (uc != NULL) {
|
||||
epc = os::Aix::ucontext_get_pc(uc);
|
||||
epc = os::Posix::ucontext_get_pc(uc);
|
||||
if (ret_sp) *ret_sp = os::Aix::ucontext_get_sp(uc);
|
||||
if (ret_fp) *ret_fp = os::Aix::ucontext_get_fp(uc);
|
||||
} else {
|
||||
@ -175,7 +175,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
address stub = NULL;
|
||||
|
||||
// retrieve program counter
|
||||
address const pc = uc ? os::Aix::ucontext_get_pc(uc) : NULL;
|
||||
address const pc = uc ? os::Posix::ucontext_get_pc(uc) : NULL;
|
||||
|
||||
// retrieve crash address
|
||||
address const addr = info ? (const address) info->si_addr : NULL;
|
||||
@ -184,9 +184,9 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
// - make it work if _thread is null
|
||||
// - make it use the standard os::...::ucontext_get/set_pc APIs
|
||||
if (uc) {
|
||||
address const pc = os::Aix::ucontext_get_pc(uc);
|
||||
address const pc = os::Posix::ucontext_get_pc(uc);
|
||||
if (pc && StubRoutines::is_safefetch_fault(pc)) {
|
||||
os::Aix::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
|
||||
os::Posix::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -353,7 +353,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
next_pc = UnsafeCopyMemory::page_error_continue_pc(pc);
|
||||
}
|
||||
next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc);
|
||||
os::Aix::ucontext_set_pc(uc, next_pc);
|
||||
os::Posix::ucontext_set_pc(uc, next_pc);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -378,7 +378,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
next_pc = UnsafeCopyMemory::page_error_continue_pc(pc);
|
||||
}
|
||||
next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc);
|
||||
os::Aix::ucontext_set_pc(uc, next_pc);
|
||||
os::Posix::ucontext_set_pc(uc, next_pc);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -400,7 +400,7 @@ run_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::Aix::ucontext_set_pc(uc, stub);
|
||||
os::Posix::ucontext_set_pc(uc, stub);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -460,7 +460,7 @@ void os::print_context(outputStream *st, const void *context) {
|
||||
// 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::Aix::ucontext_get_pc(uc);
|
||||
address pc = os::Posix::ucontext_get_pc(uc);
|
||||
print_instructions(st, pc, /*instrsize=*/4);
|
||||
st->cr();
|
||||
|
||||
|
@ -297,11 +297,11 @@ char* os::non_memory_address_word() {
|
||||
return (char*) -1;
|
||||
}
|
||||
|
||||
address os::Bsd::ucontext_get_pc(const ucontext_t * uc) {
|
||||
address os::Posix::ucontext_get_pc(const ucontext_t * uc) {
|
||||
return (address)uc->context_pc;
|
||||
}
|
||||
|
||||
void os::Bsd::ucontext_set_pc(ucontext_t * uc, address pc) {
|
||||
void os::Posix::ucontext_set_pc(ucontext_t * uc, address pc) {
|
||||
uc->context_pc = (intptr_t)pc ;
|
||||
}
|
||||
|
||||
@ -320,7 +320,7 @@ address os::fetch_frame_from_context(const void* ucVoid,
|
||||
const ucontext_t* uc = (const ucontext_t*)ucVoid;
|
||||
|
||||
if (uc != NULL) {
|
||||
epc = os::Bsd::ucontext_get_pc(uc);
|
||||
epc = os::Posix::ucontext_get_pc(uc);
|
||||
if (ret_sp) *ret_sp = os::Bsd::ucontext_get_sp(uc);
|
||||
if (ret_fp) *ret_fp = os::Bsd::ucontext_get_fp(uc);
|
||||
} else {
|
||||
@ -409,10 +409,10 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
|
||||
//%note os_trap_1
|
||||
if (info != NULL && uc != NULL && thread != NULL) {
|
||||
pc = (address) os::Bsd::ucontext_get_pc(uc);
|
||||
pc = (address) os::Posix::ucontext_get_pc(uc);
|
||||
|
||||
if (StubRoutines::is_safefetch_fault(pc)) {
|
||||
os::Bsd::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
|
||||
os::Posix::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -570,7 +570,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
uc->context_trapno == trap_page_fault) {
|
||||
int page_size = os::vm_page_size();
|
||||
address addr = (address) info->si_addr;
|
||||
address pc = os::Bsd::ucontext_get_pc(uc);
|
||||
address pc = os::Posix::ucontext_get_pc(uc);
|
||||
// Make sure the pc and the faulting address are sane.
|
||||
//
|
||||
// If an instruction spans a page boundary, and the page containing
|
||||
@ -632,7 +632,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
// save all thread context in case we need to restore it
|
||||
if (thread != NULL) thread->set_saved_exception_pc(pc);
|
||||
|
||||
os::Bsd::ucontext_set_pc(uc, stub);
|
||||
os::Posix::ucontext_set_pc(uc, stub);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -887,7 +887,7 @@ void os::print_context(outputStream *st, const void *context) {
|
||||
// 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::Bsd::ucontext_get_pc(uc);
|
||||
address pc = os::Posix::ucontext_get_pc(uc);
|
||||
print_instructions(st, pc, sizeof(char));
|
||||
st->cr();
|
||||
}
|
||||
|
@ -94,12 +94,12 @@ char* os::non_memory_address_word() {
|
||||
return (char *) -1;
|
||||
}
|
||||
|
||||
address os::Bsd::ucontext_get_pc(const ucontext_t* uc) {
|
||||
address os::Posix::ucontext_get_pc(const ucontext_t* uc) {
|
||||
ShouldNotCallThis();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void os::Bsd::ucontext_set_pc(ucontext_t * uc, address pc) {
|
||||
void os::Posix::ucontext_set_pc(ucontext_t * uc, address pc) {
|
||||
ShouldNotCallThis();
|
||||
}
|
||||
|
||||
|
@ -91,11 +91,11 @@ char* os::non_memory_address_word() {
|
||||
return (char*) 0xffffffffffff;
|
||||
}
|
||||
|
||||
address os::Linux::ucontext_get_pc(const ucontext_t * uc) {
|
||||
address os::Posix::ucontext_get_pc(const ucontext_t * uc) {
|
||||
return (address)uc->uc_mcontext.pc;
|
||||
}
|
||||
|
||||
void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) {
|
||||
void os::Posix::ucontext_set_pc(ucontext_t * uc, address pc) {
|
||||
uc->uc_mcontext.pc = (intptr_t)pc;
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ address os::fetch_frame_from_context(const void* ucVoid,
|
||||
const ucontext_t* uc = (const ucontext_t*)ucVoid;
|
||||
|
||||
if (uc != NULL) {
|
||||
epc = os::Linux::ucontext_get_pc(uc);
|
||||
epc = os::Posix::ucontext_get_pc(uc);
|
||||
if (ret_sp) *ret_sp = os::Linux::ucontext_get_sp(uc);
|
||||
if (ret_fp) *ret_fp = os::Linux::ucontext_get_fp(uc);
|
||||
} else {
|
||||
@ -183,10 +183,10 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
|
||||
//%note os_trap_1
|
||||
if (info != NULL && uc != NULL && thread != NULL) {
|
||||
pc = (address) os::Linux::ucontext_get_pc(uc);
|
||||
pc = (address) os::Posix::ucontext_get_pc(uc);
|
||||
|
||||
if (StubRoutines::is_safefetch_fault(pc)) {
|
||||
os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
|
||||
os::Posix::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -287,12 +287,11 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
// save all thread context in case we need to restore it
|
||||
if (thread != NULL) thread->set_saved_exception_pc(pc);
|
||||
|
||||
os::Linux::ucontext_set_pc(uc, stub);
|
||||
os::Posix::ucontext_set_pc(uc, stub);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false; // Mute compiler
|
||||
|
||||
}
|
||||
|
||||
void os::Linux::init_thread_fpu_state(void) {
|
||||
@ -347,7 +346,7 @@ void os::print_context(outputStream *st, const void *context) {
|
||||
// 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::Linux::ucontext_get_pc(uc);
|
||||
address pc = os::Posix::ucontext_get_pc(uc);
|
||||
print_instructions(st, pc, 4/*native instruction size*/);
|
||||
st->cr();
|
||||
}
|
||||
|
@ -108,11 +108,11 @@ char* os::non_memory_address_word() {
|
||||
#define ARM_REGS_IN_CONTEXT 16
|
||||
|
||||
|
||||
address os::Linux::ucontext_get_pc(const ucontext_t* uc) {
|
||||
address os::Posix::ucontext_get_pc(const ucontext_t* uc) {
|
||||
return (address)uc->uc_mcontext.arm_pc;
|
||||
}
|
||||
|
||||
void os::Linux::ucontext_set_pc(ucontext_t* uc, address pc) {
|
||||
void os::Posix::ucontext_set_pc(ucontext_t* uc, address pc) {
|
||||
uc->uc_mcontext.arm_pc = (uintx)pc;
|
||||
}
|
||||
|
||||
@ -149,7 +149,7 @@ address os::fetch_frame_from_context(const void* ucVoid,
|
||||
const ucontext_t* uc = (const ucontext_t*)ucVoid;
|
||||
|
||||
if (uc != NULL) {
|
||||
epc = os::Linux::ucontext_get_pc(uc);
|
||||
epc = os::Posix::ucontext_get_pc(uc);
|
||||
if (ret_sp) *ret_sp = os::Linux::ucontext_get_sp(uc);
|
||||
if (ret_fp) {
|
||||
intptr_t* fp = os::Linux::ucontext_get_fp(uc);
|
||||
@ -252,7 +252,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
|| info->si_addr == (caddr_t)check_mp_ext_fault_instr)) {
|
||||
// skip faulty instruction + instruction that sets return value to
|
||||
// success and set return value to failure.
|
||||
os::Linux::ucontext_set_pc(uc, (address)info->si_addr + 8);
|
||||
os::Posix::ucontext_set_pc(uc, (address)info->si_addr + 8);
|
||||
uc->uc_mcontext.arm_r0 = 0;
|
||||
return true;
|
||||
}
|
||||
@ -262,14 +262,14 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
bool unsafe_access = false;
|
||||
|
||||
if (info != NULL && uc != NULL && thread != NULL) {
|
||||
pc = (address) os::Linux::ucontext_get_pc(uc);
|
||||
pc = (address) os::Posix::ucontext_get_pc(uc);
|
||||
|
||||
// Handle ALL stack overflow variations here
|
||||
if (sig == SIGSEGV) {
|
||||
address addr = (address) info->si_addr;
|
||||
|
||||
if (StubRoutines::is_safefetch_fault(pc)) {
|
||||
os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
|
||||
os::Posix::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
|
||||
return true;
|
||||
}
|
||||
// check if fault address is within thread stack
|
||||
@ -389,12 +389,11 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
// save all thread context in case we need to restore it
|
||||
if (thread != NULL) thread->set_saved_exception_pc(pc);
|
||||
|
||||
os::Linux::ucontext_set_pc(uc, stub);
|
||||
os::Posix::ucontext_set_pc(uc, stub);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
void os::Linux::init_thread_fpu_state(void) {
|
||||
@ -465,7 +464,7 @@ void os::print_context(outputStream *st, const void *context) {
|
||||
// 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::Linux::ucontext_get_pc(uc);
|
||||
address pc = os::Posix::ucontext_get_pc(uc);
|
||||
print_instructions(st, pc, Assembler::InstructionSize);
|
||||
st->cr();
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ char* os::non_memory_address_word() {
|
||||
// Frame information (pc, sp, fp) retrieved via ucontext
|
||||
// always looks like a C-frame according to the frame
|
||||
// conventions in frame_ppc64.hpp.
|
||||
address os::Linux::ucontext_get_pc(const ucontext_t * uc) {
|
||||
address os::Posix::ucontext_get_pc(const ucontext_t * uc) {
|
||||
// On powerpc64, ucontext_t is not selfcontained but contains
|
||||
// a pointer to an optional substructure (mcontext_t.regs) containing the volatile
|
||||
// registers - NIP, among others.
|
||||
@ -115,7 +115,7 @@ address os::Linux::ucontext_get_pc(const ucontext_t * uc) {
|
||||
// modify PC in ucontext.
|
||||
// Note: Only use this for an ucontext handed down to a signal handler. See comment
|
||||
// in ucontext_get_pc.
|
||||
void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) {
|
||||
void os::Posix::ucontext_set_pc(ucontext_t * uc, address pc) {
|
||||
guarantee(uc->uc_mcontext.regs != NULL, "only use ucontext_set_pc in sigaction context");
|
||||
uc->uc_mcontext.regs->nip = (unsigned long)pc;
|
||||
}
|
||||
@ -143,7 +143,7 @@ address os::fetch_frame_from_context(const void* ucVoid,
|
||||
const ucontext_t* uc = (const ucontext_t*)ucVoid;
|
||||
|
||||
if (uc != NULL) {
|
||||
epc = os::Linux::ucontext_get_pc(uc);
|
||||
epc = os::Posix::ucontext_get_pc(uc);
|
||||
if (ret_sp) *ret_sp = os::Linux::ucontext_get_sp(uc);
|
||||
if (ret_fp) *ret_fp = os::Linux::ucontext_get_fp(uc);
|
||||
} else {
|
||||
@ -216,9 +216,9 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
// Moved SafeFetch32 handling outside thread!=NULL conditional block to make
|
||||
// it work if no associated JavaThread object exists.
|
||||
if (uc) {
|
||||
address const pc = os::Linux::ucontext_get_pc(uc);
|
||||
address const pc = os::Posix::ucontext_get_pc(uc);
|
||||
if (pc && StubRoutines::is_safefetch_fault(pc)) {
|
||||
os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
|
||||
os::Posix::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -228,7 +228,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
address pc = NULL;
|
||||
|
||||
if (info != NULL && uc != NULL && thread != NULL) {
|
||||
pc = (address) os::Linux::ucontext_get_pc(uc);
|
||||
pc = (address) os::Posix::ucontext_get_pc(uc);
|
||||
|
||||
// Handle ALL stack overflow variations here
|
||||
if (sig == SIGSEGV) {
|
||||
@ -364,7 +364,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
next_pc = UnsafeCopyMemory::page_error_continue_pc(pc);
|
||||
}
|
||||
next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc);
|
||||
os::Linux::ucontext_set_pc(uc, next_pc);
|
||||
os::Posix::ucontext_set_pc(uc, next_pc);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -385,7 +385,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
next_pc = UnsafeCopyMemory::page_error_continue_pc(pc);
|
||||
}
|
||||
next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc);
|
||||
os::Linux::ucontext_set_pc(uc, next_pc);
|
||||
os::Posix::ucontext_set_pc(uc, next_pc);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -403,12 +403,11 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
if (stub != NULL) {
|
||||
// Save all thread context in case we need to restore it.
|
||||
if (thread != NULL) thread->set_saved_exception_pc(pc);
|
||||
os::Linux::ucontext_set_pc(uc, stub);
|
||||
os::Posix::ucontext_set_pc(uc, stub);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
void os::Linux::init_thread_fpu_state(void) {
|
||||
@ -471,7 +470,7 @@ void os::print_context(outputStream *st, const void *context) {
|
||||
// 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::Linux::ucontext_get_pc(uc);
|
||||
address pc = os::Posix::ucontext_get_pc(uc);
|
||||
print_instructions(st, pc, /*instrsize=*/4);
|
||||
st->cr();
|
||||
}
|
||||
|
@ -99,11 +99,11 @@ char* os::non_memory_address_word() {
|
||||
// Frame information (pc, sp, fp) retrieved via ucontext
|
||||
// always looks like a C-frame according to the frame
|
||||
// conventions in frame_s390.hpp.
|
||||
address os::Linux::ucontext_get_pc(const ucontext_t * uc) {
|
||||
address os::Posix::ucontext_get_pc(const ucontext_t * uc) {
|
||||
return (address)uc->uc_mcontext.psw.addr;
|
||||
}
|
||||
|
||||
void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) {
|
||||
void os::Posix::ucontext_set_pc(ucontext_t * uc, address pc) {
|
||||
uc->uc_mcontext.psw.addr = (unsigned long)pc;
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ address os::fetch_frame_from_context(const void* ucVoid,
|
||||
const ucontext_t* uc = (const ucontext_t*)ucVoid;
|
||||
|
||||
if (uc != NULL) {
|
||||
epc = os::Linux::ucontext_get_pc(uc);
|
||||
epc = os::Posix::ucontext_get_pc(uc);
|
||||
if (ret_sp) { *ret_sp = os::Linux::ucontext_get_sp(uc); }
|
||||
if (ret_fp) { *ret_fp = os::Linux::ucontext_get_fp(uc); }
|
||||
} else {
|
||||
@ -210,9 +210,9 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
// Moved SafeFetch32 handling outside thread!=NULL conditional block to make
|
||||
// it work if no associated JavaThread object exists.
|
||||
if (uc) {
|
||||
address const pc = os::Linux::ucontext_get_pc(uc);
|
||||
address const pc = os::Posix::ucontext_get_pc(uc);
|
||||
if (pc && StubRoutines::is_safefetch_fault(pc)) {
|
||||
os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
|
||||
os::Posix::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -224,7 +224,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
|
||||
//%note os_trap_1
|
||||
if (info != NULL && uc != NULL && thread != NULL) {
|
||||
pc = os::Linux::ucontext_get_pc(uc);
|
||||
pc = os::Posix::ucontext_get_pc(uc);
|
||||
if (TraceTraps) {
|
||||
tty->print_cr(" pc at " INTPTR_FORMAT, p2i(pc));
|
||||
}
|
||||
@ -345,7 +345,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
// continue at the next instruction after the faulting read. Returning
|
||||
// garbage from this read is ok.
|
||||
thread->set_pending_unsafe_access_error();
|
||||
os::Linux::ucontext_set_pc(uc, pc + Assembler::instr_len(pc));
|
||||
os::Posix::ucontext_set_pc(uc, pc + Assembler::instr_len(pc));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -363,12 +363,11 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
if (stub != NULL) {
|
||||
// Save all thread context in case we need to restore it.
|
||||
if (thread != NULL) thread->set_saved_exception_pc(pc);
|
||||
os::Linux::ucontext_set_pc(uc, stub);
|
||||
os::Posix::ucontext_set_pc(uc, stub);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
void os::Linux::init_thread_fpu_state(void) {
|
||||
@ -455,7 +454,7 @@ void os::print_context(outputStream *st, const void *context) {
|
||||
// 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::Linux::ucontext_get_pc(uc);
|
||||
address pc = os::Posix::ucontext_get_pc(uc);
|
||||
print_instructions(st, pc, /*intrsize=*/4);
|
||||
st->cr();
|
||||
}
|
||||
|
@ -106,11 +106,11 @@ char* os::non_memory_address_word() {
|
||||
return (char*) -1;
|
||||
}
|
||||
|
||||
address os::Linux::ucontext_get_pc(const ucontext_t * uc) {
|
||||
address os::Posix::ucontext_get_pc(const ucontext_t * uc) {
|
||||
return (address)uc->uc_mcontext.gregs[REG_PC];
|
||||
}
|
||||
|
||||
void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) {
|
||||
void os::Posix::ucontext_set_pc(ucontext_t * uc, address pc) {
|
||||
uc->uc_mcontext.gregs[REG_PC] = (intptr_t)pc;
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ address os::fetch_frame_from_context(const void* ucVoid,
|
||||
const ucontext_t* uc = (const ucontext_t*)ucVoid;
|
||||
|
||||
if (uc != NULL) {
|
||||
epc = os::Linux::ucontext_get_pc(uc);
|
||||
epc = os::Posix::ucontext_get_pc(uc);
|
||||
if (ret_sp) *ret_sp = os::Linux::ucontext_get_sp(uc);
|
||||
if (ret_fp) *ret_fp = os::Linux::ucontext_get_fp(uc);
|
||||
} else {
|
||||
@ -219,10 +219,10 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
|
||||
//%note os_trap_1
|
||||
if (info != NULL && uc != NULL && thread != NULL) {
|
||||
pc = (address) os::Linux::ucontext_get_pc(uc);
|
||||
pc = (address) os::Posix::ucontext_get_pc(uc);
|
||||
|
||||
if (StubRoutines::is_safefetch_fault(pc)) {
|
||||
os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
|
||||
os::Posix::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -355,7 +355,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
uc->uc_mcontext.gregs[REG_TRAPNO] == trap_page_fault) {
|
||||
int page_size = os::vm_page_size();
|
||||
address addr = (address) info->si_addr;
|
||||
address pc = os::Linux::ucontext_get_pc(uc);
|
||||
address pc = os::Posix::ucontext_get_pc(uc);
|
||||
// Make sure the pc and the faulting address are sane.
|
||||
//
|
||||
// If an instruction spans a page boundary, and the page containing
|
||||
@ -417,7 +417,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
|
||||
// save all thread context in case we need to restore it
|
||||
if (thread != NULL) thread->set_saved_exception_pc(pc);
|
||||
|
||||
os::Linux::ucontext_set_pc(uc, stub);
|
||||
os::Posix::ucontext_set_pc(uc, stub);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -590,7 +590,7 @@ void os::print_context(outputStream *st, const void *context) {
|
||||
// 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::Linux::ucontext_get_pc(uc);
|
||||
address pc = os::Posix::ucontext_get_pc(uc);
|
||||
print_instructions(st, pc, sizeof(char));
|
||||
st->cr();
|
||||
}
|
||||
|
@ -90,12 +90,12 @@ char* os::non_memory_address_word() {
|
||||
return (char *) -1;
|
||||
}
|
||||
|
||||
address os::Linux::ucontext_get_pc(const ucontext_t* uc) {
|
||||
address os::Posix::ucontext_get_pc(const ucontext_t* uc) {
|
||||
ShouldNotCallThis();
|
||||
return NULL; // silence compile warnings
|
||||
}
|
||||
|
||||
void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) {
|
||||
void os::Posix::ucontext_set_pc(ucontext_t * uc, address pc) {
|
||||
ShouldNotCallThis();
|
||||
}
|
||||
|
||||
|
@ -971,7 +971,6 @@ class os: AllStatic {
|
||||
};
|
||||
#endif // !WINDOWS
|
||||
|
||||
|
||||
protected:
|
||||
static volatile unsigned int _rand_seed; // seed for random number generator
|
||||
static int _processor_count; // number of processors
|
||||
|
Loading…
x
Reference in New Issue
Block a user