1 /* 2 * Copyright (c) 2020, Microsoft Corporation. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef OS_CPU_WINDOWS_AARCH64_UNWIND_WINDOWS_AARCH64_HPP 26 #define OS_CPU_WINDOWS_AARCH64_UNWIND_WINDOWS_AARCH64_HPP 27 28 29 typedef unsigned char UBYTE; 30 31 #if _MSC_VER < 1700 32 33 /* Not needed for VS2012 compiler, comes from winnt.h. */ 34 #define UNW_FLAG_EHANDLER 0x01 35 #define UNW_FLAG_UHANDLER 0x02 36 #define UNW_FLAG_CHAININFO 0x04 37 38 #endif 39 40 // See https://docs.microsoft.com/en-us/cpp/build/arm64-exception-handling#xdata-records 41 typedef struct _UNWIND_INFO_EH_ONLY { 42 DWORD FunctionLength : 18; 43 DWORD Version : 2; 44 DWORD X : 1; // = 1 45 DWORD E : 1; // = 1 46 DWORD EpilogCount : 5; // = 0 47 DWORD CodeWords : 5; // = 1 48 DWORD UnwindCode0 : 8; 49 DWORD UnwindCode1 : 8; 50 DWORD UnwindCode2 : 8; 51 DWORD UnwindCode3 : 8; 52 DWORD ExceptionHandler; 53 } UNWIND_INFO_EH_ONLY, *PUNWIND_INFO_EH_ONLY; 54 55 /* 56 typedef struct _RUNTIME_FUNCTION { 57 DWORD BeginAddress; 58 union { 59 DWORD UnwindData; 60 struct { 61 DWORD Flag : 2; 62 DWORD FunctionLength : 11; 63 DWORD RegF : 3; 64 DWORD RegI : 4; 65 DWORD H : 1; 66 DWORD CR : 2; 67 DWORD FrameSize : 9; 68 } DUMMYSTRUCTNAME; 69 } DUMMYUNIONNAME; 70 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION; 71 */ 72 73 #if _MSC_VER < 1700 74 75 /* Not needed for VS2012 compiler, comes from winnt.h. */ 76 typedef struct _DISPATCHER_CONTEXT { 77 ULONG64 ControlPc; 78 ULONG64 ImageBase; 79 PRUNTIME_FUNCTION FunctionEntry; 80 ULONG64 EstablisherFrame; 81 ULONG64 TargetIp; 82 PCONTEXT ContextRecord; 83 // PEXCEPTION_ROUTINE LanguageHandler; 84 char * LanguageHandler; // double dependency problem 85 PVOID HandlerData; 86 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT; 87 88 #endif 89 90 #if _MSC_VER < 1500 91 92 /* Not needed for VS2008 compiler, comes from winnt.h. */ 93 typedef EXCEPTION_DISPOSITION (*PEXCEPTION_ROUTINE) ( 94 IN PEXCEPTION_RECORD ExceptionRecord, 95 IN ULONG64 EstablisherFrame, 96 IN OUT PCONTEXT ContextRecord, 97 IN OUT PDISPATCHER_CONTEXT DispatcherContext 98 ); 99 100 #endif 101 102 #endif // OS_CPU_WINDOWS_AARCH64_UNWIND_WINDOWS_AARCH64_HPP