(original) (raw)

src/share/vm/utilities/vmError.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File

*** old/src/share/vm/utilities/vmError.cpp Thu Nov 5 15:51:20 2015** --- new/src/share/vm/utilities/vmError.cpp Thu Nov 5 15:51:20 2015


*** 223,232 **** --- 223,259 ---- if (UseConcMarkSweepGC) return "concurrent mark sweep gc"; if (UseSerialGC) return "serial gc"; return "ERROR in GC mode"; }

+ void VMError::report_vm_version(outputStream st, char buf, int buflen) {** + // VM version + st->print_cr("#"); + JDK_Version::current().to_string(buf, buflen); + const char runtime_name = JDK_Version::runtime_name() != NULL ?* + JDK_Version::runtime_name() : ""; + const char runtime_version = JDK_Version::runtime_version() != NULL ?* + JDK_Version::runtime_version() : ""; + st->print_cr("# JRE version: %s (%s) (build %s)", runtime_name, buf, runtime_version); + // This is the long version with some default settings added + st->print_cr("# Java VM: %s (%s, %s%s%s%s%s, %s, %s)", + Abstract_VM_Version::vm_name(), + Abstract_VM_Version::vm_release(), + Abstract_VM_Version::vm_info_string(), + TieredCompilation ? ", tiered" : "", + #if INCLUDE_JVMCI + EnableJVMCI ? ", jvmci" : "", + UseJVMCICompiler ? ", jvmci compiler" : "", + #else + "", "", + #endif + UseCompressedOops ? ", compressed oops" : "", + gc_mode(), + Abstract_VM_Version::vm_platform_string() + ); + } + // This is the main function to report a fatal error. Only one thread can // call this function, so we don't need to worry about MT-safety. But it's // possible that the error handler itself may crash or die on an internal // error, for example, when the stack/heap is badly damaged. We must be // able to handle recursive errors that happen inside error handler.


*** 252,306 **** --- 279,492 ---- // thread can report error, so large buffers are statically allocated in data // segment.

int VMError::_current_step; const char* VMError::_current_step_info; + # define STEP(n, s) } if (_current_step < n) { if (!_vm_info_cmd) { _current_step = n; _current_step_info = s; } + # define BEGIN if (_current_step == 0) { if (!_vm_info_cmd) { _current_step = 1; } + # define END }

! void VMError::report~~(outputStream st, bool _verbose~~) {* ! void VMError::report_summary(outputStream st, char buf, int buflen) {**

# define BEGIN if (_current_step == 0) { _current_step = 1; # define STEP(n, s) } if (_current_step < n) { _current_step = n; _current_step_info = s; # define END } + BEGIN

// don't allocate large buffer on stack static char buf[O_BUFLEN]; + // Summary reports are in the 200s. + STEP(200, "(printing summary)" ) + + st->cr(); + st->print_cr("--------------- S U M M A R Y ------------"); + st->cr(); + + STEP(210, "(printing VM option summary)" ) + + // VM options + Arguments::print_summary_on(st); + st->cr(); + + STEP(220, "(printing summary machine and OS info)") + + os::print_summary_info(st, buf, sizeof(buf)); + + STEP(230, "(printing date and time)" ) + + os::print_date_and_time(st, buf, sizeof(buf)); + END + } + + void VMError::report_process(outputStream st, char buf, int buflen) {**

BEGIN

+ STEP(500, "(printing process)" )

STEP(10, "(printing fatal error message)") + st->cr(); + st->print_cr("--------------- P R O C E S S ---------------"); + st->cr();

st->print_cr("#"); if (should_report_bug(_id)) { st->print_cr("# A fatal error has been detected by the Java Runtime Environment:"); + STEP(510, "(printing all threads)" ) + + // all threads + if (_thread) { + Threads::print_on_error(st, _thread, buf, buflen); + st->cr(); + } + + STEP(520, "(printing VM state)" ) + + // Safepoint state + st->print("VM state:"); + + if (SafepointSynchronize::is_synchronizing()) st->print("synchronizing"); + else if (SafepointSynchronize::is_at_safepoint()) st->print("at safepoint"); + else st->print("not at safepoint"); + + // Also see if error occurred during initialization or shutdown + if (!Universe::is_fully_initialized()) { + st->print(" (not fully initialized)"); + } else if (VM_Exit::vm_exited()) { + st->print(" (shutting down)"); } else { ! st->print_cr("# There is insufficient memory for the Java " "Runtime Environment to continue."); ! st->print(" (normal execution)"); } + st->cr(); + st->cr();

#ifndef PRODUCT // Error handler self tests + STEP(530, "(printing owned locks on error)" ) + + // mutexes/monitors that currently have an owner + print_owned_locks_on_error(st); + st->cr(); + + STEP(540, "(printing number of OutOfMemoryError and StackOverflow exceptions)") + + if (Exceptions::has_exception_counts()) { + st->print_cr("OutOfMemory and StackOverflow Exception counts:"); + Exceptions::print_exception_counts_on_error(st); + st->cr(); + } + + STEP(550, "(printing compressed oops mode")

+ if (UseCompressedOops) { + Universe::print_compressed_oops_mode(st); + if (UseCompressedClassPointers) { + Metaspace::print_compressed_class_space(st); + } + st->cr(); + } + + STEP(560, "(printing heap information)" ) + + if (Universe::is_fully_initialized()) { + Universe::heap()->print_on_error(st); + st->cr(); + + st->print_cr("Polling page: " INTPTR_FORMAT, p2i(os::get_polling_page())); + st->cr(); + } + + STEP(570, "(printing code cache information)" ) + + if (Universe::is_fully_initialized()) { + // print code cache information before vm abort + CodeCache::print_summary(st); + st->cr(); + } + + STEP(580, "(printing ring buffers)" ) + + Events::print_all(st); + st->cr(); + + STEP(590, "(printing dynamic libraries)" ) + + // dynamic libraries, or memory map + os::print_dll_info(st); + st->cr(); + + STEP(600, "(printing VM options)" ) + + // VM options + Arguments::print_on(st); + st->cr(); + + STEP(610, "(printing warning if internal testing API used)" ) + + if (WhiteBox::used()) { + st->print_cr("Unsupported internal testing APIs have been used."); + st->cr(); + } + + STEP(620, "(printing all environment variables)" ) + + os::print_environment_variables(st, env_list); + st->cr(); + + STEP(630, "(printing signal handlers)" ) + + os::print_signal_handlers(st, buf, buflen); + st->cr(); + + STEP(640, "(Native Memory Tracking)" ) + MemTracker::error_report(st); + + END + } + + void VMError::report_system(outputStream st, char buf, int buflen) {** + + BEGIN + STEP(700, "(printing system)" ) + + st->cr(); + st->print_cr("--------------- S Y S T E M ---------------"); + st->cr(); + + STEP(710, "(printing OS information)" ) + + os::print_os_info(st); + st->cr(); + + STEP(720, "(printing CPU info)" ) + os::print_cpu_info(st, buf, buflen); + st->cr(); + + STEP(730, "(printing memory info)" ) + + os::print_memory_info(st); + st->cr(); + + STEP(740, "(printing internal vm info)" ) + + st->print_cr("vm_info: %s", Abstract_VM_Version::internal_vm_info_string()); + st->cr(); + + END + } + + #ifndef PRODUCT + void VMError::run_report_tests(outputStream st) {* + BEGIN // test secondary error handling. Test it twice, to test that resetting // error handler after a secondary crash works. STEP(20, "(test secondary crash 1)") - if (_verbose && TestCrashInErrorHandler != 0) { st->print_cr("Will crash now (TestCrashInErrorHandler=" UINTX_FORMAT ")...", TestCrashInErrorHandler); controlled_crash(TestCrashInErrorHandler); }

STEP(30, "(test secondary crash 2)")

- if (_verbose && TestCrashInErrorHandler != 0) { st->print_cr("Will crash now (TestCrashInErrorHandler=" UINTX_FORMAT ")...", TestCrashInErrorHandler); controlled_crash(TestCrashInErrorHandler); }

STEP(40, "(test safefetch in error handler)")
  // test whether it is safe to use SafeFetch32 in Crash Handler. Test twice
  // to test that resetting the signal handler works correctly.

- if (_verbose && TestSafeFetchInErrorHandler) { st->print_cr("Will test SafeFetch..."); if (CanUseSafeFetch32()) { int* const invalid_pointer = (int*) get_segfault_address(); const int x = 0x76543210; int i1 = SafeFetch32(invalid_pointer, x);


*** 312,321 **** --- 498,533 ---- } } else { st->print_cr("not possible; skipped."); } } + END + } + #endif // PRODUCT + + // Main error reporting function. + void VMError::report(outputStream st, bool _verbose) {* + + // don't allocate large buffer on stack + static char buf[O_BUFLEN]; + + BEGIN + STEP(10, "(printing fatal error message)") + + st->print_cr("#"); + if (should_report_bug(_id)) { + st->print_cr("# A fatal error has been detected by the Java Runtime Environment:"); + } else { + st->print_cr("# There is insufficient memory for the Java " + "Runtime Environment to continue."); + } + + #ifndef PRODUCT + // Error handler self tests Step 20-40 + if (_verbose) { + run_report_tests(st); + } #endif // PRODUCT

STEP(50, "(printing type of error)")

   switch(_id) {

*** 344,353 **** --- 556,566 ---- print_oom_reasons(st); } else { return; // that's enough for the screen } break; + case VM_INFO: case INTERNAL_ERROR: default: break; }

*** 400,432 **** --- 613,623 ---- }

STEP(90, "(printing Java version string)")

   // VM version

! st->print_cr("#"); JDK_Version::current().to_string(buf, sizeof(buf)); const char runtime_name = JDK_Version::runtime_name() != NULL ?* JDK_Version::runtime_name() : ""; const char runtime_version = JDK_Version::runtime_version() != NULL ?* JDK_Version::runtime_version() : ""; st->print_cr("# JRE version: %s (%s) (build %s)", runtime_name, buf, runtime_version); // This is the long version with some default settings added st->print_cr("# Java VM: %s (%s, %s%s%s%s%s, %s, %s)", Abstract_VM_Version::vm_name(), Abstract_VM_Version::vm_release(), Abstract_VM_Version::vm_info_string(), TieredCompilation ? ", tiered" : "", #if INCLUDE_JVMCI EnableJVMCI ? ", jvmci" : "", UseJVMCICompiler ? ", jvmci compiler" : "", #else "", "", #endif UseCompressedOops ? ", compressed oops" : "", gc_mode(), Abstract_VM_Version::vm_platform_string() ); ! report_vm_version(st, buf, sizeof(buf));

STEP(100, "(printing problematic frame)")

   // Print current frame if we have a context (i.e. it's a crash)
   if (_context) {

*** 456,503 **** --- 647,672 ----

   if (should_report_bug(_id) && _verbose) {
     print_bug_submit_message(st, _thread);
   }

STEP(130, "(printing summary)" )

if (_verbose) { st->cr(); st->print_cr("--------------- S U M M A R Y ------------"); st->cr(); }

STEP(140, "(printing VM option summary)" )

if (_verbose) { // VM options Arguments::print_summary_on(st); st->cr(); }

STEP(150, "(printing summary machine and OS info)")

if (_verbose) { os::print_summary_info(st, buf, sizeof(buf)); }

STEP(160, "(printing date and time)" )

+ // SUMMARY + // Step 200-290 if (_verbose) { ! os::print_date_and_time(st, buf, sizeof(buf)); ! report_summary(st, buf, sizeof(buf)); }

! STEP(170, "(printing thread)" ) ! STEP(300, "(printing thread)" )

   if (_verbose) {
     st->cr();
     st->print_cr("---------------  T H R E A D  ---------------");
     st->cr();
   }

! STEP(180, "(printing current thread)" ) ! STEP(310, "(printing current thread)" )

   // current thread
   if (_verbose) {
     if (_thread) {
       st->print("Current thread (" PTR_FORMAT "):  ", p2i(_thread));

*** 507,517 **** --- 676,686 ---- st->print_cr("Current thread is native thread"); } st->cr(); }

! STEP(190, "(printing current compile task)" ) ! STEP(320, "(printing current compile task)" )

   if (_verbose && _thread && _thread->is_Compiler_thread()) {
      CompilerThread* t = (CompilerThread*)_thread;
      if (t->task()) {
         st->cr();

*** 520,530 **** --- 689,699 ---- st->cr(); } }

! STEP(200, "(printing stack bounds)" ) ! STEP(330, "(printing stack bounds)" )

   if (_verbose) {
     st->print("Stack: ");

     address stack_top;

*** 551,561 **** --- 720,730 ---- }

     st->cr();
   }

! STEP(210, "(printing native stack)" ) ! STEP(340, "(printing native stack)" )

 if (_verbose) {
   if (os::platform_print_native_stack(st, _context, buf, sizeof(buf))) {
     // We have printed the native stack in platform-specific code
     // Windows/x64 needs special handling.

*** 565,617 **** --- 734,786 ----

     print_native_stack(st, fr, _thread, buf, sizeof(buf));
   }
 }

! STEP(220, "(printing Java stack)" ) ! STEP(350, "(printing Java stack)" )

   if (_verbose && _thread && _thread->is_Java_thread()) {
     print_stack_trace(st, (JavaThread*)_thread, buf, sizeof(buf));
   }

! STEP(230, "(printing target Java thread stack)" ) ! STEP(360, "(printing target Java thread stack)" )

   // printing Java thread stack trace if it is involved in GC crash
   if (_verbose && _thread && (_thread->is_Named_thread())) {
     JavaThread*  jt = ((NamedThread *)_thread)->processed_thread();
     if (jt != NULL) {
       st->print_cr("JavaThread " PTR_FORMAT " (nid = %d) was being processed", p2i(jt), jt->osthread()->thread_id());
       print_stack_trace(st, jt, buf, sizeof(buf), true);
     }
   }

! STEP(240, "(printing siginfo)" ) ! STEP(370, "(printing siginfo)" )

   // signal no, signal code, address that caused the fault
   if (_verbose && _siginfo) {
     st->cr();
     os::print_siginfo(st, _siginfo);
     st->cr();
   }

! STEP(250, "(printing register info)") ! STEP(380, "(printing register info)")

   // decode register contents if possible
   if (_verbose && _context && Universe::is_fully_initialized()) {
     os::print_register_info(st, _context);
     st->cr();
   }

! STEP(260, "(printing registers, top of stack, instructions near pc)") ! STEP(390, "(printing registers, top of stack, instructions near pc)")

   // registers, top of stack, instructions near pc
   if (_verbose && _context) {
     os::print_context(st, _context);
     st->cr();
   }

! STEP(265, "(printing code blob if possible)") ! STEP(400, "(printing code blob if possible)")

   if (_verbose && _context) {
     CodeBlob* cb = CodeCache::find_blob(_pc);
     if (cb != NULL) {
       if (Interpreter::contains(_pc)) {

*** 632,642 **** --- 801,811 ---- } } } }

! STEP(270, "(printing VM operation)" ) ! STEP(410, "(printing VM operation)" )

   if (_verbose && _thread && _thread->is_VM_thread()) {
      VMThread* t = (VMThread*)_thread;
      VM_Operation* op = t->vm_operation();
      if (op) {

*** 644,821 **** --- 813,834 ---- st->cr(); st->cr(); } }

STEP(280, "(printing process)" )

if (_verbose) { st->cr(); st->print_cr("--------------- P R O C E S S ---------------"); st->cr(); }

STEP(290, "(printing all threads)" )

// all threads if (_verbose && _thread) { Threads::print_on_error(st, _thread, buf, sizeof(buf)); st->cr(); }

STEP(300, "(printing VM state)" )

if (_verbose) { // Safepoint state st->print("VM state:");

if (SafepointSynchronize::is_synchronizing()) st->print("synchronizing"); else if (SafepointSynchronize::is_at_safepoint()) st->print("at safepoint"); else st->print("not at safepoint");

// Also see if error occurred during initialization or shutdown if (!Universe::is_fully_initialized()) { st->print(" (not fully initialized)"); } else if (VM_Exit::vm_exited()) { st->print(" (shutting down)"); } else { st->print(" (normal execution)"); } st->cr(); st->cr(); }

STEP(310, "(printing owned locks on error)" )

// mutexes/monitors that currently have an owner if (_verbose) { print_owned_locks_on_error(st); st->cr(); }

STEP(320, "(printing number of OutOfMemoryError and StackOverflow exceptions)")

if (_verbose && Exceptions::has_exception_counts()) { st->print_cr("OutOfMemory and StackOverflow Exception counts:"); Exceptions::print_exception_counts_on_error(st); st->cr(); }

STEP(330, "(printing compressed oops mode")

if (_verbose && UseCompressedOops) { Universe::print_compressed_oops_mode(st); if (UseCompressedClassPointers) { Metaspace::print_compressed_class_space(st); } st->cr(); }

STEP(340, "(printing heap information)" )

if (_verbose && Universe::is_fully_initialized()) { Universe::heap()->print_on_error(st); st->cr();

st->print_cr("Polling page: " INTPTR_FORMAT, p2i(os::get_polling_page())); st->cr(); }

STEP(350, "(printing code cache information)" )

if (_verbose && Universe::is_fully_initialized()) { // print code cache information before vm abort CodeCache::print_summary(st); st->cr(); }

STEP(360, "(printing ring buffers)" )

if (_verbose) { Events::print_all(st); st->cr(); }

STEP(370, "(printing dynamic libraries)" )

if (_verbose) { // dynamic libraries, or memory map os::print_dll_info(st); st->cr(); }

STEP(380, "(printing VM options)" )

if (_verbose) { // VM options Arguments::print_on(st); st->cr(); }

STEP(390, "(printing warning if internal testing API used)" )

if (WhiteBox::used()) { st->print_cr("Unsupported internal testing APIs have been used."); st->cr(); }

STEP(400, "(printing all environment variables)" )

if (_verbose) {

os::print_environment_variables(st, env_list); st->cr(); }

STEP(410, "(printing signal handlers)" )

if (_verbose) { os::print_signal_handlers(st, buf, sizeof(buf)); st->cr(); }

STEP(420, "(Native Memory Tracking)" ) if (_verbose) { MemTracker::error_report(st); }

STEP(430, "(printing system)" )

if (_verbose) { st->cr(); st->print_cr("--------------- S Y S T E M ---------------"); st->cr(); }

STEP(440, "(printing OS information)" )

if (_verbose) { os::print_os_info(st); st->cr(); }

STEP(450, "(printing CPU info)" ) if (_verbose) { os::print_cpu_info(st, buf, sizeof(buf)); st->cr(); }

STEP(460, "(printing memory info)" )

if (_verbose) { os::print_memory_info(st); st->cr(); }

STEP(470, "(printing internal vm info)" )

if (_verbose) { st->print_cr("vm_info: %s", Abstract_VM_Version::internal_vm_info_string()); st->cr(); + // PROCESS + // Step 500-690 + report_process(st, buf, sizeof(buf)); + + // SYSTEM + // Step 700-790 + report_system(st, buf, sizeof(buf)); }
// print a defined marker to show that error handling finished correctly. ! STEP(480, "(printing end marker)" ) ! STEP(800, "(printing end marker)" )
if (_verbose) { st->print_cr("END."); }

*** 824,833 **** --- 837,860 ----

undef BEGIN

undef STEP

undef END

}

+ // Report for the vm_info_cmd, skipping crash specific code + void VMError::report_info(outputStream st) {* + + // don't allocate large buffer on stack + static char buf[O_BUFLEN]; + + st->print_cr("# pid=%d", os::current_process_id()); + report_vm_version(st, buf, sizeof(buf)); + report_summary(st, buf, sizeof(buf)); + report_process(st, buf, sizeof(buf)); + report_system(st, buf, sizeof(buf)); + st->print_cr("END."); + } + volatile intptr_t VMError::first_error_tid = -1;

// An error could happen before tty is initialized or after it has been // destroyed. Here we use a very simple unbuffered fdStream for printing. // Only out.print_raw() and out.print_raw_cr() should be used, as other


*** 886,905 **** --- 913,948 ----

return fd;

}

int VMError::_id; + bool VMError::_vm_info_cmd; const char* VMError::_message; char VMError::_detail_msg[1024]; Thread* VMError::_thread; address VMError::_pc; void* VMError::_siginfo; void* VMError::_context; const char* VMError::_filename; int VMError::_lineno; size_t VMError::_size;

+ void VMError::print_vm_info(outputStream st) {* + _id = VM_INFO; + _vm_info_cmd = true; + _message = NULL; + _thread = NULL; + _pc = NULL; + _siginfo = NULL; + _context = NULL; + _filename = NULL; + _lineno = 0; + _size = 0; + _detail_msg[0] = 0; + report_info(st); + } + void VMError::report_and_die(Thread* thread, unsigned int sig, address pc, void* siginfo, void* context, const char* detail_fmt, ...) { va_list detail_args; va_start(detail_args, detail_fmt);


*** 958,967 **** --- 1001,1011 ---- intptr_t mytid = os::current_thread_id(); if (first_error_tid == -1 && Atomic::cmpxchg_ptr(mytid, &first_error_tid, -1) == -1) {

  _id = id;

+ _vm_info_cmd = false; _message = message; _thread = thread; _pc = pc; _siginfo = siginfo; _context = context;


src/share/vm/utilities/vmError.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File