]> Cypherpunks repositories - gostls13.git/commitdiff
gdb: fix map prettyprinter
authorJan Kratochvil <jan.kratochvil@redhat.com>
Sat, 21 Feb 2015 17:18:33 +0000 (18:18 +0100)
committerIan Lance Taylor <iant@golang.org>
Wed, 25 Feb 2015 02:36:41 +0000 (02:36 +0000)
(gdb) p x
Python Exception <class 'gdb.error'> There is no member named b.:
$2 = map[string]string
->
(gdb) p x
$1 = map[string]string = {["shane"] = "hansen"}

Change-Id: I874d02a029f2ac9afc5ab666afb65760ec2c3177
Reviewed-on: https://go-review.googlesource.com/5522
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/runtime/runtime-gdb.py
src/runtime/runtime-gdb_test.go

index 47a28f5ee6eb29ef80d2c2ba829ebdf2dc93cb9e..9f2ba9f934878f1717d68e6eb7a594c5a2fc25d1 100644 (file)
@@ -114,7 +114,7 @@ class MapTypePrinter:
                return str(self.val.type)
 
        def children(self):
-               B = self.val['b']
+               B = self.val['B']
                buckets = self.val['buckets']
                oldbuckets = self.val['oldbuckets']
                flags = self.val['flags']
index 36a0dc9e3c322b19e31e86428c595c76dc44f8e0..1668f8b1bb9b777e15cd6cb17d55917c0b53b8fe 100644 (file)
@@ -27,9 +27,15 @@ func checkGdbPython(t *testing.T) {
 const helloSource = `
 package main
 import "fmt"
-func main() {
+func finish() {
        fmt.Println("hi")
 }
+func main() {
+       mapvar := make(map[string]string,5)
+       mapvar["abc"] = "def"
+       mapvar["ghi"] = "jkl"
+       finish()
+}
 `
 
 func TestGdbPython(t *testing.T) {
@@ -60,11 +66,15 @@ func TestGdbPython(t *testing.T) {
 
        got, _ := exec.Command("gdb", "-nx", "-q", "--batch", "-iex",
                fmt.Sprintf("add-auto-load-safe-path %s/src/runtime", runtime.GOROOT()),
-               "-ex", "br 'main.main'",
+               "-ex", "br 'main.finish'",
                "-ex", "run",
+               "-ex", "up",
                "-ex", "echo BEGIN info goroutines\n",
                "-ex", "info goroutines",
                "-ex", "echo END\n",
+               "-ex", "echo BEGIN print mapvar\n",
+               "-ex", "print mapvar",
+               "-ex", "echo END\n",
                filepath.Join(dir, "a.exe")).CombinedOutput()
 
        firstLine := bytes.SplitN(got, []byte("\n"), 2)[0]
@@ -83,4 +93,9 @@ func TestGdbPython(t *testing.T) {
        if bl := blocks["info goroutines"]; !infoGoroutinesRe.MatchString(bl) {
                t.Fatalf("info goroutines failed: %s", bl)
        }
+
+       printMapvarRe := regexp.MustCompile(`\Q = map[string]string = {["abc"] = "def", ["ghi"] = "jkl"}\E$`)
+       if bl := blocks["print mapvar"]; !printMapvarRe.MatchString(bl) {
+               t.Fatalf("print mapvar failed: %s", bl)
+       }
 }