2010-08-29 Kwang Yul Seo <skyul@company100.net>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Aug 2010 01:46:43 +0000 (01:46 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Aug 2010 01:46:43 +0000 (01:46 +0000)
        Reviewed by Kent Tamura.

        [BREWMP] Port vprintf_stderr_common
        https://bugs.webkit.org/show_bug.cgi?id=33568

        Use BREW's DBGPRINTF to output debug messages.

        * wtf/Assertions.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@66345 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/wtf/Assertions.cpp

index 1a6a460..f1fcfe0 100644 (file)
@@ -1,3 +1,14 @@
+2010-08-29  Kwang Yul Seo  <skyul@company100.net>
+
+        Reviewed by Kent Tamura.
+
+        [BREWMP] Port vprintf_stderr_common
+        https://bugs.webkit.org/show_bug.cgi?id=33568
+
+        Use BREW's DBGPRINTF to output debug messages.
+
+        * wtf/Assertions.cpp:
+
 2010-08-28  Gavin Barraclough  <barraclough@apple.com>
 
         Reviewed by Oliver Hunt.
index cadbc91..273e0e0 100644 (file)
@@ -35,7 +35,7 @@
 #include <CoreFoundation/CFString.h>
 #endif
 
-#if COMPILER(MSVC) && !OS(WINCE)
+#if COMPILER(MSVC) && !OS(WINCE) && !PLATFORM(BREWMP)
 #ifndef WINVER
 #define WINVER 0x0500
 #endif
 #include <winbase.h>
 #endif
 
+#if PLATFORM(BREWMP)
+#include <AEEStdLib.h>
+#include <wtf/Vector.h>
+#endif
+
 extern "C" {
 
+#if PLATFORM(BREWMP)
+
+static void printLog(const Vector<char>& buffer)
+{
+    // Each call to DBGPRINTF generates at most 128 bytes of output on the Windows SDK.
+    // On Qualcomm chipset targets, DBGPRINTF() comes out the diag port (though this may change).
+    // The length of each output string is constrained even more than on the Windows SDK.
+#if COMPILER(MSVC)
+    const int printBufferSize = 128;
+#else
+    const int printBufferSize = 32;
+#endif
+
+    char printBuffer[printBufferSize + 1];
+    printBuffer[printBufferSize] = 0; // to guarantee null termination
+
+    const char* p = buffer.data();
+    const char* end = buffer.data() + buffer.size();
+    while (p < end) {
+        strncpy(printBuffer, p, printBufferSize);
+        DBGPRINTF(printBuffer);
+        p += printBufferSize;
+    }
+}
+
+#endif
+
 WTF_ATTRIBUTE_PRINTF(1, 0)
 static void vprintf_stderr_common(const char* format, va_list args)
 {
@@ -71,6 +103,16 @@ static void vprintf_stderr_common(const char* format, va_list args)
         CFRelease(str);
         CFRelease(cfFormat);
     } else
+#elif PLATFORM(BREWMP)
+    // When str is 0, the return value is the number of bytes needed
+    // to accept the result including null termination.
+    int size = vsnprintf(0, 0, format, args);
+    if (size > 0) {
+        Vector<char> buffer(size);
+        vsnprintf(buffer.data(), size, format, args);
+        printLog(buffer);
+    }
+
 #elif COMPILER(MSVC) && !defined(WINCEBASIC)
     if (IsDebuggerPresent()) {
         size_t size = 1024;