]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix block profile for sync semaphores
authorDmitriy Vyukov <dvyukov@google.com>
Mon, 25 Aug 2014 07:56:25 +0000 (11:56 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Mon, 25 Aug 2014 07:56:25 +0000 (11:56 +0400)
And add a test.

LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, khr, rsc
https://golang.org/cl/128670043

src/pkg/runtime/pprof/pprof_test.go

index 9ab211c2dabc35025d49d50975cb53d67b408782..45db6c59a77964aeef1da01bb90062ffa8cf8f64 100644 (file)
@@ -314,6 +314,12 @@ func TestBlockProfile(t *testing.T) {
 #      0x[0-9,a-f]+    sync\.\(\*Mutex\)\.Lock\+0x[0-9,a-f]+   .*/src/pkg/sync/mutex\.go:[0-9]+
 #      0x[0-9,a-f]+    runtime/pprof_test\.blockMutex\+0x[0-9,a-f]+    .*/src/pkg/runtime/pprof/pprof_test.go:[0-9]+
 #      0x[0-9,a-f]+    runtime/pprof_test\.TestBlockProfile\+0x[0-9,a-f]+      .*/src/pkg/runtime/pprof/pprof_test.go:[0-9]+
+`},
+               {"cond", blockCond, `
+[0-9]+ [0-9]+ @ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+
+#      0x[0-9,a-f]+    sync\.\(\*Cond\)\.Wait\+0x[0-9,a-f]+    .*/src/pkg/sync/cond\.go:[0-9]+
+#      0x[0-9,a-f]+    runtime/pprof_test\.blockCond\+0x[0-9,a-f]+     .*/src/pkg/runtime/pprof/pprof_test.go:[0-9]+
+#      0x[0-9,a-f]+    runtime/pprof_test\.TestBlockProfile\+0x[0-9,a-f]+      .*/src/pkg/runtime/pprof/pprof_test.go:[0-9]+
 `},
        }
 
@@ -401,3 +407,17 @@ func blockMutex() {
        }()
        mu.Lock()
 }
+
+func blockCond() {
+       var mu sync.Mutex
+       c := sync.NewCond(&mu)
+       mu.Lock()
+       go func() {
+               time.Sleep(blockDelay)
+               mu.Lock()
+               c.Signal()
+               mu.Unlock()
+       }()
+       c.Wait()
+       mu.Unlock()
+}