Author: Maciej Fijalkowski <[email protected]>
Branch: 
Changeset: r61767:5575406012fe
Date: 2013-02-25 19:09 +0100
http://bitbucket.org/pypy/pypy/changeset/5575406012fe/

Log:    an attempt to improve string printing

diff --git a/pypy/tool/gdb_pypy.py b/pypy/tool/gdb_pypy.py
--- a/pypy/tool/gdb_pypy.py
+++ b/pypy/tool/gdb_pypy.py
@@ -23,6 +23,7 @@
         def __init__(self, name, command_class):
             pass
 
+MAX_DISPLAY_LENGTH = 100 # maximum number of characters displayed in rpy_string
 
 def find_field_with_suffix(val, suffix):
     """
@@ -152,7 +153,15 @@
         chars = self.val['rs_chars']
         length = int(chars['length'])
         items = chars['items']
-        res = [chr(items[i]) for i in range(length)]
+        res = []
+        for i in range(min(length, MAX_DISPLAY_LENGTH)):
+            try:
+                res.append(chr(items[i]))
+            except ValueError:
+                # it's a gdb.Value so it has "121 'y'" as repr
+                res.append(chr(int(str(items[0]).split(" ")[0])))
+        if i < length:
+            res.append('...')
         string = ''.join(res)
         return 'r' + repr(string)
 
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to