Commits

Armin Rigo  committed 3f26c47

Start implementing "make lltrace". Right now with fprintf.

  • Participants
  • Parent commits e65a70f
  • Branches lltrace

Comments (0)

Files changed (3)

File pypy/translator/c/funcgen.py

             result = '/* %s */' % result
         return result
 
-    def generic_set(self, op, targetexpr):
+    def generic_set(self, op, targetexpr, gckind):
         newvalue = self.expr(op.args[-1], special_case_void=False)
         result = '%s = %s;' % (targetexpr, newvalue)
         T = self.lltypemap(op.args[-1])
         if T is Void:
             result = '/* %s */' % result
+        elif gckind == 'gc':
+            result = '%s RPyTraceSet(%s);' % (result, targetexpr)
         return result
 
     def OP_GETFIELD(self, op, ampersand=''):
         expr = structdef.ptr_access_expr(self.expr(op.args[0]),
                                          op.args[1].value,
                                          baseexpr_is_const)
-        return self.generic_set(op, expr)
+        return self.generic_set(op, expr, STRUCT._gckind)
 
     def OP_GETSUBSTRUCT(self, op):
         RESULT = self.lltypemap(op.result).TO
         ptr = self.expr(op.args[0])
         index = self.expr(op.args[1])
         arraydef = self.db.gettypedefnode(ARRAY)
-        return self.generic_set(op, arraydef.itemindex_access_expr(ptr, index))
+        return self.generic_set(op, arraydef.itemindex_access_expr(ptr, index),
+                                ARRAY._gckind)
     OP_BARE_SETARRAYITEM = OP_SETARRAYITEM
 
     def OP_GETARRAYSUBSTRUCT(self, op):
         return self.generic_get(op, self.interior_expr(op.args))
 
     def OP_BARE_SETINTERIORFIELD(self, op):
-        return self.generic_set(op, self.interior_expr(op.args[:-1]))
+        STRUCT = self.lltypemap(op.args[0]).TO
+        return self.generic_set(op, self.interior_expr(op.args[:-1]),
+                                STRUCT._gckind)
 
     def OP_GETINTERIORARRAYSIZE(self, op):
         expr, ARRAY = self.interior_expr(op.args, True)

File pypy/translator/c/genc.py

             ('linuxmemchk', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DLINUXMEMCHK" $(TARGET)'),
             ('llsafer', '', '$(MAKE) CFLAGS="-O2 -DRPY_LL_ASSERT" $(TARGET)'),
             ('lldebug', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DRPY_LL_ASSERT" $(TARGET)'),
+            ('lltrace', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DRPY_LL_ASSERT -DRPY_LL_TRACE" $(TARGET)'),
             ('profile', '', '$(MAKE) CFLAGS="-g -O1 -pg $(CFLAGS) -fno-omit-frame-pointer" LDFLAGS="-pg $(LDFLAGS)" $(TARGET)'),
             ]
         if self.has_profopt():

File pypy/translator/c/src/support.h

 #  define RPyBareItem(array, index)          ((array)[index])
 #endif
 
+
+#ifdef RPY_LL_TRACE
+#  define RPyTraceSet(ptr)   _RPyTraceSet(&(ptr), (long)(ptr))
+#else
+#  define RPyTraceSet(ptr)   /* nothing */
+#endif
+void _RPyTraceSet(void *addr, long newvalue);
+#ifndef PYPY_NOT_MAIN_FILE
+static void *_RPyTrace_start;
+static void *_RPyTrace_stop;
+static void *_RPyTrace_current = NULL;
+void _RPyTraceCreateBuffer(void)
+{
+}
+void _RPyTraceSet(void *addr, long newvalue)
+{
+  fprintf(stderr, "set 0x%x into %p\n", newvalue, addr);
+}
+#endif
+
+
 #ifndef PYPY_STANDALONE
 
 /* prototypes */