mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: unify sigtrampgo
Combine the various versions of sigtrampgo into a single function in signal_unix.go. This requires defining a fixsigcode method on sigctxt for all operating systems; it only does something on Darwin. This also requires changing the darwin/amd64 signal handler to call sigreturn itself, rather than relying on sigtrampgo to call sigreturn for it. We can then drop the Darwin sigreturn function, as it is no longer used. Change-Id: I5a0b9d2d2c141957e151b41e694efeb20e4b4b9a Reviewed-on: https://go-review.googlesource.com/29761 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
1906d93bfd
commit
c2735039f3
13 changed files with 78 additions and 204 deletions
|
|
@ -196,6 +196,54 @@ func sigpipe() {
|
|||
dieFromSignal(_SIGPIPE)
|
||||
}
|
||||
|
||||
// sigtrampgo is called from the signal handler function, sigtramp,
|
||||
// written in assembly code.
|
||||
// This is called by the signal handler, and the world may be stopped.
|
||||
//go:nosplit
|
||||
//go:nowritebarrierrec
|
||||
func sigtrampgo(sig uint32, info *siginfo, ctx unsafe.Pointer) {
|
||||
if sigfwdgo(sig, info, ctx) {
|
||||
return
|
||||
}
|
||||
g := getg()
|
||||
if g == nil {
|
||||
if sig == _SIGPROF {
|
||||
// Ignore profiling signals that arrive on
|
||||
// non-Go threads. On some systems they will
|
||||
// be handled directly by the signal handler,
|
||||
// by calling sigprofNonGo, in which case we won't
|
||||
// get here anyhow.
|
||||
return
|
||||
}
|
||||
badsignal(uintptr(sig), &sigctxt{info, ctx})
|
||||
return
|
||||
}
|
||||
|
||||
// If some non-Go code called sigaltstack, adjust.
|
||||
sp := uintptr(unsafe.Pointer(&sig))
|
||||
if sp < g.m.gsignal.stack.lo || sp >= g.m.gsignal.stack.hi {
|
||||
var st stackt
|
||||
sigaltstack(nil, &st)
|
||||
if st.ss_flags&_SS_DISABLE != 0 {
|
||||
setg(nil)
|
||||
cgocallback(unsafe.Pointer(funcPC(noSignalStack)), noescape(unsafe.Pointer(&sig)), unsafe.Sizeof(sig), 0)
|
||||
}
|
||||
stsp := uintptr(unsafe.Pointer(st.ss_sp))
|
||||
if sp < stsp || sp >= stsp+st.ss_size {
|
||||
setg(nil)
|
||||
cgocallback(unsafe.Pointer(funcPC(sigNotOnStack)), noescape(unsafe.Pointer(&sig)), unsafe.Sizeof(sig), 0)
|
||||
}
|
||||
setGsignalStack(&st)
|
||||
g.m.gsignal.stktopsp = getcallersp(unsafe.Pointer(&sig))
|
||||
}
|
||||
|
||||
setg(g.m.gsignal)
|
||||
c := &sigctxt{info, ctx}
|
||||
c.fixsigcode(sig)
|
||||
sighandler(sig, info, ctx, g)
|
||||
setg(g)
|
||||
}
|
||||
|
||||
// sigpanic turns a synchronous signal into a run-time panic.
|
||||
// If the signal handler sees a synchronous panic, it arranges the
|
||||
// stack to look like the function where the signal occurred called
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue