I am reading the Dancing in the Debugger — A Waltz with LLDB article. And I am trying the thread return
command with Swift 2.2 as well as Swift 3.0.
My code is pretty simple:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let resust = test()
print(resust)
}
func test() -> Bool {
return true
}
}
and I added a breakpoint at the beginning of the test()
function with a thread return false
action. However, after command+R, my program stops at the breakpoint as expect, but with the following error:
"error: Error returning from frame 0 of thread 1: We only support setting simple integer and float return types at present.."
Here's a screen shot:
Then I tried the same in Objective-C code; everything goes well.
These are known bugs. The value types in Swift (Int, Bool, etc.) are all complex objects, and we haven't taught lldb how to overwrite the return values for them. Error handling will also make this tricky.
In general, forced returns are unsafe - more so with ARC and even more so with Swift, since you are likely to unbalance reference counts - not just on locals but potentially on objects passed in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With