annotate src/os/posix/vm/os_posix.cpp @ 20338:8d5f66b42c53

8055525: Bigapp weblogic+medrec fails to startup after JDK-8038423 Summary: If large pages are enabled and configured in Linux, the VM always pre-commits the entire space. The VM fails verification of the commit of the initial heap because some internal data structure marked all memory pages of the heap as committed during initialization. This makes the code think that we attempted a double-commit during first allocation of the heap. Remove the initial marking of memory pages of the heap to committed. Reviewed-by: mgerdin
author tschatzl
date Wed, 20 Aug 2014 14:34:40 +0200
parents 78bbf4d43a14
children 52b4284cb496 833b0f92429a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2204
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
1 /*
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17805
diff changeset
2 * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
14410
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
4 *
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
7 * published by the Free Software Foundation.
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
8 *
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
13 * accompanied this code).
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
14 *
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
15 * You should have received a copy of the GNU General Public License version
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
18 *
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
21 * questions.
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
22 *
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
23 */
2204
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
24
14410
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
25 #include "utilities/globalDefinitions.hpp"
2204
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
26 #include "prims/jvm.h"
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6080
diff changeset
27 #include "runtime/frame.inline.hpp"
2204
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
28 #include "runtime/os.hpp"
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
29 #include "utilities/vmError.hpp"
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
30
14410
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
31 #include <signal.h>
2204
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
32 #include <unistd.h>
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
33 #include <sys/resource.h>
6080
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
34 #include <sys/utsname.h>
12141
cc56f122f3f7 8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents: 11151
diff changeset
35 #include <pthread.h>
cc56f122f3f7 8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents: 11151
diff changeset
36 #include <signal.h>
6080
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
37
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17805
diff changeset
38 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17805
diff changeset
39
14410
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
40 // Todo: provide a os::get_max_process_id() or similar. Number of processes
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
41 // may have been configured, can be read more accurately from proc fs etc.
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
42 #ifndef MAX_PID
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
43 #define MAX_PID INT_MAX
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
44 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
45 #define IS_VALID_PID(p) (p > 0 && p < MAX_PID)
2204
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
46
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
47 // Check core dump limit and report possible place where core can be found
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
48 void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) {
6200
65906dc96aa1 7129724: MAC: Core file location is wrong in crash report
mikael
parents: 6197
diff changeset
49 int n;
2204
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
50 struct rlimit rlim;
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
51 bool success;
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
52
6200
65906dc96aa1 7129724: MAC: Core file location is wrong in crash report
mikael
parents: 6197
diff changeset
53 n = get_core_path(buffer, bufferSize);
2204
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
54
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
55 if (getrlimit(RLIMIT_CORE, &rlim) != 0) {
6200
65906dc96aa1 7129724: MAC: Core file location is wrong in crash report
mikael
parents: 6197
diff changeset
56 jio_snprintf(buffer + n, bufferSize - n, "/core or core.%d (may not exist)", current_process_id());
2204
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
57 success = true;
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
58 } else {
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
59 switch(rlim.rlim_cur) {
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
60 case RLIM_INFINITY:
6200
65906dc96aa1 7129724: MAC: Core file location is wrong in crash report
mikael
parents: 6197
diff changeset
61 jio_snprintf(buffer + n, bufferSize - n, "/core or core.%d", current_process_id());
2204
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
62 success = true;
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
63 break;
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
64 case 0:
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
65 jio_snprintf(buffer, bufferSize, "Core dumps have been disabled. To enable core dumping, try \"ulimit -c unlimited\" before starting Java again");
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
66 success = false;
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
67 break;
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
68 default:
6200
65906dc96aa1 7129724: MAC: Core file location is wrong in crash report
mikael
parents: 6197
diff changeset
69 jio_snprintf(buffer + n, bufferSize - n, "/core or core.%d (max size %lu kB). To ensure a full core dump, try \"ulimit -c unlimited\" before starting Java again", current_process_id(), (unsigned long)(rlim.rlim_cur >> 10));
2204
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
70 success = true;
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
71 break;
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
72 }
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
73 }
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
74 VMError::report_coredump_status(buffer, success);
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
75 }
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
76
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6080
diff changeset
77 address os::get_caller_pc(int n) {
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6080
diff changeset
78 #ifdef _NMT_NOINLINE_
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6080
diff changeset
79 n ++;
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6080
diff changeset
80 #endif
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6080
diff changeset
81 frame fr = os::current_frame();
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6080
diff changeset
82 while (n > 0 && fr.pc() &&
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6080
diff changeset
83 !os::is_first_C_frame(&fr) && fr.sender_pc()) {
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6080
diff changeset
84 fr = os::get_sender_for_C_frame(&fr);
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6080
diff changeset
85 n --;
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6080
diff changeset
86 }
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6080
diff changeset
87 if (n == 0) {
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6080
diff changeset
88 return fr.pc();
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6080
diff changeset
89 } else {
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6080
diff changeset
90 return NULL;
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6080
diff changeset
91 }
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6080
diff changeset
92 }
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6080
diff changeset
93
4750
b16494a69d3d 7126185: Clean up lasterror handling, add os::get_last_error()
phh
parents: 2302
diff changeset
94 int os::get_last_error() {
b16494a69d3d 7126185: Clean up lasterror handling, add os::get_last_error()
phh
parents: 2302
diff changeset
95 return errno;
b16494a69d3d 7126185: Clean up lasterror handling, add os::get_last_error()
phh
parents: 2302
diff changeset
96 }
b16494a69d3d 7126185: Clean up lasterror handling, add os::get_last_error()
phh
parents: 2302
diff changeset
97
2302
da091bb67459 7022037: Pause when exiting if debugger is attached on windows
sla
parents: 2204
diff changeset
98 bool os::is_debugger_attached() {
da091bb67459 7022037: Pause when exiting if debugger is attached on windows
sla
parents: 2204
diff changeset
99 // not implemented
da091bb67459 7022037: Pause when exiting if debugger is attached on windows
sla
parents: 2204
diff changeset
100 return false;
da091bb67459 7022037: Pause when exiting if debugger is attached on windows
sla
parents: 2204
diff changeset
101 }
da091bb67459 7022037: Pause when exiting if debugger is attached on windows
sla
parents: 2204
diff changeset
102
da091bb67459 7022037: Pause when exiting if debugger is attached on windows
sla
parents: 2204
diff changeset
103 void os::wait_for_keypress_at_exit(void) {
da091bb67459 7022037: Pause when exiting if debugger is attached on windows
sla
parents: 2204
diff changeset
104 // don't do anything on posix platforms
da091bb67459 7022037: Pause when exiting if debugger is attached on windows
sla
parents: 2204
diff changeset
105 return;
da091bb67459 7022037: Pause when exiting if debugger is attached on windows
sla
parents: 2204
diff changeset
106 }
6080
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
107
7433
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
108 // Multiple threads can race in this code, and can remap over each other with MAP_FIXED,
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
109 // so on posix, unmap the section at the start and at the end of the chunk that we mapped
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
110 // rather than unmapping and remapping the whole chunk to get requested alignment.
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
111 char* os::reserve_memory_aligned(size_t size, size_t alignment) {
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
112 assert((alignment & (os::vm_allocation_granularity() - 1)) == 0,
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
113 "Alignment must be a multiple of allocation granularity (page size)");
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
114 assert((size & (alignment -1)) == 0, "size must be 'alignment' aligned");
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
115
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
116 size_t extra_size = size + alignment;
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
117 assert(extra_size >= size, "overflow, size is too large to allow alignment");
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
118
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
119 char* extra_base = os::reserve_memory(extra_size, NULL, alignment);
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
120
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
121 if (extra_base == NULL) {
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
122 return NULL;
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
123 }
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
124
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
125 // Do manual alignment
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
126 char* aligned_base = (char*) align_size_up((uintptr_t) extra_base, alignment);
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
127
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
128 // [ | | ]
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
129 // ^ extra_base
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
130 // ^ extra_base + begin_offset == aligned_base
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
131 // extra_base + begin_offset + size ^
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
132 // extra_base + extra_size ^
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
133 // |<>| == begin_offset
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
134 // end_offset == |<>|
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
135 size_t begin_offset = aligned_base - extra_base;
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
136 size_t end_offset = (extra_base + extra_size) - (aligned_base + size);
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
137
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
138 if (begin_offset > 0) {
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
139 os::release_memory(extra_base, begin_offset);
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
140 }
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
141
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
142 if (end_offset > 0) {
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
143 os::release_memory(extra_base + begin_offset + size, end_offset);
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
144 }
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
145
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
146 return aligned_base;
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
147 }
730cc4ddd550 7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents: 6842
diff changeset
148
6080
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
149 void os::Posix::print_load_average(outputStream* st) {
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
150 st->print("load average:");
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
151 double loadavg[3];
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
152 os::loadavg(loadavg, 3);
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
153 st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]);
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
154 st->cr();
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
155 }
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
156
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
157 void os::Posix::print_rlimit_info(outputStream* st) {
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
158 st->print("rlimit:");
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
159 struct rlimit rlim;
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
160
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
161 st->print(" STACK ");
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
162 getrlimit(RLIMIT_STACK, &rlim);
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
163 if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
164 else st->print("%uk", rlim.rlim_cur >> 10);
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
165
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
166 st->print(", CORE ");
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
167 getrlimit(RLIMIT_CORE, &rlim);
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
168 if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
169 else st->print("%uk", rlim.rlim_cur >> 10);
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
170
14410
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
171 // Isn't there on solaris
14412
kvn
parents: 14411 12117
diff changeset
172 #if !defined(TARGET_OS_FAMILY_solaris) && !defined(TARGET_OS_FAMILY_aix)
6080
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
173 st->print(", NPROC ");
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
174 getrlimit(RLIMIT_NPROC, &rlim);
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
175 if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
176 else st->print("%d", rlim.rlim_cur);
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
177 #endif
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
178
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
179 st->print(", NOFILE ");
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
180 getrlimit(RLIMIT_NOFILE, &rlim);
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
181 if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
182 else st->print("%d", rlim.rlim_cur);
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
183
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
184 st->print(", AS ");
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
185 getrlimit(RLIMIT_AS, &rlim);
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
186 if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
187 else st->print("%uk", rlim.rlim_cur >> 10);
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
188 st->cr();
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
189 }
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
190
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
191 void os::Posix::print_uname_info(outputStream* st) {
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
192 // kernel
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
193 st->print("uname:");
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
194 struct utsname name;
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
195 uname(&name);
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17805
diff changeset
196 st->print("%s ", name.sysname);
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17805
diff changeset
197 st->print("%s ", name.release);
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17805
diff changeset
198 st->print("%s ", name.version);
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17805
diff changeset
199 st->print("%s", name.machine);
6080
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
200 st->cr();
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
201 }
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
202
8854
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
203 bool os::has_allocatable_memory_limit(julong* limit) {
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
204 struct rlimit rlim;
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
205 int getrlimit_res = getrlimit(RLIMIT_AS, &rlim);
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
206 // if there was an error when calling getrlimit, assume that there is no limitation
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
207 // on virtual memory.
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
208 bool result;
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
209 if ((getrlimit_res != 0) || (rlim.rlim_cur == RLIM_INFINITY)) {
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
210 result = false;
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
211 } else {
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
212 *limit = (julong)rlim.rlim_cur;
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
213 result = true;
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
214 }
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
215 #ifdef _LP64
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
216 return result;
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
217 #else
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
218 // arbitrary virtual space limit for 32 bit Unices found by testing. If
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
219 // getrlimit above returned a limit, bound it with this limit. Otherwise
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
220 // directly use it.
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
221 const julong max_virtual_limit = (julong)3800*M;
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
222 if (result) {
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
223 *limit = MIN2(*limit, max_virtual_limit);
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
224 } else {
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
225 *limit = max_virtual_limit;
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
226 }
6080
7432b9db36ff 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 4750
diff changeset
227
8854
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
228 // bound by actually allocatable memory. The algorithm uses two bounds, an
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
229 // upper and a lower limit. The upper limit is the current highest amount of
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
230 // memory that could not be allocated, the lower limit is the current highest
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
231 // amount of memory that could be allocated.
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
232 // The algorithm iteratively refines the result by halving the difference
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
233 // between these limits, updating either the upper limit (if that value could
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
234 // not be allocated) or the lower limit (if the that value could be allocated)
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
235 // until the difference between these limits is "small".
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
236
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
237 // the minimum amount of memory we care about allocating.
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
238 const julong min_allocation_size = M;
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
239
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
240 julong upper_limit = *limit;
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
241
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
242 // first check a few trivial cases
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
243 if (is_allocatable(upper_limit) || (upper_limit <= min_allocation_size)) {
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
244 *limit = upper_limit;
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
245 } else if (!is_allocatable(min_allocation_size)) {
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
246 // we found that not even min_allocation_size is allocatable. Return it
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
247 // anyway. There is no point to search for a better value any more.
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
248 *limit = min_allocation_size;
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
249 } else {
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
250 // perform the binary search.
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
251 julong lower_limit = min_allocation_size;
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
252 while ((upper_limit - lower_limit) > min_allocation_size) {
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
253 julong temp_limit = ((upper_limit - lower_limit) / 2) + lower_limit;
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
254 temp_limit = align_size_down_(temp_limit, min_allocation_size);
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
255 if (is_allocatable(temp_limit)) {
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
256 lower_limit = temp_limit;
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
257 } else {
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
258 upper_limit = temp_limit;
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
259 }
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
260 }
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
261 *limit = lower_limit;
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
262 }
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
263 return true;
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
264 #endif
754c24457b20 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents: 7433
diff changeset
265 }
10195
e12c9b3740db 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 8854
diff changeset
266
e12c9b3740db 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 8854
diff changeset
267 const char* os::get_current_directory(char *buf, size_t buflen) {
e12c9b3740db 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 8854
diff changeset
268 return getcwd(buf, buflen);
e12c9b3740db 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 8854
diff changeset
269 }
e12c9b3740db 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 8854
diff changeset
270
e12c9b3740db 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 8854
diff changeset
271 FILE* os::open(int fd, const char* mode) {
e12c9b3740db 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 8854
diff changeset
272 return ::fdopen(fd, mode);
e12c9b3740db 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 8854
diff changeset
273 }
11151
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
274
12117
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
275 // Builds a platform dependent Agent_OnLoad_<lib_name> function name
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
276 // which is used to find statically linked in agents.
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
277 // Parameters:
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
278 // sym_name: Symbol in library we are looking for
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
279 // lib_name: Name of library to look in, NULL for shared libs.
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
280 // is_absolute_path == true if lib_name is absolute path to agent
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
281 // such as "/a/b/libL.so"
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
282 // == false if only the base name of the library is passed in
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
283 // such as "L"
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
284 char* os::build_agent_function_name(const char *sym_name, const char *lib_name,
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
285 bool is_absolute_path) {
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
286 char *agent_entry_name;
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
287 size_t len;
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
288 size_t name_len;
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
289 size_t prefix_len = strlen(JNI_LIB_PREFIX);
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
290 size_t suffix_len = strlen(JNI_LIB_SUFFIX);
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
291 const char *start;
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
292
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
293 if (lib_name != NULL) {
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
294 len = name_len = strlen(lib_name);
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
295 if (is_absolute_path) {
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
296 // Need to strip path, prefix and suffix
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
297 if ((start = strrchr(lib_name, *os::file_separator())) != NULL) {
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
298 lib_name = ++start;
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
299 }
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
300 if (len <= (prefix_len + suffix_len)) {
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
301 return NULL;
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
302 }
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
303 lib_name += prefix_len;
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
304 name_len = strlen(lib_name) - suffix_len;
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
305 }
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
306 }
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
307 len = (lib_name != NULL ? name_len : 0) + strlen(sym_name) + 2;
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
308 agent_entry_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, len, mtThread);
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
309 if (agent_entry_name == NULL) {
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
310 return NULL;
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
311 }
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
312 strcpy(agent_entry_name, sym_name);
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
313 if (lib_name != NULL) {
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
314 strcat(agent_entry_name, "_");
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
315 strncat(agent_entry_name, lib_name, name_len);
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
316 }
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
317 return agent_entry_name;
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
318 }
f92b82d454fa 8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents: 11151
diff changeset
319
14410
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
320 // Returned string is a constant. For unknown signals "UNKNOWN" is returned.
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
321 const char* os::Posix::get_signal_name(int sig, char* out, size_t outlen) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
322
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
323 static const struct {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
324 int sig; const char* name;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
325 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
326 info[] =
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
327 {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
328 { SIGABRT, "SIGABRT" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
329 #ifdef SIGAIO
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
330 { SIGAIO, "SIGAIO" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
331 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
332 { SIGALRM, "SIGALRM" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
333 #ifdef SIGALRM1
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
334 { SIGALRM1, "SIGALRM1" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
335 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
336 { SIGBUS, "SIGBUS" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
337 #ifdef SIGCANCEL
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
338 { SIGCANCEL, "SIGCANCEL" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
339 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
340 { SIGCHLD, "SIGCHLD" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
341 #ifdef SIGCLD
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
342 { SIGCLD, "SIGCLD" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
343 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
344 { SIGCONT, "SIGCONT" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
345 #ifdef SIGCPUFAIL
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
346 { SIGCPUFAIL, "SIGCPUFAIL" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
347 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
348 #ifdef SIGDANGER
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
349 { SIGDANGER, "SIGDANGER" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
350 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
351 #ifdef SIGDIL
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
352 { SIGDIL, "SIGDIL" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
353 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
354 #ifdef SIGEMT
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
355 { SIGEMT, "SIGEMT" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
356 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
357 { SIGFPE, "SIGFPE" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
358 #ifdef SIGFREEZE
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
359 { SIGFREEZE, "SIGFREEZE" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
360 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
361 #ifdef SIGGFAULT
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
362 { SIGGFAULT, "SIGGFAULT" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
363 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
364 #ifdef SIGGRANT
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
365 { SIGGRANT, "SIGGRANT" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
366 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
367 { SIGHUP, "SIGHUP" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
368 { SIGILL, "SIGILL" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
369 { SIGINT, "SIGINT" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
370 #ifdef SIGIO
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
371 { SIGIO, "SIGIO" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
372 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
373 #ifdef SIGIOINT
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
374 { SIGIOINT, "SIGIOINT" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
375 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
376 #ifdef SIGIOT
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
377 // SIGIOT is there for BSD compatibility, but on most Unices just a
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
378 // synonym for SIGABRT. The result should be "SIGABRT", not
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
379 // "SIGIOT".
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
380 #if (SIGIOT != SIGABRT )
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
381 { SIGIOT, "SIGIOT" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
382 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
383 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
384 #ifdef SIGKAP
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
385 { SIGKAP, "SIGKAP" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
386 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
387 { SIGKILL, "SIGKILL" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
388 #ifdef SIGLOST
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
389 { SIGLOST, "SIGLOST" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
390 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
391 #ifdef SIGLWP
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
392 { SIGLWP, "SIGLWP" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
393 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
394 #ifdef SIGLWPTIMER
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
395 { SIGLWPTIMER, "SIGLWPTIMER" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
396 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
397 #ifdef SIGMIGRATE
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
398 { SIGMIGRATE, "SIGMIGRATE" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
399 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
400 #ifdef SIGMSG
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
401 { SIGMSG, "SIGMSG" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
402 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
403 { SIGPIPE, "SIGPIPE" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
404 #ifdef SIGPOLL
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
405 { SIGPOLL, "SIGPOLL" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
406 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
407 #ifdef SIGPRE
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
408 { SIGPRE, "SIGPRE" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
409 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
410 { SIGPROF, "SIGPROF" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
411 #ifdef SIGPTY
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
412 { SIGPTY, "SIGPTY" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
413 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
414 #ifdef SIGPWR
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
415 { SIGPWR, "SIGPWR" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
416 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
417 { SIGQUIT, "SIGQUIT" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
418 #ifdef SIGRECONFIG
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
419 { SIGRECONFIG, "SIGRECONFIG" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
420 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
421 #ifdef SIGRECOVERY
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
422 { SIGRECOVERY, "SIGRECOVERY" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
423 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
424 #ifdef SIGRESERVE
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
425 { SIGRESERVE, "SIGRESERVE" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
426 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
427 #ifdef SIGRETRACT
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
428 { SIGRETRACT, "SIGRETRACT" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
429 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
430 #ifdef SIGSAK
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
431 { SIGSAK, "SIGSAK" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
432 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
433 { SIGSEGV, "SIGSEGV" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
434 #ifdef SIGSOUND
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
435 { SIGSOUND, "SIGSOUND" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
436 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
437 { SIGSTOP, "SIGSTOP" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
438 { SIGSYS, "SIGSYS" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
439 #ifdef SIGSYSERROR
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
440 { SIGSYSERROR, "SIGSYSERROR" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
441 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
442 #ifdef SIGTALRM
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
443 { SIGTALRM, "SIGTALRM" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
444 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
445 { SIGTERM, "SIGTERM" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
446 #ifdef SIGTHAW
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
447 { SIGTHAW, "SIGTHAW" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
448 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
449 { SIGTRAP, "SIGTRAP" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
450 #ifdef SIGTSTP
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
451 { SIGTSTP, "SIGTSTP" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
452 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
453 { SIGTTIN, "SIGTTIN" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
454 { SIGTTOU, "SIGTTOU" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
455 #ifdef SIGURG
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
456 { SIGURG, "SIGURG" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
457 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
458 { SIGUSR1, "SIGUSR1" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
459 { SIGUSR2, "SIGUSR2" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
460 #ifdef SIGVIRT
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
461 { SIGVIRT, "SIGVIRT" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
462 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
463 { SIGVTALRM, "SIGVTALRM" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
464 #ifdef SIGWAITING
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
465 { SIGWAITING, "SIGWAITING" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
466 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
467 #ifdef SIGWINCH
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
468 { SIGWINCH, "SIGWINCH" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
469 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
470 #ifdef SIGWINDOW
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
471 { SIGWINDOW, "SIGWINDOW" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
472 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
473 { SIGXCPU, "SIGXCPU" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
474 { SIGXFSZ, "SIGXFSZ" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
475 #ifdef SIGXRES
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
476 { SIGXRES, "SIGXRES" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
477 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
478 { -1, NULL }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
479 };
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
480
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
481 const char* ret = NULL;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
482
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
483 #ifdef SIGRTMIN
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
484 if (sig >= SIGRTMIN && sig <= SIGRTMAX) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
485 if (sig == SIGRTMIN) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
486 ret = "SIGRTMIN";
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
487 } else if (sig == SIGRTMAX) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
488 ret = "SIGRTMAX";
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
489 } else {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
490 jio_snprintf(out, outlen, "SIGRTMIN+%d", sig - SIGRTMIN);
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
491 return out;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
492 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
493 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
494 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
495
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
496 if (sig > 0) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
497 for (int idx = 0; info[idx].sig != -1; idx ++) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
498 if (info[idx].sig == sig) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
499 ret = info[idx].name;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
500 break;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
501 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
502 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
503 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
504
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
505 if (!ret) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
506 if (!is_valid_signal(sig)) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
507 ret = "INVALID";
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
508 } else {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
509 ret = "UNKNOWN";
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
510 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
511 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
512
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
513 jio_snprintf(out, outlen, ret);
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
514 return out;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
515 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
516
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
517 // Returns true if signal number is valid.
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
518 bool os::Posix::is_valid_signal(int sig) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
519 // MacOS not really POSIX compliant: sigaddset does not return
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
520 // an error for invalid signal numbers. However, MacOS does not
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
521 // support real time signals and simply seems to have just 33
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
522 // signals with no holes in the signal range.
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
523 #ifdef __APPLE__
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
524 return sig >= 1 && sig < NSIG;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
525 #else
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
526 // Use sigaddset to check for signal validity.
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
527 sigset_t set;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
528 if (sigaddset(&set, sig) == -1 && errno == EINVAL) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
529 return false;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
530 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
531 return true;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
532 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
533 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
534
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
535 #define NUM_IMPORTANT_SIGS 32
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
536 // Returns one-line short description of a signal set in a user provided buffer.
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
537 const char* os::Posix::describe_signal_set_short(const sigset_t* set, char* buffer, size_t buf_size) {
14411
bdd155477289 8023033: PPC64 (part 13): basic changes for AIX
goetz
parents: 14410
diff changeset
538 assert(buf_size == (NUM_IMPORTANT_SIGS + 1), "wrong buffer size");
14410
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
539 // Note: for shortness, just print out the first 32. That should
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
540 // cover most of the useful ones, apart from realtime signals.
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
541 for (int sig = 1; sig <= NUM_IMPORTANT_SIGS; sig++) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
542 const int rc = sigismember(set, sig);
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
543 if (rc == -1 && errno == EINVAL) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
544 buffer[sig-1] = '?';
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
545 } else {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
546 buffer[sig-1] = rc == 0 ? '0' : '1';
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
547 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
548 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
549 buffer[NUM_IMPORTANT_SIGS] = 0;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
550 return buffer;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
551 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
552
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
553 // Prints one-line description of a signal set.
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
554 void os::Posix::print_signal_set_short(outputStream* st, const sigset_t* set) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
555 char buf[NUM_IMPORTANT_SIGS + 1];
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
556 os::Posix::describe_signal_set_short(set, buf, sizeof(buf));
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17805
diff changeset
557 st->print("%s", buf);
14410
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
558 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
559
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
560 // Writes one-line description of a combination of sigaction.sa_flags into a user
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
561 // provided buffer. Returns that buffer.
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
562 const char* os::Posix::describe_sa_flags(int flags, char* buffer, size_t size) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
563 char* p = buffer;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
564 size_t remaining = size;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
565 bool first = true;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
566 int idx = 0;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
567
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
568 assert(buffer, "invalid argument");
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
569
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
570 if (size == 0) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
571 return buffer;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
572 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
573
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
574 strncpy(buffer, "none", size);
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
575
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
576 const struct {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
577 int i;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
578 const char* s;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
579 } flaginfo [] = {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
580 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
581 { SA_ONSTACK, "SA_ONSTACK" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
582 { SA_RESETHAND, "SA_RESETHAND" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
583 { SA_RESTART, "SA_RESTART" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
584 { SA_SIGINFO, "SA_SIGINFO" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
585 { SA_NOCLDWAIT, "SA_NOCLDWAIT" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
586 { SA_NODEFER, "SA_NODEFER" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
587 #ifdef AIX
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
588 { SA_ONSTACK, "SA_ONSTACK" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
589 { SA_OLDSTYLE, "SA_OLDSTYLE" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
590 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
591 { 0, NULL }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
592 };
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
593
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
594 for (idx = 0; flaginfo[idx].s && remaining > 1; idx++) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
595 if (flags & flaginfo[idx].i) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
596 if (first) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
597 jio_snprintf(p, remaining, "%s", flaginfo[idx].s);
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
598 first = false;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
599 } else {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
600 jio_snprintf(p, remaining, "|%s", flaginfo[idx].s);
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
601 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
602 const size_t len = strlen(p);
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
603 p += len;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
604 remaining -= len;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
605 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
606 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
607
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
608 buffer[size - 1] = '\0';
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
609
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
610 return buffer;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
611 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
612
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
613 // Prints one-line description of a combination of sigaction.sa_flags.
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
614 void os::Posix::print_sa_flags(outputStream* st, int flags) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
615 char buffer[0x100];
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
616 os::Posix::describe_sa_flags(flags, buffer, sizeof(buffer));
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17805
diff changeset
617 st->print("%s", buffer);
14410
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
618 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
619
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
620 // Helper function for os::Posix::print_siginfo_...():
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
621 // return a textual description for signal code.
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
622 struct enum_sigcode_desc_t {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
623 const char* s_name;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
624 const char* s_desc;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
625 };
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
626
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
627 static bool get_signal_code_description(const siginfo_t* si, enum_sigcode_desc_t* out) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
628
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
629 const struct {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
630 int sig; int code; const char* s_code; const char* s_desc;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
631 } t1 [] = {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
632 { SIGILL, ILL_ILLOPC, "ILL_ILLOPC", "Illegal opcode." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
633 { SIGILL, ILL_ILLOPN, "ILL_ILLOPN", "Illegal operand." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
634 { SIGILL, ILL_ILLADR, "ILL_ILLADR", "Illegal addressing mode." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
635 { SIGILL, ILL_ILLTRP, "ILL_ILLTRP", "Illegal trap." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
636 { SIGILL, ILL_PRVOPC, "ILL_PRVOPC", "Privileged opcode." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
637 { SIGILL, ILL_PRVREG, "ILL_PRVREG", "Privileged register." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
638 { SIGILL, ILL_COPROC, "ILL_COPROC", "Coprocessor error." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
639 { SIGILL, ILL_BADSTK, "ILL_BADSTK", "Internal stack error." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
640 #if defined(IA64) && defined(LINUX)
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
641 { SIGILL, ILL_BADIADDR, "ILL_BADIADDR", "Unimplemented instruction address" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
642 { SIGILL, ILL_BREAK, "ILL_BREAK", "Application Break instruction" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
643 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
644 { SIGFPE, FPE_INTDIV, "FPE_INTDIV", "Integer divide by zero." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
645 { SIGFPE, FPE_INTOVF, "FPE_INTOVF", "Integer overflow." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
646 { SIGFPE, FPE_FLTDIV, "FPE_FLTDIV", "Floating-point divide by zero." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
647 { SIGFPE, FPE_FLTOVF, "FPE_FLTOVF", "Floating-point overflow." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
648 { SIGFPE, FPE_FLTUND, "FPE_FLTUND", "Floating-point underflow." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
649 { SIGFPE, FPE_FLTRES, "FPE_FLTRES", "Floating-point inexact result." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
650 { SIGFPE, FPE_FLTINV, "FPE_FLTINV", "Invalid floating-point operation." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
651 { SIGFPE, FPE_FLTSUB, "FPE_FLTSUB", "Subscript out of range." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
652 { SIGSEGV, SEGV_MAPERR, "SEGV_MAPERR", "Address not mapped to object." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
653 { SIGSEGV, SEGV_ACCERR, "SEGV_ACCERR", "Invalid permissions for mapped object." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
654 #ifdef AIX
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
655 // no explanation found what keyerr would be
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
656 { SIGSEGV, SEGV_KEYERR, "SEGV_KEYERR", "key error" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
657 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
658 #if defined(IA64) && !defined(AIX)
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
659 { SIGSEGV, SEGV_PSTKOVF, "SEGV_PSTKOVF", "Paragraph stack overflow" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
660 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
661 { SIGBUS, BUS_ADRALN, "BUS_ADRALN", "Invalid address alignment." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
662 { SIGBUS, BUS_ADRERR, "BUS_ADRERR", "Nonexistent physical address." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
663 { SIGBUS, BUS_OBJERR, "BUS_OBJERR", "Object-specific hardware error." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
664 { SIGTRAP, TRAP_BRKPT, "TRAP_BRKPT", "Process breakpoint." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
665 { SIGTRAP, TRAP_TRACE, "TRAP_TRACE", "Process trace trap." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
666 { SIGCHLD, CLD_EXITED, "CLD_EXITED", "Child has exited." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
667 { SIGCHLD, CLD_KILLED, "CLD_KILLED", "Child has terminated abnormally and did not create a core file." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
668 { SIGCHLD, CLD_DUMPED, "CLD_DUMPED", "Child has terminated abnormally and created a core file." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
669 { SIGCHLD, CLD_TRAPPED, "CLD_TRAPPED", "Traced child has trapped." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
670 { SIGCHLD, CLD_STOPPED, "CLD_STOPPED", "Child has stopped." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
671 { SIGCHLD, CLD_CONTINUED,"CLD_CONTINUED","Stopped child has continued." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
672 #ifdef SIGPOLL
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
673 { SIGPOLL, POLL_OUT, "POLL_OUT", "Output buffers available." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
674 { SIGPOLL, POLL_MSG, "POLL_MSG", "Input message available." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
675 { SIGPOLL, POLL_ERR, "POLL_ERR", "I/O error." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
676 { SIGPOLL, POLL_PRI, "POLL_PRI", "High priority input available." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
677 { SIGPOLL, POLL_HUP, "POLL_HUP", "Device disconnected. [Option End]" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
678 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
679 { -1, -1, NULL, NULL }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
680 };
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
681
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
682 // Codes valid in any signal context.
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
683 const struct {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
684 int code; const char* s_code; const char* s_desc;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
685 } t2 [] = {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
686 { SI_USER, "SI_USER", "Signal sent by kill()." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
687 { SI_QUEUE, "SI_QUEUE", "Signal sent by the sigqueue()." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
688 { SI_TIMER, "SI_TIMER", "Signal generated by expiration of a timer set by timer_settime()." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
689 { SI_ASYNCIO, "SI_ASYNCIO", "Signal generated by completion of an asynchronous I/O request." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
690 { SI_MESGQ, "SI_MESGQ", "Signal generated by arrival of a message on an empty message queue." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
691 // Linux specific
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
692 #ifdef SI_TKILL
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
693 { SI_TKILL, "SI_TKILL", "Signal sent by tkill (pthread_kill)" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
694 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
695 #ifdef SI_DETHREAD
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
696 { SI_DETHREAD, "SI_DETHREAD", "Signal sent by execve() killing subsidiary threads" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
697 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
698 #ifdef SI_KERNEL
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
699 { SI_KERNEL, "SI_KERNEL", "Signal sent by kernel." },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
700 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
701 #ifdef SI_SIGIO
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
702 { SI_SIGIO, "SI_SIGIO", "Signal sent by queued SIGIO" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
703 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
704
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
705 #ifdef AIX
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
706 { SI_UNDEFINED, "SI_UNDEFINED","siginfo contains partial information" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
707 { SI_EMPTY, "SI_EMPTY", "siginfo contains no useful information" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
708 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
709
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
710 #ifdef __sun
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
711 { SI_NOINFO, "SI_NOINFO", "No signal information" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
712 { SI_RCTL, "SI_RCTL", "kernel generated signal via rctl action" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
713 { SI_LWP, "SI_LWP", "Signal sent via lwp_kill" },
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
714 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
715
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
716 { -1, NULL, NULL }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
717 };
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
718
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
719 const char* s_code = NULL;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
720 const char* s_desc = NULL;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
721
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
722 for (int i = 0; t1[i].sig != -1; i ++) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
723 if (t1[i].sig == si->si_signo && t1[i].code == si->si_code) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
724 s_code = t1[i].s_code;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
725 s_desc = t1[i].s_desc;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
726 break;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
727 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
728 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
729
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
730 if (s_code == NULL) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
731 for (int i = 0; t2[i].s_code != NULL; i ++) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
732 if (t2[i].code == si->si_code) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
733 s_code = t2[i].s_code;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
734 s_desc = t2[i].s_desc;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
735 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
736 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
737 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
738
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
739 if (s_code == NULL) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
740 out->s_name = "unknown";
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
741 out->s_desc = "unknown";
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
742 return false;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
743 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
744
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
745 out->s_name = s_code;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
746 out->s_desc = s_desc;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
747
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
748 return true;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
749 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
750
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
751 // A POSIX conform, platform-independend siginfo print routine.
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
752 // Short print out on one line.
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
753 void os::Posix::print_siginfo_brief(outputStream* os, const siginfo_t* si) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
754 char buf[20];
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
755 os->print("siginfo: ");
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
756
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
757 if (!si) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
758 os->print("<null>");
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
759 return;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
760 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
761
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
762 // See print_siginfo_full() for details.
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
763 const int sig = si->si_signo;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
764
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
765 os->print("si_signo: %d (%s)", sig, os::Posix::get_signal_name(sig, buf, sizeof(buf)));
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
766
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
767 enum_sigcode_desc_t ed;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
768 if (get_signal_code_description(si, &ed)) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
769 os->print(", si_code: %d (%s)", si->si_code, ed.s_name);
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
770 } else {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
771 os->print(", si_code: %d (unknown)", si->si_code);
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
772 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
773
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
774 if (si->si_errno) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
775 os->print(", si_errno: %d", si->si_errno);
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
776 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
777
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
778 const int me = (int) ::getpid();
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
779 const int pid = (int) si->si_pid;
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
780
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
781 if (si->si_code == SI_USER || si->si_code == SI_QUEUE) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
782 if (IS_VALID_PID(pid) && pid != me) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
783 os->print(", sent from pid: %d (uid: %d)", pid, (int) si->si_uid);
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
784 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
785 } else if (sig == SIGSEGV || sig == SIGBUS || sig == SIGILL ||
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
786 sig == SIGTRAP || sig == SIGFPE) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
787 os->print(", si_addr: " PTR_FORMAT, si->si_addr);
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
788 #ifdef SIGPOLL
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
789 } else if (sig == SIGPOLL) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
790 os->print(", si_band: " PTR64_FORMAT, (uint64_t)si->si_band);
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
791 #endif
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
792 } else if (sig == SIGCHLD) {
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
793 os->print_cr(", si_pid: %d, si_uid: %d, si_status: %d", (int) si->si_pid, si->si_uid, si->si_status);
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
794 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
795 }
f42f2e2a1518 8020775: PPC64 (part 12): posix signal printing
goetz
parents: 11151
diff changeset
796
11151
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
797 os::WatcherThreadCrashProtection::WatcherThreadCrashProtection() {
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
798 assert(Thread::current()->is_Watcher_thread(), "Must be WatcherThread");
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
799 }
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
800
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
801 /*
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
802 * See the caveats for this class in os_posix.hpp
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
803 * Protects the callback call so that SIGSEGV / SIGBUS jumps back into this
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
804 * method and returns false. If none of the signals are raised, returns true.
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
805 * The callback is supposed to provide the method that should be protected.
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
806 */
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
807 bool os::WatcherThreadCrashProtection::call(os::CrashProtectionCallback& cb) {
12141
cc56f122f3f7 8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents: 11151
diff changeset
808 sigset_t saved_sig_mask;
cc56f122f3f7 8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents: 11151
diff changeset
809
11151
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
810 assert(Thread::current()->is_Watcher_thread(), "Only for WatcherThread");
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
811 assert(!WatcherThread::watcher_thread()->has_crash_protection(),
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
812 "crash_protection already set?");
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
813
12141
cc56f122f3f7 8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents: 11151
diff changeset
814 // we cannot rely on sigsetjmp/siglongjmp to save/restore the signal mask
cc56f122f3f7 8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents: 11151
diff changeset
815 // since on at least some systems (OS X) siglongjmp will restore the mask
cc56f122f3f7 8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents: 11151
diff changeset
816 // for the process, not the thread
cc56f122f3f7 8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents: 11151
diff changeset
817 pthread_sigmask(0, NULL, &saved_sig_mask);
cc56f122f3f7 8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents: 11151
diff changeset
818 if (sigsetjmp(_jmpbuf, 0) == 0) {
11151
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
819 // make sure we can see in the signal handler that we have crash protection
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
820 // installed
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
821 WatcherThread::watcher_thread()->set_crash_protection(this);
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
822 cb.call();
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
823 // and clear the crash protection
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
824 WatcherThread::watcher_thread()->set_crash_protection(NULL);
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
825 return true;
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
826 }
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
827 // this happens when we siglongjmp() back
12141
cc56f122f3f7 8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents: 11151
diff changeset
828 pthread_sigmask(SIG_SETMASK, &saved_sig_mask, NULL);
11151
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
829 WatcherThread::watcher_thread()->set_crash_protection(NULL);
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
830 return false;
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
831 }
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
832
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
833 void os::WatcherThreadCrashProtection::restore() {
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
834 assert(WatcherThread::watcher_thread()->has_crash_protection(),
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
835 "must have crash protection");
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
836
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
837 siglongjmp(_jmpbuf, 1);
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
838 }
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
839
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
840 void os::WatcherThreadCrashProtection::check_crash_protection(int sig,
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
841 Thread* thread) {
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
842
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
843 if (thread != NULL &&
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
844 thread->is_Watcher_thread() &&
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
845 WatcherThread::watcher_thread()->has_crash_protection()) {
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
846
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
847 if (sig == SIGSEGV || sig == SIGBUS) {
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
848 WatcherThread::watcher_thread()->crash_protection()->restore();
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
849 }
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
850 }
5e3b6f79d280 8020701: Avoid crashes in WatcherThread
rbackman
parents: 10195
diff changeset
851 }