js_flowtime.d revision 1.1 1 1.1 christos #!/usr/sbin/dtrace -Zs
2 1.1 christos /*
3 1.1 christos * js_flowtime.d - JavaScript function flow with delta times using DTrace.
4 1.1 christos * Written for the JavaScript DTrace provider.
5 1.1 christos *
6 1.1 christos * $Id: js_flowtime.d,v 1.1 2015/09/30 22:01:09 christos Exp $
7 1.1 christos *
8 1.1 christos * This traces activity from all browsers on the system that are running
9 1.1 christos * with JavaScript provider support.
10 1.1 christos *
11 1.1 christos * USAGE: js_flowtime.d # hit Ctrl-C to end
12 1.1 christos *
13 1.1 christos * FIELDS:
14 1.1 christos * C CPU-id
15 1.1 christos * TIME(us) Time since boot, us
16 1.1 christos * FILE Filename that this function belongs to
17 1.1 christos * DELTA(us) Elapsed time from previous line to this line
18 1.1 christos * FUNC Function name
19 1.1 christos *
20 1.1 christos * LEGEND:
21 1.1 christos * -> function entry
22 1.1 christos * <- function return
23 1.1 christos *
24 1.1 christos * Filename and function names are printed if available.
25 1.1 christos *
26 1.1 christos * WARNING: Watch the first column carefully, it prints the CPU-id. If it
27 1.1 christos * changes, then it is very likely that the output has been shuffled.
28 1.1 christos *
29 1.1 christos * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
30 1.1 christos *
31 1.1 christos * CDDL HEADER START
32 1.1 christos *
33 1.1 christos * The contents of this file are subject to the terms of the
34 1.1 christos * Common Development and Distribution License, Version 1.0 only
35 1.1 christos * (the "License"). You may not use this file except in compliance
36 1.1 christos * with the License.
37 1.1 christos *
38 1.1 christos * You can obtain a copy of the license at Docs/cddl1.txt
39 1.1 christos * or http://www.opensolaris.org/os/licensing.
40 1.1 christos * See the License for the specific language governing permissions
41 1.1 christos * and limitations under the License.
42 1.1 christos *
43 1.1 christos * CDDL HEADER END
44 1.1 christos *
45 1.1 christos * 09-Sep-2007 Brendan Gregg Created this.
46 1.1 christos */
47 1.1 christos
48 1.1 christos #pragma D option quiet
49 1.1 christos #pragma D option switchrate=10
50 1.1 christos
51 1.1 christos self int depth;
52 1.1 christos
53 1.1 christos dtrace:::BEGIN
54 1.1 christos {
55 1.1 christos printf("%3s %-16s %-18s %9s -- %s\n", "C", "TIME(us)", "FILE",
56 1.1 christos "DELTA(us)", "FUNC");
57 1.1 christos }
58 1.1 christos
59 1.1 christos javascript*:::function-entry,
60 1.1 christos javascript*:::function-return
61 1.1 christos /self->last == 0/
62 1.1 christos {
63 1.1 christos self->last = timestamp;
64 1.1 christos }
65 1.1 christos
66 1.1 christos javascript*:::function-entry
67 1.1 christos {
68 1.1 christos this->delta = (timestamp - self->last) / 1000;
69 1.1 christos printf("%3d %-16d %-18s %9d %*s-> %s\n", cpu, timestamp / 1000,
70 1.1 christos basename(copyinstr(arg0)), this->delta, self->depth * 2, "",
71 1.1 christos copyinstr(arg2));
72 1.1 christos self->depth++;
73 1.1 christos self->last = timestamp;
74 1.1 christos }
75 1.1 christos
76 1.1 christos javascript*:::function-return
77 1.1 christos {
78 1.1 christos this->delta = (timestamp - self->last) / 1000;
79 1.1 christos self->depth -= self->depth > 0 ? 1 : 0;
80 1.1 christos printf("%3d %-16d %-18s %9d %*s<- %s\n", cpu, timestamp / 1000,
81 1.1 christos basename(copyinstr(arg0)), this->delta, self->depth * 2, "",
82 1.1 christos copyinstr(arg2));
83 1.1 christos self->last = timestamp;
84 1.1 christos }
85