]> git.cworth.org Git - apitrace/commitdiff
Merge branch 'd3dretrace'
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Fri, 13 Apr 2012 16:36:19 +0000 (17:36 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Fri, 13 Apr 2012 16:36:19 +0000 (17:36 +0100)
1  2 
CMakeLists.txt
glretrace.py
retrace.hpp
retrace.py
trace.py

diff --cc CMakeLists.txt
Simple merge
diff --cc glretrace.py
Simple merge
diff --cc retrace.hpp
index 8ce15ad6720c7e0696440fd5688da523d90452bc,7357a703669e4d06a69eaed7f2b292b8345ecc88..c1e556a97fbb03d726be09de3cb92540de88e5fc
@@@ -119,17 -120,24 +123,35 @@@ public
          return static_cast<T *>(alloc(sizeof(T) * n));
      }
  
+     /**
+      * Allocate an array with the same dimensions as the specified value.
+      */
+     template< class T >
+     inline T *
+     alloc(const trace::Value *value) {
+         const trace::Array *array = dynamic_cast<const trace::Array *>(value);
+         if (array) {
+             return alloc<T>(array->size());
+         }
+         const trace::Null *null = dynamic_cast<const trace::Null *>(value);
+         if (null) {
+             return NULL;
+         }
+         assert(0);
+         return NULL;
+     }
 +    /**
 +     * Prevent this pointer from being automatically freed.
 +     */
 +    template< class T >
 +    inline void
 +    bind(T *ptr) {
 +        if (ptr) {
 +            reinterpret_cast<uintptr_t *>(ptr)[-1] |= 1;
 +        }
 +    }
 +
      inline
      ~ScopedAllocator() {
          while (next) {
diff --cc retrace.py
index e4d462ae99ed5bdabc8ecc8a473a21dfe53db05e,ee85f29d6d5de771e08b488ae0558a3e5d12a14f..a450f8221ea47499622b118896fa6ed0f6783720
@@@ -207,9 -320,45 +320,41 @@@ class Retracer
          print '}'
          print
  
+     def retraceInterfaceMethod(self, interface, method):
+         print 'static void retrace_%s__%s(trace::Call &call) {' % (interface.name, method.name)
+         self.retraceInterfaceMethodBody(interface, method)
+         print '}'
+         print
      def retraceFunctionBody(self, function):
 -        if not function.sideeffects:
 -            print '    (void)call;'
 -            return
 +        assert function.sideeffects
  
 -        if not method.sideeffects:
 -            print '    (void)call;'
 -            return
+         self.deserializeArgs(function)
+         
+         self.invokeFunction(function)
+         self.swizzleValues(function)
+     def retraceInterfaceMethodBody(self, interface, method):
++        assert method.sideeffects
+         self.deserializeThisPointer(interface)
+         self.deserializeArgs(method)
+         
+         self.invokeInterfaceMethod(interface, method)
+         self.swizzleValues(method)
+     def deserializeThisPointer(self, interface):
+         print r'    %s *_this;' % (interface.name,)
+         print r'    _this = static_cast<%s *>(_obj_map[call.arg(0).toUIntPtr()]);' % (interface.name,)
+         print r'    if (!_this) {'
+         print r'        retrace::warning(call) << "NULL this pointer\n";'
+         print r'        return;'
+         print r'    }'
+     def deserializeArgs(self, function):
          print '    retrace::ScopedAllocator _allocator;'
          print '    (void)_allocator;'
          success = True
                  handle_names.add(handle.name)
          print
  
-         self.retraceFunctions(api.functions)
+         print 'static std::map<unsigned long long, void *> _obj_map;'
+         print
+         functions = filter(self.filterFunction, api.functions)
+         for function in functions:
 -            self.retraceFunction(function)
++            if function.sideeffects:
++                self.retraceFunction(function)
+         interfaces = api.getAllInterfaces()
+         for interface in interfaces:
+             for method in interface.iterMethods():
 -                self.retraceInterfaceMethod(interface, method)
++                if method.sideeffects:
++                    self.retraceInterfaceMethod(interface, method)
+         print 'const retrace::Entry %s[] = {' % self.table_name
+         for function in functions:
 -            print '    {"%s", &retrace_%s},' % (function.name, function.name)
++            if function.sideeffects:
++                print '    {"%s", &retrace_%s},' % (function.name, function.name)
++            else:
++                print '    {"%s", &retrace::ignore},' % (function.name,)
+         for interface in interfaces:
 -            for method in interface.iterMethods():
 -                print '    {"%s::%s", &retrace_%s__%s},' % (interface.name, method.name, interface.name, method.name)
++            for method in interface.iterMethods():                
++                if method.sideeffects:
++                    print '    {"%s::%s", &retrace_%s__%s},' % (interface.name, method.name, interface.name, method.name)
++                else:
++                    print '    {"%s::%s", &retrace::ignore},' % (interface.name, method.name)
+         print '    {NULL, NULL}'
+         print '};'
+         print
  
diff --cc trace.py
Simple merge