]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: don't track stack separately in gentraceback
authorAustin Clements <austin@google.com>
Tue, 12 Jul 2022 20:42:06 +0000 (16:42 -0400)
committerAustin Clements <austin@google.com>
Fri, 10 Mar 2023 17:18:22 +0000 (17:18 +0000)
Currently, gentraceback keeps a copy of the stack bounds of the stack
it's walking in the "stack" variable. Now that "gp" always refers to
the G whose stack it's walking, we can simply use gp.stack instead of
keeping a separate copy.

For #54466.

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

src/runtime/traceback.go

index 677350990190a9c09c6305c6c229bbe70ab32e1e..507f36603703b160f261f0c3c52fbd1f25e2a94e 100644 (file)
@@ -78,7 +78,6 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
        }
        waspanic := false
        cgoCtxt := gp.cgoCtxt
-       stack := gp.stack
        printing := pcbuf == nil && callback == nil
 
        // If the PC is zero, it's likely a nil function call.
@@ -111,7 +110,7 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
        if !f.valid() {
                if callback != nil || printing {
                        print("runtime: g ", gp.goid, ": unknown pc ", hex(frame.pc), "\n")
-                       tracebackHexdump(stack, &frame, 0)
+                       tracebackHexdump(gp.stack, &frame, 0)
                }
                if callback != nil {
                        throw("unknown pc")
@@ -177,7 +176,6 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
                                        flag = f.flag
                                        frame.lr = gp.sched.lr
                                        frame.sp = gp.sched.sp
-                                       stack = gp.stack
                                        cgoCtxt = gp.cgoCtxt
                                case funcID_systemstack:
                                        // systemstack returns normally, so just follow the
@@ -195,7 +193,6 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
                                        }
                                        gp = gp.m.curg
                                        frame.sp = gp.sched.sp
-                                       stack = gp.stack
                                        cgoCtxt = gp.cgoCtxt
                                        flag &^= funcFlag_SPWRITE
                                }
@@ -264,7 +261,7 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
                                }
                                if callback != nil || doPrint {
                                        print("runtime: g ", gp.goid, ": unexpected return pc for ", funcname(f), " called from ", hex(frame.lr), "\n")
-                                       tracebackHexdump(stack, &frame, lrPtr)
+                                       tracebackHexdump(gp.stack, &frame, lrPtr)
                                }
                                if callback != nil {
                                        throw("unknown caller pc")
@@ -483,7 +480,7 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
                if frame.pc == frame.lr && frame.sp == frame.fp {
                        // If the next frame is identical to the current frame, we cannot make progress.
                        print("runtime: traceback stuck. pc=", hex(frame.pc), " sp=", hex(frame.sp), "\n")
-                       tracebackHexdump(stack, &frame, frame.sp)
+                       tracebackHexdump(gp.stack, &frame, frame.sp)
                        throw("traceback stuck")
                }