Re: Stack Backtrace Demo Code For Free
Re: Stack Backtrace Demo Code For Free
- Subject: Re: Stack Backtrace Demo Code For Free
- From: Greg Hurrell <email@hidden>
- Date: Sat, 22 Apr 2006 13:45:48 +0200
El 21/04/2006, a las 22:04, Rush Manbert escribió:
I fiddled with the calls to __builtin_return_address for a while,
and finally wrapped them them up, because as far as I can tell, the
level argument really needs to be a compile time constant. It makes
for a nasty switch statement with a compile time decision about the
max number of levels you can trace, and I would be happy to hear
from someone who can do something more elegant.
Thanks for sharing your code, Rush. In my previous experiments with
generating stack traces I too used a kludgey compile time constant
with a macro to make the source less verbose.
Unfortunately I don't know if any code that uses
__builtin_return_address() can be relied upon in production (non-
debug) deployment because the docs (file:///Developer/ADC Reference%
20Library/documentation/DeveloperTools/gcc-4.0.1/gcc/Return-
Address.html) say, "This function should only be used with a nonzero
argument for debugging purposes." I interpret that as meaning "fine
for in-house use but don't use it in shipping code".
In my experience it also doesn't work properly from within signal
handlers, which is one of the places you are most likely to want to
print out stack traces (for example, on SIGSEGV or SIGBUS signals).
In the end these problems led me to forget about generating my own
stack traces and just provide a convenient mechanism for users to
send me the crash reports generated by the system, as others have done:
http://wincent.com/a/about/wincent/weblog/archives/2006/03/
smarter_crash_r.php
http://daringfireball.net/2006/01/smart_crash_reports (scroll down to
"Suggested alternatives")
And of course, if I want to print a stack trace locally I can just
run under GDB.
Cheers,
Greg
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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