Rob asked about how to debug into JNI code yesterday. I haven't had the need to debug into JNI code for quite some time. But I know it is possible, at least on Solaris/x86 with jdb and dbx. But that was a long time ago when jdb was the only debugging option on the Java side and System.out.println() was still mentioned as an alternative to debugging for even the non-JNI Java code.
So I took my hello world JNI project and tried to debug it with jdb and gdb (on GNU/Linux/x86). It is pretty straightforward. You just start the Java process in jdb and let it run to a point where the native library is loaded. At that point you attach gdb to the running Java process and set breakpoints in the native code. About the only unusual thing you have to be careful about is to invoke jdb with the proper
-Djava.library.path=<... (paths to JNI .so files)>
option under the proper
LD_LIBRARY_PATH=<... (paths to C++ .so files)>
environment. And you have to compile your Java and C++ code with the debugging information turned on.
A little Googling turned up this IBM developerWorks article from 2269 days ago that describes this process in more detail.
Of course, nowadays we can use our favorite Java IDE to replace jdb.
My question today is: What is a good modern way of carrying out the native debugging in a GUI environment? Although I'm currently on GNU/Linux/x86, I would also like to know answers to this question on other platforms.
I realize this is a more general question about how to debug a library/dll/shared object. And I would imagine the following combinations will work:
OS
IDE/GUI Debugger
Windows
Visual Studio
Mac OS X
XCode
GNU/Linux
Emacs gdb-mode
Are there other tools that has been used successfully fo this task? I'm playing with NetBeans 6.0's C++ support, but I couldn't find a way to debug into a DLL on Windows or a shared object on GNU/Linux. What about Eclipse CDT? DDD? Or anything else I don't know yet?