diff --git a/src/debug.cpp b/src/debug.cpp index 51c356b..37299aa 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -46,6 +46,10 @@ # include // backtrace_syminfo #endif // BX_CONFIG_CALLSTACK_* +#ifndef BX_CONFIG_CALLSTACK_USE_DBGHELP +# define BX_CONFIG_CALLSTACK_USE_DBGHELP BX_PLATFORM_WINDOWS +#endif // BX_CONFIG_CALLSTACK_USE_DBGHELP + #ifndef BX_CONFIG_EXCEPTION_HANDLING_USE_WINDOWS_SEH # define BX_CONFIG_EXCEPTION_HANDLING_USE_WINDOWS_SEH BX_PLATFORM_WINDOWS #endif // BX_CONFIG_EXCEPTION_HANDLING_USE_WINDOWS_SEH @@ -684,7 +688,7 @@ namespace bx return total; } -#elif BX_PLATFORM_WINDOWS +#elif BX_CONFIG_CALLSTACK_USE_DBGHELP struct DbgHelpSymbolInfo { @@ -729,7 +733,7 @@ namespace bx struct DbgHelpSymbolResolve { - DbgHelpSymbolResolve() + void init() { m_imageHlpDll = dlopen("dbghelp.dll"); @@ -855,6 +859,15 @@ namespace bx total += write(_writer, _err, "\t #: %-*s Line %-*s Function ---\n", kWidth, "File ---", kWidthPc, "PC ---"); + static bool initCalled = false; + + if (!initCalled) + { + initCalled = true; + + s_dbgHelpSymbolResolve.init(); + } + for (uint32_t ii = 0; ii < _num && _err->isOk(); ++ii) { FixedString1024 functionName;