[pypy-commit] lang-smalltalk default: added vmdebugging plugin allowing squeak code to start tracing and halting (when interpreted)

lwassermann noreply at buildbot.pypy.org
Tue Apr 30 11:15:05 CEST 2013


Author: Lars Wassermann <lars.wassermann at gmail.com>
Branch: 
Changeset: r355:00e92c2f5b1c
Date: 2013-04-30 11:14 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/00e92c2f5b1c/

Log:	added vmdebugging plugin allowing squeak code to start tracing and
	halting (when interpreted)

diff --git a/spyvm/plugins/vmdebugging.py b/spyvm/plugins/vmdebugging.py
new file mode 100644
--- /dev/null
+++ b/spyvm/plugins/vmdebugging.py
@@ -0,0 +1,29 @@
+from spyvm import model, error
+from spyvm.plugins.plugin import Plugin
+
+
+DebuggingPlugin = Plugin()
+
+
+ at DebuggingPlugin.expose_primitive(unwrap_spec=[object])
+def trace(interp, s_frame, w_rcvr):
+    interp.trace = True
+    return w_rcvr
+
+ at DebuggingPlugin.expose_primitive(unwrap_spec=[object])
+def untrace(interp, s_frame, w_rcvr):
+    interp.trace = False
+    return w_rcvr
+
+ at DebuggingPlugin.expose_primitive(unwrap_spec=[object])
+def halt(interp, s_frame, w_rcvr):
+    from rpython.rlib.objectmodel import we_are_translated
+    from spyvm.error import Exit
+
+    if not we_are_translated():
+        import pdb; pdb.set_trace()
+    else:
+        print s_frame.print_stack()[1]
+        print s_frame
+        raise Exit('Halt is not well defined when translated.')
+    return w_rcvr
diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -816,8 +816,6 @@
 
 @expose_primitive(EXTERNAL_CALL, clean_stack=False, no_result=True, compiled_method=True)
 def func(interp, s_frame, argcount, s_method):
-    from spyvm.plugins.socket import SocketPlugin
-
     space = interp.space
     w_description = s_method.w_self().literalat0(space, 1)
     if not isinstance(w_description, model.W_PointersObject) or w_description.size() < 2:
@@ -832,7 +830,11 @@
     if signature == ('BitBltPlugin', 'primitiveCopyBits'):
         return prim_holder.prim_table[BITBLT_COPY_BITS](interp, s_frame, argcount, s_method)
     elif signature[0] == "SocketPlugin":
+        from spyvm.plugins.socket import SocketPlugin
         return SocketPlugin.call(signature[1], interp, s_frame, argcount, s_method)
+    elif signature[0] == "VMDebugging":
+        from spyvm.plugins.vmdebugging import DebuggingPlugin
+        return DebuggingPlugin.call(signature[1], interp, s_frame, argcount, s_method)
     raise PrimitiveFailedError
 
 # ___________________________________________________________________________


More information about the pypy-commit mailing list