]> Cypherpunks repositories - gostls13.git/commitdiff
runtime-gdb.py: gdb pretty printer for go strings properly handles length.
authorLuuk van Dijk <lvd@golang.org>
Sun, 20 Feb 2011 17:53:23 +0000 (18:53 +0100)
committerLuuk van Dijk <lvd@golang.org>
Sun, 20 Feb 2011 17:53:23 +0000 (18:53 +0100)
R=rsc, r2
CC=golang-dev
https://golang.org/cl/4183060

src/pkg/runtime/runtime-gdb.py

index 677e9bde4c8ca5b98644af4e1284b71ede8ea62a..68dd8abdc6edb465faaa8dcb754208c254b68aad 100644 (file)
@@ -13,7 +13,7 @@ path to this file based on the path to the runtime package.
 #    - pretty printing only works for the 'native' strings. E.g. 'type
 #      foo string' will make foo a plain struct in the eyes of gdb,
 #      circumventing the pretty print triggering.
-#    -
+
 
 import sys, re
 
@@ -39,7 +39,8 @@ class StringTypePrinter:
                return 'string'
 
        def to_string(self):
-               return self.val['str']
+               l = int(self.val['len'])
+               return self.val['str'].string("utf-8", "ignore", l)
 
 
 class SliceTypePrinter: