mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: fix TestSehUnwind
The various TestSehUnwind tests recently started to fail due an unrelated refactor (in CL 698098) that made the stack frames to not match the expected pattern. This CL updates the tests to be more robust to such changes. Fixes #75467 Change-Id: I7950332bb6ca54e4bf693d13e2490b3d9d901dde Reviewed-on: https://go-review.googlesource.com/c/go/+/703779 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
e3ed0fbe6a
commit
c39abe0658
1 changed files with 14 additions and 5 deletions
|
|
@ -65,14 +65,20 @@ func TestSehLookupFunctionEntry(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func sehCallers() []uintptr {
|
||||
// We don't need a real context,
|
||||
// RtlVirtualUnwind just needs a context with
|
||||
// valid a pc, sp and fp (aka bp).
|
||||
//go:noinline
|
||||
func newCtx() *windows.Context {
|
||||
var ctx windows.Context
|
||||
ctx.SetPC(sys.GetCallerPC())
|
||||
ctx.SetSP(sys.GetCallerSP())
|
||||
ctx.SetFP(runtime.GetCallerFp())
|
||||
return &ctx
|
||||
}
|
||||
|
||||
func sehCallers() []uintptr {
|
||||
// We don't need a real context,
|
||||
// RtlVirtualUnwind just needs a context with
|
||||
// valid a pc, sp and fp (aka bp).
|
||||
ctx := newCtx()
|
||||
|
||||
pcs := make([]uintptr, 15)
|
||||
var base, frame uintptr
|
||||
|
|
@ -84,7 +90,7 @@ func sehCallers() []uintptr {
|
|||
}
|
||||
pcs[i] = ctx.PC()
|
||||
n++
|
||||
windows.RtlVirtualUnwind(0, base, ctx.PC(), fn, unsafe.Pointer(&ctx), nil, &frame, nil)
|
||||
windows.RtlVirtualUnwind(0, base, ctx.PC(), fn, unsafe.Pointer(ctx), nil, &frame, nil)
|
||||
}
|
||||
return pcs[:n]
|
||||
}
|
||||
|
|
@ -120,6 +126,9 @@ func testSehCallersEqual(t *testing.T, pcs []uintptr, want []string) {
|
|||
// These functions are skipped as they appear inconsistently depending
|
||||
// whether inlining is on or off.
|
||||
continue
|
||||
case "runtime_test.sehCallers":
|
||||
// This is an artifact of the implementation of sehCallers.
|
||||
continue
|
||||
}
|
||||
got = append(got, name)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue