From ac474f954532b7c6570bd4018f91922e5bd52f88 Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Fri, 11 May 2007 23:43:55 +0000 Subject: [PATCH] - Add bits for userland profiling. For sun4u this is compile-tested only. - Replace magic 14 with PIL_TICK. --- lib/libc/sparc64/Symbol.map | 1 + sys/sparc64/include/profile.h | 40 +++++++++++++++++++++++++++++++---- sys/sun4v/include/profile.h | 40 +++++++++++++++++++++++++++++++---- 3 files changed, 73 insertions(+), 8 deletions(-) diff --git a/lib/libc/sparc64/Symbol.map b/lib/libc/sparc64/Symbol.map index a2e850545e3a..d7fd308fbdac 100644 --- a/lib/libc/sparc64/Symbol.map +++ b/lib/libc/sparc64/Symbol.map @@ -11,6 +11,7 @@ FBSD_1.0 { /* PSEUDO syscalls */ _exit; + _mcount; _setjmp; _longjmp; fabs; diff --git a/sys/sparc64/include/profile.h b/sys/sparc64/include/profile.h index 8779ea59024c..6c7d1b297ac9 100644 --- a/sys/sparc64/include/profile.h +++ b/sys/sparc64/include/profile.h @@ -32,18 +32,24 @@ #ifndef _MACHINE_PROFILE_H_ #define _MACHINE_PROFILE_H_ -#define FUNCTION_ALIGNMENT 32 -#define _MCOUNT_DECL void mcount -#define MCOUNT +#if !defined(_KERNEL) && !defined(_SYS_CDEFS_H_) +#error this file needs sys/cdefs.h as a prerequisite +#endif + +#define FUNCTION_ALIGNMENT 32 typedef u_long fptrdiff_t; #ifdef _KERNEL #include +#include + +#define _MCOUNT_DECL void mcount +#define MCOUNT #define MCOUNT_DECL(s) register_t s; -#define MCOUNT_ENTER(s) s = rdpr(pil); wrpr(pil, 0, 14) +#define MCOUNT_ENTER(s) s = rdpr(pil); wrpr(pil, 0, PIL_TICK) #define MCOUNT_EXIT(s) wrpr(pil, 0, s) void bintr(void); @@ -65,6 +71,32 @@ void mcount(uintfptr_t frompc, uintfptr_t selfpc); typedef u_long uintfptr_t; +#define _MCOUNT_DECL static __inline void __mcount + +#ifdef __GNUCLIKE_ASM +#define MCOUNT \ +void \ +_mcount() \ +{ \ + uintfptr_t frompc, selfpc; \ + \ + /* \ + * Find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * selfpc = pc pushed by call to mcount \ + */ \ + __asm("add %%o7, 8, %0" : "=r" (selfpc)); \ + /* \ + * frompc = pc pushed by call to mcount's caller. \ + */ \ + __asm("add %%i7, 8, %0" : "=r" (frompc)); \ + __mcount(frompc, selfpc); \ +} +#else /* !__GNUCLIKE_ASM */ +#define MCOUNT +#endif /* __GNUCLIKE_ASM */ + #endif /* _KERNEL */ #endif /* !_MACHINE_PROFILE_H_ */ diff --git a/sys/sun4v/include/profile.h b/sys/sun4v/include/profile.h index 8779ea59024c..6c7d1b297ac9 100644 --- a/sys/sun4v/include/profile.h +++ b/sys/sun4v/include/profile.h @@ -32,18 +32,24 @@ #ifndef _MACHINE_PROFILE_H_ #define _MACHINE_PROFILE_H_ -#define FUNCTION_ALIGNMENT 32 -#define _MCOUNT_DECL void mcount -#define MCOUNT +#if !defined(_KERNEL) && !defined(_SYS_CDEFS_H_) +#error this file needs sys/cdefs.h as a prerequisite +#endif + +#define FUNCTION_ALIGNMENT 32 typedef u_long fptrdiff_t; #ifdef _KERNEL #include +#include + +#define _MCOUNT_DECL void mcount +#define MCOUNT #define MCOUNT_DECL(s) register_t s; -#define MCOUNT_ENTER(s) s = rdpr(pil); wrpr(pil, 0, 14) +#define MCOUNT_ENTER(s) s = rdpr(pil); wrpr(pil, 0, PIL_TICK) #define MCOUNT_EXIT(s) wrpr(pil, 0, s) void bintr(void); @@ -65,6 +71,32 @@ void mcount(uintfptr_t frompc, uintfptr_t selfpc); typedef u_long uintfptr_t; +#define _MCOUNT_DECL static __inline void __mcount + +#ifdef __GNUCLIKE_ASM +#define MCOUNT \ +void \ +_mcount() \ +{ \ + uintfptr_t frompc, selfpc; \ + \ + /* \ + * Find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * selfpc = pc pushed by call to mcount \ + */ \ + __asm("add %%o7, 8, %0" : "=r" (selfpc)); \ + /* \ + * frompc = pc pushed by call to mcount's caller. \ + */ \ + __asm("add %%i7, 8, %0" : "=r" (frompc)); \ + __mcount(frompc, selfpc); \ +} +#else /* !__GNUCLIKE_ASM */ +#define MCOUNT +#endif /* __GNUCLIKE_ASM */ + #endif /* _KERNEL */ #endif /* !_MACHINE_PROFILE_H_ */