inspector-repl / inspector
- среда, 14 февраля 2018 г. в 03:15:59
A drop-anywhere C++ REPL
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 presentation on Inspector
git clone http://root.cern.ch/git/llvm.git src
cd src
git checkout cling-patches
cd tools
git clone http://root.cern.ch/git/cling.git
git clone http://root.cern.ch/git/clang.git
cd clang
git checkout cling-patches
cd ../..
mkdir build inst
cd build
cmake -DCMAKE_INSTALL_PREFIX=../inst ../src
cmake --build .
cmake --build . --target install
git clone git@github.com:inspector-repl/inspector.git
cd inspector
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH="../inst" ..
cmake --build .
# bring python bindings
# (requires clang 5/trunk for python3 support, the clang branch from cling is new enough)
# 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