Skip to content

Commit 2bc8ed8

Browse files
committed
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 <[email protected]> Run-TryBot: Michael Pratt <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
1 parent 2666262 commit 2bc8ed8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/runtime/proc.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -4645,6 +4645,7 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) {
46454645
getg().m.mallocing++
46464646

46474647
var stk [maxCPUProfStack]uintptr
4648+
flags := uint(_TraceJumpStack)
46484649
n := 0
46494650
if mp.ncgo > 0 && mp.curg != nil && mp.curg.syscallpc != 0 && mp.curg.syscallsp != 0 {
46504651
cgoOff := 0
@@ -4662,12 +4663,12 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) {
46624663
}
46634664

46644665
// Collect Go stack that leads to the cgo call.
4665-
n = gentraceback(mp.curg.syscallpc, mp.curg.syscallsp, 0, mp.curg, 0, &stk[cgoOff], len(stk)-cgoOff, nil, nil, 0)
4666+
n = gentraceback(mp.curg.syscallpc, mp.curg.syscallsp, 0, mp.curg, 0, &stk[cgoOff], len(stk)-cgoOff, nil, nil, flags)
46664667
if n > 0 {
46674668
n += cgoOff
46684669
}
46694670
} else {
4670-
n = gentraceback(pc, sp, lr, gp, 0, &stk[0], len(stk), nil, nil, _TraceTrap|_TraceJumpStack)
4671+
n = gentraceback(pc, sp, lr, gp, 0, &stk[0], len(stk), nil, nil, _TraceTrap|flags)
46714672
}
46724673

46734674
if n <= 0 {
@@ -4677,10 +4678,10 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) {
46774678
if usesLibcall() && mp.libcallg != 0 && mp.libcallpc != 0 && mp.libcallsp != 0 {
46784679
// Libcall, i.e. runtime syscall on windows.
46794680
// Collect Go stack that leads to the call.
4680-
n = gentraceback(mp.libcallpc, mp.libcallsp, 0, mp.libcallg.ptr(), 0, &stk[0], len(stk), nil, nil, 0)
4681+
n = gentraceback(mp.libcallpc, mp.libcallsp, 0, mp.libcallg.ptr(), 0, &stk[0], len(stk), nil, nil, flags)
46814682
}
46824683
if n == 0 && mp != nil && mp.vdsoSP != 0 {
4683-
n = gentraceback(mp.vdsoPC, mp.vdsoSP, 0, gp, 0, &stk[0], len(stk), nil, nil, _TraceTrap|_TraceJumpStack)
4684+
n = gentraceback(mp.vdsoPC, mp.vdsoSP, 0, gp, 0, &stk[0], len(stk), nil, nil, flags)
46844685
}
46854686
if n == 0 {
46864687
// If all of the above has failed, account it against abstract "System" or "GC".

0 commit comments

Comments
 (0)