terminal: add prompt when breakpoint is hit during next/step/stepout (#2548)

* terminal: add prompt when breakpoint is hit during next/step/stepout

Adds a prompt asking the user what to do when a breakpoint is hit on a
different goroutine while next/step/stepout is being executed.
Gives the user the opportunity to cancel next/step/stepout, continue
once skipping the breakpoint or automatically skipping all other
concurrent breakpoints until next/step/stepout is finished.

Fixes #2317
This commit is contained in:
Alessandro Arzilli
2021-07-26 17:57:09 +02:00
committed by GitHub
parent e9b20d5ee1
commit 2ecc025311
2 changed files with 35 additions and 42 deletions

View File

@ -582,47 +582,6 @@ func countOccurrences(s, needle string) int {
return count
}
func TestIssue387(t *testing.T) {
if runtime.GOOS == "freebsd" {
t.Skip("test is not valid on FreeBSD")
}
// a breakpoint triggering during a 'next' operation will interrupt it
test.AllowRecording(t)
withTestTerminal("issue387", t, func(term *FakeTerminal) {
breakpointHitCount := 0
term.MustExec("break dostuff")
for {
outstr, err := term.Exec("continue")
breakpointHitCount += countOccurrences(outstr, "issue387.go:8")
t.Log(outstr)
if err != nil {
if !strings.Contains(err.Error(), "exited") {
t.Fatalf("Unexpected error executing 'continue': %v", err)
}
break
}
pos := 9
for {
outstr = term.MustExec("next")
breakpointHitCount += countOccurrences(outstr, "issue387.go:8")
t.Log(outstr)
if countOccurrences(outstr, fmt.Sprintf("issue387.go:%d", pos)) == 0 {
t.Fatalf("did not continue to expected position %d", pos)
}
pos++
if pos >= 11 {
break
}
}
}
if breakpointHitCount != 10 {
t.Fatalf("Breakpoint hit wrong number of times, expected 10 got %d", breakpointHitCount)
}
})
}
func listIsAt(t *testing.T, term *FakeTerminal, listcmd string, cur, start, end int) {
t.Helper()
outstr := term.MustExec(listcmd)