Building lldb on Mac
Create Codesign Certificate
First we need to create a certificate. The llvm provided a way to do
that, but I found this
way to work slightly better for me. Just substitute
lldb_codesign
for the certificate name, instead of gdb-cert
.
Install swig dependency
brew install swig
Pulling Code and Building
Note
Currently GDB JIT
support is disabled for MAC. To turn it on apply the following patch before running the build.
enable-jit.diff
Index: source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
===================================================================
--- source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp (revision 213962)
+++ source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp (working copy)
@@ -363,9 +363,9 @@
JITLoaderGDB::CreateInstance(Process *process, bool force)
{
JITLoaderSP jit_loader_sp;
- ArchSpec arch (process->GetTarget().GetArchitecture());
- if (arch.GetTriple().getVendor() != llvm::Triple::Apple)
- jit_loader_sp.reset(new JITLoaderGDB(process));
+ /*ArchSpec arch (process->GetTarget().GetArchitecture());
+ if (arch.GetTriple().getVendor() != llvm::Triple::Apple)*/
+ jit_loader_sp.reset(new JITLoaderGDB(process));
return jit_loader_sp;
}
Apply it via patch -p0 -i ~/enable-jit.diff
.
Steps
svn co http://llvm.org/svn/llvm-project/lldb/trunk lldb
cd lldb
xcodebuild -configuration Release
Running the build will automatically check out extra sources it needs, like llvm
. The build will prompt you twice for
your username and password in order to perform the code signing.
Replacing default lldb
Assunming /usr/local/bin
is in your path before /usr/bin
- homebrew users will be setup that way already, do
ln -s `pwd`/build/Release/lldb /usr/local/bin/lldb
lldb --version
This should print lldb-320.99.0
or higher if all is setup correctly.
Opening Xcode Project
In case you are interested at looking at lldb
s code you may open the Xcode project provided.
open lldb.xcodeproj
debugserver codesigning issue with cmake+ninja build on OSX was fixed in lldb svn rev.218890, so no more "error: process launch failed: unable to locate debugserver", although you will need to point LLDB_DEBUGSERVER_PATH at your built debugserver before debugging with lldb (e.g. export LLDB_DEBUGSERVER_PATH=$BUILDDIR/bin/debugserver). No need to launch debugserver separately anymore.