Git Product home page Git Product logo

lldb-eval's Introduction

lldb-eval - blazing fast debug expression evaluation

Build Status

What

lldb-eval is an LLDB-based library for evaluating debug expressions in the context of the debuggee process. All modern debuggers support evaluating expressions to inspect the target process state: print out variables, access member fields, etc. lldb-eval is basically a REPL-like library, that allows to inspect the process state using the familiar C++ syntax. The primary use-case is IDE integration (for example, Stadia for Visual Studio).

Why

LLDB has a very powerfull built-in expression evaluator (available via expr command). It can handle almost any valid C++ as well as perform function calls. But the downside of this power is poor performance, especially for large programs with lots of debug information. This is not as critical for interactive use, but doesn't work well for implementing IDE integrations. For example, Stadia debugger for Visual Studio evaluates dozens and hundreds of expressions for every "step", so it has to be fast.

lldb-eval makes a trade-off between performance and completeness, focusing on performance. It features a custom expression parser and relies purely on the debug information, aiming at sub-millisecond evaluation speed.

Build & Test

Dependencies

Linux

Install the dependencies:

sudo apt install lld-10 clang-10 lldb-10 llvm-10-dev libclang-10-dev liblldb-10-dev

Or build them from source, see the instructions in the LLDB documentation.

Windows

On Windows we need to build LLDB (and other parts) from source. The steps are basically the same as for Linux. You will need: CMake, Python3, SWIG, Ninja and Visual Studio (tested with Visual Studio 2019 16.6.5).

Hint: You can install the dependencies via Chocolatey.

Run the x64 Native Tools Command Prompt for VS 2019:

git clone https://github.com/llvm/llvm-project.git
cd llvm-project
mkdir build_x64_optdebug
cd build_x64_optdebug

cmake ^
    -DCMAKE_INSTALL_PREFIX='C:\src\llvm-project\build_x64_optdebug\install' ^
    -DLLVM_ENABLE_PROJECTS='lldb;clang;lld' ^
    -DCMAKE_BUILD_TYPE=RelWithDebInfo ^
    -DPYTHON_HOME=C:\Python38 ^
    -GNinja ^
    ../llvm

ninja install

Build

lldb-eval uses Bazel, you can find the installation instructions on its website.

You need to set the LLVM_INSTALL_PATH environmental variable with a location to your LLVM installation:

# If you installed the packages via "apt install".
export LLVM_INSTALL_PATH=/usr/lib/llvm-10

# If you built it from source using the instructions above.
export LLVM_INSTALL_PATH=C:\src\llvm-project\build_x64_optdebug\install

Now you can build and test lldb-eval:

# Build and run all tests
bazel test :all

# Evaluate a sample expression
bazel run :main -- "(1 + 2) * 42 / 4"

Disclamer

This is not an officially supported Google product.

lldb-eval's People

Contributors

werat avatar

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.