< prev index next >

src/share/vm/utilities/debug.hpp

Print this page
rev 8977 : imported patch assert
rev 8978 : imported patch remove_err_msg
rev 8979 : [mq]: vmerr_static

*** 38,55 **** public: operator const char *() const { return _buf; } }; // Use resource area for buffer ! #define RES_BUFSZ 256 class FormatBufferResource : public FormatBufferBase { public: FormatBufferResource(const char * format, ...) ATTRIBUTE_PRINTF(2, 3); }; // Use stack for buffer ! template <size_t bufsz = 256> class FormatBuffer : public FormatBufferBase { public: inline FormatBuffer(const char * format, ...) ATTRIBUTE_PRINTF(2, 3); inline void append(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); inline void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); --- 38,55 ---- public: operator const char *() const { return _buf; } }; // Use resource area for buffer ! #define BUFSZ 256 class FormatBufferResource : public FormatBufferBase { public: FormatBufferResource(const char * format, ...) ATTRIBUTE_PRINTF(2, 3); }; // Use stack for buffer ! template <size_t bufsz = BUFSZ> class FormatBuffer : public FormatBufferBase { public: inline FormatBuffer(const char * format, ...) ATTRIBUTE_PRINTF(2, 3); inline void append(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); inline void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
*** 103,168 **** va_start(argp, format); jio_vsnprintf(buf_end, bufsz - len, format, argp); va_end(argp); } ! // Used to format messages for vmassert(), guarantee(), fatal(), etc. typedef FormatBuffer<> err_msg; - typedef FormatBufferResource err_msg_res; // assertions #ifndef ASSERT ! #define vmassert(p, msg) #else // Note: message says "assert" rather than "vmassert" for backward // compatibility with tools that parse/match the message text. ! #define vmassert(p, msg) \ do { \ if (!(p)) { \ ! report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", msg); \ BREAKPOINT; \ } \ } while (0) #endif // For backward compatibility. ! #define assert(p, msg) vmassert(p, msg) // This version of vmassert is for use with checking return status from // library calls that return actual error values eg. EINVAL, // ENOMEM etc, rather than returning -1 and setting errno. // When the status is not what is expected it is very useful to know // what status was actually returned, so we pass the status variable as // an extra arg and use strerror to convert it to a meaningful string // like "Invalid argument", "out of memory" etc #define vmassert_status(p, status, msg) \ ! vmassert(p, err_msg("error %s(%d), %s", strerror(status), status, msg)) // For backward compatibility. #define assert_status(p, status, msg) vmassert_status(p, status, msg) // guarantee is like vmassert except it's always executed -- use it for // cheap tests that catch errors that would otherwise be hard to find. // guarantee is also used for Verify options. ! #define guarantee(p, msg) \ do { \ if (!(p)) { \ ! report_vm_error(__FILE__, __LINE__, "guarantee(" #p ") failed", msg); \ BREAKPOINT; \ } \ } while (0) ! #define fatal(msg) \ do { \ ! report_fatal(__FILE__, __LINE__, msg); \ BREAKPOINT; \ } while (0) // out of memory ! #define vm_exit_out_of_memory(size, vm_err_type, msg) \ do { \ ! report_vm_out_of_memory(__FILE__, __LINE__, size, vm_err_type, msg); \ BREAKPOINT; \ } while (0) #define ShouldNotCallThis() \ do { \ --- 103,168 ---- va_start(argp, format); jio_vsnprintf(buf_end, bufsz - len, format, argp); va_end(argp); } ! // Used to format messages typedef FormatBuffer<> err_msg; // assertions #ifndef ASSERT ! #define vmassert(p, ...) #else // Note: message says "assert" rather than "vmassert" for backward // compatibility with tools that parse/match the message text. ! #define vmassert(p, ...) \ do { \ if (!(p)) { \ ! report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", __VA_ARGS__); \ BREAKPOINT; \ } \ } while (0) + #endif // For backward compatibility. ! #define assert(p, ...) vmassert(p, __VA_ARGS__) // This version of vmassert is for use with checking return status from // library calls that return actual error values eg. EINVAL, // ENOMEM etc, rather than returning -1 and setting errno. // When the status is not what is expected it is very useful to know // what status was actually returned, so we pass the status variable as // an extra arg and use strerror to convert it to a meaningful string // like "Invalid argument", "out of memory" etc #define vmassert_status(p, status, msg) \ ! vmassert(p, "error %s(%d), %s", strerror(status), status, msg) // For backward compatibility. #define assert_status(p, status, msg) vmassert_status(p, status, msg) // guarantee is like vmassert except it's always executed -- use it for // cheap tests that catch errors that would otherwise be hard to find. // guarantee is also used for Verify options. ! #define guarantee(p, ...) \ do { \ if (!(p)) { \ ! report_vm_error(__FILE__, __LINE__, "guarantee(" #p ") failed", __VA_ARGS__); \ BREAKPOINT; \ } \ } while (0) ! #define fatal(...) \ do { \ ! report_fatal(__FILE__, __LINE__, __VA_ARGS__); \ BREAKPOINT; \ } while (0) // out of memory ! #define vm_exit_out_of_memory(size, vm_err_type, ...) \ do { \ ! report_vm_out_of_memory(__FILE__, __LINE__, size, vm_err_type, __VA_ARGS__); \ BREAKPOINT; \ } while (0) #define ShouldNotCallThis() \ do { \
*** 195,209 **** OOM_MALLOC_ERROR = 0xe0000001, OOM_MMAP_ERROR = 0xe0000002 }; // error reporting helper functions void report_vm_error(const char* file, int line, const char* error_msg, ! const char* detail_msg = NULL); ! void report_fatal(const char* file, int line, const char* message); ! void report_vm_out_of_memory(const char* file, int line, size_t size, ! VMErrorType vm_err_type, const char* message); void report_should_not_call(const char* file, int line); void report_should_not_reach_here(const char* file, int line); void report_unimplemented(const char* file, int line); void report_untested(const char* file, int line, const char* message); --- 195,210 ---- OOM_MALLOC_ERROR = 0xe0000001, OOM_MMAP_ERROR = 0xe0000002 }; // error reporting helper functions + void report_vm_error(const char* file, int line, const char* error_msg); void report_vm_error(const char* file, int line, const char* error_msg, ! const char* detail_fmt, ...) ATTRIBUTE_PRINTF(4, 5); ! void report_fatal(const char* file, int line, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(3, 4); ! void report_vm_out_of_memory(const char* file, int line, size_t size, VMErrorType vm_err_type, ! const char* detail_fmt, ...) ATTRIBUTE_PRINTF(5, 6); void report_should_not_call(const char* file, int line); void report_should_not_reach_here(const char* file, int line); void report_unimplemented(const char* file, int line); void report_untested(const char* file, int line, const char* message);
< prev index next >