Debugging tips
John Chang just posted a terrific list of debugging techniques for Mac OS X. I’ll add a few random ones of my own:
- p (char[4]) foo prints foo as a four-char code.
- Put a breakpoint on -[NSException raise] to catch the point at which your code raises an exception. It’s much easier to figure out what’s going on at that point than any time afterwards. Do this even when you don’t think an exception’s being raised…sometimes you’ll be surprised.
- If you’re seeing a pointer randomly get stomped on, try using a watchpoint. watch *<address> will cause gdb to break whenever the memory at <address> is changed.
That’s about all I can think of for now. It’d be great if these made it into a tutorial at MacDevCenter.com or something like that. It’s so much easier to write code for an OS when you know how to debug effectively on it.
Michael Tsai's Weblog Said,
August 29, 2003 @ 9:26 am
Debugging on Mac OS X
John Chang and Eric Albert have posted some debugging tips….
JOHN R CHANG > Weblog Said,
August 30, 2003 @ 1:24 am
hard core debugging
Somebody taped this on their door at work: Six Stages of Debugging That can’t happen. That doesn’t happen on my machine. That shouldn’t happen. Why does that happen? Oh, I see. How did that ever work? Today is debugging blog…