0

I have been asked to debug some C++ shared library that relies on Java libraries by loading an embedded Java virtual machine. The invocation API of the Java Native Interface (JNI) is used for that purpose.

The JVM is loaded using the JNI_CreateJavaVM and Java components are then invoked from C++.

I have the source code for both Java and C++ libraries.

I am using gdb as my debugger (I am working on a remote Linux environment) but it doesn't seem to support stepping in the invoked Java code.

My question is, are there any tool or workaround that could make that possible?

Note: My question is similar to a previous one posted in 2017, How to debug Java code running inside native code-created JVM?. However, the answer focuses on using Eclipse.

Logan Farci
  • 5
  • 1
  • 2
  • Try starting the JVM with the extras argument in the linked answer when calling `JNI_CreateJavaVM` and then uses JDB from the command line to attach to it (see https://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html). – Holt Feb 17 '22 at 13:31
  • Hey, thanks a lot! I passed the `-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n` option to `JNI_CreateJavaVM` and I was able to attach to it running `jdb --attach 8000`. Have a great day. – Logan Farci Feb 17 '22 at 15:17

0 Answers0