jeremy-rifkin / cpptrace

Simple, portable, and self-contained stacktrace library for C++11 and newer
MIT License
701 stars 75 forks source link

Compilation error in version 0.3.1 using MSVC 19.38 and Windows-on-arm #83

Closed alexbichkov closed 9 months ago

alexbichkov commented 9 months ago

Hi @jeremy-rifkin. I stumbled upon this error, and I wonder whether your library supports Windows-on-arm yet?

backward-cpp\backward.hpp(1168,29): error C2039: 'Eip': is not a member of '_CONTEXT' backward-cpp\backward.hpp(1169,32): error C2039: 'Esp': is not a member of '_CONTEXT' backward-cpp\backward.hpp(1170,32): error C2039: 'Ebp': is not a member of '_CONTEXT' see declaration of '_CONTEXT'

And this is CONTEXT object, defined in winnt.h for ARM64_NT: typedef struct DECLSPEC_ALIGN(16) DECLSPEC_NOINITALL _ARM64_NT_CONTEXT { // // Control flags. //

/* +0x000 */ DWORD ContextFlags;

//
// Integer registers
//

/* +0x004 */ DWORD Cpsr;       // NZVF + DAIF + CurrentEL + SPSel
/* +0x008 */ union {
                struct {
                    DWORD64 X0;
                    DWORD64 X1;
                    DWORD64 X2;
                    DWORD64 X3;
                    DWORD64 X4;
                    DWORD64 X5;
                    DWORD64 X6;
                    DWORD64 X7;
                    DWORD64 X8;
                    DWORD64 X9;
                    DWORD64 X10;
                    DWORD64 X11;
                    DWORD64 X12;
                    DWORD64 X13;
                    DWORD64 X14;
                    DWORD64 X15;
                    DWORD64 X16;
                    DWORD64 X17;
                    DWORD64 X18;
                    DWORD64 X19;
                    DWORD64 X20;
                    DWORD64 X21;
                    DWORD64 X22;
                    DWORD64 X23;
                    DWORD64 X24;
                    DWORD64 X25;
                    DWORD64 X26;
                    DWORD64 X27;
                    DWORD64 X28;
/* +0x0f0 */        DWORD64 Fp;
/* +0x0f8 */        DWORD64 Lr;
                } DUMMYSTRUCTNAME;
                DWORD64 X[31];
             } DUMMYUNIONNAME;
/* +0x100 */ DWORD64 Sp;
/* +0x108 */ DWORD64 Pc;

//
// Floating Point/NEON Registers
//

/* +0x110 */ ARM64_NT_NEON128 V[32];
/* +0x310 */ DWORD Fpcr;
/* +0x314 */ DWORD Fpsr;

//
// Debug registers
//

/* +0x318 */ DWORD Bcr[ARM64_MAX_BREAKPOINTS];
/* +0x338 */ DWORD64 Bvr[ARM64_MAX_BREAKPOINTS];
/* +0x378 */ DWORD Wcr[ARM64_MAX_WATCHPOINTS];
/* +0x380 */ DWORD64 Wvr[ARM64_MAX_WATCHPOINTS];
/* +0x390 */

} ARM64_NT_CONTEXT, *PARM64_NT_CONTEXT;
jeremy-rifkin commented 9 months ago

Hi @alexbichkov, I don't have a windows arm machine to test with however when adding cpptrace to vcpkg I was able to get it working for ARM. The StackWalk64 unwind code does also have specific handling for arm: https://github.com/jeremy-rifkin/cpptrace/blob/448c325d2e9d1c6e28749202c1dca7ec546cca6a/src/unwind/unwind_with_dbghelp.cpp#L83-L93

I'm a bit confused by the error message you provided though, as that is from backward-cpp which is a different library.

alexbichkov commented 9 months ago

Surely it's a different library and I got confused. Sorry to bother you.

jeremy-rifkin commented 9 months ago

All good, take care