Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2869 → Rev 2870

/branches/tracing/kernel/generic/src/udebug/udebug.c
10,6 → 10,7
#include <synch/waitq.h>
#include <console/klog.h>
#include <udebug/udebug.h>
#include <errno.h>
#include <arch.h>
 
void udebug_stoppable_begin(void)
169,6 → 170,79
waitq_sleep(&THREAD->go_wq);
}
 
/**
* Terminate task debugging session.
*
* \param ta Must be already locked and interrupts must be disabled.
* \return Zero on success or negative error code.
*/
int udebug_task_cleanup(struct task *ta)
{
thread_t *t;
link_t *cur;
int flags;
 
klog_printf("udebug_task_cleanup()");
klog_printf("task %llu", ta->taskid);
 
if (ta->dt_state == UDEBUG_TS_BEGINNING &&
ta->dt_state != UDEBUG_TS_ACTIVE) {
klog_printf("udebug_task_cleanup(): task not being debugged");
return EINVAL;
}
 
/* Finish debugging of all userspace threads */
for (cur = ta->th_head.next; cur != &ta->th_head; cur = cur->next) {
t = list_get_instance(cur, thread_t, th_link);
 
spinlock_lock(&t->debug_lock);
spinlock_lock(&t->lock);
 
flags = t->flags;
 
spinlock_unlock(&t->lock);
 
/* Only process userspace threads */
if ((flags & THREAD_FLAG_USPACE) != 0) {
/* Prevent any further debug activity in thread */
t->debug_active = false;
t->cur_event = 0; /* none */
 
/* Still has go? */
if (t->debug_stop == false) {
/*
* Yes, so clear go. As debug_active == false,
* this doesn't affect anything.
*/
t->debug_stop = true;
 
/* Answer GO call */
klog_printf("answer GO call with EVENT_FINISHED");
IPC_SET_RETVAL(t->debug_go_call->data, 0);
IPC_SET_ARG1(t->debug_go_call->data, UDEBUG_EVENT_FINISHED);
ipc_answer(&ta->answerbox, t->debug_go_call);
} else {
/*
* Debug_stop is already at initial value.
* Yet this means the thread needs waking up.
*/
 
/*
* t's lock must not be held when calling
* waitq_wakeup.
*/
waitq_wakeup(&t->go_wq, WAKEUP_FIRST);
}
}
spinlock_unlock(&t->debug_lock);
}
 
ta->dt_state = UDEBUG_TS_INACTIVE;
ta->debugger = NULL;
 
return 0;
}
 
 
/** @}
*/