79 #endif // PRODUCT |
79 #endif // PRODUCT |
80 |
80 |
81 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
81 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
82 |
82 |
83 FormatBufferResource::FormatBufferResource(const char * format, ...) |
83 FormatBufferResource::FormatBufferResource(const char * format, ...) |
84 : FormatBufferBase((char*)resource_allocate_bytes(RES_BUFSZ)) { |
84 : FormatBufferBase((char*)resource_allocate_bytes(FormatBufferBase::BufferSize)) { |
85 va_list argp; |
85 va_list argp; |
86 va_start(argp, format); |
86 va_start(argp, format); |
87 jio_vsnprintf(_buf, RES_BUFSZ, format, argp); |
87 jio_vsnprintf(_buf, FormatBufferBase::BufferSize, format, argp); |
88 va_end(argp); |
88 va_end(argp); |
89 } |
89 } |
90 |
90 |
91 ATTRIBUTE_PRINTF(1, 2) |
91 ATTRIBUTE_PRINTF(1, 2) |
92 void warning(const char* format, ...) { |
92 void warning(const char* format, ...) { |
205 // Place-holder for non-existent suppression check: |
205 // Place-holder for non-existent suppression check: |
206 #define error_is_suppressed(file_name, line_no) (false) |
206 #define error_is_suppressed(file_name, line_no) (false) |
207 |
207 |
208 #endif // !PRODUCT |
208 #endif // !PRODUCT |
209 |
209 |
210 void report_vm_error(const char* file, int line, const char* error_msg, |
210 void report_vm_error(const char* file, int line, const char* error_msg) |
211 const char* detail_msg) |
211 { |
|
212 report_vm_error(file, line, error_msg, "%s", ""); |
|
213 } |
|
214 |
|
215 void report_vm_error(const char* file, int line, const char* error_msg, const char* detail_fmt, ...) |
212 { |
216 { |
213 if (Debugging || error_is_suppressed(file, line)) return; |
217 if (Debugging || error_is_suppressed(file, line)) return; |
214 Thread* const thread = ThreadLocalStorage::get_thread_slow(); |
218 va_list detail_args; |
215 VMError err(thread, file, line, error_msg, detail_msg); |
219 va_start(detail_args, detail_fmt); |
216 err.report_and_die(); |
220 VMError::report_and_die(ThreadLocalStorage::get_thread_slow(), file, line, error_msg, detail_fmt, detail_args); |
217 } |
221 va_end(detail_args); |
218 |
222 } |
219 void report_fatal(const char* file, int line, const char* message) |
223 |
|
224 void report_fatal(const char* file, int line, const char* detail_fmt, ...) |
220 { |
225 { |
221 report_vm_error(file, line, "fatal error", message); |
226 if (Debugging || error_is_suppressed(file, line)) return; |
|
227 va_list detail_args; |
|
228 va_start(detail_args, detail_fmt); |
|
229 VMError::report_and_die(ThreadLocalStorage::get_thread_slow(), file, line, "fatal error", detail_fmt, detail_args); |
|
230 va_end(detail_args); |
222 } |
231 } |
223 |
232 |
224 void report_vm_out_of_memory(const char* file, int line, size_t size, |
233 void report_vm_out_of_memory(const char* file, int line, size_t size, |
225 VMErrorType vm_err_type, const char* message) { |
234 VMErrorType vm_err_type, const char* detail_fmt, ...) { |
226 if (Debugging) return; |
235 if (Debugging) return; |
227 |
236 va_list detail_args; |
228 Thread* thread = ThreadLocalStorage::get_thread_slow(); |
237 va_start(detail_args, detail_fmt); |
229 VMError(thread, file, line, size, vm_err_type, message).report_and_die(); |
238 VMError::report_and_die(ThreadLocalStorage::get_thread_slow(), file, line, size, vm_err_type, detail_fmt, detail_args); |
|
239 va_end(detail_args); |
230 |
240 |
231 // The UseOSErrorReporting option in report_and_die() may allow a return |
241 // The UseOSErrorReporting option in report_and_die() may allow a return |
232 // to here. If so then we'll have to figure out how to handle it. |
242 // to here. If so then we'll have to figure out how to handle it. |
233 guarantee(false, "report_and_die() should not return here"); |
243 guarantee(false, "report_and_die() should not return here"); |
234 } |
244 } |
367 |
376 |
368 // Keep this in sync with test/runtime/6888954/vmerrors.sh. |
377 // Keep this in sync with test/runtime/6888954/vmerrors.sh. |
369 switch (how) { |
378 switch (how) { |
370 case 1: vmassert(str == NULL, "expected null"); |
379 case 1: vmassert(str == NULL, "expected null"); |
371 case 2: vmassert(num == 1023 && *str == 'X', |
380 case 2: vmassert(num == 1023 && *str == 'X', |
372 err_msg("num=" SIZE_FORMAT " str=\"%s\"", num, str)); |
381 "num=" SIZE_FORMAT " str=\"%s\"", num, str); |
373 case 3: guarantee(str == NULL, "expected null"); |
382 case 3: guarantee(str == NULL, "expected null"); |
374 case 4: guarantee(num == 1023 && *str == 'X', |
383 case 4: guarantee(num == 1023 && *str == 'X', |
375 err_msg("num=" SIZE_FORMAT " str=\"%s\"", num, str)); |
384 "num=" SIZE_FORMAT " str=\"%s\"", num, str); |
376 case 5: fatal("expected null"); |
385 case 5: fatal("expected null"); |
377 case 6: fatal(err_msg("num=" SIZE_FORMAT " str=\"%s\"", num, str)); |
386 case 6: fatal("num=" SIZE_FORMAT " str=\"%s\"", num, str); |
378 case 7: fatal(err_msg("%s%s# %s%s# %s%s# %s%s# %s%s# " |
387 case 7: fatal("%s%s# %s%s# %s%s# %s%s# %s%s# " |
379 "%s%s# %s%s# %s%s# %s%s# %s%s# " |
388 "%s%s# %s%s# %s%s# %s%s# %s%s# " |
380 "%s%s# %s%s# %s%s# %s%s# %s", |
389 "%s%s# %s%s# %s%s# %s%s# %s", |
381 msg, eol, msg, eol, msg, eol, msg, eol, msg, eol, |
390 msg, eol, msg, eol, msg, eol, msg, eol, msg, eol, |
382 msg, eol, msg, eol, msg, eol, msg, eol, msg, eol, |
391 msg, eol, msg, eol, msg, eol, msg, eol, msg, eol, |
383 msg, eol, msg, eol, msg, eol, msg, eol, msg)); |
392 msg, eol, msg, eol, msg, eol, msg, eol, msg); |
384 case 8: vm_exit_out_of_memory(num, OOM_MALLOC_ERROR, "ChunkPool::allocate"); |
393 case 8: vm_exit_out_of_memory(num, OOM_MALLOC_ERROR, "ChunkPool::allocate"); |
385 case 9: ShouldNotCallThis(); |
394 case 9: ShouldNotCallThis(); |
386 case 10: ShouldNotReachHere(); |
395 case 10: ShouldNotReachHere(); |
387 case 11: Unimplemented(); |
396 case 11: Unimplemented(); |
388 // There's no guarantee the bad data pointer will crash us |
397 // There's no guarantee the bad data pointer will crash us |