From ce80df24acdae12bb858f4b0cd5ed955a156cc0a Mon Sep 17 00:00:00 2001 From: jhb Date: Fri, 16 Dec 2005 22:11:52 +0000 Subject: - Use uintfptr_t rather than int for the kernel profiling index (though it really should be a fptrdiff_t if we had that) in profclock(). - Don't try to profile kernel pc's that are >= the kernel lowpc to avoid underflows when computing a profiling index. - Use the PC_TO_I() macro to compute the kernel profiling index rather than doing it inline. Discussed with: bde --- sys/kern/kern_clock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sys/kern/kern_clock.c') diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 74862ca..3c1a1da 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -480,7 +480,7 @@ profclock(frame) struct thread *td; #ifdef GPROF struct gmonparam *g; - int i; + uintfptr_t i; #endif td = curthread; @@ -500,8 +500,8 @@ profclock(frame) * Kernel statistics are just like addupc_intr, only easier. */ g = &_gmonparam; - if (g->state == GMON_PROF_ON) { - i = CLKF_PC(frame) - g->lowpc; + if (g->state == GMON_PROF_ON && CLKF_PC(frame) >= g->lowpc) { + i = PC_TO_I(g, CLKF_PC(frame)); if (i < g->textsize) { i /= HISTFRACTION * sizeof(*g->kcount); g->kcount[i]++; -- cgit v1.1