diff --git a/core/os_shared.h b/core/os_shared.h index 5b828e66259..09aae11c53b 100644 --- a/core/os_shared.h +++ b/core/os_shared.h @@ -215,10 +215,10 @@ thread_set_mcontext(thread_record_t *tr, priv_mcontext_t *mc); /* Takes an os-specific context. Does not return. */ void -thread_set_self_context(void *cxt, bool is_detach_external); +thread_set_self_context(void *cxt); /* Only sets the priv_mcontext_t state. Does not return. */ void -thread_set_self_mcontext(priv_mcontext_t *mc, bool is_detach_external); +thread_set_self_mcontext(priv_mcontext_t *mc); /* Assumes target thread is suspended */ bool diff --git a/core/synch.c b/core/synch.c index 3af5add4afe..999c333b8a0 100644 --- a/core/synch.c +++ b/core/synch.c @@ -761,9 +761,9 @@ check_wait_at_safe_spot(dcontext_t *dcontext, thread_synch_permission_t cur_stat * being at the synch point vs in the cache. */ if (set_mcontext) - thread_set_self_mcontext((priv_mcontext_t *)cxt, false); + thread_set_self_mcontext((priv_mcontext_t *)cxt); else - thread_set_self_context((void *)cxt, false); + thread_set_self_context((void *)cxt); ASSERT_NOT_REACHED(); } } @@ -2435,6 +2435,6 @@ detach_externally_on_new_stack() LOG(GLOBAL, LOG_ALL, 1, "Detach: Entering final cleanup and unload\n"); SYSLOG_INTERNAL_INFO("Detaching from process, entering final cleanup"); detach_cleanup_helper(my_tr); - thread_set_self_mcontext(&my_mcontext, true); + thread_set_self_mcontext(&my_mcontext); } #endif diff --git a/core/unix/signal.c b/core/unix/signal.c index 04ba562ebcc..c6e5b8766df 100644 --- a/core/unix/signal.c +++ b/core/unix/signal.c @@ -3166,10 +3166,10 @@ translate_sigcontext(dcontext_t *dcontext, kernel_ucontext_t *uc, bool avoid_fai /* Takes an os-specific context */ void -thread_set_self_context(void *cxt, bool is_detach_external) +thread_set_self_context(void *cxt) { #ifdef X86 - if (!INTERNAL_OPTION(use_sigreturn_setcontext) || is_detach_external) { + if (!INTERNAL_OPTION(use_sigreturn_setcontext)) { sigcontext_t *sc = (sigcontext_t *)cxt; dr_jmp_buf_t buf; buf.xbx = sc->SC_XBX; @@ -3216,15 +3216,14 @@ thread_set_self_context(void *cxt, bool is_detach_external) #endif #ifdef LINUX # ifdef X86 - byte *xstate = get_and_initialize_xstate_buffer(dcontext); - frame.uc.uc_mcontext.fpstate = &((kernel_xstate_t *)xstate)->fpstate; + frame.uc.uc_mcontext.fpstate = sc->fpstate; # endif /* X86 */ frame.uc.uc_mcontext = *sc; #endif - IF_ARM(ASSERT_NOT_TESTED()); #if defined(X86) save_fpstate(dcontext, &frame); #endif + IF_ARM(ASSERT_NOT_TESTED()); /* The kernel calls do_sigaltstack on sys_rt_sigreturn primarily to ensure * the frame is ok, but the side effect is we can mess up our own altstack * settings if we're not careful. Having invalid ss_size looks good for @@ -3311,7 +3310,7 @@ thread_set_segment_registers(sigcontext_t *sc) /* Takes a priv_mcontext_t */ void -thread_set_self_mcontext(priv_mcontext_t *mc, bool is_detach_external) +thread_set_self_mcontext(priv_mcontext_t *mc) { kernel_ucontext_t ucxt; sig_full_cxt_t sc_full; @@ -3325,7 +3324,7 @@ thread_set_self_mcontext(priv_mcontext_t *mc, bool is_detach_external) IF_ARM( set_pc_mode_in_cpsr(sc_full.sc, dr_get_isa_mode(get_thread_private_dcontext()))); /* thread_set_self_context will fill in the real fp/simd state for x86 */ - thread_set_self_context((void *)sc_full.sc, is_detach_external); + thread_set_self_context((void *)sc_full.sc); ASSERT_NOT_REACHED(); } diff --git a/core/win32/os.c b/core/win32/os.c index 2f294643ef2..b5dc3b3793f 100644 --- a/core/win32/os.c +++ b/core/win32/os.c @@ -2795,7 +2795,7 @@ thread_attach_setup(priv_mcontext_t *mc) * sets the context back). */ mc->pc = data->continuation_pc; - thread_set_self_mcontext(mc, false); + thread_set_self_mcontext(mc); ASSERT_NOT_REACHED(); } /* Preclude double takeover if we become suspended while in ntdll */ @@ -5201,7 +5201,7 @@ thread_set_context(thread_record_t *tr, CONTEXT *context) /* Takes an os-specific context */ void -thread_set_self_context(void *cxt, bool is_detach_external) +thread_set_self_context(void *cxt) { /* We use NtContinue to avoid privilege issues with NtSetContext */ nt_continue((CONTEXT *)cxt); @@ -5210,7 +5210,7 @@ thread_set_self_context(void *cxt, bool is_detach_external) /* Takes a priv_mcontext_t */ void -thread_set_self_mcontext(priv_mcontext_t *mc, bool is_detach_external) +thread_set_self_mcontext(priv_mcontext_t *mc) { /* We can't use heap for our CONTEXT as we have no opportunity to free it. * We assume call paths can handle a large stack buffer as size something @@ -5232,7 +5232,7 @@ thread_set_self_mcontext(priv_mcontext_t *mc, bool is_detach_external) cxt = nt_initialize_context(buf, bufsz, cxt_flags); /* need ss and cs for setting my own context */ mcontext_to_context(cxt, mc, true /* set_cur_seg */); - thread_set_self_context(cxt, false); + thread_set_self_context(cxt); ASSERT_NOT_REACHED(); }