]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: enhance debug_test for infinite loops
authorDavid Chase <drchase@google.com>
Wed, 20 Mar 2019 18:29:28 +0000 (14:29 -0400)
committerDavid Chase <drchase@google.com>
Wed, 27 Mar 2019 21:04:34 +0000 (21:04 +0000)
commit591193b01fbf0ae6ad4ad6fee610d7807b8bdf7c
treeb54c66f29097899ca7b81a82ed5888442b3dae04
parent3089d189569ed272eaf2bc6c4330e848a46e9999
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 <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/ssa/debug_test.go
src/cmd/compile/internal/ssa/testdata/infloop.dlv-opt.nexts [new file with mode: 0644]
src/cmd/compile/internal/ssa/testdata/infloop.gdb-opt.nexts [new file with mode: 0644]
src/cmd/compile/internal/ssa/testdata/infloop.go [new file with mode: 0644]
src/cmd/internal/src/pos.go
src/cmd/internal/src/xpos.go