Debugging GlobalSight
Debugging GlobalSight
Probably the best way to debug GlobalSight is to start it so that it accepts
debugger connections, then attach to it whenever you want to debug. The
following instructions use the jdb
debugger that comes with the
Sun JDK, but other debuggers can attach in a similar way.
First, pass the following command line options to
java
:
-agentlib:jdwp=transport=dt_socket,address=8912,server=y,suspend=n
.
On Linux, edit jboss/jboss_server/bin/run.conf
. This applies whether GlobalSight is started from
the init.d
service or the startJboss.sh
script.
Add the line
JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=8912,server=y,suspend=n
On Windows, edit jboss\jboss_server\bin\run.bat
and add
set JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_socket,address=8912,server=y,suspend=n
The basic command to attach with jdb
is
jdb -sourcepath=<source>/main6/envoy/src/java:<source>/main6/diplomat/dev/src/java:<source>/main6/ling -attach 8912
on Unix and
jdb -sourcepath=<source>\main6\envoy\src\java;<source>\main6\diplomat\dev\src/java;<source>\main6\ling -attach 8912
on Windows. <source> refers to the base of the GlobalSight source tree. This tells jdb
where to find the GlobalSight source code.
Third-Party Libraries
You may need to debug into some of the third-party libraries that GlobalSight uses, such as Tomcat or Xerces. First, download the source for any of the following packages, and unpack them into a directory (referred to as <libsource>):
- Tomcat 5.0.28
- JBoss 4.0.1
- Hibernate 3.1
- Lucene 1.9 (The actual version used in GlobalSight is 1.4.2, but I can't find the source for that version.)
- Commons Logging 1.0.3
- log4j 1.2.8
- dom4j 1.6.1
- Xerces 1.4.3
- Jaxen 1.1 beta 4
The versions are those currently used in GlobalSight (except for Lucene, as noted).
After downloading the third-party sources, the full jdb command is
jdb -sourcepath=<source>/dev/main6/envoy/src/java:<source>/dev/main6/diplomat/dev/src/java:<source>/dev/main6/ling:<libsource>/jakarta-tomcat-5.0.28-src/jakarta-tomcat-catalina/catalina/src/share:<libsource>/jboss-4.0.1-src/system/src/main:<libsource>/hibernate-3.1/src:<libsource>/lucene-1.9-final/src/java:<libsource>/commons-logging-1.0.3-src/src/java:<libsource>/jakarta-log4j-1.2.8/src/java:<libsource>/dom4j-1.6.1/src/java:<libsource>/xerces-1_4_3/src:<libsource>/jaxen-1.1-beta-4/src/java/main -attach 8912
on Unix and
jdb -sourcepath=<source>\dev\main6\envoy\src\java;<source>\dev\main6\diplomat\dev\src\java;<source>\dev\main6\ling;<libsource>\jakarta-tomcat-5.0.28-src\jakarta-tomcat-catalina\catalina\src\share;<libsource>\jboss-4.0.1-src\system\src\main;<libsource>\hibernate-3.1\src;<libsource>\lucene-1.9-final\src\java;<libsource>\commons-logging-1.0.3-src\src\java;<libsource>\jakarta-log4j-1.2.8\src\java;<libsource>\dom4j-1.6.1\src\java;<libsource>\xerces-1_4_3\src;<libsource>\jaxen-1.1-beta-4\src\java\main -attach 8912
on Windows.
If in a debugging session you need to add a new source directory, enter
use <sourcepath>
at the jdb
command line.
Command-Line Editing
To add command-line editing, history and keyword completion to
jdb
on Unix, I highly recommend rlwrap.
Just add rlwrap
in front of your jdb
command line. You might also create a file in your home directory called
~/.jdb_completions
containing common commands, for example:
stop clear catch ignore run cont step next list where up down print dump locals set quit