Ensure thread is stopped before setting breakpoint

For hardware breakpoints we have to set them on every thread. It could
be the case that another thread is running. Stop it first, set the
breakpoint, then continue it.
This commit is contained in:
Derek Parker
2015-06-24 09:29:16 -05:00
parent 7c8fd02685
commit b35a743a3c
5 changed files with 23 additions and 5 deletions

View File

@ -18,16 +18,18 @@ func (t *Thread) Halt() error {
}
err := sys.Tgkill(t.dbp.Pid, t.Id, sys.SIGSTOP)
if err != nil {
return fmt.Errorf("Halt err %s %d", err, t.Id)
return fmt.Errorf("halt err %s on thread %d", err, t.Id)
}
_, _, err = wait(t.Id, 0)
if err != nil {
return fmt.Errorf("wait err %s %d", err, t.Id)
return fmt.Errorf("wait err %s on thread %d", err, t.Id)
}
t.running = false
return nil
}
func (t *Thread) resume() (err error) {
t.running = true
t.dbp.execPtraceFunc(func() { err = PtraceCont(t.Id, 0) })
return
}