]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: symbolize morestack caller in throwsplit panic
authorAustin Clements <austin@google.com>
Thu, 14 Dec 2017 20:32:12 +0000 (15:32 -0500)
committerAustin Clements <austin@google.com>
Fri, 15 Dec 2017 17:21:07 +0000 (17:21 +0000)
This attempts to symbolize the PC of morestack's caller when there's a
stack split at a bad time. The stack trace starts at the *caller* of
the function that attempted to grow the stack, so this is useful if it
isn't obvious what's being called at that point, such as in #21431.

Change-Id: I5dee305d87c8069611de2d14e7a3083d76264f8f
Reviewed-on: https://go-review.googlesource.com/84115
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/runtime/stack.go

index eb0716c18db0b90bfe89086f7c754669b50e7e56..6149838b6d62752f8c8264effed6ac613ff47f51 100644 (file)
@@ -938,7 +938,14 @@ func newstack() {
                morebuf := thisg.m.morebuf
                gp.syscallsp = morebuf.sp
                gp.syscallpc = morebuf.pc
-               print("runtime: newstack sp=", hex(gp.sched.sp), " stack=[", hex(gp.stack.lo), ", ", hex(gp.stack.hi), "]\n",
+               pcname, pcoff := "(unknown)", uintptr(0)
+               f := findfunc(gp.sched.pc)
+               if f.valid() {
+                       pcname = funcname(f)
+                       pcoff = gp.sched.pc - f.entry
+               }
+               print("runtime: newstack at ", pcname, "+", hex(pcoff),
+                       " sp=", hex(gp.sched.sp), " stack=[", hex(gp.stack.lo), ", ", hex(gp.stack.hi), "]\n",
                        "\tmorebuf={pc:", hex(morebuf.pc), " sp:", hex(morebuf.sp), " lr:", hex(morebuf.lr), "}\n",
                        "\tsched={pc:", hex(gp.sched.pc), " sp:", hex(gp.sched.sp), " lr:", hex(gp.sched.lr), " ctxt:", gp.sched.ctxt, "}\n")