I have a user complaining that my app is taking a lot of CPU time when it should be idle. This is a Cocoa app on Mac OS Leopard. What I would love to do is have a background thread periodically grab stack traces of the main thread and log them. Alternatively, if I could have him run a command line program to grab all the threads' stacks (or better yet, a call graph with CPU profiling info), he could do that and send me the results. I know there's CPU profiling built into XCode, but this problem is only reproducible on the user's machine, so XCode is not an option (I don't want to ask him to install it).
I can't find a command line tool that would dump stack traces on OSX, nor can I find an API for accessing other threads' stacks. I guess GDB could do it, but that would be really hard to explain to a user.