def traceApi(self, api): if self.getProcAddressFunctionNames: # Generate a function to wrap proc addresses getProcAddressFunction = api.getFunctionByName( self.getProcAddressFunctionNames[0]) argType = getProcAddressFunction.args[0].type retType = getProcAddressFunction.type print 'static %s _wrapProcAddress(%s procName, %s procPtr);' % ( retType, argType, retType) print Tracer.traceApi(self, api) print 'static %s _wrapProcAddress(%s procName, %s procPtr) {' % ( retType, argType, retType) print ' if (!procPtr) {' print ' return procPtr;' print ' }' for function in api.getAllFunctions(): ptype = function_pointer_type(function) pvalue = function_pointer_value(function) print ' if (strcmp("%s", (const char *)procName) == 0) {' % function.name print ' %s = (%s)procPtr;' % (pvalue, ptype) print ' return (%s)&%s;' % ( retType, function.name, ) print ' }' print ' os::log("apitrace: warning: unknown function \\"%s\\"\\n", (const char *)procName);' print ' return procPtr;' print '}' print else: Tracer.traceApi(self, api)
def traceApi(self, api): if self.getProcAddressFunctionNames: # Generate a function to wrap proc addresses getProcAddressFunction = api.getFunctionByName(self.getProcAddressFunctionNames[0]) argType = getProcAddressFunction.args[0].type retType = getProcAddressFunction.type print 'static %s _wrapProcAddress(%s procName, %s procPtr);' % (retType, argType, retType) print Tracer.traceApi(self, api) print 'static %s _wrapProcAddress(%s procName, %s procPtr) {' % (retType, argType, retType) print ' if (!procPtr) {' print ' return procPtr;' print ' }' for function in api.functions: ptype = function_pointer_type(function) pvalue = function_pointer_value(function) print ' if (strcmp("%s", (const char *)procName) == 0) {' % function.name print ' %s = (%s)procPtr;' % (pvalue, ptype) print ' return (%s)&%s;' % (retType, function.name,) print ' }' print ' os::log("apitrace: warning: unknown function \\"%s\\"\\n", (const char *)procName);' print ' return procPtr;' print '}' print else: Tracer.traceApi(self, api)
def traceApi(self, api): if self.getProcAddressFunctionNames: # Generate a function to wrap proc addresses getProcAddressFunction = api.getFunctionByName(self.getProcAddressFunctionNames[0]) argType = getProcAddressFunction.args[0].type retType = getProcAddressFunction.type print 'static %s _wrapProcAddress(%s procName, %s procPtr);' % (retType, argType, retType) print Tracer.traceApi(self, api) print 'static %s _wrapProcAddress(%s procName, %s procPtr) {' % (retType, argType, retType) # Provide fallback functions to missing debug functions print ' if (!procPtr) {' else_ = '' for function_name in self.debug_functions: if self.api.getFunctionByName(function_name): print ' %sif (strcmp("%s", (const char *)procName) == 0) {' % (else_, function_name) print ' return (%s)&%s;' % (retType, function_name) print ' }' else_ = 'else ' print ' %s{' % else_ print ' return NULL;' print ' }' print ' }' for function in api.getAllFunctions(): ptype = function_pointer_type(function) pvalue = function_pointer_value(function) print ' if (strcmp("%s", (const char *)procName) == 0) {' % function.name print ' %s = (%s)procPtr;' % (pvalue, ptype) print ' return (%s)&%s;' % (retType, function.name,) print ' }' print ' os::log("apitrace: warning: unknown function \\"%s\\"\\n", (const char *)procName);' print ' return procPtr;' print '}' print else: Tracer.traceApi(self, api)
print api = API() api.add_api(eglapi) api.add_api(glapi) api.add_api(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 print r""" /* * Invoke the true dlopen() function. */ static void *__dlopen(const char *filename, int flag)
def handle_case(function_name): f = func_dict[function_name] ptype = function_pointer_type(f) pvalue = function_pointer_value(f) print ' %s = (%s)%s;' % (pvalue, ptype, instance) print ' %s = (%s)&%s;' % (instance, function.type, f.name)
def handle_case(function_name): f = func_dict[function_name] ptype = function_pointer_type(f) pvalue = function_pointer_value(f) print ' %s = (%s)%s;' % (pvalue, ptype, instance) print ' %s = (%s)&%s;' % (instance, function.type, f.name);
print 'static __GLXextFuncPtr __unwrap_proc_addr(const GLubyte * procName, __GLXextFuncPtr procPtr);' print api = API() api.add_api(glxapi) api.add_api(glapi) tracer = GlxTracer() tracer.trace_api(api) print 'static __GLXextFuncPtr __unwrap_proc_addr(const GLubyte * procName, __GLXextFuncPtr 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", (const char *)procName)) {' % f.name print ' %s = (%s)procPtr;' % (pvalue, ptype) print ' return (__GLXextFuncPtr)&%s;' % (f.name, ) print ' }' print ' return procPtr;' print '}' print print r''' /* * Handle to the true libGL.so */ static void *libgl_handle = NULL;