|
|
Before you can visualize a program's execution, you must have a trace file. The trace file (or "trace" for short) records what goes on during a program's execution. Jinsight relies on this information to produce visualizations of the execution. Each execution may generate one trace; a trace does not record information for multiple executions.
Prior to producing a trace, have a look at the Tracing Tips section of the manual, since traces can grow very rapidly unless you focus your trace collection efforts. In particular, avoid using the -tracemethods option or the JINSIGHT_TRACE_METHODS environment variable for entire program runs, because the trace produced can be very large.
To create a trace, you can run your program using the command file jinsight_trace. This will invoke the Jinsight instrumented tracing VM (java_g for Windows, or java for AIX and OS/390) with appropriate settings. For example, on a short program, such as the sample Java program tinySamp provided, you could try
set CLASSPATH=<path where your program is> jinsight_trace -tracemethods yourProgram yourProgramArgsjinsight_trace will invoke the instrumented java_g or java program, and produce a message like:
******************************************************* Copyright (c) 1995-1996 Sun MicroSystems, Inc. Improvements to this JVM are Licensed Materials - Property of IBM Copyright (c) IBM Corp. 1998-2001 IBM is a Trademark of International Business Machines Unsupported Jinsight 2001xxxx JVM with instrumented java, based on IBM build a118-20000411; Use under terms of IBM alphaWorks agreement env var JINSIGHT is set, enabling Jinsight options use -tracemethods option to generate Jinsight trace use CTRL-\ for tracing options ******************************************************* tracefile: yourProgram.trcA trace file yourprogram.trc will be created as yourprogram runs.
You can specify additional Java and Jinsight options as follows:
set CLASSPATH=<path where your program is> jinsight_trace <Java and Jinsight options> yourProgram yourProgramArgsThe command file jinsight_trace may have the -classpath option built in, so specify your class path as an environment variable, not as a command line option. You can edit the command file to adapt it for your environment. On Windows it looks like this (final 4 lines are one line):
set JINSIGHT=YES set JINSIGHT_JDK=c:\jinsight2.0\n118p-2.0 %JINSIGHT_JDK%\bin\java_g -Djava.compiler=off -classpath %JINSIGHT_JDK%\lib\classes.zip; %JINSIGHT_JDK%\lib\jintrace.jar;.;%CLASSPATH% %1 %2 %3 %4 %5 %6 %7 %8 %9
On AIX the command file looks like this (final 4 lines are one line):
export JINSIGHT=YES
export JINSIGHT_JDK=~/jinsight2.0/a118-2.0
{JINSIGHT_JDK}/bin/java -Djava.compiler=off
-classpath {JINSIGHT_JDK}/lib/classes.zip:
{JINSIGHT_JDK}/lib/jintrace.jar:.:$CLASSPATH
"$@"
The command file invokes java or java_g (the instrumented VM) with the -classpath option set for the Jinsight instrumented VM you installed. It sets the JINSIGHT environment variable to enable Jinsight instrumentation in the VM.
You can also invoke java or java_g directly, as long as the JINSIGHT environment variable is set (to any value), and your PATH and CLASSPATH settings specify the locations of the instrumentation and your program.
However, you can take a snapshot of the entire object population, or of the entire object population and the objects' mutual references at a point in the program's execution. The information in the snapshot will let you visualize the object population in the Histogram view (without tracing the full execution) or the object references in the Histogram view and the Reference Pattern view (the latter being useless without a snapshot). A snapshot will only report the objects that are not garbage collectible. Notice that the current version of Jinsight only reports arrays when taking a snapshot, it doesn't report arrays when tracing with -tracemethods or -tracepopulation.
You may forgo tracing method calls entirely, thereby making the trace much more compact, and start your program without any tracing options:
set CLASSPATH=<path where
your program is>
jinsight_trace yourProgram
yourProgramArgs
To take a snapshot of all objects, or the objects and their references during an execution:
trace:yourprogram.trc, Tracing status: CORE ----------------------------------------------- Jinsight Tracing Options: [tm] - start tracing methods [sm] - stop tracing methods [tp] - start tracing population events [sp] - stop tracing population events [S] - stop tracing [g] - force synchronous garbage collection [dp] - dump a generation's population [dr] - dump a generation's references [ps] - print system state [q] - quit program [u <string>] - user event [<Enter>] - exit command handler ----------------------------------------------- >
There is also a programmatic interface which allows you to take
memory snapshots under the control of your Java program. To use this
interface,
run your program using the Jinsight instrumented tracing VM as described
above, with the additional file <instrumented VM path>/lib/jintrace.jar
added to the CLASSPATH. To take a snapshot of memory under
the control of your program, use either of the following calls:
import com.ibm.jinsight.tracing; JinsightCtrl.dumpPopulation(); // Dump object population JinsightCtrl.dumpReferences(); // Dump object pop & refs
set CLASSPATH=<path where your program is>
jinsight_trace yourProgram yourProgramArgsTo turn tracing on or off from within your program, use the following code:
import java.lang.Runtime;
Runtime.getRuntime().traceMethodCalls(true); // turns tracing on Runtime.getRuntime().traceMethodCalls(false); // turns tracing offTo turn tracing on from the command line window:
To turn tracing off:
set CLASSPATH=<path for your instrumented VM>;<path where your program is>
appletviewer_g -J-tracemethods -J-trace:yourtrace.trc yourapplet(no space between -J and -tracemethods, -J and -trace).
To trace servlets and other server-side activity using Jinsight on Windows, set up WebSphere 3.0.2 to use the Jinsight JDK instrumentation for the particular managed server(s) you wish to trace. The following guidelines apply to the IBM WebSphere 3.0.2 Application Server on Windows, installed, for example, in directory C:\WebSphere\AppServer. Similar techniques may apply to other servers.
The basic approach to configuring WebSphere will be to use the Jinsight instrumented JVM only for the managed server(s) to be traced.
install Jinsight2.0 make a copy of the WebSphere 3.0.2 standard JDK populate the copied JDK with Jinsight java_g instrumentation files set up WebSphere to control use of Jinsight instrumentation
In this section, these directory and server names are used:
C:\WebSphere\AppServer -- the directory containing WebSphere 3.0.2 C:\SQLLIB -- the directory containing DB2 C:\jinsight2.0 -- the directory containing Jinsight 2.0 C:\WebSphereJDK -- the directory containing the WebSphere 3.0.2 jdk C:\WebSphereJDKcopy -- the copied WebSphere 3.0.2 jdk to be instrumented Default Server -- a sample WebSphere managed server to be traced
C:\WebSphere\AppServer\bin\admin.configEdit the classpath line that starts with com.ibm.ejs.sm.adminserver.classpath as follows: To the end of the classpath, add
;C:/jinsight2.0/n118p-2.0/lib/jintrace.jarFurthermore, if your WebSphere 3.0.2 version is prior to 3.0.2.3, then make the following additional change: To the beginning of the classpath, add
C:/jinsight2.0/was3.0.2-select-jvm.jar;Alternatively, if you start up the WebSphere 3 admin server from a batch file, add
The reason for adding the reference to the jintrace.jar library here instead of adding the library itself to the servlets directory is that the Jinsight TraceControlservlet makes native calls for some of its functions.
To make a trace while WebSphere is running under Jinsight instrumentation, open the trace control interface file jintrace.htm in a browser. This file is distributed in directory jinsight2.0. The browser can be on a different machine. Fill in the WAS server name (possibly qualified by the application name). Let your application run to the point you want to trace, and then press the trace control buttons Start, Stop, DumpPopulation, etc. Detailed directions are in the section Tracing Servlets.
If you didn't specify a location for the trace file, the trace will be in C:\winnt\system32\com_ibm_ejs_sm_server_ManagedServer.trc by default. After tracing, copy it somewhere else so it doesn't get overwritten the next time you run. You can also specify a trace filename using -trace:filename on the VM command line for the default server.
To trace servlets and other server-side activity using Jinsight on AIX, set up WebSphere 3.0.2 to use the Jinsight JDK instrumentation for the particular managed server(s) you wish to trace. The following guidelines apply to the IBM WebSphere 3.0.2 Application Server on AIX, installed, for example, in directory /usr/IBMWebAS. Similar techniques may apply to other servers.
The basic approach to configuring WebSphere will be to use the Jinsight instrumented JVM only for the managed server(s) to be traced.
Install Jinsight2.0
Set up WebSphere to control use of Jinsight instrumentation
In this section, these directory and server names are used:
/usr/IBMWebAS -- the directory containing WebSphere 3.0.2 /usr/jinsight2.0 -- the directory containing Jinsight 2.0 /usr/jdk_base -- the directory containing the standard JDK Default Server -- a sample WebSphere managed server to be traced
uncompress jinsight2.0-aix-1.1.8.tar.Z mv jinsight2.0-aix-1.1.8.tar /usr cd /usr tar xvf jinsight2.0-aix-1.1.8.tar
This will create a /usr/jinsight2.0 directory, where 2.0 is the Jinsight version and release. Inside this directory, a subdirectory a118-2.0 is created. This subdirectory contains the instrumented JDK.
:/usr/jinsight2.0/a118-2.0/lib/jintrace.jarFurthermore, if your WebSphere 3.0.2 version is prior to 3.0.2.3, then make the following additional change: To the beginning of the classpath, add
/usr/jinsight2.0/was3.0.2-select-jvm.jar:
cd /usr/IBMWebAS/bin ./startupServer.sh & (wait until the admin server is ready) ./adminclient.sh &
To control tracing while a WebSphere managed server is running under Jinsight instrumentation, open the trace control interface file jintrace.htm in a browser. This file is distributed in directory jinsight2.0. The browser can be on a different machine. Fill in the WAS server name (possibly qualified by the managed server name). Let your managed server application run to the point you want to trace, and then press the trace control buttons Start, Stop, DumpPopulation, etc. Detailed directions are in the section Tracing Servlets.
The trace file you create should be in file /usr/jinsight2.0/jinsight.trc if that is what you specified above with the JINSIGHT_TRACEFILE_NAME environment variable. After tracing, copy it somewhere else so it doesn't get overwritten the next time you run.
Try clicking first on the button Stop tracing methods, to insure that the Jinsight tracing control servlet is loaded and is operating. You should see a confirmation that the request was executed. Use the "Back" key on the browser to return, to issue another trace control request. Let your WebSphere application run to the spot that you want to trace. Use the HTML form to start and stop tracing of methods. Make sure you trace only the sections you need, since the trace files grow very quickly.
If you need to call the trace control servlet directly without using
the HTML interface, the usage is as follows, where server is
the server name running WebSphere Application Server:
http://server/servlet/jintrace?command=tm
- start/resume tracing methods
http://server/servlet/jintrace?command=sm
- stop tracing methods
http://server/servlet/jintrace?command=dp
- dump object population
http://server/servlet/jintrace?command=dr
- dump object population and references
Each command returns an HTML document with a status confirmation.
As an alternative to using the HTML user interface, your server-side
Java program can instead use the programmatic interface
functions
Runtime.getRuntime().traceMethodCalls(true)
Runtime.getRuntime().traceMethodCalls(false)
com.ibm.jinsight.tracing.JinsightCtrl.dumpPopulation()
com.ibm.jinsight.tracing.JinsightCtrl.dumpReferences()
to start and stop Jinsight method tracing and to dump objects and references.
Tracing Commands and Options for Jinsight2.1 on Windows Tracing Commands and Options for Jinsight2.1 on OS/390 Tracing Commands and Options for Jinsight2.1 on AIX