[lldb-dev] how to build lldb-mi on OSX?

dawn at burble.org dawn at burble.org
Wed Sep 24 18:09:02 PDT 2014

On Thu, Sep 18, 2014 at 02:57:50PM -0700, dawn at burble.org wrote:
> checkout the llvm/clang/lldb sources as if on Linux (i.e. with lldb in llvm/tools/lldb)
> cd ~/llvm
> mkdir build_ninja && cd build_ninja
> cmake -G Ninja -DCMAKE_CXX_FLAGS="-std=c++11" -DCMAKE_BUILD_TYPE=Debug ..
> ninja

While the above steps will get the lldb-mi app built, that's not enuogh.
Here's an update on some issues I ran into (please speak up if anyone has
ideas for why I had these issues and/or how to fix):

- Building with cmake+ninja doesn't create dSYM files.  To workaround
this I ran dsymutil on the files, e.g. in build_ninja directory do:
    dsymutil bin/lldb-3.6.0
    dsymutil bin/lldb-mi-3.6.0
    dsymutil lib/liblldb.3.6.0.dylib

- Building with cmake+ninja doesn't codesign correctly for some reason,
because when you try to debug an app you get
    "error: process launch failed: unable to locate debugserver".
My workaround for this was to point LLDB_DEBUGSERVER_PATH at a debugserver
I built in the XCode IDE (which somehow is able to get the codesigning right):
    export LLDB_DEBUGSERVER_PATH=/Users/dawn/lldb/Xcode/DerivedData/lldb-adprtpcrhggcnrajjedcatojtgnr/Build/Products/Debug/debugserver
You can also point it to XCode's debugserver:
    export LLDB_DEBUGSERVER_PATH=/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/debugserver
Note: trying the steps described here
    https://gist.github.com/thlorenz/a068c202f2487ec13809 didn't work for me.

- Running lldb-mi had some quirks.  Here's a debug session and embedded
C++-style comments for a simple C++ console app I debugged:

  ~/llvm/build_ninja/bin/lldb-mi-3.6.0 --interpreter
    (gdb)-file-exec-and-symbols /tmp/a.out
    (gdb)-exec-run			//don't wait for prompt afterwards
    (gdb)-break-insert main
    (gdb)-break-insert x.cpp:8
    (gdb)-stack-list-arguments 1
    (gdb)-stack-list-locals 0 			//also listed globals
    (gdb)-var-create var1 --thread 1 --frame 0 * i
    (gdb)-var-show-attributes var1
    (gdb)-var-list-children var1 		//gets var1 does not exist
    (gdb)-var-evaluate-expression var1 		//gets var1 does not exist
    (gdb)-var-delete var1
    (gdb)-stack-info-depth 512 --thread 1 --frame 0
    (gdb)-stack-list-frames --thread 1 --frame 0 1
    (gdb)-exec-next --thread 1 --frame 0
    (gdb)-exec-step --thread 1 --frame 0
    (gdb)-gdb-exit				//appears to hangs after this
         q     					//needed to exit

The following don't appear to be implemented yet:
    -stack-info-frame, -data-info-line, -symbol-list-lines,
    -stack-list-variables, -var-evaluate-expression, -var-info-num-children

So it's a great start in spite of the rough edges.  Many thanks to the
contributers for the support! :)


More information about the lldb-dev mailing list