-
Notifications
You must be signed in to change notification settings - Fork 14
Debugging
Here we present a step-by-step tutorial for debugging FLIMLib's C/C++ code when invoked from Java.
The usual mvn install comamnd builds FLIMLib's native libraries as Release by default. To enable debug build on any supported platforms, change the cmake.build.option property in properties in pom.xml from Release to Debug.
Rebuild the project with
mvn clean install
On Windows with Visual Studio toolchain, this will create two debug database files (flimlib.pdb and flimlib-jni.pdb) in target/natives during the build. On Linux and macOS, nothing will change, except that the .so libraries will have debug information built into them.
If you are debugging FLIMLib from a dependent project such as flimj-ops or flimj-ui, make sure you change the flimlib.version property in the dependent project's pom.xml to the x.y.z-SHAPSHOT version you just built. You can find the exact version by searching for "SNAPSHOT" in FLIMLib's pom.xml.
Place a break point (immediately) before entry to native methods such as FLIMLib.GCI_triple_integral_fitting_engine() and launch the Java program. The execution will halt at the break point. This will give us time to do:
In your favorite C/C++ IDE, open the project and set break points in the C source files where you want to stop. For Visual Studio, it is recommended that you open target/build/flimlib.sln instead. Source files will be available in Solution Explorer > "Solution 'flimlib' > flimlib > Source Files.
Attach the debugger in the C/C++ IDE to the youngest Java process. For Visual Studio, you can go through to Debug > Attach to Process, search for "java" and select the process at the top of the list.
Click "continue" in your Java debugger. If set up correctly, the C/C++ debugger will notify when a break point in C/C++ source file is hit.