diff options
author | comex | 2015-01-24 21:59:37 -0500 |
---|---|---|
committer | comex | 2015-01-24 21:59:37 -0500 |
commit | 98afb15eaa8f8c31bf5763de0e3c83a845414b0a (patch) | |
tree | e603aae961ead4e596fc994ed06df884eaee7b9a /lib/darwin/stop-other-threads.c | |
parent | Add function to deal with mprotecting RW and back. A bit more complex than t... (diff) | |
download | substitute-98afb15eaa8f8c31bf5763de0e3c83a845414b0a.tar.gz |
...
Diffstat (limited to 'lib/darwin/stop-other-threads.c')
-rw-r--r-- | lib/darwin/stop-other-threads.c | 12 |
1 files changed, 11 insertions, 1 deletions
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 @@ -49,9 +49,19 @@ static bool apply_one_pcp(mach_port_t thread, #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; |