From: qmuntal Date: Thu, 23 Feb 2023 13:15:28 +0000 (+0100) Subject: runtime: set procid on Windows X-Git-Tag: go1.21rc1~1452 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=140000dd55d9c4e3058f2b1a2488233a0671dbff;p=gostls13.git runtime: set procid on Windows The runtime-gdb.py script needs procid to be set in order to map a goroutine ID with an OS thread. The Go runtime is not currently setting that variable on Windows, so TestGdbPython (and friends) can't succeed. This CL initializes procid and unskips gdb tests on Windows. Fixes #22687 Updates #21380 Updates #22021 Change-Id: Icd1d9fc1764669ed1bf04f53d17fadfd24ac3f30 Reviewed-on: https://go-review.googlesource.com/c/go/+/470596 Reviewed-by: Alex Brainman Reviewed-by: Dmitri Shuralyov TryBot-Result: Gopher Robot Reviewed-by: Bryan Mills Run-TryBot: Quim Muntal --- diff --git a/src/runtime/os_windows.go b/src/runtime/os_windows.go index 62be6350bd..62509df030 100644 --- a/src/runtime/os_windows.go +++ b/src/runtime/os_windows.go @@ -28,6 +28,7 @@ const ( //go:cgo_import_dynamic runtime._ExitProcess ExitProcess%1 "kernel32.dll" //go:cgo_import_dynamic runtime._FreeEnvironmentStringsW FreeEnvironmentStringsW%1 "kernel32.dll" //go:cgo_import_dynamic runtime._GetConsoleMode GetConsoleMode%2 "kernel32.dll" +//go:cgo_import_dynamic runtime._GetCurrentThreadId GetCurrentThreadId%0 "kernel32.dll" //go:cgo_import_dynamic runtime._GetEnvironmentStringsW GetEnvironmentStringsW%0 "kernel32.dll" //go:cgo_import_dynamic runtime._GetProcAddress GetProcAddress%2 "kernel32.dll" //go:cgo_import_dynamic runtime._GetProcessAffinityMask GetProcessAffinityMask%3 "kernel32.dll" @@ -78,6 +79,7 @@ var ( _ExitProcess, _FreeEnvironmentStringsW, _GetConsoleMode, + _GetCurrentThreadId, _GetEnvironmentStringsW, _GetProcAddress, _GetProcessAffinityMask, @@ -957,6 +959,7 @@ func minit() { mp := getg().m lock(&mp.threadLock) mp.thread = thandle + mp.procid = uint64(stdcall0(_GetCurrentThreadId)) // Configure usleep timer, if possible. if mp.highResTimer == 0 && haveHighResTimer { diff --git a/src/runtime/runtime-gdb_test.go b/src/runtime/runtime-gdb_test.go index a45654d085..5af3b7455e 100644 --- a/src/runtime/runtime-gdb_test.go +++ b/src/runtime/runtime-gdb_test.go @@ -34,8 +34,6 @@ func checkGdbEnvironment(t *testing.T) { t.Skip("gdb does not work on darwin") case "netbsd": t.Skip("gdb does not work with threads on NetBSD; see https://golang.org/issue/22893 and https://gnats.netbsd.org/52548") - case "windows": - t.Skip("gdb tests fail on Windows: https://golang.org/issue/22687") case "linux": if runtime.GOARCH == "ppc64" { t.Skip("skipping gdb tests on linux/ppc64; see https://golang.org/issue/17366")