Author: Anton Gulenko <[email protected]>
Branch: storage
Changeset: r904:c5189bb59f35
Date: 2014-07-13 17:17 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/c5189bb59f35/

Log:    Fixed tracing and doesNotUnderstand outputs

diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py
--- a/spyvm/interpreter.py
+++ b/spyvm/interpreter.py
@@ -128,10 +128,11 @@
             # Now (continue to) execute the context bytecodes
             self.loop_bytecodes(s_frame, may_context_switch)
         except rstackovf.StackOverflow:
+            rstackovf.check_stack_overflow()
+            raise StackOverflow(s_frame)
+        finally:
             if self.is_tracing():
                 self.stack_depth -= 1
-            rstackovf.check_stack_overflow()
-            raise StackOverflow(s_frame)
 
     def step(self, context):
         bytecode = context.fetch_next_bytecode()
@@ -229,7 +230,7 @@
         
     def padding(self, symbol=' '):
         assert self.is_tracing()
-        return self.stack_depth * symbol
+        return symbol * self.stack_depth
 
 class ReturnFromTopLevel(Exception):
     _attrs_ = ["object"]
diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -370,24 +370,31 @@
 
 FAIL = 19
 
+def get_string(w_obj):
+    if isinstance(w_obj, model.W_BytesObject):
+        return w_obj.as_string()
+    return w_obj.as_repr_string()
+
 @expose_primitive(FAIL)
 def func(interp, s_frame, argcount):
     if interp.space.headless.is_set() and s_frame.w_method().lookup_selector 
== 'doesNotUnderstand:':
-        w_msg = s_frame.peek(1)
-        if isinstance(w_msg, model.W_BytesObject):
-            print "== Error message: %s" % w_msg.as_string()
+        print "== Error message: %s" % get_string(s_frame.peek(1))
+        print "== Receiver: %s" % s_frame.w_receiver().as_repr_string()
+        w_arguments = s_frame.w_arguments()
+        if len(w_arguments) >= 1:
+            w_message = w_arguments[0]
+            if isinstance(w_message, model.W_PointersObject):
+                fields = w_message.fetch_all(interp.space)
+                if len(fields) >= 1:
+                    print "== Selector: %s" % get_string(fields[0])
+                if len(fields) >= 2:
+                    w_args = fields[0]
+                    if isinstance(w_args, model.W_PointersObject):
+                        arg_strings = [ get_string(w_arg) for w_arg in 
w_args.fetch_all(interp.space) ]
+                        print "== Arguments: %s" % ', '.join(arg_strings)
+            else:
+                print "== Message: %s" % w_message
         print "== VM Stack:%s" % s_frame.print_stack()
-        print "== Message:"
-        for w_argument in s_frame.w_arguments():
-            print w_argument.as_repr_string()
-            if isinstance(w_argument, model.W_PointersObject):
-                fields = w_argument.fetch_all(interp.space)
-                for i, w_field in enumerate(fields):
-                    print "\t%s" % w_field.as_repr_string()
-                    if i == 1 and isinstance(w_field, model.W_PointersObject):
-                        # These are the arguments to the not-undersood message
-                        for w_field_field in w_field.fetch_all(interp.space):
-                            print "\t\t%s" % w_field_field.as_repr_string()
         w_stack = s_frame.peek(0)
         if isinstance(w_stack, model.W_BytesObject):
             print "== Squeak stack:\n%s" % w_stack.as_string()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to