DTrace

From Wikipedia, the free encyclopedia

DTrace
Developed by Sun Microsystems
Initial release January 2005
OS Unix-like
Development status active
Genre tracing
License Common Development and Distribution License
Website http://opensolaris.org/os/community/dtrace/

DTrace is a comprehensive dynamic tracing framework created by Sun Microsystems for troubleshooting system and application problems in real time. It was first made available for use in November 2003, and formally released as part of Sun's Solaris 10 in January 2005. DTrace was the first component of the OpenSolaris project to have its source code released under the Common Development and Distribution License (CDDL).

DTrace is designed to give operational insights that allow users to tune and troubleshoot applications and the OS itself. Special consideration has been taken to make it safe to use in a production environment. For example, there is minimal probe effect when tracing is underway, and no performance impact associated with any disabled probe; this is important since there are tens of thousands of DTrace probes that can be enabled.

Tracing programs (also referred to as scripts) can be written using the D programming language (not to be confused with other programming languages named "D"). The language is a subset of C with added functions and variables specific to tracing. D programs resemble awk programs in structure; they consist of a set of actions rather than a top-down structured program. In a DTrace program, one or more probes (instrumentation points) are enabled; whenever the condition for the probe is met, the action associated with the probe in the DTrace program is executed (the probe "fires").

DTrace was designed and implemented by Bryan Cantrill, Mike Shapiro, and Adam Leventhal. The authors received recognition in 2005 for the innovations in DTrace from InfoWorld and Technology Review.[1][2] DTrace won the top prize in the Wall Street Journal's 2006 Technology Innovation Awards competition.[3]

DTrace implementations require tight integration with the operating system kernel. Although DTrace was initially written for Solaris, its source code is freely available as part of the OpenSolaris project, and work is in progress to port it to FreeBSD (in which there has been initial success[4] as a substitute for the ktrace utility; further work on DTrace integration into FreeBSD is being sponsored by Cisco) and QNX [5]. Apple has included DTrace in Mac OS X 10.5 "Leopard" with a GUI called Instruments;[6] Unlike other platforms that DTrace is supported on, Mac OS X has a flag (P_LNOATTACH) that a program may set that disallows tracing of that process by debugging utilities such as DTrace and gdb. This can affect tracing of other system information, as unrelated probes that should fire while a program with this flag set is running will fail to do so.[7]

Contents

[edit] Using DTrace

Typical usage of DTrace consists of invoking it from the command line, providing one or more arguments. Here a list of command line with examples arguments.

# 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); }'

[edit] References

[edit] Notes

  1. ^ Tracing software in real time. Technology Review. MIT (2005). Retrieved on 2007-03-31.
  2. ^ McAllister, Neil (August 2005). Innovation is alive and well in 2005. InfoWorld. IDG. Retrieved on 2007-03-31.
  3. ^ Totty, Michael (September 2006). The Winners Are.... The Wall Street Journal. Dow Jones & Company, Inc.. Retrieved on 2007-03-31.
  4. ^ LeMay, Renai (2006-05-29). DTrace reaches prime time on FreeBSD. ZDNet Australia. Retrieved on 2007-04-15.
  5. ^ I trace, you trace … what about dtrace?. QNX blog. Retrieved on 2007-11-08.
  6. ^ Mac OS X Leopard - Developer Tools - Instruments. Apple, Inc. Retrieved on 2007-10-19.
  7. ^ Mac OS X and the missing probes. Leventhal, Adam H.. Retrieved on 2008-01-20.

[edit] See also

[edit] External links