From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19784 invoked by alias); 4 Jul 2003 16:26:04 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 19777 invoked from network); 4 Jul 2003 16:26:04 -0000 Received: from unknown (HELO gwsmtp.thomson-csf.com) (195.101.39.226) by sources.redhat.com with SMTP; 4 Jul 2003 16:26:04 -0000 Received: from thalescan.corp.thales (200.3.2.3) by gwsmtp.thomson-csf.com (NPlex 6.5.026) id 3F000677000D6981 for gdb@sources.redhat.com; Fri, 4 Jul 2003 18:26:03 +0200 Received: from ariane.tus.fr.thales ([64.1.20.100]) by thalescan with InterScan Messaging Security Suite; Fri, 04 Jul 2003 18:25:58 +0200 Received: from mercure.tus.fr.thales (64.1.20.156) by ariane.tus.fr.thales (NPlex 6.5.026) id 3F029CB600003D55 for gdb@sources.redhat.com; Fri, 4 Jul 2003 18:25:58 +0200 Received: by mercure.tus.fr.thales with Internet Mail Service (5.5.2653.19) id <31AD09FC>; Fri, 4 Jul 2003 18:26:05 +0200 Message-ID: From: Janier Julien To: "'gdb@sources.redhat.com'" Subject: How to get a context ? Date: Fri, 04 Jul 2003 16:26:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-SW-Source: 2003-07/txt/msg00077.txt.bz2 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 #include #include #include 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