Changeset 16782 in webkit for trunk/JavaScriptCore/wtf
- Timestamp:
- Oct 4, 2006, 1:34:21 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/Assertions.cpp
r16484 r16782 39 39 #define _WIN32_WINNT 0x0500 40 40 #include <windows.h> 41 #include <crtdbg.h> 41 42 #endif 42 43 … … 45 46 // This is to work around the "you should use a printf format attribute" warning on GCC 46 47 // We can't use _attribute__ ((format (printf, 2, 3))) since we allow %@ 47 static int (* vfprintf_no_warning)(FILE *, const char 48 static int (* vfprintf_no_warning)(FILE *, const char*, va_list) = vfprintf; 48 49 49 static void vprintf_stderr_common(const char *format, va_list args)50 static void vprintf_stderr_common(const char* format, va_list args) 50 51 { 51 52 #if PLATFORM(MAC) … … 55 56 56 57 int length = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str), kCFStringEncodingUTF8); 57 char *buffer = (char*)malloc(length + 1);58 char* buffer = (char*)malloc(length + 1); 58 59 59 60 CFStringGetCString(str, buffer, length, kCFStringEncodingUTF8); … … 66 67 } else 67 68 #elif PLATFORM(WIN) 68 if (IsDebuggerPresent()) 69 { 69 if (IsDebuggerPresent()) { 70 70 size_t size = 1024; 71 71 72 do 73 { 72 do { 74 73 char* buffer = (char*)malloc(size); 75 74 … … 77 76 break; 78 77 79 if (_vsnprintf(buffer, size, format, args) != -1) 80 { 78 if (_vsnprintf(buffer, size, format, args) != -1) { 81 79 OutputDebugStringA(buffer); 82 80 free(buffer); … … 92 90 } 93 91 94 static void printf_stderr_common(const char 92 static void printf_stderr_common(const char* format, ...) 95 93 { 96 94 va_list args; … … 100 98 } 101 99 102 void WTFReportAssertionFailure(const char *file, int line, const char *function, const char *assertion) 100 static void printCallSite(const char* file, int line, const char* function) 101 { 102 #if PLATFORM(WIN) 103 _CrtDbgReport(_CRT_WARN, file, line, NULL, "%s\n", function); 104 #else 105 printf_stderr_common("(%s:%d %s)\n", file, line, function); 106 #endif 107 } 108 109 void WTFReportAssertionFailure(const char* file, int line, const char* function, const char* assertion) 103 110 { 104 111 if (assertion) 105 printf_stderr_common(" =================\nASSERTION FAILED: %s (%s:%d %s)\n=================\n", assertion, file, line, function);112 printf_stderr_common("ASSERTION FAILED: %s\n", assertion); 106 113 else 107 printf_stderr_common("=================\nSHOULD NEVER BE REACHED (%s:%d %s)\n=================\n", file, line, function); 114 printf_stderr_common("SHOULD NEVER BE REACHED\n"); 115 printCallSite(file, line, function); 108 116 } 109 117 110 void WTFReportAssertionFailureWithMessage(const char *file, int line, const char *function, const char *assertion, const char *format, ...)118 void WTFReportAssertionFailureWithMessage(const char* file, int line, const char* function, const char* assertion, const char* format, ...) 111 119 { 112 printf_stderr_common(" =================\nASSERTION FAILED: ");120 printf_stderr_common("ASSERTION FAILED: "); 113 121 va_list args; 114 122 va_start(args, format); 115 123 vprintf_stderr_common(format, args); 116 124 va_end(args); 117 printf_stderr_common("\n%s (%s:%d %s)\n=================\n", assertion, file, line, function); 125 printf_stderr_common("\n%s\n", assertion); 126 printCallSite(file, line, function); 118 127 } 119 128 120 void WTFReportArgumentAssertionFailure(const char *file, int line, const char *function, const char *argName, const char *assertion)129 void WTFReportArgumentAssertionFailure(const char* file, int line, const char* function, const char* argName, const char* assertion) 121 130 { 122 printf_stderr_common("=================\nARGUMENT BAD: %s, %s (%s:%d %s)\n=================\n", argName, assertion, file, line, function); 131 printf_stderr_common("ARGUMENT BAD: %s, %s\n", argName, assertion); 132 printCallSite(file, line, function); 123 133 } 124 134 125 void WTFReportFatalError(const char *file, int line, const char *function, const char *format, ...)135 void WTFReportFatalError(const char* file, int line, const char* function, const char* format, ...) 126 136 { 127 printf_stderr_common(" =================\nFATAL ERROR: ");137 printf_stderr_common("FATAL ERROR: "); 128 138 va_list args; 129 139 va_start(args, format); 130 140 vprintf_stderr_common(format, args); 131 141 va_end(args); 132 printf_stderr_common("\n(%s:%d %s)\n=================\n", file, line, function); 142 printf_stderr_common("\n"); 143 printCallSite(file, line, function); 133 144 } 134 145 135 void WTFReportError(const char *file, int line, const char *function, const char *format, ...)146 void WTFReportError(const char* file, int line, const char* function, const char* format, ...) 136 147 { 137 printf_stderr_common(" =================\nERROR: ");148 printf_stderr_common("ERROR: "); 138 149 va_list args; 139 150 va_start(args, format); 140 151 vprintf_stderr_common(format, args); 141 152 va_end(args); 142 printf_stderr_common("\n(%s:%d %s)\n=================\n", file, line, function); 153 printf_stderr_common("\n"); 154 printCallSite(file, line, function); 143 155 } 144 156 145 void WTFLog(const char*, int, const char*, WTFLogChannel *channel, const char *format, ...)157 void WTFLog(const char*, int, const char*, WTFLogChannel *channel, const char* format, ...) 146 158 { 147 159 if (channel->state != WTFLogChannelOn)
Note:
See TracChangeset
for help on using the changeset viewer.