mirror of
https://github.com/go-delve/delve.git
synced 2025-10-29 01:27:16 +08:00
command (next): Improvements for parallel programs
This patch aims to improve how Delve tracks the current goroutine, especially in very highly parallel programs. The main spirit of this patch is to ensure that even in situations where the goroutine we care about is not executing (common for len(g) > len(m)) we still end up back on that goroutine as a result of executing the 'next' command. We accomplish this by tracking our original goroutine id, and any time a breakpoint is hit or a threads stops, we examine the stopped threads and see if any are executing the goroutine we care about. If not, we set 'next' breakpoint for them again and continue them. This is done so that one of those threads can eventually pick up the goroutine we care about and begin executing it again.
This commit is contained in:
@ -67,7 +67,7 @@ func (dbp *Process) Kill() (err error) {
|
||||
if dbp.exited {
|
||||
return nil
|
||||
}
|
||||
if !stopped(dbp.Pid) {
|
||||
if !dbp.Threads[dbp.Pid].Stopped() {
|
||||
return errors.New("process must be stopped in order to kill it")
|
||||
}
|
||||
if err = sys.Kill(-dbp.Pid, sys.SIGKILL); err != nil {
|
||||
@ -322,14 +322,6 @@ func status(pid int) rune {
|
||||
return state
|
||||
}
|
||||
|
||||
func stopped(pid int) bool {
|
||||
state := status(pid)
|
||||
if state == STATUS_TRACE_STOP {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func wait(pid, tgid, options int) (int, *sys.WaitStatus, error) {
|
||||
var s sys.WaitStatus
|
||||
if (pid != tgid) || (options != 0) {
|
||||
|
||||
Reference in New Issue
Block a user