From 3a700e7a155b5806105b02bb9c5b99ad310a0439 Mon Sep 17 00:00:00 2001 From: aarzilli Date: Fri, 10 Jan 2020 14:23:55 +0100 Subject: [PATCH] proc/native: partial support for Windows async preempt mechanism See https://github.com/golang/go/issues/36494 for a description of why full support for 1.14 under windows is problematic. --- pkg/proc/native/threads_windows.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/pkg/proc/native/threads_windows.go b/pkg/proc/native/threads_windows.go index 899962ba50..4fa67ca4c2 100644 --- a/pkg/proc/native/threads_windows.go +++ b/pkg/proc/native/threads_windows.go @@ -36,9 +36,17 @@ func (t *Thread) singleStep() error { return err } - _, err = _ResumeThread(t.os.hThread) - if err != nil { - return err + suspendcnt := 0 + + for { + n, err := _ResumeThread(t.os.hThread) + if err != nil { + return err + } + suspendcnt++ + if n == 1 { + break + } } for { @@ -63,9 +71,11 @@ func (t *Thread) singleStep() error { }) } - _, err = _SuspendThread(t.os.hThread) - if err != nil { - return err + for i := 0; i < suspendcnt; i++ { + _, err = _SuspendThread(t.os.hThread) + if err != nil { + return err + } } t.dbp.execPtraceFunc(func() {