From: José Fonseca Date: Fri, 27 Apr 2012 12:02:08 +0000 (+0100) Subject: Don't retrace calls that failed when tracing. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=7c7c9061a2862dd9238607df2693ff9451412dce;p=apitrace Don't retrace calls that failed when tracing. --- diff --git a/retrace/d3dretrace.py b/retrace/d3dretrace.py index 9990f1b..a04e01d 100644 --- a/retrace/d3dretrace.py +++ b/retrace/d3dretrace.py @@ -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' }' diff --git a/retrace/retrace.py b/retrace/retrace.py index 6206905..9828cfb 100644 --- a/retrace/retrace.py +++ b/retrace/retrace.py @@ -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,)