]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/trace: Fix TestTraceSymbolize on solaris and illumos
authorFelix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Sun, 2 Apr 2023 00:19:37 +0000 (20:19 -0400)
committerMichael Knyszek <mknyszek@google.com>
Tue, 4 Apr 2023 20:44:45 +0000 (20:44 +0000)
Fix a regression caused by CL 463835. Unlike most platforms, solaris and
illumos don't use a libc_read_trampoline, so we need to skip one frame
less when using frame pointer unwinding in traceGoSysCall.

The solution is a bit hacky, so it might make sense to implement
gp.syscallbp if this causes more test failures in the future.

Fixes #59350

Change-Id: I0f0b08f36efe8a492eb4a535e752c03636857057
Reviewed-on: https://go-review.googlesource.com/c/go/+/481336
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/runtime/trace.go

index 81093cc9b9c9df48436c444bd15e0814f831204e..d174ee2e4a4eaba04dc8e25f59671147572e5298 100644 (file)
@@ -1553,16 +1553,23 @@ func traceGoUnpark(gp *g, skip int) {
 }
 
 func traceGoSysCall() {
-       if tracefpunwindoff() {
-               traceEvent(traceEvGoSysCall, 1)
-       } else {
-               // The default unwinder starts unwinding from gp.syscallsp
-               // which is captured 3 frames above this frame. We could
-               // capture gp.syscallbp to allow frame pointer unwinding to
-               // behave the same, but skipping 3 more frames here is
-               // simpler.
-               traceEvent(traceEvGoSysCall, 4)
-       }
+       var skip int
+       switch {
+       case tracefpunwindoff():
+               // Unwind by skipping 1 frame relative to gp.syscallsp which is captured 3
+               // frames above this frame. For frame pointer unwinding we produce the same
+               // results by hard coding the number of frames in between our caller and the
+               // actual syscall, see cases below.
+               // TODO(felixge): Implement gp.syscallbp to avoid this workaround?
+               skip = 1
+       case GOOS == "solaris" || GOOS == "illumos":
+               // These platforms don't use a libc_read_trampoline.
+               skip = 3
+       default:
+               // Skip the extra trampoline frame used on most systems.
+               skip = 4
+       }
+       traceEvent(traceEvGoSysCall, skip)
 }
 
 func traceGoSysExit(ts int64) {