Reputation: 73
I have a Java Project in which I used Native Library (dll) whose code is written in CPP. I want to debug the java application and as soon as I reach to a point from where the native method compiled in dll called I want to step into the CPP code. How should I do this? Is there Any IDE available that can switch debugging between java and cpp code?
Upvotes: 7
Views: 8164
Reputation: 81
This also works for Eclipse: start debugging the "enveloping Java application" that invokes the .dll (or .so, on Linux), set a breakpoint at the accessory native call and start second debugger from the native process that is started there.... Result is: 2 debuggers, one running in Java and the second in the native .dll/.so... when the latter is finished and returns to Java again, it should be possible to resume Java debugging from there. In my environment, this setup works.
Upvotes: 1
Reputation: 2173
Don't know of any debugger that can actually switch but you can attach two debuggers to your process. Starting your Java program in your Java IDE in debug mode attaches the Java debugger. Then open the IDE you use for your CPP code and attach its debugger to the running Java process.
In Visual Studio this would be Debug -> Attach to Process...
. You get a dialog with a process list. Choose your Java process here. You might have to switch the field just above the list to "Native code" if Visual Studio can't detect that correctly. Set an appropriate breakpoint in your CPP code and the debugger will stop there. Make sure your Java process loads the debug version of the library for this to work.
Upvotes: 4