I use Runtime.getRuntime().exec() to execute my native cpp application and would like to attach/debug the native application while running inside Java.
Adding
__asm int 3;
into my native application and executing it OUTSIDE java, Windows prompts me whether I want to debug it, which is all good.
However, running INSIDE java Runtime.getRuntime().exec(), the interrupt is intercepted by JVM and an exception is thrown.
Is there any way to debug my native application while it’s running inside Java Runtime.getRuntime().exec() ?
Put some break points into your native app and compile it with debug options.
In your java code place a break point before the
call and start the java app.
Open Visual Studio (guess you use that under windows) select Debug->Attach to process. Attach to the java process.
Continue in java (jump over the break point) then you should see your VS stop at the native break point.
I don’t have any Windows machine here with VS installed so i can’t test it, but it should work. I haven’t done that in a while but that should be all you need.
Edit: Sorry i skipped the “application with interrupt” part. I have no clue how to “re-throw” the assembler interrupt call. Hopefully i could help you anyway 😉