(original) (raw)
--- old/src/share/vm/utilities/vmError.cpp 2015-11-05 15:51:20.667648994 -0500 +++ new/src/share/vm/utilities/vmError.cpp 2015-11-05 15:51:20.339384140 -0500 @@ -225,6 +225,33 @@ 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 @@ -254,42 +281,201 @@ 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) { + if (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) { + if (TestCrashInErrorHandler != 0) { st->print_cr("Will crash now (TestCrashInErrorHandler=" UINTX_FORMAT ")...", TestCrashInErrorHandler); controlled_crash(TestCrashInErrorHandler); @@ -298,7 +484,7 @@ 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) { + if (TestSafeFetchInErrorHandler) { st->print_cr("Will test SafeFetch..."); if (CanUseSafeFetch32()) { int* const invalid_pointer = (int*) get_segfault_address(); @@ -314,6 +500,32 @@ 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)") @@ -346,6 +558,7 @@ return; // that's enough for the screen } break; + case VM_INFO: case INTERNAL_ERROR: default: break; @@ -402,29 +615,7 @@ 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)") @@ -439,18 +630,18 @@ } STEP(110, "(printing core file information)") - st->print("# "); - if (CreateCoredumpOnCrash) { - if (coredump_status) { - st->print("Core dump will be written. Default location: %s", coredump_message); - } else { - st->print("No core dump will be written. %s", coredump_message); - } - } else { - st->print("CreateCoredumpOnCrash turned off, no core file dumped"); - } - st->cr(); - st->print_cr("#"); + st->print("# "); + if (CreateCoredumpOnCrash) { + if (coredump_status) { + st->print("Core dump will be written. Default location: %s", coredump_message); + } else { + st->print("No core dump will be written. %s", coredump_message); + } + } else { + st->print("CreateCoredumpOnCrash turned off, no core file dumped"); + } + st->cr(); + st->print_cr("#"); STEP(120, "(printing bug submit message)") @@ -458,36 +649,14 @@ 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)" ) - if (_verbose) { - os::print_date_and_time(st, buf, sizeof(buf)); - } + // SUMMARY + // Step 200-290 + if (_verbose) { + report_summary(st, buf, sizeof(buf)); + } - STEP(170, "(printing thread)" ) + STEP(300, "(printing thread)" ) if (_verbose) { st->cr(); @@ -495,7 +664,7 @@ st->cr(); } - STEP(180, "(printing current thread)" ) + STEP(310, "(printing current thread)" ) // current thread if (_verbose) { @@ -509,7 +678,7 @@ 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; @@ -522,7 +691,7 @@ } - STEP(200, "(printing stack bounds)" ) + STEP(330, "(printing stack bounds)" ) if (_verbose) { st->print("Stack: "); @@ -553,7 +722,7 @@ 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))) { @@ -567,13 +736,13 @@ } } - 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())) { @@ -584,7 +753,7 @@ } } - STEP(240, "(printing siginfo)" ) + STEP(370, "(printing siginfo)" ) // signal no, signal code, address that caused the fault if (_verbose && _siginfo) { @@ -593,7 +762,7 @@ st->cr(); } - STEP(250, "(printing register info)") + STEP(380, "(printing register info)") // decode register contents if possible if (_verbose && _context && Universe::is_fully_initialized()) { @@ -601,7 +770,7 @@ 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) { @@ -609,7 +778,7 @@ 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); @@ -634,7 +803,7 @@ } } - STEP(270, "(printing VM operation)" ) + STEP(410, "(printing VM operation)" ) if (_verbose && _thread && _thread->is_VM_thread()) { VMThread* t = (VMThread*)_thread; @@ -646,178 +815,22 @@ } } - 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(); - } + if (_verbose) { + // 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."); - } + if (_verbose) { + st->print_cr("END."); + } END @@ -826,6 +839,20 @@ # 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 @@ -888,6 +915,7 @@ } int VMError::_id; +bool VMError::_vm_info_cmd; const char* VMError::_message; char VMError::_detail_msg[1024]; Thread* VMError::_thread; @@ -898,6 +926,21 @@ 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, ...) { @@ -960,6 +1003,7 @@ Atomic::cmpxchg_ptr(mytid, &first_error_tid, -1) == -1) { _id = id; + _vm_info_cmd = false; _message = message; _thread = thread; _pc = pc;