Search code examples
xcodedebuggingswiftlldb

Xcode: how to exit lldb swift repl


I made a typo debugging my project and appeared in lldb swift REPL now I don't know how to exit it and simultaneously do not exit from my program which I debug. So I typed expr -r -- myVariable instead of expr -R -- myVariable. and below is what I see. (if you want to try personally I use Xcode 6.1, C++ code project, and myVariable has to exist)

(lldb) expr -r -- record.mFileRecord.mVolumeName
(std::string) $19 = ""
1> help expr
/var/folders/zv/r3033x4n0f72bprvyk8612480000gn/T/lldb/30856
/repl433.swift:2:5: error: consecutive statements on a line must be 
separated by ';'

1> quit

/var/folders/zv/r3033x4n0f72bprvyk8612480000gn/T/lldb/30856
/repl434.swift:2:1: error: use of unresolved identifier 'quit'

quit


1> exit

/var/folders/zv/r3033x4n0f72bprvyk8612480000gn/T/lldb/30856/repl435.swift:2:1: error: use of unresolved identifier 'exit'

exit



1> exit()

/var/folders/zv/r3033x4n0f72bprvyk8612480000gn/T/lldb/30856/repl436.swift:2:1: error: use of unresolved identifier 'exit'

exit()

^


1> quit()

/var/folders/zv/r3033x4n0f72bprvyk8612480000gn/T/lldb/30856/repl437.swift:2:1: error: use of unresolved identifier 'quit'

quit()  


1> .quit

/var/folders/zv/r3033x4n0f72bprvyk8612480000gn/T/lldb/30856
/repl438.swift:2:2: error: could not find member 'quit'

.quit

^~~


1> :quit

(here my application terminated and lldb was self-killed)


Solution

  • With a single colon you can leave the Swift REPL and return to lldb:

    (lldb) repl
    1> 
    2> 
    3> :
    (lldb)
    

    (Found here: http://swift.exomachina.com/how-to-use-lldb-to-debug-swift-program.)

    With :quit you can stop the entire debugging session:

    (lldb) repl
    3> 
    4> 
    5> :quit
    5> Program ended with exit code: 9