From: Rob Pike Date: Mon, 10 Nov 2008 22:53:32 +0000 (-0800) Subject: fix start/stop bug in prof. X-Git-Tag: weekly.2009-11-06~2757 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=10137e7f1d5ec7d9ddedc02b50b6ad832bed7c0a;p=gostls13.git fix start/stop bug in prof. also only time-limit if a value is provided. R=rsc DELTA=9 (4 added, 2 deleted, 3 changed) OCL=18917 CL=18920 --- diff --git a/src/cmd/prof/main.c b/src/cmd/prof/main.c index 6057ab501a..22a2605c93 100644 --- a/src/cmd/prof/main.c +++ b/src/cmd/prof/main.c @@ -19,7 +19,7 @@ int fd; Map *map; Map *symmap; struct Ureg ureg; -int total_sec = 10; +int total_sec = 0; int delta_msec = 100; int collapse = 1; // collapse histogram trace points in same function @@ -94,7 +94,6 @@ sample(void) static int n; n++; - ctlproc(pid, "stop"); for(i = 0; i < sizeof ureg; i+=8) { if(get8(map, (uvlong)i, &((uvlong*)&ureg)[i/8]) < 0) { if(n == 1) @@ -103,7 +102,6 @@ sample(void) return 0; } } - ctlproc(pid, "start"); return 1; } @@ -145,7 +143,7 @@ addtohistogram(uvlong pc, uvlong sp) { int h; PC *x; - + h = pc % Ncounters; for(x = counters[h]; x != NULL; x = x->next) { if(x->pc == pc) { @@ -188,10 +186,14 @@ samples(void) req.tv_sec = delta_msec/1000; req.tv_nsec = 1000000*(delta_msec % 1000); - for(msec = 0; msec < 1000*total_sec; msec += delta_msec) { - if(!sample()) + for(msec = 0; total_sec <= 0 || msec < 1000*total_sec; msec += delta_msec) { + ctlproc(pid, "stop"); + if(!sample()) { + ctlproc(pid, "start"); break; + } printpc(ureg.ip, ureg.sp); + ctlproc(pid, "start"); nanosleep(&req, NULL); } }