Skip to content

Commit

Permalink
Merge pull request #54 from ZacWalk/master
Browse files Browse the repository at this point in the history
Windows ARM64 support
  • Loading branch information
JochenKalmbach authored Jul 2, 2022
2 parents 5332051 + e3c85f0 commit 5b0df7a
Show file tree
Hide file tree
Showing 8 changed files with 647 additions and 5 deletions.
1 change: 1 addition & 0 deletions Main/StackWalker/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/Debug_*
/Release_*
/x64
/arm64
/Itanium
/ipch
/.vs
Expand Down
8 changes: 8 additions & 0 deletions Main/StackWalker/StackWalker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,14 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread,
s.AddrBStore.Mode = AddrModeFlat;
s.AddrStack.Offset = c.IntSp;
s.AddrStack.Mode = AddrModeFlat;
#elif _M_ARM64
imageType = IMAGE_FILE_MACHINE_ARM64;
s.AddrPC.Offset = c.Pc;
s.AddrPC.Mode = AddrModeFlat;
s.AddrFrame.Offset = c.Fp;
s.AddrFrame.Mode = AddrModeFlat;
s.AddrStack.Offset = c.Sp;
s.AddrStack.Mode = AddrModeFlat;
#else
#error "Platform not supported!"
#endif
Expand Down
54 changes: 54 additions & 0 deletions Main/StackWalker/StackWalker_VC2022.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32620.295
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StackWalker_VC2022", "StackWalker_VC2022.vcxproj", "{89B2BD42-B130-4811-9043-71A8EBC40DE5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug_VC2017|ARM64 = Debug_VC2017|ARM64
Debug_VC2017|Win32 = Debug_VC2017|Win32
Debug_VC2017|x64 = Debug_VC2017|x64
Debug_VC2017-UNICODE|ARM64 = Debug_VC2017-UNICODE|ARM64
Debug_VC2017-UNICODE|Win32 = Debug_VC2017-UNICODE|Win32
Debug_VC2017-UNICODE|x64 = Debug_VC2017-UNICODE|x64
Release_VC2017|ARM64 = Release_VC2017|ARM64
Release_VC2017|Win32 = Release_VC2017|Win32
Release_VC2017|x64 = Release_VC2017|x64
Release_VC2017-UNICODE|ARM64 = Release_VC2017-UNICODE|ARM64
Release_VC2017-UNICODE|Win32 = Release_VC2017-UNICODE|Win32
Release_VC2017-UNICODE|x64 = Release_VC2017-UNICODE|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017|ARM64.ActiveCfg = Debug_VC2017|ARM64
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017|ARM64.Build.0 = Debug_VC2017|ARM64
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017|Win32.ActiveCfg = Debug_VC2017|Win32
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017|Win32.Build.0 = Debug_VC2017|Win32
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017|x64.ActiveCfg = Debug_VC2017|x64
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017|x64.Build.0 = Debug_VC2017|x64
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017-UNICODE|ARM64.ActiveCfg = Debug_VC2017-UNICODE|ARM64
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017-UNICODE|ARM64.Build.0 = Debug_VC2017-UNICODE|ARM64
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017-UNICODE|Win32.ActiveCfg = Debug_VC2017-UNICODE|Win32
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017-UNICODE|Win32.Build.0 = Debug_VC2017-UNICODE|Win32
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017-UNICODE|x64.ActiveCfg = Debug_VC2017-UNICODE|x64
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017-UNICODE|x64.Build.0 = Debug_VC2017-UNICODE|x64
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017|ARM64.ActiveCfg = Release_VC2017|ARM64
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017|ARM64.Build.0 = Release_VC2017|ARM64
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017|Win32.ActiveCfg = Release_VC2017|Win32
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017|Win32.Build.0 = Release_VC2017|Win32
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017|x64.ActiveCfg = Release_VC2017|x64
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017|x64.Build.0 = Release_VC2017|x64
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017-UNICODE|ARM64.ActiveCfg = Release_VC2017-UNICODE|ARM64
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017-UNICODE|ARM64.Build.0 = Release_VC2017-UNICODE|ARM64
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017-UNICODE|Win32.ActiveCfg = Release_VC2017-UNICODE|Win32
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017-UNICODE|Win32.Build.0 = Release_VC2017-UNICODE|Win32
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017-UNICODE|x64.ActiveCfg = Release_VC2017-UNICODE|x64
{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017-UNICODE|x64.Build.0 = Release_VC2017-UNICODE|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {214F4088-66CE-43FA-80E8-33674E8CE048}
EndGlobalSection
EndGlobal
517 changes: 517 additions & 0 deletions Main/StackWalker/StackWalker_VC2022.vcxproj

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions Main/StackWalker/StackWalker_VC2022.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="StackWalker.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="StackWalker.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
10 changes: 10 additions & 0 deletions Main/StackWalker/StackWalker_VC2022.vcxproj.vspscc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT"
}
11 changes: 8 additions & 3 deletions Main/StackWalker/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void GlobalFunctionPointerTest()
// http://blog.kalmbach-software.de/2008/04/02/unhandled-exceptions-in-vc8-and-above-for-x86-and-x64/
// Even better: http://blog.kalmbach-software.de/2013/05/23/improvedpreventsetunhandledexceptionfilter/

#if defined(_M_X64) || defined(_M_IX86)
#if defined(_M_X64) || defined(_M_IX86) || defined(_M_ARM64)
static BOOL PreventSetUnhandledExceptionFilter()
{
HMODULE hKernel32 = LoadLibrary(_T("kernel32.dll"));
Expand All @@ -104,6 +104,11 @@ static BOOL PreventSetUnhandledExceptionFilter()
// 33 C0 xor eax,eax
// C3 ret
unsigned char szExecute[] = {0x33, 0xC0, 0xC3};
#elif _M_ARM64
unsigned char szExecute[] = {
0x00, 0x00, 0x80, 0x52, // mov w0, #0
0xC0, 0x03, 0x5F, 0xD6 // ret
};
#else
#error "The following code only works for x86 and x64!"
#endif
Expand All @@ -123,7 +128,7 @@ static BOOL PreventSetUnhandledExceptionFilter()
return bRet;
}
#else
#pragma message("This code works only for x86 and x64!")
#pragma message("This code works only for x86, x64 and arm64!")
#endif

static TCHAR s_szExceptionLogFileName[_MAX_PATH] = _T("\\exceptions.log"); // default
Expand Down Expand Up @@ -174,7 +179,7 @@ static void InitUnhandledExceptionFilter()
{
// set global exception handler (for handling all unhandled exceptions)
SetUnhandledExceptionFilter(CrashHandlerExceptionFilter);
#if defined _M_X64 || defined _M_IX86
#if defined _M_X64 || defined _M_IX86 || defined _M_ARM64
PreventSetUnhandledExceptionFilter();
#endif
s_bUnhandledExeptionFilterSet = TRUE;
Expand Down
21 changes: 19 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,31 @@ environment:
CONFIGURATION: "Release_VC9-UNICODE"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
CMAKE_GENERATOR: "Visual Studio 12 2013"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
CMAKE_GENERATOR: "Visual Studio 12 2013 Win64"
TARGET_CONFIG: "--config RelWithDebInfo"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
CMAKE_GENERATOR: "Visual Studio 14 2015"
TARGET_CONFIG: "--config RelWithDebInfo"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
CMAKE_GENERATOR: "Visual Studio 14 2015 Win64"
TARGET_CONFIG: "--config RelWithDebInfo"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_GENERATOR: "Visual Studio 15 2017"
TARGET_CONFIG: "--config RelWithDebInfo"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_GENERATOR: "Visual Studio 15 2017 Win64"
TARGET_CONFIG: "--config RelWithDebInfo"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
CMAKE_GENERATOR: "Visual Studio 17 2022"
TARGET_ARCH: "-A Win32"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
CMAKE_GENERATOR: "Visual Studio 17 2022"
TARGET_ARCH: "-A x64"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
CMAKE_GENERATOR: "Visual Studio 17 2022"
TARGET_ARCH: "-A ARM64"


before_build:
- if [%BUILDER%]==[msbuild] echo MSVC2008
Expand Down Expand Up @@ -55,6 +70,8 @@ build_script:
- if [%BUILDER%]==[msbuild] msbuild %SLN_NAME% %MS_BLD_ARGS% /logger:"%AVLOGGER%"
- if not [%BUILDER%]==[msbuild] cmake --version
- if not [%BUILDER%]==[msbuild] cmake -E make_directory "build-dir"
- if not [%BUILDER%]==[msbuild] cmake -E chdir "build-dir" cmake -G "%CMAKE_GENERATOR%" --config RelWithDebInfo -DCMAKE_INSTALL_PREFIX="%APPVEYOR_BUILD_FOLDER%/root" ..
- if not [%BUILDER%]==[msbuild] cmake -E chdir "build-dir" cmake -G "%CMAKE_GENERATOR%" %TARGET_ARCH% %TARGET_CONFIG% -DCMAKE_INSTALL_PREFIX="%APPVEYOR_BUILD_FOLDER%/root" ..
- if not [%BUILDER%]==[msbuild] cmake --build "build-dir" --config RelWithDebInfo
- if not [%BUILDER%]==[msbuild] cmake --build "build-dir" --target install --config RelWithDebInfo


0 comments on commit 5b0df7a

Please sign in to comment.