]> git.cworth.org Git - apitrace/commitdiff
Don't retrace calls that failed when tracing.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Fri, 27 Apr 2012 12:02:08 +0000 (13:02 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Fri, 27 Apr 2012 12:02:08 +0000 (13:02 +0100)
retrace/d3dretrace.py
retrace/retrace.py

index 9990f1b89f7bda1d92cf7fc5d0c91913ba321c0a..a04e01def391870b815a68ff54884f3685561f0d 100644 (file)
@@ -67,7 +67,7 @@ class D3DRetracer(Retracer):
 
         # check errors
         if str(method.type) == 'HRESULT':
-            print r'    if (_result != S_OK) {'
+            print r'    if (FAILED(_result)) {'
             print r'        retrace::warning(call) << "failed\n";'
             print r'    }'
 
index 6206905dcd787d166f95617a4a851a99466ce09d..9828cfbaa831d20c242bc2da89cf7f2d33c7d79d 100644 (file)
@@ -323,6 +323,9 @@ class Retracer:
     def retraceFunctionBody(self, function):
         assert function.sideeffects
 
+        if function.type is not stdapi.Void:
+            self.checkOrigResult(function)
+
         self.deserializeArgs(function)
         
         self.invokeFunction(function)
@@ -332,6 +335,9 @@ class Retracer:
     def retraceInterfaceMethodBody(self, interface, method):
         assert method.sideeffects
 
+        if method.type is not stdapi.Void:
+            self.checkOrigResult(method)
+
         self.deserializeThisPointer(interface)
 
         self.deserializeArgs(method)
@@ -340,6 +346,18 @@ class Retracer:
 
         self.swizzleValues(method)
 
+    def checkOrigResult(self, function):
+        '''Hook for checking the original result, to prevent succeeding now
+        where the original did not, which would cause diversion and potentially
+        unpredictable results.'''
+
+        assert function.type is not stdapi.Void
+
+        if str(function.type) == 'HRESULT':
+            print r'    if (call.ret && FAILED(call.ret->toSInt())) {'
+            print r'        return;'
+            print r'    }'
+
     def deserializeThisPointer(self, interface):
         print r'    %s *_this;' % (interface.name,)
         print r'    _this = static_cast<%s *>(_obj_map[call.arg(0).toUIntPtr()]);' % (interface.name,)