diff options
Diffstat (limited to 'usr/src')
-rwxr-xr-x | usr/src/cmd/dtrace/demo/mkdemo.pl | 9 | ||||
-rw-r--r-- | usr/src/cmd/dtrace/test/tst/common/Makefile | 13 | ||||
-rw-r--r-- | usr/src/cmd/dtrace/test/tst/common/pid/tst.main.ksh | 59 | ||||
-rw-r--r-- | usr/src/cmd/dtrace/test/tst/common/usdt/forker.d | 31 | ||||
-rw-r--r-- | usr/src/cmd/dtrace/test/tst/common/usdt/tst.forker.c | 47 | ||||
-rw-r--r-- | usr/src/cmd/dtrace/test/tst/common/usdt/tst.forker.ksh | 55 | ||||
-rw-r--r-- | usr/src/lib/libdtrace/common/dt_pid.c | 12 | ||||
-rw-r--r-- | usr/src/lib/libdtrace/common/dt_proc.c | 15 | ||||
-rw-r--r-- | usr/src/lib/libdtrace/common/dt_proc.h | 10 | ||||
-rw-r--r-- | usr/src/pkgdefs/SUNWdtrt/prototype_com | 3 | ||||
-rw-r--r-- | usr/src/uts/common/os/fork.c | 15 |
11 files changed, 239 insertions, 30 deletions
diff --git a/usr/src/cmd/dtrace/demo/mkdemo.pl b/usr/src/cmd/dtrace/demo/mkdemo.pl index e75813cec5..9c3919850b 100755 --- a/usr/src/cmd/dtrace/demo/mkdemo.pl +++ b/usr/src/cmd/dtrace/demo/mkdemo.pl @@ -3,9 +3,8 @@ # CDDL HEADER START # # The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. @@ -21,7 +20,7 @@ # CDDL HEADER END # # -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" @@ -193,7 +192,7 @@ sub chaps_process { print HTML "<td><table border=0>\n"; - foreach $demo (@demos) { + foreach $demo (sort(@demos)) { if ($demo !~ /^[a-z].*\.d$/) { next; } diff --git a/usr/src/cmd/dtrace/test/tst/common/Makefile b/usr/src/cmd/dtrace/test/tst/common/Makefile index d6a2827d85..ebdec272d7 100644 --- a/usr/src/cmd/dtrace/test/tst/common/Makefile +++ b/usr/src/cmd/dtrace/test/tst/common/Makefile @@ -60,5 +60,18 @@ usdt/tst.argmap.exe: usdt/tst.argmap.o usdt/argmap.o usdt/argmap.o: usdt/argmap.d usdt/tst.argmap.o $(COMPILE.d) -o usdt/argmap.o -s usdt/argmap.d usdt/tst.argmap.o +usdt/tst.forker.exe: usdt/tst.forker.o usdt/forker.o + $(LINK.c) -o usdt/tst.forker.exe usdt/tst.forker.o usdt/forker.o \ + $(LDLIBS) + $(POST_PROCESS) ; $(STRIP_STABS) + +usdt/forker.o: usdt/forker.d usdt/tst.forker.o + $(COMPILE.d) -o usdt/forker.o -s usdt/forker.d usdt/tst.forker.o + +usdt/tst.forker.o: usdt/forker.h + +usdt/forker.h: usdt/forker.d + $(DTRACE) -h -s usdt/forker.d -o usdt/forker.h + SUBDIRS = java_api include ../../Makefile.subdirs diff --git a/usr/src/cmd/dtrace/test/tst/common/pid/tst.main.ksh b/usr/src/cmd/dtrace/test/tst/common/pid/tst.main.ksh new file mode 100644 index 0000000000..b3b9960140 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/pid/tst.main.ksh @@ -0,0 +1,59 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +# +# Make sure we can trace main:entry properly -- this was problematic because +# we also set a breakpoint on the same spot in libdtrace. +# + +$dtrace -c date -s /dev/stdin <<EOF + BEGIN + { + status = 1; + } + + pid\$target::main:entry + { + status = 0; + } + + END + { + exit(status); + } +EOF + +exit $? diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/forker.d b/usr/src/cmd/dtrace/test/tst/common/usdt/forker.d new file mode 100644 index 0000000000..f63b965df2 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/forker.d @@ -0,0 +1,31 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +provider forker { + probe fire(); +}; diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.forker.c b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.forker.c new file mode 100644 index 0000000000..ade7f83b3d --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.forker.c @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <unistd.h> + +#include "forker.h" + +int +main(int argc, char **argv) +{ + int i; + + for (i = 0; i < 10000; i++) { + FORKER_FIRE(); + if (fork() == 0) + exit(0); + + (void) wait(NULL); + } + + return (0); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.forker.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.forker.ksh new file mode 100644 index 0000000000..b2a8721b3c --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.forker.ksh @@ -0,0 +1,55 @@ +#!/usr/bin/ksh +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +# +# Test that we don't deadlock between forking and enabling/disabling USDT +# probes. This test has succeeded if it completes at all. +# + +./tst.forker.exe & +id=$! + +while kill -0 $id >/dev/null 2>&1; do + $dtrace -s /dev/stdin <<-EOF + forker*:::fire + /i++ == 4/ + { + exit(0); + } + EOF +done + +exit 0 diff --git a/usr/src/lib/libdtrace/common/dt_pid.c b/usr/src/lib/libdtrace/common/dt_pid.c index 07378e29ea..f16e742cdd 100644 --- a/usr/src/lib/libdtrace/common/dt_pid.c +++ b/usr/src/lib/libdtrace/common/dt_pid.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -440,11 +440,6 @@ dt_pid_create_pid_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pid_probe_t pp; int ret = 0; - /* - * Disable breakpoints so they don't interfere with our disassembly. - */ - dt_proc_bpdisable(dpr); - pp.dpp_dtp = dtp; pp.dpp_dpr = dpr; pp.dpp_pr = dpr->dpr_proc; @@ -455,7 +450,6 @@ dt_pid_create_pid_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, * hidden some magic in ld.so.1 as well as libc.so.1). */ if (Pname_to_map(pp.dpp_pr, PR_OBJ_LDSO) == NULL) { - dt_proc_bpenable(dpr); return (dt_pid_error(dtp, pcb, dpr, NULL, D_PROC_DYN, "process %s is not a dynamically-linked executable", &pdp->dtpd_provider[3])); @@ -476,14 +470,12 @@ dt_pid_create_pid_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, (aout = Pname_to_map(pp.dpp_pr, "a.out")) == NULL || (pmp = Pname_to_map(pp.dpp_pr, pp.dpp_mod)) == NULL || aout->pr_vaddr != pmp->pr_vaddr) { - dt_proc_bpenable(dpr); return (dt_pid_error(dtp, pcb, dpr, NULL, D_PROC_LIB, "only the a.out module is valid with the " "'-' function")); } if (strisglob(pp.dpp_name)) { - dt_proc_bpenable(dpr); return (dt_pid_error(dtp, pcb, dpr, NULL, D_PROC_NAME, "only individual addresses may be specified " "with the '-' function")); @@ -516,8 +508,6 @@ dt_pid_create_pid_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, } } - dt_proc_bpenable(dpr); - return (ret); } diff --git a/usr/src/lib/libdtrace/common/dt_proc.c b/usr/src/lib/libdtrace/common/dt_proc.c index 3d739a7b06..419f13b847 100644 --- a/usr/src/lib/libdtrace/common/dt_proc.c +++ b/usr/src/lib/libdtrace/common/dt_proc.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -162,7 +162,7 @@ dt_proc_bpmatch(dtrace_hdl_t *dtp, dt_proc_t *dpr) (void) Pxecbkpt(dpr->dpr_proc, dbp->dbp_instr); } -void +static void dt_proc_bpenable(dt_proc_t *dpr) { dt_bkpt_t *dbp; @@ -179,7 +179,7 @@ dt_proc_bpenable(dt_proc_t *dpr) dt_dprintf("breakpoints enabled\n"); } -void +static void dt_proc_bpdisable(dt_proc_t *dpr) { dt_bkpt_t *dbp; @@ -241,8 +241,17 @@ dt_proc_stop(dt_proc_t *dpr, uint8_t why) (void) pthread_cond_broadcast(&dpr->dpr_cv); + /* + * We disable breakpoints while stopped to preserve the + * integrity of the program text for both our own disassembly + * and that of the kernel. + */ + dt_proc_bpdisable(dpr); + while (dpr->dpr_stop & DT_PROC_STOP_IDLE) (void) pthread_cond_wait(&dpr->dpr_cv, &dpr->dpr_lock); + + dt_proc_bpenable(dpr); } } diff --git a/usr/src/lib/libdtrace/common/dt_proc.h b/usr/src/lib/libdtrace/common/dt_proc.h index fbc6f4aec1..a3236694b2 100644 --- a/usr/src/lib/libdtrace/common/dt_proc.h +++ b/usr/src/lib/libdtrace/common/dt_proc.h @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -21,7 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -107,9 +106,6 @@ extern void dt_proc_lock(dtrace_hdl_t *, struct ps_prochandle *); extern void dt_proc_unlock(dtrace_hdl_t *, struct ps_prochandle *); extern dt_proc_t *dt_proc_lookup(dtrace_hdl_t *, struct ps_prochandle *, int); -extern void dt_proc_bpenable(dt_proc_t *); -extern void dt_proc_bpdisable(dt_proc_t *); - extern void dt_proc_hash_create(dtrace_hdl_t *); extern void dt_proc_hash_destroy(dtrace_hdl_t *); diff --git a/usr/src/pkgdefs/SUNWdtrt/prototype_com b/usr/src/pkgdefs/SUNWdtrt/prototype_com index ffd31e83e7..8eb1b75ceb 100644 --- a/usr/src/pkgdefs/SUNWdtrt/prototype_com +++ b/usr/src/pkgdefs/SUNWdtrt/prototype_com @@ -664,6 +664,7 @@ f none SUNWdtrt/tst/common/pid/tst.fork.d 0444 root bin f none SUNWdtrt/tst/common/pid/tst.fork.exe 0555 root bin f none SUNWdtrt/tst/common/pid/tst.gcc.d 0444 root bin f none SUNWdtrt/tst/common/pid/tst.gcc.exe 0555 root bin +f none SUNWdtrt/tst/common/pid/tst.main.ksh 0444 root bin f none SUNWdtrt/tst/common/pid/tst.manypids.ksh 0444 root bin f none SUNWdtrt/tst/common/pid/tst.probemod.ksh 0444 root bin f none SUNWdtrt/tst/common/pid/tst.ret1.d 0444 root bin @@ -1330,6 +1331,8 @@ f none SUNWdtrt/tst/common/usdt/tst.dlclose2.ksh 0444 root bin f none SUNWdtrt/tst/common/usdt/tst.dlclose2.ksh.out 0444 root bin f none SUNWdtrt/tst/common/usdt/tst.fork.ksh 0444 root bin f none SUNWdtrt/tst/common/usdt/tst.fork.ksh.out 0444 root bin +f none SUNWdtrt/tst/common/usdt/tst.forker.exe 0555 root bin +f none SUNWdtrt/tst/common/usdt/tst.forker.ksh 0444 root bin f none SUNWdtrt/tst/common/usdt/tst.guess32.ksh 0444 root bin f none SUNWdtrt/tst/common/usdt/tst.guess64.ksh 0444 root bin f none SUNWdtrt/tst/common/usdt/tst.header.ksh 0444 root bin diff --git a/usr/src/uts/common/os/fork.c b/usr/src/uts/common/os/fork.c index 77c22aa7bb..8e11ec7437 100644 --- a/usr/src/uts/common/os/fork.c +++ b/usr/src/uts/common/os/fork.c @@ -328,13 +328,20 @@ cfork(int isvfork, int isfork1, int flags) * sprlock() may fail because the child is being forked. */ if (p->p_dtrace_helpers != NULL) { + mutex_enter(&p->p_lock); + sprunlock(p); + ASSERT(dtrace_helpers_fork != NULL); (*dtrace_helpers_fork)(p, cp); - } - mutex_enter(&p->p_lock); - p->p_flag &= ~SFORKING; - sprunlock(p); + mutex_enter(&p->p_lock); + p->p_flag &= ~SFORKING; + mutex_exit(&p->p_lock); + } else { + mutex_enter(&p->p_lock); + p->p_flag &= ~SFORKING; + sprunlock(p); + } } /* |