The LLVM code base through a debugger
As you discovered in the previous section, a debugger offers a powerful mechanism to evaluate any expression, including the ability to make function calls. In this section, we’ll highlight some of the APIs of the LLVM code base that you can use to easily inspect the state of the LLVM IR.
When built with the right CMake options, which is the case when built in Debug
mode, most of the key LLVM classes come with a dump
method. This method prints the related object in a human-readable form, similar to what you can see in the textual representation of the LLVM IR. What this means is that by calling this method from the debugger, you can easily visualize what the related object represents.
Note
By default, the dump
methods are only available when LLVM is built with assertions enabled. You can change this behavior by setting the LLVM_ENABLE_DUMP
CMake variable to on
or off
.
Let’s see these dump
methods in action...