< prev index next >

src/os/linux/vm/vmError_linux.cpp

Print this page




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "runtime/arguments.hpp"
  27 #include "runtime/os.hpp"
  28 #include "runtime/thread.hpp"
  29 #include "utilities/vmError.hpp"
  30 
  31 #include <sys/types.h>
  32 #include <sys/wait.h>
  33 #include <sys/syscall.h>
  34 #include <unistd.h>
  35 #include <signal.h>
  36 
  37 void VMError::show_message_box(char *buf, int buflen) {

  38   bool yes;
  39   do {
  40     error_string(buf, buflen);
  41     int len = (int)strlen(buf);
  42     char *p = &buf[len];
  43 
  44     jio_snprintf(p, buflen - len,
  45                "\n\n"
  46                "Do you want to debug the problem?\n\n"
  47                "To debug, run 'gdb /proc/%d/exe %d'; then switch to thread " UINTX_FORMAT " (" INTPTR_FORMAT ")\n"
  48                "Enter 'yes' to launch gdb automatically (PATH must include gdb)\n"
  49                "Otherwise, press RETURN to abort...",
  50                os::current_process_id(), os::current_process_id(),
  51                os::current_thread_id(), os::current_thread_id());
  52 
  53     yes = os::message_box("Unexpected Error", buf);
  54 
  55     if (yes) {
  56       // yes, user asked VM to launch debugger
  57       jio_snprintf(buf, buflen, "gdb /proc/%d/exe %d",
  58                    os::current_process_id(), os::current_process_id());
  59 
  60       os::fork_and_exec(buf);


 104 static void crash_handler(int sig, siginfo_t* info, void* ucVoid) {
 105   // unmask current signal
 106   sigset_t newset;
 107   sigemptyset(&newset);
 108   sigaddset(&newset, sig);
 109   // also unmask other synchronous signals
 110   for (int i = 0; i < NUM_SIGNALS; i++) {
 111     sigaddset(&newset, SIGNALS[i]);
 112   }
 113   pthread_sigmask(SIG_UNBLOCK, &newset, NULL);
 114 
 115   // support safefetch faults in error handling
 116   ucontext_t* const uc = (ucontext_t*) ucVoid;
 117   address const pc = uc ? os::Linux::ucontext_get_pc(uc) : NULL;
 118 
 119   if (uc && pc && StubRoutines::is_safefetch_fault(pc)) {
 120     os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
 121     return;
 122   }
 123 
 124   VMError err(NULL, sig, pc, info, ucVoid);
 125   err.report_and_die();
 126 }
 127 
 128 void VMError::reset_signal_handlers() {
 129   // install signal handlers for all synchronous program error signals
 130   sigset_t newset;
 131   sigemptyset(&newset);
 132 
 133   for (int i = 0; i < NUM_SIGNALS; i++) {
 134     save_signal(i, SIGNALS[i]);
 135     os::signal(SIGNALS[i], CAST_FROM_FN_PTR(void *, crash_handler));
 136     sigaddset(&newset, SIGNALS[i]);
 137   }
 138   pthread_sigmask(SIG_UNBLOCK, &newset, NULL);
 139 
 140 }


  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "runtime/arguments.hpp"
  27 #include "runtime/os.hpp"
  28 #include "runtime/thread.hpp"
  29 #include "utilities/vmError.hpp"
  30 
  31 #include <sys/types.h>
  32 #include <sys/wait.h>
  33 #include <sys/syscall.h>
  34 #include <unistd.h>
  35 #include <signal.h>
  36 
  37 void VMError::show_message_box(char *buf, int buflen, int id, const char* message, const char* detail_fmt,
  38                                va_list detail_args, address pc, const char* filename, int lineno) {
  39   bool yes;
  40   do {
  41     error_string(buf, buflen, id, message, detail_fmt, detail_args, pc, filename, lineno);
  42     int len = (int)strlen(buf);
  43     char *p = &buf[len];
  44 
  45     jio_snprintf(p, buflen - len,
  46                "\n\n"
  47                "Do you want to debug the problem?\n\n"
  48                "To debug, run 'gdb /proc/%d/exe %d'; then switch to thread " UINTX_FORMAT " (" INTPTR_FORMAT ")\n"
  49                "Enter 'yes' to launch gdb automatically (PATH must include gdb)\n"
  50                "Otherwise, press RETURN to abort...",
  51                os::current_process_id(), os::current_process_id(),
  52                os::current_thread_id(), os::current_thread_id());
  53 
  54     yes = os::message_box("Unexpected Error", buf);
  55 
  56     if (yes) {
  57       // yes, user asked VM to launch debugger
  58       jio_snprintf(buf, buflen, "gdb /proc/%d/exe %d",
  59                    os::current_process_id(), os::current_process_id());
  60 
  61       os::fork_and_exec(buf);


 105 static void crash_handler(int sig, siginfo_t* info, void* ucVoid) {
 106   // unmask current signal
 107   sigset_t newset;
 108   sigemptyset(&newset);
 109   sigaddset(&newset, sig);
 110   // also unmask other synchronous signals
 111   for (int i = 0; i < NUM_SIGNALS; i++) {
 112     sigaddset(&newset, SIGNALS[i]);
 113   }
 114   pthread_sigmask(SIG_UNBLOCK, &newset, NULL);
 115 
 116   // support safefetch faults in error handling
 117   ucontext_t* const uc = (ucontext_t*) ucVoid;
 118   address const pc = uc ? os::Linux::ucontext_get_pc(uc) : NULL;
 119 
 120   if (uc && pc && StubRoutines::is_safefetch_fault(pc)) {
 121     os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
 122     return;
 123   }
 124 
 125   VMError::report_and_die(NULL, sig, pc, info, ucVoid);

 126 }
 127 
 128 void VMError::reset_signal_handlers() {
 129   // install signal handlers for all synchronous program error signals
 130   sigset_t newset;
 131   sigemptyset(&newset);
 132 
 133   for (int i = 0; i < NUM_SIGNALS; i++) {
 134     save_signal(i, SIGNALS[i]);
 135     os::signal(SIGNALS[i], CAST_FROM_FN_PTR(void *, crash_handler));
 136     sigaddset(&newset, SIGNALS[i]);
 137   }
 138   pthread_sigmask(SIG_UNBLOCK, &newset, NULL);
 139 
 140 }
< prev index next >