408 #undef EXTENSIONS_DIR 409 } 410 411 //////////////////////////////////////////////////////////////////////////////// 412 // breakpoint support 413 414 void os::breakpoint() { 415 BREAKPOINT; 416 } 417 418 extern "C" void breakpoint() { 419 // use debugger to set breakpoint here 420 } 421 422 //////////////////////////////////////////////////////////////////////////////// 423 // signal support 424 425 debug_only(static bool signal_sets_initialized = false); 426 static sigset_t unblocked_sigs, vm_sigs; 427 428 bool os::Linux::is_sig_ignored(int sig) { 429 struct sigaction oact; 430 sigaction(sig, (struct sigaction*)NULL, &oact); 431 void* ohlr = oact.sa_sigaction ? CAST_FROM_FN_PTR(void*, oact.sa_sigaction) 432 : CAST_FROM_FN_PTR(void*, oact.sa_handler); 433 if (ohlr == CAST_FROM_FN_PTR(void*, SIG_IGN)) { 434 return true; 435 } else { 436 return false; 437 } 438 } 439 440 void os::Linux::signal_sets_init() { 441 // Should also have an assertion stating we are still single-threaded. 442 assert(!signal_sets_initialized, "Already initialized"); 443 // Fill in signals that are necessarily unblocked for all threads in 444 // the VM. Currently, we unblock the following signals: 445 // SHUTDOWN{1,2,3}_SIGNAL: for shutdown hooks support (unless over-ridden 446 // by -Xrs (=ReduceSignalUsage)); 447 // BREAK_SIGNAL which is unblocked only by the VM thread and blocked by all 448 // other threads. The "ReduceSignalUsage" boolean tells us not to alter 449 // the dispositions or masks wrt these signals. 450 // Programs embedding the VM that want to use the above signals for their 451 // own purposes must, at this time, use the "-Xrs" option to prevent 452 // interference with shutdown hooks and BREAK_SIGNAL thread dumping. 453 // (See bug 4345157, and other related bugs). 454 // In reality, though, unblocking these signals is really a nop, since 455 // these signals are not blocked by default. 456 sigemptyset(&unblocked_sigs); 457 sigaddset(&unblocked_sigs, SIGILL); 458 sigaddset(&unblocked_sigs, SIGSEGV); 459 sigaddset(&unblocked_sigs, SIGBUS); 460 sigaddset(&unblocked_sigs, SIGFPE); 461 #if defined(PPC64) 462 sigaddset(&unblocked_sigs, SIGTRAP); 463 #endif 464 sigaddset(&unblocked_sigs, SR_signum); 465 466 if (!ReduceSignalUsage) { 467 if (!os::Linux::is_sig_ignored(SHUTDOWN1_SIGNAL)) { 468 sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL); 469 } 470 if (!os::Linux::is_sig_ignored(SHUTDOWN2_SIGNAL)) { 471 sigaddset(&unblocked_sigs, SHUTDOWN2_SIGNAL); 472 } 473 if (!os::Linux::is_sig_ignored(SHUTDOWN3_SIGNAL)) { 474 sigaddset(&unblocked_sigs, SHUTDOWN3_SIGNAL); 475 } 476 } 477 // Fill in signals that are blocked by all but the VM thread. 478 sigemptyset(&vm_sigs); 479 if (!ReduceSignalUsage) { 480 sigaddset(&vm_sigs, BREAK_SIGNAL); 481 } 482 debug_only(signal_sets_initialized = true); 483 484 } 485 486 // These are signals that are unblocked while a thread is running Java. 487 // (For some reason, they get blocked by default.) 488 sigset_t* os::Linux::unblocked_signals() { 489 assert(signal_sets_initialized, "Not initialized"); 490 return &unblocked_sigs; 491 } 492 493 // These are the signals that are blocked while a (non-VM) thread is | 408 #undef EXTENSIONS_DIR 409 } 410 411 //////////////////////////////////////////////////////////////////////////////// 412 // breakpoint support 413 414 void os::breakpoint() { 415 BREAKPOINT; 416 } 417 418 extern "C" void breakpoint() { 419 // use debugger to set breakpoint here 420 } 421 422 //////////////////////////////////////////////////////////////////////////////// 423 // signal support 424 425 debug_only(static bool signal_sets_initialized = false); 426 static sigset_t unblocked_sigs, vm_sigs; 427 428 void os::Linux::signal_sets_init() { 429 // Should also have an assertion stating we are still single-threaded. 430 assert(!signal_sets_initialized, "Already initialized"); 431 // Fill in signals that are necessarily unblocked for all threads in 432 // the VM. Currently, we unblock the following signals: 433 // SHUTDOWN{1,2,3}_SIGNAL: for shutdown hooks support (unless over-ridden 434 // by -Xrs (=ReduceSignalUsage)); 435 // BREAK_SIGNAL which is unblocked only by the VM thread and blocked by all 436 // other threads. The "ReduceSignalUsage" boolean tells us not to alter 437 // the dispositions or masks wrt these signals. 438 // Programs embedding the VM that want to use the above signals for their 439 // own purposes must, at this time, use the "-Xrs" option to prevent 440 // interference with shutdown hooks and BREAK_SIGNAL thread dumping. 441 // (See bug 4345157, and other related bugs). 442 // In reality, though, unblocking these signals is really a nop, since 443 // these signals are not blocked by default. 444 sigemptyset(&unblocked_sigs); 445 sigaddset(&unblocked_sigs, SIGILL); 446 sigaddset(&unblocked_sigs, SIGSEGV); 447 sigaddset(&unblocked_sigs, SIGBUS); 448 sigaddset(&unblocked_sigs, SIGFPE); 449 #if defined(PPC64) 450 sigaddset(&unblocked_sigs, SIGTRAP); 451 #endif 452 sigaddset(&unblocked_sigs, SR_signum); 453 454 if (!ReduceSignalUsage) { 455 if (!os::Posix::is_sig_ignored(SHUTDOWN1_SIGNAL)) { 456 sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL); 457 } 458 if (!os::Posix::is_sig_ignored(SHUTDOWN2_SIGNAL)) { 459 sigaddset(&unblocked_sigs, SHUTDOWN2_SIGNAL); 460 } 461 if (!os::Posix::is_sig_ignored(SHUTDOWN3_SIGNAL)) { 462 sigaddset(&unblocked_sigs, SHUTDOWN3_SIGNAL); 463 } 464 } 465 // Fill in signals that are blocked by all but the VM thread. 466 sigemptyset(&vm_sigs); 467 if (!ReduceSignalUsage) { 468 sigaddset(&vm_sigs, BREAK_SIGNAL); 469 } 470 debug_only(signal_sets_initialized = true); 471 472 } 473 474 // These are signals that are unblocked while a thread is running Java. 475 // (For some reason, they get blocked by default.) 476 sigset_t* os::Linux::unblocked_signals() { 477 assert(signal_sets_initialized, "Not initialized"); 478 return &unblocked_sigs; 479 } 480 481 // These are the signals that are blocked while a (non-VM) thread is |