]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: set procid on Windows
authorqmuntal <quimmuntal@gmail.com>
Thu, 23 Feb 2023 13:15:28 +0000 (14:15 +0100)
committerQuim Muntal <quimmuntal@gmail.com>
Mon, 27 Feb 2023 20:53:17 +0000 (20:53 +0000)
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 <alex.brainman@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>

src/runtime/os_windows.go
src/runtime/runtime-gdb_test.go

index 62be6350bddf52489d4b195a1d29dfc0da4c5a93..62509df03081717b05fde13bfe212d0fb139debf 100644 (file)
@@ -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 {
index a45654d085fde496273eb337ff190239c4d0a9f3..5af3b7455e1baacbbd3ce3e419ec15e07ba327a6 100644 (file)
@@ -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")