]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: in runtime-gdb.py, use SliceValue wrapper
authorAustin Clements <austin@google.com>
Tue, 17 Feb 2015 03:04:24 +0000 (22:04 -0500)
committerAustin Clements <austin@google.com>
Tue, 17 Feb 2015 18:41:10 +0000 (18:41 +0000)
Rather than reaching in to slices directly in the slice pretty
printer, use the newly introduced SliceValue wrapper.

Change-Id: Ibb25f8c618c2ffb3fe1a8dd044bb9a6a085df5b7
Reviewed-on: https://go-review.googlesource.com/4936
Reviewed-by: Minux Ma <minux@golang.org>
src/runtime/runtime-gdb.py

index 33fcc7693134708d26ea85ab7f2be3f20000693b..6076bcb11bcadf1fd7afe4179b4c98a9179c4323 100644 (file)
@@ -88,11 +88,11 @@ class SliceTypePrinter:
                return str(self.val.type)[6:]  # skip 'struct '
 
        def children(self):
-               if self.val["len"] > self.val["cap"]:
+               sval = SliceValue(self.val)
+               if sval.len > sval.cap:
                        return
-               ptr = self.val["array"]
-               for idx in range(int(self.val["len"])):
-                       yield ('[{0}]'.format(idx), (ptr + idx).dereference())
+               for idx, item in enumerate(sval):
+                       yield ('[{0}]'.format(idx), item)
 
 
 class MapTypePrinter: