[pypy-commit] pypy dtrace-support: try to support debug_probe

fijal noreply at buildbot.pypy.org
Wed Mar 18 16:16:46 CET 2015


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: dtrace-support
Changeset: r76455:5190ebff847e
Date: 2015-03-18 17:16 +0200
http://bitbucket.org/pypy/pypy/changeset/5190ebff847e/

Log:	try to support debug_probe

diff --git a/rpython/rtyper/lltypesystem/lloperation.py b/rpython/rtyper/lltypesystem/lloperation.py
--- a/rpython/rtyper/lltypesystem/lloperation.py
+++ b/rpython/rtyper/lltypesystem/lloperation.py
@@ -557,6 +557,8 @@
     # __________ debugging __________
     'debug_view':           LLOp(),
     'debug_print':          LLOp(canrun=True),
+    'debug_probe':          LLOp(canrun=True),
+    # dtrace or similar probe call
     'debug_start':          LLOp(canrun=True),
     'debug_stop':           LLOp(canrun=True),
     'have_debug_prints':    LLOp(canrun=True),
diff --git a/rpython/rtyper/lltypesystem/opimpl.py b/rpython/rtyper/lltypesystem/opimpl.py
--- a/rpython/rtyper/lltypesystem/opimpl.py
+++ b/rpython/rtyper/lltypesystem/opimpl.py
@@ -594,6 +594,9 @@
 def op_debug_flush():
     pass
 
+def op_debug_probe(probename, arg):
+    pass
+
 def op_have_debug_prints():
     return debug.have_debug_prints()
 
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
@@ -808,6 +808,14 @@
     def OP_DEBUG_STOP(self, op):
         return self._op_debug('PYPY_DEBUG_STOP', op.args[0])
 
+    def OP_DEBUG_PROBE(self, op):
+        if not self.db.translator.config.translation.dtrace:
+            return
+        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]))
+
     def OP_DEBUG_ASSERT(self, op):
         return 'RPyAssert(%s, %s);' % (self.expr(op.args[0]),
                                        c_string_constant(op.args[1].value))
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
@@ -1,12 +1,18 @@
 
-import subprocess
+import subprocess, py, sys
 from rpython.translator.c.test.test_standalone import StandaloneTests
 from rpython.rlib.debug import debug_start, debug_stop
 from rpython.config.translationoption import get_combined_translation_config
+from rpython.rtyper.lltypesystem.lloperation import llop
+from rpython.rtyper.lltypesystem import lltype
 
 class TestDTrace(StandaloneTests):
     config = get_combined_translation_config(translating=True)
     config.translation.dtrace = True
+
+    def setup_class(cls):
+        if sys.platform not in ['freebsd', 'darwin']:
+            py.test.skip("not supported on other platforms")
     
     def test_dtrace_probes(self):
         def f(argv):
@@ -24,3 +30,16 @@
         out = p.stdout.read()
         assert 'pypy_g_f:x-start' in out
         assert 'pypy_g_f:x-end' in out
+
+    def test_debug_probe(self):
+        def f(argv):
+            llop.debug_probe(lltype.Void, "foo", 13)
+            return 0
+
+        _, cbuilder = self.compile(f)
+        exe = cbuilder.executable_name
+        p = subprocess.Popen(['dtrace', '-n', ':' + exe.basename + '::',
+                              '-c', str(exe)], stdout=subprocess.PIPE,
+                              stderr=subprocess.PIPE)
+        out = p.stdout.read()
+        assert 'pypy_g_f:foo' in out


More information about the pypy-commit mailing list