public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* How to get a context ?
@ 2003-07-04 16:26 Janier Julien
  0 siblings, 0 replies; only message in thread
From: Janier Julien @ 2003-07-04 16:26 UTC (permalink / raw)
  To: 'gdb@sources.redhat.com'

I hope this is the rigth place for this question, I thinks that gdb dev team
can give me some hints.

I'm trying to get information on a process when a signal is raised like a
sigsegv in order to print a backtrace.
I first try to get the address of the instruction that cause the segfault
with the siginfo_t structure, but this one is most of the time empty and not
filled by the kernel (it depends of the signal and how the crash happen).


Here the code I use :

#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <signal.h>

void handler(int cause, siginfo_t *HowCome, void *uap)  {
        printf("SIGSEGV raised at adress %p\n", HowCome->si_addr);
        exit(0);
}


int main(void) {
        struct sigaction sa;
        
        sa.sa_sigaction = handler;
        sigemptyset( &sa.sa_mask);
        sa.sa_flags = SA_SIGINFO;
        if (sigaction( SIGSEGV, &sa, 0)) {
                perror("Sigaction SUGSEGV");
                exit(0);
        }
	
	  *((int*)0) = 0;
        return 0;
}

}




I'd tryed to look on te gdb source but I cant figured out how it is done.

If you can give me some pist I can explore I would be very pleased.


Thanks In advance.

julien

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-07-04 16:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-04 16:26 How to get a context ? Janier Julien

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).