From 8d09f7c5178b04bade2859d32d0710233a620d4f Mon Sep 17 00:00:00 2001 From: Rhys Hiltner Date: Fri, 13 Aug 2021 09:01:13 -0700 Subject: runtime: use per-thread profiler for SetCgoTraceback platforms Updates #35057 Change-Id: I61d772a2cbfb27540fb70c14676c68593076ca94 Reviewed-on: https://go-review.googlesource.com/c/go/+/342054 Run-TryBot: Rhys Hiltner TryBot-Result: Go Bot Reviewed-by: Michael Pratt Trust: Michael Knyszek --- src/runtime/sys_linux_amd64.s | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/runtime/sys_linux_amd64.s') diff --git a/src/runtime/sys_linux_amd64.s b/src/runtime/sys_linux_amd64.s index 345dc90eb0..f0e58e11db 100644 --- a/src/runtime/sys_linux_amd64.s +++ b/src/runtime/sys_linux_amd64.s @@ -364,6 +364,23 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$0 POP_REGS_HOST_TO_ABI0() RET +// Called using C ABI. +TEXT runtime·sigprofNonGoWrapper<>(SB),NOSPLIT,$0 + // Transition from C ABI to Go ABI. + PUSH_REGS_HOST_TO_ABI0() + + // Call into the Go signal handler + NOP SP // disable vet stack checking + ADJSP $24 + MOVL DI, 0(SP) // sig + MOVQ SI, 8(SP) // info + MOVQ DX, 16(SP) // ctx + CALL ·sigprofNonGo(SB) + ADJSP $-24 + + POP_REGS_HOST_TO_ABI0() + RET + // Used instead of sigtramp in programs that use cgo. // Arguments from kernel are in DI, SI, DX. TEXT runtime·cgoSigtramp(SB),NOSPLIT,$0 @@ -431,12 +448,12 @@ sigtrampnog: JNZ sigtramp // Skip stack trace if already locked. // Jump to the traceback function in runtime/cgo. - // It will call back to sigprofNonGo, which will ignore the - // arguments passed in registers. + // It will call back to sigprofNonGo, via sigprofNonGoWrapper, to convert + // the arguments to the Go calling convention. // First three arguments to traceback function are in registers already. MOVQ runtime·cgoTraceback(SB), CX MOVQ $runtime·sigprofCallers(SB), R8 - MOVQ $runtime·sigprofNonGo(SB), R9 + MOVQ $runtime·sigprofNonGoWrapper<>(SB), R9 MOVQ _cgo_callers(SB), AX JMP AX -- cgit v1.3-5-g9baa