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
# The symbols visible in libEGL.so can vary, so expose them all
return True
+ getProcAddressFunctionNames = [
+ "eglGetProcAddress",
+ ]
+
def traceFunctionImplBody(self, function):
GlTracer.traceFunctionImplBody(self, function)
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)'
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>'
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'''
/*
* 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;
}
}
- 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");
}