]> git.cworth.org Git - apitrace/blobdiff - wrappers/egltrace.py
Refactor d3d9 lock tracking code further.
[apitrace] / wrappers / egltrace.py
index 65c14efdb69415d67bb7f10f254697b5969dd8a4..4858e2fbabff88e45d46a4f46dca210ed7395a12 100644 (file)
@@ -33,7 +33,6 @@
 
 
 from gltrace import GlTracer
-from dispatch import function_pointer_type, function_pointer_value
 from specs.stdapi import API
 from specs.glapi import glapi
 from specs.eglapi import eglapi
@@ -46,6 +45,10 @@ class EglTracer(GlTracer):
         # The symbols visible in libEGL.so can vary, so expose them all
         return True
 
+    getProcAddressFunctionNames = [
+        "eglGetProcAddress",
+    ]
+
     def traceFunctionImplBody(self, function):
         GlTracer.traceFunctionImplBody(self, function)
 
@@ -54,8 +57,8 @@ class EglTracer(GlTracer):
             print '    if (ctx != EGL_NO_CONTEXT) {'
             print '        EGLint api = EGL_OPENGL_ES_API, version = 1;'
             print '        gltrace::Context *tr = gltrace::getContext();'
-            print '        __eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_TYPE, &api);'
-            print '        __eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_VERSION, &version);'
+            print '        _eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_TYPE, &api);'
+            print '        _eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_VERSION, &version);'
             print '        if (api == EGL_OPENGL_API)'
             print '            tr->profile = gltrace::PROFILE_COMPAT;'
             print '        else if (version == 1)'
@@ -64,12 +67,6 @@ class EglTracer(GlTracer):
             print '            tr->profile = gltrace::PROFILE_ES2;'
             print '    }'
 
-    def wrapRet(self, function, instance):
-        GlTracer.wrapRet(self, function, instance)
-
-        if function.name == "eglGetProcAddress":
-            print '    %s = __unwrap_proc_addr(procname, %s);' % (instance, instance)
-
 
 if __name__ == '__main__':
     print '#include <stdlib.h>'
@@ -85,31 +82,14 @@ if __name__ == '__main__':
     print '#include "glproc.hpp"'
     print '#include "glsize.hpp"'
     print
-    print 'static __eglMustCastToProperFunctionPointerType __unwrap_proc_addr(const char * procname, __eglMustCastToProperFunctionPointerType procPtr);'
-    print
-
+    
     api = API()
     api.addApi(eglapi)
     api.addApi(glapi)
     api.addApi(glesapi)
     tracer = EglTracer()
-    tracer.trace_api(api)
-
-    print 'static __eglMustCastToProperFunctionPointerType __unwrap_proc_addr(const char * procname, __eglMustCastToProperFunctionPointerType procPtr) {'
-    print '    if (!procPtr) {'
-    print '        return procPtr;'
-    print '    }'
-    for f in api.functions:
-        ptype = function_pointer_type(f)
-        pvalue = function_pointer_value(f)
-        print '    if (!strcmp("%s", procname)) {' % f.name
-        print '        %s = (%s)procPtr;' % (pvalue, ptype)
-        print '        return (__eglMustCastToProperFunctionPointerType)&%s;' % (f.name,)
-        print '    }'
-    print '    os::log("apitrace: warning: unknown function \\"%s\\"\\n", procname);'
-    print '    return procPtr;'
-    print '}'
-    print
+    tracer.traceApi(api)
+
     print r'''
 
 
@@ -122,13 +102,13 @@ if __name__ == '__main__':
 /*
  * Invoke the true dlopen() function.
  */
-static void *__dlopen(const char *filename, int flag)
+static void *_dlopen(const char *filename, int flag)
 {
-    typedef void * (*PFNDLOPEN)(const char *, int);
-    static PFNDLOPEN dlopen_ptr = NULL;
+    typedef void * (*PFN_DLOPEN)(const char *, int);
+    static PFN_DLOPEN dlopen_ptr = NULL;
 
     if (!dlopen_ptr) {
-        dlopen_ptr = (PFNDLOPEN)dlsym(RTLD_NEXT, "dlopen");
+        dlopen_ptr = (PFN_DLOPEN)dlsym(RTLD_NEXT, "dlopen");
         if (!dlopen_ptr) {
             os::log("apitrace: error: dlsym(RTLD_NEXT, \"dlopen\") failed\n");
             return NULL;
@@ -175,14 +155,14 @@ void * dlopen(const char *filename, int flag)
         }
     }
 
-    void *handle = __dlopen(filename, flag);
+    void *handle = _dlopen(filename, flag);
 
     if (intercept) {
         // Get the file path for our shared object, and use it instead
         static int dummy = 0xdeedbeef;
         Dl_info info;
         if (dladdr(&dummy, &info)) {
-            handle = __dlopen(info.dli_fname, flag);
+            handle = _dlopen(info.dli_fname, flag);
         } else {
             os::log("apitrace: warning: dladdr() failed\n");
         }