diff --git a/Scripts/Mac/Tracing/Docs/cddl1.txt b/Scripts/Mac/Tracing/Docs/cddl1.txt new file mode 100644 index 00000000..b3487ade --- /dev/null +++ b/Scripts/Mac/Tracing/Docs/cddl1.txt @@ -0,0 +1,385 @@ + +COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 + + + 1. Definitions. + + 1.1. Contributor means each individual or entity that + creates or contributes to the creation of Modifications. + + 1.2. Contributor Version means the combination of the + Original Software, prior Modifications used by a + Contributor (if any), and the Modifications made by that + particular Contributor. + + 1.3. Covered Software means (a) the Original Software, or + (b) Modifications, or (c) the combination of files + containing Original Software with files containing + Modifications, in each case including portions thereof. + + 1.4. Executable means the Covered Software in any form + other than Source Code. + + 1.5. Initial Developer means the individual or entity + that first makes Original Software available under this + License. + + 1.6. Larger Work means a work which combines Covered + Software or portions thereof with code not governed by the + terms of this License. + + 1.7. License means this document. + + 1.8. Licensable means having the right to grant, to the + maximum extent possible, whether at the time of the initial + grant or subsequently acquired, any and all of the rights + conveyed herein. + + 1.9. Modifications means the Source Code and Executable + form of any of the following: + + A. Any file that results from an addition to, + deletion from or modification of the contents of a + file containing Original Software or previous + Modifications; + + B. Any new file that contains any part of the + Original Software or previous Modification; or + + C. Any new file that is contributed or otherwise made + available under the terms of this License. + + 1.10. Original Software means the Source Code and + Executable form of computer software code that is + originally released under this License. + + 1.11. Patent Claims means any patent claim(s), now owned + or hereafter acquired, including without limitation, + method, process, and apparatus claims, in any patent + Licensable by grantor. + + 1.12. Source Code means (a) the common form of computer + software code in which modifications are made and (b) + associated documentation included in or with such code. + + 1.13. You (or Your) means an individual or a legal + entity exercising rights under, and complying with all of + the terms of, this License. For legal entities, You + includes any entity which controls, is controlled by, or is + under common control with You. For purposes of this + definition, control means (a) the power, direct or + indirect, to cause the direction or management of such + entity, whether by contract or otherwise, or (b) ownership + of more than fifty percent (50%) of the outstanding shares + or beneficial ownership of such entity. + + 2. License Grants. + + 2.1. The Initial Developer Grant. + + Conditioned upon Your compliance with Section 3.1 below and + subject to third party intellectual property claims, the + Initial Developer hereby grants You a world-wide, + royalty-free, non-exclusive license: + + (a) under intellectual property rights (other than + patent or trademark) Licensable by Initial Developer, + to use, reproduce, modify, display, perform, + sublicense and distribute the Original Software (or + portions thereof), with or without Modifications, + and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, + using or selling of Original Software, to make, have + made, use, practice, sell, and offer for sale, and/or + otherwise dispose of the Original Software (or + portions thereof). + + (c) The licenses granted in Sections 2.1(a) and (b) + are effective on the date Initial Developer first + distributes or otherwise makes the Original Software + available to a third party under the terms of this + License. + + (d) Notwithstanding Section 2.1(b) above, no patent + license is granted: (1) for code that You delete from + the Original Software, or (2) for infringements + caused by: (i) the modification of the Original + Software, or (ii) the combination of the Original + Software with other software or devices. + + 2.2. Contributor Grant. + + Conditioned upon Your compliance with Section 3.1 below and + subject to third party intellectual property claims, each + Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + (a) under intellectual property rights (other than + patent or trademark) Licensable by Contributor to + use, reproduce, modify, display, perform, sublicense + and distribute the Modifications created by such + Contributor (or portions thereof), either on an + unmodified basis, with other Modifications, as + Covered Software and/or as part of a Larger Work; and + + + (b) under Patent Claims infringed by the making, + using, or selling of Modifications made by that + Contributor either alone and/or in combination with + its Contributor Version (or portions of such + combination), to make, use, sell, offer for sale, + have made, and/or otherwise dispose of: (1) + Modifications made by that Contributor (or portions + thereof); and (2) the combination of Modifications + made by that Contributor with its Contributor Version + (or portions of such combination). + + (c) The licenses granted in Sections 2.2(a) and + 2.2(b) are effective on the date Contributor first + distributes or otherwise makes the Modifications + available to a third party. + + (d) Notwithstanding Section 2.2(b) above, no patent + license is granted: (1) for any code that Contributor + has deleted from the Contributor Version; (2) for + infringements caused by: (i) third party + modifications of Contributor Version, or (ii) the + combination of Modifications made by that Contributor + with other software (except as part of the + Contributor Version) or other devices; or (3) under + Patent Claims infringed by Covered Software in the + absence of Modifications made by that Contributor. + + 3. Distribution Obligations. + + 3.1. Availability of Source Code. + + Any Covered Software that You distribute or otherwise make + available in Executable form must also be made available in + Source Code form and that Source Code form must be + distributed only under the terms of this License. You must + include a copy of this License with every copy of the + Source Code form of the Covered Software You distribute or + otherwise make available. You must inform recipients of any + such Covered Software in Executable form as to how they can + obtain such Covered Software in Source Code form in a + reasonable manner on or through a medium customarily used + for software exchange. + + 3.2. Modifications. + + The Modifications that You create or to which You + contribute are governed by the terms of this License. You + represent that You believe Your Modifications are Your + original creation(s) and/or You have sufficient rights to + grant the rights conveyed by this License. + + 3.3. Required Notices. + + You must include a notice in each of Your Modifications + that identifies You as the Contributor of the Modification. + You may not remove or alter any copyright, patent or + trademark notices contained within the Covered Software, or + any notices of licensing or any descriptive text giving + attribution to any Contributor or the Initial Developer. + + 3.4. Application of Additional Terms. + + You may not offer or impose any terms on any Covered + Software in Source Code form that alters or restricts the + applicable version of this License or the recipients + rights hereunder. You may choose to offer, and to charge a + fee for, warranty, support, indemnity or liability + obligations to one or more recipients of Covered Software. + However, you may do so only on Your own behalf, and not on + behalf of the Initial Developer or any Contributor. You + must make it absolutely clear that any such warranty, + support, indemnity or liability obligation is offered by + You alone, and You hereby agree to indemnify the Initial + Developer and every Contributor for any liability incurred + by the Initial Developer or such Contributor as a result of + warranty, support, indemnity or liability terms You offer. + + + 3.5. Distribution of Executable Versions. + + You may distribute the Executable form of the Covered + Software under the terms of this License or under the terms + of a license of Your choice, which may contain terms + different from this License, provided that You are in + compliance with the terms of this License and that the + license for the Executable form does not attempt to limit + or alter the recipients rights in the Source Code form + from the rights set forth in this License. If You + distribute the Covered Software in Executable form under a + different license, You must make it absolutely clear that + any terms which differ from this License are offered by You + alone, not by the Initial Developer or Contributor. You + hereby agree to indemnify the Initial Developer and every + Contributor for any liability incurred by the Initial + Developer or such Contributor as a result of any such terms + You offer. + + 3.6. Larger Works. + + You may create a Larger Work by combining Covered Software + with other code not governed by the terms of this License + and distribute the Larger Work as a single product. In such + a case, You must make sure the requirements of this License + are fulfilled for the Covered Software. + + 4. Versions of the License. + + 4.1. New Versions. + + Sun Microsystems, Inc. is the initial license steward and + may publish revised and/or new versions of this License + from time to time. Each version will be given a + distinguishing version number. Except as provided in + Section 4.3, no one other than the license steward has the + right to modify this License. + + 4.2. Effect of New Versions. + + You may always continue to use, distribute or otherwise + make the Covered Software available under the terms of the + version of the License under which You originally received + the Covered Software. If the Initial Developer includes a + notice in the Original Software prohibiting it from being + distributed or otherwise made available under any + subsequent version of the License, You must distribute and + make the Covered Software available under the terms of the + version of the License under which You originally received + the Covered Software. Otherwise, You may also choose to + use, distribute or otherwise make the Covered Software + available under the terms of any subsequent version of the + License published by the license steward. + + 4.3. Modified Versions. + + When You are an Initial Developer and You want to create a + new license for Your Original Software, You may create and + use a modified version of this License if You: (a) rename + the license and remove any references to the name of the + license steward (except to note that the license differs + from this License); and (b) otherwise make it clear that + the license contains terms which differ from this License. + + + 5. DISCLAIMER OF WARRANTY. + + COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN AS IS + BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, + INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED + SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR + PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND + PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY + COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE + INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF + ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF + WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF + ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS + DISCLAIMER. + + 6. TERMINATION. + + 6.1. This License and the rights granted hereunder will + terminate automatically if You fail to comply with terms + herein and fail to cure such breach within 30 days of + becoming aware of the breach. Provisions which, by their + nature, must remain in effect beyond the termination of + this License shall survive. + + 6.2. If You assert a patent infringement claim (excluding + declaratory judgment actions) against Initial Developer or + a Contributor (the Initial Developer or Contributor against + whom You assert such claim is referred to as Participant) + alleging that the Participant Software (meaning the + Contributor Version where the Participant is a Contributor + or the Original Software where the Participant is the + Initial Developer) directly or indirectly infringes any + patent, then any and all rights granted directly or + indirectly to You by such Participant, the Initial + Developer (if the Initial Developer is not the Participant) + and all Contributors under Sections 2.1 and/or 2.2 of this + License shall, upon 60 days notice from Participant + terminate prospectively and automatically at the expiration + of such 60 day notice period, unless if within such 60 day + period You withdraw Your claim with respect to the + Participant Software against such Participant either + unilaterally or pursuant to a written agreement with + Participant. + + 6.3. In the event of termination under Sections 6.1 or 6.2 + above, all end user licenses that have been validly granted + by You or any distributor hereunder prior to termination + (excluding licenses granted to You by any distributor) + shall survive termination. + + 7. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT + (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE + INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF + COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE + LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR + CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT + LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK + STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER + COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN + INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF + LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL + INJURY RESULTING FROM SUCH PARTYS NEGLIGENCE TO THE EXTENT + APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO + NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR + CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT + APPLY TO YOU. + + 8. U.S. GOVERNMENT END USERS. + + The Covered Software is a commercial item, as that term is + defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of commercial + computer software (as that term is defined at 48 C.F.R. + 252.227-7014(a)(1)) and commercial computer software + documentation as such terms are used in 48 C.F.R. 12.212 (Sept. + 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 + through 227.7202-4 (June 1995), all U.S. Government End Users + acquire Covered Software with only those rights set forth herein. + This U.S. Government Rights clause is in lieu of, and supersedes, + any other FAR, DFAR, or other clause or provision that addresses + Government rights in computer software under this License. + + 9. MISCELLANEOUS. + + This License represents the complete agreement concerning subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the + extent necessary to make it enforceable. This License shall be + governed by the law of the jurisdiction specified in a notice + contained within the Original Software (except to the extent + applicable law, if any, provides otherwise), excluding such + jurisdictions conflict-of-law provisions. Any litigation + relating to this License shall be subject to the jurisdiction of + the courts located in the jurisdiction and venue specified in a + notice contained within the Original Software, with the losing + party responsible for costs, including, without limitation, court + costs and reasonable attorneys fees and expenses. The + application of the United Nations Convention on Contracts for the + International Sale of Goods is expressly excluded. Any law or + regulation which provides that the language of a contract shall + be construed against the drafter shall not apply to this License. + You agree that You alone are responsible for compliance with the + United States export administration regulations (and the export + control laws and regulation of any other countries) when You use, + distribute or otherwise make available any Covered Software. + + 10. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is + responsible for claims and damages arising, directly or + indirectly, out of its utilization of rights under this License + and You agree to work with Initial Developer and Contributors to + distribute such responsibility on an equitable basis. Nothing + herein is intended or shall be deemed to constitute any admission + of liability. diff --git a/Scripts/Mac/Tracing/dtruss b/Scripts/Mac/Tracing/dtruss new file mode 100755 index 00000000..b0513d15 --- /dev/null +++ b/Scripts/Mac/Tracing/dtruss @@ -0,0 +1,1045 @@ +#!/bin/sh +# #!/usr/bin/sh +# +# dtruss - print process system call time details. +# Written using DTrace (Solaris 10 3/05). +# +# 17-Jun-2005, ver 0.80 (check for newer versions) +# +# USAGE: dtruss [-acdeflhoLs] [-t syscall] { -p PID | -n name | command } +# +# -p PID # examine this PID +# -n name # examine this process name +# -t syscall # examine this syscall only +# -a # print all details +# -c # print system call counts +# -d # print relative timestamps (us) +# -e # print elapsed times (us) +# -f # follow children as they are forked +# -l # force printing of pid/lwpid per line +# -o # print on cpu times (us) +# -s # print stack backtraces +# -L # don't print pid/lwpid per line +# -b bufsize # dynamic variable buf size (default is "4m") +# eg, +# dtruss df -h # run and examine the "df -h" command +# dtruss -p 1871 # examine PID 1871 +# dtruss -n tar # examine all processes called "tar" +# dtruss -f test.sh # run test.sh and follow children +# +# The elapsed times are interesting, to help identify syscalls that take +# some time to complete (during which the process may have context +# switched off the CPU). +# +# SEE ALSO: procsystime # DTraceToolkit +# dapptrace # DTraceToolkit +# truss +# +# COPYRIGHT: Copyright (c) 2005 Brendan Gregg. +# +# 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. +# +# You can obtain a copy of the license at Docs/cddl1.txt +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# CDDL HEADER END +# +# Author: Brendan Gregg [Sydney, Australia] +# +# TODO: Track signals, more output formatting. +# +# 29-Apr-2005 Brendan Gregg Created this. +# 09-May-2005 " " Fixed evaltime (thanks Adam L.) +# 16-May-2005 " " Added -t syscall tracing. +# 17-Jun-2005 " " Added -s stack backtraces. +# + + +############################## +# --- Process Arguments --- +# + +### Default variables +opt_pid=0; opt_name=0; pid=0; pname="." +opt_elapsed=0; opt_cpu=0; opt_counts=0; +opt_relative=0; opt_printid=0; opt_follow=0 +opt_command=0; command=""; opt_buf=0; buf="4m" +opt_trace=0; trace="."; opt_stack=0; +opt_wait=0; wname="."; opt_has_target=0 +### Process options +while getopts ab:cdefhln:op:st:LW: name +do + case $name in + b) opt_buf=1; buf=$OPTARG ;; + p) opt_pid=1; pid=$OPTARG ;; + n) opt_name=1; pname=$OPTARG ;; + W) opt_wait=1; wname=$OPTARG ;; + t) opt_trace=1; trace=$OPTARG ;; + a) opt_counts=1; opt_relative=1; opt_elapsed=1; opt_follow=1 + opt_printid=1; opt_cpu=1 ;; + c) opt_counts=1 ;; + d) opt_relative=1 ;; + e) opt_elapsed=1 ;; + f) opt_follow=1 ;; + l) opt_printid=1 ;; + o) opt_cpu=1 ;; + L) opt_printid=-1 ;; + s) opt_stack=-1 ;; + h|?) cat <<-END >&2 + USAGE: dtruss [-acdefholLs] [-t syscall] { -p PID | -n name | command | -W name } + + -p PID # examine this PID + -n name # examine this process name + -t syscall # examine this syscall only + -W name # wait for a process matching this name + -a # print all details + -c # print syscall counts + -d # print relative times (us) + -e # print elapsed times (us) + -f # follow children + -l # force printing pid/lwpid + -o # print on cpu times + -s # print stack backtraces + -L # don't print pid/lwpid + -b bufsize # dynamic variable buf size + eg, + dtruss df -h # run and examine "df -h" + dtruss -p 1871 # examine PID 1871 + dtruss -n tar # examine all processes called "tar" + dtruss -f test.sh # run test.sh and follow children + END + exit 1 + esac +done +shift `expr $OPTIND - 1` + +### Option logic +if [ $opt_pid -eq 0 -a $opt_name -eq 0 -a $opt_wait -eq 0 ]; then + opt_has_target=1 + opt_command=1 + if [ "$*" = "" ]; then + $0 -h + exit + fi + command="$*" # yes, I meant $*! +fi +if [ $opt_wait -eq 1 ]; then + opt_has_target=1 +fi +if [ $opt_follow -eq 1 -o $opt_name -eq 1 ]; then + if [ $opt_printid -ne -1 ]; then + opt_printid=1 + else + opt_printid=0 + fi +fi + +### Option translation +## if [ "$trace" = "exec" ]; then trace="exece"; fi +if [ "$trace" = "exec" ]; then trace="execve"; fi + + +################################# +# --- Main Program, DTrace --- +# + +### Define D Script +dtrace=' + #pragma D option quiet + + /* + * Command line arguments + */ + inline int OPT_has_target = '$opt_has_target'; + inline int OPT_follow = '$opt_follow'; + inline int OPT_printid = '$opt_printid'; + inline int OPT_relative = '$opt_relative'; + inline int OPT_elapsed = '$opt_elapsed'; + inline int OPT_cpu = '$opt_cpu'; + inline int OPT_counts = '$opt_counts'; + inline int OPT_pid = '$opt_pid'; + inline int OPT_name = '$opt_name'; + inline int OPT_trace = '$opt_trace'; + inline int OPT_stack = '$opt_stack'; + inline int PID = '$pid'; + inline string NAME = "'"$pname"'"; + inline string TRACE = "'$trace'"; + + dtrace:::BEGIN + { + /* print header */ + /* OPT_printid ? printf("%-8s ","PID/LWP") : 1; */ + OPT_printid ? printf("\t%-8s ","PID/THRD") : 1; + OPT_relative ? printf("%8s ","RELATIVE") : 1; + OPT_elapsed ? printf("%7s ","ELAPSD") : 1; + OPT_cpu ? printf("%6s ","CPU") : 1; + printf("SYSCALL(args) \t\t = return\n"); + + /* Apple: Names of top-level sysctl MIBs */ + sysctl_first[0] = "CTL_UNSPEC"; + sysctl_first[1] = "CTL_KERN"; + sysctl_first[2] = "CTL_VM"; + sysctl_first[3] = "CTL_VFS"; + sysctl_first[4] = "CTL_NET"; + sysctl_first[5] = "CTL_DEBUG"; + sysctl_first[6] = "CTL_HW"; + sysctl_first[7] = "CTL_MACHDEP"; + sysctl_first[9] = "CTL_MAXID"; + + /* globals */ + trackedpid[pid] = 0; + self->child = 0; + this->type = 0; + } + + /* + * Save syscall entry info + */ + + /* MacOS X: notice first appearance of child from fork. Its parent + fires syscall::*fork:return in the ususal way (see below) */ + syscall:::entry + /OPT_follow && trackedpid[ppid] == -1 && 0 == self->child/ + { + /* set as child */ + self->child = 1; + + /* print output */ + self->code = errno == 0 ? "" : "Err#"; + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d: ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d: ",0) : 1; + OPT_cpu ? printf("%6d ",0) : 1; + printf("%s()\t\t = %d %s%d\n","fork", + 0,self->code,(int)errno); + } + + /* MacOS X: notice first appearance of child and parent from vfork */ + syscall:::entry + /OPT_follow && trackedpid[ppid] > 0 && 0 == self->child/ + { + /* set as child */ + this->vforking_tid = trackedpid[ppid]; + self->child = (this->vforking_tid == tid) ? 0 : 1; + + /* print output */ + self->code = errno == 0 ? "" : "Err#"; + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",(this->vforking_tid == tid) ? ppid : pid,tid) : 1; + OPT_relative ? printf("%8d: ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d: ",0) : 1; + OPT_cpu ? printf("%6d ",0) : 1; + printf("%s()\t\t = %d %s%d\n","vfork", + (this->vforking_tid == tid) ? pid : 0,self->code,(int)errno); + } + + syscall:::entry + /(OPT_has_target && pid == $target) || + (OPT_pid && pid == PID) || + (OPT_name && NAME == strstr(NAME, execname)) || + (OPT_name && execname == strstr(execname, NAME)) || + (self->child)/ + { + /* set start details */ + self->start = timestamp; + self->vstart = vtimestamp; + self->arg0 = arg0; + self->arg1 = arg1; + self->arg2 = arg2; + + /* count occurances */ + OPT_counts == 1 ? @Counts[probefunc] = count() : 1; + } + +/* 4, 5 and 6 arguments */ + syscall::select:entry, + syscall::mmap:entry, + syscall::pwrite:entry, + syscall::pread:entry, + syscall::openat:entry, + syscall::unlinkat:entry, + syscall::getattrlistat:entry, + syscall::readlinkat:entry, + syscall::linkat:entry, + syscall::fchownat:entry, + syscall::renameat:entry, + syscall::sysctl:entry, + syscall::sysctlbyname:entry, + syscall::faccessat:entry, + syscall::kdebug_trace64:entry + /(OPT_has_target && pid == $target) || + (OPT_pid && pid == PID) || + (OPT_name && NAME == strstr(NAME, execname)) || + (OPT_name && execname == strstr(execname, NAME)) || + (self->child)/ + { + self->arg3 = arg3; + self->arg4 = arg4; + self->arg5 = arg5; + } + + /* + * Follow children + */ + syscall::fork:entry + /OPT_follow && self->start/ + { + /* track this parent process */ + trackedpid[pid] = -1; + } + + syscall::vfork:entry + /OPT_follow && self->start/ + { + /* track this parent process */ + trackedpid[pid] = tid; + } + + /* syscall::rexit:entry */ + syscall::exit:entry + { + /* forget child */ + self->child = 0; + trackedpid[pid] = 0; + } + + /* + * Check for syscall tracing + */ + syscall:::entry + /OPT_trace && probefunc != TRACE/ + { + /* drop info */ + self->start = 0; + self->vstart = 0; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + self->arg3 = 0; + self->arg4 = 0; + self->arg5 = 0; + } + + /* + * Print return data + */ + + /* + * NOTE: + * The following code is written in an intentionally repetetive way. + * The first versions had no code redundancies, but performed badly during + * benchmarking. The priority here is speed, not cleverness. I know there + * are many obvious shortcuts to this code, Ive tried them. This style has + * shown in benchmarks to be the fastest (fewest probes, fewest actions). + */ + + /* print 3 args, return as hex */ + syscall::sigprocmask:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s(0x%X, 0x%X, 0x%X)\t\t = 0x%X %s%d\n",probefunc, + (int)self->arg0,self->arg1,self->arg2,(int)arg0, + self->code,(int)errno); + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + } + + /* print 3 args, arg0 as a string */ + syscall::execve:return, + syscall::stat:return, + syscall::stat64:return, + syscall::lstat:return, + syscall::lstat64:return, + syscall::access:return, + syscall::mkdir:return, + syscall::chdir:return, + syscall::chroot:return, + syscall::getattrlist:return, /* XXX 5 arguments */ + syscall::chown:return, + syscall::lchown:return, + syscall::chflags:return, + syscall::readlink:return, + syscall::utimes:return, + syscall::pathconf:return, + syscall::truncate:return, + syscall::getxattr:return, + syscall::setxattr:return, + syscall::removexattr:return, + syscall::unlink:return, + syscall::open:return, + syscall::open_nocancel:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s(\"%S\", 0x%X, 0x%X)\t\t = %d %s%d\n",probefunc, + copyinstr(self->arg0),self->arg1,self->arg2,(int)arg0, + self->code,(int)errno); + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + } + + /* print 3 args, arg1 as a string, for read/write variant */ + syscall::write:return, + syscall::write_nocancel:return, + syscall::read:return, + syscall::read_nocancel:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s(0x%X, \"%S\", 0x%X)\t\t = %d %s%d\n",probefunc,self->arg0, + arg0 == -1 ? "" : stringof(copyin(self->arg1,arg0)),self->arg2,(int)arg0, + self->code,(int)errno); + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + } + + /* print 3 args, arg1 as a string */ + syscall::mkdirat:return, + syscall::unlinkat:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s(0x%X, \"%S\", 0x%X)\t\t = %d %s%d\n",probefunc,self->arg0, + copyinstr(self->arg1),self->arg2,(int)arg0, + self->code,(int)errno); + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + } + + /* print 3 args, arg0 and arg2 as strings */ + syscall::symlinkat:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s(\"%S\", 0x%X, \"%S\")\t\t = %d %s%d\n",probefunc, + copyinstr(self->arg0), self->arg1, copyinstr(self->arg2), (int)arg0, + self->code,(int)errno); + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + } + + + /* print 2 args, arg0 and arg1 as strings */ + syscall::rename:return, + syscall::symlink:return, + syscall::link:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s(\"%S\", \"%S\")\t\t = %d %s%d\n",probefunc, + copyinstr(self->arg0), copyinstr(self->arg1), + (int)arg0,self->code,(int)errno); + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + } + + /* print 0 arg output */ + syscall::*fork:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s()\t\t = %d %s%d\n",probefunc, + (int)arg0,self->code,(int)errno); + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + } + + /* print 1 arg output */ + syscall::close:return, + syscall::close_nocancel:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s(0x%X)\t\t = %d %s%d\n",probefunc,self->arg0, + (int)arg0,self->code,(int)errno); + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + } + + /* print 2 arg output */ + syscall::utimes:return, + syscall::munmap:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s(0x%X, 0x%X)\t\t = %d %s%d\n",probefunc,self->arg0, + self->arg1,(int)arg0,self->code,(int)errno); + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + } + + /* print pread/pwrite with 4 arguments */ + syscall::pread*:return, + syscall::pwrite*:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s(0x%X, \"%S\", 0x%X, 0x%X)\t\t = %d %s%d\n",probefunc,self->arg0, + stringof(copyin(self->arg1,self->arg2)),self->arg2,self->arg3,(int)arg0,self->code,(int)errno); + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + self->arg3 = 0; + } + + /* print 4 args, arg1 as string */ + syscall::openat:return, + syscall::faccessat:return, + syscall::fchmodat:return, + syscall::readlinkat:return, + syscall::fstatat:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s(0x%X, \"%S\", 0x%X, 0x%X)\t\t = %d %s%d\n",probefunc, + self->arg0, copyinstr(self->arg1),self->arg2,self->arg3,(int)arg0, + self->code,(int)errno); + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + self->arg3 = 0; + } + + /* print 4 args, arg1 and arg3 as strings */ + syscall::renameat:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s(0x%X, \"%S\", 0x%X, \"%S\")\t\t = %d %s%d\n",probefunc, + self->arg0, copyinstr(self->arg1), self->arg2, copyinstr(self->arg3), (int)arg0, + self->code,(int)errno); + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + self->arg3 = 0; + } + + /* Apple: print the arguments passed to sysctl */ + syscall::sysctl:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + mib = copyin(self->arg0, self->arg1 * sizeof(int)); + mib1 = *(int *)mib; + mib2 = *((int *)mib + 1); + + printf("%s(", probefunc); + + printf("[%s, ", (self->arg1 > 0) ? ((*(int *)mib > 0 && *(int *)mib < 9) ? sysctl_first[mib1] : "unknown") : 0); + + printf("%d, %d, %d, %d, %d] (%d), ", + (self->arg1 > 1) ? *((int *)mib + 1) : 0, + (self->arg1 > 2) ? *((int *)mib + 2) : 0, + (self->arg1 > 3) ? *((int *)mib + 3) : 0, + (self->arg1 > 4) ? *((int *)mib + 4) : 0, + (self->arg1 > 5) ? *((int *)mib + 5) : 0, + self->arg1); + + printf("0x%X, 0x%X, 0x%X, 0x%X)\t\t = %d %s%d\n", + self->arg2, self->arg3, self->arg4, self->arg5, + (int)arg0, self->code, (int)errno); + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + self->arg3 = 0; + self->arg4 = 0; + self->arg5 = 0; + } + + /* Apple: print the string provided to sysctlbyname */ + syscall::sysctlbyname:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s(%s, 0x%X, 0x%X, 0x%X, 0x%X)\t\t = %d %s%d\n",probefunc, + copyinstr(self->arg0), + self->arg1,self->arg2,self->arg3,self->arg4,(int)arg0,self->code,(int)errno); + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + self->arg3 = 0; + self->arg4 = 0; + } + + /* print 5 arguments */ + syscall::kdebug_trace64:return, + syscall::select:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s(0x%X, 0x%X, 0x%X, 0x%X, 0x%X)\t\t = %d %s%d\n",probefunc,self->arg0, + self->arg1,self->arg2,self->arg3,self->arg4,(int)arg0,self->code,(int)errno); + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + self->arg3 = 0; + self->arg4 = 0; + } + + /* print 5 args, arg1 as string */ + syscall::fchownat:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s(0x%X, \"%S\", 0x%X, 0x%X, 0x%X)\t\t = %d %s%d\n",probefunc, + self->arg0, copyinstr(self->arg1), self->arg2, self->arg3, self->arg4, + (int)arg0,self->code,(int)errno); + + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + self->arg3 = 0; + self->arg4 = 0; + } + /* print 5 args, arg1 and arg3 as strings */ + syscall::linkat:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s(0x%X, \"%S\", 0x%X, \"%S\", 0x%X)\t\t = %d %s%d\n",probefunc, + self->arg0, copyinstr(self->arg1), self->arg2, self->arg3 ? copyinstr(self->arg3) : "", self->arg4, + (int)arg0,self->code,(int)errno); + + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + self->arg3 = 0; + self->arg4 = 0; + } + + /* getattrlistat has 6 arguments */ + syscall::getattrlistat:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s(0x%X, \"%S\", 0x%X, 0x%X, 0x%X, 0x%X)\t\t = 0x%X %s%d\n",probefunc,self->arg0, + copyinstr(self->arg1),self->arg2,self->arg3,self->arg4,self->arg5, arg0,self->code,(int)errno); + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + self->arg3 = 0; + self->arg4 = 0; + self->arg5 = 0; + } + + /* kill has 2 args that should be shown as decimal*/ + syscall::kill:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s(%d, %d)\t\t = %d %s%d\n",probefunc,self->arg0, + self->arg1,(int)arg0,self->code,(int)errno); + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + } + + /* mmap has 6 arguments */ + syscall::mmap:return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s(0x%X, 0x%X, 0x%X, 0x%X, 0x%X, 0x%X)\t\t = 0x%X %s%d\n",probefunc,self->arg0, + self->arg1,self->arg2,self->arg3,self->arg4,self->arg5, arg0,self->code,(int)errno); + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + self->arg3 = 0; + self->arg4 = 0; + self->arg5 = 0; + } + + /* print 3 arg output - default */ + syscall:::return + /self->start/ + { + /* calculate elapsed time */ + this->elapsed = timestamp - self->start; + self->start = 0; + this->cpu = vtimestamp - self->vstart; + self->vstart = 0; + self->code = errno == 0 ? "" : "Err#"; + + /* print optional fields */ + /* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */ + OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1; + OPT_relative ? printf("%8d ",vtimestamp/1000) : 1; + OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1; + OPT_cpu ? printf("%6d ",this->cpu/1000) : 1; + + /* print main data */ + printf("%s(0x%X, 0x%X, 0x%X)\t\t = %d %s%d\n",probefunc,self->arg0, + self->arg1,self->arg2,(int)arg0,self->code,(int)errno); + OPT_stack ? ustack() : 1; + OPT_stack ? trace("\n") : 1; + self->arg0 = 0; + self->arg1 = 0; + self->arg2 = 0; + } + + /* print counts */ + dtrace:::END + { + OPT_counts == 1 ? printf("\n%-32s %16s\n","CALL","COUNT") : 1; + OPT_counts == 1 ? printa("%-32s %@16d\n",@Counts) : 1; + } +' + +### Run DTrace +#if [ $opt_command -eq 1 ]; then +# /usr/sbin/dtrace -x dynvarsize=$buf -x evaltime=postinit -n "$dtrace" \ +# -c "$command" >&2 +#else +# /usr/sbin/dtrace -x dynvarsize=$buf -n "$dtrace" >&2 +#fi + +### Run DTrace (Mac OS X) +# Redirect the output to stderr so that it doesn't mingle with +# data going to the target's stdout +if [ $opt_wait -eq 1 ]; then + /usr/sbin/dtrace -x dynvarsize=$buf -n "$dtrace" \ + -W "$wname" >&2 +elif [ $opt_command -eq 1 ]; then + /usr/sbin/dtrace -x dynvarsize=$buf -x evaltime=preinit -Z -n "$dtrace" \ + -c "$command" >&2 + +else + /usr/sbin/dtrace -x dynvarsize=$buf -n "$dtrace" >&2 +fi diff --git a/ThirdPartyNotices.txt b/ThirdPartyNotices.txt new file mode 100644 index 00000000..afc4c9df --- /dev/null +++ b/ThirdPartyNotices.txt @@ -0,0 +1,397 @@ +microsoft-VFSForGit + +THIRD-PARTY SOFTWARE NOTICES AND INFORMATION +Do Not Translate or Localize + +This project incorporates components from the projects listed below. The original copyright notices and the licenses under which Microsoft received such components are set forth below. Microsoft reserves all rights not expressly granted herein, whether by implication, estoppel or otherwise. + + +1. dtruss from Apple's dtrace distribution version 284.200.15 (https://opensource.apple.com/source/dtrace/dtrace-284.200.15/DTTk/) + + +dtrace NOTICES AND INFORMATION BEGIN HERE +========================================= +COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 + + + 1. Definitions. + + 1.1. “Contributor” means each individual or entity that + creates or contributes to the creation of Modifications. + + 1.2. “Contributor Version” means the combination of the + Original Software, prior Modifications used by a + Contributor (if any), and the Modifications made by that + particular Contributor. + + 1.3. “Covered Software” means (a) the Original Software, or + (b) Modifications, or (c) the combination of files + containing Original Software with files containing + Modifications, in each case including portions thereof. + + 1.4. “Executable” means the Covered Software in any form + other than Source Code. + + 1.5. “Initial Developer” means the individual or entity + that first makes Original Software available under this + License. + + 1.6. “Larger Work” means a work which combines Covered + Software or portions thereof with code not governed by the + terms of this License. + + 1.7. “License” means this document. + + 1.8. “Licensable” means having the right to grant, to the + maximum extent possible, whether at the time of the initial + grant or subsequently acquired, any and all of the rights + conveyed herein. + + 1.9. “Modifications” means the Source Code and Executable + form of any of the following: + + A. Any file that results from an addition to, + deletion from or modification of the contents of a + file containing Original Software or previous + Modifications; + + B. Any new file that contains any part of the + Original Software or previous Modification; or + + C. Any new file that is contributed or otherwise made + available under the terms of this License. + + 1.10. “Original Software” means the Source Code and + Executable form of computer software code that is + originally released under this License. + + 1.11. “Patent Claims” means any patent claim(s), now owned + or hereafter acquired, including without limitation, + method, process, and apparatus claims, in any patent + Licensable by grantor. + + 1.12. “Source Code” means (a) the common form of computer + software code in which modifications are made and (b) + associated documentation included in or with such code. + + 1.13. “You” (or “Your”) means an individual or a legal + entity exercising rights under, and complying with all of + the terms of, this License. For legal entities, “You” + includes any entity which controls, is controlled by, or is + under common control with You. For purposes of this + definition, “control” means (a) the power, direct or + indirect, to cause the direction or management of such + entity, whether by contract or otherwise, or (b) ownership + of more than fifty percent (50%) of the outstanding shares + or beneficial ownership of such entity. + + 2. License Grants. + + 2.1. The Initial Developer Grant. + + Conditioned upon Your compliance with Section 3.1 below and + subject to third party intellectual property claims, the + Initial Developer hereby grants You a world-wide, + royalty-free, non-exclusive license: + + (a) under intellectual property rights (other than + patent or trademark) Licensable by Initial Developer, + to use, reproduce, modify, display, perform, + sublicense and distribute the Original Software (or + portions thereof), with or without Modifications, + and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, + using or selling of Original Software, to make, have + made, use, practice, sell, and offer for sale, and/or + otherwise dispose of the Original Software (or + portions thereof). + + (c) The licenses granted in Sections 2.1(a) and (b) + are effective on the date Initial Developer first + distributes or otherwise makes the Original Software + available to a third party under the terms of this + License. + + (d) Notwithstanding Section 2.1(b) above, no patent + license is granted: (1) for code that You delete from + the Original Software, or (2) for infringements + caused by: (i) the modification of the Original + Software, or (ii) the combination of the Original + Software with other software or devices. + + 2.2. Contributor Grant. + + Conditioned upon Your compliance with Section 3.1 below and + subject to third party intellectual property claims, each + Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + (a) under intellectual property rights (other than + patent or trademark) Licensable by Contributor to + use, reproduce, modify, display, perform, sublicense + and distribute the Modifications created by such + Contributor (or portions thereof), either on an + unmodified basis, with other Modifications, as + Covered Software and/or as part of a Larger Work; and + + + (b) under Patent Claims infringed by the making, + using, or selling of Modifications made by that + Contributor either alone and/or in combination with + its Contributor Version (or portions of such + combination), to make, use, sell, offer for sale, + have made, and/or otherwise dispose of: (1) + Modifications made by that Contributor (or portions + thereof); and (2) the combination of Modifications + made by that Contributor with its Contributor Version + (or portions of such combination). + + (c) The licenses granted in Sections 2.2(a) and + 2.2(b) are effective on the date Contributor first + distributes or otherwise makes the Modifications + available to a third party. + + (d) Notwithstanding Section 2.2(b) above, no patent + license is granted: (1) for any code that Contributor + has deleted from the Contributor Version; (2) for + infringements caused by: (i) third party + modifications of Contributor Version, or (ii) the + combination of Modifications made by that Contributor + with other software (except as part of the + Contributor Version) or other devices; or (3) under + Patent Claims infringed by Covered Software in the + absence of Modifications made by that Contributor. + + 3. Distribution Obligations. + + 3.1. Availability of Source Code. + + Any Covered Software that You distribute or otherwise make + available in Executable form must also be made available in + Source Code form and that Source Code form must be + distributed only under the terms of this License. You must + include a copy of this License with every copy of the + Source Code form of the Covered Software You distribute or + otherwise make available. You must inform recipients of any + such Covered Software in Executable form as to how they can + obtain such Covered Software in Source Code form in a + reasonable manner on or through a medium customarily used + for software exchange. + + 3.2. Modifications. + + The Modifications that You create or to which You + contribute are governed by the terms of this License. You + represent that You believe Your Modifications are Your + original creation(s) and/or You have sufficient rights to + grant the rights conveyed by this License. + + 3.3. Required Notices. + + You must include a notice in each of Your Modifications + that identifies You as the Contributor of the Modification. + You may not remove or alter any copyright, patent or + trademark notices contained within the Covered Software, or + any notices of licensing or any descriptive text giving + attribution to any Contributor or the Initial Developer. + + 3.4. Application of Additional Terms. + + You may not offer or impose any terms on any Covered + Software in Source Code form that alters or restricts the + applicable version of this License or the recipients’ + rights hereunder. You may choose to offer, and to charge a + fee for, warranty, support, indemnity or liability + obligations to one or more recipients of Covered Software. + However, you may do so only on Your own behalf, and not on + behalf of the Initial Developer or any Contributor. You + must make it absolutely clear that any such warranty, + support, indemnity or liability obligation is offered by + You alone, and You hereby agree to indemnify the Initial + Developer and every Contributor for any liability incurred + by the Initial Developer or such Contributor as a result of + warranty, support, indemnity or liability terms You offer. + + + 3.5. Distribution of Executable Versions. + + You may distribute the Executable form of the Covered + Software under the terms of this License or under the terms + of a license of Your choice, which may contain terms + different from this License, provided that You are in + compliance with the terms of this License and that the + license for the Executable form does not attempt to limit + or alter the recipient’s rights in the Source Code form + from the rights set forth in this License. If You + distribute the Covered Software in Executable form under a + different license, You must make it absolutely clear that + any terms which differ from this License are offered by You + alone, not by the Initial Developer or Contributor. You + hereby agree to indemnify the Initial Developer and every + Contributor for any liability incurred by the Initial + Developer or such Contributor as a result of any such terms + You offer. + + 3.6. Larger Works. + + You may create a Larger Work by combining Covered Software + with other code not governed by the terms of this License + and distribute the Larger Work as a single product. In such + a case, You must make sure the requirements of this License + are fulfilled for the Covered Software. + + 4. Versions of the License. + + 4.1. New Versions. + + Sun Microsystems, Inc. is the initial license steward and + may publish revised and/or new versions of this License + from time to time. Each version will be given a + distinguishing version number. Except as provided in + Section 4.3, no one other than the license steward has the + right to modify this License. + + 4.2. Effect of New Versions. + + You may always continue to use, distribute or otherwise + make the Covered Software available under the terms of the + version of the License under which You originally received + the Covered Software. If the Initial Developer includes a + notice in the Original Software prohibiting it from being + distributed or otherwise made available under any + subsequent version of the License, You must distribute and + make the Covered Software available under the terms of the + version of the License under which You originally received + the Covered Software. Otherwise, You may also choose to + use, distribute or otherwise make the Covered Software + available under the terms of any subsequent version of the + License published by the license steward. + + 4.3. Modified Versions. + + When You are an Initial Developer and You want to create a + new license for Your Original Software, You may create and + use a modified version of this License if You: (a) rename + the license and remove any references to the name of the + license steward (except to note that the license differs + from this License); and (b) otherwise make it clear that + the license contains terms which differ from this License. + + + 5. DISCLAIMER OF WARRANTY. + + COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN “AS IS” + BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, + INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED + SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR + PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND + PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY + COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE + INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF + ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF + WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF + ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS + DISCLAIMER. + + 6. TERMINATION. + + 6.1. This License and the rights granted hereunder will + terminate automatically if You fail to comply with terms + herein and fail to cure such breach within 30 days of + becoming aware of the breach. Provisions which, by their + nature, must remain in effect beyond the termination of + this License shall survive. + + 6.2. If You assert a patent infringement claim (excluding + declaratory judgment actions) against Initial Developer or + a Contributor (the Initial Developer or Contributor against + whom You assert such claim is referred to as “Participant”) + alleging that the Participant Software (meaning the + Contributor Version where the Participant is a Contributor + or the Original Software where the Participant is the + Initial Developer) directly or indirectly infringes any + patent, then any and all rights granted directly or + indirectly to You by such Participant, the Initial + Developer (if the Initial Developer is not the Participant) + and all Contributors under Sections 2.1 and/or 2.2 of this + License shall, upon 60 days notice from Participant + terminate prospectively and automatically at the expiration + of such 60 day notice period, unless if within such 60 day + period You withdraw Your claim with respect to the + Participant Software against such Participant either + unilaterally or pursuant to a written agreement with + Participant. + + 6.3. In the event of termination under Sections 6.1 or 6.2 + above, all end user licenses that have been validly granted + by You or any distributor hereunder prior to termination + (excluding licenses granted to You by any distributor) + shall survive termination. + + 7. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT + (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE + INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF + COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE + LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR + CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT + LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK + STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER + COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN + INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF + LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL + INJURY RESULTING FROM SUCH PARTY’S NEGLIGENCE TO THE EXTENT + APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO + NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR + CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT + APPLY TO YOU. + + 8. U.S. GOVERNMENT END USERS. + + The Covered Software is a “commercial item,” as that term is + defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of “commercial + computer software” (as that term is defined at 48 C.F.R. § + 252.227-7014(a)(1)) and “commercial computer software + documentation” as such terms are used in 48 C.F.R. 12.212 (Sept. + 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 + through 227.7202-4 (June 1995), all U.S. Government End Users + acquire Covered Software with only those rights set forth herein. + This U.S. Government Rights clause is in lieu of, and supersedes, + any other FAR, DFAR, or other clause or provision that addresses + Government rights in computer software under this License. + + 9. MISCELLANEOUS. + + This License represents the complete agreement concerning subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the + extent necessary to make it enforceable. This License shall be + governed by the law of the jurisdiction specified in a notice + contained within the Original Software (except to the extent + applicable law, if any, provides otherwise), excluding such + jurisdiction’s conflict-of-law provisions. Any litigation + relating to this License shall be subject to the jurisdiction of + the courts located in the jurisdiction and venue specified in a + notice contained within the Original Software, with the losing + party responsible for costs, including, without limitation, court + costs and reasonable attorneys’ fees and expenses. The + application of the United Nations Convention on Contracts for the + International Sale of Goods is expressly excluded. Any law or + regulation which provides that the language of a contract shall + be construed against the drafter shall not apply to this License. + You agree that You alone are responsible for compliance with the + United States export administration regulations (and the export + control laws and regulation of any other countries) when You use, + distribute or otherwise make available any Covered Software. + + 10. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is + responsible for claims and damages arising, directly or + indirectly, out of its utilization of rights under this License + and You agree to work with Initial Developer and Contributors to + distribute such responsibility on an equitable basis. Nothing + herein is intended or shall be deemed to constitute any admission + of liability.