335 void VMError::report(outputStream* st) {
336 # define BEGIN if (_current_step == 0) { _current_step = 1;
337 # define STEP(n, s) } if (_current_step < n) { _current_step = n; _current_step_info = s;
338 # define END }
339
340 // don't allocate large buffer on stack
341 static char buf[O_BUFLEN];
342
343 BEGIN
344
345 STEP(10, "(printing fatal error message)")
346
347 st->print_cr("#");
348 if (should_report_bug(_id)) {
349 st->print_cr("# A fatal error has been detected by the Java Runtime Environment:");
350 } else {
351 st->print_cr("# There is insufficient memory for the Java "
352 "Runtime Environment to continue.");
353 }
354
355 STEP(15, "(printing type of error)")
356
357 switch(_id) {
358 case OOM_MALLOC_ERROR:
359 case OOM_MMAP_ERROR:
360 if (_size) {
361 st->print("# Native memory allocation ");
362 st->print((_id == (int)OOM_MALLOC_ERROR) ? "(malloc) failed to allocate " :
363 "(mmap) failed to map ");
364 jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size);
365 st->print("%s", buf);
366 st->print(" bytes");
367 if (_message != NULL) {
368 st->print(" for ");
369 st->print("%s", _message);
370 }
371 st->cr();
372 } else {
373 if (_message != NULL)
374 st->print("# ");
768
769 if (_verbose) {
770 os::print_memory_info(st);
771 st->cr();
772 }
773
774 STEP(270, "(printing internal vm info)" )
775
776 if (_verbose) {
777 st->print_cr("vm_info: %s", Abstract_VM_Version::internal_vm_info_string());
778 st->cr();
779 }
780
781 STEP(280, "(printing date and time)" )
782
783 if (_verbose) {
784 os::print_date_and_time(st);
785 st->cr();
786 }
787
788 END
789
790 # undef BEGIN
791 # undef STEP
792 # undef END
793 }
794
795 VMError* volatile VMError::first_error = NULL;
796 volatile jlong VMError::first_error_tid = -1;
797
798 // An error could happen before tty is initialized or after it has been
799 // destroyed. Here we use a very simple unbuffered fdStream for printing.
800 // Only out.print_raw() and out.print_raw_cr() should be used, as other
801 // printing methods need to allocate large buffer on stack. To format a
802 // string, use jio_snprintf() with a static buffer or use staticBufferStream.
803 fdStream VMError::out(defaultStream::output_fd());
804 fdStream VMError::log; // error log used by VMError::report_and_die()
805
806 /** Expand a pattern into a buffer starting at pos and open a file using constructed path */
807 static int expand_and_open(const char* pattern, char* buf, size_t buflen, size_t pos) {
|
335 void VMError::report(outputStream* st) {
336 # define BEGIN if (_current_step == 0) { _current_step = 1;
337 # define STEP(n, s) } if (_current_step < n) { _current_step = n; _current_step_info = s;
338 # define END }
339
340 // don't allocate large buffer on stack
341 static char buf[O_BUFLEN];
342
343 BEGIN
344
345 STEP(10, "(printing fatal error message)")
346
347 st->print_cr("#");
348 if (should_report_bug(_id)) {
349 st->print_cr("# A fatal error has been detected by the Java Runtime Environment:");
350 } else {
351 st->print_cr("# There is insufficient memory for the Java "
352 "Runtime Environment to continue.");
353 }
354
355 #ifndef PRODUCT
356 // Error handler self tests
357
358 // test secondary error handling. Test it twice, to test that resetting
359 // error handler after a secondary crash works.
360 STEP(13, "(test secondary crash 1)")
361 if (TestCrashInErrorHandler != 0) {
362 controlled_crash(TestCrashInErrorHandler);
363 }
364
365 STEP(14, "(test secondary crash 2)")
366 if (TestCrashInErrorHandler != 0) {
367 controlled_crash(TestCrashInErrorHandler);
368 }
369 #endif // PRODUCT
370
371 STEP(15, "(printing type of error)")
372
373 switch(_id) {
374 case OOM_MALLOC_ERROR:
375 case OOM_MMAP_ERROR:
376 if (_size) {
377 st->print("# Native memory allocation ");
378 st->print((_id == (int)OOM_MALLOC_ERROR) ? "(malloc) failed to allocate " :
379 "(mmap) failed to map ");
380 jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size);
381 st->print("%s", buf);
382 st->print(" bytes");
383 if (_message != NULL) {
384 st->print(" for ");
385 st->print("%s", _message);
386 }
387 st->cr();
388 } else {
389 if (_message != NULL)
390 st->print("# ");
784
785 if (_verbose) {
786 os::print_memory_info(st);
787 st->cr();
788 }
789
790 STEP(270, "(printing internal vm info)" )
791
792 if (_verbose) {
793 st->print_cr("vm_info: %s", Abstract_VM_Version::internal_vm_info_string());
794 st->cr();
795 }
796
797 STEP(280, "(printing date and time)" )
798
799 if (_verbose) {
800 os::print_date_and_time(st);
801 st->cr();
802 }
803
804 #ifdef PRODUCT
805 // print a defined marker to show that error handling finished correctly.
806 STEP(290, "(printing end marker)" )
807
808 if (_verbose) {
809 st->print_cr("END.");
810 }
811 #endif
812
813 END
814
815 # undef BEGIN
816 # undef STEP
817 # undef END
818 }
819
820 VMError* volatile VMError::first_error = NULL;
821 volatile jlong VMError::first_error_tid = -1;
822
823 // An error could happen before tty is initialized or after it has been
824 // destroyed. Here we use a very simple unbuffered fdStream for printing.
825 // Only out.print_raw() and out.print_raw_cr() should be used, as other
826 // printing methods need to allocate large buffer on stack. To format a
827 // string, use jio_snprintf() with a static buffer or use staticBufferStream.
828 fdStream VMError::out(defaultStream::output_fd());
829 fdStream VMError::log; // error log used by VMError::report_and_die()
830
831 /** Expand a pattern into a buffer starting at pos and open a file using constructed path */
832 static int expand_and_open(const char* pattern, char* buf, size_t buflen, size_t pos) {
|