Converting floating point exceptions into C++ exceptions

前端 未结 5 902
栀梦
栀梦 2021-02-06 08:41

Is it possible to convert floating point exceptions (signals) into C++ exceptions on x86 Linux?

This is for debugging purposes, so nonportability and imperfection is oka

5条回答
  •  春和景丽
    2021-02-06 09:19

    The basic idea will be for you to install the appropriate signal handlers for floating point exceptions. Inside your signal handler, you can throw an exception (or send a user-defined signal to another process which will raise the exception, or send a message to another thread for something similar, etc. etc. etc). There are any number of ways to actually throw the exception - the main thing is to handle the signal.

提交回复
热议问题