Giter Site home page Giter Site logo

inspector's Introduction

Inspector - A drop-anywhere C++ REPL

Build Status

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

Inspector example session

Presentation slides on Inspector

10 min video presentation on Inspector

Cppcast about Inspector

Build

Requirements

  • a c++ compiler (gcc or clang++)
  • libcling (see installation instructions below)
  • jsoncpp
  • python3
  • python-prompt-toolkit (for python3)
  • python-setuptools (for python3)
  • pkg-config

Build Cling

Note that for some linux distributions the cling project also provide pre-build binaries.

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 ..
cmake --build .
cmake --build . --target install

Build Inspector

git clone [email protected]:inspector-repl/inspector.git
cd inspector
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH="../inst" ..
cmake --build .

Usage

# 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

TODO

  • 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 cling / 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

inspector's People

Contributors

jhasse avatar liviurazorea avatar mic92 avatar mmmm1998 avatar stellarpower avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

inspector's Issues

Handle relative includes, which escapes .inspector-includes/ better

If I a file is relative to the compiler in an parent directory (ex.: gcc ../../test.cpp) then FILE contains also ...
This makes generated headers ending up outside the hidden directory .inspector-includes.

Possible hacky solution: Put headers in a sub-sub-sub-sub... directory (.inspector-includes/a/a/a/a/a/a) and print a warning if this level get exceeded.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.