7 #ifndef WITH_PYTHON_MODULE
9 # if defined(__linux__) && defined(__GNUC__)
14 # if (defined(__APPLE__) && (defined(__i386__) || defined(__x86_64__)))
16 # include <xmmintrin.h>
38 # include BLI_SYSTEM_PID_H
55 # ifdef USE_WRITE_CRASH_BLEND
61 # if defined(__linux__) || defined(_WIN32) || defined(OSX_SSE_FPE)
62 static void sig_handle_fpe(
int UNUSED(sig))
64 fprintf(stderr,
"debug: SIGFPE trapped\n");
69 # if !defined(WITH_HEADLESS)
78 printf(
"\nBlender killed\n");
81 printf(
"\nSent an internal break event. Press ^C again to kill Blender\n");
89 fputs(
"\n# backtrace\n", fp);
100 # ifdef USE_WRITE_CRASH_BLEND
114 printf(
"Writing: %s\n", fname);
136 printf(
"Writing: %s\n", fname);
157 "Unable to save '%s': %s\n",
159 errno ? strerror(errno) :
"Unknown error opening file");
180 signal(signum, SIG_DFL);
182 kill(getpid(), signum);
184 TerminateProcess(GetCurrentProcess(), signum);
189 extern LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
193 if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_STACK_OVERFLOW) {
195 CHAR modulename[MAX_PATH];
196 LPVOID address = ExceptionInfo->ExceptionRecord->ExceptionAddress;
197 fprintf(stderr,
"Error : EXCEPTION_STACK_OVERFLOW\n");
198 fprintf(stderr,
"Address : 0x%p\n", address);
199 if (GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, address, &
mod)) {
200 if (GetModuleFileName(
mod, modulename, MAX_PATH)) {
201 fprintf(stderr,
"Module : %s\n", modulename);
210 return EXCEPTION_EXECUTE_HANDLER;
224 SetUnhandledExceptionFilter(windows_exception_handler);
233 SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT | SEM_NOGPFAULTERRORBOX |
234 SEM_NOOPENFILEERRORBOX);
247 # if !defined(WITH_HEADLESS)
256 # if defined(__linux__) || defined(_WIN32) || defined(OSX_SSE_FPE)
259 signal(SIGFPE, sig_handle_fpe);
261 # if defined(__linux__) && defined(__GNUC__)
262 feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
264 # if defined(OSX_SSE_FPE)
267 _MM_SET_EXCEPTION_MASK(_MM_MASK_MASK &
268 ~(_MM_MASK_OVERFLOW | _MM_MASK_INVALID | _MM_MASK_DIV_ZERO));
270 # if defined(_WIN32) && defined(_MSC_VER)
272 _controlfp_s(
NULL, 0, _MCW_EM);
274 _controlfp_s(
NULL, _EM_DENORMAL | _EM_UNDERFLOW | _EM_INEXACT, _MCW_EM);
void BKE_tempdir_session_purge(void)
const char * BKE_tempdir_base(void)
bool BKE_report_write_file_fp(FILE *fp, ReportList *reports, const char *header)
File and directory operations.
FILE * BLI_fopen(const char *filepath, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
const char * BLI_path_basename(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
bool BLI_path_extension_replace(char *path, size_t maxlen, const char *ext) ATTR_NONNULL()
void BLI_join_dirfile(char *__restrict dst, size_t maxlen, const char *__restrict dir, const char *__restrict file) ATTR_NONNULL()
#define STRNCPY(dst, src)
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
void BLI_system_backtrace(FILE *fp)
Compatibility-like things for windows.
bool BLO_memfile_write_file(struct MemFile *memfile, const char *filepath)
void BPY_python_backtrace(FILE *fp)
struct ApplicationState app_state
#define BLEND_VERSION_ARG
#define BLEND_VERSION_FMT
void main_signal_setup_background(void)
static void sig_handle_abort(int UNUSED(signum))
void main_signal_setup_fpe(void)
static void sig_handle_crash(int signum)
static void sig_handle_blender_esc(int sig)
void main_signal_setup(void)
static void sig_handle_crash_backtrace(FILE *fp)
struct ApplicationState::@1221 signal
struct ReportList reports
struct UndoStack * undo_stack
void BLI_windows_handle_exception(EXCEPTION_POINTERS *exception)
ccl_device_inline int mod(int x, int m)