Gnome-GCJ
new GNOME bindings for the Java language
Debugging
This page gives a small introduction into the gdb debugger and into the
debugging of Gnome-GCJ applications.
gdb invocation
To debug an application with gdb, execute gdb >binary-name< .
This opens a gdb process. I usually execute gdb --args ./criawips gnome.criawips
to be able to add command line arguments that are not processed by gdb.
[15:23] herzi@gromit:~/Hacking/GNOME/Office/criawips-java/gnu/criawips > ../../libtool gdb --args ./criawips
*** Warning: inferring the mode of operation is deprecated.
*** Future versions of Libtool will require -mode=MODE be specified.
GNU gdb 6.1-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "powerpc-linux"...Using host libthread_db library "/lib/libthread_db.so.1".
(gdb)
starting the application
Use run to start the application in the debugger, try to
reproduce the bug and you'll get something like this:
(gdb) run
Starting program: /home/herzi/Hacking/GNOME/Office/criawips-java/gnu/criawips/.libs/lt-criawips
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 5053)]
[New Thread 32769 (LWP 5056)]
[New Thread 16386 (LWP 5057)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 5053)]
gnu.criawips.Criawips.Criawips(java.lang.String[]) (this=@100b3440, args=@1006afe0) at Criawips.java:23
23 fs.addDeleteEventListener(this);
Current language: auto; currently java
(gdb)
Variable status
Use print <varname> to see some info about this variable.
(gdb) print fs
$1 = null
(gdb)
Backtrace/Stacktrace
To get information like exception.printStackTrace(); produces,
use backtrace (or the shortcut back ).
(gdb) back
#0 gnu.criawips.Criawips.Criawips(java.lang.String[]) (this=@100b3440, args=@1006afe0) at Criawips.java:23
#1 0x1000cf10 in gnu.criawips.Criawips.main(java.lang.String[]) (args=@1) at Criawips.java:56
#2 0x0f09bba0 in gnu::gcj::runtime::FirstThread::call_main () from /usr/lib/./libgcj.so.4
#3 0x0f12a2c8 in gnu::gcj::runtime::FirstThread::run () from /usr/lib/./libgcj.so.4
#4 0x0f0ab894 in _Jv_ThreadRun () from /usr/lib/./libgcj.so.4
#5 0x0f080294 in _Jv_RunMain () from /usr/lib/./libgcj.so.4
#6 0x0f0803b8 in JvRunMain () from /usr/lib/./libgcj.so.4
#7 0x1000ca90 in main (argc=0, argv=@100b3440) at /tmp/cc51WP7F.i:11
(gdb)
traps
GDB doesn't seem to love debugging of applications compiled with gcj, but
fortunately we can convince it to do that nicely by executing the following
commands in gdb. They only need to be run once, gdb stores this information.
handle SIGPWR nostop noprint
handle SIGXCPU nostop noprint
|