]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: print goid when throwing in gentraceback
authorMichael Pratt <mpratt@google.com>
Fri, 4 Mar 2022 16:17:43 +0000 (11:17 -0500)
committerMichael Pratt <mpratt@google.com>
Mon, 7 Mar 2022 16:24:54 +0000 (16:24 +0000)
This makes it easier to figure out where the crash is occurring.

Change-Id: Ie1f78a360367090dcd61c61b2a55c34f3e2ff2eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/390034
Trust: David Chase <drchase@google.com>
Reviewed-by: David Chase <drchase@google.com>
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/runtime/crash_test.go
src/runtime/traceback.go

index 9b9ab4f3e1b0e97710b08e0495dad1e9bb492f88..d8cabcdda28080b09f4f80ae47ed2ec3138eb6e3 100644 (file)
@@ -665,7 +665,7 @@ retry:
 func TestBadTraceback(t *testing.T) {
        output := runTestProg(t, "testprog", "BadTraceback")
        for _, want := range []string{
-               "runtime: unexpected return pc",
+               "unexpected return pc",
                "called from 0xbad",
                "00000bad",    // Smashed LR in hex dump
                "<main.badLR", // Symbolization in hex dump (badLR1 or badLR2)
index 0cdd53cc936f257c561eab0211d494735636b025..23bce2bf34eca2b8f7b05854cd3f65d377718a33 100644 (file)
@@ -113,7 +113,7 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
        f := findfunc(frame.pc)
        if !f.valid() {
                if callback != nil || printing {
-                       print("runtime: unknown pc ", hex(frame.pc), "\n")
+                       print("runtime: g ", gp.goid, ": unknown pc ", hex(frame.pc), "\n")
                        tracebackHexdump(gp.stack, &frame, 0)
                }
                if callback != nil {
@@ -247,7 +247,7 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
                                        doPrint = false
                                }
                                if callback != nil || doPrint {
-                                       print("runtime: unexpected return pc for ", funcname(f), " called from ", hex(frame.lr), "\n")
+                                       print("runtime: g ", gp.goid, ": unexpected return pc for ", funcname(f), " called from ", hex(frame.lr), "\n")
                                        tracebackHexdump(gp.stack, &frame, lrPtr)
                                }
                                if callback != nil {