Continue thread properly taking into account suspend_count
This commit is contained in:
parent
0660fcc09b
commit
11405314d8
@ -74,8 +74,22 @@ single_step(thread_act_t thread) {
|
|||||||
kret = thread_set_state(thread, x86_THREAD_STATE64, (thread_state_t)®s, count);
|
kret = thread_set_state(thread, x86_THREAD_STATE64, (thread_state_t)®s, count);
|
||||||
if (kret != KERN_SUCCESS) return kret;
|
if (kret != KERN_SUCCESS) return kret;
|
||||||
|
|
||||||
// Continue here until we've fully decremented suspend_count
|
kret = resume_thread(thread);
|
||||||
for (;;) {
|
if (kret != KERN_SUCCESS) return kret;
|
||||||
|
|
||||||
|
return KERN_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
kern_return_t
|
||||||
|
resume_thread(thread_act_t thread) {
|
||||||
|
kern_return_t kret;
|
||||||
|
struct thread_basic_info info;
|
||||||
|
unsigned int info_count = THREAD_BASIC_INFO_COUNT;
|
||||||
|
|
||||||
|
kret = thread_info((thread_t)thread, THREAD_BASIC_INFO, (thread_info_t)&info, &info_count);
|
||||||
|
if (kret != KERN_SUCCESS) return kret;
|
||||||
|
|
||||||
|
for (int i = 0; i < info.suspend_count; i++) {
|
||||||
kret = thread_resume(thread);
|
kret = thread_resume(thread);
|
||||||
if (kret != KERN_SUCCESS) break;
|
if (kret != KERN_SUCCESS) break;
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,9 @@ func (t *ThreadContext) resume() error {
|
|||||||
if PtraceCont(t.Process.Pid, 0) == nil {
|
if PtraceCont(t.Process.Pid, 0) == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
for {
|
kret := C.resume_thread(t.os.thread_act)
|
||||||
if C.thread_resume(t.os.thread_act) != C.KERN_SUCCESS {
|
if kret != C.KERN_SUCCESS {
|
||||||
break
|
return fmt.Errorf("could not continue thread")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -19,4 +19,7 @@ kern_return_t
|
|||||||
single_step(thread_act_t);
|
single_step(thread_act_t);
|
||||||
|
|
||||||
kern_return_t
|
kern_return_t
|
||||||
clear_trap_flag(thread_act_t thread);
|
clear_trap_flag(thread_act_t);
|
||||||
|
|
||||||
|
kern_return_t
|
||||||
|
resume_thread(thread_act_t);
|
||||||
|
Loading…
Reference in New Issue
Block a user