[pypy-commit] lang-smalltalk storage: Added --safe-trace flag which omits printing contents of byte objects.
anton_gulenko
noreply at buildbot.pypy.org
Thu Jul 24 11:27:12 CEST 2014
Author: Anton Gulenko <anton.gulenko at googlemail.com>
Branch: storage
Changeset: r942:adcfa00d78d1
Date: 2014-07-23 19:27 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/adcfa00d78d1/
Log: Added --safe-trace flag which omits printing contents of byte
objects.
diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py
--- a/spyvm/interpreter.py
+++ b/spyvm/interpreter.py
@@ -648,12 +648,13 @@
def _mustBeBoolean(self, interp, receiver):
return self._sendSpecialSelector(interp, receiver, "mustBeBoolean")
-
+
def _call_primitive(self, code, interp, argcount, w_method, w_selector):
# ##################################################################
if interp.is_tracing():
- interp.print_padded("-> primitive %d \t(in %s, named #%s)" % (
- code, self.w_method().get_identifier_string(), w_selector.str_content()))
+ interp.print_padded("-> primitive %d \t(in %s, named %s)" % (
+ code, self.w_method().get_identifier_string(),
+ w_selector.selector_string()))
func = primitives.prim_holder.prim_table[code]
try:
# note: argcount does not include rcvr
@@ -662,7 +663,7 @@
except primitives.PrimitiveFailedError, e:
if interp.is_tracing():
interp.print_padded("-- primitive %d FAILED\t (in %s, named %s)" % (
- code, w_method.safe_identifier_string(), w_selector.str_content()))
+ code, w_method.safe_identifier_string(), w_selector.selector_string()))
raise e
def _return(self, return_value, interp, local_return=False):
diff --git a/spyvm/model.py b/spyvm/model.py
--- a/spyvm/model.py
+++ b/spyvm/model.py
@@ -194,6 +194,9 @@
def repr_content(self):
return self.str_content()
+
+ def selector_string(self):
+ return self.as_repr_string()
class W_SmallInteger(W_Object):
"""Boxed integer value"""
@@ -817,15 +820,22 @@
return self._size
def str_content(self):
- return "'%s'" % self.as_string()
+ if self.has_class() and self.w_class.has_space():
+ if self.w_class.space().omit_printing_raw_bytes.is_set():
+ return "<omitted>"
+ else:
+ return "'%s'" % self.as_string().replace('\r', '\n')
def as_string(self):
if self.bytes is not None:
string = "".join(self.bytes)
else:
string = "".join([self.c_bytes[i] for i in range(self.size())])
- return string.replace('\r', '\n')
-
+ return string
+
+ def selector_string(self):
+ return "#" + self.as_string()
+
def invariant(self):
if not W_AbstractObjectWithClassReference.invariant(self):
return False
diff --git a/spyvm/objspace.py b/spyvm/objspace.py
--- a/spyvm/objspace.py
+++ b/spyvm/objspace.py
@@ -52,6 +52,7 @@
self.suppress_process_switch = ConstantFlag()
self.run_spy_hacks = ConstantFlag()
self.headless = ConstantFlag()
+ self.omit_printing_raw_bytes = ConstantFlag()
self.classtable = {}
self.objtable = {}
diff --git a/targetimageloadingsmalltalk.py b/targetimageloadingsmalltalk.py
--- a/targetimageloadingsmalltalk.py
+++ b/targetimageloadingsmalltalk.py
@@ -12,7 +12,7 @@
def _usage(argv):
print """
- Usage: %s <path> [-r|-m|-h] [-naPu] [-jpiS] [-tlLE]
+ Usage: %s <path> [-r|-m|-h] [-naPu] [-jpiS] [-tslLE]
<path> - image path (default: Squeak.image)
Execution mode:
@@ -40,6 +40,7 @@
Logging parameters:
-t|--trace - Output a trace of each message, primitive, return value and process switch.
+ -s|--safe-trace - Like -t, but without printing contents of BytesObjects
-l|--storage-log - Output a log of storage operations.
-L|--storage-log-aggregate - Output an aggregated storage log at the end of execution.
-E|--storage-log-elements - Include classnames of elements into the storage log.
@@ -110,6 +111,9 @@
selector, idx = get_parameter(argv, idx, arg)
elif arg in ["-t", "--trace"]:
trace = True
+ elif arg in ["-s", "--safe-trace"]:
+ trace = True
+ space.omit_printing_raw_bytes.activate()
elif arg in ["-p", "--poll"]:
poll = True
elif arg in ["-a", "--arg"]:
More information about the pypy-commit
mailing list