diff --git a/src/unwind/unwind_with_dbghelp.cpp b/src/unwind/unwind_with_dbghelp.cpp index 7474c4b..a85ba52 100644 --- a/src/unwind/unwind_with_dbghelp.cpp +++ b/src/unwind/unwind_with_dbghelp.cpp @@ -32,9 +32,10 @@ namespace detail { // GetThreadContext cannot be used on the current thread. // RtlCaptureContext doesn't work on i386 CONTEXT context; - #ifdef _M_IX86 + #if defined(_M_IX86) || defined(__i386__) ZeroMemory(&context, sizeof(CONTEXT)); context.ContextFlags = CONTEXT_CONTROL; + #if IS_MSVC __asm { label: mov [context.Ebp], ebp; @@ -43,6 +44,18 @@ namespace detail { mov [context.Eip], eax; } #else + asm( + "label:\n\t" + "mov{l %%ebp, %[cEbp] | %[cEbp], ebp};\n\t" + "mov{l %%esp, %[cEsp] | %[cEsp], esp};\n\t" + "mov{l $label, %%eax | eax, label};\n\t" + "mov{l %%eax, %[cEip] | %[cEip], eax};\n\t" + : [cEbp] "=r" (context.Ebp), + [cEsp] "=r" (context.Esp), + [cEip] "=r" (context.Eip) + ); + #endif + #else RtlCaptureContext(&context); #endif // Setup current frame