| Index: third_party/WebKit/Source/wtf/Assertions.h
|
| diff --git a/third_party/WebKit/Source/wtf/Assertions.h b/third_party/WebKit/Source/wtf/Assertions.h
|
| index 2c363f941fccb79e425c665803b6c4522c84e737..13dbd30e156c9b367c4738d7e02b90c56dff8df4 100644
|
| --- a/third_party/WebKit/Source/wtf/Assertions.h
|
| +++ b/third_party/WebKit/Source/wtf/Assertions.h
|
| @@ -40,6 +40,7 @@
|
|
|
| */
|
|
|
| +#include "base/gtest_prod_util.h"
|
| #include "base/logging.h"
|
| #include "wtf/Compiler.h"
|
| #include "wtf/Noncopyable.h"
|
| @@ -89,6 +90,58 @@ WTF_EXPORT void WTFGetBacktrace(void** stack, int* size);
|
| WTF_EXPORT void WTFReportBacktrace(int framesToShow = 31);
|
| WTF_EXPORT void WTFPrintBacktrace(void** stack, int size);
|
|
|
| +namespace WTF {
|
| +
|
| +#if LOG_DISABLED
|
| +
|
| +#define WTF_CREATE_SCOPED_LOGGER(...) ((void) 0)
|
| +#define WTF_CREATE_SCOPED_LOGGER_IF(...) ((void) 0)
|
| +#define WTF_APPEND_SCOPED_LOGGER(...) ((void) 0)
|
| +
|
| +#else
|
| +
|
| +// ScopedLogger wraps log messages in parentheses, with indentation proportional
|
| +// to the number of instances. This makes it easy to see the flow of control in
|
| +// the output, particularly when instrumenting recursive functions.
|
| +//
|
| +// NOTE: This class is a debugging tool, not intended for use by checked-in
|
| +// code. Please do not remove it.
|
| +//
|
| +class WTF_EXPORT ScopedLogger {
|
| + WTF_MAKE_NONCOPYABLE(ScopedLogger);
|
| +public:
|
| + // The first message is passed to the constructor. Additional messages for
|
| + // the same scope can be added with log(). If condition is false, produce no
|
| + // output and do not create a scope.
|
| + ScopedLogger(bool condition, const char* format, ...) WTF_ATTRIBUTE_PRINTF(3, 4);
|
| + ~ScopedLogger();
|
| + void log(const char* format, ...) WTF_ATTRIBUTE_PRINTF(2, 3);
|
| +
|
| +private:
|
| + FRIEND_TEST_ALL_PREFIXES(AssertionsTest, ScopedLogger);
|
| + using PrintFunctionPtr = void (*)(const char* format, va_list args);
|
| + static void setPrintFuncForTests(PrintFunctionPtr p) { m_printFunc = p; } // Note: not thread safe.
|
| +
|
| + void init(const char* format, va_list args);
|
| + void writeNewlineIfNeeded();
|
| + void indent();
|
| + void print(const char* format, ...);
|
| + void printIndent();
|
| + static ScopedLogger*& current();
|
| +
|
| + ScopedLogger* const m_parent;
|
| + bool m_multiline; // The ')' will go on the same line if there is only one entry.
|
| + static PrintFunctionPtr m_printFunc;
|
| +};
|
| +
|
| +#define WTF_CREATE_SCOPED_LOGGER(name, ...) WTF::ScopedLogger name(true, __VA_ARGS__)
|
| +#define WTF_CREATE_SCOPED_LOGGER_IF(name, condition, ...) WTF::ScopedLogger name(condition, __VA_ARGS__)
|
| +#define WTF_APPEND_SCOPED_LOGGER(name, ...) (name.log(__VA_ARGS__))
|
| +
|
| +#endif // LOG_DISABLED
|
| +
|
| +} // namespace WTF
|
| +
|
| /* IMMEDIATE_CRASH() - Like CRASH() below but crashes in the fastest, simplest possible way with no attempt at logging. */
|
| #ifndef IMMEDIATE_CRASH
|
| #if COMPILER(GCC) || COMPILER(CLANG)
|
|
|