subr_prof.c (d2d3e8751c3b7831f7064ccf400978b75b696547) subr_prof.c (4b2af45f4ba1f8d8d5a56c4b18f29da6d08146e9)
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

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

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 * @(#)subr_prof.c 8.3 (Berkeley) 9/23/93
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

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

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 * @(#)subr_prof.c 8.3 (Berkeley) 9/23/93
34 * $Id: subr_prof.c,v 1.9 1995/09/09 18:10:05 davidg Exp $
34 * $Id: subr_prof.c,v 1.10 1995/11/12 06:43:04 bde Exp $
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/sysproto.h>
40#include <sys/kernel.h>
41#include <sys/proc.h>
42#include <vm/vm.h>

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

93 p->kcount = (u_short *)cp;
94 cp += p->kcountsize;
95 p->froms = (u_short *)cp;
96}
97
98/*
99 * Return kernel profiling information.
100 */
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/sysproto.h>
40#include <sys/kernel.h>
41#include <sys/proc.h>
42#include <vm/vm.h>

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

93 p->kcount = (u_short *)cp;
94 cp += p->kcountsize;
95 p->froms = (u_short *)cp;
96}
97
98/*
99 * Return kernel profiling information.
100 */
101int
102sysctl_doprof(name, namelen, oldp, oldlenp, newp, newlen)
103 int *name;
104 u_int namelen;
105 void *oldp;
106 size_t *oldlenp;
107 void *newp;
108 size_t newlen;
101static int
102sysctl_kern_prof SYSCTL_HANDLER_ARGS
109{
103{
104 int *name = (int *) arg1;
105 u_int namelen = arg2;
110 struct gmonparam *gp = &_gmonparam;
111 int error;
112
113 /* all sysctl names at this level are terminal */
114 if (namelen != 1)
115 return (ENOTDIR); /* overloaded */
116
117 switch (name[0]) {
118 case GPROF_STATE:
106 struct gmonparam *gp = &_gmonparam;
107 int error;
108
109 /* all sysctl names at this level are terminal */
110 if (namelen != 1)
111 return (ENOTDIR); /* overloaded */
112
113 switch (name[0]) {
114 case GPROF_STATE:
119 error = sysctl_int(oldp, oldlenp, newp, newlen, &gp->state);
115 error = sysctl_handle_int(oidp, &gp->state, 0, req);
120 if (error)
121 return (error);
122 if (gp->state == GMON_PROF_OFF)
123 stopprofclock(&proc0);
124 else
125 startprofclock(&proc0);
126 return (0);
127 case GPROF_COUNT:
116 if (error)
117 return (error);
118 if (gp->state == GMON_PROF_OFF)
119 stopprofclock(&proc0);
120 else
121 startprofclock(&proc0);
122 return (0);
123 case GPROF_COUNT:
128 return (sysctl_struct(oldp, oldlenp, newp, newlen,
129 gp->kcount, gp->kcountsize));
124 return (sysctl_handle_opaque(oidp,
125 gp->kcount, gp->kcountsize, req));
130 case GPROF_FROMS:
126 case GPROF_FROMS:
131 return (sysctl_struct(oldp, oldlenp, newp, newlen,
132 gp->froms, gp->fromssize));
127 return (sysctl_handle_opaque(oidp,
128 gp->froms, gp->fromssize, req));
133 case GPROF_TOS:
129 case GPROF_TOS:
134 return (sysctl_struct(oldp, oldlenp, newp, newlen,
135 gp->tos, gp->tossize));
130 return (sysctl_handle_opaque(oidp,
131 gp->tos, gp->tossize, req));
136 case GPROF_GMONPARAM:
132 case GPROF_GMONPARAM:
137 return (sysctl_rdstruct(oldp, oldlenp, newp, gp, sizeof *gp));
133 return (sysctl_handle_opaque(oidp, gp, sizeof *gp, req));
138 default:
139 return (EOPNOTSUPP);
140 }
141 /* NOTREACHED */
142}
134 default:
135 return (EOPNOTSUPP);
136 }
137 /* NOTREACHED */
138}
139
140SYSCTL_NODE(_kern, KERN_PROF, prof, CTLFLAG_RW, sysctl_kern_prof, "");
143#endif /* GPROF */
144
145/*
146 * Profiling system call.
147 *
148 * The scale factor is a fixed point number with 16 bits of fraction, so that
149 * 1.0 is represented as 0x10000. A scale factor of 0 turns off profiling.
150 */

--- 118 unchanged lines hidden ---
141#endif /* GPROF */
142
143/*
144 * Profiling system call.
145 *
146 * The scale factor is a fixed point number with 16 bits of fraction, so that
147 * 1.0 is represented as 0x10000. A scale factor of 0 turns off profiling.
148 */

--- 118 unchanged lines hidden ---