service/dap: support running requests asynchronously (#2423)

* service/dap: refine teardown logic

* Address review comments + add missing lock/unlock

* Narrow lock scope

* Update comments only

* Remove redundan temp var from stopNoDebugProcess

* Clarify comment

* service/dap: support running requests asynchronously

* Respond to review comments

* Remove debugging printf

* Refine locking. Add call TODO. Use -1 for running thread id.

* Fix TestAttachStopOnEntry: it can terminate on halt

* Respond to review comments

* Recover panics in async requests handling

* defer releasing asyncSetupDone, so it happens on panic

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
This commit is contained in:
polinasok
2021-05-04 12:49:52 -07:00
committed by GitHub
parent 0da1c9a9d7
commit 03f1ec1dfc
4 changed files with 391 additions and 164 deletions

View File

@ -549,7 +549,7 @@ func (d *Debugger) Restart(rerecord bool, pos string, resetArgs bool, newArgs []
// State returns the current state of the debugger.
func (d *Debugger) State(nowait bool) (*api.DebuggerState, error) {
if d.isRunning() && nowait {
if d.IsRunning() && nowait {
return &api.DebuggerState{Running: true}, nil
}
@ -973,7 +973,7 @@ func (d *Debugger) setRunning(running bool) {
d.runningMutex.Unlock()
}
func (d *Debugger) isRunning() bool {
func (d *Debugger) IsRunning() bool {
d.runningMutex.Lock()
defer d.runningMutex.Unlock()
return d.running
@ -1711,7 +1711,7 @@ func (d *Debugger) GetVersion(out *api.GetVersionOut) error {
}
}
if !d.isRecording() && !d.isRunning() {
if !d.isRecording() && !d.IsRunning() {
out.TargetGoVersion = d.target.BinInfo().Producer()
}