runtime-gdb.py: gdb pretty printer for go strings properly handles length.
R=rsc, r2
CC=golang-dev
https://golang.org/cl/4183060
diff --git a/src/pkg/runtime/runtime-gdb.py b/src/pkg/runtime/runtime-gdb.py
index 677e9bd..68dd8ab 100644
--- a/src/pkg/runtime/runtime-gdb.py
+++ b/src/pkg/runtime/runtime-gdb.py
@@ -13,7 +13,7 @@
# - 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 @@
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: