This article describes how to download, install, and run the NetBeans
Dynamic Tracing (DTrace) GUI plug-in. The NetBeans DTrace GUI
plug-in is a Graphical User Interface
(GUI)
for running DTrace scripts, and can be installed into the
SunTM
Studio 12 IDE, NetBeansTM IDE 5.5, NetBeans IDE 5.5.1, and NetBeans IDE
6.0.
You can run D scripts from the
GUI, even those that are embedded in shell scripts. In fact, the DTrace
GUI plug-in runs all of the D
scripts that are packaged in the DTraceToolkit.
The DTraceToolkit is a collection of useful documented scripts
developed by the OpenSolaris DTrace community.
The NetBeans DTrace GUI plug-in is architected in such a way that
you can easily extend and customize it.
The GUI package consists of two components: The NetBeans plug-in and
the DTraceScripts directory.
The NetBeans DTrace GUI plug-in can be easily installed into
Sun
Studio 12 IDE, NetBeans IDE 5.5, NetBeans IDE 5.5.1, or NetBeans
IDE 6.0.
The DTraceScripts directory contains several
subdirectories. Each subdirectory contains several D scripts. The
D scripts are categorized mostly based on DTrace providers. You can
copy a new D script to an existing subdirectory from the shell command
line, you can
copy it into a newly created subdirectory in the DTraceScripts
directory. You can also create and save a new D script from within the
IDE.
What is DTrace?
DTrace is a comprehensive tracing facility built into the
SolarisTM Operating System
that can be used by developers and administrators on live production
systems to examine the behavior of both user programs and of the
operating system itself.
DTrace enables you to explore your system to understand how it works,
track down performance problems across many layers of software, or
locate the cause of aberrant behavior.
DTrace helps you understand a software system by enabling you to
dynamically modify the operating system kernel and user processes to
record additional data that you specify at locations of interest, called
probes.
A probe is a location or activity to which DTrace can bind a request to
perform a set of actions, like recording a stack trace, a timestamp, or
the arguments to a function.
Probes are like programmable sensors scattered all over your Solaris
system in interesting places. If you want to figure out what's going on,
you use D scripts to program the appropriate sensors to record the
information that is of interest to you. Then, as each probe fires, DTrace
gathers the data from your probes and
reports it back to you.
Your privileges need to be set in the /etc/user_attr
file. For example, the following is how DTrace privileges are set
in the machines on which I run DTrace:
Installation steps for NetBeans IDE 5.5, NetBeans IDE 5.5.1, and Sun
Studio 12 IDE
Start up NetBeans IDE 5.5, NetBeans IDE 5.5.1, or Sun Studio 12 IDE.
Choose Tools > Update Center.
On the Select Location of Modules page of the Update Center
Wizard, if the checkbox for NetBeans Update Center Beta (for NetBeans IDE 5.5
or NetBeans IDE 5.5.1) or the checkbox for Sun Studio Update Center (for Sun
Studio 12 IDE) does not contain a
checkmark, click the checkbox. Then click Next.
On the Select Modules to Install page, select DTrace in the
Available Updates and New Modules list, and click Add. Then click Next.
Accept the license agreement.
On the Download Modules page, click Next when the download is complete.
On the View Certificates and Install Modules page, click Finish.
The NetBeans DTrace GUI plug-in is now installed into NetBeans IDE 5.5 or
NetBeans IDE 5.5.1. See Installing the DTraceScripts
File to install the DTraceScripts file.
Installation steps for NetBeans IDE 6.0
Start up NetBeans IDE 6.0.
Choose Tools > Plugins.
On the Available Plugins tab of the Plugins window, click the checkbox for
DTrace to add a checkmark. (If DTrace does not appear in the available plugins
list, click Reload Catalog and try again.) Click Install.
In the NetBeans IDE Installer window, click Next.
Accept the License Agreement and click Install.
Click Finish.
Close the Plugins window.
The NetBeans DTrace GUI plug-in is now installed into NetBeans IDE
6.0. See the next section to install the DTraceScripts file.
Installing the DTraceScripts File
If you will be running the IDE as yourself, the DTraceScripts.tar
file needs to be installed in your home
directory. If you will be running the IDE as root, the DTraceScripts.tar
file needs to be installed in the root directory.
After you have installed
the DTrace GUI plug-in, the DTraceScripts.tar file is in the
.netbeans/netbeans_release directory or
.sunstudio/12.0-SunOS-platform directory in your home directory.
For example, /home/nassern/.netbeans/6.0/dtrace-gui-102007.
To install the DTraceScripts.tar file:
In your home directory or root directory, untar the file. For example:
tar -xvf /home/nassern/.netbeans/6.0/dtrace-gui-102007/DTraceScripts.tar
The file permissions for all of the scripts need to be set to -rwxr-xr-x
or 755. If necessary, use the UNIX chmod command to set the
proper file permissions. For example:
chmod -R 755 DTraceScripts
Your installation of the DTrace GUI is now complete. To open the DTrace
GUI, choose Window > DTrace.
How to Run the D Scripts in DTrace GUI Environment
To run D scripts in the DTrace GUI:
Start up the Sun Studio 12 IDE, NetBeans IDE 5.5, NetBeans IDE
5.5.1, or NetBeans IDE 6.0.
Choose Windows > DTrace. The DTrace tab opens on the left side
of the IDE.
Select a D script from the Category list box in DTrace panel
and click Start. See the screen shot below.
The output of the selected D script is displayed in the Output
window. Some scripts do not generate any output until you click Stop.
You can run multiple D scripts simultaneously.
Clicking Stop stops the last D script that you started.
To save the output of a script, right-click in the Output window
and choose Save As.
Advanced Options
Click Advanced in the DTrace GUI to use the advanced options.
You can use the View/Edit option to display the selected D script
in the Editor window.
To create a new D script:
Click Advanced and select the Create new script option.
In the New Script dialog box, type the name of the new D script
without the .d extension. The empty D script will be created
in selected category (directory). For example, the screen shot below
shows how to create an empty hello
D script in the Proc directory.
Click Advanced and select the View/Edit option to display the
newly created
(empty) D script in the Editor window.
Enter the code for new D script in the Editor window and save
the file. The screen shot below shows the DTrace code for the hello.d
script.
You can run the newly created hello.d script from the
DTrace GUI.
The configuration panel lists optional parameters that
you can specify for each selected D script.
pid
The process-id of the running
process
Script args
The D script arguments
executable
The absolute path name to the
executable
executable args
The executable arguments
output
Ignore this field
description
The help messages can be
inserted in this field
In order to create the persistent data, the user specified
parameters or properties are stored in a .xml file. The
property file has the same name as the D script file, with the
exception .xml extension. In other words, the user data is
preserved for the subsequent invocation of D scripts and the IDE itself.
The screen shot below shows how to run the memleak.d
script. The
memleak.d script can be used to detect memory leaks in
applications.
The
memleak.d script requires two parameters: The absolute path
name to the
executable and the D script module name. In the example below,
/home/nassern/test/umem/hello is the absolute path name to the
executable and libc is the module name.
Limitations and Known Bugs
Currently, clicking Stop stops the last D script that has
been started
by user. This will be changed in the next release. The Stop action will
halt the running script, that its output tab is selected by the user.
Double clicking on selected D script does not display the D
script in Editor window. This will be fixed in the next release.
Currently,
you must use the Advanced View/Edit option to display the D script
in the Editor window.