Anton Tropashko
Anton Tropashko

Reputation: 5806

(lldb) error: anonymous closure argument not contained in a closure

similar to Anonymous closure argument not contained in a closure but lldb related

tableViews.forEach {
        $0.dataSource = self
        $0.delegate = self

        $0.estimatedRowHeight = 30
          ^^^^^^^^^^^^^^ breakpoint is here
}

Trying to debug

(lldb) p $0.delegate

error: :3:1: error: anonymous closure argument not contained in a closure $0.delegate

(lldb) po $0.delegate

error: :3:1: error: anonymous closure argument not contained in a closure $0.delegate

Visual debugging (positioning cursor on the $0) does work, you get to expend the tree and go down to the variable you are interested in. But there is a slight problem there is a gazillion of them for uitableview so that visual debugging intention paves the road to the comprehension hell

Given that visual part of debugging works there must be some way to get there from the command line???? How could I get only the part I'm interesed in?

Upvotes: 3

Views: 744

Answers (1)

Jim Ingham
Jim Ingham

Reputation: 27110

The "p" command actually compiles the text you type as though the expression had been in the text of the frame you are stopped in. To do that it has to completely recreate that context. lldb gets a lot of this right, but it doesn't yet know how emulate the $ closure automatic variables in the context it uses to compile expressions.

But more generally, the job print tries to do is a much harder task that just viewing local variables, and not surprisingly lldb also has a more straightforward way to view simple local variables. That facility is what Xcode uses to implement the locals view and the tooltips. But it is also an lldb command-line command:

(lldb) frame var $0

The "frame var" command doesn't have a full language parser, for instance it can't evaluate expressions. But it does allow you to specify elements of a struct, for instance:

(lldb) frame var $0.delegate

You might have more luck with the frame var command.

Upvotes: 5

Related Questions