1054 return Bsd::ucontext_get_pc(ctx);
1055 #else
1056 VMError::report_and_die("unimplemented ucontext_get_pc");
1057 #endif
1058 }
1059
1060 void os::Posix::ucontext_set_pc(ucontext_t* ctx, address pc) {
1061 #ifdef TARGET_OS_FAMILY_linux
1062 Linux::ucontext_set_pc(ctx, pc);
1063 #elif defined(TARGET_OS_FAMILY_solaris)
1064 Solaris::ucontext_set_pc(ctx, pc);
1065 #elif defined(TARGET_OS_FAMILY_aix)
1066 Aix::ucontext_set_pc(ctx, pc);
1067 #elif defined(TARGET_OS_FAMILY_bsd)
1068 Bsd::ucontext_set_pc(ctx, pc);
1069 #else
1070 VMError::report_and_die("unimplemented ucontext_get_pc");
1071 #endif
1072 }
1073
1074
1075 os::WatcherThreadCrashProtection::WatcherThreadCrashProtection() {
1076 assert(Thread::current()->is_Watcher_thread(), "Must be WatcherThread");
1077 }
1078
1079 /*
1080 * See the caveats for this class in os_posix.hpp
1081 * Protects the callback call so that SIGSEGV / SIGBUS jumps back into this
1082 * method and returns false. If none of the signals are raised, returns true.
1083 * The callback is supposed to provide the method that should be protected.
1084 */
1085 bool os::WatcherThreadCrashProtection::call(os::CrashProtectionCallback& cb) {
1086 sigset_t saved_sig_mask;
1087
1088 assert(Thread::current()->is_Watcher_thread(), "Only for WatcherThread");
1089 assert(!WatcherThread::watcher_thread()->has_crash_protection(),
1090 "crash_protection already set?");
1091
1092 // we cannot rely on sigsetjmp/siglongjmp to save/restore the signal mask
1093 // since on at least some systems (OS X) siglongjmp will restore the mask
|
1054 return Bsd::ucontext_get_pc(ctx);
1055 #else
1056 VMError::report_and_die("unimplemented ucontext_get_pc");
1057 #endif
1058 }
1059
1060 void os::Posix::ucontext_set_pc(ucontext_t* ctx, address pc) {
1061 #ifdef TARGET_OS_FAMILY_linux
1062 Linux::ucontext_set_pc(ctx, pc);
1063 #elif defined(TARGET_OS_FAMILY_solaris)
1064 Solaris::ucontext_set_pc(ctx, pc);
1065 #elif defined(TARGET_OS_FAMILY_aix)
1066 Aix::ucontext_set_pc(ctx, pc);
1067 #elif defined(TARGET_OS_FAMILY_bsd)
1068 Bsd::ucontext_set_pc(ctx, pc);
1069 #else
1070 VMError::report_and_die("unimplemented ucontext_get_pc");
1071 #endif
1072 }
1073
1074 char* os::Posix::describe_pthread_attr(char* buf, size_t buflen, const pthread_attr_t* attr) {
1075 size_t stack_size = 0;
1076 size_t guard_size = 0;
1077 int detachstate = 0;
1078 pthread_attr_getstacksize(attr, &stack_size);
1079 pthread_attr_getguardsize(attr, &guard_size);
1080 pthread_attr_getdetachstate(attr, &detachstate);
1081 jio_snprintf(buf, buflen, "stacksize: " SIZE_FORMAT "k, guardsize: " SIZE_FORMAT "k, %s",
1082 stack_size / 1024, guard_size / 1024,
1083 (detachstate == PTHREAD_CREATE_DETACHED ? "detached" : "joinable"));
1084 return buf;
1085 }
1086
1087
1088 os::WatcherThreadCrashProtection::WatcherThreadCrashProtection() {
1089 assert(Thread::current()->is_Watcher_thread(), "Must be WatcherThread");
1090 }
1091
1092 /*
1093 * See the caveats for this class in os_posix.hpp
1094 * Protects the callback call so that SIGSEGV / SIGBUS jumps back into this
1095 * method and returns false. If none of the signals are raised, returns true.
1096 * The callback is supposed to provide the method that should be protected.
1097 */
1098 bool os::WatcherThreadCrashProtection::call(os::CrashProtectionCallback& cb) {
1099 sigset_t saved_sig_mask;
1100
1101 assert(Thread::current()->is_Watcher_thread(), "Only for WatcherThread");
1102 assert(!WatcherThread::watcher_thread()->has_crash_protection(),
1103 "crash_protection already set?");
1104
1105 // we cannot rely on sigsetjmp/siglongjmp to save/restore the signal mask
1106 // since on at least some systems (OS X) siglongjmp will restore the mask
|