From 98b90e73944dd9f2fb04cf2efec7a2e94351ef80 Mon Sep 17 00:00:00 2001 From: Justin Miller Date: Thu, 27 Oct 2022 08:14:10 -0700 Subject: [PATCH] [DBGHELP] Add ARM64 definitions into compat.h (#4810) This fixes ARM64 build in preparation for PR #4809. CORE-18200 --- dll/win32/dbghelp/compat.h | 143 ++++++++++++++++++++++++++++++++++++- 1 file changed, 142 insertions(+), 1 deletion(-) diff --git a/dll/win32/dbghelp/compat.h b/dll/win32/dbghelp/compat.h index f7bef66bc91..02e693f62a5 100644 --- a/dll/win32/dbghelp/compat.h +++ b/dll/win32/dbghelp/compat.h @@ -450,7 +450,7 @@ typedef struct _CONTEXT { DWORD64 LastExceptionFromRip; } CONTEXT; -#elif defined TARGET_arm /* ARM? */ +#elif defined TARGET_arm /* The following flags control the contents of the CONTEXT structure. */ @@ -549,6 +549,147 @@ typedef struct _CONTEXT { BOOLEAN CDECL RtlAddFunctionTable(RUNTIME_FUNCTION*,DWORD,DWORD); BOOLEAN CDECL RtlDeleteFunctionTable(RUNTIME_FUNCTION*); PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry(ULONG_PTR,DWORD*,UNWIND_HISTORY_TABLE*); + +#elif defined TARGET_arm64 + +#define CONTEXT_ARM64 0x00400000L +#define CONTEXT_CONTROL (CONTEXT_ARM64 | 0x1L) +#define CONTEXT_INTEGER (CONTEXT_ARM64 | 0x2L) +#define CONTEXT_FLOATING_POINT (CONTEXT_ARM64 | 0x4L) +#define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM64 | 0x8L) +#define CONTEXT_X18 (CONTEXT_ARM64 | 0x10L) +#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT) + +#define EXCEPTION_READ_FAULT 0 +#define EXCEPTION_WRITE_FAULT 1 +#define EXCEPTION_EXECUTE_FAULT 8 + +typedef union NEON128 { + struct { + ULONGLONG Low; + LONGLONG High; + } DUMMYSTRUCTNAME; + double D[2]; + float S[4]; + WORD H[8]; + BYTE B[16]; +} NEON128, *PNEON128; + +#define ARM64_MAX_BREAKPOINTS 8 +#define ARM64_MAX_WATCHPOINTS 2 + +typedef struct _CONTEXT { + + // + // Control flags. + // + + DWORD ContextFlags; + + // + // Integer registers + // + + DWORD Cpsr; + 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; + DWORD64 Fp; + DWORD64 Lr; + } DUMMYSTRUCTNAME; + DWORD64 X[31]; + } DUMMYUNIONNAME; + + DWORD64 Sp; + DWORD64 Pc; + + // + // Floating Point/NEON Registers + // + + NEON128 V[32]; + DWORD Fpcr; + DWORD Fpsr; + + // + // Debug registers + // + + DWORD Bcr[ARM64_MAX_BREAKPOINTS]; + DWORD64 Bvr[ARM64_MAX_BREAKPOINTS]; + DWORD Wcr[ARM64_MAX_WATCHPOINTS]; + DWORD64 Wvr[ARM64_MAX_WATCHPOINTS]; + +} _CONTEXT, *P_CONTEXT; +typedef _CONTEXT CONTEXT, *PCONTEXT; + +typedef struct _IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY { + DWORD BeginAddress; + union { + DWORD UnwindData; + struct { + DWORD Flag : 2; + DWORD FunctionLength : 11; + DWORD RegF : 3; + DWORD RegI : 4; + DWORD H : 1; + DWORD CR : 2; + DWORD FrameSize : 9; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; +} IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY, * PIMAGE_ARM64_RUNTIME_FUNCTION_ENTRY; +typedef struct _IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY RUNTIME_FUNCTION, *PRUNTIME_FUNCTION; + +#define UNWIND_HISTORY_TABLE_SIZE 12 + +typedef struct _UNWIND_HISTORY_TABLE_ENTRY { + ULONG_PTR ImageBase; + PRUNTIME_FUNCTION FunctionEntry; +} UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY; + +typedef struct _UNWIND_HISTORY_TABLE { + DWORD Count; + BYTE LocalHint; + BYTE GlobalHint; + BYTE Search; + BYTE Once; + ULONG_PTR LowAddress; + ULONG_PTR HighAddress; + UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE]; +} UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE; + +BOOLEAN CDECL RtlAddFunctionTable(RUNTIME_FUNCTION*,DWORD,DWORD); +BOOLEAN CDECL RtlDeleteFunctionTable(RUNTIME_FUNCTION*); +PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry(ULONG_PTR,DWORD*,UNWIND_HISTORY_TABLE*); + #else #error "Unknown target platform"