Deleted Added
full compact
prof_machdep.c (163722) prof_machdep.c (163726)
1/*-
2 * Copyright (c) 1996 Bruce D. Evans.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1996 Bruce D. Evans.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/i386/isa/prof_machdep.c 163722 2006-10-27 14:17:50Z bde $");
28__FBSDID("$FreeBSD: head/sys/i386/isa/prof_machdep.c 163726 2006-10-28 06:04:29Z bde $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32
29
30#include <sys/param.h>
31#include <sys/systm.h>
32
33#include <machine/asmacros.h>
34#include <machine/timerreg.h>
35
33#include <machine/timerreg.h>
34
36/*
37 * There are 2 definitions of MCOUNT to have a C version and an asm version
38 * with the same name and not have LOCORE #ifdefs to distinguish them.
39 * <machine/profile.h> provides a C version, and <machine/asmacros.h>
40 * provides an asm version. To avoid conflicts, #undef the asm version.
41 */
42#undef MCOUNT
43
44#ifdef GUPROF
45#include "opt_i586_guprof.h"
46#include "opt_perfmon.h"
47
48#include <sys/gmon.h>
49#include <sys/kernel.h>
50#include <sys/sysctl.h>
51

--- 25 unchanged lines hidden (view full) ---

77 .text \n\
78 .p2align 4,0x90 \n\
79 .globl __mcount \n\
80 .type __mcount,@function \n\
81__mcount: \n\
82 # \n\
83 # Check that we are profiling. Do it early for speed. \n\
84 # \n\
35#ifdef GUPROF
36#include "opt_i586_guprof.h"
37#include "opt_perfmon.h"
38
39#include <sys/gmon.h>
40#include <sys/kernel.h>
41#include <sys/sysctl.h>
42

--- 25 unchanged lines hidden (view full) ---

68 .text \n\
69 .p2align 4,0x90 \n\
70 .globl __mcount \n\
71 .type __mcount,@function \n\
72__mcount: \n\
73 # \n\
74 # Check that we are profiling. Do it early for speed. \n\
75 # \n\
85 cmpl $GMON_PROF_OFF," __XSTRING(CNAME(_gmonparam)) "+GM_STATE \n\
76 cmpl $GMON_PROF_OFF,_gmonparam+GM_STATE \n\
86 je .mcount_exit \n\
87 # \n\
88 # __mcount is the same as [.]mcount except the caller \n\
89 # hasn't changed the stack except to call here, so the \n\
90 # caller's raddr is above our raddr. \n\
91 # \n\
92 movl 4(%esp),%edx \n\
93 jmp .got_frompc \n\
94 \n\
95 .p2align 4,0x90 \n\
77 je .mcount_exit \n\
78 # \n\
79 # __mcount is the same as [.]mcount except the caller \n\
80 # hasn't changed the stack except to call here, so the \n\
81 # caller's raddr is above our raddr. \n\
82 # \n\
83 movl 4(%esp),%edx \n\
84 jmp .got_frompc \n\
85 \n\
86 .p2align 4,0x90 \n\
96 .globl " __XSTRING(HIDENAME(mcount)) " \n\
97" __XSTRING(HIDENAME(mcount)) ": \n\
87 .globl .mcount \n\
88.mcount: \n\
98 .globl __cyg_profile_func_enter \n\
99__cyg_profile_func_enter: \n\
89 .globl __cyg_profile_func_enter \n\
90__cyg_profile_func_enter: \n\
100 cmpl $GMON_PROF_OFF," __XSTRING(CNAME(_gmonparam)) "+GM_STATE \n\
91 cmpl $GMON_PROF_OFF,_gmonparam+GM_STATE \n\
101 je .mcount_exit \n\
102 # \n\
103 # The caller's stack frame has already been built, so \n\
104 # %ebp is the caller's frame pointer. The caller's \n\
105 # raddr is in the caller's frame following the caller's \n\
106 # caller's frame pointer. \n\
107 # \n\
108 movl 4(%ebp),%edx \n\
109.got_frompc: \n\
110 # \n\
111 # Our raddr is the caller's pc. \n\
112 # \n\
113 movl (%esp),%eax \n\
114 \n\
115 pushfl \n\
116 pushl %eax \n\
117 pushl %edx \n\
118 cli \n\
92 je .mcount_exit \n\
93 # \n\
94 # The caller's stack frame has already been built, so \n\
95 # %ebp is the caller's frame pointer. The caller's \n\
96 # raddr is in the caller's frame following the caller's \n\
97 # caller's frame pointer. \n\
98 # \n\
99 movl 4(%ebp),%edx \n\
100.got_frompc: \n\
101 # \n\
102 # Our raddr is the caller's pc. \n\
103 # \n\
104 movl (%esp),%eax \n\
105 \n\
106 pushfl \n\
107 pushl %eax \n\
108 pushl %edx \n\
109 cli \n\
119 call " __XSTRING(CNAME(mcount)) " \n\
110 call mcount \n\
120 addl $8,%esp \n\
121 popfl \n\
122.mcount_exit: \n\
123 ret \n\
124");
125#else /* !__GNUCLIKE_ASM */
126#error this file needs to be ported to your compiler
127#endif /* __GNUCLIKE_ASM */

--- 15 unchanged lines hidden (view full) ---

143 .globl __mexitcount \n\
144 .type __mexitcount,@function \n\
145__mexitcount: \n\
146 nop \n\
147 \n\
148GMON_PROF_HIRES = 4 \n\
149 \n\
150 .p2align 4,0x90 \n\
111 addl $8,%esp \n\
112 popfl \n\
113.mcount_exit: \n\
114 ret \n\
115");
116#else /* !__GNUCLIKE_ASM */
117#error this file needs to be ported to your compiler
118#endif /* __GNUCLIKE_ASM */

--- 15 unchanged lines hidden (view full) ---

134 .globl __mexitcount \n\
135 .type __mexitcount,@function \n\
136__mexitcount: \n\
137 nop \n\
138 \n\
139GMON_PROF_HIRES = 4 \n\
140 \n\
141 .p2align 4,0x90 \n\
151 .globl " __XSTRING(HIDENAME(mexitcount)) " \n\
152" __XSTRING(HIDENAME(mexitcount)) ": \n\
142 .globl .mexitcount \n\
143.mexitcount: \n\
153 .globl __cyg_profile_func_exit \n\
154__cyg_profile_func_exit: \n\
144 .globl __cyg_profile_func_exit \n\
145__cyg_profile_func_exit: \n\
155 cmpl $GMON_PROF_HIRES," __XSTRING(CNAME(_gmonparam)) "+GM_STATE \n\
146 cmpl $GMON_PROF_HIRES,_gmonparam+GM_STATE \n\
156 jne .mexitcount_exit \n\
157 pushl %edx \n\
158 pushl %eax \n\
159 movl 8(%esp),%eax \n\
160 pushfl \n\
161 pushl %eax \n\
162 cli \n\
147 jne .mexitcount_exit \n\
148 pushl %edx \n\
149 pushl %eax \n\
150 movl 8(%esp),%eax \n\
151 pushfl \n\
152 pushl %eax \n\
153 cli \n\
163 call " __XSTRING(CNAME(mexitcount)) " \n\
154 call mexitcount \n\
164 addl $4,%esp \n\
165 popfl \n\
166 popl %eax \n\
167 popl %edx \n\
168.mexitcount_exit: \n\
169 ret \n\
170");
171#endif /* __GNUCLIKE_ASM */

--- 181 unchanged lines hidden ---
155 addl $4,%esp \n\
156 popfl \n\
157 popl %eax \n\
158 popl %edx \n\
159.mexitcount_exit: \n\
160 ret \n\
161");
162#endif /* __GNUCLIKE_ASM */

--- 181 unchanged lines hidden ---