use fpe_handler on linux when running with -d, this runs a function rarther then quitting, use for setting breakpoints to find where nan/inf occur.

This commit is contained in:
Campbell Barton 2010-02-03 15:50:08 +00:00
parent fb728addd2
commit 61457571af

@ -134,7 +134,8 @@ char blender_path[FILE_MAXDIR+FILE_MAXFILE] = BLENDERPATH;
/* Initialise callbacks for the modules that need them */ /* Initialise callbacks for the modules that need them */
static void setCallbacks(void); static void setCallbacks(void);
#if defined(__sgi) || defined(__alpha__) /* on linux set breakpoints here when running in debug mode, useful to catch floating point errors */
#if defined(__sgi) || defined(__linux__)
static void fpe_handler(int sig) static void fpe_handler(int sig)
{ {
// printf("SIGFPE trapped\n"); // printf("SIGFPE trapped\n");
@ -899,14 +900,6 @@ int main(int argc, char **argv)
#ifdef __FreeBSD__ #ifdef __FreeBSD__
fpsetmask(0); fpsetmask(0);
#endif #endif
#ifdef __linux__
#ifdef __alpha__
signal (SIGFPE, fpe_handler);
#endif
#endif
#if defined(__sgi)
signal (SIGFPE, fpe_handler);
#endif
// copy path to executable in bprogname. playanim and creting runtimes // copy path to executable in bprogname. playanim and creting runtimes
// need this. // need this.
@ -947,11 +940,17 @@ int main(int argc, char **argv)
setuid(getuid()); /* end superuser */ setuid(getuid()); /* end superuser */
#endif #endif
#if defined(__sgi) || defined(__linux__)
if(G.f & G_DEBUG) {
/* zealous but makes float issues a heck of a lot easier to find!
* set breakpoints on fpe_handler */
signal(SIGFPE, fpe_handler);
#ifdef __linux__ #ifdef __linux__
/* zealous but makes float issues a heck of a lot easier to find! */
if(G.f & G_DEBUG)
feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW ); feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW );
#endif #endif
}
#endif
/* for all platforms, even windos has it! */ /* for all platforms, even windos has it! */
if(G.background) signal(SIGINT, blender_esc); /* ctrl c out bg render */ if(G.background) signal(SIGINT, blender_esc); /* ctrl c out bg render */