Skip to content

Commit 6a04074

Browse files
committed
Capture the dtrace scripts from Dustin Sallings
Change-Id: I6ecd29edb4d310edebda717b5793ff0ea0ae11ea Reviewed-on: http://review.couchbase.org/9563 Tested-by: Steve Yen <[email protected]> Reviewed-by: Steve Yen <[email protected]>
1 parent 0f3a435 commit 6a04074

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

scripts/dtrace-profile.d

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* Count function invocations.
2+
*
3+
* usage:
4+
* sudo dtrace -q -s dtrace-profile.d PID
5+
*/
6+
7+
pid$1:::entry
8+
{
9+
self->t[probefunc] = timestamp;
10+
}
11+
12+
pid$1:::return
13+
/ self->t[probefunc] != 0 /
14+
{
15+
@counts[probemod, probefunc] = sum(timestamp - self->t[probefunc]);
16+
}
17+
18+
tick-5s
19+
{
20+
printa(@counts);
21+
}

scripts/dtrace-syscalls.d

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* Trace all the syscalls invoked during a given C function.
2+
*
3+
* usage:
4+
* sudo dtrace -q -s dtrace-syscalls.d PID PROBEFUNC
5+
*
6+
* example:
7+
* sudo dtrace -q -s dtrace-syscalls.d 6666 try_read_command
8+
*/
9+
10+
pid$1::$2:entry
11+
{
12+
printf("starting %s\n", probefunc);
13+
self->in_function = 1;
14+
ustack();
15+
}
16+
17+
pid$1::$2:return
18+
{
19+
printf("ending %s\n", probefunc);
20+
self->in_function = 0;
21+
}
22+
23+
syscall:::
24+
/ self->in_function != 0 /
25+
{
26+
printf("%s %s %s\n", execname, probefunc, probename);
27+
}
28+
29+

0 commit comments

Comments
 (0)