Skip to content

Commit 140000d

Browse files
committed
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 <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Run-TryBot: Quim Muntal <[email protected]>
1 parent b611b3a commit 140000d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/runtime/os_windows.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const (
2828
//go:cgo_import_dynamic runtime._ExitProcess ExitProcess%1 "kernel32.dll"
2929
//go:cgo_import_dynamic runtime._FreeEnvironmentStringsW FreeEnvironmentStringsW%1 "kernel32.dll"
3030
//go:cgo_import_dynamic runtime._GetConsoleMode GetConsoleMode%2 "kernel32.dll"
31+
//go:cgo_import_dynamic runtime._GetCurrentThreadId GetCurrentThreadId%0 "kernel32.dll"
3132
//go:cgo_import_dynamic runtime._GetEnvironmentStringsW GetEnvironmentStringsW%0 "kernel32.dll"
3233
//go:cgo_import_dynamic runtime._GetProcAddress GetProcAddress%2 "kernel32.dll"
3334
//go:cgo_import_dynamic runtime._GetProcessAffinityMask GetProcessAffinityMask%3 "kernel32.dll"
@@ -78,6 +79,7 @@ var (
7879
_ExitProcess,
7980
_FreeEnvironmentStringsW,
8081
_GetConsoleMode,
82+
_GetCurrentThreadId,
8183
_GetEnvironmentStringsW,
8284
_GetProcAddress,
8385
_GetProcessAffinityMask,
@@ -957,6 +959,7 @@ func minit() {
957959
mp := getg().m
958960
lock(&mp.threadLock)
959961
mp.thread = thandle
962+
mp.procid = uint64(stdcall0(_GetCurrentThreadId))
960963

961964
// Configure usleep timer, if possible.
962965
if mp.highResTimer == 0 && haveHighResTimer {

src/runtime/runtime-gdb_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ func checkGdbEnvironment(t *testing.T) {
3434
t.Skip("gdb does not work on darwin")
3535
case "netbsd":
3636
t.Skip("gdb does not work with threads on NetBSD; see https://golang.org/issue/22893 and https://gnats.netbsd.org/52548")
37-
case "windows":
38-
t.Skip("gdb tests fail on Windows: https://golang.org/issue/22687")
3937
case "linux":
4038
if runtime.GOARCH == "ppc64" {
4139
t.Skip("skipping gdb tests on linux/ppc64; see https://golang.org/issue/17366")

0 commit comments

Comments
 (0)