Tuesday, June 19, 2007

Project status

Work done

  • Creation of a new plug-in : the plug-in adds a "JNI Application" group in the "Debug Dialog"
  • When we launch a debug session :
    • The JVM is lauched and Java internal debugger of Eclipse connects to it
    • The PID of the lauched JVM is found
    • The C debugger is attached to the launched JVM process (it works with gdb, I dont know if others debuggers offer this possibility )
  • The debug perspective is open and we could see the 2 debuggers launched


versions used : eclipse SDK 3.3 RC4 and CDT 4.0 RC3
os : GNU/linux on a ppc processor
java version min: 1.5 (I think I will change to 1.4)

getting the svn code : svn co https://eclipse-incub.svn.sourceforge.net/svnroot/eclipse-incub/jni_seamless_debugging jni_seamless_debugging

  • First step : you have to install the plugin. If you are here, I am sure you know how to do it.
  • Second step : you have to create a Java Application which uses JNI.
  • Third step : set a breakpoint in the Java code after the code which loads the native library

  • Fourth step : set a breakpoint in the C code in the begin of a native method

  • Fifth step : Open the debug dialog and create a new configuration of "Java JNI Application" kind

    In the tabs you have to configure the Java and C project, and specify the javaw path as C/C++ application. On linux machines you could have to add the current directory in the library path environment variable

    Then click on debug
  • Sixth step : the debug perspective will be launched, with the 2 debuggers.

  • Seventh step : Resume the JVM process (right click on "gdb/mi") and start debugging !


It makes 3 weeks that I am working on C source files visualisation. I spend too much time on this, and don't find why it doesn't work.

To resume :

  • I have created a JMLSourceLookupDirector
  • I have added CParticipant and JavaParticipant
  • I have created a JMLSourcePathComputer which contains a JavaSourcePathComputer and a CDelegate.For the computeSourceContainers() method I only merge results obtained from JavaSourcePathComputer and CDelegate computeSourceContainers() methods. I checked with the debugger, and it works well.

When I try to debug a JNI Application with my plug-in, the JVM is launched, gdb is attached and the code stop on the first breakpoint in the Java Code. Then I debug step by step until the native call.
When I arrive to the breakpoint in the C code, it stops well, but the Editor doesn't display the file.

Of course the path is correct and the directory is in the source path.

Any idea or comment is welcome


Quentin said...

Looks like great work Mariot - well done! I'm looking forward to try it as soon as as got some time!

As for the problem you have with the editor, I've got the same one using CDT, which have been fixed when I switched in my debug confiuration to gdb/mi mode, using the Window specific interface instead of the cygwin one.

Venkat said...

I read this in this Blog :the plug-in adds a "JNI Application" group in the "Debug Dialog".
Where do i get this Plugin. I want to debug the Native code (CPP Code) and my application is Java Application. I have few CPP files which we access thru JNI calls to Natvie CPP code.

Mariot Chauvin said...

venkat :

You have to checkout the code from the svn repository for the moment. I give the address in the post.

Tom Parry said...

IS there any update to this project lately (2008 June)?

Mariot Chauvin said...

Hi Tom,

I presented my work at EclipseCon'08. The code currently available on svn works with eclipse 3.3 with the ibm jre on a ppc architecture. I have currently no time to work on the project to made it available for Eclipse 3.4 or test it on a i586 architecture and/on with other JRE implementation. If you are interested in it contact me.