mirror of
https://github.com/golang/go.git
synced 2025-05-29 03:11:26 +00:00
This CL fixes two problems: - NewContextStub initialize a context with the wrong FP. That function should dereference the FP returned by getcallerfp, as it returns the callers's FP instead of the caller's caller FP. CL 494857 will rename getcallerfp to getfp to make this fact clearer. - sehCallers skips the bottom frame when it should. Fixes #60053 Change-Id: I7d59b0175fc95281fcc7dd565ced9293064df3a1 Reviewed-on: https://go-review.googlesource.com/c/go/+/496140 Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
44 lines
903 B
Go
44 lines
903 B
Go
// Copyright 2014 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Export guts for testing.
|
|
|
|
package runtime
|
|
|
|
import "unsafe"
|
|
|
|
const MaxArgs = maxArgs
|
|
|
|
var (
|
|
OsYield = osyield
|
|
TimeBeginPeriodRetValue = &timeBeginPeriodRetValue
|
|
)
|
|
|
|
func NumberOfProcessors() int32 {
|
|
var info systeminfo
|
|
stdcall1(_GetSystemInfo, uintptr(unsafe.Pointer(&info)))
|
|
return int32(info.dwnumberofprocessors)
|
|
}
|
|
|
|
type ContextStub struct {
|
|
context
|
|
}
|
|
|
|
func (c ContextStub) GetPC() uintptr {
|
|
return c.ip()
|
|
}
|
|
|
|
func NewContextStub() *ContextStub {
|
|
var ctx context
|
|
ctx.set_ip(getcallerpc())
|
|
ctx.set_sp(getcallersp())
|
|
fp := getfp()
|
|
// getfp is not implemented on windows/386 and windows/arm,
|
|
// in which case it returns 0.
|
|
if fp != 0 {
|
|
ctx.set_fp(*(*uintptr)(unsafe.Pointer(fp)))
|
|
}
|
|
return &ContextStub{ctx}
|
|
}
|