From 75e273fc2c183896a11bf23f0688c38059933336 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 27 Jan 2021 11:02:33 -0500 Subject: [PATCH] runtime: fix windows/arm CONTEXT_CONTROL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The constant was wrong, and the “right” constant doesn't work either. But with the actually-right constant (and possibly earlier fixes in this stack as well), profiling now works. Change-Id: If8caff1da556826db40961fb9bcfe2b1f31ea9f9 Reviewed-on: https://go-review.googlesource.com/c/go/+/288808 Trust: Russ Cox Trust: Jason A. Donenfeld Reviewed-by: Cherry Zhang Reviewed-by: Jason A. Donenfeld --- src/runtime/defs_windows_arm.go | 8 +++++++- src/runtime/pprof/pprof_test.go | 4 ---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/runtime/defs_windows_arm.go b/src/runtime/defs_windows_arm.go index 4021f77ba8c..370470e35d9 100644 --- a/src/runtime/defs_windows_arm.go +++ b/src/runtime/defs_windows_arm.go @@ -4,7 +4,13 @@ package runtime -const _CONTEXT_CONTROL = 0x10001 +// NOTE(rsc): _CONTEXT_CONTROL is actually 0x200001 and should include PC, SP, and LR. +// However, empirically, LR doesn't come along on Windows 10 +// unless you also set _CONTEXT_INTEGER (0x200002). +// Without LR, we skip over the next-to-bottom function in profiles +// when the bottom function is frameless. +// So we set both here, to make a working _CONTEXT_CONTROL. +const _CONTEXT_CONTROL = 0x200003 type neon128 struct { low uint64 diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go index 37f12de0d91..f7c1349bc68 100644 --- a/src/runtime/pprof/pprof_test.go +++ b/src/runtime/pprof/pprof_test.go @@ -285,10 +285,6 @@ func testCPUProfile(t *testing.T, matches matchFunc, need []string, avoid []stri if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" { broken = true } - case "windows": - if runtime.GOARCH == "arm" { - broken = true // See https://golang.org/issues/42862 - } } maxDuration := 5 * time.Second