Mercurial > hg > graal-compiler
annotate src/os/solaris/vm/vmError_solaris.cpp @ 1725:09cdb1e1c77b
Merge
author | trims |
---|---|
date | Fri, 20 Aug 2010 04:08:08 -0700 |
parents | c18cbe5936b8 |
children | f95d63e2154a |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
2 * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 # include "incls/_precompiled.incl" | |
26 # include "incls/_vmError_solaris.cpp.incl" | |
27 | |
28 #include <sys/types.h> | |
29 #include <sys/wait.h> | |
30 #include <signal.h> | |
31 | |
32 void VMError::show_message_box(char *buf, int buflen) { | |
33 bool yes; | |
34 do { | |
35 error_string(buf, buflen); | |
36 int len = (int)strlen(buf); | |
37 char *p = &buf[len]; | |
38 | |
39 jio_snprintf(p, buflen - len, | |
40 "\n\n" | |
41 "Do you want to debug the problem?\n\n" | |
42 "To debug, run 'dbx - %d'; then switch to thread " INTX_FORMAT "\n" | |
43 "Enter 'yes' to launch dbx automatically (PATH must include dbx)\n" | |
44 "Otherwise, press RETURN to abort...", | |
45 os::current_process_id(), os::current_thread_id()); | |
46 | |
47 yes = os::message_box("Unexpected Error", buf); | |
48 | |
49 if (yes) { | |
50 // yes, user asked VM to launch debugger | |
51 jio_snprintf(buf, buflen, "dbx - %d", os::current_process_id()); | |
52 | |
53 os::fork_and_exec(buf); | |
54 yes = false; | |
55 } | |
56 } while (yes); | |
57 } | |
58 | |
59 // Space for our "saved" signal flags and handlers | |
60 static int resettedSigflags[2]; | |
61 static address resettedSighandler[2]; | |
62 | |
63 static void save_signal(int idx, int sig) | |
64 { | |
65 struct sigaction sa; | |
66 sigaction(sig, NULL, &sa); | |
67 resettedSigflags[idx] = sa.sa_flags; | |
68 resettedSighandler[idx] = (sa.sa_flags & SA_SIGINFO) | |
69 ? CAST_FROM_FN_PTR(address, sa.sa_sigaction) | |
70 : CAST_FROM_FN_PTR(address, sa.sa_handler); | |
71 } | |
72 | |
73 int VMError::get_resetted_sigflags(int sig) { | |
74 if(SIGSEGV == sig) { | |
75 return resettedSigflags[0]; | |
76 } else if(SIGBUS == sig) { | |
77 return resettedSigflags[1]; | |
78 } | |
79 return -1; | |
80 } | |
81 | |
82 address VMError::get_resetted_sighandler(int sig) { | |
83 if(SIGSEGV == sig) { | |
84 return resettedSighandler[0]; | |
85 } else if(SIGBUS == sig) { | |
86 return resettedSighandler[1]; | |
87 } | |
88 return NULL; | |
89 } | |
90 | |
91 static void crash_handler(int sig, siginfo_t* info, void* ucVoid) { | |
92 // unmask current signal | |
93 sigset_t newset; | |
94 sigemptyset(&newset); | |
95 sigaddset(&newset, sig); | |
96 sigprocmask(SIG_UNBLOCK, &newset, NULL); | |
97 | |
98 VMError err(NULL, sig, NULL, info, ucVoid); | |
99 err.report_and_die(); | |
100 } | |
101 | |
102 void VMError::reset_signal_handlers() { | |
103 // Save sigflags for resetted signals | |
104 save_signal(0, SIGSEGV); | |
105 save_signal(1, SIGBUS); | |
106 os::signal(SIGSEGV, CAST_FROM_FN_PTR(void *, crash_handler)); | |
107 os::signal(SIGBUS, CAST_FROM_FN_PTR(void *, crash_handler)); | |
108 } |