>>>> "GE" == Gunnar Evermann
<ge204(a)eng.cam.ac.uk> writes:
GE> yes, in fatal_error_signal()
GE> Basically it calls system("pstack <pid>"). It is currently #if
GE> 0'd -- Apparently Steve didn't like it. Steve: could you explain
GE> why?
I believe he felt it didn't work all the time or something. I've
attached a test program that demonstrates the concept. If enough of
you run it and don't have any problems, it's probably safe to remove
the ifdefs (remember, though, that the pstack command did not appear
until Solaris 2.5.1).
GE> Actually I have just tried it and it's trivial to get the
GE> addresses. The big problem is converting them into symbols. The
GE> only way seems to involve 'addr2line' which is part of the gnu
GE> binutils...
Under Solaris, the run-time linker can translate an address to a
symbol name with the dladdr() call (from libdl). Given the
resemblance that the linux linker has to Solaris' I'd look in libdl...
#include <sys/types.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
void
handler(int sig)
{
char buf[40];
sprintf(buf, "/usr/proc/bin/pstack %d", getpid());
system(buf);
exit(EXIT_FAILURE);
}
int
main(void)
{
struct sigaction act;
sigemptyset(&act.sa_mask);
act.sa_flags = SA_RESTART;
act.sa_handler = handler;
sigaction(SIGSEGV, &act, NULL);
raise(SIGSEGV);
return (0);
}