src/os/posix/vm/os_posix.cpp

Mon, 28 Feb 2011 14:19:52 +0100

author
sla
date
Mon, 28 Feb 2011 14:19:52 +0100
changeset 2584
da091bb67459
parent 2520
63d374c54045
child 3379
b16494a69d3d
permissions
-rw-r--r--

7022037: Pause when exiting if debugger is attached on windows
Reviewed-by: dsamersoff, kamg, hosterda

ctornqvi@2520 1 /*
ctornqvi@2520 2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
ctornqvi@2520 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ctornqvi@2520 4 *
ctornqvi@2520 5 * This code is free software; you can redistribute it and/or modify it
ctornqvi@2520 6 * under the terms of the GNU General Public License version 2 only, as
ctornqvi@2520 7 * published by the Free Software Foundation.
ctornqvi@2520 8 *
ctornqvi@2520 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ctornqvi@2520 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ctornqvi@2520 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ctornqvi@2520 12 * version 2 for more details (a copy is included in the LICENSE file that
ctornqvi@2520 13 * accompanied this code).
ctornqvi@2520 14 *
ctornqvi@2520 15 * You should have received a copy of the GNU General Public License version
ctornqvi@2520 16 * 2 along with this work; if not, write to the Free Software Foundation,
ctornqvi@2520 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ctornqvi@2520 18 *
ctornqvi@2520 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ctornqvi@2520 20 * or visit www.oracle.com if you need additional information or have any
ctornqvi@2520 21 * questions.
ctornqvi@2520 22 *
ctornqvi@2520 23 */
ctornqvi@2520 24
ctornqvi@2520 25 #include "prims/jvm.h"
ctornqvi@2520 26 #include "runtime/os.hpp"
ctornqvi@2520 27 #include "utilities/vmError.hpp"
ctornqvi@2520 28
ctornqvi@2520 29 #include <unistd.h>
ctornqvi@2520 30 #include <sys/resource.h>
ctornqvi@2520 31
ctornqvi@2520 32 // Check core dump limit and report possible place where core can be found
ctornqvi@2520 33 void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) {
ctornqvi@2520 34 struct rlimit rlim;
ctornqvi@2520 35 static char cwd[O_BUFLEN];
ctornqvi@2520 36 bool success;
ctornqvi@2520 37
ctornqvi@2520 38 get_current_directory(cwd, sizeof(cwd));
ctornqvi@2520 39
ctornqvi@2520 40 if (getrlimit(RLIMIT_CORE, &rlim) != 0) {
ctornqvi@2520 41 jio_snprintf(buffer, bufferSize, "%s/core or core.%d (may not exist)", cwd, current_process_id());
ctornqvi@2520 42 success = true;
ctornqvi@2520 43 } else {
ctornqvi@2520 44 switch(rlim.rlim_cur) {
ctornqvi@2520 45 case RLIM_INFINITY:
ctornqvi@2520 46 jio_snprintf(buffer, bufferSize, "%s/core or core.%d", cwd, current_process_id());
ctornqvi@2520 47 success = true;
ctornqvi@2520 48 break;
ctornqvi@2520 49 case 0:
ctornqvi@2520 50 jio_snprintf(buffer, bufferSize, "Core dumps have been disabled. To enable core dumping, try \"ulimit -c unlimited\" before starting Java again");
ctornqvi@2520 51 success = false;
ctornqvi@2520 52 break;
ctornqvi@2520 53 default:
ctornqvi@2520 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));
ctornqvi@2520 55 success = true;
ctornqvi@2520 56 break;
ctornqvi@2520 57 }
ctornqvi@2520 58 }
ctornqvi@2520 59 VMError::report_coredump_status(buffer, success);
ctornqvi@2520 60 }
ctornqvi@2520 61
sla@2584 62 bool os::is_debugger_attached() {
sla@2584 63 // not implemented
sla@2584 64 return false;
sla@2584 65 }
sla@2584 66
sla@2584 67 void os::wait_for_keypress_at_exit(void) {
sla@2584 68 // don't do anything on posix platforms
sla@2584 69 return;
sla@2584 70 }

mercurial