mirror of
https://github.com/golang/go
synced 2024-09-28 18:14:29 -06:00
runtime: print g pointer in crash stack dump
When debugging a runtime crash with a stack trace, sometimes we have the g pointer in some places (e.g. as an argument of a traceback function), but the g's goid in some other places (the stack trace of that goroutine), which are usually not easy to match up. This CL makes it print the g pointer. This is only printed in crash mode, so it doesn't change the usual user stack trace. Change-Id: I19140855bf020a327ab0619b665ec1d1c70cca8a Reviewed-on: https://go-review.googlesource.com/c/go/+/541996 Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
1ab9df4849
commit
3a9254636c
@ -199,7 +199,7 @@ func (u *unwinder) initAt(pc0, sp0, lr0 uintptr, gp *g, flags unwindFlags) {
|
||||
f := findfunc(frame.pc)
|
||||
if !f.valid() {
|
||||
if flags&unwindSilentErrors == 0 {
|
||||
print("runtime: g ", gp.goid, ": unknown pc ", hex(frame.pc), "\n")
|
||||
print("runtime: g ", gp.goid, " gp=", gp, ": unknown pc ", hex(frame.pc), "\n")
|
||||
tracebackHexdump(gp.stack, &frame, 0)
|
||||
}
|
||||
if flags&(unwindPrintErrors|unwindSilentErrors) == 0 {
|
||||
@ -1177,6 +1177,8 @@ var gStatusStrings = [...]string{
|
||||
}
|
||||
|
||||
func goroutineheader(gp *g) {
|
||||
level, _, _ := gotraceback()
|
||||
|
||||
gpstatus := readgstatus(gp)
|
||||
|
||||
isScan := gpstatus&_Gscan != 0
|
||||
@ -1200,7 +1202,16 @@ func goroutineheader(gp *g) {
|
||||
if (gpstatus == _Gwaiting || gpstatus == _Gsyscall) && gp.waitsince != 0 {
|
||||
waitfor = (nanotime() - gp.waitsince) / 60e9
|
||||
}
|
||||
print("goroutine ", gp.goid, " [", status)
|
||||
print("goroutine ", gp.goid)
|
||||
if gp.m != nil && gp.m.throwing >= throwTypeRuntime && gp == gp.m.curg || level >= 2 {
|
||||
print(" gp=", gp)
|
||||
if gp.m != nil {
|
||||
print(" m=", gp.m.id, " mp=", gp.m)
|
||||
} else {
|
||||
print(" m=nil")
|
||||
}
|
||||
}
|
||||
print(" [", status)
|
||||
if isScan {
|
||||
print(" (scan)")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user