annotate src/os/posix/vm/os_posix.cpp @ 2204:63d374c54045

7014918: Improve core/minidump handling in Hotspot Summary: Added Minidump support on Windows, enabled large page core dumps when coredump_filter is present and writing out path/rlimit for core dumps. Reviewed-by: poonam, dsamersoff, sla, coleenp
author ctornqvi
date Wed, 09 Feb 2011 11:08:10 +0100
parents
children da091bb67459
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 /*
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
4 *
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
7 * published by the Free Software Foundation.
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
8 *
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
13 * accompanied this code).
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
14 *
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
18 *
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
21 * questions.
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
22 *
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
23 */
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
24
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
25 #include "prims/jvm.h"
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
26 #include "runtime/os.hpp"
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
27 #include "utilities/vmError.hpp"
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
28
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
29 #include <unistd.h>
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
30 #include <sys/resource.h>
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
31
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
32 // 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
33 void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) {
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
34 struct rlimit rlim;
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
35 static char cwd[O_BUFLEN];
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
36 bool success;
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
37
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
38 get_current_directory(cwd, sizeof(cwd));
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
39
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
40 if (getrlimit(RLIMIT_CORE, &rlim) != 0) {
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
41 jio_snprintf(buffer, bufferSize, "%s/core or core.%d (may not exist)", cwd, current_process_id());
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
42 success = true;
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
43 } else {
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
44 switch(rlim.rlim_cur) {
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
45 case RLIM_INFINITY:
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
46 jio_snprintf(buffer, bufferSize, "%s/core or core.%d", cwd, current_process_id());
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
47 success = true;
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
48 break;
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
49 case 0:
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
50 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
51 success = false;
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
52 break;
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
53 default:
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
54 jio_snprintf(buffer, bufferSize, "%s/core or core.%d (max size %lu kB). To ensure a full core dump, try \"ulimit -c unlimited\" before starting Java again", cwd, current_process_id(), (unsigned long)(rlim.rlim_cur >> 10));
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
55 success = true;
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
56 break;
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
57 }
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
58 }
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
59 VMError::report_coredump_status(buffer, success);
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
60 }
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
diff changeset
61