29 #include "runtime/os.hpp"
30 #include "utilities/vmError.hpp"
31
32 #include <signal.h>
33 #include <unistd.h>
34 #include <sys/resource.h>
35 #include <sys/utsname.h>
36 #include <pthread.h>
37 #include <signal.h>
38
39 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
40
41 // Todo: provide a os::get_max_process_id() or similar. Number of processes
42 // may have been configured, can be read more accurately from proc fs etc.
43 #ifndef MAX_PID
44 #define MAX_PID INT_MAX
45 #endif
46 #define IS_VALID_PID(p) (p > 0 && p < MAX_PID)
47
48 // Check core dump limit and report possible place where core can be found
49 void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) {
50 int n;
51 struct rlimit rlim;
52 bool success;
53
54 char core_path[PATH_MAX];
55 n = get_core_path(core_path, PATH_MAX);
56
57 if (n <= 0) {
58 jio_snprintf(buffer, bufferSize, "core.%d (may not exist)", current_process_id());
59 success = true;
60 #ifdef LINUX
61 } else if (core_path[0] == '"') { // redirect to user process
62 jio_snprintf(buffer, bufferSize, "Core dumps may be processed with %s", core_path);
63 success = true;
64 #endif
65 } else if (getrlimit(RLIMIT_CORE, &rlim) != 0) {
66 jio_snprintf(buffer, bufferSize, "%s (may not exist)", core_path);
67 success = true;
68 } else {
69 switch(rlim.rlim_cur) {
|
29 #include "runtime/os.hpp"
30 #include "utilities/vmError.hpp"
31
32 #include <signal.h>
33 #include <unistd.h>
34 #include <sys/resource.h>
35 #include <sys/utsname.h>
36 #include <pthread.h>
37 #include <signal.h>
38
39 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
40
41 // Todo: provide a os::get_max_process_id() or similar. Number of processes
42 // may have been configured, can be read more accurately from proc fs etc.
43 #ifndef MAX_PID
44 #define MAX_PID INT_MAX
45 #endif
46 #define IS_VALID_PID(p) (p > 0 && p < MAX_PID)
47
48 // Check core dump limit and report possible place where core can be found
49 void os::check_dump_limit(char* buffer, size_t bufferSize) {
50 int n;
51 struct rlimit rlim;
52 bool success;
53
54 char core_path[PATH_MAX];
55 n = get_core_path(core_path, PATH_MAX);
56
57 if (n <= 0) {
58 jio_snprintf(buffer, bufferSize, "core.%d (may not exist)", current_process_id());
59 success = true;
60 #ifdef LINUX
61 } else if (core_path[0] == '"') { // redirect to user process
62 jio_snprintf(buffer, bufferSize, "Core dumps may be processed with %s", core_path);
63 success = true;
64 #endif
65 } else if (getrlimit(RLIMIT_CORE, &rlim) != 0) {
66 jio_snprintf(buffer, bufferSize, "%s (may not exist)", core_path);
67 success = true;
68 } else {
69 switch(rlim.rlim_cur) {
|