diff --git a/zeno/utils/SignalHooks.cpp b/zeno/utils/SignalHooks.cpp index 82a2a85232..102d2215eb 100644 --- a/zeno/utils/SignalHooks.cpp +++ b/zeno/utils/SignalHooks.cpp @@ -1,10 +1,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include #ifdef __linux__ +#include #include #endif @@ -32,7 +32,15 @@ void trigger_gdb() { #ifdef ZENO_FAULTHANDLER static void signal_handler(int signo) { +#ifdef __linux__ zlog::error("recieved signal {}: {}", signo, strsignal(signo)); +#else + const char *signame = "SIG-unknown"; + if (signo == SIGSEGV) signame = "SIGSEGV"; + if (signo == SIGFPE) signame = "SIGFPE"; + if (signo == SIGILL) signame = "SIGILL"; + zlog::error("recieved signal {}: {}", signo, signame); +#endif print_traceback(); trigger_gdb(); exit(-signo); @@ -45,7 +53,9 @@ static int registerMyHandlers() { signal(SIGSEGV, signal_handler); signal(SIGFPE, signal_handler); signal(SIGILL, signal_handler); +#ifdef __linux__ signal(SIGBUS, signal_handler); +#endif return 1; } diff --git a/zeno/utils/StackTraceback.cpp b/zeno/utils/StackTraceback.cpp index 394b75eb59..04213bf5ac 100644 --- a/zeno/utils/StackTraceback.cpp +++ b/zeno/utils/StackTraceback.cpp @@ -20,10 +20,7 @@ #include #include #endif -#ifdef _WIN64 -#include -#include - +#ifdef _WIN32 #include // Never directly include . That will bring you evil max/min macros. #if defined(min) @@ -32,6 +29,8 @@ #if defined(max) #undef max #endif +#include +#include #pragma comment(lib, "dbghelp.lib") // https://gist.github.com/rioki/85ca8295d51a5e0b7c56e5005b0ba8b4 @@ -91,7 +90,7 @@ struct StackFrame { }; inline std::vector stack_trace() { -#if _WIN64 +#if _WIN32 DWORD machine = IMAGE_FILE_MACHINE_AMD64; #else DWORD machine = IMAGE_FILE_MACHINE_I386; @@ -110,7 +109,7 @@ inline std::vector stack_trace() { context.ContextFlags = CONTEXT_FULL; RtlCaptureContext(&context); -#if _WIN64 +#if _WIN32 STACKFRAME frame = {}; frame.AddrPC.Offset = context.Rip; frame.AddrPC.Mode = AddrModeFlat; @@ -136,7 +135,7 @@ inline std::vector stack_trace() { StackFrame f = {}; f.address = frame.AddrPC.Offset; -#if _WIN64 +#if _WIN32 DWORD64 moduleBase = 0; #else DWORD moduleBase = 0; @@ -151,7 +150,7 @@ inline std::vector stack_trace() { } else { f.module = "Unknown Module"; } -#if _WIN64 +#if _WIN32 DWORD64 offset = 0; #else DWORD offset = 0; @@ -294,7 +293,7 @@ void print_traceback() { "========================================================================" "==================\n"); printf("\n"); -#elif defined(_WIN64) +#elif defined(_WIN32) // Windows fmt::print(fg(fmt::color::magenta), "************************\n"); fmt::print(fg(fmt::color::magenta), "* Zeno Stack Traceback *\n"); diff --git a/zenqt/system/dll.py b/zenqt/system/dll.py index ab22922a52..376d6e2092 100644 --- a/zenqt/system/dll.py +++ b/zenqt/system/dll.py @@ -2,33 +2,36 @@ from .utils import rel2abs, os_name -''' +lib_dir = rel2abs(__file__, '..', 'lib') + +#''' if os_name == 'win32': - dllpath = rel2abs(__file__, 'lib') - os.environ['PATH'] += os.pathsep + dllpath + os.environ['PATH'] += os.pathsep + lib_dir ctypes.cdll.LoadLibrary('zeno.dll') elif os_name == 'darwin': - ctypes.cdll.LoadLibrary(rel2abs(__file__, 'lib', 'libzeno.dylib')) + ctypes.cdll.LoadLibrary(os.path.join(lib_dir, 'libzeno.dylib')) else: - ctypes.cdll.LoadLibrary(rel2abs(__file__, 'lib', 'libzeno.so')) -''' + ctypes.cdll.LoadLibrary(os.path.join(lib_dir, 'libzeno.so')) +#''' from . import pyzeno as core def loadAutoloads(): - dir = rel2abs(__file__, 'lib') - print('loading addons from', dir) - if not os.path.isdir(dir): + print('loading addons from', lib_dir) + if not os.path.isdir(lib_dir): return paths = [] - for name in os.listdir(dir): - path = os.path.join(dir, name) + for name in os.listdir(lib_dir): + path = os.path.join(lib_dir, name) if os.path.islink(path): continue if os_name == 'win32': if name.endswith('.dll'): paths.append(name) + elif os_name == 'darwin': + if name.endswith('.dylib'): + paths.append(name) else: if 'so' in name.split(os.extsep): paths.append(path)