3 * js_calls.d - count JavaScript calls using DTrace.
4 * Written for the JavaScript DTrace provider.
6 * $Id: js_calls.d 63 2007-10-04 04:34:38Z brendan $
8 * This traces activity from all browsers on the system that are
9 * running with JavaScript provider support.
11 * USAGE: js_calls.d # hit Ctrl-C to end
14 * FILE Filename of the JavaScript program
15 * TYPE Type of call (func/obj-new/...)
16 * NAME Descriptive name of call
17 * COUNT Number of calls during sample
19 * Filename and function names are printed if available.
21 * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
25 * The contents of this file are subject to the terms of the
26 * Common Development and Distribution License, Version 1.0 only
27 * (the "License"). You may not use this file except in compliance
30 * You can obtain a copy of the license at Docs/cddl1.txt
31 * or http://www.opensolaris.org/os/licensing.
32 * See the License for the specific language governing permissions
33 * and limitations under the License.
37 * 09-Sep-2007 Brendan Gregg Created this.
40 #pragma D option quiet
44 printf("Tracing... Hit Ctrl-C to end.\n");
47 javascript*:::function-entry
49 this->name = copyinstr(arg2);
50 @calls[basename(copyinstr(arg0)), "func", this->name] = count();
53 javascript*:::execute-start
55 this->filename = basename(copyinstr(arg0));
56 @calls[this->filename, "exec", "."] = count();
59 javascript*:::object-create-start
61 this->name = copyinstr(arg1);
62 this->filename = basename(copyinstr(arg0));
63 @calls[this->filename, "obj-new", this->name] = count();
66 javascript*:::object-finalize
68 this->name = copyinstr(arg1);
69 @calls["<null>", "obj-free", this->name] = count();
74 printf(" %-24s %-10s %-30s %8s\n", "FILE", "TYPE", "NAME", "CALLS");
75 printa(" %-24s %-10s %-30s %@8d\n", @calls);