The Artima Developer Community
Sponsored Link

Java Buzz Forum
Friday Java Question: Debugging Into JNI Code

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Weiqi Gao

Posts: 1808
Nickname: weiqigao
Registered: Jun, 2003

Weiqi Gao is a Java programmer.
Friday Java Question: Debugging Into JNI Code Posted: Jan 18, 2008 8:24 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Weiqi Gao.
Original Post: Friday Java Question: Debugging Into JNI Code
Feed Title: Weiqi Gao's Weblog
Feed URL: http://www.weiqigao.com/blog/rss.xml
Feed Description: Sharing My Experience...
Latest Java Buzz Posts
Latest Java Buzz Posts by Weiqi Gao
Latest Posts From Weiqi Gao's Weblog

Advertisement

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?

Your help is appreciated.

Read: Friday Java Question: Debugging Into JNI Code

Topic: Google Down! Previous Topic   Next Topic Topic: The Mac Mini that hosts xom.nu, The Cafes, and Mokka mit Schlag seems to have died.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use