Permalink
Browse files

[tools] Support more gdb-pp.py encodings

Also fix a python gdb strlen error. The number of char is needed, not the number of codepoints.
  • Loading branch information...
1 parent e414aae commit f163f842502cb15005b701b09cfd9caf145156cd Reini Urban committed Sep 30, 2012
Showing with 10 additions and 3 deletions.
  1. +10 −3 tools/dev/gdb-pp.py
View
@@ -1,4 +1,4 @@
-# Copyright (C) 2011, Parrot Foundation.
+# Copyright (C) 2011-2012, Parrot Foundation.
from gdb.printing import PrettyPrinter, SubPrettyPrinter
import gdb.types
import gdb
@@ -155,6 +155,13 @@ def _parrot_str_to_str(val):
"""
encoding = val['encoding'].dereference()
encoding_name = encoding['name'].string()
- length = val['strlen']
-
+ length = val['bufused']
+
+ # See http://docs.python.org/library/codecs.html#standard-encodings
+ if encoding_name == 'binary':
+ encoding_name='raw_unicode_escape'
+ if encoding_name == 'ucs2':
+ encoding_name='utf_16_le'
+ if encoding_name == 'ucs4':
+ encoding_name=='utf_32_le'
return val['strstart'].string(encoding=encoding_name,length=length)

0 comments on commit f163f84

Please sign in to comment.