Collect errors from defer in proc.next
This commit is contained in:
parent
cf105863a7
commit
a0cffab881
38
proc/proc.go
38
proc/proc.go
@ -253,15 +253,30 @@ func (dbp *Process) Next() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (dbp *Process) next() (err error) {
|
func (dbp *Process) next() (err error) {
|
||||||
// Make sure we clean up the temp breakpoints created by thread.Next
|
defer func() {
|
||||||
defer dbp.clearTempBreakpoints()
|
// Always halt process at end of this function.
|
||||||
|
herr := dbp.Halt()
|
||||||
|
// Make sure we clean up the temp breakpoints.
|
||||||
|
cerr := dbp.clearTempBreakpoints()
|
||||||
|
// If we already had an error, return it.
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if herr != nil {
|
||||||
|
err = herr
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if cerr != nil {
|
||||||
|
err = cerr
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
// Set breakpoints for any goroutine that is currently
|
// Set breakpoints for any goroutine that is currently
|
||||||
// blocked trying to read from a channel. This is so that
|
// blocked trying to read from a channel. This is so that
|
||||||
// if control flow switches to that goroutine, we end up
|
// if control flow switches to that goroutine, we end up
|
||||||
// somewhere useful instead of in runtime code.
|
// somewhere useful instead of in runtime code.
|
||||||
if _, err := dbp.setChanRecvBreakpoints(); err != nil {
|
if _, err = dbp.setChanRecvBreakpoints(); err != nil {
|
||||||
return err
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the goroutine for the current thread. We will
|
// Get the goroutine for the current thread. We will
|
||||||
@ -272,11 +287,6 @@ func (dbp *Process) next() (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure that we halt the process at the end of this
|
|
||||||
// function. We could get into a situation where we have
|
|
||||||
// started some, but not all threads.
|
|
||||||
defer func() { err = dbp.Halt() }()
|
|
||||||
|
|
||||||
var goroutineExiting bool
|
var goroutineExiting bool
|
||||||
if err = dbp.CurrentThread.setNextBreakpoints(); err != nil {
|
if err = dbp.CurrentThread.setNextBreakpoints(); err != nil {
|
||||||
switch t := err.(type) {
|
switch t := err.(type) {
|
||||||
@ -284,13 +294,13 @@ func (dbp *Process) next() (err error) {
|
|||||||
case GoroutineExitingError:
|
case GoroutineExitingError:
|
||||||
goroutineExiting = t.goid == g.Id
|
goroutineExiting = t.goid == g.Id
|
||||||
default:
|
default:
|
||||||
return err
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, th := range dbp.Threads {
|
for _, th := range dbp.Threads {
|
||||||
if err := th.Continue(); err != nil {
|
if err = th.Continue(); err != nil {
|
||||||
return err
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +318,7 @@ func (dbp *Process) next() (err error) {
|
|||||||
// Check to see if the goroutine has switched to another
|
// Check to see if the goroutine has switched to another
|
||||||
// thread, if so make it the current thread.
|
// thread, if so make it the current thread.
|
||||||
if dbp.CurrentThread.Id != th.Id {
|
if dbp.CurrentThread.Id != th.Id {
|
||||||
if err := dbp.SwitchThread(th.Id); err != nil {
|
if err = dbp.SwitchThread(th.Id); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -317,7 +327,7 @@ func (dbp *Process) next() (err error) {
|
|||||||
// This thread was not running our goroutine.
|
// This thread was not running our goroutine.
|
||||||
// We continue it since our goroutine could
|
// We continue it since our goroutine could
|
||||||
// potentially be on this threads queue.
|
// potentially be on this threads queue.
|
||||||
if err := th.Continue(); err != nil {
|
if err = th.Continue(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user