From 4121fb1f9644e1a18971ac9a46bfe7267993a9d3 Mon Sep 17 00:00:00 2001 From: aarzilli Date: Fri, 23 Jun 2017 15:52:46 +0200 Subject: [PATCH] proc/native,proc/gdbserial: set selectedGoroutine after StepInstruction When stepping through runtime sometimes the current goroutine will change. It is impossible to handle this in Next, Step and StepOut but StepInstruction can reset the current goroutine correctly. --- pkg/proc/gdbserial/gdbserver.go | 9 ++++++++- pkg/proc/native/proc.go | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/proc/gdbserial/gdbserver.go b/pkg/proc/gdbserial/gdbserver.go index b351f8fc..d376e233 100644 --- a/pkg/proc/gdbserial/gdbserver.go +++ b/pkg/proc/gdbserial/gdbserver.go @@ -642,7 +642,14 @@ func (p *Process) StepInstruction() error { if err != nil { return err } - return thread.SetCurrentBreakpoint() + err = thread.SetCurrentBreakpoint() + if err != nil { + return err + } + if g, _ := proc.GetG(thread); g != nil { + p.selectedGoroutine = g + } + return nil } func (p *Process) SwitchThread(tid int) error { diff --git a/pkg/proc/native/proc.go b/pkg/proc/native/proc.go index 9c319551..b9fa14a2 100644 --- a/pkg/proc/native/proc.go +++ b/pkg/proc/native/proc.go @@ -316,7 +316,14 @@ func (dbp *Process) StepInstruction() (err error) { if err != nil { return err } - return thread.SetCurrentBreakpoint() + err = thread.SetCurrentBreakpoint() + if err != nil { + return err + } + if g, _ := proc.GetG(thread); g != nil { + dbp.selectedGoroutine = g + } + return nil } // SwitchThread changes from current thread to the thread specified by `tid`. -- GitLab