Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcode 3.2.2 and objective-c 2.0 and debug: where are my object's property/instance variable values in debug?

working on a mac os project (meaning not iPhone) requiring 10.6 and is 64bit, allows me to use properties to generate both accessor methods and instance variables in the header file. but, during debug, i'm not seeing how to look at the object's properties values after they have been populated. is there some build setting that needs to be turned on?

if i am declaring an object's instance variables (between {} in the header), then i can see those values (when they are used) during debug either in the debug window itself, or by using the cursor-hover over the highlighted line trick in the editor during a break, or by doing cli in gdb like 'p *object' for instance.

old way:

@class Suit;
@interface Card : NSObject 
{
    NSNumber *playOrder;
    Suit *suit;
    NSNumber *displayNumber;
    NSNumber *orderIndex;
}
@property(nonatomic, retain) Suit *suit;
@property(nonatomic, retain) NSNumber *displayNumber;
@property(nonatomic, retain) NSNumber *orderIndex;

new way:

@class Suit;
@interface Card : NSObject 

@property(nonatomic, retain) Suit *suit;
@property(nonatomic, retain) NSNumber *displayNumber;
@property(nonatomic, retain) NSNumber *orderIndex;
@property(nonatomic, retain) NSNumber *playOrder;

in this new-fangled 10.6 required 64bit idea (which seems simpler to me) none of these debug methods display the object's values. i figure that i must have something turned off, because this newer idea, doesn't seem better.

gdb results for old way:

(gdb) po newCard
New Card : 0 of Suit : Hearts (NSCalibratedRGBColorSpace 1 0 0 1). with orderIndex of: 1
(gdb) p *newCard
$1 = {
  <NSObject> = {
    isa = 0x100002188
  }, 
  members of Card: 
  playOrder = 0x0, 
  suit = 0x200053a20, 
  displayNumber = 0x20001bac0, 
  orderIndex = 0x200012de0
}
(gdb)

gdb results for new way:

(gdb) po newCard
New Card : 0 of Suit : Hearts (NSCalibratedRGBColorSpace 1 0 0 1). with orderIndex of: 1
(gdb) p *newCard
$3 = {
  <NSObject> = {
    isa = 0x100002188
  }, <No data fields>}
(gdb) 

so looking at the docs for objective-c 2.0:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocProperties.html#//apple_ref/doc/uid/TP30001163-CH17-SW3

describes what i am referring to (synthesizing instance variables in 'modern' runtime), but what isn't said anywhere, is that if you do this, the values will not be available during debugging.

i've found an SO page with pertinent information, but not focused on this effect: Using instance variables with Modern Runtime

what did i miss?

like image 469
lulu Avatar asked Jun 03 '10 23:06

lulu


1 Answers

In GDB, you can use property getters to access dynamic ivars:

(gdb) po [newCard displayNumber]
0
like image 174
outis Avatar answered Oct 03 '22 00:10

outis