On 08/21/2011 03:02 PM, sudhakar govindavajhala wrote:
Hi there, Is there a flag in compiling or using gcc/g++ so that a signal like SIGSEGV in my C++ program will result in an exception being thrown? If not, why not? I mean, is this is not a reasonable expectation in OOPS? Is there anything I need to be careful in throwing an exception in my signal handlers that convert SIGSEGV to an exception. I will ensure that no malloc style calls are called.
The GCJ runtime library libgcj does exactly this. You can study it for the details.
Basically everything has to be compiled with -fnon-call-exceptions, and then you can throw exceptions right out of your signal handler. The exception object can be populated with information about the machine state and perhaps a stack trace as well.
David Daney
Thanks for your help. Sincerely, --Sudhakar