Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

swift

lldb

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:

codesnapshot1

Then I tried the same in Objective-C code; everything goes well.

like image 218
oneMortale Avatar asked Jul 15 '16 12:07

oneMortale


1 Answers

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.

like image 94
Jim Ingham Avatar answered Nov 02 '22 18:11

Jim Ingham