| 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 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 #include <stdio.h> | 41 #include <stdio.h> |
| 42 #include <stdarg.h> | 42 #include <stdarg.h> |
| 43 #include <stdlib.h> | 43 #include <stdlib.h> |
| 44 #include <string.h> | 44 #include <string.h> |
| 45 | 45 |
| 46 #if HAVE(SIGNAL_H) | 46 #if HAVE(SIGNAL_H) |
| 47 #include <signal.h> | 47 #include <signal.h> |
| 48 #endif | 48 #endif |
| 49 | 49 |
| 50 #if USE(CF) | 50 #if (OS(LINUX) && !defined(__UCLIBC__)) |
| 51 #include <AvailabilityMacros.h> | |
| 52 #include <CoreFoundation/CFString.h> | |
| 53 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 | |
| 54 #define WTF_USE_APPLE_SYSTEM_LOG 1 | |
| 55 #include <asl.h> | |
| 56 #endif | |
| 57 #endif // USE(CF) | |
| 58 | |
| 59 #if COMPILER(MSVC) | |
| 60 #include <crtdbg.h> | |
| 61 #endif | |
| 62 | |
| 63 #if OS(MACOSX) || (OS(LINUX) && !defined(__UCLIBC__)) | |
| 64 #include <cxxabi.h> | 51 #include <cxxabi.h> |
| 65 #include <dlfcn.h> | 52 #include <dlfcn.h> |
| 66 #include <execinfo.h> | 53 #include <execinfo.h> |
| 67 #endif | 54 #endif |
| 68 | 55 |
| 69 #if OS(ANDROID) | 56 #if OS(ANDROID) |
| 70 #include <android/log.h> | 57 #include <android/log.h> |
| 71 #endif | 58 #endif |
| 72 | 59 |
| 73 #include "base/debug/stack_trace.h" | 60 #include "base/debug/stack_trace.h" |
| 74 | 61 |
| 75 extern "C" { | 62 extern "C" { |
| 76 | 63 |
| 77 WTF_ATTRIBUTE_PRINTF(1, 0) | 64 WTF_ATTRIBUTE_PRINTF(1, 0) |
| 78 static void vprintf_stderr_common(const char* format, va_list args) | 65 static void vprintf_stderr_common(const char* format, va_list args) |
| 79 { | 66 { |
| 80 #if USE(CF) && !OS(WIN) | 67 #if OS(ANDROID) |
| 81 if (strstr(format, "%@")) { | |
| 82 CFStringRef cfFormat = CFStringCreateWithCString(NULL, format, kCFString
EncodingUTF8); | |
| 83 | |
| 84 #if COMPILER(CLANG) | |
| 85 #pragma clang diagnostic push | |
| 86 #pragma clang diagnostic ignored "-Wformat-nonliteral" | |
| 87 #endif | |
| 88 CFStringRef str = CFStringCreateWithFormatAndArguments(NULL, NULL, cfFor
mat, args); | |
| 89 #if COMPILER(CLANG) | |
| 90 #pragma clang diagnostic pop | |
| 91 #endif | |
| 92 CFIndex length = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str
), kCFStringEncodingUTF8); | |
| 93 char* buffer = (char*)malloc(length + 1); | |
| 94 | |
| 95 CFStringGetCString(str, buffer, length, kCFStringEncodingUTF8); | |
| 96 | |
| 97 #if USE(APPLE_SYSTEM_LOG) | |
| 98 asl_log(0, 0, ASL_LEVEL_NOTICE, "%s", buffer); | |
| 99 #endif | |
| 100 fputs(buffer, stderr); | |
| 101 | |
| 102 free(buffer); | |
| 103 CFRelease(str); | |
| 104 CFRelease(cfFormat); | |
| 105 return; | |
| 106 } | |
| 107 | |
| 108 #if USE(APPLE_SYSTEM_LOG) | |
| 109 va_list copyOfArgs; | |
| 110 va_copy(copyOfArgs, args); | |
| 111 asl_vlog(0, 0, ASL_LEVEL_NOTICE, format, copyOfArgs); | |
| 112 va_end(copyOfArgs); | |
| 113 #endif | |
| 114 | |
| 115 // Fall through to write to stderr in the same manner as other platforms. | |
| 116 | |
| 117 #elif OS(ANDROID) | |
| 118 __android_log_vprint(ANDROID_LOG_WARN, "WebKit", format, args); | 68 __android_log_vprint(ANDROID_LOG_WARN, "WebKit", format, args); |
| 119 #elif HAVE(ISDEBUGGERPRESENT) | |
| 120 if (IsDebuggerPresent()) { | |
| 121 size_t size = 1024; | |
| 122 | |
| 123 do { | |
| 124 char* buffer = (char*)malloc(size); | |
| 125 | |
| 126 if (buffer == NULL) | |
| 127 break; | |
| 128 | |
| 129 if (_vsnprintf(buffer, size, format, args) != -1) { | |
| 130 OutputDebugStringA(buffer); | |
| 131 free(buffer); | |
| 132 break; | |
| 133 } | |
| 134 | |
| 135 free(buffer); | |
| 136 size *= 2; | |
| 137 } while (size > 1024); | |
| 138 } | |
| 139 #endif | 69 #endif |
| 140 vfprintf(stderr, format, args); | 70 vfprintf(stderr, format, args); |
| 141 } | 71 } |
| 142 | 72 |
| 143 #if COMPILER(CLANG) || (COMPILER(GCC) && GCC_VERSION_AT_LEAST(4, 6, 0)) | 73 #if COMPILER(CLANG) || (COMPILER(GCC) && GCC_VERSION_AT_LEAST(4, 6, 0)) |
| 144 #pragma GCC diagnostic push | 74 #pragma GCC diagnostic push |
| 145 #pragma GCC diagnostic ignored "-Wformat-nonliteral" | 75 #pragma GCC diagnostic ignored "-Wformat-nonliteral" |
| 146 #endif | 76 #endif |
| 147 | 77 |
| 148 static void vprintf_stderr_with_prefix(const char* prefix, const char* format, v
a_list args) | 78 static void vprintf_stderr_with_prefix(const char* prefix, const char* format, v
a_list args) |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 200 |
| 271 void WTFLogAlways(const char* format, ...) | 201 void WTFLogAlways(const char* format, ...) |
| 272 { | 202 { |
| 273 va_list args; | 203 va_list args; |
| 274 va_start(args, format); | 204 va_start(args, format); |
| 275 vprintf_stderr_with_trailing_newline(format, args); | 205 vprintf_stderr_with_trailing_newline(format, args); |
| 276 va_end(args); | 206 va_end(args); |
| 277 } | 207 } |
| 278 | 208 |
| 279 } // extern "C" | 209 } // extern "C" |
| OLD | NEW |