The LLDB Debugger

Continuous Integraton

The following LLVM buildbots build and test LLDB trunk:

Building LLDB

Building LLDB on Windows

Required Dependencies


This section describes how to set up your system and install the required dependencies such that they can be found when needed during the build process. The steps outlined here only need to be performed once.

  1. Install Visual Studio and the Windows SDK.

  2. Build Python from source using the solution file supplied with the Python 2.7 source distribution.

    Because LLDB functionality is compiled into a Python extension module, the extension module must be compiled with the same version of Visual Studio that Python itself was compiled with. The binary release of Python 2.7 is compiled with Visual Studio 2008, so it is incompatible with linking against LLDB.

    Note that if you plan to do both debug and release builds of LLDB, you will need to compile both debug and release builds of Python.

  3. Copy <python src dir>\PC\pyconfig.h to <python src dir>\Include.

    This is necessary because pyconfig.h is a hand-maintained file which is platform specific, so multiple copies of this file are included with each source distribution. It appears to be up to the person building Python to move the correct version of pyconfig.h to the Include folder.

  4. Install GnuWin32, making sure <GnuWin32 install dir>\bin is added to your PATH environment variable.

  5. Install SWIG for Windows, making sure <SWIG install dir> is added to your PATH environment variable.

  6. (Optional) Create a file somewhere on your disk called llvm_env.bat and add the following code to it:


    IF "%1" == "build" goto do_build
    IF "%1" == "dev" goto do_dev
    ECHO Unknown option, expected "build" or "dev"
    goto do_end

    ECHO Initializing MSVC Build Environment...
    CALL "c:\Program Files (x86)\Microsoft Visual Studio 12.0\vc\vcvarsall.bat"
    ECHO Initializing Python environment...
    set PYTHONPATH=<python src dir>\Lib;<cmake gen dir>\lib\site-packages
    set PATH=%PATH%;<python src dir>\PCbuild
    goto do_end

    goto do_end
  7. (Optional) To make the process of setting up the environment before building more convenient, you can optionally create a shortcut with the following properties:

    %windir%\system32\cmd.exe /K <path-to-llvm_env.bat> build

Building LLDB

Any command prompt from which you build LLDB should have a valid Visual Studio environment setup. This means you should run vcvarsall.bat or open an appropriate Visual Studio Command Prompt corresponding to the version you wish to use. Additionally, in order for LLDB to be able to locate Python to link against, you will need to set up your PYTHONPATH environment variable to contain two additional values:

  1. <python src dir>\Lib
  2. <folder where CMake build files are generated>\lib\site-packages

The first allows your custom built python installation to locate its system libraries, and the second allows Python to locate the LLDB extension module.

Steps 6 and 7 of Preliminaries describe a method for simplifying this setup.

Finally, when you are ready to build LLDB, generate CMake with the following command line:

cmake -G Ninja <cmake variables> <path to root of llvm src tree>

and run ninja to build LLDB, and ninja check-lldb to run LLDB's test suite.

Following is a description of some of the most important CMake variables which you are likely to encounter. A variable FOO is set by adding -DFOO=value to the CMake command line.

  • LLDB_TEST_DEBUG_TEST_CRASHES (Default=0): If set to 1, will cause Windows to generate a crash dialog whenever lldb.exe or the python extension module crashes while running the test suite. If set to 0, LLDB will silently crash. Setting to 1 allows a developer to attach a JIT debugger at the time of a crash, rather than having to reproduce a failure or use a crash dump.
  • PYTHON_LIBRARY: Path to python27.lib. If doing a debug build, note that the library is called python27_d.lib. Generally this should be set to
    <python src dir>\PCBuild\python27(_d).lib
  • PYTHON_INCLUDE_DIR: Path to python include directory. Generally this should be set to
    <python src dir>\Include
  • PYTHON_EXECUTABLE: Path to python.exe. If doing a debug build of LLDB, note that the executable is called python_d.exe. Generally this should be set to
    <python src dir>\PCBuild\python(_d).exe
  • LLDB_TEST_COMPILER: The test suite only supports testing executables that were compiled with clang. This specifies the path to the copy of clang that you wish to use to compile test executables. To use the version of clang that you compiled alongside LLDB, set this to
    <folder where CMake build files are generated>\bin\clang.exe

Building LLDB on Mac OS X

Building on Mac OS X is as easy as downloading the code and building the Xcode project or workspace:


  • XCode 4.3 or newer requires the "Command Line Tools" component (XCode->Preferences->Downloads->Components).
  • Mac OS X Lion or newer requires installing Swig.

Building LLDB

  • Download the lldb sources.
  • Follow the code signing instructions in lldb/docs/code-signing.txt
  • In Xcode 3.x: lldb/lldb.xcodeproj, select the lldb-tool target, and build.
  • In Xcode 4.x: lldb/lldb.xcworkspace, select the lldb-tool scheme, and build.

Building LLDB on Linux and FreeBSD

This document describes the steps needed to compile LLDB on most Linux systems, and FreeBSD.


LLDB relies on many of the technologies developed by the larger LLVM project. In particular, it requires both Clang and LLVM itself in order to build. Due to this tight integration the Getting Started guides for both of these projects come as prerequisite reading:

Supported compilers for building LLDB on Linux include:

  • Clang 3.2
  • GCC 4.6.2 (later versions should work as well)

It is recommended to use libstdc++ 4.6 (or higher) to build LLDB on Linux, but using libc++ is also known to work.

On FreeBSD the base system Clang and libc++ may be used to build LLDB, or the GCC port or package.

In addition to any dependencies required by LLVM and Clang, LLDB needs a few development packages that may also need to be installed depending on your system. The current list of dependencies are:

So for example, on a Fedora system one might run:

> yum install swig python-devel libedit-devel

On a Debian or Ubuntu system one might run:

> sudo apt-get install build-essential subversion swig python2.7-dev libedit-dev libncurses5-dev


> sudo apt-get build-dep lldb-3.3 # or lldb-3.4

On FreeBSD one might run:

> pkg install swig python

If you wish to build the optional reference documentation, additional dependencies are required:

  • Graphviz (for the 'dot' tool).
  • doxygen (only if you wish to build the C++ API reference)
  • epydoc (only if you wish to build the Python API reference)

To install the prerequisites for building the documentation (on Debian/Ubuntu) do:

> sudo apt-get install doxygen graphviz
> sudo pip install epydoc # or install package python-epydoc

Building LLDB

We first need to checkout the source trees into the appropriate locations. Both Clang and LLDB build as subprojects of LLVM. This means we will be checking out the source for both Clang and LLDB into the tools subdirectory of LLVM. We will be setting up a directory hierarchy looking something like this:

                  `-- tools
                      +-- clang
                      `-- lldb

For reference, we will call the root of the LLVM project tree $llvm, and the roots of the Clang and LLDB source trees $clang and $lldb respectively.

Change to the directory where you want to do development work and checkout LLVM:

> svn co llvm

Now switch to LLVM’s tools subdirectory and checkout both Clang and LLDB:

> cd $llvm/tools
> svn co clang
> svn co lldb

In general, building the LLDB trunk revision requires trunk revisions of both LLVM and Clang.

It is highly recommended that you build the system out of tree. Create a second build directory and configure the LLVM project tree to your specifications as outlined in LLVM’s Getting Started Guide. A typical build procedure might be:

> cd $llvm/..
> mkdir build
> cd build

To build with CMake

Using CMake is documented on the Building LLVM with CMake page. Building LLDB is possible using one of the following generators:

  • Ninja
  • Unix Makefiles

Using CMake + Ninja

Ninja is the fastest way to build LLDB! In order to use ninja, you need to have recent versions of CMake and ninja on your system. To build using ninja:

> cmake .. -G Ninja
> ninja lldb
> ninja check-lldb

Using CMake + Unix Makefiles

If you do not have Ninja, you can still use CMake to generate Unix Makefiles that build LLDB:

> cmake ..
> make
> make check-lldb

To build with autoconf

If you do not have CMake, it is still possible to build LLDB using the autoconf build system. If you are using Clang or GCC 4.8+, run:

> $llvm/configure
> make

If you are building with a GCC that isn't the default gcc/g++, like gcc-4.9/g++-4.9

> $llvm/configure CC=gcc-4.9 CXX=g++-4.9
> make CC=gcc-4.9 CXX=g++-4.9

If you are running in a system that doesn't have a lot of RAM (less than 4GB), you might want to disable debug symbols by specifying DEBUG_SYMBOLS=0 when running make. You will know if you need to enable this because you will fail to link clang (the linker will get a SIGKILL and exit with status 9).


To run the LLDB test suite, run:

> make -C tools/lldb/test

Note that once both LLVM and Clang have been configured and built it is not necessary to perform a top-level make to rebuild changes made only to LLDB. You can run make from the build/tools/lldb subdirectory as well.

If you wish to build with libc++ instead of libstdc++ (the default), run configure with the --enable-libcpp flag.

If you wish to build a release version of LLDB, run configure with the --enable-optimized flag.


By default, the check-lldb target builds the 64-bit variants of the test programs with the same compiler that was used to build LLDB. It is possible to customize the architecture and compiler by appending -A and -C options respectively to the CMake variable LLDB_TEST_ARGS. For example, to test LLDB against 32-bit binaries built with a custom version of clang, do:

> cmake -DLLDB_TEST_ARGS="-A i386 -C /path/to/custom/clang" -G Ninja
> ninja check-lldb

Note that multiple -A and -C flags can be specified to LLDB_TEST_ARGS.

In addition to running all the LLDB test suites with the "check-lldb" CMake target above, it is possible to run individual LLDB tests. For example, to run the test cases defined in, run:

> cd $lldb/test
> python --executable <path-to-lldb> -p

In addition to running a test by name, it is also possible to specify a directory path to in order to run all the tests under that directory. For example, to run all the tests under the 'functionalities/data-formatter' directory, run:

> python --executable <path-to-lldb> functionalities/data-formatter

To dump additional information to stdout about how the test harness is driving LLDB, run with the -t flag. Many more options that are available. To see a list of all of them, run:

> python -h

Building API reference documentation

LLDB exposes a C++ as well as a Python API. To build the reference documentation for these two APIs, ensure you have the required dependencies installed, and build the lldb-python-doc and lldb-cpp-doc CMake targets.

The output HTML reference documentation can be found in <build-dir>/tools/lldb/docs/.

Additional Notes

LLDB has a Python scripting capability and supplies its own Python module named lldb. If a script is run inside the command line lldb application, the Python module is made available automatically. However, if a script is to be run by a Python interpreter outside the command line application, the PYTHONPATH environment variable can be used to let the Python interpreter find the lldb module.

The correct path can be obtained by invoking the command line lldb tool with the -P flag:

> export PYTHONPATH=`$llvm/build/Debug+Asserts/bin/lldb -P`

If you used a different build directory or made a release build, you may need to adjust the above to suit your needs. To test that the lldb Python module is built correctly and is available to the default Python interpreter, run:

> python -c 'import lldb'