Allows to inject a fully-functional C++17 REPL into running, compiled programs that can access your program state and offers features like code-completion and syntax highlighting.
The API is similar to tools like Pry in Ruby or Pdb in Python:
Example program:
// save as main.cpp
#include <iostream>
#include <string>
int main(int argc, char** argv) {
int a = 1;
std::string b = "hello world";
#include INSPECTOR
std::cout << "second break." << std::endl;
#include INSPECTOR
}
$ ./inspector prebuild main.cpp
$ clang++ $(./inspector print-cflags) main.cpp -o main
$ ./inspector repl
$ ./main
Presentation slides on Inspector
10 min video presentation on Inspector
- a c++ compiler (gcc or clang++)
- LLVM/Clang 22+ with clang-repl (unreleased as of August 23, 2025)
- jsoncpp
- python3
- python-prompt-toolkit (for python3)
- python-pygments (for python3)
- python-libclang (for python3)
- python-hatchling (for building the Python package)
- pkg-config
- ninja (build system)
The easiest way to get all dependencies is using the Nix flake:
nix develop
You need LLVM/Clang 22 or later with clang-repl support. As LLVM 22 is unreleased (as of August 23, 2025), you'll need to build from source or use the development version.
Building LLVM from source:
git clone https://github.com/llvm/llvm-project.git
cd llvm-project
cmake -S llvm -B build -G Ninja \
-DLLVM_ENABLE_PROJECTS="clang" \
-DCLANG_ENABLE_CLANG_REPL=ON \
-DCMAKE_BUILD_TYPE=Release
ninja -C build
Note: Package managers will provide LLVM 22 packages once it's officially released.
git clone git@github.com:inspector-repl/inspector.git
cd inspector
mkdir build
cd build
cmake -GNinja .. -DCLANG_LIBDIR=<path-to-llvm>/lib
ninja
Note: The -DCLANG_LIBDIR
flag should point to the lib directory of your LLVM/Clang installation. For example:
- If built from source:
-DCLANG_LIBDIR=/path/to/llvm-project/build/lib
- If installed system-wide:
-DCLANG_LIBDIR=/usr/lib/llvm-22/lib
# bring python bindings
# (requires clang with clang-repl support, LLVM 22+ required)
# and libclang into path
export PYTHONPATH=$(readlink -f <llvm-root>/src/tools/clang/bindings/python/)
export LD_LIBRARY_PATH=$(readlink -f <llvm-repo>/inst/lib)
cd build
./inspector prebuild ../test/test.cpp
gcc -o test-proc $(./inspector print-cflags) ../test/test.cpp
# start repl cli
./inspector repl
# let program connect to repl
./test-proc
- buildsystem integration:
- cmake
- autotools
- make
- meson
- include type declaration into the repl
- search for '#include INSPECTOR' before parsing (speed)
- use verbose mode of compiler to get additional include paths for clang-repl / libclang parsing
- multiprocessing scanning
- GDB/LLDB plugin: link/preload libinspector.so and invoke inspector with debug information from gdb/lldb.
- Support for more languages:
- C