Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lldb error: property not found on object of type

I am trying to debug my iOS app using lldb and I'm getting really weird errors on debug.

A few lines before my breakpoint, I've got:

CGRect frame = view.frame;

Which I can access with no problems with print frame command in lldb. However, when I try to access the frame again in lldb, I type print view.frame and get the following error:

error: property 'frame' not found on object of type 'UIView *'

This doesn't make sense as I can verify the view is a UIView* instance and has a valid property called frame by typing po view and getting correct results:

(UIView *) $4 = 0x1e199bf0 <MyAppCustomView: 0x1e199bf0; frame = (3398 3396; 204 208); layer = <CALayer: 0x1e199ce0>>

This particular lldb error happens to me a lot, and I couldn't find the cause of this error. Someone suggested at Property 'count' not found on object of type 'NSMutableArray *' PO command in lldb that one could use gdb as (gdb) p view.frame but I'm getting error: '(gdb)' is not a valid command. and I highly suspect that a gdb command would "work?" inside another debugger anyway.

Any suggestions or workarounds for this bug which occurs randomly?

like image 874
Can Poyrazoğlu Avatar asked Dec 23 '12 01:12

Can Poyrazoğlu


3 Answers

Dot notation for message sending is not supported in lldb when using Objective-C. Use bracket notation and cast the result to CGRect:

p (CGRect)[view frame]
like image 163
Nate Chandler Avatar answered Oct 23 '22 01:10

Nate Chandler


Just in case the above doesn't work (which it didn't for me, looking for the frame for a variable cell, class derived from UITableViewCell): forcing the extra parentheses seemed to help lldb's little ditty brain:

p ((CGRect)[cell frame])

presto magico:

(CGRect) $5 = origin=(x=0, y=0) size=(width=320, height=44)
like image 38
ssdscott Avatar answered Oct 23 '22 01:10

ssdscott


I had to disable (uncheck) Thread Sanitizer in Xcode > Product > Scheme > Edit Scheme > Run > Diagnostics. With Thread Sanitizer enabled I wasn't able to access many NSView properties (e.g. bounds, frame) through LLDB.

like image 23
Andrew Avatar answered Oct 22 '22 23:10

Andrew