comparison src/os/linux/vm/os_linux.cpp @ 14460:8a9bb7821e28

Merge
author kvn
date Wed, 19 Feb 2014 12:08:49 -0800
parents c2626e4f0c80 935bf3340572
children bb9356ec5967
comparison
equal deleted inserted replaced
14360:e8ef156f0bc9 14460:8a9bb7821e28
137 137
138 static int clock_tics_per_sec = 100; 138 static int clock_tics_per_sec = 100;
139 139
140 // For diagnostics to print a message once. see run_periodic_checks 140 // For diagnostics to print a message once. see run_periodic_checks
141 static sigset_t check_signal_done; 141 static sigset_t check_signal_done;
142 static bool check_signals = true;; 142 static bool check_signals = true;
143 143
144 static pid_t _initial_pid = 0; 144 static pid_t _initial_pid = 0;
145 145
146 /* Signal number used to suspend/resume a thread */ 146 /* Signal number used to suspend/resume a thread */
147 147
255 static char cpu_arch[] = "i386"; 255 static char cpu_arch[] = "i386";
256 #elif defined(AMD64) 256 #elif defined(AMD64)
257 static char cpu_arch[] = "amd64"; 257 static char cpu_arch[] = "amd64";
258 #elif defined(ARM) 258 #elif defined(ARM)
259 static char cpu_arch[] = "arm"; 259 static char cpu_arch[] = "arm";
260 #elif defined(PPC) 260 #elif defined(PPC32)
261 static char cpu_arch[] = "ppc"; 261 static char cpu_arch[] = "ppc";
262 #elif defined(PPC64)
263 static char cpu_arch[] = "ppc64";
262 #elif defined(SPARC) 264 #elif defined(SPARC)
263 # ifdef _LP64 265 # ifdef _LP64
264 static char cpu_arch[] = "sparcv9"; 266 static char cpu_arch[] = "sparcv9";
265 # else 267 # else
266 static char cpu_arch[] = "sparc"; 268 static char cpu_arch[] = "sparc";
528 sigemptyset(&allowdebug_blocked_sigs); 530 sigemptyset(&allowdebug_blocked_sigs);
529 sigaddset(&unblocked_sigs, SIGILL); 531 sigaddset(&unblocked_sigs, SIGILL);
530 sigaddset(&unblocked_sigs, SIGSEGV); 532 sigaddset(&unblocked_sigs, SIGSEGV);
531 sigaddset(&unblocked_sigs, SIGBUS); 533 sigaddset(&unblocked_sigs, SIGBUS);
532 sigaddset(&unblocked_sigs, SIGFPE); 534 sigaddset(&unblocked_sigs, SIGFPE);
535 #if defined(PPC64)
536 sigaddset(&unblocked_sigs, SIGTRAP);
537 #endif
533 sigaddset(&unblocked_sigs, SR_signum); 538 sigaddset(&unblocked_sigs, SR_signum);
534 539
535 if (!ReduceSignalUsage) { 540 if (!ReduceSignalUsage) {
536 if (!os::Linux::is_sig_ignored(SHUTDOWN1_SIGNAL)) { 541 if (!os::Linux::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
537 sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL); 542 sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL);
2258 st->print(" <Not Available>"); 2263 st->print(" <Not Available>");
2259 } 2264 }
2260 st->cr(); 2265 st->cr();
2261 } 2266 }
2262 2267
2263 // Taken from /usr/include/bits/siginfo.h Supposed to be architecture specific
2264 // but they're the same for all the linux arch that we support
2265 // and they're the same for solaris but there's no common place to put this.
2266 const char *ill_names[] = { "ILL0", "ILL_ILLOPC", "ILL_ILLOPN", "ILL_ILLADR",
2267 "ILL_ILLTRP", "ILL_PRVOPC", "ILL_PRVREG",
2268 "ILL_COPROC", "ILL_BADSTK" };
2269
2270 const char *fpe_names[] = { "FPE0", "FPE_INTDIV", "FPE_INTOVF", "FPE_FLTDIV",
2271 "FPE_FLTOVF", "FPE_FLTUND", "FPE_FLTRES",
2272 "FPE_FLTINV", "FPE_FLTSUB", "FPE_FLTDEN" };
2273
2274 const char *segv_names[] = { "SEGV0", "SEGV_MAPERR", "SEGV_ACCERR" };
2275
2276 const char *bus_names[] = { "BUS0", "BUS_ADRALN", "BUS_ADRERR", "BUS_OBJERR" };
2277
2278 void os::print_siginfo(outputStream* st, void* siginfo) { 2268 void os::print_siginfo(outputStream* st, void* siginfo) {
2279 st->print("siginfo:"); 2269 const siginfo_t* si = (const siginfo_t*)siginfo;
2280 2270
2281 const int buflen = 100; 2271 os::Posix::print_siginfo_brief(st, si);
2282 char buf[buflen]; 2272
2283 siginfo_t *si = (siginfo_t*)siginfo; 2273 if (si && (si->si_signo == SIGBUS || si->si_signo == SIGSEGV) &&
2284 st->print("si_signo=%s: ", os::exception_name(si->si_signo, buf, buflen));
2285 if (si->si_errno != 0 && strerror_r(si->si_errno, buf, buflen) == 0) {
2286 st->print("si_errno=%s", buf);
2287 } else {
2288 st->print("si_errno=%d", si->si_errno);
2289 }
2290 const int c = si->si_code;
2291 assert(c > 0, "unexpected si_code");
2292 switch (si->si_signo) {
2293 case SIGILL:
2294 st->print(", si_code=%d (%s)", c, c > 8 ? "" : ill_names[c]);
2295 st->print(", si_addr=" PTR_FORMAT, si->si_addr);
2296 break;
2297 case SIGFPE:
2298 st->print(", si_code=%d (%s)", c, c > 9 ? "" : fpe_names[c]);
2299 st->print(", si_addr=" PTR_FORMAT, si->si_addr);
2300 break;
2301 case SIGSEGV:
2302 st->print(", si_code=%d (%s)", c, c > 2 ? "" : segv_names[c]);
2303 st->print(", si_addr=" PTR_FORMAT, si->si_addr);
2304 break;
2305 case SIGBUS:
2306 st->print(", si_code=%d (%s)", c, c > 3 ? "" : bus_names[c]);
2307 st->print(", si_addr=" PTR_FORMAT, si->si_addr);
2308 break;
2309 default:
2310 st->print(", si_code=%d", si->si_code);
2311 // no si_addr
2312 }
2313
2314 if ((si->si_signo == SIGBUS || si->si_signo == SIGSEGV) &&
2315 UseSharedSpaces) { 2274 UseSharedSpaces) {
2316 FileMapInfo* mapinfo = FileMapInfo::current_info(); 2275 FileMapInfo* mapinfo = FileMapInfo::current_info();
2317 if (mapinfo->is_in_shared_space(si->si_addr)) { 2276 if (mapinfo->is_in_shared_space(si->si_addr)) {
2318 st->print("\n\nError accessing class data sharing archive." \ 2277 st->print("\n\nError accessing class data sharing archive." \
2319 " Mapped file inaccessible during execution, " \ 2278 " Mapped file inaccessible during execution, " \
2339 print_signal_handler(st, SR_signum, buf, buflen); 2298 print_signal_handler(st, SR_signum, buf, buflen);
2340 print_signal_handler(st, SHUTDOWN1_SIGNAL, buf, buflen); 2299 print_signal_handler(st, SHUTDOWN1_SIGNAL, buf, buflen);
2341 print_signal_handler(st, SHUTDOWN2_SIGNAL , buf, buflen); 2300 print_signal_handler(st, SHUTDOWN2_SIGNAL , buf, buflen);
2342 print_signal_handler(st, SHUTDOWN3_SIGNAL , buf, buflen); 2301 print_signal_handler(st, SHUTDOWN3_SIGNAL , buf, buflen);
2343 print_signal_handler(st, BREAK_SIGNAL, buf, buflen); 2302 print_signal_handler(st, BREAK_SIGNAL, buf, buflen);
2303 #if defined(PPC64)
2304 print_signal_handler(st, SIGTRAP, buf, buflen);
2305 #endif
2344 } 2306 }
2345 2307
2346 static char saved_jvm_path[MAXPATHLEN] = {0}; 2308 static char saved_jvm_path[MAXPATHLEN] = {0};
2347 2309
2348 // Find the full path to the current module, libjvm.so 2310 // Find the full path to the current module, libjvm.so
4495 set_signal_handler(SIGSEGV, true); 4457 set_signal_handler(SIGSEGV, true);
4496 set_signal_handler(SIGPIPE, true); 4458 set_signal_handler(SIGPIPE, true);
4497 set_signal_handler(SIGBUS, true); 4459 set_signal_handler(SIGBUS, true);
4498 set_signal_handler(SIGILL, true); 4460 set_signal_handler(SIGILL, true);
4499 set_signal_handler(SIGFPE, true); 4461 set_signal_handler(SIGFPE, true);
4462 #if defined(PPC64)
4463 set_signal_handler(SIGTRAP, true);
4464 #endif
4500 set_signal_handler(SIGXFSZ, true); 4465 set_signal_handler(SIGXFSZ, true);
4501 4466
4502 if (libjsig_is_loaded) { 4467 if (libjsig_is_loaded) {
4503 // Tell libjsig jvm finishes setting signal handlers 4468 // Tell libjsig jvm finishes setting signal handlers
4504 (*end_signal_setting)(); 4469 (*end_signal_setting)();
4588 st->print("SIG_IGN"); 4553 st->print("SIG_IGN");
4589 } else { 4554 } else {
4590 st->print("[%s]", get_signal_handler_name(handler, buf, buflen)); 4555 st->print("[%s]", get_signal_handler_name(handler, buf, buflen));
4591 } 4556 }
4592 4557
4593 st->print(", sa_mask[0]=" PTR32_FORMAT, *(uint32_t*)&sa.sa_mask); 4558 st->print(", sa_mask[0]=");
4559 os::Posix::print_signal_set_short(st, &sa.sa_mask);
4594 4560
4595 address rh = VMError::get_resetted_sighandler(sig); 4561 address rh = VMError::get_resetted_sighandler(sig);
4596 // May be, handler was resetted by VMError? 4562 // May be, handler was resetted by VMError?
4597 if(rh != NULL) { 4563 if(rh != NULL) {
4598 handler = rh; 4564 handler = rh;
4599 sa.sa_flags = VMError::get_resetted_sigflags(sig) & SIGNIFICANT_SIGNAL_MASK; 4565 sa.sa_flags = VMError::get_resetted_sigflags(sig) & SIGNIFICANT_SIGNAL_MASK;
4600 } 4566 }
4601 4567
4602 st->print(", sa_flags=" PTR32_FORMAT, sa.sa_flags); 4568 st->print(", sa_flags=");
4569 os::Posix::print_sa_flags(st, sa.sa_flags);
4603 4570
4604 // Check: is it our handler? 4571 // Check: is it our handler?
4605 if(handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler) || 4572 if(handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler) ||
4606 handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler)) { 4573 handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler)) {
4607 // It is our signal handler 4574 // It is our signal handler
4635 DO_SIGNAL_CHECK(SIGILL); 4602 DO_SIGNAL_CHECK(SIGILL);
4636 DO_SIGNAL_CHECK(SIGFPE); 4603 DO_SIGNAL_CHECK(SIGFPE);
4637 DO_SIGNAL_CHECK(SIGBUS); 4604 DO_SIGNAL_CHECK(SIGBUS);
4638 DO_SIGNAL_CHECK(SIGPIPE); 4605 DO_SIGNAL_CHECK(SIGPIPE);
4639 DO_SIGNAL_CHECK(SIGXFSZ); 4606 DO_SIGNAL_CHECK(SIGXFSZ);
4640 4607 #if defined(PPC64)
4608 DO_SIGNAL_CHECK(SIGTRAP);
4609 #endif
4641 4610
4642 // ReduceSignalUsage allows the user to override these handlers 4611 // ReduceSignalUsage allows the user to override these handlers
4643 // see comments at the very top and jvm_solaris.h 4612 // see comments at the very top and jvm_solaris.h
4644 if (!ReduceSignalUsage) { 4613 if (!ReduceSignalUsage) {
4645 DO_SIGNAL_CHECK(SHUTDOWN1_SIGNAL); 4614 DO_SIGNAL_CHECK(SHUTDOWN1_SIGNAL);
4957 4926
4958 // note: perfMemory_exit_helper atexit function may be removed in 4927 // note: perfMemory_exit_helper atexit function may be removed in
4959 // the future if the appropriate cleanup code can be added to the 4928 // the future if the appropriate cleanup code can be added to the
4960 // VM_Exit VMOperation's doit method. 4929 // VM_Exit VMOperation's doit method.
4961 if (atexit(perfMemory_exit_helper) != 0) { 4930 if (atexit(perfMemory_exit_helper) != 0) {
4962 warning("os::init2 atexit(perfMemory_exit_helper) failed"); 4931 warning("os::init_2 atexit(perfMemory_exit_helper) failed");
4963 } 4932 }
4964 } 4933 }
4965 4934
4966 // initialize thread priority policy 4935 // initialize thread priority policy
4967 prio_init(); 4936 prio_init();
4968 4937
4969 return JNI_OK; 4938 return JNI_OK;
4970 } 4939 }
4971 4940
4972 // this is called at the end of vm_initialization 4941 // this is called at the end of vm_initialization
4973 void os::init_3(void) 4942 void os::init_3(void) {
4974 {
4975 #ifdef JAVASE_EMBEDDED 4943 #ifdef JAVASE_EMBEDDED
4976 // Start the MemNotifyThread 4944 // Start the MemNotifyThread
4977 if (LowMemoryProtection) { 4945 if (LowMemoryProtection) {
4978 MemNotifyThread::start(); 4946 MemNotifyThread::start();
4979 } 4947 }