Commit 1c82e236 authored by Jan Kratochvil's avatar Jan Kratochvil Committed by Ian Lance Taylor

gdb: fix map prettyprinter

(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/5522Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 9f926e81
......@@ -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']
......
......@@ -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)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment