I don't have a ready made solution, but one thing you could look at are signals (not sure whether you can safely throw C++ exceptions from them, but it should help for debugging anyway.)
You could install a signal handler for SIGFPE, and use that for your debugging purposes.