How to print exception stack trace of Objective-C exceptions with GNU runtime and without GNUStep?
I have an Objective-C app build on Linux with GCC 4.3 using no specific framework (only GNU-runtime).开发者_运维知识库 I am using Objective-C exceptions (via the '-fobjc-exceptions' compiler flag).
Now I want to print the stack trace of such an exception when I caught some. Or what would make me even happier: put the trace in a string or some kind of structure to evaluate or print it later on.
How can that be achieved?
NSArray * stack = [NSThread callStackSymbols];
It may help.
Since no more knowledge is floating in, here is what I found out by myself:
At least under Linux I can use the GNU extensions backtrace
and backtrace_symbols
to get addresses of the call stack and the corresponding symbols. This helps a little but is far away from the information that gdb gives. There are neither line numbers nor arguments values.
With the glibc extension dladdr
I can get similar information but not further.
This is still not exactly what I'm looking for but no one got so clause – so I would accept my own answer :(.
精彩评论