public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: sudhakar govindavajhala <sudhakarg79spam@gmail.com>
To: gcc@gcc.gnu.org
Subject: Converting SIGSEGV etc. signals to exceptions
Date: Sat, 20 Aug 2011 12:51:00 -0000	[thread overview]
Message-ID: <CAGdJZsDajivsuZ+nMm552yzuoa2OOkmXa3wDFSed-=ggduqoZA@mail.gmail.com> (raw)

Hi there,

I am writing C++ code in Linux (2.6.18) using pthreads. glibc 2.5. gcc 4.1.2

1) I understand that signals SIGFPE and SIGSEGV are sent to individual
threads while SIGINT is sent to the whole process.  How do I find out
what signal is thread specific and what signal is process wide.  How
does the OS/glibc determine which thread should be served the signal?

2) I would like to translate SIGSEGV or SIGFPE to an exception in the
program so that it can be caught at higher levels. Is there a default
option to convert a SIGSEGV to an exception?  For my tests, I provided
a signal handler for SIGSEGV/SIGFPE that throws an int exception and
it works. Is it legal to throw exceptions in signal handlers? Is there
any limitation on what kind of object can be thrown as an exception?
Could someone help me understand the rules in this space?

3) Could someone point me to  a sample to print the stack trace when
an exception occurred?

Thank you.

Sincerely
Sudhakar

             reply	other threads:[~2011-08-20 12:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-20 12:51 sudhakar govindavajhala [this message]
2011-08-20 14:43 ` Ian Lance Taylor
2011-08-20 14:55 ` Paweł Sikora

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='CAGdJZsDajivsuZ+nMm552yzuoa2OOkmXa3wDFSed-=ggduqoZA@mail.gmail.com' \
    --to=sudhakarg79spam@gmail.com \
    --cc=gcc@gcc.gnu.org \
    /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).