mirror of
https://github.com/golang/go
synced 2024-11-18 15:44:41 -07:00
runtime: introduce CPU access functions on windows
This CL introduces new methods for 'context' type, so we can manipulate its values in an architecture independent way. Use new methods to replace both 386 and amd64 versions of dosigprof with single piece of code. There is more similar code to be converted in the following CLs. Also remove os_windows_386.go and os_windows_amd64.go. These contain unused functions. Change-Id: I28f76aeb97f6e4249843d30d3d0c33fb233d3f7f Reviewed-on: https://go-review.googlesource.com/2790 Reviewed-by: Minux Ma <minux@golang.org>
This commit is contained in:
parent
1e5d8bb544
commit
5c4a86d0d0
@ -101,6 +101,12 @@ type context struct {
|
||||
extendedregisters [512]uint8
|
||||
}
|
||||
|
||||
func (c *context) ip() uintptr { return uintptr(c.eip) }
|
||||
func (c *context) sp() uintptr { return uintptr(c.esp) }
|
||||
|
||||
func (c *context) setip(x uintptr) { c.eip = uint32(x) }
|
||||
func (c *context) setsp(x uintptr) { c.esp = uint32(x) }
|
||||
|
||||
type overlapped struct {
|
||||
internal uint32
|
||||
internalhigh uint32
|
||||
|
@ -116,6 +116,12 @@ type context struct {
|
||||
lastexceptionfromrip uint64
|
||||
}
|
||||
|
||||
func (c *context) ip() uintptr { return uintptr(c.rip) }
|
||||
func (c *context) sp() uintptr { return uintptr(c.rsp) }
|
||||
|
||||
func (c *context) setip(x uintptr) { c.rip = uint64(x) }
|
||||
func (c *context) setsp(x uintptr) { c.rsp = uint64(x) }
|
||||
|
||||
type overlapped struct {
|
||||
internal uint64
|
||||
internalhigh uint64
|
||||
|
@ -506,7 +506,7 @@ func profilem(mp *m) {
|
||||
r = (*context)(unsafe.Pointer((uintptr(unsafe.Pointer(&rbuf[15]))) &^ 15))
|
||||
r.contextflags = _CONTEXT_CONTROL
|
||||
stdcall2(_GetThreadContext, mp.thread, uintptr(unsafe.Pointer(r)))
|
||||
dosigprof(r, gp, mp)
|
||||
sigprof((*byte)(unsafe.Pointer(r.ip())), (*byte)(unsafe.Pointer(r.sp())), nil, gp, mp)
|
||||
}
|
||||
|
||||
func profileloop1() {
|
||||
|
@ -118,7 +118,3 @@ func sigenable(sig uint32) {
|
||||
|
||||
func sigdisable(sig uint32) {
|
||||
}
|
||||
|
||||
func dosigprof(r *context, gp *g, mp *m) {
|
||||
sigprof((*byte)(unsafe.Pointer(uintptr(r.eip))), (*byte)(unsafe.Pointer(uintptr(r.esp))), nil, gp, mp)
|
||||
}
|
||||
|
@ -137,7 +137,3 @@ func sigenable(sig uint32) {
|
||||
|
||||
func sigdisable(sig uint32) {
|
||||
}
|
||||
|
||||
func dosigprof(r *context, gp *g, mp *m) {
|
||||
sigprof((*byte)(unsafe.Pointer(uintptr(r.rip))), (*byte)(unsafe.Pointer(uintptr(r.rsp))), nil, gp, mp)
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
// 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.
|
||||
|
||||
package runtime
|
||||
|
||||
// contextPC returns the EIP (program counter) register from the context.
|
||||
func contextPC(r *context) uintptr { return uintptr(r.eip) }
|
||||
|
||||
// contextSP returns the ESP (stack pointer) register from the context.
|
||||
func contextSP(r *context) uintptr { return uintptr(r.esp) }
|
@ -1,11 +0,0 @@
|
||||
// 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.
|
||||
|
||||
package runtime
|
||||
|
||||
// contextPC returns the RIP (program counter) register from the context.
|
||||
func contextPC(r *context) uintptr { return uintptr(r.rip) }
|
||||
|
||||
// contextSP returns the RSP (stack pointer) register from the context.
|
||||
func contextSP(r *context) uintptr { return uintptr(r.rsp) }
|
Loading…
Reference in New Issue
Block a user