mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +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:
@@ -162,11 +162,18 @@ inline void LogStackTrace()
|
||||
|
||||
HANDLE process = GetCurrentProcess();
|
||||
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.Mode = AddrModeFlat;
|
||||
stack.AddrStack.Offset = context.Rsp;
|
||||
stack.AddrStack.Mode = AddrModeFlat;
|
||||
stack.AddrFrame.Offset = context.Rbp;
|
||||
#endif
|
||||
stack.AddrPC.Mode = AddrModeFlat;
|
||||
stack.AddrStack.Mode = AddrModeFlat;
|
||||
stack.AddrFrame.Mode = AddrModeFlat;
|
||||
|
||||
BOOL result = false;
|
||||
@@ -174,7 +181,11 @@ inline void LogStackTrace()
|
||||
for (;;)
|
||||
{
|
||||
result = StackWalk64(
|
||||
#ifdef _M_ARM64
|
||||
IMAGE_FILE_MACHINE_ARM64,
|
||||
#else
|
||||
IMAGE_FILE_MACHINE_AMD64,
|
||||
#endif
|
||||
process,
|
||||
thread,
|
||||
&stack,
|
||||
@@ -252,7 +263,7 @@ inline void InitSymbols()
|
||||
}
|
||||
}
|
||||
|
||||
inline void InitUnhandledExceptionHandler_x64(void)
|
||||
inline void InitUnhandledExceptionHandler(void)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <common/SettingsAPI/settings_helpers.h>
|
||||
#include <common/utils/ProcessWaiter.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/EventWaiter.h>
|
||||
|
||||
@@ -46,7 +46,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
||||
{
|
||||
winrt::init_apartment();
|
||||
LoggerHelpers::init_logger(ShortcutGuideConstants::ModuleKey, L"ShortcutGuide", LogSettings::shortcutGuideLoggerName);
|
||||
InitUnhandledExceptionHandler_x64();
|
||||
InitUnhandledExceptionHandler();
|
||||
Logger::trace("Starting Shortcut Guide");
|
||||
|
||||
if (!SetCurrentPath())
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <common/utils/ProcessWaiter.h>
|
||||
#include <common/utils/window.h>
|
||||
#include <common/utils/UnhandledExceptionHandler_x64.h>
|
||||
#include <common/utils/UnhandledExceptionHandler.h>
|
||||
|
||||
#include <common/utils/logger_helper.h>
|
||||
|
||||
@@ -18,7 +18,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
||||
{
|
||||
winrt::init_apartment();
|
||||
LoggerHelpers::init_logger(moduleName, internalPath, LogSettings::alwaysOnTopLoggerName);
|
||||
InitUnhandledExceptionHandler_x64();
|
||||
InitUnhandledExceptionHandler();
|
||||
|
||||
auto mutex = CreateMutex(nullptr, true, instanceMutexName.c_str());
|
||||
if (mutex == nullptr)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <common/display/dpi_aware.h>
|
||||
#include <common/utils/logger_helper.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/FancyZonesData.h>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <common/utils/ProcessWaiter.h>
|
||||
#include <common/utils/window.h>
|
||||
#include <common/utils/UnhandledExceptionHandler_x64.h>
|
||||
#include <common/utils/UnhandledExceptionHandler.h>
|
||||
|
||||
#include <FancyZonesLib/trace.h>
|
||||
#include <FancyZonesLib/Generated Files/resource.h>
|
||||
@@ -26,7 +26,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
||||
{
|
||||
winrt::init_apartment();
|
||||
LoggerHelpers::init_logger(moduleName, internalPath, LogSettings::fancyZonesLoggerName);
|
||||
InitUnhandledExceptionHandler_x64();
|
||||
InitUnhandledExceptionHandler();
|
||||
|
||||
auto mutex = CreateMutex(nullptr, true, instanceMutexName.c_str());
|
||||
if (mutex == nullptr)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <common/utils/winapi_error.h>
|
||||
#include <common/utils/logger_helper.h>
|
||||
#include <common/utils/ProcessWaiter.h>
|
||||
#include <common/utils/UnhandledExceptionHandler_x64.h>
|
||||
#include <common/utils/UnhandledExceptionHandler.h>
|
||||
|
||||
#include <trace.h>
|
||||
|
||||
@@ -28,7 +28,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
|
||||
LoggerHelpers::init_logger(KeyboardManagerConstants::ModuleName, L"Editor", LogSettings::keyboardManagerLoggerName);
|
||||
InitUnhandledExceptionHandler_x64();
|
||||
InitUnhandledExceptionHandler();
|
||||
Trace::RegisterProvider();
|
||||
|
||||
auto mutex = CreateMutex(nullptr, true, instanceMutexName.c_str());
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <common/utils/ProcessWaiter.h>
|
||||
#include <common/utils/winapi_error.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/KeyboardManagerEngineLibrary/KeyboardManager.h>
|
||||
#include <keyboardmanager/KeyboardManagerEngineLibrary/trace.h>
|
||||
@@ -15,7 +15,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
||||
winrt::init_apartment();
|
||||
LoggerHelpers::init_logger(KeyboardManagerConstants::ModuleName, L"Engine", LogSettings::keyboardManagerLoggerName);
|
||||
|
||||
InitUnhandledExceptionHandler_x64();
|
||||
InitUnhandledExceptionHandler();
|
||||
|
||||
auto mutex = CreateMutex(nullptr, true, instanceMutexName.c_str());
|
||||
if (mutex == nullptr)
|
||||
|
||||
@@ -82,18 +82,30 @@ void log_stack_trace(std::wstring& generalErrorDescription)
|
||||
auto thread = GetCurrentThread();
|
||||
STACKFRAME64 stack;
|
||||
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.Mode = AddrModeFlat;
|
||||
stack.AddrStack.Offset = context.Rsp;
|
||||
stack.AddrStack.Mode = AddrModeFlat;
|
||||
stack.AddrFrame.Offset = context.Rbp;
|
||||
#endif
|
||||
stack.AddrPC.Mode = AddrModeFlat;
|
||||
stack.AddrStack.Mode = AddrModeFlat;
|
||||
stack.AddrFrame.Mode = AddrModeFlat;
|
||||
|
||||
std::wstringstream ss;
|
||||
ss << generalErrorDescription << std::endl;
|
||||
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,
|
||||
thread,
|
||||
&stack,
|
||||
|
||||
Reference in New Issue
Block a user