You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
There are other ways to build, but I've found them to be harder to get right, especially the codesigning that is
performed in these cases doesn't work out of the box.
Additionally I could never get lldb to find the debugserver even after it was codesigned directly, so only try the
below if you are ready for a bit of pain.
First we generate the ninja build file with cmake and then tell ninja to build llvm entirely which builds all we need
including lldb and debugserver.
mkdir build
cd build
cmake .. -G Ninja
ninja all
You may see the following error as I did (seems like not too many folks try to build this on Mac?)
../tools/lldb/source/Host/common/Host.cpp:371:68: error: use of undeclared identifier 'CPU_SUBTYPE_X86_64_H'
if (cpusubtype == CPU_SUBTYPE_486 || cpusubtype == CPU_SUBTYPE_X86_64_H)
you'll have to fix the Host.cpp file a bit basically to include Mach0.h and to namespace CPU_SUBTYPE_X86_64_H:
diff --git a/source/Host/common/Host.cpp b/source/Host/common/Host.cpp
index 275b446..9cba9fe 100644
--- a/source/Host/common/Host.cpp+++ b/source/Host/common/Host.cpp@@ -33,6 +33,7 @@
#endif
#if defined (__APPLE__)
+#include "llvm/Support/MachO.h"
#include <mach/mach_port.h>
#include <mach/mach_init.h>
#include <mach-o/dyld.h>
@@ -364,11 +365,11 @@ Host::GetArchitecture (SystemDefaultArchitecture arch_kind)
// cpusubtype will be correct as if it were for a 64 bit architecture
g_host_arch_64.SetArchitecture (eArchTypeMachO, cputype | CPU_ARCH_ABI64, cpusubtype);
}
-+
// Now we need modify the cpusubtype for the 32 bit slices.
uint32_t cpusubtype32 = cpusubtype;
#if defined (__i386__) || defined (__x86_64__)
- if (cpusubtype == CPU_SUBTYPE_486 || cpusubtype == CPU_SUBTYPE_X86_64_H)+ if (cpusubtype == CPU_SUBTYPE_486 || cpusubtype == llvm::MachO::CPU_SUBTYPE_X86_64_H)
cpusubtype32 = CPU_SUBTYPE_I386_ALL;
#elif defined (__arm__) || defined (__arm64__) || defined (__aarch64__)
if (cputype == CPU_TYPE_ARM || cputype == CPU_TYPE_ARM64)
At this point you should have a bin directory added that looks similar to the below:
In case you want to generate an Xcode project to look at the entire llvm project you can do that with cmake as well after you followed along the above
Get Build Tools and Dependencies and Clone Projects sections.
cmake .. -G Xcode
open LLDB.xcodeproj
You can then build the entire llvm project in Xcode.