Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Vorlicek <janvorli@microsoft.com>2016-06-22 21:00:20 +0300
committerJan Kotas <jkotas@microsoft.com>2016-06-22 21:00:20 +0300
commitd8ba6a0def20c2ef44dbfa8a0f53eb0513043001 (patch)
treec9f66e680b0311765c4ff71db91511079d05416c /src/Native/Runtime/PalRedhawk.h
parent0603b782dc0ab509b4f8c7fa3da1e8923fc24958 (diff)
Implement Linux hardware and software exception handling (#1417)
This change implements code manager for Linux, context manipulation and compiler changes necessary to enable exception handling. All calls to libunwind are disabled for now on non-OSX though, since our build system doesn't support specifying additional dynamic libraries, which prevents us from using the libunwind. Those pieces of code are under CAN_LINK_SHARED_LIBUNWIND ifdef so that the ifdef can easily be located and removed after we add the necessary support to the build system. On OSX, the unwind functionality is part of the compiler support libraries, so it works. I have verified that everything works with the libunwind though by manually invoking clang to link everything together and adding the necessary libraries to its command line. The exception handling test was passing with that.
Diffstat (limited to 'src/Native/Runtime/PalRedhawk.h')
-rw-r--r--src/Native/Runtime/PalRedhawk.h34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/Native/Runtime/PalRedhawk.h b/src/Native/Runtime/PalRedhawk.h
index 7616d047d..4d5dd9bff 100644
--- a/src/Native/Runtime/PalRedhawk.h
+++ b/src/Native/Runtime/PalRedhawk.h
@@ -275,12 +275,19 @@ typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
UInt64 LastExceptionToRip;
UInt64 LastExceptionFromRip;
- void SetIP(UIntNative ip) { Rip = ip; }
- void SetSP(UIntNative sp) { Rsp = sp; }
+ void SetIp(UIntNative ip) { Rip = ip; }
+ void SetSp(UIntNative sp) { Rsp = sp; }
+#ifdef UNIX_AMD64_ABI
+ UIntNative GetArg0Reg() { return Rdi; }
+ UIntNative GetArg1Reg() { return Rsi; }
+ void SetArg0Reg(UIntNative val) { Rdi = val; }
+ void SetArg1Reg(UIntNative val) { Rsi = val; }
+#else // UNIX_AMD64_ABI
void SetArg0Reg(UIntNative val) { Rcx = val; }
void SetArg1Reg(UIntNative val) { Rdx = val; }
- UIntNative GetIP() { return Rip; }
- UIntNative GetSP() { return Rsp; }
+#endif // UNIX_AMD64_ABI
+ UIntNative GetIp() { return Rip; }
+ UIntNative GetSp() { return Rsp; }
} CONTEXT, *PCONTEXT;
#elif defined(_ARM_)
@@ -322,8 +329,8 @@ typedef struct DECLSPEC_ALIGN(8) _CONTEXT {
void SetIP(UIntNative ip) { Pc = ip; }
void SetArg0Reg(UIntNative val) { R0 = val; }
void SetArg1Reg(UIntNative val) { R1 = val; }
- UIntNative GetIP() { return Pc; }
- UIntNative GetLR() { return Lr; }
+ UIntNative GetIp() { return Pc; }
+ UIntNative GetLr() { return Lr; }
} CONTEXT, *PCONTEXT;
#elif defined(_X86_)
@@ -374,8 +381,8 @@ typedef struct _CONTEXT {
void SetSP(UIntNative sp) { Esp = sp; }
void SetArg0Reg(UIntNative val) { Ecx = val; }
void SetArg1Reg(UIntNative val) { Edx = val; }
- UIntNative GetIP() { return Eip; }
- UIntNative GetSP() { return Esp; }
+ UIntNative GetIp() { return Eip; }
+ UIntNative GetSp() { return Esp; }
} CONTEXT, *PCONTEXT;
#include "poppack.h"
@@ -455,8 +462,8 @@ typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
void SetIP(UIntNative ip) { Pc = ip; }
void SetArg0Reg(UIntNative val) { X0 = val; }
void SetArg1Reg(UIntNative val) { X1 = val; }
- UIntNative GetIP() { return Pc; }
- UIntNative GetLR() { return Lr; }
+ UIntNative GetIp() { return Pc; }
+ UIntNative GetLr() { return Lr; }
} CONTEXT, *PCONTEXT;
#endif
@@ -779,9 +786,16 @@ REDHAWK_PALIMPORT void REDHAWK_PALAPI PalTerminateCurrentProcess(UInt32 exitCode
REDHAWK_PALIMPORT HANDLE REDHAWK_PALAPI PalGetModuleHandleFromPointer(_In_ void* pointer);
#ifndef APP_LOCAL_RUNTIME
+
+#ifdef PLATFORM_UNIX
+REDHAWK_PALIMPORT void REDHAWK_PALAPI PalSetHardwareExceptionHandler(PHARDWARE_EXCEPTION_HANDLER handler);
+#else
REDHAWK_PALIMPORT void* REDHAWK_PALAPI PalAddVectoredExceptionHandler(UInt32 firstHandler, _In_ PVECTORED_EXCEPTION_HANDLER vectoredHandler);
#endif
+#endif
+
+
typedef UInt32 (__stdcall *BackgroundCallback)(_In_opt_ void* pCallbackContext);
REDHAWK_PALIMPORT bool REDHAWK_PALAPI PalStartBackgroundGCThread(_In_ BackgroundCallback callback, _In_opt_ void* pCallbackContext);
REDHAWK_PALIMPORT bool REDHAWK_PALAPI PalStartFinalizerThread(_In_ BackgroundCallback callback, _In_opt_ void* pCallbackContext);