diff options
author | Michael Pratt <mpratt@google.com> | 2021-10-26 16:18:52 -0400 |
---|---|---|
committer | Michael Pratt <mpratt@google.com> | 2021-10-28 18:10:50 +0000 |
commit | 2bc8ed8e9c5d8ae303b42bbd8c65f2c5dc38352a (patch) | |
tree | 34cdab33d2fccd7c4b27d6f9a40b6dee29953098 /src/runtime/proc.go | |
parent | 266626211e40d1f2c3a34fa4cd2023f5310cbd7d (diff) | |
download | go-2bc8ed8e9c5d8ae303b42bbd8c65f2c5dc38352a.tar.gz go-2bc8ed8e9c5d8ae303b42bbd8c65f2c5dc38352a.zip |
runtime: normalize sigprof traceback flags
Each gentraceback call uses a different set of flags. Combine these into
a common variable, only adjusted as necessary.
The effective changes here are:
* cgo traceback now has _TraceJumpStack. This is a no-op since it
already passes curg.
* libcall traceback now has _TraceJumpStack. This is a behavior change
and will allow following stack transitions if a libcall is performed on
g0.
* VDSO traceback drops _TraceTrap. vdsoPC is a return address, so
_TraceTrap was not necessary.
Change-Id: I351b3cb8dc77df7466795d5fbf2bd8f30bba2d37
Reviewed-on: https://go-review.googlesource.com/c/go/+/358900
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/runtime/proc.go')
-rw-r--r-- | src/runtime/proc.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 990637e21a..bd7dacd440 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -4645,6 +4645,7 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) { getg().m.mallocing++ var stk [maxCPUProfStack]uintptr + flags := uint(_TraceJumpStack) n := 0 if mp.ncgo > 0 && mp.curg != nil && mp.curg.syscallpc != 0 && mp.curg.syscallsp != 0 { cgoOff := 0 @@ -4662,12 +4663,12 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) { } // Collect Go stack that leads to the cgo call. - n = gentraceback(mp.curg.syscallpc, mp.curg.syscallsp, 0, mp.curg, 0, &stk[cgoOff], len(stk)-cgoOff, nil, nil, 0) + n = gentraceback(mp.curg.syscallpc, mp.curg.syscallsp, 0, mp.curg, 0, &stk[cgoOff], len(stk)-cgoOff, nil, nil, flags) if n > 0 { n += cgoOff } } else { - n = gentraceback(pc, sp, lr, gp, 0, &stk[0], len(stk), nil, nil, _TraceTrap|_TraceJumpStack) + n = gentraceback(pc, sp, lr, gp, 0, &stk[0], len(stk), nil, nil, _TraceTrap|flags) } if n <= 0 { @@ -4677,10 +4678,10 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) { if usesLibcall() && mp.libcallg != 0 && mp.libcallpc != 0 && mp.libcallsp != 0 { // Libcall, i.e. runtime syscall on windows. // Collect Go stack that leads to the call. - n = gentraceback(mp.libcallpc, mp.libcallsp, 0, mp.libcallg.ptr(), 0, &stk[0], len(stk), nil, nil, 0) + n = gentraceback(mp.libcallpc, mp.libcallsp, 0, mp.libcallg.ptr(), 0, &stk[0], len(stk), nil, nil, flags) } if n == 0 && mp != nil && mp.vdsoSP != 0 { - n = gentraceback(mp.vdsoPC, mp.vdsoSP, 0, gp, 0, &stk[0], len(stk), nil, nil, _TraceTrap|_TraceJumpStack) + n = gentraceback(mp.vdsoPC, mp.vdsoSP, 0, gp, 0, &stk[0], len(stk), nil, nil, flags) } if n == 0 { // If all of the above has failed, account it against abstract "System" or "GC". |