| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2007-2009 Torch Mobile, Inc. | 3 * Copyright (C) 2007-2009 Torch Mobile, Inc. |
| 4 * Copyright (C) 2011 University of Szeged. All rights reserved. | 4 * Copyright (C) 2011 University of Szeged. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #endif | 46 #endif |
| 47 | 47 |
| 48 #if USE(CF) | 48 #if USE(CF) |
| 49 #include <CoreFoundation/CFString.h> | 49 #include <CoreFoundation/CFString.h> |
| 50 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 | 50 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 |
| 51 #define WTF_USE_APPLE_SYSTEM_LOG 1 | 51 #define WTF_USE_APPLE_SYSTEM_LOG 1 |
| 52 #include <asl.h> | 52 #include <asl.h> |
| 53 #endif | 53 #endif |
| 54 #endif // USE(CF) | 54 #endif // USE(CF) |
| 55 | 55 |
| 56 #if COMPILER(MSVC) && !OS(WINCE) | 56 #if COMPILER(MSVC) |
| 57 #include <crtdbg.h> | 57 #include <crtdbg.h> |
| 58 #endif | 58 #endif |
| 59 | 59 |
| 60 #if OS(WINDOWS) | 60 #if OS(WINDOWS) |
| 61 #include <windows.h> | 61 #include <windows.h> |
| 62 #endif | 62 #endif |
| 63 | 63 |
| 64 #if (OS(DARWIN) || (OS(LINUX) && !defined(__UCLIBC__))) && !OS(ANDROID) | 64 #if (OS(DARWIN) || (OS(LINUX) && !defined(__UCLIBC__))) && !OS(ANDROID) |
| 65 #include <cxxabi.h> | 65 #include <cxxabi.h> |
| 66 #include <dlfcn.h> | 66 #include <dlfcn.h> |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 if (IsDebuggerPresent()) { | 119 if (IsDebuggerPresent()) { |
| 120 size_t size = 1024; | 120 size_t size = 1024; |
| 121 | 121 |
| 122 do { | 122 do { |
| 123 char* buffer = (char*)malloc(size); | 123 char* buffer = (char*)malloc(size); |
| 124 | 124 |
| 125 if (buffer == NULL) | 125 if (buffer == NULL) |
| 126 break; | 126 break; |
| 127 | 127 |
| 128 if (_vsnprintf(buffer, size, format, args) != -1) { | 128 if (_vsnprintf(buffer, size, format, args) != -1) { |
| 129 #if OS(WINCE) | |
| 130 // WinCE only supports wide chars | |
| 131 wchar_t* wideBuffer = (wchar_t*)malloc(size * sizeof(wchar_t)); | |
| 132 if (wideBuffer == NULL) | |
| 133 break; | |
| 134 for (unsigned int i = 0; i < size; ++i) { | |
| 135 if (!(wideBuffer[i] = buffer[i])) | |
| 136 break; | |
| 137 } | |
| 138 OutputDebugStringW(wideBuffer); | |
| 139 free(wideBuffer); | |
| 140 #else | |
| 141 OutputDebugStringA(buffer); | 129 OutputDebugStringA(buffer); |
| 142 #endif | |
| 143 free(buffer); | 130 free(buffer); |
| 144 break; | 131 break; |
| 145 } | 132 } |
| 146 | 133 |
| 147 free(buffer); | 134 free(buffer); |
| 148 size *= 2; | 135 size *= 2; |
| 149 } while (size > 1024); | 136 } while (size > 1024); |
| 150 } | 137 } |
| 151 #endif | 138 #endif |
| 152 vfprintf(stderr, format, args); | 139 vfprintf(stderr, format, args); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 static void printf_stderr_common(const char* format, ...) | 180 static void printf_stderr_common(const char* format, ...) |
| 194 { | 181 { |
| 195 va_list args; | 182 va_list args; |
| 196 va_start(args, format); | 183 va_start(args, format); |
| 197 vprintf_stderr_common(format, args); | 184 vprintf_stderr_common(format, args); |
| 198 va_end(args); | 185 va_end(args); |
| 199 } | 186 } |
| 200 | 187 |
| 201 static void printCallSite(const char* file, int line, const char* function) | 188 static void printCallSite(const char* file, int line, const char* function) |
| 202 { | 189 { |
| 203 #if OS(WINDOWS) && !OS(WINCE) && defined(_DEBUG) | 190 #if OS(WINDOWS) && defined(_DEBUG) |
| 204 _CrtDbgReport(_CRT_WARN, file, line, NULL, "%s\n", function); | 191 _CrtDbgReport(_CRT_WARN, file, line, NULL, "%s\n", function); |
| 205 #else | 192 #else |
| 206 // By using this format, which matches the format used by MSVC for compiler
errors, developers | 193 // By using this format, which matches the format used by MSVC for compiler
errors, developers |
| 207 // using Visual Studio can double-click the file/line number in the Output W
indow to have the | 194 // using Visual Studio can double-click the file/line number in the Output W
indow to have the |
| 208 // editor navigate to that line of code. It seems fine for other developers,
too. | 195 // editor navigate to that line of code. It seems fine for other developers,
too. |
| 209 printf_stderr_common("%s(%d) : %s\n", file, line, function); | 196 printf_stderr_common("%s(%d) : %s\n", file, line, function); |
| 210 #endif | 197 #endif |
| 211 } | 198 } |
| 212 | 199 |
| 213 void WTFReportAssertionFailure(const char* file, int line, const char* function,
const char* assertion) | 200 void WTFReportAssertionFailure(const char* file, int line, const char* function,
const char* assertion) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 232 void WTFReportArgumentAssertionFailure(const char* file, int line, const char* f
unction, const char* argName, const char* assertion) | 219 void WTFReportArgumentAssertionFailure(const char* file, int line, const char* f
unction, const char* argName, const char* assertion) |
| 233 { | 220 { |
| 234 printf_stderr_common("ARGUMENT BAD: %s, %s\n", argName, assertion); | 221 printf_stderr_common("ARGUMENT BAD: %s, %s\n", argName, assertion); |
| 235 printCallSite(file, line, function); | 222 printCallSite(file, line, function); |
| 236 } | 223 } |
| 237 | 224 |
| 238 void WTFGetBacktrace(void** stack, int* size) | 225 void WTFGetBacktrace(void** stack, int* size) |
| 239 { | 226 { |
| 240 #if (OS(DARWIN) || (OS(LINUX) && !defined(__UCLIBC__))) && !OS(ANDROID) | 227 #if (OS(DARWIN) || (OS(LINUX) && !defined(__UCLIBC__))) && !OS(ANDROID) |
| 241 *size = backtrace(stack, *size); | 228 *size = backtrace(stack, *size); |
| 242 #elif OS(WINDOWS) && !OS(WINCE) | 229 #elif OS(WINDOWS) |
| 243 // The CaptureStackBackTrace function is available in XP, but it is not defi
ned | 230 // The CaptureStackBackTrace function is available in XP, but it is not defi
ned |
| 244 // in the Windows Server 2003 R2 Platform SDK. So, we'll grab the function | 231 // in the Windows Server 2003 R2 Platform SDK. So, we'll grab the function |
| 245 // through GetProcAddress. | 232 // through GetProcAddress. |
| 246 typedef WORD (NTAPI* RtlCaptureStackBackTraceFunc)(DWORD, DWORD, PVOID*, PDW
ORD); | 233 typedef WORD (NTAPI* RtlCaptureStackBackTraceFunc)(DWORD, DWORD, PVOID*, PDW
ORD); |
| 247 HMODULE kernel32 = ::GetModuleHandleW(L"Kernel32.dll"); | 234 HMODULE kernel32 = ::GetModuleHandleW(L"Kernel32.dll"); |
| 248 if (!kernel32) { | 235 if (!kernel32) { |
| 249 *size = 0; | 236 *size = 0; |
| 250 return; | 237 return; |
| 251 } | 238 } |
| 252 RtlCaptureStackBackTraceFunc captureStackBackTraceFunc = reinterpret_cast<Rt
lCaptureStackBackTraceFunc>( | 239 RtlCaptureStackBackTraceFunc captureStackBackTraceFunc = reinterpret_cast<Rt
lCaptureStackBackTraceFunc>( |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 | 393 |
| 407 void WTFLogAlways(const char* format, ...) | 394 void WTFLogAlways(const char* format, ...) |
| 408 { | 395 { |
| 409 va_list args; | 396 va_list args; |
| 410 va_start(args, format); | 397 va_start(args, format); |
| 411 vprintf_stderr_with_trailing_newline(format, args); | 398 vprintf_stderr_with_trailing_newline(format, args); |
| 412 va_end(args); | 399 va_end(args); |
| 413 } | 400 } |
| 414 | 401 |
| 415 } // extern "C" | 402 } // extern "C" |
| OLD | NEW |