|
Home > Archive > Unix Programming > December 2007 > Stack traceback?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| SM Ryan 2007-12-17, 7:35 am |
| Occasionally I see references to compiling stack trace back code
into a program, as some kind of gcc extension. If this is possible,
can it be done on Mac OSX? Any documentation?
--
SM Ryan http://www.rawbw.com/~wyrmwif/
TEMPORARILY CLOSED
BE OPENED AFTER FIRST PERIOD
| |
| Paul Pluzhnikov 2007-12-17, 1:29 pm |
| SM Ryan <wyrmwif@tango-sierra-oscar-foxtrot-tango.fake.org> writes:
> Occasionally I see references to compiling stack trace back code
> into a program, as some kind of gcc extension.
It's a glibc extension; google for backtrace_symbols.
> can it be done on Mac OSX?
Not unless there is a MacOS equivalent. Googling for
'backtrace_symbols macos' gives this:
http://developer.apple.com/document..._symbols.3.html
But it's probably too recent 
HISTORY
These functions first appeared in Mac OS X 10.5.
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
| |
| sjdevnull@yahoo.com 2007-12-17, 7:22 pm |
| On Dec 17, 10:39 am, Paul Pluzhnikov <ppluzhnikov-...@gmail.com>
wrote:
> SM Ryan <wyrm...@tango-sierra-oscar-foxtrot-tango.fake.org> writes:
>
> It's a glibc extension; google for backtrace_symbols.
I've seen code in the past that installs a SIGSEGV handler which
invokes gdb on the current PID and prints a stack trace; obviously
after SIGSEGV all bets are off as far as standard behavior, but it
might be a useful hack. On Linux something like this in the SIGSEGV
handler:
char str[100+4096];
char path[4096];
path[readlink("/proc/self/exe", path, -1+ sizeof(path))] =
'\0';
sprintf(str, "echo 'bt\ndetach\nquit\n' | gdb -batch -x /dev/
stdin %s %d\n",
path, (int)getpid() );
system(str);
obviously you need some other hack to try to guess a program filename
(instead of /proc/self/exe) and you probably just drop the -x /dev/
stdin part if the program runs on console. But the basic idea may be
workable on OS X.
|
|
|
|
|