public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Janier Julien <Julien.Janier@fr.thalesgroup.com>
To: "'gdb@sources.redhat.com'" <gdb@sources.redhat.com>
Subject: How to get a context ?
Date: Fri, 04 Jul 2003 16:26:00 -0000	[thread overview]
Message-ID: <F2E37429BA50E34EA0B7F97AFEB8CBD1017FB14C@mercure.tus.fr.thales> (raw)

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

                 reply	other threads:[~2003-07-04 16:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F2E37429BA50E34EA0B7F97AFEB8CBD1017FB14C@mercure.tus.fr.thales \
    --to=julien.janier@fr.thalesgroup.com \
    --cc=gdb@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).