summaryrefslogtreecommitdiff
path: root/src/pal/src/exception/seh-unwind.cpp
diff options
context:
space:
mode:
authorJan Vorlicek <janvorli@microsoft.com>2015-04-08 13:15:32 +0200
committerJan Vorlicek <janvorli@microsoft.com>2015-04-08 13:15:32 +0200
commitdeb93573e834ce7c3e88ec8660e3a3da3be441af (patch)
treeecfb642a370c190b2912f714b60d3cf0e0f3bb35 /src/pal/src/exception/seh-unwind.cpp
parenta64519b1f982ad4179f3973e43af2389b700f3bd (diff)
downloadcoreclr-deb93573e834ce7c3e88ec8660e3a3da3be441af.tar.gz
coreclr-deb93573e834ce7c3e88ec8660e3a3da3be441af.tar.bz2
coreclr-deb93573e834ce7c3e88ec8660e3a3da3be441af.zip
Refactor context register access in seh-unwind.cpp
This change refactors the native context register access to use the MCREG_xxx macros so that it can compile on FreeBSD too.
Diffstat (limited to 'src/pal/src/exception/seh-unwind.cpp')
-rw-r--r--src/pal/src/exception/seh-unwind.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/pal/src/exception/seh-unwind.cpp b/src/pal/src/exception/seh-unwind.cpp
index 8d9a06b144..22742d1f5d 100644
--- a/src/pal/src/exception/seh-unwind.cpp
+++ b/src/pal/src/exception/seh-unwind.cpp
@@ -39,20 +39,26 @@ Abstract:
#if HAVE_LIBUNWIND_H
#if UNWIND_CONTEXT_IS_UCONTEXT_T
-static void WinContextToUnwindContext(CONTEXT *winContext, unw_context_t *unwContext)
-{
+
#if defined(_AMD64_)
- unwContext->uc_mcontext.gregs[REG_RIP] = winContext->Rip;
- unwContext->uc_mcontext.gregs[REG_RSP] = winContext->Rsp;
- unwContext->uc_mcontext.gregs[REG_RBP] = winContext->Rbp;
- unwContext->uc_mcontext.gregs[REG_RBX] = winContext->Rbx;
- unwContext->uc_mcontext.gregs[REG_R12] = winContext->R12;
- unwContext->uc_mcontext.gregs[REG_R13] = winContext->R13;
- unwContext->uc_mcontext.gregs[REG_R14] = winContext->R14;
- unwContext->uc_mcontext.gregs[REG_R15] = winContext->R15;
-#else
+#define ASSIGN_UNWIND_REGS \
+ ASSIGN_REG(Rip) \
+ ASSIGN_REG(Rsp) \
+ ASSIGN_REG(Rbp) \
+ ASSIGN_REG(Rbx) \
+ ASSIGN_REG(R12) \
+ ASSIGN_REG(R13) \
+ ASSIGN_REG(R14) \
+ ASSIGN_REG(R15)
+#else // _AMD64_
#error unsupported architecture
-#endif
+#endif // _AMD64_
+
+static void WinContextToUnwindContext(CONTEXT *winContext, unw_context_t *unwContext)
+{
+#define ASSIGN_REG(reg) MCREG_##reg(unwContext->uc_mcontext) = winContext->reg;
+ ASSIGN_UNWIND_REGS
+#undef ASSIGN_REG
}
#else
static void WinContextToUnwindCursor(CONTEXT *winContext, unw_cursor_t *cursor)