1 /* |
1 /* |
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
797 } |
797 } |
798 |
798 |
799 VMError* volatile VMError::first_error = NULL; |
799 VMError* volatile VMError::first_error = NULL; |
800 volatile jlong VMError::first_error_tid = -1; |
800 volatile jlong VMError::first_error_tid = -1; |
801 |
801 |
|
802 // An error could happen before tty is initialized or after it has been |
|
803 // destroyed. Here we use a very simple unbuffered fdStream for printing. |
|
804 // Only out.print_raw() and out.print_raw_cr() should be used, as other |
|
805 // printing methods need to allocate large buffer on stack. To format a |
|
806 // string, use jio_snprintf() with a static buffer or use staticBufferStream. |
|
807 fdStream VMError::out(defaultStream::output_fd()); |
|
808 fdStream VMError::log; // error log used by VMError::report_and_die() |
|
809 |
802 /** Expand a pattern into a buffer starting at pos and open a file using constructed path */ |
810 /** Expand a pattern into a buffer starting at pos and open a file using constructed path */ |
803 static int expand_and_open(const char* pattern, char* buf, size_t buflen, size_t pos) { |
811 static int expand_and_open(const char* pattern, char* buf, size_t buflen, size_t pos) { |
804 int fd = -1; |
812 int fd = -1; |
805 if (Arguments::copy_expand_pid(pattern, strlen(pattern), &buf[pos], buflen - pos)) { |
813 if (Arguments::copy_expand_pid(pattern, strlen(pattern), &buf[pos], buflen - pos)) { |
806 fd = open(buf, O_RDWR | O_CREAT | O_TRUNC, 0666); |
814 fd = open(buf, O_RDWR | O_CREAT | O_TRUNC, 0666); |
851 |
859 |
852 void VMError::report_and_die() { |
860 void VMError::report_and_die() { |
853 // Don't allocate large buffer on stack |
861 // Don't allocate large buffer on stack |
854 static char buffer[O_BUFLEN]; |
862 static char buffer[O_BUFLEN]; |
855 |
863 |
856 // An error could happen before tty is initialized or after it has been |
|
857 // destroyed. Here we use a very simple unbuffered fdStream for printing. |
|
858 // Only out.print_raw() and out.print_raw_cr() should be used, as other |
|
859 // printing methods need to allocate large buffer on stack. To format a |
|
860 // string, use jio_snprintf() with a static buffer or use staticBufferStream. |
|
861 static fdStream out(defaultStream::output_fd()); |
|
862 |
|
863 // How many errors occurred in error handler when reporting first_error. |
864 // How many errors occurred in error handler when reporting first_error. |
864 static int recursive_error_count; |
865 static int recursive_error_count; |
865 |
866 |
866 // We will first print a brief message to standard out (verbose = false), |
867 // We will first print a brief message to standard out (verbose = false), |
867 // then save detailed information in log file (verbose = true). |
868 // then save detailed information in log file (verbose = true). |
868 static bool out_done = false; // done printing to standard out |
869 static bool out_done = false; // done printing to standard out |
869 static bool log_done = false; // done saving error log |
870 static bool log_done = false; // done saving error log |
870 static bool transmit_report_done = false; // done error reporting |
871 static bool transmit_report_done = false; // done error reporting |
871 static fdStream log; // error log |
|
872 |
872 |
873 // disble NMT to avoid further exception |
873 // disble NMT to avoid further exception |
874 MemTracker::shutdown(MemTracker::NMT_error_reporting); |
874 MemTracker::shutdown(MemTracker::NMT_error_reporting); |
875 |
875 |
876 if (SuppressFatalErrorMessage) { |
876 if (SuppressFatalErrorMessage) { |