| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 | 51 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 |
| 52 #define WTF_USE_APPLE_SYSTEM_LOG 1 | 52 #define WTF_USE_APPLE_SYSTEM_LOG 1 |
| 53 #include <asl.h> | 53 #include <asl.h> |
| 54 #endif | 54 #endif |
| 55 #endif // USE(CF) | 55 #endif // USE(CF) |
| 56 | 56 |
| 57 #if COMPILER(MSVC) | 57 #if COMPILER(MSVC) |
| 58 #include <crtdbg.h> | 58 #include <crtdbg.h> |
| 59 #endif | 59 #endif |
| 60 | 60 |
| 61 #if OS(WINDOWS) | 61 #if OS(WIN) |
| 62 #include <windows.h> | 62 #include <windows.h> |
| 63 #define HAVE_ISDEBUGGERPRESENT 1 | 63 #define HAVE_ISDEBUGGERPRESENT 1 |
| 64 #endif | 64 #endif |
| 65 | 65 |
| 66 #if (OS(MACOSX) || (OS(LINUX) && !defined(__UCLIBC__))) && !OS(ANDROID) | 66 #if (OS(MACOSX) || (OS(LINUX) && !defined(__UCLIBC__))) && !OS(ANDROID) |
| 67 #include <cxxabi.h> | 67 #include <cxxabi.h> |
| 68 #include <dlfcn.h> | 68 #include <dlfcn.h> |
| 69 #include <execinfo.h> | 69 #include <execinfo.h> |
| 70 #endif | 70 #endif |
| 71 | 71 |
| 72 #if OS(ANDROID) | 72 #if OS(ANDROID) |
| 73 #include "android/log.h" | 73 #include "android/log.h" |
| 74 #endif | 74 #endif |
| 75 | 75 |
| 76 extern "C" { | 76 extern "C" { |
| 77 | 77 |
| 78 WTF_ATTRIBUTE_PRINTF(1, 0) | 78 WTF_ATTRIBUTE_PRINTF(1, 0) |
| 79 static void vprintf_stderr_common(const char* format, va_list args) | 79 static void vprintf_stderr_common(const char* format, va_list args) |
| 80 { | 80 { |
| 81 #if USE(CF) && !OS(WINDOWS) | 81 #if USE(CF) && !OS(WIN) |
| 82 if (strstr(format, "%@")) { | 82 if (strstr(format, "%@")) { |
| 83 CFStringRef cfFormat = CFStringCreateWithCString(NULL, format, kCFString
EncodingUTF8); | 83 CFStringRef cfFormat = CFStringCreateWithCString(NULL, format, kCFString
EncodingUTF8); |
| 84 | 84 |
| 85 #if COMPILER(CLANG) | 85 #if COMPILER(CLANG) |
| 86 #pragma clang diagnostic push | 86 #pragma clang diagnostic push |
| 87 #pragma clang diagnostic ignored "-Wformat-nonliteral" | 87 #pragma clang diagnostic ignored "-Wformat-nonliteral" |
| 88 #endif | 88 #endif |
| 89 CFStringRef str = CFStringCreateWithFormatAndArguments(NULL, NULL, cfFor
mat, args); | 89 CFStringRef str = CFStringCreateWithFormatAndArguments(NULL, NULL, cfFor
mat, args); |
| 90 #if COMPILER(CLANG) | 90 #if COMPILER(CLANG) |
| 91 #pragma clang diagnostic pop | 91 #pragma clang diagnostic pop |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 static void printf_stderr_common(const char* format, ...) | 182 static void printf_stderr_common(const char* format, ...) |
| 183 { | 183 { |
| 184 va_list args; | 184 va_list args; |
| 185 va_start(args, format); | 185 va_start(args, format); |
| 186 vprintf_stderr_common(format, args); | 186 vprintf_stderr_common(format, args); |
| 187 va_end(args); | 187 va_end(args); |
| 188 } | 188 } |
| 189 | 189 |
| 190 static void printCallSite(const char* file, int line, const char* function) | 190 static void printCallSite(const char* file, int line, const char* function) |
| 191 { | 191 { |
| 192 #if OS(WINDOWS) && defined(_DEBUG) | 192 #if OS(WIN) && defined(_DEBUG) |
| 193 _CrtDbgReport(_CRT_WARN, file, line, NULL, "%s\n", function); | 193 _CrtDbgReport(_CRT_WARN, file, line, NULL, "%s\n", function); |
| 194 #else | 194 #else |
| 195 // By using this format, which matches the format used by MSVC for compiler
errors, developers | 195 // By using this format, which matches the format used by MSVC for compiler
errors, developers |
| 196 // using Visual Studio can double-click the file/line number in the Output W
indow to have the | 196 // using Visual Studio can double-click the file/line number in the Output W
indow to have the |
| 197 // editor navigate to that line of code. It seems fine for other developers,
too. | 197 // editor navigate to that line of code. It seems fine for other developers,
too. |
| 198 printf_stderr_common("%s(%d) : %s\n", file, line, function); | 198 printf_stderr_common("%s(%d) : %s\n", file, line, function); |
| 199 #endif | 199 #endif |
| 200 } | 200 } |
| 201 | 201 |
| 202 void WTFReportAssertionFailure(const char* file, int line, const char* function,
const char* assertion) | 202 void WTFReportAssertionFailure(const char* file, int line, const char* function,
const char* assertion) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 221 void WTFReportArgumentAssertionFailure(const char* file, int line, const char* f
unction, const char* argName, const char* assertion) | 221 void WTFReportArgumentAssertionFailure(const char* file, int line, const char* f
unction, const char* argName, const char* assertion) |
| 222 { | 222 { |
| 223 printf_stderr_common("ARGUMENT BAD: %s, %s\n", argName, assertion); | 223 printf_stderr_common("ARGUMENT BAD: %s, %s\n", argName, assertion); |
| 224 printCallSite(file, line, function); | 224 printCallSite(file, line, function); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void WTFGetBacktrace(void** stack, int* size) | 227 void WTFGetBacktrace(void** stack, int* size) |
| 228 { | 228 { |
| 229 #if (OS(MACOSX) || (OS(LINUX) && !defined(__UCLIBC__))) && !OS(ANDROID) | 229 #if (OS(MACOSX) || (OS(LINUX) && !defined(__UCLIBC__))) && !OS(ANDROID) |
| 230 *size = backtrace(stack, *size); | 230 *size = backtrace(stack, *size); |
| 231 #elif OS(WINDOWS) | 231 #elif OS(WIN) |
| 232 // The CaptureStackBackTrace function is available in XP, but it is not defi
ned | 232 // The CaptureStackBackTrace function is available in XP, but it is not defi
ned |
| 233 // in the Windows Server 2003 R2 Platform SDK. So, we'll grab the function | 233 // in the Windows Server 2003 R2 Platform SDK. So, we'll grab the function |
| 234 // through GetProcAddress. | 234 // through GetProcAddress. |
| 235 typedef WORD (NTAPI* RtlCaptureStackBackTraceFunc)(DWORD, DWORD, PVOID*, PDW
ORD); | 235 typedef WORD (NTAPI* RtlCaptureStackBackTraceFunc)(DWORD, DWORD, PVOID*, PDW
ORD); |
| 236 HMODULE kernel32 = ::GetModuleHandleW(L"Kernel32.dll"); | 236 HMODULE kernel32 = ::GetModuleHandleW(L"Kernel32.dll"); |
| 237 if (!kernel32) { | 237 if (!kernel32) { |
| 238 *size = 0; | 238 *size = 0; |
| 239 return; | 239 return; |
| 240 } | 240 } |
| 241 RtlCaptureStackBackTraceFunc captureStackBackTraceFunc = reinterpret_cast<Rt
lCaptureStackBackTraceFunc>( | 241 RtlCaptureStackBackTraceFunc captureStackBackTraceFunc = reinterpret_cast<Rt
lCaptureStackBackTraceFunc>( |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 | 376 |
| 377 void WTFLogAlways(const char* format, ...) | 377 void WTFLogAlways(const char* format, ...) |
| 378 { | 378 { |
| 379 va_list args; | 379 va_list args; |
| 380 va_start(args, format); | 380 va_start(args, format); |
| 381 vprintf_stderr_with_trailing_newline(format, args); | 381 vprintf_stderr_with_trailing_newline(format, args); |
| 382 va_end(args); | 382 va_end(args); |
| 383 } | 383 } |
| 384 | 384 |
| 385 } // extern "C" | 385 } // extern "C" |
| OLD | NEW |