subr_prof.c (77978ab8bc1968d7606144ddc20b2a8a9f9b3382) subr_prof.c (0384fff8c5b098545c3db311b0e0aa1ec4c9ae7e)
1/*-
2 * Copyright (c) 1982, 1986, 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

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

88 int empty_loop_time;
89 int i;
90 int mcount_overhead;
91 int mexitcount_overhead;
92 int nullfunc_loop_overhead;
93 int nullfunc_loop_profiled_time;
94 uintfptr_t tmp_addr;
95#endif
1/*-
2 * Copyright (c) 1982, 1986, 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

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

88 int empty_loop_time;
89 int i;
90 int mcount_overhead;
91 int mexitcount_overhead;
92 int nullfunc_loop_overhead;
93 int nullfunc_loop_profiled_time;
94 uintfptr_t tmp_addr;
95#endif
96 int intrstate;
96
97 /*
98 * Round lowpc and highpc to multiples of the density we're using
99 * so the rest of the scaling (here and in gprof) stays in ints.
100 */
101 p->lowpc = ROUNDDOWN((u_long)btext, HISTFRACTION * sizeof(HISTCOUNTER));
102 p->highpc = ROUNDUP((u_long)etext, HISTFRACTION * sizeof(HISTCOUNTER));
103 p->textsize = p->highpc - p->lowpc;

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

130 p->cputime_count = &KCOUNT(p, PC_TO_I(p, cputime));
131 p->mcount_count = &KCOUNT(p, PC_TO_I(p, mcount));
132 p->mexitcount_count = &KCOUNT(p, PC_TO_I(p, mexitcount));
133
134 /*
135 * Disable interrupts to avoid interference while we calibrate
136 * things.
137 */
97
98 /*
99 * Round lowpc and highpc to multiples of the density we're using
100 * so the rest of the scaling (here and in gprof) stays in ints.
101 */
102 p->lowpc = ROUNDDOWN((u_long)btext, HISTFRACTION * sizeof(HISTCOUNTER));
103 p->highpc = ROUNDUP((u_long)etext, HISTFRACTION * sizeof(HISTCOUNTER));
104 p->textsize = p->highpc - p->lowpc;

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

131 p->cputime_count = &KCOUNT(p, PC_TO_I(p, cputime));
132 p->mcount_count = &KCOUNT(p, PC_TO_I(p, mcount));
133 p->mexitcount_count = &KCOUNT(p, PC_TO_I(p, mexitcount));
134
135 /*
136 * Disable interrupts to avoid interference while we calibrate
137 * things.
138 */
139 intrstate = save_intr();
138 disable_intr();
139
140 /*
141 * Determine overheads.
142 * XXX this needs to be repeated for each useful timer/counter.
143 */
144 cputime_overhead = 0;
145 startguprof(p);

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

184#else
185#error
186#endif
187 mexitcount_overhead = KCOUNT(p, PC_TO_I(p, tmp_addr));
188
189 p->state = GMON_PROF_OFF;
190 stopguprof(p);
191
140 disable_intr();
141
142 /*
143 * Determine overheads.
144 * XXX this needs to be repeated for each useful timer/counter.
145 */
146 cputime_overhead = 0;
147 startguprof(p);

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

186#else
187#error
188#endif
189 mexitcount_overhead = KCOUNT(p, PC_TO_I(p, tmp_addr));
190
191 p->state = GMON_PROF_OFF;
192 stopguprof(p);
193
192 enable_intr();
194 restore_intr(intrstate);
193
194 nullfunc_loop_profiled_time = 0;
195 for (tmp_addr = (uintfptr_t)nullfunc_loop_profiled;
196 tmp_addr < (uintfptr_t)nullfunc_loop_profiled_end;
197 tmp_addr += HISTFRACTION * sizeof(HISTCOUNTER))
198 nullfunc_loop_profiled_time += KCOUNT(p, PC_TO_I(p, tmp_addr));
199#define CALIB_DOSCALE(count) (((count) + CALIB_SCALE / 3) / CALIB_SCALE)
200#define c2n(count, freq) ((int)((count) * 1000000000LL / freq))

--- 261 unchanged lines hidden ---
195
196 nullfunc_loop_profiled_time = 0;
197 for (tmp_addr = (uintfptr_t)nullfunc_loop_profiled;
198 tmp_addr < (uintfptr_t)nullfunc_loop_profiled_end;
199 tmp_addr += HISTFRACTION * sizeof(HISTCOUNTER))
200 nullfunc_loop_profiled_time += KCOUNT(p, PC_TO_I(p, tmp_addr));
201#define CALIB_DOSCALE(count) (((count) + CALIB_SCALE / 3) / CALIB_SCALE)
202#define c2n(count, freq) ((int)((count) * 1000000000LL / freq))

--- 261 unchanged lines hidden ---