4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1998, Sun Microsystems, Inc.
24 * All rights reserved.
25 * Copyright 2012 Milan Jurik. All rights reserved.
28 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
29 /* All Rights Reserved */
31 #include <sys/param.h>
32 #include <sys/types.h>
33 #include <sys/sysmacros.h>
34 #include <sys/systm.h>
35 #include <sys/errno.h>
37 #include <sys/debug.h>
43 profil(unsigned short *bufbase
, size_t bufsize
, ulong_t pcoffset
,
46 struct proc
*p
= ttoproc(curthread
);
51 mutex_enter(&p
->p_pflock
);
52 p
->p_prof
.pr_base
= bufbase
;
53 p
->p_prof
.pr_size
= bufsize
;
54 p
->p_prof
.pr_off
= pcoffset
;
55 p
->p_prof
.pr_scale
= pcscale
;
57 /* pcsample and profil are mutually exclusive */
58 p
->p_prof
.pr_samples
= 0;
60 mutex_exit(&p
->p_pflock
);
61 mutex_enter(&p
->p_lock
);
62 set_proc_post_sys(p
); /* activate post_syscall profiling code */
63 mutex_exit(&p
->p_lock
);
72 pcsample(void *buf
, long nsamples
)
74 struct proc
*p
= ttoproc(curthread
);
78 ((get_udatamodel() != DATAMODEL_NATIVE
) && (nsamples
> INT32_MAX
)))
79 return (set_errno(EINVAL
));
81 mutex_enter(&p
->p_pflock
);
82 p
->p_prof
.pr_base
= buf
;
83 p
->p_prof
.pr_size
= nsamples
;
84 p
->p_prof
.pr_scale
= 1;
85 count
= p
->p_prof
.pr_samples
;
86 p
->p_prof
.pr_samples
= 0;
87 mutex_exit(&p
->p_pflock
);
89 mutex_enter(&p
->p_lock
);
90 set_proc_post_sys(p
); /* activate post_syscall profiling code */
91 mutex_exit(&p
->p_lock
);