I'm new to LLDB and try to familiar those commands in the official website.
I'm confusing about the function of fr v bar and p bar.
As you can see from the website, they are described to 'Show the contents of local variable "bar"' and put in the same place.
But When I put them into real use in Xcode 4.6.4, there is some differences?
(lldb) fr v self
(FGPLoginViewController *const) self = 0x07566350
(lldb) p self
(FGPLoginViewController *) $0 = 0x07566350
(lldb) fr v self.initCount
error: "self" is a pointer and . was used to attempt to access "initCount". Did you mean "self->initCount"?
(lldb) p self.initCount
(NSInteger) $1 = 0
initCount is a NSInteger property of FGPLoginViewController.
And my questions is what's the real differences between fr v bar and p bar?
The difference (as I understand it) is that frame variable is only for printing the
contents of variables, whereas print is a shortcut for
expression -- and can evaluate arbitrary C and Objective-C expressions.
In your example, self.initCount is the property syntax for [self initCount]. To evaluate that expression, the debugger compiles it and executes the code in the context of the
application.
Another example: p 2+3 computes the sum and prints the result, but fr v 2+3 gives
an error message.
On the other hand, frame variable has much more options to display variables.
For example, fr v -r "app.*" shows all variables starting with "app". You cannot do that
with the print command.
To summarize: frame variable is for variables and print (or expr) is for expressions.
In the case of one variable they both work equally well.
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