proc: manual stop requests should clear internal breakpoints
Fixes #1145
This commit is contained in:
parent
cd5203e305
commit
449b3cedef
13
_fixtures/issue1145.go
Normal file
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()}
|
return &ProcessExitedError{Pid: dbp.Pid()}
|
||||||
}
|
}
|
||||||
dbp.CheckAndClearManualStopRequest()
|
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 {
|
for {
|
||||||
if dbp.CheckAndClearManualStopRequest() {
|
if dbp.CheckAndClearManualStopRequest() {
|
||||||
|
dbp.ClearInternalBreakpoints()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
trapthread, err := dbp.ContinueOnce()
|
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
|
return nil
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
|
fmt.Printf("\tbreakpoint hit during %s, continuing...\n", op)
|
||||||
stateChan := t.client.Continue()
|
stateChan := t.client.Continue()
|
||||||
var state *api.DebuggerState
|
var state *api.DebuggerState
|
||||||
for state = range stateChan {
|
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)
|
printfile(t, state.CurrentThread.File, state.CurrentThread.Line, true)
|
||||||
return nil
|
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)
|
signal.Notify(ch, syscall.SIGINT)
|
||||||
go func() {
|
go func() {
|
||||||
for range ch {
|
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()
|
_, err := t.client.Halt()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "%v", err)
|
fmt.Fprintf(os.Stderr, "%v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user