Easy backtrace
Easy backtrace
- Subject: Easy backtrace
- From: Gideon King <email@hidden>
- Date: Mon, 7 Nov 2005 22:14:07 +1000
Hi, I don't know whether others of you may find this trivial, but I
just came across something I thought might be useful for other people...
I had an issue to debug where I needed to know what the stack trace
was on a series of calls to retain and release on an object.
Unfortunately because of the nature of the program, switching window
focus by having GDB stop at a breakbpoint and looking in XCode
altered the behavior of the code, as did throwing an exception,
catching it and printing the stack trace from there.
So I added the following two methods to my class so I could print out
when retain and release were called:
- (void)retain {
NSLog(@"+++Retaining graphicview %d", [self retainCount]);
[super retain];
}
- (void)release {
NSLog(@"---Releasing graphicview %d", [self retainCount]);
[super release];
}
I then put breakpoints after the NSLogs, and double-clicked the
breakpoints to see the breakpoint settings, and clicked on the plus
button for each one, and added the debugger command:
bt
c
to each one. Now when I run it, I get the backtrace of each call
without interrupting the flow or switching windows.
Obviously there are variations of this where you don't need to
explicitly override methods etc, but you get the idea.
As I say, pretty basic, but I hadn't thought of it before, and
thought others may find it useful too.
Gideon King
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden