< prev index next >

src/share/vm/utilities/debug.hpp

Print this page
rev 7614 : [mq]: revert_msg


  96 void FormatBuffer<bufsz>::append(const char* format, ...) {
  97   // Given that the constructor does a vsnprintf we can assume that
  98   // _buf is already initialized.
  99   size_t len = strlen(_buf);
 100   char* buf_end = _buf + len;
 101 
 102   va_list argp;
 103   va_start(argp, format);
 104   jio_vsnprintf(buf_end, bufsz - len, format, argp);
 105   va_end(argp);
 106 }
 107 
 108 // Used to format messages for vmassert(), guarantee(), fatal(), etc.
 109 typedef FormatBuffer<> err_msg;
 110 typedef FormatBufferResource err_msg_res;
 111 
 112 // assertions
 113 #ifndef ASSERT
 114 #define vmassert(p, msg)
 115 #else


 116 #define vmassert(p, msg)                                                     \
 117 do {                                                                         \
 118   if (!(p)) {                                                                \
 119     report_vm_error(__FILE__, __LINE__, "vmassert(" #p ") failed", msg);     \
 120     BREAKPOINT;                                                              \
 121   }                                                                          \
 122 } while (0)
 123 #endif
 124 
 125 // For backward compatibility.
 126 #define assert(p, msg) vmassert(p, msg)
 127 
 128 // This version of vmassert is for use with checking return status from
 129 // library calls that return actual error values eg. EINVAL,
 130 // ENOMEM etc, rather than returning -1 and setting errno.
 131 // When the status is not what is expected it is very useful to know
 132 // what status was actually returned, so we pass the status variable as
 133 // an extra arg and use strerror to convert it to a meaningful string
 134 // like "Invalid argument", "out of memory" etc
 135 #define vmassert_status(p, status, msg) \
 136   vmassert(p, err_msg("error %s(%d), %s", strerror(status), status, msg))
 137 
 138 // For backward compatibility.
 139 #define assert_status(p, status, msg) vmassert_status(p, status, msg)




  96 void FormatBuffer<bufsz>::append(const char* format, ...) {
  97   // Given that the constructor does a vsnprintf we can assume that
  98   // _buf is already initialized.
  99   size_t len = strlen(_buf);
 100   char* buf_end = _buf + len;
 101 
 102   va_list argp;
 103   va_start(argp, format);
 104   jio_vsnprintf(buf_end, bufsz - len, format, argp);
 105   va_end(argp);
 106 }
 107 
 108 // Used to format messages for vmassert(), guarantee(), fatal(), etc.
 109 typedef FormatBuffer<> err_msg;
 110 typedef FormatBufferResource err_msg_res;
 111 
 112 // assertions
 113 #ifndef ASSERT
 114 #define vmassert(p, msg)
 115 #else
 116 // Note: message says "assert" rather than "vmassert" for backward
 117 // compatibility with tools that parse/match the message text.
 118 #define vmassert(p, msg)                                                     \
 119 do {                                                                         \
 120   if (!(p)) {                                                                \
 121     report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", msg);       \
 122     BREAKPOINT;                                                              \
 123   }                                                                          \
 124 } while (0)
 125 #endif
 126 
 127 // For backward compatibility.
 128 #define assert(p, msg) vmassert(p, msg)
 129 
 130 // This version of vmassert is for use with checking return status from
 131 // library calls that return actual error values eg. EINVAL,
 132 // ENOMEM etc, rather than returning -1 and setting errno.
 133 // When the status is not what is expected it is very useful to know
 134 // what status was actually returned, so we pass the status variable as
 135 // an extra arg and use strerror to convert it to a meaningful string
 136 // like "Invalid argument", "out of memory" etc
 137 #define vmassert_status(p, status, msg) \
 138   vmassert(p, err_msg("error %s(%d), %s", strerror(status), status, msg))
 139 
 140 // For backward compatibility.
 141 #define assert_status(p, status, msg) vmassert_status(p, status, msg)


< prev index next >