formatting issue in gdb
formatting issue in gdb
- Subject: formatting issue in gdb
- From: Ludovic Nicolle <email@hidden>
- Date: Fri, 13 Aug 2010 13:20:35 -0700
Hi,
I have a Cocoa project here, with a fairly banal pattern of classes with Cocoa containers (NSArray/NSDictionary) referencing objects of other classes. For most of these classes, I defined a -(NSString*) description method, to help me debug in gdb.
It mostly works well, except for the fact that when I do a po on an object of a top level class, the newlines embedded by the Cocoa container classes around the description generated by the "contained" class show up as \n instead of moving the text to the next line. The oddity to me is that if I do a po on the "contained" object itself, then the newlines properly move to the next line.
I am using Xcode 3.2.2 on intel mac, my project is x86_64, but behavior is identical on i386.
Am I mistaken in my usage of the -description method?
If it is a bug I will file a radar, but I'd like to be sure it is not something wrong I am doing first.
Below is a synthetic example of the problem, where you need to put a breakpoint in -(void)callThisMethod and then invoke 2 po commands on gdb.
The reason I care is because I tend to debug containers with dozens of embedded objects, and it makes a mess of an output currently :)
The output I get is this:
(gdb) po correctPrintout
(
multiple,
objects
)
(gdb) po self
(
"(\n multiple,\n objects\n)",
(
"direct cocoa containers",
"indent properly"
)
)
Thanks.
Ludo
Code below
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#import <Cocoa/Cocoa.h>
@interface MyContainedClass : NSObject { } @end
@implementation MyContainedClass
-(NSString*) description {
return [NSString stringWithFormat: @"%@", [NSArray arrayWithObjects: @"multiple", @"objects", nil]];
}
@end
@interface MyContainerClass : NSObject { }
- (void)callThisMethod;
@end
@implementation MyContainerClass
-(NSString*)description {
return [NSString stringWithFormat: @"%@", [NSArray arrayWithObjects:
[[MyContainedClass new] autorelease],
[NSMutableArray arrayWithObjects: @"direct cocoa containers", @"indent properly", nil],
nil]];
}
- (void)callThisMethod
{
MyContainedClass* correctPrintout = [[MyContainedClass new] autorelease];
if ( !correctPrintout) exit(2); //just to avoid warning
NSLog(@"Put a breakpoint here and when it stops, do this command in gdb: po correctPrintout");
NSLog(@"then do this secondcommand in gdb: po self");
NSLog(@"If the output shows with \\n around multiple and objects, then you see what I see");
}
@end
int main(int argc, char *argv[])
{
[NSAutoreleasePool new]; // yes, I never release it. How mean is that?
[[MyContainerClass new] callThisMethod];
exit(1);
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden