Commit 10137e7f authored by Rob Pike's avatar Rob Pike

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
parent 091fb779
...@@ -19,7 +19,7 @@ int fd; ...@@ -19,7 +19,7 @@ int fd;
Map *map; Map *map;
Map *symmap; Map *symmap;
struct Ureg ureg; struct Ureg ureg;
int total_sec = 10; int total_sec = 0;
int delta_msec = 100; int delta_msec = 100;
int collapse = 1; // collapse histogram trace points in same function int collapse = 1; // collapse histogram trace points in same function
...@@ -94,7 +94,6 @@ sample(void) ...@@ -94,7 +94,6 @@ sample(void)
static int n; static int n;
n++; n++;
ctlproc(pid, "stop");
for(i = 0; i < sizeof ureg; i+=8) { for(i = 0; i < sizeof ureg; i+=8) {
if(get8(map, (uvlong)i, &((uvlong*)&ureg)[i/8]) < 0) { if(get8(map, (uvlong)i, &((uvlong*)&ureg)[i/8]) < 0) {
if(n == 1) if(n == 1)
...@@ -103,7 +102,6 @@ sample(void) ...@@ -103,7 +102,6 @@ sample(void)
return 0; return 0;
} }
} }
ctlproc(pid, "start");
return 1; return 1;
} }
...@@ -145,7 +143,7 @@ addtohistogram(uvlong pc, uvlong sp) ...@@ -145,7 +143,7 @@ addtohistogram(uvlong pc, uvlong sp)
{ {
int h; int h;
PC *x; PC *x;
h = pc % Ncounters; h = pc % Ncounters;
for(x = counters[h]; x != NULL; x = x->next) { for(x = counters[h]; x != NULL; x = x->next) {
if(x->pc == pc) { if(x->pc == pc) {
...@@ -188,10 +186,14 @@ samples(void) ...@@ -188,10 +186,14 @@ samples(void)
req.tv_sec = delta_msec/1000; req.tv_sec = delta_msec/1000;
req.tv_nsec = 1000000*(delta_msec % 1000); req.tv_nsec = 1000000*(delta_msec % 1000);
for(msec = 0; msec < 1000*total_sec; msec += delta_msec) { for(msec = 0; total_sec <= 0 || msec < 1000*total_sec; msec += delta_msec) {
if(!sample()) ctlproc(pid, "stop");
if(!sample()) {
ctlproc(pid, "start");
break; break;
}
printpc(ureg.ip, ureg.sp); printpc(ureg.ip, ureg.sp);
ctlproc(pid, "start");
nanosleep(&req, NULL); nanosleep(&req, NULL);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment