aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/runtime-gdb_test.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/runtime/runtime-gdb_test.go b/src/runtime/runtime-gdb_test.go
index ba005ac35b..3f2d74248b 100644
--- a/src/runtime/runtime-gdb_test.go
+++ b/src/runtime/runtime-gdb_test.go
@@ -68,14 +68,18 @@ func checkGdbPython(t *testing.T) {
const helloSource = `
package main
import "fmt"
+var gslice []string
func main() {
mapvar := make(map[string]string,5)
mapvar["abc"] = "def"
mapvar["ghi"] = "jkl"
strvar := "abc"
ptrvar := &strvar
- fmt.Println("hi") // line 10
+ slicevar := make([]string, 0, 16)
+ slicevar = append(slicevar, mapvar["abc"])
+ fmt.Println("hi") // line 12
_ = ptrvar
+ gslice = slicevar
}
`
@@ -120,6 +124,9 @@ func TestGdbPython(t *testing.T) {
"-ex", "echo BEGIN print strvar\n",
"-ex", "print strvar",
"-ex", "echo END\n",
+ "-ex", "echo BEGIN info locals\n",
+ "-ex", "info locals",
+ "-ex", "echo END\n",
"-ex", "down", // back to fmt.Println (goroutine 2 below only works at bottom of stack. TODO: fix that)
"-ex", "echo BEGIN goroutine 2 bt\n",
"-ex", "goroutine 2 bt",
@@ -168,6 +175,15 @@ func TestGdbPython(t *testing.T) {
t.Fatalf("print strvar failed: %s", bl)
}
+ // Issue 16338: ssa decompose phase can split a structure into
+ // a collection of scalar vars holding the fields. In such cases
+ // the DWARF variable location expression should be of the
+ // form "var.field" and not just "field".
+ infoLocalsRe := regexp.MustCompile(`^slicevar.len = `)
+ if bl := blocks["info locals"]; !infoLocalsRe.MatchString(bl) {
+ t.Fatalf("info locals failed: %s", bl)
+ }
+
btGoroutineRe := regexp.MustCompile(`^#0\s+runtime.+at`)
if bl := blocks["goroutine 2 bt"]; !btGoroutineRe.MatchString(bl) {
t.Fatalf("goroutine 2 bt failed: %s", bl)