Improve handling of process natural death (OS X)

This commit is contained in:
Derek Parker
2015-03-21 17:31:53 -05:00
parent 6b3d724fdc
commit 684dc92ccd
4 changed files with 63 additions and 35 deletions

View File

@ -35,6 +35,7 @@ type DebuggedProcess struct {
breakpointIDCounter int
running bool
halt bool
exited bool
}
// A ManualStopError happens when the user triggers a
@ -87,6 +88,12 @@ func Launch(cmd []string) (*DebuggedProcess, error) {
return newDebugProcess(proc.Process.Pid, false)
}
// Returns whether or not Delve thinks the debugged
// process has exited.
func (dbp *DebuggedProcess) Exited() bool {
return dbp.exited
}
// Returns whether or not Delve thinks the debugged
// process is currently executing.
func (dbp *DebuggedProcess) Running() bool {
@ -242,6 +249,7 @@ func (dbp *DebuggedProcess) Continue() error {
if err != nil {
return err
}
thread, ok := dbp.Threads[wpid]
if !ok {
return fmt.Errorf("could not find thread for %d", wpid)
@ -380,6 +388,9 @@ func newDebugProcess(pid int, attach bool) (*DebuggedProcess, error) {
}
func (dbp *DebuggedProcess) run(fn func() error) error {
if dbp.exited {
return fmt.Errorf("process has already exited")
}
dbp.running = true
dbp.halt = false
defer func() { dbp.running = false }()