Xcode 4 / gdb / How to just view object properties?

I got really lost in Xcode 4. Viewing a simple variable is a nightmare. I don’t understand how simple it is to “look at a variable value”. It was easier in Xcode 3 ...

I have the following code snippet:

if (labelEast.center.x > (east_oldPosition.x + 50) ) NSLog(@"Time to switch to previous exercise !"); else if (labelEast.center.x < (east_oldPosition.x - 50) ) NSLog(@"Time to switch to next exercise !"); 

After setting a breakpoint, I just try to look at labelEast.center.x ( labelEast is a UILabel object). Since I could not find the watch item in the Xcode 4 menu, I am trying to use gdb. I use to print the values ​​of variables / objects using po (print object). But now I can’t display the labelEast center property because it is inherited from the mother class.

(gdb) po labelEast.center
No named center name.

I don’t understand why gdb talks about this, while the code works fine and sees the property.

So I have 2 questions:

  • How to watch such a property without gdb in a graphical way (same as in Visual Studio)?
  • How to do the same with gdb?

Thanks a lot, Franz


Unfortunately, I tried, but got the following:

po [labelSouth center]

Software received signal EXC_BAD_ACCESS, Unable to access memory. Reason: KERN_INVALID_ADDRESS at: 0x1a000356 0x343c7d06 in objc_msgSend_stret () The program to be debugged was pointed to a function called from GDB. GDB remains in the frame where the signal was received. To change this behavior, use the "set unwindonsignal on" evaluation of the expression containing the function (objc_msgSend) will be left.

And when I try:

(gdb) print labelSouth.center
No named center name.

I really suspect that access to the center object is missing in UILabel . But how do I run the code?

+4
source share
1 answer

I hit this thing a few times, just remember "oh that's right, gdb does not support spot recording, so I need to use getter". Then just do:

 (gdb) po [myObject someProperty] 

and all is well with the world again. While re-reading your question, I see that you are not requesting an object to print, so you should give gdb a hint about what type of property you want to print:

 (gdb) p (CGRect)[myView frame] (gdb) p (CGPoint)[myView center] 

etc.

+12
source

All Articles