Skip to content

Commit a9c69e0

Browse files
shuLhanianlancetaylor
authored andcommitted
runtime: fix runtime gdb test with gdb v8.2
Previously, some of output from gdb matched with literal string, while gdb v8.2 print the address of variable (e.g. map key and value) in output. This commit fix the regex in testing the output. Fixes #27608 Change-Id: Ic3fe8280b9f93fda2799116804822616caa66beb Reviewed-on: https://go-review.googlesource.com/135055 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: David Chase <[email protected]>
1 parent b57ccdf commit a9c69e0

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/runtime/runtime-gdb_test.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,14 @@ func testGdbPython(t *testing.T, cgo bool) {
242242
t.Fatalf("info goroutines failed: %s", bl)
243243
}
244244

245-
printMapvarRe1 := regexp.MustCompile(`\Q = map[string]string = {["abc"] = "def", ["ghi"] = "jkl"}\E$`)
246-
printMapvarRe2 := regexp.MustCompile(`\Q = map[string]string = {["ghi"] = "jkl", ["abc"] = "def"}\E$`)
245+
printMapvarRe1 := regexp.MustCompile(`^\$[0-9]+ = map\[string\]string = {\[(0x[0-9a-f]+\s+)?"abc"\] = (0x[0-9a-f]+\s+)?"def", \[(0x[0-9a-f]+\s+)?"ghi"\] = (0x[0-9a-f]+\s+)?"jkl"}$`)
246+
printMapvarRe2 := regexp.MustCompile(`^\$[0-9]+ = map\[string\]string = {\[(0x[0-9a-f]+\s+)?"ghi"\] = (0x[0-9a-f]+\s+)?"jkl", \[(0x[0-9a-f]+\s+)?"abc"\] = (0x[0-9a-f]+\s+)?"def"}$`)
247247
if bl := blocks["print mapvar"]; !printMapvarRe1.MatchString(bl) &&
248248
!printMapvarRe2.MatchString(bl) {
249249
t.Fatalf("print mapvar failed: %s", bl)
250250
}
251251

252-
strVarRe := regexp.MustCompile(`\Q = "abc"\E$`)
252+
strVarRe := regexp.MustCompile(`^\$[0-9]+ = (0x[0-9a-f]+\s+)?"abc"$`)
253253
if bl := blocks["print strvar"]; !strVarRe.MatchString(bl) {
254254
t.Fatalf("print strvar failed: %s", bl)
255255
}
@@ -263,8 +263,11 @@ func testGdbPython(t *testing.T, cgo bool) {
263263
// aggregates from their fields and reverted their printing
264264
// back to its original form.
265265

266-
infoLocalsRe := regexp.MustCompile(`slicevar *= *\[\]string *= *{"def"}`)
267-
if bl := blocks["info locals"]; !infoLocalsRe.MatchString(bl) {
266+
infoLocalsRe1 := regexp.MustCompile(`slicevar *= *\[\]string *= *{"def"}`)
267+
// Format output from gdb v8.2
268+
infoLocalsRe2 := regexp.MustCompile(`^slicevar = .*\nmapvar = .*\nstrvar = 0x[0-9a-f]+ "abc"`)
269+
if bl := blocks["info locals"]; !infoLocalsRe1.MatchString(bl) &&
270+
!infoLocalsRe2.MatchString(bl) {
268271
t.Fatalf("info locals failed: %s", bl)
269272
}
270273

@@ -425,11 +428,11 @@ func TestGdbAutotmpTypes(t *testing.T) {
425428

426429
// Check that the backtrace matches the source code.
427430
types := []string{
428-
"struct []main.astruct;",
429-
"struct bucket<string,main.astruct>;",
430-
"struct hash<string,main.astruct>;",
431-
"struct main.astruct;",
432-
"typedef struct hash<string,main.astruct> * map[string]main.astruct;",
431+
"[]main.astruct;",
432+
"bucket<string,main.astruct>;",
433+
"hash<string,main.astruct>;",
434+
"main.astruct;",
435+
"hash<string,main.astruct> * map[string]main.astruct;",
433436
}
434437
for _, name := range types {
435438
if !strings.Contains(sgot, name) {

0 commit comments

Comments
 (0)