diff options
-rw-r--r-- | sys/alpha/include/profile.h | 26 | ||||
-rw-r--r-- | sys/amd64/include/profile.h | 13 | ||||
-rw-r--r-- | sys/arm/include/profile.h | 13 | ||||
-rw-r--r-- | sys/i386/include/profile.h | 13 | ||||
-rw-r--r-- | sys/ia64/include/profile.h | 15 | ||||
-rw-r--r-- | sys/libkern/mcount.c | 54 | ||||
-rw-r--r-- | sys/powerpc/include/profile.h | 14 | ||||
-rw-r--r-- | sys/sparc64/include/profile.h | 13 |
8 files changed, 123 insertions, 38 deletions
diff --git a/sys/alpha/include/profile.h b/sys/alpha/include/profile.h index 37e85cf..2cb16c5 100644 --- a/sys/alpha/include/profile.h +++ b/sys/alpha/include/profile.h @@ -215,11 +215,27 @@ LX98: ldgp $29,0($27); \ * * XXX These macros should probably use inline assembly. */ -#define MCOUNT_ENTER(s) \ - s = _alpha_pal_swpipl(ALPHA_PSL_IPL_HIGH) -#define MCOUNT_EXIT(s) \ - (void)_alpha_pal_swpipl(s); -#define MCOUNT_DECL(s) u_long s; +u_long _alpha_pal_swpipl(u_long); + +#define MCOUNT_ENTER(s) s = _alpha_pal_swpipl(ALPHA_PSL_IPL_HIGH) +#define MCOUNT_EXIT(s) (void)_alpha_pal_swpipl(s) +#define MCOUNT_DECL(s) u_long s; + +void bintr(void); +void btrap(void); +void eintr(void); +void user(void); + +#define MCOUNT_FROMPC_USER(pc) \ + ((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? (uintfptr_t)user : pc) + +#define MCOUNT_FROMPC_INTR(pc) \ + ((pc >= (uintfptr_t)btrap && pc < (uintfptr_t)eintr) ? \ + ((pc >= (uintfptr_t)bintr) ? (uintfptr_t)bintr : \ + (uintfptr_t)btrap) : ~0UL) + +_MCOUNT_DECL(uintfptr_t, uintfptr_t); + #else /* !_KERNEL */ typedef u_long uintfptr_t; #endif diff --git a/sys/amd64/include/profile.h b/sys/amd64/include/profile.h index a4cce2c..d9ed7cc 100644 --- a/sys/amd64/include/profile.h +++ b/sys/amd64/include/profile.h @@ -87,6 +87,19 @@ extern int mcount_lock; #endif #endif /* GUPROF */ +void bintr(void); +void btrap(void); +void eintr(void); +void user(void); + +#define MCOUNT_FROMPC_USER(pc) \ + ((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? (uintfptr_t)user : pc) + +#define MCOUNT_FROMPC_INTR(pc) \ + ((pc >= (uintfptr_t)btrap && pc < (uintfptr_t)eintr) ? \ + ((pc >= (uintfptr_t)bintr) ? (uintfptr_t)bintr : \ + (uintfptr_t)btrap) : ~0UL) + #else /* !_KERNEL */ #define FUNCTION_ALIGNMENT 4 diff --git a/sys/arm/include/profile.h b/sys/arm/include/profile.h index efd3003..4c5321b 100644 --- a/sys/arm/include/profile.h +++ b/sys/arm/include/profile.h @@ -72,6 +72,19 @@ extern int mcount_lock; #endif #endif /* GUPROF */ +void bintr(void); +void btrap(void); +void eintr(void); +void user(void); + +#define MCOUNT_FROMPC_USER(pc) \ + ((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? (uintfptr_t)user : pc) + +#define MCOUNT_FROMPC_INTR(pc) \ + ((pc >= (uintfptr_t)btrap && pc < (uintfptr_t)eintr) ? \ + ((pc >= (uintfptr_t)bintr) ? (uintfptr_t)bintr : \ + (uintfptr_t)btrap) : ~0U) + #else /* !_KERNEL */ #define FUNCTION_ALIGNMENT 4 diff --git a/sys/i386/include/profile.h b/sys/i386/include/profile.h index 1c5ecf2..4e59ca0 100644 --- a/sys/i386/include/profile.h +++ b/sys/i386/include/profile.h @@ -87,6 +87,19 @@ extern int mcount_lock; #endif #endif /* GUPROF */ +void bintr(void); +void btrap(void); +void eintr(void); +void user(void); + +#define MCOUNT_FROMPC_USER(pc) \ + ((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? (uintfptr_t)user : pc) + +#define MCOUNT_FROMPC_INTR(pc) \ + ((pc >= (uintfptr_t)btrap && pc < (uintfptr_t)eintr) ? \ + ((pc >= (uintfptr_t)bintr) ? (uintfptr_t)bintr : \ + (uintfptr_t)btrap) : ~0U) + #else /* !_KERNEL */ #define FUNCTION_ALIGNMENT 4 diff --git a/sys/ia64/include/profile.h b/sys/ia64/include/profile.h index 9c15d00..91b14e2 100644 --- a/sys/ia64/include/profile.h +++ b/sys/ia64/include/profile.h @@ -26,6 +26,9 @@ * $FreeBSD$ */ +#ifndef _MACHINE_PROFILE_H_ +#define _MACHINE_PROFILE_H_ + #define _MCOUNT_DECL void __mcount #define MCOUNT @@ -41,6 +44,16 @@ typedef unsigned long fptrdiff_t; #define MCOUNT_EXIT(s) intr_restore(s) #define MCOUNT_DECL(s) register_t s; +void bintr(void); +void btrap(void); +void eintr(void); +void user(void); + +#define MCOUNT_FROMPC_USER(pc) \ + ((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? ~0UL : pc) + +#define MCOUNT_FROMPC_INTR(pc) (~0UL) + _MCOUNT_DECL(uintfptr_t, uintfptr_t); #else /* !_KERNEL */ @@ -48,3 +61,5 @@ _MCOUNT_DECL(uintfptr_t, uintfptr_t); typedef unsigned long uintfptr_t; #endif + +#endif /* _MACHINE_PROFILE_H_ */ diff --git a/sys/libkern/mcount.c b/sys/libkern/mcount.c index 1a9f8ac..d967fe8 100644 --- a/sys/libkern/mcount.c +++ b/sys/libkern/mcount.c @@ -39,10 +39,6 @@ __FBSDID("$FreeBSD$"); #include <vm/vm.h> #include <vm/vm_param.h> #include <vm/pmap.h> -void bintr(void); -void btrap(void); -void eintr(void); -void user(void); #endif /* @@ -61,16 +57,16 @@ void user(void); * perform this optimization. */ _MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */ - register uintfptr_t frompc, selfpc; + uintfptr_t frompc, selfpc; { #ifdef GUPROF int delta; #endif - register fptrdiff_t frompci; - register u_short *frompcindex; - register struct tostruct *top, *prevtop; - register struct gmonparam *p; - register long toindex; + fptrdiff_t frompci; + u_short *frompcindex; + struct tostruct *top, *prevtop; + struct gmonparam *p; + long toindex; #ifdef _KERNEL MCOUNT_DECL(s) #endif @@ -89,24 +85,20 @@ _MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */ #else p->state = GMON_PROF_BUSY; #endif - frompci = frompc - p->lowpc; #ifdef _KERNEL /* - * When we are called from an exception handler, frompci may be - * for a user address. Convert such frompci's to the index of - * user() to merge all user counts. + * When we are called from an exception handler, frompc may be + * a user address. Convert such frompc's to some representation + * in kernel address space. */ - if (frompci >= p->textsize) { - if (frompci + p->lowpc - >= (uintfptr_t)(VM_MAXUSER_ADDRESS)) - goto done; - frompci = (uintfptr_t)user - p->lowpc; - if (frompci >= p->textsize) - goto done; - } + frompc = MCOUNT_FROMPC_USER(frompc); #endif + frompci = frompc - p->lowpc; + if (frompci >= p->textsize) + goto done; + #ifdef GUPROF if (p->state == GMON_PROF_HIRES) { /* @@ -141,18 +133,14 @@ _MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */ /* * When we are called from an exception handler, frompc is faked * to be for where the exception occurred. We've just solidified - * the count for there. Now convert frompci to the index of btrap() - * for trap handlers and bintr() for interrupt handlers to make - * exceptions appear in the call graph as calls from btrap() and - * bintr() instead of calls from all over. + * the count for there. Now convert frompci to an index that + * represents the kind of exception so that interruptions appear + * in the call graph as calls from those index instead of calls + * from all over. */ - if ((uintfptr_t)selfpc >= (uintfptr_t)btrap - && (uintfptr_t)selfpc < (uintfptr_t)eintr) { - if ((uintfptr_t)selfpc >= (uintfptr_t)bintr) - frompci = (uintfptr_t)bintr - p->lowpc; - else - frompci = (uintfptr_t)btrap - p->lowpc; - } + frompc = MCOUNT_FROMPC_INTR(selfpc); + if ((frompc - p->lowpc) < p->textsize) + frompci = frompc - p->lowpc; #endif /* diff --git a/sys/powerpc/include/profile.h b/sys/powerpc/include/profile.h index 6960fb1..f7ee088 100644 --- a/sys/powerpc/include/profile.h +++ b/sys/powerpc/include/profile.h @@ -49,6 +49,20 @@ _mcount() \ #define MCOUNT_ENTER(s) #define MCOUNT_EXIT(s) #define MCOUNT_DECL(s) + +void bintr(void); +void btrap(void); +void eintr(void); +void user(void); + +#define MCOUNT_FROMPC_USER(pc) \ + ((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? (uintfptr_t)user : pc) + +#define MCOUNT_FROMPC_INTR(pc) \ + ((pc >= (uintfptr_t)btrap && pc < (uintfptr_t)eintr) ? \ + ((pc >= (uintfptr_t)bintr) ? (uintfptr_t)bintr : \ + (uintfptr_t)btrap) : ~0U) + #endif #endif /* !_MACHINE_PROFILE_H_ */ diff --git a/sys/sparc64/include/profile.h b/sys/sparc64/include/profile.h index 2cf1cef..2340b47 100644 --- a/sys/sparc64/include/profile.h +++ b/sys/sparc64/include/profile.h @@ -46,6 +46,19 @@ typedef u_long fptrdiff_t; #define MCOUNT_ENTER(s) s = rdpr(pil); wrpr(pil, 0, 14) #define MCOUNT_EXIT(s) wrpr(pil, 0, s) +void bintr(void); +void btrap(void); +void eintr(void); +void user(void); + +#define MCOUNT_FROMPC_USER(pc) \ + ((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? (uintfptr_t)user : pc) + +#define MCOUNT_FROMPC_INTR(pc) \ + ((pc >= (uintfptr_t)btrap && pc < (uintfptr_t)eintr) ? \ + ((pc >= (uintfptr_t)bintr) ? (uintfptr_t)bintr : \ + (uintfptr_t)btrap) : ~0UL) + void mcount(uintfptr_t frompc, uintfptr_t selfpc); #else /* !_KERNEL */ |