Debugging native code with Hotspot and GDB
The last couple of hours I struggled to debug a segfault some JNI code of OpenJDK. I could not get GDB doing anything useful with Hotspot. Until I discovered the following very useful command line option:
java -XX:OnError="gdb - %p" MyApplication
This fires up gdb whenever an error occurs, and sets up all the libraries etc for debugging. Very nice. Ideally you do this using a debug build of OpenJDK, so get get as much useful information as possible.
February 29th, 2008 at 3:20 pm
Yeah, that’s useful, I had same troubles with hotspot and java-gnome few weeks ago, and debugging it the “usual” way was not really the best option.
February 29th, 2008 at 7:04 pm
Oh, nice! I usually set LD_LIBRARY_PATH but this way is much simpler.