[pypy-svn] pypy lltrace: Start implementing "make lltrace". Right now with fprintf.
arigo
commits-noreply at bitbucket.org
Tue Feb 22 14:59:48 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: lltrace
Changeset: r42209:3f26c4717b82
Date: 2011-02-22 13:04 +0100
http://bitbucket.org/pypy/pypy/changeset/3f26c4717b82/
Log: Start implementing "make lltrace". Right now with fprintf.
diff --git a/pypy/translator/c/genc.py b/pypy/translator/c/genc.py
--- a/pypy/translator/c/genc.py
+++ b/pypy/translator/c/genc.py
@@ -557,6 +557,7 @@
('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():
diff --git a/pypy/translator/c/src/support.h b/pypy/translator/c/src/support.h
--- a/pypy/translator/c/src/support.h
+++ b/pypy/translator/c/src/support.h
@@ -103,6 +103,27 @@
# 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 */
diff --git a/pypy/translator/c/funcgen.py b/pypy/translator/c/funcgen.py
--- a/pypy/translator/c/funcgen.py
+++ b/pypy/translator/c/funcgen.py
@@ -484,12 +484,14 @@
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=''):
@@ -510,7 +512,7 @@
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
@@ -540,7 +542,8 @@
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):
@@ -582,7 +585,9 @@
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)
More information about the Pypy-commit
mailing list