Author: Anton Gulenko <anton.gule...@googlemail.com> Branch: storage Changeset: r903:b73849087f13 Date: 2014-07-13 16:42 +0200 http://bitbucket.org/pypy/lang-smalltalk/changeset/b73849087f13/
Log: Printing better information in case of a doesNotUnderstand: diff --git a/spyvm/model.py b/spyvm/model.py --- a/spyvm/model.py +++ b/spyvm/model.py @@ -821,9 +821,10 @@ def as_string(self): if self.bytes is not None: - return "".join(self.bytes) + string = "".join(self.bytes) else: - return "".join([self.c_bytes[i] for i in range(self.size())]) + string = "".join([self.c_bytes[i] for i in range(self.size())]) + return string.replace('\r', '\n') def invariant(self): if not W_AbstractObjectWithClassReference.invariant(self): diff --git a/spyvm/objspace.py b/spyvm/objspace.py --- a/spyvm/objspace.py +++ b/spyvm/objspace.py @@ -33,6 +33,7 @@ self.no_specialized_storage = ConstantFlag() # This is a hack; see compile_code() in targetimageloadingsmalltalk.py self.suppress_process_switch = ConstantFlag() + self.headless = ConstantFlag() self.classtable = {} self.objtable = {} diff --git a/spyvm/primitives.py b/spyvm/primitives.py --- a/spyvm/primitives.py +++ b/spyvm/primitives.py @@ -2,10 +2,8 @@ import inspect import math import operator -from spyvm import model, shadow -from spyvm import constants, display -from spyvm.error import PrimitiveFailedError, \ - PrimitiveNotYetWrittenError +from spyvm import model, shadow, error, constants, display +from spyvm.error import PrimitiveFailedError, PrimitiveNotYetWrittenError from spyvm import wrapper from rpython.rlib import rarithmetic, rfloat, unroll, jit @@ -374,14 +372,26 @@ @expose_primitive(FAIL) def func(interp, s_frame, argcount): - if s_frame.w_method().lookup_selector == 'doesNotUnderstand:': - print '' - print s_frame.print_stack() - w_message = s_frame.peek(0) - print ("%s" % w_message).replace('\r', '\n') - print ("%s" % s_frame.peek(1)).replace('\r', '\n') - if isinstance(w_message, model.W_PointersObject): - print ('%s' % w_message.fetch_all(s_frame.space)).replace('\r', '\n') + 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 "== 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() + raise error.Exit("Unhandled doesNotUnderstand:") raise PrimitiveFailedError() # ___________________________________________________________________________ diff --git a/spyvm/shadow.py b/spyvm/shadow.py --- a/spyvm/shadow.py +++ b/spyvm/shadow.py @@ -929,6 +929,9 @@ # ______________________________________________________________________ # Printing + def argument_strings(self): + return [ w_arg.as_repr_string() for w_arg in self.w_arguments() ] + def __str__(self): retval = self.short_str() retval += "\n%s" % self.w_method().bytecode_string(markBytecode=self.pc() + 1) @@ -1099,7 +1102,7 @@ # === Printing === - def argument_strings(self): + def w_arguments(self): return [] def method_str(self): @@ -1255,13 +1258,9 @@ # === Printing === - def argument_strings(self): + def w_arguments(self): argcount = self.w_method().argsize - tempsize = self.w_method().tempsize() - args = [] - for i in range(argcount): - args.append(self.peek(tempsize - i - 1).as_repr_string()) - return args + return [ self.stack_get(i) for i in range(argcount) ] def method_str(self): block = '[] in ' if self.is_closure_context() else '' diff --git a/targetimageloadingsmalltalk.py b/targetimageloadingsmalltalk.py --- a/targetimageloadingsmalltalk.py +++ b/targetimageloadingsmalltalk.py @@ -165,6 +165,7 @@ return -1 # Compilation failed, message is printed. s_frame = create_context(interp, w_receiver, selector, stringarg) if headless: + space.headless.set() context = s_frame else: create_process(interp, s_frame) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit