]> git.cworth.org Git - apitrace/blobdiff - retrace.py
Fix a crash when loading multiple frames at once.
[apitrace] / retrace.py
index a9c5b4d41f8cd84158678ba59bbdc654a5842129..9092f351366a2377231761c962e2c1daec382879 100644 (file)
@@ -26,9 +26,8 @@
 
 """Generic retracing code generator."""
 
-import stdapi
-import glapi
-from codegen import *
+import specs.stdapi as stdapi
+import specs.glapi as glapi
 
 
 class ConstRemover(stdapi.Rebuilder):
@@ -190,6 +189,7 @@ class Retracer:
 
     def retrace_function_body(self, function):
         if not function.sideeffects:
+            print '    (void)call;'
             return
 
         success = True
@@ -205,7 +205,9 @@ class Retracer:
                 success = False
                 print '    %s = 0; // FIXME' % arg.name
         if not success:
+            print '    if (1) {'
             self.fail_function(function)
+            print '    }'
         self.call_function(function)
         for arg in function.args:
             if arg.output:
@@ -231,6 +233,9 @@ class Retracer:
 
     def extract_arg(self, function, arg, arg_type, lvalue, rvalue):
         ValueExtractor().visit(arg_type, lvalue, rvalue)
+    
+    def extract_opaque_arg(self, function, arg, arg_type, lvalue, rvalue):
+        OpaqueValueExtractor().visit(arg_type, lvalue, rvalue)
 
     def call_function(self, function):
         arg_names = ", ".join([arg.name for arg in function.args])
@@ -244,27 +249,19 @@ class Retracer:
     def filter_function(self, function):
         return True
 
+    table_name = 'retrace::callbacks'
+
     def retrace_functions(self, functions):
         functions = filter(self.filter_function, functions)
 
         for function in functions:
             self.retrace_function(function)
 
-        print 'void retrace::retrace_call(Trace::Call &call) {'
-        print '    const char *name = call.name().c_str();'
-        print
-
-        func_dict = dict([(function.name, function) for function in functions])
-
-        def handle_case(function_name):
-            function = func_dict[function_name]
-            print '        retrace_%s(call);' % function.name
-            print '        return;'
-    
-        string_switch('name', func_dict.keys(), handle_case)
-
-        print '    retrace_unknown(call);'
-        print '}'
+        print 'const retrace::Entry %s[] = {' % self.table_name
+        for function in functions:
+            print '    {"%s", &retrace_%s},' % (function.name, function.name)
+        print '    {NULL, NULL}'
+        print '};'
         print