From 98afb15eaa8f8c31bf5763de0e3c83a845414b0a Mon Sep 17 00:00:00 2001 From: comex Date: Sat, 24 Jan 2015 21:59:37 -0500 Subject: ... --- lib/darwin/stop-other-threads.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/darwin/stop-other-threads.c') diff --git a/lib/darwin/stop-other-threads.c b/lib/darwin/stop-other-threads.c index dd00a2a..1975b47 100644 --- a/lib/darwin/stop-other-threads.c +++ b/lib/darwin/stop-other-threads.c @@ -48,10 +48,20 @@ static bool apply_one_pcp(mach_port_t thread, pcp = (uintptr_t *) &state.eip; #elif defined(__arm__) || defined(__arm64__) pcp = (uintptr_t *) &state.pc; +#endif + uintptr_t old = *pcp; +#ifdef __arm__ + /* thumb */ + if (state.cpsr & 0x20) + old |= 1; #endif uintptr_t new = callback(ctx, *pcp); - if (new != *pcp) { + if (new != old) { *pcp = new; +#ifdef __arm__ + *pcp &= ~1; + state.cpsr = (state.cpsr & ~0x20) | ((new & 1) * 0x20); +#endif kr = thread_set_state(thread, flavor, (thread_state_t) &state, real_cnt); if (kr) return false; -- cgit v1.2.3