src/os/posix/vm/os_posix.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File osx-cores Sdiff src/os/posix/vm

src/os/posix/vm/os_posix.cpp

Print this page




  13 * accompanied this code).
  14 *
  15 * You should have received a copy of the GNU General Public License version
  16 * 2 along with this work; if not, write to the Free Software Foundation,
  17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18 *
  19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20 * or visit www.oracle.com if you need additional information or have any
  21 * questions.
  22 *
  23 */
  24 
  25 #include "prims/jvm.h"
  26 #include "runtime/os.hpp"
  27 #include "utilities/vmError.hpp"
  28 
  29 #include <unistd.h>
  30 #include <sys/resource.h>
  31 #include <sys/utsname.h>
  32 





















  33 
  34 // Check core dump limit and report possible place where core can be found
  35 void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) {
  36   struct rlimit rlim;
  37   static char cwd[O_BUFLEN];
  38   bool success;
  39 
  40   get_current_directory(cwd, sizeof(cwd));
  41 
  42   if (getrlimit(RLIMIT_CORE, &rlim) != 0) {
  43     jio_snprintf(buffer, bufferSize, "%s/core or core.%d (may not exist)", cwd, current_process_id());

  44     success = true;
  45   } else {
  46     switch(rlim.rlim_cur) {
  47       case RLIM_INFINITY:
  48         jio_snprintf(buffer, bufferSize, "%s/core or core.%d", cwd, current_process_id());
  49         success = true;
  50         break;
  51       case 0:
  52         jio_snprintf(buffer, bufferSize, "Core dumps have been disabled. To enable core dumping, try \"ulimit -c unlimited\" before starting Java again");
  53         success = false;
  54         break;
  55       default:
  56         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));

  57         success = true;
  58         break;
  59     }
  60   }
  61   VMError::report_coredump_status(buffer, success);
  62 }
  63 
  64 int os::get_last_error() {
  65   return errno;
  66 }
  67 
  68 bool os::is_debugger_attached() {
  69   // not implemented
  70   return false;
  71 }
  72 
  73 void os::wait_for_keypress_at_exit(void) {
  74   // don't do anything on posix platforms
  75   return;
  76 }




  13 * accompanied this code).
  14 *
  15 * You should have received a copy of the GNU General Public License version
  16 * 2 along with this work; if not, write to the Free Software Foundation,
  17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18 *
  19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20 * or visit www.oracle.com if you need additional information or have any
  21 * questions.
  22 *
  23 */
  24 
  25 #include "prims/jvm.h"
  26 #include "runtime/os.hpp"
  27 #include "utilities/vmError.hpp"
  28 
  29 #include <unistd.h>
  30 #include <sys/resource.h>
  31 #include <sys/utsname.h>
  32 
  33 // Generate the candidate core paths into the supplied buffer
  34 // Return the number of characters actually generated
  35 int os::Posix::generate_core_paths(char* buffer, size_t bufferSize) {
  36   int n;
  37 
  38 #ifndef __APPLE__
  39   static char cwd[O_BUFLEN];
  40 
  41   get_current_directory(cwd, sizeof(cwd));
  42 
  43   n = jio_snprintf(buffer, bufferSize, "%s/core or core.%d", cwd, current_process_id());
  44 #else
  45   n = jio_snprintf(buffer, bufferSize, "/cores/core.%d", current_process_id());
  46 #endif
  47 
  48   // Truncate if theoretical string was longer than bufferSize
  49   n = MIN2(n, (int)bufferSize);
  50 
  51   return n;
  52 }
  53 
  54 
  55 // Check core dump limit and report possible place where core can be found
  56 void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) {
  57   struct rlimit rlim;

  58   bool success;
  59   int n;

  60 
  61   if (getrlimit(RLIMIT_CORE, &rlim) != 0) {
  62     n = os::Posix::generate_core_paths(buffer, bufferSize);
  63     jio_snprintf(buffer + n, bufferSize - n, " (may not exist)");
  64     success = true;
  65   } else {
  66     switch(rlim.rlim_cur) {
  67       case RLIM_INFINITY:
  68         os::Posix::generate_core_paths(buffer, bufferSize);
  69         success = true;
  70         break;
  71       case 0:
  72         jio_snprintf(buffer, bufferSize, "Core dumps have been disabled. To enable core dumping, try \"ulimit -c unlimited\" before starting Java again");
  73         success = false;
  74         break;
  75       default:
  76         n = os::Posix::generate_core_paths(buffer, bufferSize);
  77         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));
  78         success = true;
  79         break;
  80     }
  81   }
  82   VMError::report_coredump_status(buffer, success);
  83 }
  84 
  85 int os::get_last_error() {
  86   return errno;
  87 }
  88 
  89 bool os::is_debugger_attached() {
  90   // not implemented
  91   return false;
  92 }
  93 
  94 void os::wait_for_keypress_at_exit(void) {
  95   // don't do anything on posix platforms
  96   return;
  97 }


src/os/posix/vm/os_posix.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File