48,13 → 48,13 |
/** |
* Prepare a thread for a debugging operation. |
* |
* Simply put, return thread t with t->debug_lock held, |
* Simply put, return thread t with t->udebug.lock held, |
* but only if it verifies all conditions. |
* |
* Specifically, verifies that thread t exists, is a userspace thread, |
* and belongs to the current task (TASK). Verifies, that the thread |
* has (or hasn't) go according to having_go (typically false). |
* It also locks t->debug_lock, making sure that t->debug_active is true |
* It also locks t->udebug.lock, making sure that t->udebug.debug_active is true |
* - that the thread is in a valid debugging session. |
* |
* Returns EOK if all went well, or an error code otherwise. |
77,7 → 77,7 |
return ENOENT; |
} |
|
spinlock_lock(&t->debug_lock); |
spinlock_lock(&t->udebug.lock); |
spinlock_lock(&t->lock); |
|
/* Now verify that it's the current task */ |
94,7 → 94,7 |
goto error_exit; |
} |
|
if ((t->debug_active != true) || (!t->debug_stop != having_go)) { |
if ((t->udebug.debug_active != true) || (!t->udebug.stop != having_go)) { |
/* Not in debugging session or undesired GO state */ |
rc = EINVAL; |
goto error_exit; |
103,7 → 103,7 |
spinlock_unlock(&threads_lock); |
spinlock_unlock(&t->lock); |
|
/* Only t->debug_lock left */ |
/* Only t->udebug.lock left */ |
|
return EOK; /* All went well */ |
|
111,7 → 111,7 |
/* Executed when a check on the thread fails */ |
error_exit: |
spinlock_unlock(&t->lock); |
spinlock_unlock(&t->debug_lock); |
spinlock_unlock(&t->udebug.lock); |
spinlock_unlock(&threads_lock); |
|
/* No locks left here */ |
121,7 → 121,7 |
|
static void _thread_op_end(thread_t *t) |
{ |
spinlock_unlock(&t->debug_lock); |
spinlock_unlock(&t->udebug.lock); |
} |
|
/** |
159,16 → 159,16 |
reply = 0; /* no reply */ |
} |
|
/* Set debug_active on all of the task's userspace threads */ |
/* Set udebug.debug_active on all of the task's userspace threads */ |
|
for (cur = TASK->th_head.next; cur != &TASK->th_head; cur = cur->next) { |
t = list_get_instance(cur, thread_t, th_link); |
|
ipl = interrupts_disable(); |
spinlock_lock(&t->debug_lock); |
spinlock_lock(&t->udebug.lock); |
if ((t->flags & THREAD_FLAG_USPACE) != 0) |
t->debug_active = true; |
spinlock_unlock(&t->debug_lock); |
t->udebug.debug_active = true; |
spinlock_unlock(&t->udebug.lock); |
interrupts_restore(ipl); |
} |
|
228,7 → 228,7 |
|
ipl = interrupts_disable(); |
|
/* On success, this will lock t->debug_lock */ |
/* On success, this will lock t->udebug.lock */ |
rc = _thread_op_begin(t, false); |
if (rc != EOK) { |
interrupts_restore(ipl); |
235,14 → 235,14 |
return rc; |
} |
|
t->debug_go_call = call; |
t->debug_stop = false; |
t->cur_event = 0; /* none */ |
t->udebug.go_call = call; |
t->udebug.stop = false; |
t->udebug.cur_event = 0; /* none */ |
|
/* |
* Neither t's lock nor threads_lock may be held during wakeup |
*/ |
waitq_wakeup(&t->go_wq, WAKEUP_FIRST); |
waitq_wakeup(&t->udebug.go_wq, WAKEUP_FIRST); |
|
_thread_op_end(t); |
interrupts_restore(ipl); |
261,7 → 261,7 |
ipl = interrupts_disable(); |
|
/* |
* On success, this will lock t->debug_lock. Note that this makes sure |
* On success, this will lock t->udebug.lock. Note that this makes sure |
* the thread is not stopped. |
*/ |
rc = _thread_op_begin(t, true); |
271,9 → 271,9 |
} |
|
/* Take GO away from the thread */ |
t->debug_stop = true; |
t->udebug.stop = true; |
|
if (!t->debug_stoppable) { |
if (!t->udebug.stoppable) { |
/* Answer will be sent when the thread becomes stoppable */ |
_thread_op_end(t); |
interrupts_restore(ipl); |
286,14 → 286,14 |
klog_printf("udebug_stop - answering go call"); |
|
/* Make sure nobody takes this call away from us */ |
call = t->debug_go_call; |
t->debug_go_call = NULL; |
call = t->udebug.go_call; |
t->udebug.go_call = NULL; |
|
IPC_SET_RETVAL(call->data, 0); |
IPC_SET_ARG1(call->data, UDEBUG_EVENT_STOP); |
klog_printf("udebug_stop/ipc_answer"); |
|
THREAD->cur_event = UDEBUG_EVENT_STOP; |
THREAD->udebug.cur_event = UDEBUG_EVENT_STOP; |
|
_thread_op_end(t); |
interrupts_restore(ipl); |
378,7 → 378,7 |
|
ipl = interrupts_disable(); |
|
/* On success, this will lock t->debug_lock */ |
/* On success, this will lock t->udebug.lock */ |
rc = _thread_op_begin(t, false); |
if (rc != EOK) { |
interrupts_restore(ipl); |
386,8 → 386,8 |
} |
|
/* Additionally we need to verify that we are inside a syscall */ |
if (t->cur_event != UDEBUG_EVENT_SYSCALL_B && |
t->cur_event != UDEBUG_EVENT_SYSCALL_E) { |
if (t->udebug.cur_event != UDEBUG_EVENT_SYSCALL_B && |
t->udebug.cur_event != UDEBUG_EVENT_SYSCALL_E) { |
_thread_op_end(t); |
interrupts_restore(ipl); |
|
395,7 → 395,7 |
} |
|
/* Copy to a local buffer before releasing the lock */ |
memcpy(arg_buffer, t->syscall_args, 6 * sizeof(unative_t)); |
memcpy(arg_buffer, t->udebug.syscall_args, 6 * sizeof(unative_t)); |
|
_thread_op_end(t); |
interrupts_restore(ipl); |
414,7 → 414,7 |
|
ipl = interrupts_disable(); |
|
/* On success, this will lock t->debug_lock */ |
/* On success, this will lock t->udebug.lock */ |
rc = _thread_op_begin(t, false); |
if (rc != EOK) { |
interrupts_restore(ipl); |
421,7 → 421,7 |
return rc; |
} |
|
state = t->uspace_state; |
state = t->udebug.uspace_state; |
if (state == NULL) { |
_thread_op_end(t); |
interrupts_restore(ipl); |
450,7 → 450,7 |
|
ipl = interrupts_disable(); |
|
/* On success, this will lock t->debug_lock */ |
/* On success, this will lock t->udebug.lock */ |
rc = _thread_op_begin(t, false); |
if (rc != EOK) { |
klog_printf("error locking thread"); |
458,7 → 458,7 |
return rc; |
} |
|
state = t->uspace_state; |
state = t->udebug.uspace_state; |
if (state == NULL) { |
_thread_op_end(t); |
interrupts_restore(ipl); |
467,7 → 467,7 |
return EBUSY; |
} |
|
memcpy(t->uspace_state, buffer, sizeof(istate_t)); |
memcpy(t->udebug.uspace_state, buffer, sizeof(istate_t)); |
|
_thread_op_end(t); |
interrupts_restore(ipl); |