summaryrefslogtreecommitdiff
path: root/src/pal
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal')
-rw-r--r--src/pal/src/exception/seh-unwind.cpp30
-rw-r--r--src/pal/src/exception/signal.cpp4
-rw-r--r--src/pal/src/include/pal/context.h22
3 files changed, 29 insertions, 27 deletions
diff --git a/src/pal/src/exception/seh-unwind.cpp b/src/pal/src/exception/seh-unwind.cpp
index 322515ad5e..c69c3e1504 100644
--- a/src/pal/src/exception/seh-unwind.cpp
+++ b/src/pal/src/exception/seh-unwind.cpp
@@ -209,28 +209,6 @@ static void GetContextPointers(unw_cursor_t *cursor, unw_context_t *unwContext,
#endif
}
-static DWORD64 GetPc(CONTEXT *context)
-{
-#if defined(_AMD64_)
- return context->Rip;
-#elif defined(_ARM64_) || defined(_ARM_)
- return context->Pc;
-#else
-#error don't know how to get the program counter for this architecture
-#endif
-}
-
-static void SetPc(CONTEXT *context, DWORD64 pc)
-{
-#if defined(_AMD64_)
- context->Rip = pc;
-#elif defined(_ARM64_) || defined(_ARM_)
- context->Pc = pc;
-#else
-#error don't know how to set the program counter for this architecture
-#endif
-}
-
BOOL PAL_VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextPointers)
{
int st;
@@ -250,7 +228,7 @@ BOOL PAL_VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextP
// So we compensate it by incrementing the PC before passing it to the unwinder.
// Without it, the unwinder would not find unwind info if the hardware exception
// happened in the first instruction of a function.
- SetPc(context, GetPc(context) + 1);
+ SetProgramCounterOnCONTEXT(context, GetProgramCounterFromCONTEXT(context) + 1);
}
#if UNWIND_CONTEXT_IS_UCONTEXT_T
@@ -282,7 +260,7 @@ BOOL PAL_VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextP
// The behaviour of libunwind from nongnu.org is to null the PC
// So we bank the original PC here, so we can compare it after
// the step
- curPc = GetPc(context);
+ curPc = GetProgramCounterFromCONTEXT(context);
#endif
st = unw_step(&cursor);
@@ -307,9 +285,9 @@ BOOL PAL_VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextP
//
UnwindContextToWinContext(&cursor, context);
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_ARM64_)
- if (st == 0 && GetPc(context) == curPc)
+ if (st == 0 && GetProgramCounterFromCONTEXT(context) == curPc)
{
- SetPc(context, 0);
+ SetProgramCounterOnCONTEXT(context, 0);
}
#endif
diff --git a/src/pal/src/exception/signal.cpp b/src/pal/src/exception/signal.cpp
index d11d5ffd2c..27fadc9b9d 100644
--- a/src/pal/src/exception/signal.cpp
+++ b/src/pal/src/exception/signal.cpp
@@ -101,6 +101,8 @@ int g_signalPipe[2] = { 0, 0 };
DWORD g_dwExternalSignalHandlerThreadId = 0;
+
+
/* public function definitions ************************************************/
/*++
@@ -594,7 +596,7 @@ static void inject_activation_handler(int code, siginfo_t *siginfo, void *contex
&winContext,
CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT);
- if (g_safeActivationCheckFunction(winContext.Rip))
+ if (g_safeActivationCheckFunction(GetProgramCounterFromCONTEXT(&winContext)))
{
g_activationFunction(&winContext);
}
diff --git a/src/pal/src/include/pal/context.h b/src/pal/src/include/pal/context.h
index 51dcedfcd2..e94c1a0ac1 100644
--- a/src/pal/src/include/pal/context.h
+++ b/src/pal/src/include/pal/context.h
@@ -336,6 +336,28 @@ typedef ucontext_t native_context_t;
#endif // HAVE_BSD_REGS_T
+inline static DWORD64 GetProgramCounterFromCONTEXT(LPCONTEXT pContext)
+{
+#if defined(_AMD64_)
+ return pContext->Rip;
+#elif defined(_ARM64_) || defined(_ARM_)
+ return pContext->Pc;
+#else
+#error don't know how to get the program counter for this architecture
+#endif
+}
+
+inline static void SetProgramCounterOnCONTEXT(LPCONTEXT pContext, DWORD64 pc)
+{
+#if defined(_AMD64_)
+ pContext->Rip = pc;
+#elif defined(_ARM64_) || defined(_ARM_)
+ pContext->Pc = pc;
+#else
+#error don't know how to set the program counter for this architecture
+#endif
+}
+
/*++
Function :
CONTEXT_CaptureContext