4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2013, Joyent, Inc. All rights reserved.
25 */
26
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
29
30 #include <sys/types.h>
31 #include <sys/t_lock.h>
32 #include <sys/param.h>
33 #include <sys/cmn_err.h>
34 #include <sys/cred.h>
35 #include <sys/priv.h>
36 #include <sys/debug.h>
37 #include <sys/errno.h>
38 #include <sys/inline.h>
39 #include <sys/kmem.h>
40 #include <sys/mman.h>
41 #include <sys/proc.h>
42 #include <sys/brand.h>
43 #include <sys/sobject.h>
44 #include <sys/sysmacros.h>
184 break;
185 case PR_JOBCONTROL:
186 if (t->t_proc_flag & TP_PRSTOP) {
187 if (t_jdstop == NULL)
188 t_jdstop = t;
189 } else {
190 if (t_jstop == NULL)
191 t_jstop = t;
192 }
193 break;
194 case PR_REQUESTED:
195 if (t->t_dtrace_stop && t_dtrace == NULL)
196 t_dtrace = t;
197 else if (t_req == NULL)
198 t_req = t;
199 break;
200 case PR_SYSENTRY:
201 case PR_SYSEXIT:
202 case PR_SIGNALLED:
203 case PR_FAULTED:
204 /*
205 * Make an lwp calling exit() be the
206 * last lwp seen in the process.
207 */
208 if (t_istop == NULL ||
209 (t_istop->t_whystop == PR_SYSENTRY &&
210 t_istop->t_whatstop == SYS_exit))
211 t_istop = t;
212 break;
213 case PR_CHECKPOINT: /* can't happen? */
214 break;
215 default:
216 panic("prchoose: bad t_whystop %d, thread 0x%p",
217 t->t_whystop, (void *)t);
218 /*NOTREACHED*/
219 }
220 break;
221 }
222 thread_unlock(t);
223 } while ((t = t->t_forw) != p->p_tlist);
517 pnp->pr_common->prc_datamodel = model;
518 }
519 }
520 if ((vp = p->p_lwpdir[tslot].ld_entry->le_trace) != NULL) {
521 /*
522 * We dealt with the process common above.
523 */
524 ASSERT(p->p_trace != NULL);
525 pcp = VTOP(vp)->pr_common;
526 mutex_enter(&pcp->prc_mutex);
527 cv_broadcast(&pcp->prc_wait);
528 mutex_exit(&pcp->prc_mutex);
529 for (; vp != NULL; vp = pnp->pr_next) {
530 pnp = VTOP(vp);
531 pcp = pnp->pr_common;
532 pcp->prc_datamodel = model;
533 pcp->prc_tid = tid;
534 pcp->prc_tslot = tslot;
535 }
536 }
537 }
538
539 /*
540 * Called from a hook in relvm() just before freeing the address space.
541 * We free all the watched areas now.
542 */
543 void
544 prrelvm(void)
545 {
546 proc_t *p = ttoproc(curthread);
547
548 mutex_enter(&p->p_lock);
549 prbarrier(p); /* block all other /proc operations */
550 if (pr_watch_active(p)) {
551 pr_free_watchpoints(p);
552 watch_disable(curthread);
553 }
554 mutex_exit(&p->p_lock);
555 pr_free_watched_pages(p);
556 }
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2016, Joyent, Inc.
25 */
26
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
29
30 #include <sys/types.h>
31 #include <sys/t_lock.h>
32 #include <sys/param.h>
33 #include <sys/cmn_err.h>
34 #include <sys/cred.h>
35 #include <sys/priv.h>
36 #include <sys/debug.h>
37 #include <sys/errno.h>
38 #include <sys/inline.h>
39 #include <sys/kmem.h>
40 #include <sys/mman.h>
41 #include <sys/proc.h>
42 #include <sys/brand.h>
43 #include <sys/sobject.h>
44 #include <sys/sysmacros.h>
184 break;
185 case PR_JOBCONTROL:
186 if (t->t_proc_flag & TP_PRSTOP) {
187 if (t_jdstop == NULL)
188 t_jdstop = t;
189 } else {
190 if (t_jstop == NULL)
191 t_jstop = t;
192 }
193 break;
194 case PR_REQUESTED:
195 if (t->t_dtrace_stop && t_dtrace == NULL)
196 t_dtrace = t;
197 else if (t_req == NULL)
198 t_req = t;
199 break;
200 case PR_SYSENTRY:
201 case PR_SYSEXIT:
202 case PR_SIGNALLED:
203 case PR_FAULTED:
204 case PR_BRAND:
205 /*
206 * Make an lwp calling exit() be the
207 * last lwp seen in the process.
208 */
209 if (t_istop == NULL ||
210 (t_istop->t_whystop == PR_SYSENTRY &&
211 t_istop->t_whatstop == SYS_exit))
212 t_istop = t;
213 break;
214 case PR_CHECKPOINT: /* can't happen? */
215 break;
216 default:
217 panic("prchoose: bad t_whystop %d, thread 0x%p",
218 t->t_whystop, (void *)t);
219 /*NOTREACHED*/
220 }
221 break;
222 }
223 thread_unlock(t);
224 } while ((t = t->t_forw) != p->p_tlist);
518 pnp->pr_common->prc_datamodel = model;
519 }
520 }
521 if ((vp = p->p_lwpdir[tslot].ld_entry->le_trace) != NULL) {
522 /*
523 * We dealt with the process common above.
524 */
525 ASSERT(p->p_trace != NULL);
526 pcp = VTOP(vp)->pr_common;
527 mutex_enter(&pcp->prc_mutex);
528 cv_broadcast(&pcp->prc_wait);
529 mutex_exit(&pcp->prc_mutex);
530 for (; vp != NULL; vp = pnp->pr_next) {
531 pnp = VTOP(vp);
532 pcp = pnp->pr_common;
533 pcp->prc_datamodel = model;
534 pcp->prc_tid = tid;
535 pcp->prc_tslot = tslot;
536 }
537 }
538
539 /*
540 * There may be threads waiting for the flag change blocked behind the
541 * pr_pid_cv as well.
542 */
543 cv_signal(&pr_pid_cv[p->p_slot]);
544 }
545
546 /*
547 * Called from a hook in relvm() just before freeing the address space.
548 * We free all the watched areas now.
549 */
550 void
551 prrelvm(void)
552 {
553 proc_t *p = ttoproc(curthread);
554
555 mutex_enter(&p->p_lock);
556 prbarrier(p); /* block all other /proc operations */
557 if (pr_watch_active(p)) {
558 pr_free_watchpoints(p);
559 watch_disable(curthread);
560 }
561 mutex_exit(&p->p_lock);
562 pr_free_watched_pages(p);
563 }
|