< prev index next >

src/share/vm/utilities/vmError.cpp

Print this page
rev 9019 : [mq]: format.patch


  28 #include "compiler/compileBroker.hpp"
  29 #include "gc/shared/collectedHeap.hpp"
  30 #include "prims/whitebox.hpp"
  31 #include "runtime/arguments.hpp"
  32 #include "runtime/atomic.inline.hpp"
  33 #include "runtime/frame.inline.hpp"
  34 #include "runtime/init.hpp"
  35 #include "runtime/os.hpp"
  36 #include "runtime/thread.inline.hpp"
  37 #include "runtime/vmThread.hpp"
  38 #include "runtime/vm_operations.hpp"
  39 #include "services/memTracker.hpp"
  40 #include "utilities/debug.hpp"
  41 #include "utilities/decoder.hpp"
  42 #include "utilities/defaultStream.hpp"
  43 #include "utilities/errorReporter.hpp"
  44 #include "utilities/events.hpp"
  45 #include "utilities/top.hpp"
  46 #include "utilities/vmError.hpp"
  47 
  48 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  49 
  50 // List of environment variables that should be reported in error log file.
  51 const char *env_list[] = {
  52   // All platforms
  53   "JAVA_HOME", "JRE_HOME", "JAVA_TOOL_OPTIONS", "_JAVA_OPTIONS", "CLASSPATH",
  54   "JAVA_COMPILER", "PATH", "USERNAME",
  55 
  56   // Env variables that are defined on Solaris/Linux/BSD
  57   "LD_LIBRARY_PATH", "LD_PRELOAD", "SHELL", "DISPLAY",
  58   "HOSTTYPE", "OSTYPE", "ARCH", "MACHTYPE",
  59 
  60   // defined on Linux
  61   "LD_ASSUME_KERNEL", "_JAVA_SR_SIGNUM",
  62 
  63   // defined on Darwin
  64   "DYLD_LIBRARY_PATH", "DYLD_FALLBACK_LIBRARY_PATH",
  65   "DYLD_FRAMEWORK_PATH", "DYLD_FALLBACK_FRAMEWORK_PATH",
  66   "DYLD_INSERT_LIBRARIES",
  67 
  68   // defined on Windows
  69   "OS", "PROCESSOR_IDENTIFIER", "_ALT_JAVA_HOME_DIR",


 267 
 268   BEGIN
 269 
 270   STEP(10, "(printing fatal error message)")
 271 
 272     st->print_cr("#");
 273     if (should_report_bug(_id)) {
 274       st->print_cr("# A fatal error has been detected by the Java Runtime Environment:");
 275     } else {
 276       st->print_cr("# There is insufficient memory for the Java "
 277                    "Runtime Environment to continue.");
 278     }
 279 
 280 #ifndef PRODUCT
 281   // Error handler self tests
 282 
 283   // test secondary error handling. Test it twice, to test that resetting
 284   // error handler after a secondary crash works.
 285   STEP(20, "(test secondary crash 1)")
 286     if (_verbose && TestCrashInErrorHandler != 0) {
 287       st->print_cr("Will crash now (TestCrashInErrorHandler=%d)...",
 288         TestCrashInErrorHandler);
 289       controlled_crash(TestCrashInErrorHandler);
 290     }
 291 
 292   STEP(30, "(test secondary crash 2)")
 293     if (_verbose && TestCrashInErrorHandler != 0) {
 294       st->print_cr("Will crash now (TestCrashInErrorHandler=%d)...",
 295         TestCrashInErrorHandler);
 296       controlled_crash(TestCrashInErrorHandler);
 297     }
 298 
 299   STEP(40, "(test safefetch in error handler)")
 300     // test whether it is safe to use SafeFetch32 in Crash Handler. Test twice
 301     // to test that resetting the signal handler works correctly.
 302     if (_verbose && TestSafeFetchInErrorHandler) {
 303       st->print_cr("Will test SafeFetch...");
 304       if (CanUseSafeFetch32()) {
 305         int* const invalid_pointer = (int*) get_segfault_address();
 306         const int x = 0x76543210;
 307         int i1 = SafeFetch32(invalid_pointer, x);
 308         int i2 = SafeFetch32(invalid_pointer, x);
 309         if (i1 == x && i2 == x) {
 310           st->print_cr("SafeFetch OK."); // Correctly deflected and returned default pattern
 311         } else {
 312           st->print_cr("??");
 313         }
 314       } else {


 343          // In error file give some solutions
 344          if (_verbose) {
 345            print_oom_reasons(st);
 346          } else {
 347            return;  // that's enough for the screen
 348          }
 349          break;
 350        case INTERNAL_ERROR:
 351        default:
 352          break;
 353      }
 354 
 355   STEP(60, "(printing exception/signal name)")
 356 
 357      st->print_cr("#");
 358      st->print("#  ");
 359      // Is it an OS exception/signal?
 360      if (os::exception_name(_id, buf, sizeof(buf))) {
 361        st->print("%s", buf);
 362        st->print(" (0x%x)", _id);                // signal number
 363        st->print(" at pc=" PTR_FORMAT, _pc);
 364      } else {
 365        if (should_report_bug(_id)) {
 366          st->print("Internal Error");
 367        } else {
 368          st->print("Out of Memory Error");
 369        }
 370        if (_filename != NULL && _lineno > 0) {
 371 #ifdef PRODUCT
 372          // In product mode chop off pathname?
 373          char separator = os::file_separator()[0];
 374          const char *p = strrchr(_filename, separator);
 375          const char *file = p ? p+1 : _filename;
 376 #else
 377          const char *file = _filename;
 378 #endif
 379          st->print(" (%s:%d)", file, _lineno);
 380        } else {
 381          st->print(" (0x%x)", _id);
 382        }
 383      }


 478 
 479   STEP(160, "(printing date and time)" )
 480 
 481      if (_verbose) {
 482        os::print_date_and_time(st, buf, sizeof(buf));
 483      }
 484 
 485   STEP(170, "(printing thread)" )
 486 
 487      if (_verbose) {
 488        st->cr();
 489        st->print_cr("---------------  T H R E A D  ---------------");
 490        st->cr();
 491      }
 492 
 493   STEP(180, "(printing current thread)" )
 494 
 495      // current thread
 496      if (_verbose) {
 497        if (_thread) {
 498          st->print("Current thread (" PTR_FORMAT "):  ", _thread);
 499          _thread->print_on_error(st, buf, sizeof(buf));
 500          st->cr();
 501        } else {
 502          st->print_cr("Current thread is native thread");
 503        }
 504        st->cr();
 505      }
 506 
 507   STEP(190, "(printing current compile task)" )
 508 
 509      if (_verbose && _thread && _thread->is_Compiler_thread()) {
 510         CompilerThread* t = (CompilerThread*)_thread;
 511         if (t->task()) {
 512            st->cr();
 513            st->print_cr("Current CompileTask:");
 514            t->task()->print_line_on_error(st, buf, sizeof(buf));
 515            st->cr();
 516         }
 517      }
 518 
 519 
 520   STEP(200, "(printing stack bounds)" )
 521 
 522      if (_verbose) {
 523        st->print("Stack: ");
 524 
 525        address stack_top;
 526        size_t stack_size;
 527 
 528        if (_thread) {
 529           stack_top = _thread->stack_base();
 530           stack_size = _thread->stack_size();
 531        } else {
 532           stack_top = os::current_stack_base();
 533           stack_size = os::current_stack_size();
 534        }
 535 
 536        address stack_bottom = stack_top - stack_size;
 537        st->print("[" PTR_FORMAT "," PTR_FORMAT "]", stack_bottom, stack_top);
 538 
 539        frame fr = _context ? os::fetch_frame_from_context(_context)
 540                            : os::current_frame();
 541 
 542        if (fr.sp()) {
 543          st->print(",  sp=" PTR_FORMAT, fr.sp());
 544          size_t free_stack_size = pointer_delta(fr.sp(), stack_bottom, 1024);
 545          st->print(",  free space=" SIZE_FORMAT "k", free_stack_size);
 546        }
 547 
 548        st->cr();
 549      }
 550 
 551   STEP(210, "(printing native stack)" )
 552 
 553    if (_verbose) {
 554      if (os::platform_print_native_stack(st, _context, buf, sizeof(buf))) {
 555        // We have printed the native stack in platform-specific code
 556        // Windows/x64 needs special handling.
 557      } else {
 558        frame fr = _context ? os::fetch_frame_from_context(_context)
 559                            : os::current_frame();
 560 
 561        print_native_stack(st, fr, _thread, buf, sizeof(buf));
 562      }
 563    }
 564 
 565   STEP(220, "(printing Java stack)" )
 566 
 567      if (_verbose && _thread && _thread->is_Java_thread()) {
 568        print_stack_trace(st, (JavaThread*)_thread, buf, sizeof(buf));
 569      }
 570 
 571   STEP(230, "(printing target Java thread stack)" )
 572 
 573      // printing Java thread stack trace if it is involved in GC crash
 574      if (_verbose && _thread && (_thread->is_Named_thread())) {
 575        JavaThread*  jt = ((NamedThread *)_thread)->processed_thread();
 576        if (jt != NULL) {
 577          st->print_cr("JavaThread " PTR_FORMAT " (nid = " UINTX_FORMAT ") was being processed", jt, jt->osthread()->thread_id());
 578          print_stack_trace(st, jt, buf, sizeof(buf), true);
 579        }
 580      }
 581 
 582   STEP(240, "(printing siginfo)" )
 583 
 584      // signal no, signal code, address that caused the fault
 585      if (_verbose && _siginfo) {
 586        st->cr();
 587        os::print_siginfo(st, _siginfo);
 588        st->cr();
 589      }
 590 
 591   STEP(250, "(printing register info)")
 592 
 593      // decode register contents if possible
 594      if (_verbose && _context && Universe::is_fully_initialized()) {
 595        os::print_register_info(st, _context);
 596        st->cr();
 597      }


 669        Exceptions::print_exception_counts_on_error(st);
 670        st->cr();
 671      }
 672 
 673   STEP(330, "(printing compressed oops mode")
 674 
 675      if (_verbose && UseCompressedOops) {
 676        Universe::print_compressed_oops_mode(st);
 677        if (UseCompressedClassPointers) {
 678          Metaspace::print_compressed_class_space(st);
 679        }
 680        st->cr();
 681      }
 682 
 683   STEP(340, "(printing heap information)" )
 684 
 685      if (_verbose && Universe::is_fully_initialized()) {
 686        Universe::heap()->print_on_error(st);
 687        st->cr();
 688 
 689        st->print_cr("Polling page: " INTPTR_FORMAT, os::get_polling_page());
 690        st->cr();
 691      }
 692 
 693   STEP(350, "(printing code cache information)" )
 694 
 695      if (_verbose && Universe::is_fully_initialized()) {
 696        // print code cache information before vm abort
 697        CodeCache::print_summary(st);
 698        st->cr();
 699      }
 700 
 701   STEP(360, "(printing ring buffers)" )
 702 
 703      if (_verbose) {
 704        Events::print_all(st);
 705        st->cr();
 706      }
 707 
 708   STEP(370, "(printing dynamic libraries)" )
 709 




  28 #include "compiler/compileBroker.hpp"
  29 #include "gc/shared/collectedHeap.hpp"
  30 #include "prims/whitebox.hpp"
  31 #include "runtime/arguments.hpp"
  32 #include "runtime/atomic.inline.hpp"
  33 #include "runtime/frame.inline.hpp"
  34 #include "runtime/init.hpp"
  35 #include "runtime/os.hpp"
  36 #include "runtime/thread.inline.hpp"
  37 #include "runtime/vmThread.hpp"
  38 #include "runtime/vm_operations.hpp"
  39 #include "services/memTracker.hpp"
  40 #include "utilities/debug.hpp"
  41 #include "utilities/decoder.hpp"
  42 #include "utilities/defaultStream.hpp"
  43 #include "utilities/errorReporter.hpp"
  44 #include "utilities/events.hpp"
  45 #include "utilities/top.hpp"
  46 #include "utilities/vmError.hpp"
  47 


  48 // List of environment variables that should be reported in error log file.
  49 const char *env_list[] = {
  50   // All platforms
  51   "JAVA_HOME", "JRE_HOME", "JAVA_TOOL_OPTIONS", "_JAVA_OPTIONS", "CLASSPATH",
  52   "JAVA_COMPILER", "PATH", "USERNAME",
  53 
  54   // Env variables that are defined on Solaris/Linux/BSD
  55   "LD_LIBRARY_PATH", "LD_PRELOAD", "SHELL", "DISPLAY",
  56   "HOSTTYPE", "OSTYPE", "ARCH", "MACHTYPE",
  57 
  58   // defined on Linux
  59   "LD_ASSUME_KERNEL", "_JAVA_SR_SIGNUM",
  60 
  61   // defined on Darwin
  62   "DYLD_LIBRARY_PATH", "DYLD_FALLBACK_LIBRARY_PATH",
  63   "DYLD_FRAMEWORK_PATH", "DYLD_FALLBACK_FRAMEWORK_PATH",
  64   "DYLD_INSERT_LIBRARIES",
  65 
  66   // defined on Windows
  67   "OS", "PROCESSOR_IDENTIFIER", "_ALT_JAVA_HOME_DIR",


 265 
 266   BEGIN
 267 
 268   STEP(10, "(printing fatal error message)")
 269 
 270     st->print_cr("#");
 271     if (should_report_bug(_id)) {
 272       st->print_cr("# A fatal error has been detected by the Java Runtime Environment:");
 273     } else {
 274       st->print_cr("# There is insufficient memory for the Java "
 275                    "Runtime Environment to continue.");
 276     }
 277 
 278 #ifndef PRODUCT
 279   // Error handler self tests
 280 
 281   // test secondary error handling. Test it twice, to test that resetting
 282   // error handler after a secondary crash works.
 283   STEP(20, "(test secondary crash 1)")
 284     if (_verbose && TestCrashInErrorHandler != 0) {
 285       st->print_cr("Will crash now (TestCrashInErrorHandler=" UINTX_FORMAT ")...",
 286         TestCrashInErrorHandler);
 287       controlled_crash(TestCrashInErrorHandler);
 288     }
 289 
 290   STEP(30, "(test secondary crash 2)")
 291     if (_verbose && TestCrashInErrorHandler != 0) {
 292       st->print_cr("Will crash now (TestCrashInErrorHandler=" UINTX_FORMAT ")...",
 293         TestCrashInErrorHandler);
 294       controlled_crash(TestCrashInErrorHandler);
 295     }
 296 
 297   STEP(40, "(test safefetch in error handler)")
 298     // test whether it is safe to use SafeFetch32 in Crash Handler. Test twice
 299     // to test that resetting the signal handler works correctly.
 300     if (_verbose && TestSafeFetchInErrorHandler) {
 301       st->print_cr("Will test SafeFetch...");
 302       if (CanUseSafeFetch32()) {
 303         int* const invalid_pointer = (int*) get_segfault_address();
 304         const int x = 0x76543210;
 305         int i1 = SafeFetch32(invalid_pointer, x);
 306         int i2 = SafeFetch32(invalid_pointer, x);
 307         if (i1 == x && i2 == x) {
 308           st->print_cr("SafeFetch OK."); // Correctly deflected and returned default pattern
 309         } else {
 310           st->print_cr("??");
 311         }
 312       } else {


 341          // In error file give some solutions
 342          if (_verbose) {
 343            print_oom_reasons(st);
 344          } else {
 345            return;  // that's enough for the screen
 346          }
 347          break;
 348        case INTERNAL_ERROR:
 349        default:
 350          break;
 351      }
 352 
 353   STEP(60, "(printing exception/signal name)")
 354 
 355      st->print_cr("#");
 356      st->print("#  ");
 357      // Is it an OS exception/signal?
 358      if (os::exception_name(_id, buf, sizeof(buf))) {
 359        st->print("%s", buf);
 360        st->print(" (0x%x)", _id);                // signal number
 361        st->print(" at pc=" PTR_FORMAT, p2i(_pc));
 362      } else {
 363        if (should_report_bug(_id)) {
 364          st->print("Internal Error");
 365        } else {
 366          st->print("Out of Memory Error");
 367        }
 368        if (_filename != NULL && _lineno > 0) {
 369 #ifdef PRODUCT
 370          // In product mode chop off pathname?
 371          char separator = os::file_separator()[0];
 372          const char *p = strrchr(_filename, separator);
 373          const char *file = p ? p+1 : _filename;
 374 #else
 375          const char *file = _filename;
 376 #endif
 377          st->print(" (%s:%d)", file, _lineno);
 378        } else {
 379          st->print(" (0x%x)", _id);
 380        }
 381      }


 476 
 477   STEP(160, "(printing date and time)" )
 478 
 479      if (_verbose) {
 480        os::print_date_and_time(st, buf, sizeof(buf));
 481      }
 482 
 483   STEP(170, "(printing thread)" )
 484 
 485      if (_verbose) {
 486        st->cr();
 487        st->print_cr("---------------  T H R E A D  ---------------");
 488        st->cr();
 489      }
 490 
 491   STEP(180, "(printing current thread)" )
 492 
 493      // current thread
 494      if (_verbose) {
 495        if (_thread) {
 496          st->print("Current thread (" PTR_FORMAT "):  ", p2i(_thread));
 497          _thread->print_on_error(st, buf, sizeof(buf));
 498          st->cr();
 499        } else {
 500          st->print_cr("Current thread is native thread");
 501        }
 502        st->cr();
 503      }
 504 
 505   STEP(190, "(printing current compile task)" )
 506 
 507      if (_verbose && _thread && _thread->is_Compiler_thread()) {
 508         CompilerThread* t = (CompilerThread*)_thread;
 509         if (t->task()) {
 510            st->cr();
 511            st->print_cr("Current CompileTask:");
 512            t->task()->print_line_on_error(st, buf, sizeof(buf));
 513            st->cr();
 514         }
 515      }
 516 
 517 
 518   STEP(200, "(printing stack bounds)" )
 519 
 520      if (_verbose) {
 521        st->print("Stack: ");
 522 
 523        address stack_top;
 524        size_t stack_size;
 525 
 526        if (_thread) {
 527           stack_top = _thread->stack_base();
 528           stack_size = _thread->stack_size();
 529        } else {
 530           stack_top = os::current_stack_base();
 531           stack_size = os::current_stack_size();
 532        }
 533 
 534        address stack_bottom = stack_top - stack_size;
 535        st->print("[" PTR_FORMAT "," PTR_FORMAT "]", p2i(stack_bottom), p2i(stack_top));
 536 
 537        frame fr = _context ? os::fetch_frame_from_context(_context)
 538                            : os::current_frame();
 539 
 540        if (fr.sp()) {
 541          st->print(",  sp=" PTR_FORMAT, p2i(fr.sp()));
 542          size_t free_stack_size = pointer_delta(fr.sp(), stack_bottom, 1024);
 543          st->print(",  free space=" SIZE_FORMAT "k", free_stack_size);
 544        }
 545 
 546        st->cr();
 547      }
 548 
 549   STEP(210, "(printing native stack)" )
 550 
 551    if (_verbose) {
 552      if (os::platform_print_native_stack(st, _context, buf, sizeof(buf))) {
 553        // We have printed the native stack in platform-specific code
 554        // Windows/x64 needs special handling.
 555      } else {
 556        frame fr = _context ? os::fetch_frame_from_context(_context)
 557                            : os::current_frame();
 558 
 559        print_native_stack(st, fr, _thread, buf, sizeof(buf));
 560      }
 561    }
 562 
 563   STEP(220, "(printing Java stack)" )
 564 
 565      if (_verbose && _thread && _thread->is_Java_thread()) {
 566        print_stack_trace(st, (JavaThread*)_thread, buf, sizeof(buf));
 567      }
 568 
 569   STEP(230, "(printing target Java thread stack)" )
 570 
 571      // printing Java thread stack trace if it is involved in GC crash
 572      if (_verbose && _thread && (_thread->is_Named_thread())) {
 573        JavaThread*  jt = ((NamedThread *)_thread)->processed_thread();
 574        if (jt != NULL) {
 575          st->print_cr("JavaThread " PTR_FORMAT " (nid = %d) was being processed", p2i(jt), jt->osthread()->thread_id());
 576          print_stack_trace(st, jt, buf, sizeof(buf), true);
 577        }
 578      }
 579 
 580   STEP(240, "(printing siginfo)" )
 581 
 582      // signal no, signal code, address that caused the fault
 583      if (_verbose && _siginfo) {
 584        st->cr();
 585        os::print_siginfo(st, _siginfo);
 586        st->cr();
 587      }
 588 
 589   STEP(250, "(printing register info)")
 590 
 591      // decode register contents if possible
 592      if (_verbose && _context && Universe::is_fully_initialized()) {
 593        os::print_register_info(st, _context);
 594        st->cr();
 595      }


 667        Exceptions::print_exception_counts_on_error(st);
 668        st->cr();
 669      }
 670 
 671   STEP(330, "(printing compressed oops mode")
 672 
 673      if (_verbose && UseCompressedOops) {
 674        Universe::print_compressed_oops_mode(st);
 675        if (UseCompressedClassPointers) {
 676          Metaspace::print_compressed_class_space(st);
 677        }
 678        st->cr();
 679      }
 680 
 681   STEP(340, "(printing heap information)" )
 682 
 683      if (_verbose && Universe::is_fully_initialized()) {
 684        Universe::heap()->print_on_error(st);
 685        st->cr();
 686 
 687        st->print_cr("Polling page: " INTPTR_FORMAT, p2i(os::get_polling_page()));
 688        st->cr();
 689      }
 690 
 691   STEP(350, "(printing code cache information)" )
 692 
 693      if (_verbose && Universe::is_fully_initialized()) {
 694        // print code cache information before vm abort
 695        CodeCache::print_summary(st);
 696        st->cr();
 697      }
 698 
 699   STEP(360, "(printing ring buffers)" )
 700 
 701      if (_verbose) {
 702        Events::print_all(st);
 703        st->cr();
 704      }
 705 
 706   STEP(370, "(printing dynamic libraries)" )
 707 


< prev index next >