summaryrefslogtreecommitdiff
path: root/src/pal/src/exception/seh-unwind.cpp
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2015-07-24 10:02:44 -0700
committerJan Kotas <jkotas@microsoft.com>2015-07-24 10:02:44 -0700
commit2cf141dce5c3a22efd148e88f8a732835ee68336 (patch)
treed627cdb8f6a97cc0e8c1d39ae70c87259fa155ed /src/pal/src/exception/seh-unwind.cpp
parentacca43b33dcd97d1dc5d92147a3047a3bdfaf1ce (diff)
parentb4cf5255496130911498600d99717325f509eaf3 (diff)
downloadcoreclr-2cf141dce5c3a22efd148e88f8a732835ee68336.tar.gz
coreclr-2cf141dce5c3a22efd148e88f8a732835ee68336.tar.bz2
coreclr-2cf141dce5c3a22efd148e88f8a732835ee68336.zip
Merge pull request #1210 from benpye/linux-arm
CoreCLR building on ARM
Diffstat (limited to 'src/pal/src/exception/seh-unwind.cpp')
-rw-r--r--src/pal/src/exception/seh-unwind.cpp51
1 files changed, 42 insertions, 9 deletions
diff --git a/src/pal/src/exception/seh-unwind.cpp b/src/pal/src/exception/seh-unwind.cpp
index 2e77814b9b..9dd025c51d 100644
--- a/src/pal/src/exception/seh-unwind.cpp
+++ b/src/pal/src/exception/seh-unwind.cpp
@@ -49,10 +49,10 @@ Abstract:
ASSIGN_REG(R12) \
ASSIGN_REG(R13) \
ASSIGN_REG(R14) \
- ASSIGN_REG(R15)
-#else // _AMD64_
+ ASSIGN_REG(R15)
+#else
#error unsupported architecture
-#endif // _AMD64_
+#endif
static void WinContextToUnwindContext(CONTEXT *winContext, unw_context_t *unwContext)
{
@@ -72,8 +72,18 @@ static void WinContextToUnwindCursor(CONTEXT *winContext, unw_cursor_t *cursor)
unw_set_reg(cursor, UNW_X86_64_R13, winContext->R13);
unw_set_reg(cursor, UNW_X86_64_R14, winContext->R14);
unw_set_reg(cursor, UNW_X86_64_R15, winContext->R15);
-#else
-#error unsupported architecture
+#elif defined(_ARM_)
+ unw_set_reg(cursor, UNW_REG_IP, winContext->Pc);
+ unw_set_reg(cursor, UNW_REG_SP, winContext->Sp);
+ unw_set_reg(cursor, UNW_ARM_R14, winContext->Lr);
+ unw_set_reg(cursor, UNW_ARM_R4, winContext->R4);
+ unw_set_reg(cursor, UNW_ARM_R5, winContext->R5);
+ unw_set_reg(cursor, UNW_ARM_R6, winContext->R6);
+ unw_set_reg(cursor, UNW_ARM_R7, winContext->R7);
+ unw_set_reg(cursor, UNW_ARM_R8, winContext->R8);
+ unw_set_reg(cursor, UNW_ARM_R9, winContext->R9);
+ unw_set_reg(cursor, UNW_ARM_R10, winContext->R10);
+ unw_set_reg(cursor, UNW_ARM_R11, winContext->R11);
#endif
}
#endif
@@ -89,12 +99,24 @@ static void UnwindContextToWinContext(unw_cursor_t *cursor, CONTEXT *winContext)
unw_get_reg(cursor, UNW_X86_64_R13, (unw_word_t *) &winContext->R13);
unw_get_reg(cursor, UNW_X86_64_R14, (unw_word_t *) &winContext->R14);
unw_get_reg(cursor, UNW_X86_64_R15, (unw_word_t *) &winContext->R15);
+#elif defined(_ARM_)
+ unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Pc);
+ unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Sp);
+ unw_get_reg(cursor, UNW_ARM_R14, (unw_word_t *) &winContext->Lr);
+ unw_get_reg(cursor, UNW_ARM_R4, (unw_word_t *) &winContext->R4);
+ unw_get_reg(cursor, UNW_ARM_R5, (unw_word_t *) &winContext->R5);
+ unw_get_reg(cursor, UNW_ARM_R6, (unw_word_t *) &winContext->R6);
+ unw_get_reg(cursor, UNW_ARM_R7, (unw_word_t *) &winContext->R7);
+ unw_get_reg(cursor, UNW_ARM_R8, (unw_word_t *) &winContext->R8);
+ unw_get_reg(cursor, UNW_ARM_R9, (unw_word_t *) &winContext->R9);
+ unw_get_reg(cursor, UNW_ARM_R10, (unw_word_t *) &winContext->R10);
+ unw_get_reg(cursor, UNW_ARM_R11, (unw_word_t *) &winContext->R11);
#else
#error unsupported architecture
#endif
}
-static void GetContextPointer(unw_cursor_t *cursor, unw_context_t *unwContext, int reg, PDWORD64 *contextPointer)
+static void GetContextPointer(unw_cursor_t *cursor, unw_context_t *unwContext, int reg, SIZE_T **contextPointer)
{
#if defined(__APPLE__)
// Returning NULL indicates that we don't have context pointers available
@@ -104,10 +126,10 @@ static void GetContextPointer(unw_cursor_t *cursor, unw_context_t *unwContext, i
unw_get_save_loc(cursor, reg, &saveLoc);
if (saveLoc.type == UNW_SLT_MEMORY)
{
- PDWORD64 pLoc = (PDWORD64)saveLoc.u.addr;
+ SIZE_T *pLoc = (SIZE_T *)saveLoc.u.addr;
// Filter out fake save locations that point to unwContext
- if ((pLoc < (PDWORD64)unwContext) || ((PDWORD64)(unwContext + 1) <= pLoc))
- *contextPointer = (PDWORD64)saveLoc.u.addr;
+ if ((pLoc < (SIZE_T *)unwContext) || ((SIZE_T *)(unwContext + 1) <= pLoc))
+ *contextPointer = (SIZE_T *)saveLoc.u.addr;
}
#endif
}
@@ -121,6 +143,15 @@ static void GetContextPointers(unw_cursor_t *cursor, unw_context_t *unwContext,
GetContextPointer(cursor, unwContext, UNW_X86_64_R13, &contextPointers->R13);
GetContextPointer(cursor, unwContext, UNW_X86_64_R14, &contextPointers->R14);
GetContextPointer(cursor, unwContext, UNW_X86_64_R15, &contextPointers->R15);
+#elif defined(_ARM_)
+ GetContextPointer(cursor, unwContext, UNW_ARM_R4, &contextPointers->R4);
+ GetContextPointer(cursor, unwContext, UNW_ARM_R5, &contextPointers->R5);
+ GetContextPointer(cursor, unwContext, UNW_ARM_R6, &contextPointers->R6);
+ GetContextPointer(cursor, unwContext, UNW_ARM_R7, &contextPointers->R7);
+ GetContextPointer(cursor, unwContext, UNW_ARM_R8, &contextPointers->R8);
+ GetContextPointer(cursor, unwContext, UNW_ARM_R9, &contextPointers->R9);
+ GetContextPointer(cursor, unwContext, UNW_ARM_R10, &contextPointers->R10);
+ GetContextPointer(cursor, unwContext, UNW_ARM_R11, &contextPointers->R11);
#else
#error unsupported architecture
#endif
@@ -226,6 +257,8 @@ static void RtlpRaiseException(EXCEPTION_RECORD *ExceptionRecord)
ExceptionRecord->ExceptionAddress = (void *) ContextRecord.Eip;
#elif defined(_AMD64_)
ExceptionRecord->ExceptionAddress = (void *) ContextRecord.Rip;
+#elif defined(_ARM_)
+ ExceptionRecord->ExceptionAddress = (void *) ContextRecord.Pc;
#else
#error unsupported architecture
#endif