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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(WIN) | 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__)) |
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" { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 } | 219 } |
220 | 220 |
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__)) |
230 *size = backtrace(stack, *size); | 230 *size = backtrace(stack, *size); |
231 #elif OS(WIN) | 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; |
(...skipping 18 matching lines...) Expand all Loading... |
258 | 258 |
259 WTFGetBacktrace(samples, &frames); | 259 WTFGetBacktrace(samples, &frames); |
260 WTFPrintBacktrace(samples + framesToSkip, frames - framesToSkip); | 260 WTFPrintBacktrace(samples + framesToSkip, frames - framesToSkip); |
261 } | 261 } |
262 | 262 |
263 void WTFPrintBacktrace(void** stack, int size) | 263 void WTFPrintBacktrace(void** stack, int size) |
264 { | 264 { |
265 for (int i = 0; i < size; ++i) { | 265 for (int i = 0; i < size; ++i) { |
266 const char* mangledName = 0; | 266 const char* mangledName = 0; |
267 char* cxaDemangled = 0; | 267 char* cxaDemangled = 0; |
268 #if OS(MACOSX) || (OS(LINUX) && !OS(ANDROID)) | 268 #if OS(MACOSX) || OS(LINUX) |
269 Dl_info info; | 269 Dl_info info; |
270 if (dladdr(stack[i], &info) && info.dli_sname) | 270 if (dladdr(stack[i], &info) && info.dli_sname) |
271 mangledName = info.dli_sname; | 271 mangledName = info.dli_sname; |
272 if (mangledName) | 272 if (mangledName) |
273 cxaDemangled = abi::__cxa_demangle(mangledName, 0, 0, 0); | 273 cxaDemangled = abi::__cxa_demangle(mangledName, 0, 0, 0); |
274 #endif | 274 #endif |
275 const int frameNumber = i + 1; | 275 const int frameNumber = i + 1; |
276 if (mangledName || cxaDemangled) | 276 if (mangledName || cxaDemangled) |
277 printf_stderr_common("%-3d %p %s\n", frameNumber, stack[i], cxaDeman
gled ? cxaDemangled : mangledName); | 277 printf_stderr_common("%-3d %p %s\n", frameNumber, stack[i], cxaDeman
gled ? cxaDemangled : mangledName); |
278 else | 278 else |
(...skipping 97 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 |