Merge pull request #2749 from pyhalov/nginx
[unleashed-userland.git] / tools / build-watch.d
blob94f2dd6e8285059b90546d95ed33331ec1755ffb
1 #!/usr/sbin/dtrace -s -q
2 /*
3 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
22 * Copyright (c) 2010, Oracle and/or it's affiliates. All rights reserved.
25 * build-watch.d - a simple dtrace script to keep track of some key
26 * information to help determine build dependencies.
30 * record paths successfully opened
32 syscall::open:entry, syscall::open64:entry
33 /(pid == $target) || progenyof($target)/
35 self->file = cleanpath(copyinstr(arg0));
37 syscall::openat:entry
38 /(pid == $target) || progenyof($target)/
40 self->file = cleanpath(copyinstr(arg1));
43 syscall::open*:return
44 /((pid == $target) || progenyof($target)) && (arg0 != -1) && (self->file != "")/
46 @opened[self->file] = count();
47 self->file = 0;
51 * record the programs successfully execed (full path names)
53 proc:::exec
54 /(pid == $target) || progenyof($target)/
56 self->execpath = stringof(arg0);
59 proc:::exec-success
60 /(pid == $target) || progenyof($target)/
62 @tools[execname, self->execpath] = count();
63 self->execpath = 0;
67 * Summarize the results of watching the [sub]process tree
69 END
71 printf("\n");
72 printa("TOOL: %s = %s\n", @tools);
73 printa("FILE: %s\n", @opened);