summaryrefslogtreecommitdiff
path: root/src/pal
diff options
context:
space:
mode:
authorBen Pye <ben@curlybracket.co.uk>2015-12-05 17:05:29 +0000
committerBen Pye <ben@curlybracket.co.uk>2015-12-05 17:05:29 +0000
commitd37c575cb2be8c11aca3a5572ce7e05455dca93f (patch)
tree602f77399d73fce39ef7e3bf795ca273d329d65f /src/pal
parent18deaf9691626f01f60cf32706a064b6d1fda21c (diff)
downloadcoreclr-d37c575cb2be8c11aca3a5572ce7e05455dca93f.tar.gz
coreclr-d37c575cb2be8c11aca3a5572ce7e05455dca93f.tar.bz2
coreclr-d37c575cb2be8c11aca3a5572ce7e05455dca93f.zip
Remove usage of getcontext
Diffstat (limited to 'src/pal')
-rw-r--r--src/pal/src/config.h.in2
-rw-r--r--src/pal/src/configure.cmake2
-rw-r--r--src/pal/src/thread/context.cpp56
3 files changed, 10 insertions, 50 deletions
diff --git a/src/pal/src/config.h.in b/src/pal/src/config.h.in
index f3274076e8..143679d5a7 100644
--- a/src/pal/src/config.h.in
+++ b/src/pal/src/config.h.in
@@ -28,8 +28,6 @@
#cmakedefine01 HAVE_PTHREAD_SIGQUEUE
#cmakedefine01 HAVE_SIGRETURN
#cmakedefine01 HAVE__THREAD_SYS_SIGRETURN
-#cmakedefine01 HAVE_SETCONTEXT
-#cmakedefine01 HAVE_GETCONTEXT
#cmakedefine01 HAVE_COPYSIGN
#cmakedefine01 HAVE_FSYNC
#cmakedefine01 HAVE_FUTIMES
diff --git a/src/pal/src/configure.cmake b/src/pal/src/configure.cmake
index 4b09fc0492..333f0094c5 100644
--- a/src/pal/src/configure.cmake
+++ b/src/pal/src/configure.cmake
@@ -43,8 +43,6 @@ check_library_exists(pthread pthread_getattr_np "" HAVE_PTHREAD_GETATTR_NP)
check_library_exists(pthread pthread_sigqueue "" HAVE_PTHREAD_SIGQUEUE)
check_function_exists(sigreturn HAVE_SIGRETURN)
check_function_exists(_thread_sys_sigreturn HAVE__THREAD_SYS_SIGRETURN)
-check_function_exists(setcontext HAVE_SETCONTEXT)
-check_function_exists(getcontext HAVE_GETCONTEXT)
check_function_exists(copysign HAVE_COPYSIGN)
check_function_exists(fsync HAVE_FSYNC)
check_function_exists(futimes HAVE_FUTIMES)
diff --git a/src/pal/src/thread/context.cpp b/src/pal/src/thread/context.cpp
index f945c427e4..ebd4383a71 100644
--- a/src/pal/src/thread/context.cpp
+++ b/src/pal/src/thread/context.cpp
@@ -173,11 +173,11 @@ Abstract
Parameter
processId: process ID
- registers: reg structure in which the machine registers value will be returned.
+ lpContext: context structure in which the machine registers value will be returned.
Return
returns TRUE if it succeeds, FALSE otherwise
--*/
-BOOL CONTEXT_GetRegisters(DWORD processId, ucontext_t *registers)
+BOOL CONTEXT_GetRegisters(DWORD processId, LPCONTEXT lpContext)
{
#if HAVE_BSD_REGS_T
int regFd = -1;
@@ -186,46 +186,11 @@ BOOL CONTEXT_GetRegisters(DWORD processId, ucontext_t *registers)
if (processId == GetCurrentProcessId())
{
-#if HAVE_GETCONTEXT
- if (getcontext(registers) != 0)
- {
- ASSERT("getcontext() failed %d (%s)\n", errno, strerror(errno));
- return FALSE;
- }
-#elif HAVE_BSD_REGS_T
- char buf[MAX_PATH];
- struct reg bsd_registers;
-
- sprintf_s(buf, sizeof(buf), "/proc/%d/regs", processId);
-
- if ((regFd = PAL__open(buf, O_RDONLY)) == -1)
- {
- ASSERT("PAL__open() failed %d (%s) \n", errno, strerror(errno));
- return FALSE;
- }
-
- if (lseek(regFd, 0, 0) == -1)
- {
- ASSERT("lseek() failed %d (%s)\n", errno, strerror(errno));
- goto EXIT;
- }
-
- if (read(regFd, &bsd_registers, sizeof(bsd_registers)) != sizeof(bsd_registers))
- {
- ASSERT("read() failed %d (%s)\n", errno, strerror(errno));
- goto EXIT;
- }
-
-#define ASSIGN_REG(reg) MCREG_##reg(registers->uc_mcontext) = BSDREG_##reg(bsd_registers);
- ASSIGN_ALL_REGS
-#undef ASSIGN_REG
-
-#else
-#error "Don't know how to get current context on this platform!"
-#endif
+ CONTEXT_CaptureContext(lpContext);
}
else
{
+ ucontext_t registers;
#if HAVE_PT_REGS
struct pt_regs ptrace_registers;
if (ptrace((__ptrace_request)PT_GETREGS, processId, (caddr_t) &ptrace_registers, 0) == -1)
@@ -239,9 +204,9 @@ BOOL CONTEXT_GetRegisters(DWORD processId, ucontext_t *registers)
}
#if HAVE_PT_REGS
-#define ASSIGN_REG(reg) MCREG_##reg(registers->uc_mcontext) = PTREG_##reg(ptrace_registers);
+#define ASSIGN_REG(reg) MCREG_##reg(registers.uc_mcontext) = PTREG_##reg(ptrace_registers);
#elif HAVE_BSD_REGS_T
-#define ASSIGN_REG(reg) MCREG_##reg(registers->uc_mcontext) = BSDREG_##reg(ptrace_registers);
+#define ASSIGN_REG(reg) MCREG_##reg(registers.uc_mcontext) = BSDREG_##reg(ptrace_registers);
#else
#define ASSIGN_REG(reg)
ASSERT("Don't know how to get the context of another process on this platform!");
@@ -249,6 +214,8 @@ BOOL CONTEXT_GetRegisters(DWORD processId, ucontext_t *registers)
#endif
ASSIGN_ALL_REGS
#undef ASSIGN_REG
+
+ CONTEXTFromNativeContext(&registers, lpContext, lpContext->ContextFlags);
}
bRet = TRUE;
@@ -275,7 +242,6 @@ CONTEXT_GetThreadContext(
LPCONTEXT lpContext)
{
BOOL ret = FALSE;
- ucontext_t registers;
if (lpContext == NULL)
{
@@ -317,13 +283,11 @@ CONTEXT_GetThreadContext(
if (lpContext->ContextFlags &
(CONTEXT_CONTROL | CONTEXT_INTEGER))
{
- if (CONTEXT_GetRegisters(dwProcessId, &registers) == FALSE)
+ if (CONTEXT_GetRegisters(dwProcessId, lpContext) == FALSE)
{
SetLastError(ERROR_INTERNAL_ERROR);
goto EXIT;
- }
-
- CONTEXTFromNativeContext(&registers, lpContext, lpContext->ContextFlags);
+ }
}
ret = TRUE;