1.1 --- a/src/share/vm/utilities/vmError.cpp Sun Oct 11 16:19:25 2009 -0700 1.2 +++ b/src/share/vm/utilities/vmError.cpp Thu Apr 22 13:23:15 2010 -0700 1.3 @@ -65,7 +65,8 @@ 1.4 _current_step = 0; 1.5 _current_step_info = NULL; 1.6 1.7 - _message = ""; 1.8 + _message = NULL; 1.9 + _detail_msg = NULL; 1.10 _filename = NULL; 1.11 _lineno = 0; 1.12 1.13 @@ -73,31 +74,36 @@ 1.14 } 1.15 1.16 // Constructor for internal errors 1.17 -VMError::VMError(Thread* thread, const char* message, const char* filename, int lineno) { 1.18 +VMError::VMError(Thread* thread, const char* filename, int lineno, 1.19 + const char* message, const char * detail_msg) 1.20 +{ 1.21 + _thread = thread; 1.22 + _id = internal_error; // Value that's not an OS exception/signal 1.23 + _filename = filename; 1.24 + _lineno = lineno; 1.25 + _message = message; 1.26 + _detail_msg = detail_msg; 1.27 + 1.28 + _verbose = false; 1.29 + _current_step = 0; 1.30 + _current_step_info = NULL; 1.31 + 1.32 + _pc = NULL; 1.33 + _siginfo = NULL; 1.34 + _context = NULL; 1.35 + 1.36 + _size = 0; 1.37 +} 1.38 + 1.39 +// Constructor for OOM errors 1.40 +VMError::VMError(Thread* thread, const char* filename, int lineno, size_t size, 1.41 + const char* message) { 1.42 _thread = thread; 1.43 - _id = internal_error; // set it to a value that's not an OS exception/signal 1.44 + _id = oom_error; // Value that's not an OS exception/signal 1.45 _filename = filename; 1.46 _lineno = lineno; 1.47 _message = message; 1.48 - 1.49 - _verbose = false; 1.50 - _current_step = 0; 1.51 - _current_step_info = NULL; 1.52 - 1.53 - _pc = NULL; 1.54 - _siginfo = NULL; 1.55 - _context = NULL; 1.56 - 1.57 - _size = 0; 1.58 -} 1.59 - 1.60 -// Constructor for OOM errors 1.61 -VMError::VMError(Thread* thread, size_t size, const char* message, const char* filename, int lineno) { 1.62 - _thread = thread; 1.63 - _id = oom_error; // set it to a value that's not an OS exception/signal 1.64 - _filename = filename; 1.65 - _lineno = lineno; 1.66 - _message = message; 1.67 + _detail_msg = NULL; 1.68 1.69 _verbose = false; 1.70 _current_step = 0; 1.71 @@ -114,10 +120,11 @@ 1.72 // Constructor for non-fatal errors 1.73 VMError::VMError(const char* message) { 1.74 _thread = NULL; 1.75 - _id = internal_error; // set it to a value that's not an OS exception/signal 1.76 + _id = internal_error; // Value that's not an OS exception/signal 1.77 _filename = NULL; 1.78 _lineno = 0; 1.79 _message = message; 1.80 + _detail_msg = NULL; 1.81 1.82 _verbose = false; 1.83 _current_step = 0; 1.84 @@ -191,22 +198,27 @@ 1.85 "%s (0x%x) at pc=" PTR_FORMAT ", pid=%d, tid=" UINTX_FORMAT, 1.86 signame, _id, _pc, 1.87 os::current_process_id(), os::current_thread_id()); 1.88 + } else if (_filename != NULL && _lineno > 0) { 1.89 + // skip directory names 1.90 + char separator = os::file_separator()[0]; 1.91 + const char *p = strrchr(_filename, separator); 1.92 + int n = jio_snprintf(buf, buflen, 1.93 + "Internal Error at %s:%d, pid=%d, tid=" UINTX_FORMAT, 1.94 + p ? p + 1 : _filename, _lineno, 1.95 + os::current_process_id(), os::current_thread_id()); 1.96 + if (n >= 0 && n < buflen && _message) { 1.97 + if (_detail_msg) { 1.98 + jio_snprintf(buf + n, buflen - n, "%s%s: %s", 1.99 + os::line_separator(), _message, _detail_msg); 1.100 + } else { 1.101 + jio_snprintf(buf + n, buflen - n, "%sError: %s", 1.102 + os::line_separator(), _message); 1.103 + } 1.104 + } 1.105 } else { 1.106 - if (_filename != NULL && _lineno > 0) { 1.107 - // skip directory names 1.108 - char separator = os::file_separator()[0]; 1.109 - const char *p = strrchr(_filename, separator); 1.110 - 1.111 - jio_snprintf(buf, buflen, 1.112 - "Internal Error at %s:%d, pid=%d, tid=" UINTX_FORMAT " \nError: %s", 1.113 - p ? p + 1 : _filename, _lineno, 1.114 - os::current_process_id(), os::current_thread_id(), 1.115 - _message ? _message : ""); 1.116 - } else { 1.117 - jio_snprintf(buf, buflen, 1.118 - "Internal Error (0x%x), pid=%d, tid=" UINTX_FORMAT, 1.119 - _id, os::current_process_id(), os::current_thread_id()); 1.120 - } 1.121 + jio_snprintf(buf, buflen, 1.122 + "Internal Error (0x%x), pid=%d, tid=" UINTX_FORMAT, 1.123 + _id, os::current_process_id(), os::current_thread_id()); 1.124 } 1.125 1.126 return buf; 1.127 @@ -369,7 +381,9 @@ 1.128 STEP(40, "(printing error message)") 1.129 1.130 // error message 1.131 - if (_message && _message[0] != '\0') { 1.132 + if (_detail_msg) { 1.133 + st->print_cr("# %s: %s", _message ? _message : "Error", _detail_msg); 1.134 + } else if (_message) { 1.135 st->print_cr("# Error: %s", _message); 1.136 } 1.137