< prev index next >
src/share/vm/utilities/debug.hpp
Print this page
rev 10991 : 8149591: Prepare hotspot for GTest
Contributed-by: stefan.karlsson@oracle.com, stefan.sarne@oracle.com, jesper.wilhelmsson@oracle.com
Reviewed-by: duke
*** 44,58 ****
--- 44,61 ----
class FormatBufferResource : public FormatBufferBase {
public:
FormatBufferResource(const char * format, ...) ATTRIBUTE_PRINTF(2, 3);
};
+ class FormatBufferDummy {};
+
// Use stack for buffer
template <size_t bufsz = FormatBufferBase::BufferSize>
class FormatBuffer : public FormatBufferBase {
public:
inline FormatBuffer(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
+ inline FormatBuffer(FormatBufferDummy dummy, const char* format, va_list ap) ATTRIBUTE_PRINTF(3, 0);
inline void append(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
inline void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
inline void printv(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0);
char* buffer() { return _buf; }
*** 73,82 ****
--- 76,90 ----
jio_vsnprintf(_buf, bufsz, format, argp);
va_end(argp);
}
template <size_t bufsz>
+ FormatBuffer<bufsz>::FormatBuffer(FormatBufferDummy dummy, const char * format, va_list ap) : FormatBufferBase(_buffer) {
+ jio_vsnprintf(_buf, bufsz, format, ap);
+ }
+
+ template <size_t bufsz>
FormatBuffer<bufsz>::FormatBuffer() : FormatBufferBase(_buffer) {
_buf[0] = '\0';
}
template <size_t bufsz>
*** 117,131 ****
// Note: The signature is vmassert(p, format, ...), but the solaris
// compiler can't handle an empty ellipsis in a macro without a warning.
#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__)
--- 125,141 ----
// Note: The signature is vmassert(p, format, ...), but the solaris
// compiler can't handle an empty ellipsis in a macro without a warning.
#define vmassert(p, ...) \
do { \
if (!(p)) { \
+ if (is_executing_unit_tests()) { \
+ report_assert_msg(__VA_ARGS__); \
+ } \
report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", __VA_ARGS__); \
BREAKPOINT; \
} \
} while (0)
#endif
// For backward compatibility.
#define assert(p, ...) vmassert(p, __VA_ARGS__)
*** 223,232 ****
--- 233,248 ----
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);
+ #ifdef ASSERT
+ // unit test support
+ bool is_executing_unit_tests();
+ void report_assert_msg(const char* msg, ...) ATTRIBUTE_PRINTF(1, 2);
+ #endif // ASSERT
+
void warning(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);
// Compile-time asserts. Cond must be a compile-time constant expression that
// is convertible to bool. STATIC_ASSERT() can be used anywhere a declaration
// may appear.
< prev index next >