source: webkit/trunk/JavaScriptCore/wtf/Assertions.cpp@ 38487

Last change on this file since 38487 was 35900, checked in by [email protected], 17 years ago

2008-08-23 Cameron Zwarich <[email protected]>

Rubber-stamped by Mark Rowe.

Remove modelines.

JavaScriptCore:

  • API/APICast.h:
  • API/JSBase.cpp:
  • API/JSCallbackConstructor.cpp:
  • API/JSCallbackConstructor.h:
  • API/JSCallbackFunction.cpp:
  • API/JSCallbackFunction.h:
  • API/JSCallbackObject.cpp:
  • API/JSCallbackObject.h:
  • API/JSCallbackObjectFunctions.h:
  • API/JSClassRef.cpp:
  • API/JSContextRef.cpp:
  • API/JSObjectRef.cpp:
  • API/JSProfilerPrivate.cpp:
  • API/JSStringRef.cpp:
  • API/JSStringRefBSTR.cpp:
  • API/JSStringRefCF.cpp:
  • API/JSValueRef.cpp:
  • API/tests/JSNode.c:
  • API/tests/JSNode.h:
  • API/tests/JSNodeList.c:
  • API/tests/JSNodeList.h:
  • API/tests/Node.c:
  • API/tests/Node.h:
  • API/tests/NodeList.c:
  • API/tests/NodeList.h:
  • API/tests/minidom.c:
  • API/tests/minidom.js:
  • API/tests/testapi.c:
  • API/tests/testapi.js:
  • JavaScriptCore.pro:
  • kjs/FunctionConstructor.h:
  • kjs/FunctionPrototype.h:
  • kjs/JSArray.h:
  • kjs/JSString.h:
  • kjs/JSWrapperObject.cpp:
  • kjs/NumberConstructor.h:
  • kjs/NumberObject.h:
  • kjs/NumberPrototype.h:
  • kjs/lexer.h:
  • kjs/lookup.h:
  • wtf/Assertions.cpp:
  • wtf/Assertions.h:
  • wtf/HashCountedSet.h:
  • wtf/HashFunctions.h:
  • wtf/HashIterators.h:
  • wtf/HashMap.h:
  • wtf/HashSet.h:
  • wtf/HashTable.h:
  • wtf/HashTraits.h:
  • wtf/ListHashSet.h:
  • wtf/ListRefPtr.h:
  • wtf/Noncopyable.h:
  • wtf/OwnArrayPtr.h:
  • wtf/OwnPtr.h:
  • wtf/PassRefPtr.h:
  • wtf/Platform.h:
  • wtf/RefPtr.h:
  • wtf/RefPtrHashMap.h:
  • wtf/RetainPtr.h:
  • wtf/UnusedParam.h:
  • wtf/Vector.h:
  • wtf/VectorTraits.h:
  • wtf/unicode/Unicode.h:
  • wtf/unicode/icu/UnicodeIcu.h:

WebCore:

  • WebCore.pro:
  • bridge/testbindings.cpp:
  • dom/DocPtr.h:
  • loader/SubstituteData.h:
  • page/Chrome.cpp:
  • page/Chrome.h:
  • page/ChromeClient.h:
  • page/Frame.h:
  • page/FrameLoadRequest.h:
  • page/FrameTree.cpp:
  • page/FrameTree.h:
  • page/Page.h:
  • page/mac/ChromeMac.mm:
  • platform/network/HTTPHeaderMap.h:
  • platform/network/ResourceErrorBase.cpp:
  • platform/network/ResourceErrorBase.h:
  • platform/network/ResourceHandleInternal.h:
  • platform/network/ResourceRequestBase.cpp:
  • platform/network/ResourceRequestBase.h:
  • platform/network/ResourceResponseBase.cpp:
  • platform/network/ResourceResponseBase.h:
  • platform/network/cf/ResourceError.h:
  • platform/network/cf/ResourceRequest.h:
  • platform/network/cf/ResourceRequestCFNet.h:
  • platform/network/cf/ResourceResponse.h:
  • platform/network/cf/ResourceResponseCFNet.h:
  • platform/network/curl/ResourceError.h:
  • platform/network/curl/ResourceRequest.h:
  • platform/network/curl/ResourceResponse.h:
  • platform/network/mac/ResourceError.h:
  • platform/network/mac/ResourceErrorMac.mm:
  • platform/network/mac/ResourceRequest.h:
  • platform/network/mac/ResourceRequestMac.mm:
  • platform/network/mac/ResourceResponse.h:
  • platform/network/mac/ResourceResponseMac.mm:
  • platform/network/qt/ResourceError.h:
  • platform/network/qt/ResourceRequest.h:
  • platform/network/qt/ResourceResponse.h:
  • platform/network/soup/CookieJarSoup.cpp:
  • platform/network/soup/ResourceError.h:
  • platform/network/soup/ResourceRequest.h:
  • platform/network/soup/ResourceResponse.h:
  • Property svn:eol-style set to native
File size: 5.5 KB
Line 
1/*
2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27#include "Assertions.h"
28
29#include <stdio.h>
30#include <stdarg.h>
31#include <string.h>
32
33#if PLATFORM(MAC)
34#include <CoreFoundation/CFString.h>
35#endif
36
37#if COMPILER(MSVC)
38#ifndef WINVER
39#define WINVER 0x0500
40#endif
41#ifndef _WIN32_WINNT
42#define _WIN32_WINNT 0x0500
43#endif
44#include <windows.h>
45#include <crtdbg.h>
46#endif
47
48extern "C" {
49
50WTF_ATTRIBUTE_PRINTF(1, 0)
51static void vprintf_stderr_common(const char* format, va_list args)
52{
53#if PLATFORM(MAC)
54 if (strstr(format, "%@")) {
55 CFStringRef cfFormat = CFStringCreateWithCString(NULL, format, kCFStringEncodingUTF8);
56 CFStringRef str = CFStringCreateWithFormatAndArguments(NULL, NULL, cfFormat, args);
57
58 int length = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str), kCFStringEncodingUTF8);
59 char* buffer = (char*)malloc(length + 1);
60
61 CFStringGetCString(str, buffer, length, kCFStringEncodingUTF8);
62
63 fputs(buffer, stderr);
64
65 free(buffer);
66 CFRelease(str);
67 CFRelease(cfFormat);
68 } else
69#elif COMPILER(MSVC)
70 if (IsDebuggerPresent()) {
71 size_t size = 1024;
72
73 do {
74 char* buffer = (char*)malloc(size);
75
76 if (buffer == NULL)
77 break;
78
79 if (_vsnprintf(buffer, size, format, args) != -1) {
80 OutputDebugStringA(buffer);
81 free(buffer);
82 break;
83 }
84
85 free(buffer);
86 size *= 2;
87 } while (size > 1024);
88 }
89#endif
90 vfprintf(stderr, format, args);
91}
92
93WTF_ATTRIBUTE_PRINTF(1, 2)
94static void printf_stderr_common(const char* format, ...)
95{
96 va_list args;
97 va_start(args, format);
98 vprintf_stderr_common(format, args);
99 va_end(args);
100}
101
102static void printCallSite(const char* file, int line, const char* function)
103{
104#if PLATFORM(WIN) && defined _DEBUG
105 _CrtDbgReport(_CRT_WARN, file, line, NULL, "%s\n", function);
106#else
107 printf_stderr_common("(%s:%d %s)\n", file, line, function);
108#endif
109}
110
111void WTFReportAssertionFailure(const char* file, int line, const char* function, const char* assertion)
112{
113 if (assertion)
114 printf_stderr_common("ASSERTION FAILED: %s\n", assertion);
115 else
116 printf_stderr_common("SHOULD NEVER BE REACHED\n");
117 printCallSite(file, line, function);
118}
119
120void WTFReportAssertionFailureWithMessage(const char* file, int line, const char* function, const char* assertion, const char* format, ...)
121{
122 printf_stderr_common("ASSERTION FAILED: ");
123 va_list args;
124 va_start(args, format);
125 vprintf_stderr_common(format, args);
126 va_end(args);
127 printf_stderr_common("\n%s\n", assertion);
128 printCallSite(file, line, function);
129}
130
131void WTFReportArgumentAssertionFailure(const char* file, int line, const char* function, const char* argName, const char* assertion)
132{
133 printf_stderr_common("ARGUMENT BAD: %s, %s\n", argName, assertion);
134 printCallSite(file, line, function);
135}
136
137void WTFReportFatalError(const char* file, int line, const char* function, const char* format, ...)
138{
139 printf_stderr_common("FATAL ERROR: ");
140 va_list args;
141 va_start(args, format);
142 vprintf_stderr_common(format, args);
143 va_end(args);
144 printf_stderr_common("\n");
145 printCallSite(file, line, function);
146}
147
148void WTFReportError(const char* file, int line, const char* function, const char* format, ...)
149{
150 printf_stderr_common("ERROR: ");
151 va_list args;
152 va_start(args, format);
153 vprintf_stderr_common(format, args);
154 va_end(args);
155 printf_stderr_common("\n");
156 printCallSite(file, line, function);
157}
158
159void WTFLog(WTFLogChannel* channel, const char* format, ...)
160{
161 if (channel->state != WTFLogChannelOn)
162 return;
163
164 va_list args;
165 va_start(args, format);
166 vprintf_stderr_common(format, args);
167 va_end(args);
168 if (format[strlen(format) - 1] != '\n')
169 printf_stderr_common("\n");
170}
171
172void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChannel* channel, const char* format, ...)
173{
174 if (channel->state != WTFLogChannelOn)
175 return;
176
177 va_list args;
178 va_start(args, format);
179 vprintf_stderr_common(format, args);
180 va_end(args);
181 if (format[strlen(format) - 1] != '\n')
182 printf_stderr_common("\n");
183 printCallSite(file, line, function);
184}
185
186} // extern "C"
Note: See TracBrowser for help on using the repository browser.