Fix trivial bug in kprof -- pc not getting set correctly
authorRonald G. Minnich <rminnich@google.com>
Sat, 26 Apr 2014 00:45:50 +0000 (17:45 -0700)
committerRonald G. Minnich <rminnich@google.com>
Sat, 26 Apr 2014 00:45:50 +0000 (17:45 -0700)
I was testing with dd bs=64 etc. etc.
Andrew Gallatin tested with cat.

For me, the pc was always right, since each read was a single
record and the pc was recomputed each time. For larger reads, it would be mostly wrong.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
kern/drivers/dev/kprof.c

index 9a462a9..499fd94 100644 (file)
@@ -184,6 +184,7 @@ kprofread(struct chan *c, void *va, long n, int64_t off)
                a = va;
                ea = a + n;
                bp = kprof.buf + offset/FORMATSIZE;
+               pc = kprof.minpc + ((offset/FORMATSIZE)<<LRES);
                while((a < ea) && (n >= FORMATSIZE)){
                        /* what a pain. We need to manage the
                         * fact that the *prints all make room for
@@ -196,13 +197,13 @@ kprofread(struct chan *c, void *va, long n, int64_t off)
                                break;
                        }
                        w = *bp++;
-                       pc = kprof.minpc + ((offset/FORMATSIZE)<<LRES);
                        name = get_fn_name(pc);
                        snprintf(print, sizeof(print), outformat, pc, name, w);
                        memmove(a, print, FORMATSIZE);
                        a += FORMATSIZE;
                        n -= FORMATSIZE;
                        ret += FORMATSIZE;
+                       pc++;
                }
                n = ret;
                break;