Mercurial > hg > truffle
comparison src/share/vm/utilities/vmError.cpp @ 1490:f03d0a26bf83
6888954: argument formatting for assert() and friends
Reviewed-by: kvn, twisti, apetrusenko, never, dcubed
author | jcoomes |
---|---|
date | Thu, 22 Apr 2010 13:23:15 -0700 |
parents | c544d979f886 |
children | c18cbe5936b8 |
comparison
equal
deleted
inserted
replaced
1489:cff162798819 | 1490:f03d0a26bf83 |
---|---|
63 | 63 |
64 _verbose = false; | 64 _verbose = false; |
65 _current_step = 0; | 65 _current_step = 0; |
66 _current_step_info = NULL; | 66 _current_step_info = NULL; |
67 | 67 |
68 _message = ""; | 68 _message = NULL; |
69 _detail_msg = NULL; | |
69 _filename = NULL; | 70 _filename = NULL; |
70 _lineno = 0; | 71 _lineno = 0; |
71 | 72 |
72 _size = 0; | 73 _size = 0; |
73 } | 74 } |
74 | 75 |
75 // Constructor for internal errors | 76 // Constructor for internal errors |
76 VMError::VMError(Thread* thread, const char* message, const char* filename, int lineno) { | 77 VMError::VMError(Thread* thread, const char* filename, int lineno, |
78 const char* message, const char * detail_msg) | |
79 { | |
80 _thread = thread; | |
81 _id = internal_error; // Value that's not an OS exception/signal | |
82 _filename = filename; | |
83 _lineno = lineno; | |
84 _message = message; | |
85 _detail_msg = detail_msg; | |
86 | |
87 _verbose = false; | |
88 _current_step = 0; | |
89 _current_step_info = NULL; | |
90 | |
91 _pc = NULL; | |
92 _siginfo = NULL; | |
93 _context = NULL; | |
94 | |
95 _size = 0; | |
96 } | |
97 | |
98 // Constructor for OOM errors | |
99 VMError::VMError(Thread* thread, const char* filename, int lineno, size_t size, | |
100 const char* message) { | |
77 _thread = thread; | 101 _thread = thread; |
78 _id = internal_error; // set it to a value that's not an OS exception/signal | 102 _id = oom_error; // Value that's not an OS exception/signal |
79 _filename = filename; | 103 _filename = filename; |
80 _lineno = lineno; | 104 _lineno = lineno; |
81 _message = message; | 105 _message = message; |
106 _detail_msg = NULL; | |
82 | 107 |
83 _verbose = false; | 108 _verbose = false; |
84 _current_step = 0; | 109 _current_step = 0; |
85 _current_step_info = NULL; | 110 _current_step_info = NULL; |
86 | 111 |
87 _pc = NULL; | 112 _pc = NULL; |
88 _siginfo = NULL; | 113 _siginfo = NULL; |
89 _context = NULL; | 114 _context = NULL; |
90 | 115 |
91 _size = 0; | |
92 } | |
93 | |
94 // Constructor for OOM errors | |
95 VMError::VMError(Thread* thread, size_t size, const char* message, const char* filename, int lineno) { | |
96 _thread = thread; | |
97 _id = oom_error; // set it to a value that's not an OS exception/signal | |
98 _filename = filename; | |
99 _lineno = lineno; | |
100 _message = message; | |
101 | |
102 _verbose = false; | |
103 _current_step = 0; | |
104 _current_step_info = NULL; | |
105 | |
106 _pc = NULL; | |
107 _siginfo = NULL; | |
108 _context = NULL; | |
109 | |
110 _size = size; | 116 _size = size; |
111 } | 117 } |
112 | 118 |
113 | 119 |
114 // Constructor for non-fatal errors | 120 // Constructor for non-fatal errors |
115 VMError::VMError(const char* message) { | 121 VMError::VMError(const char* message) { |
116 _thread = NULL; | 122 _thread = NULL; |
117 _id = internal_error; // set it to a value that's not an OS exception/signal | 123 _id = internal_error; // Value that's not an OS exception/signal |
118 _filename = NULL; | 124 _filename = NULL; |
119 _lineno = 0; | 125 _lineno = 0; |
120 _message = message; | 126 _message = message; |
127 _detail_msg = NULL; | |
121 | 128 |
122 _verbose = false; | 129 _verbose = false; |
123 _current_step = 0; | 130 _current_step = 0; |
124 _current_step_info = NULL; | 131 _current_step_info = NULL; |
125 | 132 |
189 if (signame) { | 196 if (signame) { |
190 jio_snprintf(buf, buflen, | 197 jio_snprintf(buf, buflen, |
191 "%s (0x%x) at pc=" PTR_FORMAT ", pid=%d, tid=" UINTX_FORMAT, | 198 "%s (0x%x) at pc=" PTR_FORMAT ", pid=%d, tid=" UINTX_FORMAT, |
192 signame, _id, _pc, | 199 signame, _id, _pc, |
193 os::current_process_id(), os::current_thread_id()); | 200 os::current_process_id(), os::current_thread_id()); |
201 } else if (_filename != NULL && _lineno > 0) { | |
202 // skip directory names | |
203 char separator = os::file_separator()[0]; | |
204 const char *p = strrchr(_filename, separator); | |
205 int n = jio_snprintf(buf, buflen, | |
206 "Internal Error at %s:%d, pid=%d, tid=" UINTX_FORMAT, | |
207 p ? p + 1 : _filename, _lineno, | |
208 os::current_process_id(), os::current_thread_id()); | |
209 if (n >= 0 && n < buflen && _message) { | |
210 if (_detail_msg) { | |
211 jio_snprintf(buf + n, buflen - n, "%s%s: %s", | |
212 os::line_separator(), _message, _detail_msg); | |
213 } else { | |
214 jio_snprintf(buf + n, buflen - n, "%sError: %s", | |
215 os::line_separator(), _message); | |
216 } | |
217 } | |
194 } else { | 218 } else { |
195 if (_filename != NULL && _lineno > 0) { | 219 jio_snprintf(buf, buflen, |
196 // skip directory names | 220 "Internal Error (0x%x), pid=%d, tid=" UINTX_FORMAT, |
197 char separator = os::file_separator()[0]; | 221 _id, os::current_process_id(), os::current_thread_id()); |
198 const char *p = strrchr(_filename, separator); | |
199 | |
200 jio_snprintf(buf, buflen, | |
201 "Internal Error at %s:%d, pid=%d, tid=" UINTX_FORMAT " \nError: %s", | |
202 p ? p + 1 : _filename, _lineno, | |
203 os::current_process_id(), os::current_thread_id(), | |
204 _message ? _message : ""); | |
205 } else { | |
206 jio_snprintf(buf, buflen, | |
207 "Internal Error (0x%x), pid=%d, tid=" UINTX_FORMAT, | |
208 _id, os::current_process_id(), os::current_thread_id()); | |
209 } | |
210 } | 222 } |
211 | 223 |
212 return buf; | 224 return buf; |
213 } | 225 } |
214 | 226 |
367 st->cr(); | 379 st->cr(); |
368 | 380 |
369 STEP(40, "(printing error message)") | 381 STEP(40, "(printing error message)") |
370 | 382 |
371 // error message | 383 // error message |
372 if (_message && _message[0] != '\0') { | 384 if (_detail_msg) { |
385 st->print_cr("# %s: %s", _message ? _message : "Error", _detail_msg); | |
386 } else if (_message) { | |
373 st->print_cr("# Error: %s", _message); | 387 st->print_cr("# Error: %s", _message); |
374 } | 388 } |
375 | 389 |
376 STEP(50, "(printing Java version string)") | 390 STEP(50, "(printing Java version string)") |
377 | 391 |