aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/proc.c
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2014-06-26 11:40:48 -0700
committerDmitriy Vyukov <dvyukov@google.com>2014-06-26 11:40:48 -0700
commit07f6f313a90b264377f8a9ecc4fadfe13bfff633 (patch)
treebff77d5d2d66764e88c2a0102f7899296a4c1179 /src/pkg/runtime/proc.c
parent9e04ff79531201b43d1cc708e0308664fbbd8ef5 (diff)
downloadgo-07f6f313a90b264377f8a9ecc4fadfe13bfff633.tar.xz
runtime: say when a goroutine is locked to OS thread
Say when a goroutine is locked to OS thread in crash reports and goroutine profiles. It can be useful to understand what goroutines consume OS threads (syscall and locked), e.g. if you forget to call UnlockOSThread or leak locked goroutines. R=golang-codereviews CC=golang-codereviews, rsc https://golang.org/cl/94170043
Diffstat (limited to 'src/pkg/runtime/proc.c')
-rw-r--r--src/pkg/runtime/proc.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c
index 7467e9fa16..dd98e8ce26 100644
--- a/src/pkg/runtime/proc.c
+++ b/src/pkg/runtime/proc.c
@@ -297,10 +297,12 @@ runtime·goroutineheader(G *gp)
if((gp->status == Gwaiting || gp->status == Gsyscall) && gp->waitsince != 0)
waitfor = (runtime·nanotime() - gp->waitsince) / (60LL*1000*1000*1000);
- if(waitfor < 1)
- runtime·printf("goroutine %D [%s]:\n", gp->goid, status);
- else
- runtime·printf("goroutine %D [%s, %D minutes]:\n", gp->goid, status, waitfor);
+ runtime·printf("goroutine %D [%s", gp->goid, status);
+ if(waitfor >= 1)
+ runtime·printf(", %D minutes", waitfor);
+ if(gp->lockedm != nil)
+ runtime·printf(", locked to thread");
+ runtime·printf("]:\n");
}
void