]> git.cworth.org Git - apitrace/commitdiff
More debugging output.
authorJosé Fonseca <jfonseca@vmware.com>
Thu, 25 Nov 2010 19:06:00 +0000 (19:06 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Thu, 25 Nov 2010 19:06:00 +0000 (19:06 +0000)
log.cpp
opengl32.py
os.hpp
os_posix.cpp
os_win32.cpp
wglapi.py

diff --git a/log.cpp b/log.cpp
index 23a3393fb468efa2a25e3999fcff5f177f2981a8..719666fb21a7df211d2a1102e513f323ed2c6cae 100644 (file)
--- a/log.cpp
+++ b/log.cpp
@@ -86,11 +86,7 @@ static void _Open(const char *szExtension) {
        }
    }
 
-   {
-       char szMessage[PATH_MAX];
-       snprintf(szMessage, PATH_MAX, "Tracing to %s\n", szFileName);
-       OS::DebugMessage(szMessage);
-   }
+   OS::DebugMessage("apitrace: tracing to %s\n", szFileName);
 
    g_gzFile = gzopen(szFileName, "wb");
 }
index cf1dc2a906e5005e2643dd1242a681313986bdf5..b5f94f3b73345db91cd029e9ebef2fbffe612ed7 100644 (file)
@@ -410,13 +410,18 @@ class WglTracer(Tracer):
     def wrap_ret(self, function, instance):
         if function.name == "wglGetProcAddress":
             print '    if (%s) {' % instance
+            else_ = ''
             for f in wglapi.functions:
                 ptype = self.function_pointer_type(f)
                 pvalue = self.function_pointer_value(f)
-                print '        if (!strcmp("%s", lpszProc)) {' % f.name
+                print '        %sif (!strcmp("%s", lpszProc)) {' % (else_, f.name)
                 print '            %s = (%s)%s;' % (pvalue, ptype, instance)
                 print '            %s = (%s)&%s;' % (instance, function.type, f.name);
                 print '        }'
+                else_ = 'else '
+            print '        %s{' % (else_,)
+            print '            OS::DebugMessage("apitrace: unknown function \\"%s\\"\\n", lpszProc);'
+            print '        }'
             print '    }'
 
 
@@ -427,6 +432,7 @@ if __name__ == '__main__':
     print '#include "glimports.hpp"'
     print
     print '#include "log.hpp"'
+    print '#include "os.hpp"'
     print '#include "glsize.hpp"'
     print
     print '#ifndef PFD_SUPPORT_DIRECTDRAW'
diff --git a/os.hpp b/os.hpp
index 94d0cf3c4a6941907c70a827c20fe84014453517..52f70eb5a772275a5b4992d2a6e20204a6245445 100644 (file)
--- a/os.hpp
+++ b/os.hpp
@@ -26,6 +26,9 @@
 #ifndef _OS_HPP_
 #define _OS_HPP_
 
+#include <stdlib.h>
+#include <stdarg.h>
+
 #ifdef WIN32
 #ifndef snprintf
 #define snprintf _snprintf
@@ -51,7 +54,7 @@ void ReleaseMutex(void);
 bool GetProcessName(char *str, size_t size);
 bool GetCurrentDir(char *str, size_t size);
 
-void DebugMessage(const char *str);
+void DebugMessage(const char *format, ...);
 
 void Abort(void);
 
index 3f423fe99cd1e01d3f8b7312e6590fbe37981f52..590738f36f51b97e411acc0226ce9f94d19e6316 100644 (file)
@@ -88,10 +88,13 @@ GetCurrentDir(char *str, size_t size)
 }
 
 void
-DebugMessage(const char *message)
+DebugMessage(const char *format, ...)
 {
+   va_list ap;
+   va_start(ap, format);
    fflush(stdout);
-   fputs(message, stderr);
+   vfprintf(stderr, format, ap);
+   va_end(ap);
 }
 
 void
index 0849ab06e522959e5d25b70f27d98ef428b474f3..5f8dddfc1204f7805d720d4a7ae3c98c8df052b5 100644 (file)
@@ -89,12 +89,20 @@ GetCurrentDir(char *str, size_t size)
 }
 
 void
-DebugMessage(const char *message)
+DebugMessage(const char *format, ...)
 {
-   OutputDebugStringA(message);
+   char buf[4096];
+
+   va_list ap;
+   va_start(ap, format);
+   fflush(stdout);
+   vsnprintf(buf, sizeof buf, format, ap);
+   va_end(ap);
+
+   OutputDebugStringA(buf);
    if (!IsDebuggerPresent()) {
       fflush(stdout);
-      fputs(message, stderr);
+      fputs(buf, stderr);
       fflush(stderr);
    }
 }
index e5611b2d68217a68ac8810520256788562cf7591..481a4fe60299284b5de026c43f99f84aa30ce0ee 100644 (file)
--- a/wglapi.py
+++ b/wglapi.py
@@ -261,6 +261,10 @@ wglapi.add_functions([
     StdFunction(BOOL, "wglSwapIntervalEXT", [(Int, "interval")]),
     StdFunction(Int, "wglGetSwapIntervalEXT", [], sideeffects=False),
 
+    # WGL_NV_vertex_array_range
+    StdFunction(OpaquePointer(Void), "wglAllocateMemoryNV", [(GLsizei, "size"), (GLfloat, "readfreq"), (GLfloat, "writefreq"), (GLfloat, "priority")]),
+    StdFunction(Void, "wglFreeMemoryNV", [(OpaquePointer(Void), "pointer")]),
+
     # must be last
     StdFunction(PROC, "wglGetProcAddress", [(LPCSTR, "lpszProc")]),
 ])