src/os/posix/vm/os_posix.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
osx-cores Cdiff src/os/posix/vm/os_posix.cpp
src/os/posix/vm/os_posix.cpp
Print this page
*** 28,61 ****
#include <unistd.h>
#include <sys/resource.h>
#include <sys/utsname.h>
// Check core dump limit and report possible place where core can be found
void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) {
struct rlimit rlim;
- static char cwd[O_BUFLEN];
bool success;
!
! get_current_directory(cwd, sizeof(cwd));
if (getrlimit(RLIMIT_CORE, &rlim) != 0) {
! jio_snprintf(buffer, bufferSize, "%s/core or core.%d (may not exist)", cwd, current_process_id());
success = true;
} else {
switch(rlim.rlim_cur) {
case RLIM_INFINITY:
! jio_snprintf(buffer, bufferSize, "%s/core or core.%d", cwd, current_process_id());
success = true;
break;
case 0:
jio_snprintf(buffer, bufferSize, "Core dumps have been disabled. To enable core dumping, try \"ulimit -c unlimited\" before starting Java again");
success = false;
break;
default:
! 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));
success = true;
break;
}
}
VMError::report_coredump_status(buffer, success);
--- 28,82 ----
#include <unistd.h>
#include <sys/resource.h>
#include <sys/utsname.h>
+ // Generate the candidate core paths into the supplied buffer
+ // Return the number of characters actually generated
+ int os::Posix::generate_core_paths(char* buffer, size_t bufferSize) {
+ int n;
+
+ #ifndef __APPLE__
+ static char cwd[O_BUFLEN];
+
+ get_current_directory(cwd, sizeof(cwd));
+
+ n = jio_snprintf(buffer, bufferSize, "%s/core or core.%d", cwd, current_process_id());
+ #else
+ n = jio_snprintf(buffer, bufferSize, "/cores/core.%d", current_process_id());
+ #endif
+
+ // Truncate if theoretical string was longer than bufferSize
+ n = MIN2(n, (int)bufferSize);
+
+ return n;
+ }
+
// Check core dump limit and report possible place where core can be found
void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) {
struct rlimit rlim;
bool success;
! int n;
if (getrlimit(RLIMIT_CORE, &rlim) != 0) {
! n = os::Posix::generate_core_paths(buffer, bufferSize);
! jio_snprintf(buffer + n, bufferSize - n, " (may not exist)");
success = true;
} else {
switch(rlim.rlim_cur) {
case RLIM_INFINITY:
! os::Posix::generate_core_paths(buffer, bufferSize);
success = true;
break;
case 0:
jio_snprintf(buffer, bufferSize, "Core dumps have been disabled. To enable core dumping, try \"ulimit -c unlimited\" before starting Java again");
success = false;
break;
default:
! n = os::Posix::generate_core_paths(buffer, bufferSize);
! jio_snprintf(buffer + n, bufferSize - n, " (max size %lu kB). To ensure a full core dump, try \"ulimit -c unlimited\" before starting Java again", (unsigned long)(rlim.rlim_cur >> 10));
success = true;
break;
}
}
VMError::report_coredump_status(buffer, success);
src/os/posix/vm/os_posix.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File