comparison src/share/vm/utilities/vmError.cpp @ 11173:6b0fd0964b87

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Wed, 31 Jul 2013 11:00:54 +0200
parents 836a62f43af9 93e6dce53ba7
children cefad50507d8
comparison
equal deleted inserted replaced
10912:4ea54634f03e 11173:6b0fd0964b87
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) {
906 if (UseOSErrorReporting && log_done) return; 906 if (UseOSErrorReporting && log_done) return;
907 907
908 // This is not the first error, see if it happened in a different thread 908 // This is not the first error, see if it happened in a different thread
909 // or in the same thread during error reporting. 909 // or in the same thread during error reporting.
910 if (first_error_tid != mytid) { 910 if (first_error_tid != mytid) {
911 jio_snprintf(buffer, sizeof(buffer), 911 char msgbuf[64];
912 jio_snprintf(msgbuf, sizeof(msgbuf),
912 "[thread " INT64_FORMAT " also had an error]", 913 "[thread " INT64_FORMAT " also had an error]",
913 mytid); 914 mytid);
914 out.print_raw_cr(buffer); 915 out.print_raw_cr(msgbuf);
915 916
916 // error reporting is not MT-safe, block current thread 917 // error reporting is not MT-safe, block current thread
917 os::infinite_sleep(); 918 os::infinite_sleep();
918 919
919 } else { 920 } else {