I getted an error which is "The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation."
I want to know how to use "thread return -x"?
It's an LLDB command.
That message is more of a follow-up message to an error, rather than an error message itself. It's saying "hey, something went wrong, but you're in a context where you can type LLDB commands and possibly spelunk around and debug your program's state".
If you're in the Swift REPL, you run that command by prefixing it with a colon, like :thread return -x
.
If you're in Xcode, type that into the debug area.
LLDB's description of the command is helpful if you know what stack frames are; otherwise I think there's a bit of a learning cliff here that's going to be tricky to hurdle:
:help thread return
Prematurely return from a stack frame, short-circuiting execution of newer frames and optionally yielding a specified value. Defaults to the exiting the current stack frame. Expects 'raw' input (see
help raw-input
.)-x ( --from-expression ) Return from the innermost expression evaluation.
As far as I know, it is meant to be typed after lldb
in your debugger (in the Xcode debug area).
My Code in Playground (Xcode 10 beta 6
):
import UIKit
import Foundation
let string = "123 Main St. / (555) 555-1234"
let types: NSTextCheckingResult.CheckingType = [.phoneNumber, .address]
let detector = try NSDataDetector(types: types.rawValue)
let range = NSRange(string)
detector.enumerateMatches(in: string, options: [], range: range!) { (result, _, _) in
print(result)
}
And got the error:
error: Execution was interrupted, reason: signal SIGABRT.
The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.
What going wrong with me?
My guess is it's that NSRange(string)
, which tries to convert a string to a range rather than getting a range for the entire string.
Can you file a bug at https://bugs.swift.org that LLDB should not print this message for a playground? The actual error message would have been a few lines earlier.
The bug here SR-8694. But I am not sure if the title and the tag is right. Please let me know if I should update for more clearer.
In the case that I see that in Playground as you did, where do I type "thread return -x". The debug area at the bottom of Playground doesn't let me type in it like it does in Xcode.