mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 20:27:36 +02:00
[ARM64] UnhandledExceptionHandler ARM64 support (#17587)
* Rename UnhandledExceptionHandler_x64.h and InitUnhandledExceptionHandler_x64 * Added ARM64 registers to UnhandledExceptionHandler * Added ARM64 registers to unhandled_exception_handler.cpp
This commit is contained in:
@@ -284,8 +284,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "utils", "utils", "{B39DC643
|
|||||||
src\common\utils\resources.h = src\common\utils\resources.h
|
src\common\utils\resources.h = src\common\utils\resources.h
|
||||||
src\common\utils\string_utils.h = src\common\utils\string_utils.h
|
src\common\utils\string_utils.h = src\common\utils\string_utils.h
|
||||||
src\common\utils\timeutil.h = src\common\utils\timeutil.h
|
src\common\utils\timeutil.h = src\common\utils\timeutil.h
|
||||||
src\common\utils\UnhandledExceptionHandler_x64.h = src\common\utils\UnhandledExceptionHandler_x64.h
|
|
||||||
src\common\utils\winapi_error.h = src\common\utils\winapi_error.h
|
src\common\utils\winapi_error.h = src\common\utils\winapi_error.h
|
||||||
|
src\common\utils\UnhandledExceptionHandler.h = src\common\utils\UnhandledExceptionHandler.h
|
||||||
src\common\utils\window.h = src\common\utils\window.h
|
src\common\utils\window.h = src\common\utils\window.h
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
|||||||
@@ -162,11 +162,18 @@ inline void LogStackTrace()
|
|||||||
|
|
||||||
HANDLE process = GetCurrentProcess();
|
HANDLE process = GetCurrentProcess();
|
||||||
HANDLE thread = GetCurrentThread();
|
HANDLE thread = GetCurrentThread();
|
||||||
|
|
||||||
|
#ifdef _M_ARM64
|
||||||
|
stack.AddrPC.Offset = context.Pc;
|
||||||
|
stack.AddrStack.Offset = context.Sp;
|
||||||
|
stack.AddrFrame.Offset = context.Fp;
|
||||||
|
#else
|
||||||
stack.AddrPC.Offset = context.Rip;
|
stack.AddrPC.Offset = context.Rip;
|
||||||
stack.AddrPC.Mode = AddrModeFlat;
|
|
||||||
stack.AddrStack.Offset = context.Rsp;
|
stack.AddrStack.Offset = context.Rsp;
|
||||||
stack.AddrStack.Mode = AddrModeFlat;
|
|
||||||
stack.AddrFrame.Offset = context.Rbp;
|
stack.AddrFrame.Offset = context.Rbp;
|
||||||
|
#endif
|
||||||
|
stack.AddrPC.Mode = AddrModeFlat;
|
||||||
|
stack.AddrStack.Mode = AddrModeFlat;
|
||||||
stack.AddrFrame.Mode = AddrModeFlat;
|
stack.AddrFrame.Mode = AddrModeFlat;
|
||||||
|
|
||||||
BOOL result = false;
|
BOOL result = false;
|
||||||
@@ -174,7 +181,11 @@ inline void LogStackTrace()
|
|||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
result = StackWalk64(
|
result = StackWalk64(
|
||||||
|
#ifdef _M_ARM64
|
||||||
|
IMAGE_FILE_MACHINE_ARM64,
|
||||||
|
#else
|
||||||
IMAGE_FILE_MACHINE_AMD64,
|
IMAGE_FILE_MACHINE_AMD64,
|
||||||
|
#endif
|
||||||
process,
|
process,
|
||||||
thread,
|
thread,
|
||||||
&stack,
|
&stack,
|
||||||
@@ -252,7 +263,7 @@ inline void InitSymbols()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void InitUnhandledExceptionHandler_x64(void)
|
inline void InitUnhandledExceptionHandler(void)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <common/SettingsAPI/settings_helpers.h>
|
#include <common/SettingsAPI/settings_helpers.h>
|
||||||
#include <common/utils/ProcessWaiter.h>
|
#include <common/utils/ProcessWaiter.h>
|
||||||
#include <common/utils/winapi_error.h>
|
#include <common/utils/winapi_error.h>
|
||||||
#include <common/utils/UnhandledExceptionHandler_x64.h>
|
#include <common/utils/UnhandledExceptionHandler.h>
|
||||||
#include <common/utils/logger_helper.h>
|
#include <common/utils/logger_helper.h>
|
||||||
#include <common/utils/EventWaiter.h>
|
#include <common/utils/EventWaiter.h>
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
|||||||
{
|
{
|
||||||
winrt::init_apartment();
|
winrt::init_apartment();
|
||||||
LoggerHelpers::init_logger(ShortcutGuideConstants::ModuleKey, L"ShortcutGuide", LogSettings::shortcutGuideLoggerName);
|
LoggerHelpers::init_logger(ShortcutGuideConstants::ModuleKey, L"ShortcutGuide", LogSettings::shortcutGuideLoggerName);
|
||||||
InitUnhandledExceptionHandler_x64();
|
InitUnhandledExceptionHandler();
|
||||||
Logger::trace("Starting Shortcut Guide");
|
Logger::trace("Starting Shortcut Guide");
|
||||||
|
|
||||||
if (!SetCurrentPath())
|
if (!SetCurrentPath())
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <common/utils/ProcessWaiter.h>
|
#include <common/utils/ProcessWaiter.h>
|
||||||
#include <common/utils/window.h>
|
#include <common/utils/window.h>
|
||||||
#include <common/utils/UnhandledExceptionHandler_x64.h>
|
#include <common/utils/UnhandledExceptionHandler.h>
|
||||||
|
|
||||||
#include <common/utils/logger_helper.h>
|
#include <common/utils/logger_helper.h>
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
|||||||
{
|
{
|
||||||
winrt::init_apartment();
|
winrt::init_apartment();
|
||||||
LoggerHelpers::init_logger(moduleName, internalPath, LogSettings::alwaysOnTopLoggerName);
|
LoggerHelpers::init_logger(moduleName, internalPath, LogSettings::alwaysOnTopLoggerName);
|
||||||
InitUnhandledExceptionHandler_x64();
|
InitUnhandledExceptionHandler();
|
||||||
|
|
||||||
auto mutex = CreateMutex(nullptr, true, instanceMutexName.c_str());
|
auto mutex = CreateMutex(nullptr, true, instanceMutexName.c_str());
|
||||||
if (mutex == nullptr)
|
if (mutex == nullptr)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <common/display/dpi_aware.h>
|
#include <common/display/dpi_aware.h>
|
||||||
#include <common/utils/logger_helper.h>
|
#include <common/utils/logger_helper.h>
|
||||||
#include <common/utils/resources.h>
|
#include <common/utils/resources.h>
|
||||||
#include <common/utils/UnhandledExceptionHandler_x64.h>
|
#include <common/utils/UnhandledExceptionHandler.h>
|
||||||
|
|
||||||
#include <FancyZonesLib/Generated Files/resource.h>
|
#include <FancyZonesLib/Generated Files/resource.h>
|
||||||
#include <FancyZonesLib/FancyZonesData.h>
|
#include <FancyZonesLib/FancyZonesData.h>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <common/utils/ProcessWaiter.h>
|
#include <common/utils/ProcessWaiter.h>
|
||||||
#include <common/utils/window.h>
|
#include <common/utils/window.h>
|
||||||
#include <common/utils/UnhandledExceptionHandler_x64.h>
|
#include <common/utils/UnhandledExceptionHandler.h>
|
||||||
|
|
||||||
#include <FancyZonesLib/trace.h>
|
#include <FancyZonesLib/trace.h>
|
||||||
#include <FancyZonesLib/Generated Files/resource.h>
|
#include <FancyZonesLib/Generated Files/resource.h>
|
||||||
@@ -26,7 +26,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
|||||||
{
|
{
|
||||||
winrt::init_apartment();
|
winrt::init_apartment();
|
||||||
LoggerHelpers::init_logger(moduleName, internalPath, LogSettings::fancyZonesLoggerName);
|
LoggerHelpers::init_logger(moduleName, internalPath, LogSettings::fancyZonesLoggerName);
|
||||||
InitUnhandledExceptionHandler_x64();
|
InitUnhandledExceptionHandler();
|
||||||
|
|
||||||
auto mutex = CreateMutex(nullptr, true, instanceMutexName.c_str());
|
auto mutex = CreateMutex(nullptr, true, instanceMutexName.c_str());
|
||||||
if (mutex == nullptr)
|
if (mutex == nullptr)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include <common/utils/winapi_error.h>
|
#include <common/utils/winapi_error.h>
|
||||||
#include <common/utils/logger_helper.h>
|
#include <common/utils/logger_helper.h>
|
||||||
#include <common/utils/ProcessWaiter.h>
|
#include <common/utils/ProcessWaiter.h>
|
||||||
#include <common/utils/UnhandledExceptionHandler_x64.h>
|
#include <common/utils/UnhandledExceptionHandler.h>
|
||||||
|
|
||||||
#include <trace.h>
|
#include <trace.h>
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
|||||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||||
|
|
||||||
LoggerHelpers::init_logger(KeyboardManagerConstants::ModuleName, L"Editor", LogSettings::keyboardManagerLoggerName);
|
LoggerHelpers::init_logger(KeyboardManagerConstants::ModuleName, L"Editor", LogSettings::keyboardManagerLoggerName);
|
||||||
InitUnhandledExceptionHandler_x64();
|
InitUnhandledExceptionHandler();
|
||||||
Trace::RegisterProvider();
|
Trace::RegisterProvider();
|
||||||
|
|
||||||
auto mutex = CreateMutex(nullptr, true, instanceMutexName.c_str());
|
auto mutex = CreateMutex(nullptr, true, instanceMutexName.c_str());
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <common/utils/ProcessWaiter.h>
|
#include <common/utils/ProcessWaiter.h>
|
||||||
#include <common/utils/winapi_error.h>
|
#include <common/utils/winapi_error.h>
|
||||||
#include <common/utils/logger_helper.h>
|
#include <common/utils/logger_helper.h>
|
||||||
#include <common/utils/UnhandledExceptionHandler_x64.h>
|
#include <common/utils/UnhandledExceptionHandler.h>
|
||||||
#include <keyboardmanager/common/KeyboardManagerConstants.h>
|
#include <keyboardmanager/common/KeyboardManagerConstants.h>
|
||||||
#include <keyboardmanager/KeyboardManagerEngineLibrary/KeyboardManager.h>
|
#include <keyboardmanager/KeyboardManagerEngineLibrary/KeyboardManager.h>
|
||||||
#include <keyboardmanager/KeyboardManagerEngineLibrary/trace.h>
|
#include <keyboardmanager/KeyboardManagerEngineLibrary/trace.h>
|
||||||
@@ -15,7 +15,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
|||||||
winrt::init_apartment();
|
winrt::init_apartment();
|
||||||
LoggerHelpers::init_logger(KeyboardManagerConstants::ModuleName, L"Engine", LogSettings::keyboardManagerLoggerName);
|
LoggerHelpers::init_logger(KeyboardManagerConstants::ModuleName, L"Engine", LogSettings::keyboardManagerLoggerName);
|
||||||
|
|
||||||
InitUnhandledExceptionHandler_x64();
|
InitUnhandledExceptionHandler();
|
||||||
|
|
||||||
auto mutex = CreateMutex(nullptr, true, instanceMutexName.c_str());
|
auto mutex = CreateMutex(nullptr, true, instanceMutexName.c_str());
|
||||||
if (mutex == nullptr)
|
if (mutex == nullptr)
|
||||||
|
|||||||
@@ -82,18 +82,30 @@ void log_stack_trace(std::wstring& generalErrorDescription)
|
|||||||
auto thread = GetCurrentThread();
|
auto thread = GetCurrentThread();
|
||||||
STACKFRAME64 stack;
|
STACKFRAME64 stack;
|
||||||
memset(&stack, 0, sizeof(STACKFRAME64));
|
memset(&stack, 0, sizeof(STACKFRAME64));
|
||||||
|
|
||||||
|
#ifdef _M_ARM64
|
||||||
|
stack.AddrPC.Offset = context.Pc;
|
||||||
|
stack.AddrStack.Offset = context.Sp;
|
||||||
|
stack.AddrFrame.Offset = context.Fp;
|
||||||
|
#else
|
||||||
stack.AddrPC.Offset = context.Rip;
|
stack.AddrPC.Offset = context.Rip;
|
||||||
stack.AddrPC.Mode = AddrModeFlat;
|
|
||||||
stack.AddrStack.Offset = context.Rsp;
|
stack.AddrStack.Offset = context.Rsp;
|
||||||
stack.AddrStack.Mode = AddrModeFlat;
|
|
||||||
stack.AddrFrame.Offset = context.Rbp;
|
stack.AddrFrame.Offset = context.Rbp;
|
||||||
|
#endif
|
||||||
|
stack.AddrPC.Mode = AddrModeFlat;
|
||||||
|
stack.AddrStack.Mode = AddrModeFlat;
|
||||||
stack.AddrFrame.Mode = AddrModeFlat;
|
stack.AddrFrame.Mode = AddrModeFlat;
|
||||||
|
|
||||||
std::wstringstream ss;
|
std::wstringstream ss;
|
||||||
ss << generalErrorDescription << std::endl;
|
ss << generalErrorDescription << std::endl;
|
||||||
for (ULONG frame = 0;; frame++)
|
for (ULONG frame = 0;; frame++)
|
||||||
{
|
{
|
||||||
auto result = StackWalk64(IMAGE_FILE_MACHINE_AMD64,
|
auto result = StackWalk64(
|
||||||
|
#ifdef _M_ARM64
|
||||||
|
IMAGE_FILE_MACHINE_ARM64,
|
||||||
|
#else
|
||||||
|
IMAGE_FILE_MACHINE_AMD64,
|
||||||
|
#endif
|
||||||
process,
|
process,
|
||||||
thread,
|
thread,
|
||||||
&stack,
|
&stack,
|
||||||
|
|||||||
Reference in New Issue
Block a user