cmd/compile: leave Pos unset for racewalk enter/exit

The locations chosen for racewalking inserted code can
be wrong and thus cause unwanted next/step behavior in
debuggers.  Forcing the positions to be unset results in
better behavior.

Test added, and test harness corrected to deal with
changes to gdb's output caused by -racewalk.

Incidental changes in Delve (not part of the usual testing,
but provided because we care about Delve) also reflected
in this CL.

Fixes #22600.

Change-Id: Idd0218afed52ab8c68efd9eabbdff3c92ea2b996
Reviewed-on: https://go-review.googlesource.com/78336
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
David Chase 2017-11-15 18:25:01 -08:00
parent c2efb2fde5
commit d2414cefba
5 changed files with 130 additions and 3 deletions

View file

@ -132,6 +132,9 @@ func TestNexting(t *testing.T) {
t.Run("dbg-"+debugger, func(t *testing.T) {
testNexting(t, "hist", "dbg", "-N -l")
})
t.Run("dbg-race-"+debugger, func(t *testing.T) {
testNexting(t, "i22600", "dbg-race", "-N -l", "-race")
})
t.Run("opt-"+debugger, func(t *testing.T) {
// If this is test is run with a runtime compiled with -N -l, it is very likely to fail.
// This occurs in the noopt builders (for example).
@ -148,7 +151,7 @@ func TestNexting(t *testing.T) {
})
}
func testNexting(t *testing.T, base, tag, gcflags string) {
func testNexting(t *testing.T, base, tag, gcflags string, moreArgs ...string) {
// (1) In testdata, build sample.go into sample
// (2) Run debugger gathering a history
// (3) Read expected history from testdata/sample.<variant>.nexts
@ -171,7 +174,11 @@ func testNexting(t *testing.T, base, tag, gcflags string) {
defer os.RemoveAll(tmpdir)
}
runGo(t, "", "build", "-o", exe, "-gcflags=all="+gcflags, filepath.Join("testdata", base+".go"))
runGoArgs := []string{"build", "-o", exe, "-gcflags=all=" + gcflags}
runGoArgs = append(runGoArgs, moreArgs...)
runGoArgs = append(runGoArgs, filepath.Join("testdata", base+".go"))
runGo(t, "", runGoArgs...)
var h1 *nextHist
nextlog := logbase + "-" + debugger + ".nexts"
@ -533,7 +540,7 @@ func newGdb(tag, executable string, args ...string) dbgr {
s := &gdbState{tag: tag, cmd: cmd, args: args}
s.atLineRe = regexp.MustCompile("(^|\n)([0-9]+)(.*)")
s.funcFileLinePCre = regexp.MustCompile(
"([^ ]+) [(][)][ \\t\\n]+at ([^:]+):([0-9]+)")
"([^ ]+) [(][^)]*[)][ \\t\\n]+at ([^:]+):([0-9]+)")
// runtime.main () at /Users/drchase/GoogleDrive/work/go/src/runtime/proc.go:201
// function file line
// Thread 2 hit Breakpoint 1, main.main () at /Users/drchase/GoogleDrive/work/debug/hist.go:18