views:

119

answers:

2

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?

A: 
  NSArray * stack = [NSThread callStackSymbols];

It may help.

icespace
As you have seen I required _no_ specific founation (like Cocoa or GNUStep).
Tilo Prütz
A: 

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 :(.

Tilo Prütz