proc: manual stop requests should clear internal breakpoints

Fixes #1145
This commit is contained in:
aarzilli 2018-03-07 11:14:34 +01:00 committed by Derek Parker
parent cd5203e305
commit 449b3cedef
5 changed files with 42 additions and 2 deletions

13
_fixtures/issue1145.go Normal file

@ -0,0 +1,13 @@
package main
import "time"
func f() {
for {
time.Sleep(10 * time.Millisecond)
}
}
func main() {
f()
}

@ -88,8 +88,16 @@ func Continue(dbp Process) error {
return &ProcessExitedError{Pid: dbp.Pid()}
}
dbp.CheckAndClearManualStopRequest()
defer func() {
// Make sure we clear internal breakpoints if we simultaneously receive a
// manual stop request and hit a breakpoint.
if dbp.CheckAndClearManualStopRequest() {
dbp.ClearInternalBreakpoints()
}
}()
for {
if dbp.CheckAndClearManualStopRequest() {
dbp.ClearInternalBreakpoints()
return nil
}
trapthread, err := dbp.ContinueOnce()

@ -3436,3 +3436,22 @@ func TestIssue1101(t *testing.T) {
}
})
}
func TestIssue1145(t *testing.T) {
withTestProcess("issue1145", t, func(p proc.Process, fixture protest.Fixture) {
setFileBreakpoint(p, t, fixture, 12)
assertNoError(proc.Continue(p), t, "Continue()")
resumeChan := make(chan struct{}, 1)
p.ResumeNotify(resumeChan)
go func() {
<-resumeChan
time.Sleep(100 * time.Millisecond)
p.RequestManualStop()
}()
assertNoError(proc.Next(p), t, "Next()")
if p.Breakpoints().HasInternalBreakpoints() {
t.Fatal("has internal breakpoints after manual stop request")
}
})
}

@ -750,6 +750,7 @@ func continueUntilCompleteNext(t *Term, state *api.DebuggerState, op string) err
return nil
}
for {
fmt.Printf("\tbreakpoint hit during %s, continuing...\n", op)
stateChan := t.client.Continue()
var state *api.DebuggerState
for state = range stateChan {
@ -763,7 +764,6 @@ func continueUntilCompleteNext(t *Term, state *api.DebuggerState, op string) err
printfile(t, state.CurrentThread.File, state.CurrentThread.Line, true)
return nil
}
fmt.Printf("\tbreakpoint hit during %s, continuing...\n", op)
}
}

@ -76,7 +76,7 @@ func (t *Term) Run() (int, error) {
signal.Notify(ch, syscall.SIGINT)
go func() {
for range ch {
fmt.Printf("received SIGINT, stopping process (will not forward signal)")
fmt.Printf("received SIGINT, stopping process (will not forward signal)\n")
_, err := t.client.Halt()
if err != nil {
fmt.Fprintf(os.Stderr, "%v", err)