me(kern_return_t r)
{
int i;
-
+
if(r == 0)
return 0;
pthread_cond_init(&cond, nil);
first = 0;
}
-
+
if(!force){
for(i=0; i<nthr; i++)
if(thr[i].pid == pid)
{
if(id >= 0)
return addpid(id, 1);
-
+
id = -(id+1);
if(id >= nthr)
return nil;
idtopid(int id)
{
Thread *t;
-
+
if((t = idtotable(id)) == nil)
return -1;
return t->pid;
idtotask(int id)
{
Thread *t;
-
+
if((t = idtotable(id)) == nil)
return -1;
return t->task;
idtothread(int id)
{
Thread *t;
-
+
if((t = idtotable(id)) == nil)
return -1;
return t->thread;
Thread *t;
int i, n, pid;
int *out;
-
+
t = idtotable(id);
if(t == nil)
return -1;
pid = t->pid;
+ addpid(pid, 1); // force refresh of thread list
n = 0;
for(i=0; i<nthr; i++)
if(thr[i].pid == pid)
uintptr nn;
mach_port_t task;
int r;
-
+
task = idtotask(map->pid);
if(task == -1)
return -1;
werrstr("no such id");
return -1;
}
-
+
if((reg = go2darwin(addr)) < 0 || reg+n > sizeof u){
if(isr){
memset(v, 0, n);
werrstr("thread_set_state: %r");
return -1;
}
-
+
if(me(thread_resume(thread)) < 0){
werrstr("thread_resume: %r");
return -1;
(thread_state_t)®s,
x86_THREAD_STATE64_COUNT)) < 0)
return -1;
-
+
// Run.
n = sizeof info;
if(me(thread_info(t->thread, THREAD_BASIC_INFO, (thread_info_t)&info, &n)) < 0)
if(ncode > nelem(t->code))
ncode = nelem(t->code);
memmove(t->code, code, ncode*sizeof t->code[0]);
-
+
// Synchronize with waitstop below.
pthread_mutex_lock(&mu);
pthread_cond_broadcast(&cond);
pthread_mutex_unlock(&mu);
-
+
// Suspend thread, so that we can look at it & restart it later.
if(me(thread_suspend(thread)) < 0)
fprint(2, "catch_exception_raise thread_suspend: %r\n");
return -1;
return waitstop(t);
}
-
+
if(strcmp(msg, "waitstop") == 0)
return waitstop(t);
-
+
// sysstop not available on OS X
werrstr("unknown control message");
procstatus(int id)
{
Thread *t;
-
+
if((t = idtotable(id)) == nil)
return "gone!";
-
+
if(threadstopped(t))
return "Stopped";
-
+
return "Running";
}