BelledonneCommunications / bctoolbox

Linphone.org mirror for bctoolbox (git://git.linphone.org/bctoolbox.git)
http://linphone.org
GNU General Public License v3.0
25 stars 33 forks source link

[Bug]: Win64 for ARM64 cpu build fails (fix included) #23

Open boreno opened 1 year ago

boreno commented 1 year ago

Context

We are using a commercial license to embed Linphone in our cross-platform Standard ERP system. The BCToolbox project doesn't build on Windows ARM64, a fix is provided below.

General information

Expected behaviour

The bctoolbox::getStackTrace() function should use the ARM64 registers in the _CONTEXT structure on Win64 ARM64.

To Reproduce

  1. Build BCTOOLBOX using the Visual Studio 2022 ARM64 native command prompt using the ARM64 architecture

Additional context

To fix this build issue, edit the file bctoolbox\src\utils\win_utils.cc, function getStackTrace() on line 107, changing the following:

#if _WIN64
    STACKFRAME frame = {};
    frame.AddrPC.Offset = context.Rip;
    frame.AddrPC.Mode = AddrModeFlat;
    frame.AddrFrame.Offset = context.Rbp;
    frame.AddrFrame.Mode = AddrModeFlat;
    frame.AddrStack.Offset = context.Rsp;
    frame.AddrStack.Mode = AddrModeFlat;

into this

#if _WIN64 && !defined(_ARM64_)
    STACKFRAME frame = {};
    frame.AddrPC.Offset = context.Rip;
    frame.AddrPC.Mode = AddrModeFlat;
    frame.AddrFrame.Offset = context.Rbp;
    frame.AddrFrame.Mode = AddrModeFlat;
    frame.AddrStack.Offset = context.Rsp;
    frame.AddrStack.Mode = AddrModeFlat;
#elif defined(_ARM64_)
    STACKFRAME frame = {};
    frame.AddrPC.Offset = context.Pc;
    frame.AddrPC.Mode = AddrModeFlat;
    frame.AddrFrame.Offset = context.Fp;
    frame.AddrFrame.Mode = AddrModeFlat;
    frame.AddrStack.Offset = context.Sp;
    frame.AddrStack.Mode = AddrModeFlat;

SDK logs URL

No response