tools/build-watch.d
author Mike Sullivan <Mike.Sullivan@Oracle.COM>
Fri, 07 Apr 2017 17:56:36 -0700
changeset 7851 f82a18f72950
parent 3770 ca450a806cc1
permissions -rwxr-xr-x
Close of build 122.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
     1
#!/usr/sbin/dtrace -s -q
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
     2
/*
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
     3
 * CDDL HEADER START
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
     4
 *
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
     5
 * The contents of this file are subject to the terms of the
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
     6
 * Common Development and Distribution License (the "License").
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
     7
 * You may not use this file except in compliance with the License.
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
     8
 *
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
     9
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    10
 * or http://www.opensolaris.org/os/licensing.
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    11
 * See the License for the specific language governing permissions
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    12
 * and limitations under the License.
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    13
 *
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    14
 * When distributing Covered Code, include this CDDL HEADER in each
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    15
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    16
 * If applicable, add the following below this CDDL HEADER, with the
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    17
 * fields enclosed by brackets "[]" replaced with your own identifying
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    18
 * information: Portions Copyright [yyyy] [name of copyright owner]
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    19
 *
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    20
 * CDDL HEADER END
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    21
 *
3770
ca450a806cc1 20440888 Userland python tools should migrate to 2.7
John Beck <John.Beck@Oracle.COM>
parents: 10
diff changeset
    22
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
10
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    23
 *
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    24
 *
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    25
 * build-watch.d - a simple dtrace script to keep track of some key
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    26
 *		   information to help determine build dependencies.
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    27
 */
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    28
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    29
/*
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    30
 * record paths successfully opened
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    31
 */
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    32
syscall::open:entry, syscall::open64:entry
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    33
/(pid == $target) || progenyof($target)/
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    34
{
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    35
	self->file = cleanpath(copyinstr(arg0));
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    36
}
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    37
syscall::openat:entry
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    38
/(pid == $target) || progenyof($target)/
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    39
{
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    40
	self->file = cleanpath(copyinstr(arg1));
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    41
}
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    42
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    43
syscall::open*:return
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    44
/((pid == $target) || progenyof($target)) && (arg0 != -1) && (self->file != "")/
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    45
{
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    46
	@opened[self->file] = count();
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    47
	self->file = 0;
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    48
}
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    49
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    50
/*
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    51
 * record the programs successfully execed (full path names)
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    52
 */
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    53
proc:::exec
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    54
/(pid == $target) || progenyof($target)/
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    55
{
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    56
	self->execpath = stringof(arg0);
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    57
}
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    58
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    59
proc:::exec-success
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    60
/(pid == $target) || progenyof($target)/
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    61
{
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    62
	@tools[execname, self->execpath] = count();
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    63
	self->execpath = 0;
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    64
}
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    65
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    66
/*
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    67
 * Summarize the results of watching the [sub]process tree
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    68
 */
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    69
END
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    70
{
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    71
	printf("\n");
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    72
	printa("TOOL: %s = %s\n", @tools);
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    73
	printa("FILE: %s\n", @opened);
e3fdbd3632b6 dependency gathering tool(s)
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    74
}