Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2840 → Rev 2841

/branches/tracing/kernel/generic/src/udebug/udebug_ipc.c
65,6 → 65,31
return ta;
}
 
static int verify_thread(thread_t *t)
{
/* Verify that 't' exists and belongs to task 'ta' */
if (!thread_exists(t) || (t->task != ta)) {
spinlock_unlock(&threads_lock);
interrupts_restore(ipl);
return ENOENT;
}
 
/* Verify that 't' is a userspace thread */
if ((t->flags & THREAD_FLAG_USPACE) == 0) {
/* It's not, deny its existence */
return ENOENT;
}
 
if ((t->debug_active != true) || (t->debug_stop != true)) {
/* Not in debugging session or already has GO */
spinlock_unlock(&threads_lock);
interrupts_restore(ipl);
return EBUSY;
}
 
return EOK;
}
 
static int udebug_rp_begin(call_t *call, phone_t *phone)
{
task_t *ta;
205,20 → 230,7
ipl = interrupts_disable();
spinlock_lock(&threads_lock);
 
/* Verify that 't' exists and belongs to task 'ta' */
if (!thread_exists(t) || (t->task != ta)) {
spinlock_unlock(&threads_lock);
interrupts_restore(ipl);
return ENOENT;
}
 
if ((t->debug_active != true) || (t->debug_stop != true)) {
/* Not in debugging session or already has GO */
spinlock_unlock(&threads_lock);
interrupts_restore(ipl);
return EBUSY;
}
 
t->debug_go_call = call;
t->debug_stop = false;
waitq_wakeup(&t->go_wq, WAKEUP_FIRST);
249,20 → 261,15
ipl = interrupts_disable();
spinlock_lock(&threads_lock);
 
/* Verify that 't' exists and belongs to task 'ta' */
if (!thread_exists(t) || (t->task != ta)) {
/* Verify that thread t exists and may be operated on */
rc = verify_thread(t);
if (rc != EOK) {
spinlock_unlock(&threads_lock);
interrupts_restore(ipl);
return ENOENT;
return rc;
}
 
//FIXME: additionally we need to verify that we are inside a syscall
if ((t->debug_active != true) || (t->debug_stop != true)) {
/* Not in debugging session or has GO */
spinlock_unlock(&threads_lock);
interrupts_restore(ipl);
return EBUSY;
}
 
/* Copy to a local buffer before releasing the lock */
memcpy(buffer, t->syscall_args, 6 * sizeof(unative_t));
307,20 → 314,14
 
t = (thread_t *) IPC_GET_ARG2(call->data);
 
/* Verify that 't' exists and belongs to task 'ta' */
if (!thread_exists(t) || (t->task != ta)) {
/* Verify that thread t exists and may be operated on */
rc = verify_thread(t);
if (rc != EOK) {
spinlock_unlock(&threads_lock);
interrupts_restore(ipl);
return ENOENT;
return rc;
}
 
if ((t->debug_active != true) || (t->debug_stop != true)) {
/* Not in debugging session or has GO */
spinlock_unlock(&threads_lock);
interrupts_restore(ipl);
return EBUSY;
}
 
state = t->uspace_state;
if (state == NULL) {
spinlock_unlock(&threads_lock);
388,20 → 389,14
 
t = (thread_t *) IPC_GET_ARG2(call->data);
 
/* Verify that 't' exists and belongs to task 'ta' */
if (!thread_exists(t) || (t->task != ta)) {
/* Verify that thread t exists and may be operated on */
rc = verify_thread(t);
if (rc != EOK) {
spinlock_unlock(&threads_lock);
interrupts_restore(ipl);
return ENOENT;
return rc;
}
 
if ((t->debug_active != true) || (t->debug_stop != true)) {
/* Not in debugging session or has GO */
spinlock_unlock(&threads_lock);
interrupts_restore(ipl);
return EBUSY;
}
 
state = t->uspace_state;
if (state == NULL) {
spinlock_unlock(&threads_lock);