how to build lldb-mi on OSX?

Can someone please tell me how to build lldb with MI support on OSX?
I follow the instructions at
http://www.codeplay.com/portal/lldb-mi-driver---part-2-setting-up-the-driver
which say "the lldb-mi project is built as part of a full LLVM build" at
http://lldb.llvm.org/build.html, so I "build the lldb-tool scheme" in Xcode
but there's no lldb-mi anywhere, and lldb itself doesn't recognize the MI
commands. I have rev.217536 checked out yesterday in case that matters.
What am I missing?

Thanks in advance,
-Dawn

Hi Dawn,

I had built lldb-mi on OSX, however using CMake and Makefiles instead of from Xcode.
I have just committed two small fixes for lldb-mi to build and run on OSX.
Try building the tip.

I was able to debug a local x86_64-apple-darwin executable using lldb-mi from Eclipse on OSX.

Thanks,
Deepak

Thanks for responding. Still no lldb-mi* tho :(. I'd like to try your
cmake method next - what are the exact commands/steps you used? I had
tried cmake also with no luck, but there are several variations out there
so I want to make sure I try the exact steps you did to get it to work.

Thanks,
-Dawn

Right now if you take a look at:

lldb/tools/Makefile

you’ll see:

ifeq ($(HOST_OS),Linux)
DIRS += lldb-mi
endif

Just remove the conditional or add in darwin support.

-eric

I just took it out, since CMake builds already build lldb-mi on all platforms.

Thanks! I have lldb-mi* built now :). Although what fixed things for
me was blowing away my old build tree and rebuilding with cmake+ninja
from scratch (so it was probably Deepak's commits that fixed things -
thanks Deepak!). That said, knowing that the Makefile has the lldb-mi
build enabled only for Linux is vital for folks trying to build with
configure (which I had also tried).

In case others want to give it a try, here's what I did (on Mavericks with Xcode 5.1.1):
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

Thanks to all,
-Dawn

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

Oops - just noticed my lines got joined. Last step should be:

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
         -exec-continue
    (gdb)-break-insert main
    (gdb)-exec-continue
    (gdb)-break-insert x.cpp:8
    (gdb)-exec-continue
    (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! :slight_smile:

-Dawn