-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/compile: enhance debug_test for infinite loops
ssa/debug_test.go already had a step limit; this exposes it to individual tests, and it is then set low for the infinite loop tests. That however is not enough; in an infinite loop debuggers see an unchanging line number, and therefore keep trying until they see a different one. To do this, the concept of a "bogus" line number is introduced, and on output single-instruction infinite loops are detected and a hardware nop with correct line number is inserted into the loop; the branch itself receives a bogus line number. This breaks up the endless stream of same line number and causes both gdb and delve to not hang; Delve complains about the incorrect line number while gdb does a sort of odd step-to-nowhere that then steps back to the loop. Since repeats are suppressed in the reference file, a single line is shown there. (The wrong line number mentioned in previous message was an artifact of debug_test.go, not Delve, and is now fixed.) The bogus line number exposed in Delve is less than wonderful, but compared to hanging, it is better. Fixes #30664. Change-Id: I30c927cf8869a84c6c9b84033ee44d7044aab552 Reviewed-on: https://go-review.googlesource.com/c/go/+/168477 Run-TryBot: David Chase <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Keith Randall <[email protected]>
- Loading branch information
Showing
7 changed files
with
81 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/cmd/compile/internal/ssa/testdata/infloop.dlv-opt.nexts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
./testdata/infloop.go | ||
6: func test() { | ||
8: go func() {}() | ||
10: for { | ||
1048575: | ||
10: for { | ||
1048575: | ||
10: for { | ||
1048575: | ||
10: for { | ||
1048575: | ||
10: for { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
src/cmd/compile/internal/ssa/testdata/infloop.go | ||
6: func test() { | ||
8: go func() {}() | ||
10: for { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package main | ||
|
||
var sink int | ||
|
||
//go:noinline | ||
func test() { | ||
// This is for #30167, incorrect line numbers in an infinite loop | ||
go func() {}() | ||
|
||
for { | ||
} | ||
} | ||
|
||
func main() { | ||
test() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters