DTrace is a programming language created in 2005.
#301on PLDB | 19Years Old | 534Repos |
DTrace is a comprehensive dynamic tracing framework created by Sun Microsystems for troubleshooting kernel and application problems on production systems in real time. Originally developed for Solaris, it has since been released under the free Common Development and Distribution License (CDDL) and has been ported to several other Unix-like systems. DTrace can be used to get a global overview of a running system, such as the amount of memory, CPU time, filesystem and network resources used by the active processes. Read more on Wikipedia...
# Syscall count by syscall
dtrace -n 'syscall:::entry { @num[probefunc] = count(); }'
# Syscall count by process
dtrace -n 'syscall:::entry { @num[pid,execname] = count(); }'
#!/usr/sbin/dtrace -qs
BEGIN {
printf("Hello World");
exit(0);
}
/*
* This software is in the public domain.
*
* $Id: counts.d 10510 2005-08-15 01:46:19Z kateturner $
*/
#pragma D option quiet
self int tottime;
BEGIN {
tottime = timestamp;
}
php$target:::function-entry
@counts[copyinstr(arg0)] = count();
}
END {
printf("Total time: %dus\n", (timestamp - tottime) / 1000);
printf("# calls by function:\n");
printa("%-40s %@d\n", @counts);
}
# New processes with arguments
dtrace -n 'proc:::exec-success { trace(curpsinfo->pr_psargs); }'
# Files opened by process
dtrace -n 'syscall::open*:entry { printf("%s %s",execname,copyinstr(arg0)); }'
# Syscall count by program
dtrace -n 'syscall:::entry { @num[execname] = count(); }'
# Syscall count by syscall
dtrace -n 'syscall:::entry { @num[probefunc] = count(); }'
# Syscall count by process
dtrace -n 'syscall:::entry { @num[pid,execname] = count(); }'
# Disk size by process
dtrace -n 'io:::start { printf("%d %s %d",pid,execname,args[0]->b_bcount); }'
# Pages paged in by process
dtrace -n 'vminfo:::pgpgin { @pg[execname] = sum(arg0); }'
Feature | Supported | Example | Token |
---|---|---|---|
Strings | ✓ | "Hello world" | " |
Comments | ✓ | /* A comment */ | |
MultiLine Comments | ✓ | /* A comment */ | /* */ |
Print() Debugging | ✓ | printf | |
Semantic Indentation | X |