tools/build-watch.d
changeset 10 e3fdbd3632b6
child 3770 ca450a806cc1
equal deleted inserted replaced
9:97fb557d9979 10:e3fdbd3632b6
       
     1 #!/usr/sbin/dtrace -s -q
       
     2 /*
       
     3  * CDDL HEADER START
       
     4  *
       
     5  * The contents of this file are subject to the terms of the
       
     6  * Common Development and Distribution License (the "License").
       
     7  * You may not use this file except in compliance with the License.
       
     8  *
       
     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.
       
    13  *
       
    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]
       
    19  *
       
    20  * CDDL HEADER END
       
    21  *
       
    22  * Copyright (c) 2010, Oracle and/or it's affiliates.  All rights reserved.
       
    23  *
       
    24  *
       
    25  * build-watch.d - a simple dtrace script to keep track of some key
       
    26  *		   information to help determine build dependencies.
       
    27  */
       
    28 
       
    29 /*
       
    30  * record paths successfully opened
       
    31  */
       
    32 syscall::open:entry, syscall::open64:entry
       
    33 /(pid == $target) || progenyof($target)/
       
    34 {
       
    35 	self->file = cleanpath(copyinstr(arg0));
       
    36 }
       
    37 syscall::openat:entry
       
    38 /(pid == $target) || progenyof($target)/
       
    39 {
       
    40 	self->file = cleanpath(copyinstr(arg1));
       
    41 }
       
    42 
       
    43 syscall::open*:return
       
    44 /((pid == $target) || progenyof($target)) && (arg0 != -1) && (self->file != "")/
       
    45 {
       
    46 	@opened[self->file] = count();
       
    47 	self->file = 0;
       
    48 }
       
    49 
       
    50 /*
       
    51  * record the programs successfully execed (full path names)
       
    52  */
       
    53 proc:::exec
       
    54 /(pid == $target) || progenyof($target)/
       
    55 {
       
    56 	self->execpath = stringof(arg0);
       
    57 }
       
    58 
       
    59 proc:::exec-success
       
    60 /(pid == $target) || progenyof($target)/
       
    61 {
       
    62 	@tools[execname, self->execpath] = count();
       
    63 	self->execpath = 0;
       
    64 }
       
    65 
       
    66 /*
       
    67  * Summarize the results of watching the [sub]process tree
       
    68  */
       
    69 END
       
    70 {
       
    71 	printf("\n");
       
    72 	printa("TOOL: %s = %s\n", @tools);
       
    73 	printa("FILE: %s\n", @opened);
       
    74 }