Author: Maciej Fijalkowski <fij...@gmail.com>
Branch: dtrace-support
Changeset: r76456:311c07895ec9
Date: 2015-03-18 16:34 +0100
http://bitbucket.org/pypy/pypy/changeset/311c07895ec9/

Log:    write support for debug_probe

diff --git a/rpython/translator/c/database.py b/rpython/translator/c/database.py
--- a/rpython/translator/c/database.py
+++ b/rpython/translator/c/database.py
@@ -48,7 +48,7 @@
         self.containerstats = {}
         self.externalfuncs = {}
         self.helper2ptr = {}
-        self.debug_nodes = set()
+        self.debug_nodes = {}
 
         # late_initializations is for when the value you want to
         # assign to a constant object is something C doesn't think is
@@ -234,12 +234,12 @@
         else:
             raise Exception("don't know about %r" % (obj,))
 
-    def seen_debug_start(self, op):
+    def seen_debug_node(self, op, suffix, args=''):
         arg = op.args[0]
         if not isinstance(arg, Constant):
             return
-        name = ''.join(arg.value.chars)
-        self.debug_nodes.add(name)
+        name = ''.join(arg.value.chars) + suffix
+        self.debug_nodes[name] = args
 
     def complete(self, show_progress=True):
         assert not self.completed
diff --git a/rpython/translator/c/funcgen.py b/rpython/translator/c/funcgen.py
--- a/rpython/translator/c/funcgen.py
+++ b/rpython/translator/c/funcgen.py
@@ -802,7 +802,8 @@
             return x
 
     def OP_DEBUG_START(self, op):
-        self.db.seen_debug_start(op)
+        self.db.seen_debug_node(op, '__start')
+        self.db.seen_debug_node(op, '__end')
         return self._op_debug('PYPY_DEBUG_START', op.args[0])
 
     def OP_DEBUG_STOP(self, op):
@@ -811,10 +812,11 @@
     def OP_DEBUG_PROBE(self, op):
         if not self.db.translator.config.translation.dtrace:
             return
+        self.db.seen_debug_node(op, '', 'long')
         assert isinstance(op.args[0], Constant)
         val = ''.join(op.args[0].value.chars)
-        string_literal = c_string_constant(val)
-        return 'RPYTHON_%s(%d);' % (string_literal, self.expr(op.args[1]))
+        string_literal = val.upper()
+        return 'RPYTHON_%s(%s);' % (string_literal, self.expr(op.args[1]))
 
     def OP_DEBUG_ASSERT(self, op):
         return 'RPyAssert(%s, %s);' % (self.expr(op.args[0]),
diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -256,10 +256,9 @@
         name = self.targetdir.join('rpython.d')
         f = name.open('w')
         f.write('provider rpython {\n')
-        for debug_node in debug_nodes:
+        for debug_node, args in debug_nodes.iteritems():
             debug_node = debug_node.replace('-', '_')
-            f.write('  probe %s__start();\n' % debug_node)
-            f.write('  probe %s__end();\n' % debug_node)
+            f.write('  probe %s(%s);\n' % (debug_node, args))
         f.write('};\n')
         f.close()
         returncode, stdout, stderr = runsubprocess.run_subprocess(
diff --git a/rpython/translator/c/test/test_dtrace.py 
b/rpython/translator/c/test/test_dtrace.py
--- a/rpython/translator/c/test/test_dtrace.py
+++ b/rpython/translator/c/test/test_dtrace.py
@@ -11,7 +11,8 @@
     config.translation.dtrace = True
 
     def setup_class(cls):
-        if sys.platform not in ['freebsd', 'darwin']:
+        if not (sys.platform.startswith('freebsd') or
+                sys.platform.startswith('darwin')):
             py.test.skip("not supported on other platforms")
     
     def test_dtrace_probes(self):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to