Mercurial > hg > truffle
annotate src/os/posix/vm/os_posix.cpp @ 7417:1b1e16471e46
8005002: Crash because of a raw oop in ClassLoaderData::add_dependency
Summary: Move the handelization of 'last' to a point before the GC might enter.
Reviewed-by: dholmes, sspitsyn, coleenp
author | stefank |
---|---|
date | Wed, 12 Dec 2012 22:41:13 +0100 |
parents | b9a9ed0f8eeb |
children | 730cc4ddd550 |
rev | line source |
---|---|
2204 | 1 /* |
6842
b9a9ed0f8eeb
7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents:
6200
diff
changeset
|
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
2204 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 | |
25 #include "prims/jvm.h" | |
6197 | 26 #include "runtime/frame.inline.hpp" |
2204 | 27 #include "runtime/os.hpp" |
28 #include "utilities/vmError.hpp" | |
29 | |
30 #include <unistd.h> | |
31 #include <sys/resource.h> | |
6080
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
32 #include <sys/utsname.h> |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
33 |
2204 | 34 |
35 // Check core dump limit and report possible place where core can be found | |
36 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
|
37 int n; |
2204 | 38 struct rlimit rlim; |
39 bool success; | |
40 | |
6200
65906dc96aa1
7129724: MAC: Core file location is wrong in crash report
mikael
parents:
6197
diff
changeset
|
41 n = get_core_path(buffer, bufferSize); |
2204 | 42 |
43 if (getrlimit(RLIMIT_CORE, &rlim) != 0) { | |
6200
65906dc96aa1
7129724: MAC: Core file location is wrong in crash report
mikael
parents:
6197
diff
changeset
|
44 jio_snprintf(buffer + n, bufferSize - n, "/core or core.%d (may not exist)", current_process_id()); |
2204 | 45 success = true; |
46 } else { | |
47 switch(rlim.rlim_cur) { | |
48 case RLIM_INFINITY: | |
6200
65906dc96aa1
7129724: MAC: Core file location is wrong in crash report
mikael
parents:
6197
diff
changeset
|
49 jio_snprintf(buffer + n, bufferSize - n, "/core or core.%d", current_process_id()); |
2204 | 50 success = true; |
51 break; | |
52 case 0: | |
53 jio_snprintf(buffer, bufferSize, "Core dumps have been disabled. To enable core dumping, try \"ulimit -c unlimited\" before starting Java again"); | |
54 success = false; | |
55 break; | |
56 default: | |
6200
65906dc96aa1
7129724: MAC: Core file location is wrong in crash report
mikael
parents:
6197
diff
changeset
|
57 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 | 58 success = true; |
59 break; | |
60 } | |
61 } | |
62 VMError::report_coredump_status(buffer, success); | |
63 } | |
64 | |
6197 | 65 address os::get_caller_pc(int n) { |
66 #ifdef _NMT_NOINLINE_ | |
67 n ++; | |
68 #endif | |
69 frame fr = os::current_frame(); | |
70 while (n > 0 && fr.pc() && | |
71 !os::is_first_C_frame(&fr) && fr.sender_pc()) { | |
72 fr = os::get_sender_for_C_frame(&fr); | |
73 n --; | |
74 } | |
75 if (n == 0) { | |
76 return fr.pc(); | |
77 } else { | |
78 return NULL; | |
79 } | |
80 } | |
81 | |
4750
b16494a69d3d
7126185: Clean up lasterror handling, add os::get_last_error()
phh
parents:
2302
diff
changeset
|
82 int os::get_last_error() { |
b16494a69d3d
7126185: Clean up lasterror handling, add os::get_last_error()
phh
parents:
2302
diff
changeset
|
83 return errno; |
b16494a69d3d
7126185: Clean up lasterror handling, add os::get_last_error()
phh
parents:
2302
diff
changeset
|
84 } |
b16494a69d3d
7126185: Clean up lasterror handling, add os::get_last_error()
phh
parents:
2302
diff
changeset
|
85 |
2302
da091bb67459
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
2204
diff
changeset
|
86 bool os::is_debugger_attached() { |
da091bb67459
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
2204
diff
changeset
|
87 // not implemented |
da091bb67459
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
2204
diff
changeset
|
88 return false; |
da091bb67459
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
2204
diff
changeset
|
89 } |
da091bb67459
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
2204
diff
changeset
|
90 |
da091bb67459
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
2204
diff
changeset
|
91 void os::wait_for_keypress_at_exit(void) { |
da091bb67459
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
2204
diff
changeset
|
92 // don't do anything on posix platforms |
da091bb67459
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
2204
diff
changeset
|
93 return; |
da091bb67459
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
2204
diff
changeset
|
94 } |
6080
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
95 |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
96 void os::Posix::print_load_average(outputStream* st) { |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
97 st->print("load average:"); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
98 double loadavg[3]; |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
99 os::loadavg(loadavg, 3); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
100 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
|
101 st->cr(); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
102 } |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
103 |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
104 void os::Posix::print_rlimit_info(outputStream* st) { |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
105 st->print("rlimit:"); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
106 struct rlimit rlim; |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
107 |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
108 st->print(" STACK "); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
109 getrlimit(RLIMIT_STACK, &rlim); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
110 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
|
111 else st->print("%uk", rlim.rlim_cur >> 10); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
112 |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
113 st->print(", CORE "); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
114 getrlimit(RLIMIT_CORE, &rlim); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
115 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
|
116 else st->print("%uk", rlim.rlim_cur >> 10); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
117 |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
118 //Isn't there on solaris |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
119 #ifndef TARGET_OS_FAMILY_solaris |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
120 st->print(", NPROC "); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
121 getrlimit(RLIMIT_NPROC, &rlim); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
122 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
|
123 else st->print("%d", rlim.rlim_cur); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
124 #endif |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
125 |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
126 st->print(", NOFILE "); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
127 getrlimit(RLIMIT_NOFILE, &rlim); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
128 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
|
129 else st->print("%d", rlim.rlim_cur); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
130 |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
131 st->print(", AS "); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
132 getrlimit(RLIMIT_AS, &rlim); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
133 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
|
134 else st->print("%uk", rlim.rlim_cur >> 10); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
135 st->cr(); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
136 } |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
137 |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
138 void os::Posix::print_uname_info(outputStream* st) { |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
139 // kernel |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
140 st->print("uname:"); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
141 struct utsname name; |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
142 uname(&name); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
143 st->print(name.sysname); st->print(" "); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
144 st->print(name.release); st->print(" "); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
145 st->print(name.version); st->print(" "); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
146 st->print(name.machine); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
147 st->cr(); |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
148 } |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
149 |
7432b9db36ff
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
4750
diff
changeset
|
150 |