diff --git a/proc/proc.go b/proc/proc.go index d63097df52810a13fca05a0ee097167dc23db69c..20809963beb7f935b9ee00384ac6baf43a866442 100644 --- a/proc/proc.go +++ b/proc/proc.go @@ -389,20 +389,8 @@ func (dbp *Process) runBreakpointConditions() error { // Resume process, does not evaluate breakpoint conditionals func (dbp *Process) continueOnce() error { - // all threads stopped over a breakpoint are made to step over it - for _, thread := range dbp.Threads { - if thread.CurrentBreakpoint != nil { - if err := thread.Step(); err != nil { - return err - } - thread.CurrentBreakpoint = nil - } - } - // everything is resumed - for _, thread := range dbp.Threads { - if err := thread.resume(); err != nil { - return dbp.exitGuard(err) - } + if err := dbp.resume(); err != nil { + return err } return dbp.run(func() error { thread, err := dbp.trapWait(-1) diff --git a/proc/proc_darwin.go b/proc/proc_darwin.go index 098b858a29ff394ab94dcdc3ce3ae324170bf126..478a956a0ee37dd54f701b7b73e2e23ae67ce7b3 100644 --- a/proc/proc_darwin.go +++ b/proc/proc_darwin.go @@ -354,3 +354,22 @@ func (dbp *Process) exitGuard(err error) error { } return err } + +func (dbp *Process) resume() error { + // all threads stopped over a breakpoint are made to step over it + for _, thread := range dbp.Threads { + if thread.CurrentBreakpoint != nil { + if err := thread.Step(); err != nil { + return err + } + thread.CurrentBreakpoint = nil + } + } + // everything is resumed + for _, thread := range dbp.Threads { + if err := thread.resume(); err != nil { + return dbp.exitGuard(err) + } + } + return nil +} diff --git a/proc/proc_linux.go b/proc/proc_linux.go index c90947b112b45584a0a24c94f167e7e19b6eb646..81454e2f03577ece64742186d2c5cca215833022 100644 --- a/proc/proc_linux.go +++ b/proc/proc_linux.go @@ -286,7 +286,9 @@ func (dbp *Process) trapWait(pid int) (*Thread, error) { return nil, fmt.Errorf("could not continue new thread %d %s", cloned, err) } if err = dbp.Threads[int(wpid)].Continue(); err != nil { - return nil, fmt.Errorf("could not continue existing thread %d %s", cloned, err) + if err != sys.ESRCH { + return nil, fmt.Errorf("could not continue existing thread %d %s", wpid, err) + } } continue } @@ -401,3 +403,22 @@ func (dbp *Process) exitGuard(err error) error { return err } + +func (dbp *Process) resume() error { + // all threads stopped over a breakpoint are made to step over it + for _, thread := range dbp.Threads { + if thread.CurrentBreakpoint != nil { + if err := thread.Step(); err != nil { + return err + } + thread.CurrentBreakpoint = nil + } + } + // everything is resumed + for _, thread := range dbp.Threads { + if err := thread.resume(); err != nil && err != sys.ESRCH { + return err + } + } + return nil +}