Debugging native images
Debugging a native image requires building the image with debug info. We can use -H:GenerateDebugInfo=1
. Here is an example of using this argument for FibonnacciCalculator
:
native-image -H:GenerateDebugInfo=1 FibonacciCalculator
The generated image has debug information in the form of the GNU Debugger (GDB). This can be used to debug the code at runtime. The following shows the output of running the preceding command:
native-image -H:GenerateDebugInfo=1 FibonacciCalculator [fibonaccicalculator:57833] classlist: 817.01 ms, 0.96 GB [fibonaccicalculator:57833] (cap): 6,301.03 ms, 0.96 GB [fibonaccicalculator:57833] setup: 9,946.35 ms, 0.96 GB [fibonaccicalculator:57833] (clinit): 147.54 ms, 1.22 GB [fibonaccicalculator:57833] (typeflow): ...