annotate src/os/aix/vm/vmError_aix.cpp @ 21947:9f70fc90169d

Truffle: remove expensive assertion
author Andreas Woess <andreas.woess@oracle.com>
date Wed, 17 Jun 2015 04:09:30 +0200
parents 666e6ce3976c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
1 /*
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
4 *
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
7 * published by the Free Software Foundation.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
8 *
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
13 * accompanied this code).
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
14 *
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
18 *
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
21 * questions.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
22 *
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
23 */
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
24
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
25 #include "precompiled.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
26 #include "runtime/arguments.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
27 #include "runtime/os.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
28 #include "runtime/thread.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
29 #include "utilities/vmError.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
30
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
31 #include <sys/types.h>
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
32 #include <sys/wait.h>
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
33 #include <unistd.h>
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
34 #include <signal.h>
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
35
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
36 void VMError::show_message_box(char *buf, int buflen) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
37 bool yes;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
38 do {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
39 error_string(buf, buflen);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
40 int len = (int)strlen(buf);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
41 char *p = &buf[len];
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
42
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
43 jio_snprintf(p, buflen - len,
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
44 "\n\n"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
45 "Do you want to debug the problem?\n\n"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
46 "To debug, run 'dbx -a %d'; then switch to thread tid " INTX_FORMAT ", k-tid " INTX_FORMAT "\n"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
47 "Enter 'yes' to launch dbx automatically (PATH must include dbx)\n"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
48 "Otherwise, press RETURN to abort...",
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
49 os::current_process_id(),
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
50 os::current_thread_id(), thread_self());
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
51
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
52 yes = os::message_box("Unexpected Error", buf);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
53
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
54 if (yes) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
55 // yes, user asked VM to launch debugger
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
56 jio_snprintf(buf, buflen, "dbx -a %d", os::current_process_id());
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
57
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
58 os::fork_and_exec(buf);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
59 yes = false;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
60 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
61 } while (yes);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
62 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
63
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
64 // Handle all synchronous signals which may happen during signal handling,
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
65 // not just SIGSEGV and SIGBUS.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
66 static const int SIGNALS[] = { SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP }; // add more if needed
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
67 static const int NUM_SIGNALS = sizeof(SIGNALS) / sizeof(int);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
68
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
69 // Space for our "saved" signal flags and handlers
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
70 static int resettedSigflags[NUM_SIGNALS];
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
71 static address resettedSighandler[NUM_SIGNALS];
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
72
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
73 static void save_signal(int idx, int sig) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
74 struct sigaction sa;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
75 sigaction(sig, NULL, &sa);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
76 resettedSigflags[idx] = sa.sa_flags;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
77 resettedSighandler[idx] = (sa.sa_flags & SA_SIGINFO)
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
78 ? CAST_FROM_FN_PTR(address, sa.sa_sigaction)
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
79 : CAST_FROM_FN_PTR(address, sa.sa_handler);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
80 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
81
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
82 int VMError::get_resetted_sigflags(int sig) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
83 // Handle all program errors.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
84 for (int i = 0; i < NUM_SIGNALS; i++) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
85 if (SIGNALS[i] == sig) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
86 return resettedSigflags[i];
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
87 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
88 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
89 return -1;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
90 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
91
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
92 address VMError::get_resetted_sighandler(int sig) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
93 // Handle all program errors.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
94 for (int i = 0; i < NUM_SIGNALS; i++) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
95 if (SIGNALS[i] == sig) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
96 return resettedSighandler[i];
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
97 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
98 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
99 return NULL;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
100 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
101
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
102 static void crash_handler(int sig, siginfo_t* info, void* ucVoid) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
103 // Unmask current signal.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
104 sigset_t newset;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
105 sigemptyset(&newset);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
106 sigaddset(&newset, sig);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
107
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
108 Unimplemented();
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
109 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
110
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
111 void VMError::reset_signal_handlers() {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
112 sigset_t newset;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
113 sigemptyset(&newset);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
114
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
115 for (int i = 0; i < NUM_SIGNALS; i++) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
116 save_signal(i, SIGNALS[i]);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
117 os::signal(SIGNALS[i], CAST_FROM_FN_PTR(void *, crash_handler));
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
118 sigaddset(&newset, SIGNALS[i]);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
119 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
120
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
121 sigthreadmask(SIG_UNBLOCK, &newset, NULL);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
122 }