aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64/amd64/prof_machdep.c
diff options
context:
space:
mode:
authorBruce Evans <bde@FreeBSD.org>1999-05-06 09:44:57 +0000
committerBruce Evans <bde@FreeBSD.org>1999-05-06 09:44:57 +0000
commitea2b3e3d1b0aaff8addc8f0c058e9046c9d9324e (patch)
tree406c7894127f69c091aafd4d6bc0fee9f0778369 /sys/amd64/amd64/prof_machdep.c
parent5c32431080c74b5779df97b4c31c11561ca2c799 (diff)
downloadsrc-ea2b3e3d1b0aaff8addc8f0c058e9046c9d9324e.tar.gz
src-ea2b3e3d1b0aaff8addc8f0c058e9046c9d9324e.zip
Fixed profiling of elf kernels. Made high resolution profiling compile
for elf kernels (it is broken for all kernels due to lack of egcs support). Renaming of many assembler labels is avoided by declaring by declaring the labels that need to be visible to gprof as having type "function" and depending on the elf version of gprof being zealous about discarding the others. A few type declarations are still missing, mainly for SMP. PR: 9413 Submitted by: Assar Westerlund <assar@sics.se> (initial parts)
Notes
Notes: svn path=/head/; revision=46548
Diffstat (limited to 'sys/amd64/amd64/prof_machdep.c')
-rw-r--r--sys/amd64/amd64/prof_machdep.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/sys/amd64/amd64/prof_machdep.c b/sys/amd64/amd64/prof_machdep.c
index 60167ea8ae79..808dd86b811d 100644
--- a/sys/amd64/amd64/prof_machdep.c
+++ b/sys/amd64/amd64/prof_machdep.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: prof_machdep.c,v 1.10 1998/04/19 15:41:06 bde Exp $
+ * $Id: prof_machdep.c,v 1.11 1998/12/14 18:21:34 bde Exp $
*/
#ifdef GUPROF
@@ -39,8 +39,11 @@
#include <machine/clock.h>
#include <machine/perfmon.h>
#include <machine/profile.h>
+#undef MCOUNT
#endif
+#include <machine/asmacros.h>
+
#ifdef PC98
#include <pc98/pc98/pc98.h>
#else
@@ -73,25 +76,26 @@ GMON_PROF_OFF = 3 \n\
.text \n\
.align 4,0x90 \n\
.globl __mcount \n\
+ .type __mcount,@function \n\
__mcount: \n\
# \n\
# Check that we are profiling. Do it early for speed. \n\
# \n\
- cmpl $GMON_PROF_OFF,__gmonparam+GM_STATE \n\
- je Lmcount_exit \n\
+ cmpl $GMON_PROF_OFF," __XSTRING(CNAME(_gmonparam)) "+GM_STATE \n\
+ je .mcount_exit \n\
# \n\
- # __mcount is the same as mcount except the caller \n\
+ # __mcount is the same as [.]mcount except the caller \n\
# hasn't changed the stack except to call here, so the \n\
# caller's raddr is above our raddr. \n\
# \n\
movl 4(%esp),%edx \n\
- jmp Lgot_frompc \n\
+ jmp .got_frompc \n\
\n\
.align 4,0x90 \n\
- .globl mcount \n\
-mcount: \n\
- cmpl $GMON_PROF_OFF,__gmonparam+GM_STATE \n\
- je Lmcount_exit \n\
+ .globl " __XSTRING(HIDENAME(mcount)) " \n\
+" __XSTRING(HIDENAME(mcount)) ": \n\
+ cmpl $GMON_PROF_OFF," __XSTRING(CNAME(_gmonparam)) "+GM_STATE \n\
+ je .mcount_exit \n\
# \n\
# The caller's stack frame has already been built, so \n\
# %ebp is the caller's frame pointer. The caller's \n\
@@ -99,7 +103,7 @@ mcount: \n\
# caller's frame pointer. \n\
# \n\
movl 4(%ebp),%edx \n\
-Lgot_frompc: \n\
+.got_frompc: \n\
# \n\
# Our raddr is the caller's pc. \n\
# \n\
@@ -109,10 +113,10 @@ Lgot_frompc: \n\
pushl %eax \n\
pushl %edx \n\
cli \n\
- call _mcount \n\
+ call " __XSTRING(CNAME(mcount)) " \n\
addl $8,%esp \n\
popfl \n\
-Lmcount_exit: \n\
+.mcount_exit: \n\
ret \n\
");
#else /* !__GNUC__ */
@@ -121,41 +125,42 @@ Lmcount_exit: \n\
#ifdef GUPROF
/*
- * mexitcount saves the return register(s), loads selfpc and calls
+ * [.]mexitcount saves the return register(s), loads selfpc and calls
* mexitcount(selfpc) to do the work. Someday it should be in a machine
- * dependent file together with cputime(), __mcount and mcount. cputime()
+ * dependent file together with cputime(), __mcount and [.]mcount. cputime()
* can't just be put in machdep.c because it has to be compiled without -pg.
*/
#ifdef __GNUC__
__asm(" \n\
.text \n\
# \n\
-# Dummy label to be seen when gprof -u hides mexitcount. \n\
+# Dummy label to be seen when gprof -u hides [.]mexitcount. \n\
# \n\
.align 4,0x90 \n\
.globl __mexitcount \n\
+ .type __mexitcount,@function \n\
__mexitcount: \n\
nop \n\
\n\
GMON_PROF_HIRES = 4 \n\
\n\
.align 4,0x90 \n\
- .globl mexitcount \n\
-mexitcount: \n\
- cmpl $GMON_PROF_HIRES,__gmonparam+GM_STATE \n\
- jne Lmexitcount_exit \n\
+ .globl " __XSTRING(HIDENAME(mexitcount)) " \n\
+" __XSTRING(HIDENAME(mexitcount)) ": \n\
+ cmpl $GMON_PROF_HIRES," __XSTRING(CNAME(_gmonparam)) "+GM_STATE \n\
+ jne .mexitcount_exit \n\
pushl %edx \n\
pushl %eax \n\
movl 8(%esp),%eax \n\
pushfl \n\
pushl %eax \n\
cli \n\
- call _mexitcount \n\
+ call " __XSTRING(CNAME(mexitcount)) " \n\
addl $4,%esp \n\
popfl \n\
popl %eax \n\
popl %edx \n\
-Lmexitcount_exit: \n\
+.mexitcount_exit: \n\
ret \n\
");
#else /* !__GNUC__ */
@@ -340,8 +345,8 @@ stopguprof(gp)
__asm(" \n\
.text \n\
.align 4,0x90 \n\
- .globl mexitcount \n\
-mexitcount: \n\
+ .globl " __XSTRING(HIDENAME(mexitcount)) " \n\
+" __XSTRING(HIDENAME(mexitcount)) ": \n\
ret \n\
");
#else /* !__GNUC__ */