Deleted Added
full compact
mcount.c (50477) mcount.c (55206)
1/*-
2 * Copyright (c) 1983, 1992, 1993
3 * The Regents of the University of California. 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

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

25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
1/*-
2 * Copyright (c) 1983, 1992, 1993
3 * The Regents of the University of California. 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

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

25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * $FreeBSD: head/sys/libkern/mcount.c 50477 1999-08-28 01:08:13Z peter $
33 * $FreeBSD: head/sys/libkern/mcount.c 55206 1999-12-29 05:07:58Z peter $
34 */
35
36#include <sys/param.h>
37#include <sys/gmon.h>
34 */
35
36#include <sys/param.h>
37#include <sys/gmon.h>
38#ifdef KERNEL
38#ifdef _KERNEL
39#ifndef GUPROF
40#include <sys/systm.h>
41#endif
42#include <vm/vm.h>
43#include <vm/vm_param.h>
44#include <vm/pmap.h>
45void bintr __P((void));
46void btrap __P((void));

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

69#ifdef GUPROF
70 int delta;
71#endif
72 register fptrdiff_t frompci;
73 register u_short *frompcindex;
74 register struct tostruct *top, *prevtop;
75 register struct gmonparam *p;
76 register long toindex;
39#ifndef GUPROF
40#include <sys/systm.h>
41#endif
42#include <vm/vm.h>
43#include <vm/vm_param.h>
44#include <vm/pmap.h>
45void bintr __P((void));
46void btrap __P((void));

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

69#ifdef GUPROF
70 int delta;
71#endif
72 register fptrdiff_t frompci;
73 register u_short *frompcindex;
74 register struct tostruct *top, *prevtop;
75 register struct gmonparam *p;
76 register long toindex;
77#ifdef KERNEL
77#ifdef _KERNEL
78 MCOUNT_DECL(s)
79#endif
80
81 p = &_gmonparam;
82#ifndef GUPROF /* XXX */
83 /*
84 * check that we are profiling
85 * and that we aren't recursively invoked.
86 */
87 if (p->state != GMON_PROF_ON)
88 return;
89#endif
78 MCOUNT_DECL(s)
79#endif
80
81 p = &_gmonparam;
82#ifndef GUPROF /* XXX */
83 /*
84 * check that we are profiling
85 * and that we aren't recursively invoked.
86 */
87 if (p->state != GMON_PROF_ON)
88 return;
89#endif
90#ifdef KERNEL
90#ifdef _KERNEL
91 MCOUNT_ENTER(s);
92#else
93 p->state = GMON_PROF_BUSY;
94#endif
95 frompci = frompc - p->lowpc;
96
91 MCOUNT_ENTER(s);
92#else
93 p->state = GMON_PROF_BUSY;
94#endif
95 frompci = frompc - p->lowpc;
96
97#ifdef KERNEL
97#ifdef _KERNEL
98 /*
99 * When we are called from an exception handler, frompci may be
100 * for a user address. Convert such frompci's to the index of
101 * user() to merge all user counts.
102 */
103 if (frompci >= p->textsize) {
104 if (frompci + p->lowpc
105 >= (uintfptr_t)(VM_MAXUSER_ADDRESS + UPAGES * PAGE_SIZE))
106 goto done;
107 frompci = (uintfptr_t)user - p->lowpc;
108 if (frompci >= p->textsize)
109 goto done;
110 }
98 /*
99 * When we are called from an exception handler, frompci may be
100 * for a user address. Convert such frompci's to the index of
101 * user() to merge all user counts.
102 */
103 if (frompci >= p->textsize) {
104 if (frompci + p->lowpc
105 >= (uintfptr_t)(VM_MAXUSER_ADDRESS + UPAGES * PAGE_SIZE))
106 goto done;
107 frompci = (uintfptr_t)user - p->lowpc;
108 if (frompci >= p->textsize)
109 goto done;
110 }
111#endif /* KERNEL */
111#endif
112
113#ifdef GUPROF
114 if (p->state == GMON_PROF_HIRES) {
115 /*
116 * Count the time since cputime() was previously called
117 * against `frompc'. Compensate for overheads.
118 *
119 * cputime() sets its prev_count variable to the count when

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

135 delta = cputime() - cputime_bias - p->mcount_pre_overhead;
136 cputime_bias = p->mcount_post_overhead;
137 KCOUNT(p, frompci) += delta;
138 *p->cputime_count += p->cputime_overhead;
139 *p->mcount_count += p->mcount_overhead;
140 }
141#endif /* GUPROF */
142
112
113#ifdef GUPROF
114 if (p->state == GMON_PROF_HIRES) {
115 /*
116 * Count the time since cputime() was previously called
117 * against `frompc'. Compensate for overheads.
118 *
119 * cputime() sets its prev_count variable to the count when

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

135 delta = cputime() - cputime_bias - p->mcount_pre_overhead;
136 cputime_bias = p->mcount_post_overhead;
137 KCOUNT(p, frompci) += delta;
138 *p->cputime_count += p->cputime_overhead;
139 *p->mcount_count += p->mcount_overhead;
140 }
141#endif /* GUPROF */
142
143#ifdef KERNEL
143#ifdef _KERNEL
144 /*
145 * When we are called from an exception handler, frompc is faked
146 * to be for where the exception occurred. We've just solidified
147 * the count for there. Now convert frompci to the index of btrap()
148 * for trap handlers and bintr() for interrupt handlers to make
149 * exceptions appear in the call graph as calls from btrap() and
150 * bintr() instead of calls from all over.
151 */
152 if ((uintfptr_t)selfpc >= (uintfptr_t)btrap
153 && (uintfptr_t)selfpc < (uintfptr_t)eintr) {
154 if ((uintfptr_t)selfpc >= (uintfptr_t)bintr)
155 frompci = (uintfptr_t)bintr - p->lowpc;
156 else
157 frompci = (uintfptr_t)btrap - p->lowpc;
158 }
144 /*
145 * When we are called from an exception handler, frompc is faked
146 * to be for where the exception occurred. We've just solidified
147 * the count for there. Now convert frompci to the index of btrap()
148 * for trap handlers and bintr() for interrupt handlers to make
149 * exceptions appear in the call graph as calls from btrap() and
150 * bintr() instead of calls from all over.
151 */
152 if ((uintfptr_t)selfpc >= (uintfptr_t)btrap
153 && (uintfptr_t)selfpc < (uintfptr_t)eintr) {
154 if ((uintfptr_t)selfpc >= (uintfptr_t)bintr)
155 frompci = (uintfptr_t)bintr - p->lowpc;
156 else
157 frompci = (uintfptr_t)btrap - p->lowpc;
158 }
159#endif /* KERNEL */
159#endif
160
161 /*
162 * check that frompc is a reasonable pc value.
163 * for example: signal catchers get called from the stack,
164 * not from text space. too bad.
165 */
166 if (frompci >= p->textsize)
167 goto done;

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

233 prevtop->link = top->link;
234 top->link = *frompcindex;
235 *frompcindex = toindex;
236 goto done;
237 }
238
239 }
240done:
160
161 /*
162 * check that frompc is a reasonable pc value.
163 * for example: signal catchers get called from the stack,
164 * not from text space. too bad.
165 */
166 if (frompci >= p->textsize)
167 goto done;

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

233 prevtop->link = top->link;
234 top->link = *frompcindex;
235 *frompcindex = toindex;
236 goto done;
237 }
238
239 }
240done:
241#ifdef KERNEL
241#ifdef _KERNEL
242 MCOUNT_EXIT(s);
243#else
244 p->state = GMON_PROF_ON;
245#endif
246 return;
247overflow:
248 p->state = GMON_PROF_ERROR;
242 MCOUNT_EXIT(s);
243#else
244 p->state = GMON_PROF_ON;
245#endif
246 return;
247overflow:
248 p->state = GMON_PROF_ERROR;
249#ifdef KERNEL
249#ifdef _KERNEL
250 MCOUNT_EXIT(s);
251#endif
252 return;
253}
254
255/*
256 * Actual definition of mcount function. Defined in <machine/profile.h>,
257 * which is included by <sys/gmon.h>.

--- 51 unchanged lines hidden ---
250 MCOUNT_EXIT(s);
251#endif
252 return;
253}
254
255/*
256 * Actual definition of mcount function. Defined in <machine/profile.h>,
257 * which is included by <sys/gmon.h>.

--- 51 unchanged lines hidden ---