summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjake <jake@FreeBSD.org>2002-07-30 06:14:34 +0000
committerjake <jake@FreeBSD.org>2002-07-30 06:14:34 +0000
commiteb814d118c4a5e3b73d46399b5540e0b0d26a319 (patch)
tree74701a761cdf70fb06c38ae12e398e0b9cd4c6ad
parent5b1899e180f5e79b1c5d10f861e1e8f99e17f52c (diff)
downloadFreeBSD-src-eb814d118c4a5e3b73d46399b5540e0b0d26a319.zip
FreeBSD-src-eb814d118c4a5e3b73d46399b5540e0b0d26a319.tar.gz
Add definitions for statistical and high-resolution profiling. The calling
conventions for _mcount and __cyg_profile_func_enter are different, so statistical profiling kernels build and link but don't actually work. IWBNI one could tell gcc to only generate calls to the former. Define uintfptr_t properly for userland, but not for the kernel (I hope).
-rw-r--r--sys/sparc64/include/profile.h49
-rw-r--r--sys/sparc64/sparc64/support.S54
-rw-r--r--sys/sparc64/sparc64/support.s54
3 files changed, 91 insertions, 66 deletions
diff --git a/sys/sparc64/include/profile.h b/sys/sparc64/include/profile.h
index 122fc87..398f5c7 100644
--- a/sys/sparc64/include/profile.h
+++ b/sys/sparc64/include/profile.h
@@ -32,34 +32,55 @@
#ifndef _MACHINE_PROFILE_H_
#define _MACHINE_PROFILE_H_
+#define FUNCTION_ALIGNMENT 32
#define _MCOUNT_DECL void mcount
-
-#define FUNCTION_ALIGNMENT 32
+#define MCOUNT
typedef u_long fptrdiff_t;
-typedef u_long uintfptr_t;
-
-#define MCOUNT \
-void \
-_mcount() \
-{ \
-}
#ifdef _KERNEL
-#define MCOUNT_ENTER(s)
-#define MCOUNT_EXIT(s)
-#define MCOUNT_DECL(s)
+
+#include <machine/cpufunc.h>
+
+#define MCOUNT_DECL(s) register_t s;
+#define MCOUNT_ENTER(s) s = rdpr(pil); wrpr(pil, 0, 14)
+#define MCOUNT_EXIT(s) wrpr(pil, 0, s)
+
#ifdef GUPROF
+
+#define CALIB_SCALE 1000
+#define KCOUNT(p,index) \
+ ((p)->kcount[(index) / (HISTFRACTION * sizeof(HISTCOUNTER))])
+#define PC_TO_I(p, pc) ((uintfptr_t)(pc) - (uintfptr_t)(p)->lowpc)
+
struct gmonparam;
+extern int cputime_bias;
+
+int cputime(void);
void nullfunc_loop_profiled(void);
void nullfunc_profiled(void);
void startguprof(struct gmonparam *p);
void stopguprof(struct gmonparam *p);
-#else
+
+#else /* GUPROF */
+
#define startguprof(p)
#define stopguprof(p)
+
#endif /* GUPROF */
-#endif
+
+void empty_loop(void);
+void kmupetext(uintfptr_t nhighpc);
+void mcount(uintfptr_t frompc, uintfptr_t selfpc);
+void mexitcount(uintfptr_t selfpc);
+void nullfunc(void);
+void nullfunc_loop(void);
+
+#else /* _KERNEL */
+
+typedef u_long uintfptr_t;
+
+#endif /* _KERNEL */
#endif /* !_MACHINE_PROFILE_H_ */
diff --git a/sys/sparc64/sparc64/support.S b/sys/sparc64/sparc64/support.S
index 405d813..68cf714 100644
--- a/sys/sparc64/sparc64/support.S
+++ b/sys/sparc64/sparc64/support.S
@@ -585,7 +585,23 @@ ENTRY(openfirmware_exit)
! never to return
END(openfirmware_exit)
-#ifdef GUPROF
+#ifdef GPROF
+
+ENTRY(user)
+ nop
+
+ENTRY(btrap)
+ nop
+
+ENTRY(etrap)
+ nop
+
+ENTRY(bintr)
+ nop
+
+ENTRY(eintr)
+ nop
+
/*
* XXX including sys/gmon.h in genassym.c is not possible due to uintfptr_t
@@ -595,10 +611,10 @@ END(openfirmware_exit)
#define GMON_PROF_OFF 3
#define GMON_PROF_HIRES 4
- _ALIGN_TEXT
- .globl __cyg_profile_func_enter
- .type __cyg_profile_func_enter,@function
-__cyg_profile_func_enter:
+ .globl _mcount
+ .set _mcount, __cyg_profile_func_enter
+
+ENTRY(__cyg_profile_func_enter)
SET(_gmonparam, %o3, %o2)
lduw [%o2 + GM_STATE], %o3
cmp %o3, GMON_PROF_OFF
@@ -609,12 +625,11 @@ __cyg_profile_func_enter:
nop
1: retl
nop
- .size __cyg_profile_func_enter, . - __cyg_profile_func_enter
+END(__cyg_profile_func_enter)
- _ALIGN_TEXT
- .globl __cyg_profile_func_exit
- .type __cyg_profile_func_exit,@function
-__cyg_profile_func_exit:
+#ifdef GUPROF
+
+ENTRY(__cyg_profile_func_exit)
SET(_gmonparam, %o3, %o2)
lduw [%o2 + GM_STATE], %o3
cmp %o3, GMON_PROF_HIRES
@@ -625,21 +640,8 @@ __cyg_profile_func_exit:
nop
1: retl
nop
- .size __cyg_profile_func_exit, . - __cyg_profile_func_exit
-
-ENTRY(user)
- nop
-
-ENTRY(btrap)
- nop
+END(__cyg_profile_func_exit)
-ENTRY(etrap)
- nop
-
-ENTRY(bintr)
- nop
-
-ENTRY(eintr)
- nop
+#endif /* GUPROF */
-#endif
+#endif /* GPROF */
diff --git a/sys/sparc64/sparc64/support.s b/sys/sparc64/sparc64/support.s
index 405d813..68cf714 100644
--- a/sys/sparc64/sparc64/support.s
+++ b/sys/sparc64/sparc64/support.s
@@ -585,7 +585,23 @@ ENTRY(openfirmware_exit)
! never to return
END(openfirmware_exit)
-#ifdef GUPROF
+#ifdef GPROF
+
+ENTRY(user)
+ nop
+
+ENTRY(btrap)
+ nop
+
+ENTRY(etrap)
+ nop
+
+ENTRY(bintr)
+ nop
+
+ENTRY(eintr)
+ nop
+
/*
* XXX including sys/gmon.h in genassym.c is not possible due to uintfptr_t
@@ -595,10 +611,10 @@ END(openfirmware_exit)
#define GMON_PROF_OFF 3
#define GMON_PROF_HIRES 4
- _ALIGN_TEXT
- .globl __cyg_profile_func_enter
- .type __cyg_profile_func_enter,@function
-__cyg_profile_func_enter:
+ .globl _mcount
+ .set _mcount, __cyg_profile_func_enter
+
+ENTRY(__cyg_profile_func_enter)
SET(_gmonparam, %o3, %o2)
lduw [%o2 + GM_STATE], %o3
cmp %o3, GMON_PROF_OFF
@@ -609,12 +625,11 @@ __cyg_profile_func_enter:
nop
1: retl
nop
- .size __cyg_profile_func_enter, . - __cyg_profile_func_enter
+END(__cyg_profile_func_enter)
- _ALIGN_TEXT
- .globl __cyg_profile_func_exit
- .type __cyg_profile_func_exit,@function
-__cyg_profile_func_exit:
+#ifdef GUPROF
+
+ENTRY(__cyg_profile_func_exit)
SET(_gmonparam, %o3, %o2)
lduw [%o2 + GM_STATE], %o3
cmp %o3, GMON_PROF_HIRES
@@ -625,21 +640,8 @@ __cyg_profile_func_exit:
nop
1: retl
nop
- .size __cyg_profile_func_exit, . - __cyg_profile_func_exit
-
-ENTRY(user)
- nop
-
-ENTRY(btrap)
- nop
+END(__cyg_profile_func_exit)
-ENTRY(etrap)
- nop
-
-ENTRY(bintr)
- nop
-
-ENTRY(eintr)
- nop
+#endif /* GUPROF */
-#endif
+#endif /* GPROF */
OpenPOWER on IntegriCloud