Skip to content

Instantly share code, notes, and snippets.

@modocache
Created March 30, 2016 01:05
Show Gist options
  • Save modocache/2ef5e3916b97b97a1aa9e0126208aea9 to your computer and use it in GitHub Desktop.
Save modocache/2ef5e3916b97b97a1aa9e0126208aea9 to your computer and use it in GitHub Desktop.
Attaching LLDB to a Debug build of Swift
$ lldb -- ../build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swiftc -dump-parse ~/GitHub/tmp/hello.swift
(lldb) target create "../build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swiftc"
Current executable set to '../build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swiftc' (x86_64).
(lldb) settings set -- target.run-args "-dump-parse" "/Users/bgesiak/GitHub/tmp/hello.swift"
(lldb) process launch --stop-at-entry
Process 91478 stopped
* thread #1: tid = 0x1bd329, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
Process 91478 launched: '../build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swiftc' (x86_64)
(lldb) b Driver::buildCompilation
Breakpoint 1: where = swiftc`swift::driver::Driver::buildCompilation(llvm::ArrayRef<char const*>) + 79 at Driver.cpp:343, address = 0x00000001000fd83f
(lldb) c
Process 91478 resuming
Process 91478 stopped
* thread #1: tid = 0x1bd329, 0x00000001000fd83f swiftc`swift::driver::Driver::buildCompilation(this=0x00007fff5fbfdc98, Args=ArrayRef<const char *> @ 0x00007fff5fbfc2b8) + 79 at Driver.cpp:343, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x00000001000fd83f swiftc`swift::driver::Driver::buildCompilation(this=0x00007fff5fbfdc98, Args=ArrayRef<const char *> @ 0x00007fff5fbfc2b8) + 79 at Driver.cpp:343
340
341 std::unique_ptr<Compilation> Driver::buildCompilation(
342 ArrayRef<const char *> Args) {
-> 343 llvm::PrettyStackTraceString CrashInfo("Compilation construction");
344
345 llvm::sys::TimeValue StartTime = llvm::sys::TimeValue::now();
346
(lldb) b Driver::parseArgStrings
Breakpoint 2: where = swiftc`swift::driver::Driver::parseArgStrings(llvm::ArrayRef<char const*>) + 77 at Driver.cpp:634, address = 0x00000001001012cd
(lldb) c
Process 91478 resuming
Process 91478 stopped
* thread #1: tid = 0x1bd329, 0x00000001001012cd swiftc`swift::driver::Driver::parseArgStrings(this=0x00007fff5fbfdc98, Args=ArrayRef<const char *> @ 0x00007fff5fbfb370) + 77 at Driver.cpp:634, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
frame #0: 0x00000001001012cd swiftc`swift::driver::Driver::parseArgStrings(this=0x00007fff5fbfdc98, Args=ArrayRef<const char *> @ 0x00007fff5fbfb370) + 77 at Driver.cpp:634
631
632 std::unique_ptr<InputArgList>
633 Driver::parseArgStrings(ArrayRef<const char *> Args) {
-> 634 unsigned IncludedFlagsBitmask = 0;
635 unsigned ExcludedFlagsBitmask = options::NoDriverOption;
636 unsigned MissingArgIndex, MissingArgCount;
637 std::unique_ptr<InputArgList> ArgList;
(lldb) s
Process 91478 stopped
* thread #1: tid = 0x1bd329, 0x00000001001012d7 swiftc`swift::driver::Driver::parseArgStrings(this=0x00007fff5fbfdc98, Args=ArrayRef<const char *> @ 0x00007fff5fbfb370) + 87 at Driver.cpp:635, queue = 'com.apple.main-thread', stop reason = step in
frame #0: 0x00000001001012d7 swiftc`swift::driver::Driver::parseArgStrings(this=0x00007fff5fbfdc98, Args=ArrayRef<const char *> @ 0x00007fff5fbfb370) + 87 at Driver.cpp:635
632 std::unique_ptr<InputArgList>
633 Driver::parseArgStrings(ArrayRef<const char *> Args) {
634 unsigned IncludedFlagsBitmask = 0;
-> 635 unsigned ExcludedFlagsBitmask = options::NoDriverOption;
636 unsigned MissingArgIndex, MissingArgCount;
637 std::unique_ptr<InputArgList> ArgList;
638
(lldb) p Args
(llvm::ArrayRef<const char *>) $0 = {
Data = 0x00007fff5fbff070
Length = 2
}
(lldb) exit
Quitting LLDB will kill one or more processes. Do you really want to proceed: [Y/n] Y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment