[pypy-commit] lang-smalltalk default: added print_stack method to ContextPartShadow to alleviate Smalltalk stack identification during debugging

lwassermann noreply at buildbot.pypy.org
Thu Apr 25 12:11:52 CEST 2013


Author: Lars Wassermann <lars.wassermann at gmail.com>
Branch: 
Changeset: r336:2e86339195d1
Date: 2013-04-25 12:10 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/2e86339195d1/

Log:	added print_stack method to ContextPartShadow to alleviate Smalltalk
	stack identification during debugging

diff --git a/spyvm/model.py b/spyvm/model.py
--- a/spyvm/model.py
+++ b/spyvm/model.py
@@ -926,7 +926,7 @@
 
     def get_identifier_string(self):
         from spyvm import shadow
-        classname = '<unknown>'
+        classname = '<unknown>  class'
         if len(self.literals) > 0:
             w_candidate = self.literals[-1]
             if isinstance(w_candidate, W_PointersObject):
@@ -939,6 +939,9 @@
                             classname = d_shadow.getname()
                 elif isinstance(shadow, shadow.ClassShadow):
                     classname = c_shadow.getname()
+        class_cutoff = len(classname) - 6
+        if class_cutoff > 0:
+            classname = classname[0:class_cutoff]
         return "%s>>#%s" % (classname, self._likely_methodname)
 
 
diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -586,7 +586,8 @@
         raise PrimitiveFailedError
 
     # only allow combinationRules 0-41
-    if interp.space.unwrap_positive_32bit_int(w_rcvr.fetch(interp.space, 3)) > 41:
+    combinationRule = interp.space.unwrap_positive_32bit_int(w_rcvr.fetch(interp.space, 3))
+    if combinationRule > 41:
         raise PrimitiveFailedError
 
     space = interp.space
diff --git a/spyvm/shadow.py b/spyvm/shadow.py
--- a/spyvm/shadow.py
+++ b/spyvm/shadow.py
@@ -702,6 +702,15 @@
     def instances_array(self):
         return self.instances_w
 
+    # ______________________________________________________________________
+    # Debugging printout
+
+    def print_stack(self):
+        padding = ret_str = ''
+        if self.s_sender() is not None:
+            padding, ret_str = self.s_sender().print_stack()
+        return padding + ' ', '%s\n%s%s' % (ret_str, padding, self.short_str(0))
+
 
 class BlockContextShadow(ContextPartShadow):
     _attr_ = ['_w_home', '_initialip', '_eargc']
@@ -952,6 +961,13 @@
 
     def short_str(self, argcount):
         block = '[] of ' if self.is_closure_context() else ''
+        if argcount == 0:
+            return '%s%s (rcvr: %s) [pc: %d]' % (
+                block,
+                self.w_method().get_identifier_string(),
+                self.w_receiver().as_repr_string(),
+                self.pc() + 1
+            )
         args = '%d' % argcount
         for i in range(argcount - 1, -1, -1):
             args += ': %s' % self.peek(i).as_repr_string()


More information about the pypy-commit mailing list