LLDB 'thread return' command emits error in a Swift function

若如初见. 提交于 2019-12-09 16:50:11

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/38396777/lldb-thread-return-command-emits-error-in-a-swift-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!