[Bug 39750] New: lldb built with cmake on macOS fails to debug applications

Bug ID 39750
Summary lldb built with cmake on macOS fails to debug applications
Product lldb
Version 7.0
Hardware Macintosh
OS MacOS X
Status NEW
Severity normal
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter alexandru.croitor@qt.io
CC llvm-bugs@lists.llvm.org

Created attachment 21141 [details]
lldb stacktrace

Hi,

I'm trying to build lldb master from sources using cmake on macOS 10.14.1, and
the build finishes successfully, but debugging does not work. 
Using the same sources with xcodebuild, lldb can successfully debug
applications.

Initially I thought the issue might be due to code signing, but then I saw that
the xcodebuild lldb is not code signed at all (although the debugserver is)

Nevertheless I tried building both with -DLLDB_CODESIGN_IDENTITY="" and
DLLDB_CODESIGN_IDENTITY="lldb_codesign", but it didn't make a difference.

I also have SIP and gatekeeper disabled, and I followed the steps for creating
a code sign cert from the docs.

The issue specifically is that after running 
$ lldb ./my-app
(lldb) r

the application is not launched, and lldb freezes.
If I press Ctrl-C 3 times, lldb quits, and the application gets launched.

Attaching the stacktrace of lldb, as well as the log file.
Judging from the log and trace, it looks like lldb expects some event to happen
when launching the app, but it doesn't.

lldb version 8.0.0 ([http://llvm.org/git/lldb.git](http://llvm.org/git/lldb.git) revision
0d6a8ba20fb9eb76c7cce62f18a9764c743f4e52)
  clang revision 2d5099826365b50ff253e48c0832255600e68202
  llvm revision 498b7f9b57123ce661e075ae584876be72852506

Stefan Gränitz changed bug 39750

What Removed Added
Status NEW RESOLVED
Resolution FIXED

Comment # 9 on bug 39750 from Stefan Gränitz

As soon as my CMake changes around [https://reviews.llvm.org/D55328](https://reviews.llvm.org/D55328) are
committed, the following should work for LLDB Standalone builds:

Directory structure:
  $ROOT/lldb (master with pending CMake changes)
  $ROOT/llvm/projects/compiler-rt (master)
  $ROOT/llvm/projects/libcxx (master)
  $ROOT/llvm/projects/libcxxabi (master)
  $ROOT/llvm/tools/clang (master)

Build LLVM&co (e.g. with ninja):
  $ mkdir -p $ROOT/llvm-build/release
  $ cd $ROOT/llvm-build/release
  $ xcrun cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=host
../../llvm
  $ ninja

Build standalone LLDB (e.g. with xcodebuild):
  $ mkdir $ROOT/xcode-release
  $ cd $ROOT/xcode-release
  $ xcrun cmake -GXcode -DLLVM_TARGETS_TO_BUILD=host
-DLLVM_CONFIG=$ROOT/llvm-build/release/bin/llvm-config ../lldb
  $ xcodebuild -configuration Release

Run test suite:
  $ cd $/lldb/test
  $ python2.7 dotest.py --executable $ROOT/xcode-release/Release/bin/lldb
--filecheck $ROOT/llvm-build/release/bin/FileCheck -C
$ROOT/llvm-build/release/bin/clang

You should be able to build other configurations and use your favorite
generator for the individual parts. As noted earlier, there are no bots that
test this setup at the moment, so feel free to fix things if they break.

Best
Stefan