src/os/posix/vm/os_posix.cpp

Tue, 03 Jul 2012 17:35:00 -0700

author
mikael
date
Tue, 03 Jul 2012 17:35:00 -0700
changeset 3903
65906dc96aa1
parent 3900
d2a62e0f25eb
child 4153
b9a9ed0f8eeb
permissions
-rw-r--r--

7129724: MAC: Core file location is wrong in crash report
Summary: Updated core path location to reflect macosx default
Reviewed-by: dholmes, kamg

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"
zgu@3900 26 #include "runtime/frame.inline.hpp"
ctornqvi@2520 27 #include "runtime/os.hpp"
ctornqvi@2520 28 #include "utilities/vmError.hpp"
ctornqvi@2520 29
ctornqvi@2520 30 #include <unistd.h>
ctornqvi@2520 31 #include <sys/resource.h>
nloodin@3783 32 #include <sys/utsname.h>
nloodin@3783 33
ctornqvi@2520 34
ctornqvi@2520 35 // Check core dump limit and report possible place where core can be found
ctornqvi@2520 36 void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) {
mikael@3903 37 int n;
ctornqvi@2520 38 struct rlimit rlim;
ctornqvi@2520 39 bool success;
ctornqvi@2520 40
mikael@3903 41 n = get_core_path(buffer, bufferSize);
ctornqvi@2520 42
ctornqvi@2520 43 if (getrlimit(RLIMIT_CORE, &rlim) != 0) {
mikael@3903 44 jio_snprintf(buffer + n, bufferSize - n, "/core or core.%d (may not exist)", current_process_id());
ctornqvi@2520 45 success = true;
ctornqvi@2520 46 } else {
ctornqvi@2520 47 switch(rlim.rlim_cur) {
ctornqvi@2520 48 case RLIM_INFINITY:
mikael@3903 49 jio_snprintf(buffer + n, bufferSize - n, "/core or core.%d", current_process_id());
ctornqvi@2520 50 success = true;
ctornqvi@2520 51 break;
ctornqvi@2520 52 case 0:
ctornqvi@2520 53 jio_snprintf(buffer, bufferSize, "Core dumps have been disabled. To enable core dumping, try \"ulimit -c unlimited\" before starting Java again");
ctornqvi@2520 54 success = false;
ctornqvi@2520 55 break;
ctornqvi@2520 56 default:
mikael@3903 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));
ctornqvi@2520 58 success = true;
ctornqvi@2520 59 break;
ctornqvi@2520 60 }
ctornqvi@2520 61 }
ctornqvi@2520 62 VMError::report_coredump_status(buffer, success);
ctornqvi@2520 63 }
ctornqvi@2520 64
zgu@3900 65 address os::get_caller_pc(int n) {
zgu@3900 66 #ifdef _NMT_NOINLINE_
zgu@3900 67 n ++;
zgu@3900 68 #endif
zgu@3900 69 frame fr = os::current_frame();
zgu@3900 70 while (n > 0 && fr.pc() &&
zgu@3900 71 !os::is_first_C_frame(&fr) && fr.sender_pc()) {
zgu@3900 72 fr = os::get_sender_for_C_frame(&fr);
zgu@3900 73 n --;
zgu@3900 74 }
zgu@3900 75 if (n == 0) {
zgu@3900 76 return fr.pc();
zgu@3900 77 } else {
zgu@3900 78 return NULL;
zgu@3900 79 }
zgu@3900 80 }
zgu@3900 81
phh@3379 82 int os::get_last_error() {
phh@3379 83 return errno;
phh@3379 84 }
phh@3379 85
sla@2584 86 bool os::is_debugger_attached() {
sla@2584 87 // not implemented
sla@2584 88 return false;
sla@2584 89 }
sla@2584 90
sla@2584 91 void os::wait_for_keypress_at_exit(void) {
sla@2584 92 // don't do anything on posix platforms
sla@2584 93 return;
sla@2584 94 }
nloodin@3783 95
nloodin@3783 96 void os::Posix::print_load_average(outputStream* st) {
nloodin@3783 97 st->print("load average:");
nloodin@3783 98 double loadavg[3];
nloodin@3783 99 os::loadavg(loadavg, 3);
nloodin@3783 100 st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]);
nloodin@3783 101 st->cr();
nloodin@3783 102 }
nloodin@3783 103
nloodin@3783 104 void os::Posix::print_rlimit_info(outputStream* st) {
nloodin@3783 105 st->print("rlimit:");
nloodin@3783 106 struct rlimit rlim;
nloodin@3783 107
nloodin@3783 108 st->print(" STACK ");
nloodin@3783 109 getrlimit(RLIMIT_STACK, &rlim);
nloodin@3783 110 if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
nloodin@3783 111 else st->print("%uk", rlim.rlim_cur >> 10);
nloodin@3783 112
nloodin@3783 113 st->print(", CORE ");
nloodin@3783 114 getrlimit(RLIMIT_CORE, &rlim);
nloodin@3783 115 if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
nloodin@3783 116 else st->print("%uk", rlim.rlim_cur >> 10);
nloodin@3783 117
nloodin@3783 118 //Isn't there on solaris
nloodin@3783 119 #ifndef TARGET_OS_FAMILY_solaris
nloodin@3783 120 st->print(", NPROC ");
nloodin@3783 121 getrlimit(RLIMIT_NPROC, &rlim);
nloodin@3783 122 if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
nloodin@3783 123 else st->print("%d", rlim.rlim_cur);
nloodin@3783 124 #endif
nloodin@3783 125
nloodin@3783 126 st->print(", NOFILE ");
nloodin@3783 127 getrlimit(RLIMIT_NOFILE, &rlim);
nloodin@3783 128 if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
nloodin@3783 129 else st->print("%d", rlim.rlim_cur);
nloodin@3783 130
nloodin@3783 131 st->print(", AS ");
nloodin@3783 132 getrlimit(RLIMIT_AS, &rlim);
nloodin@3783 133 if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
nloodin@3783 134 else st->print("%uk", rlim.rlim_cur >> 10);
nloodin@3783 135 st->cr();
nloodin@3783 136 }
nloodin@3783 137
nloodin@3783 138 void os::Posix::print_uname_info(outputStream* st) {
nloodin@3783 139 // kernel
nloodin@3783 140 st->print("uname:");
nloodin@3783 141 struct utsname name;
nloodin@3783 142 uname(&name);
nloodin@3783 143 st->print(name.sysname); st->print(" ");
nloodin@3783 144 st->print(name.release); st->print(" ");
nloodin@3783 145 st->print(name.version); st->print(" ");
nloodin@3783 146 st->print(name.machine);
nloodin@3783 147 st->cr();
nloodin@3783 148 }
nloodin@3783 149
nloodin@3783 150

mercurial