Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3013 → Rev 3014

/branches/tracing/kernel/generic/src/udebug/udebug.c
41,6 → 41,14
#include <errno.h>
#include <arch.h>
 
void udebug_task_init(udebug_task_t *ut)
{
ut->dt_state = UDEBUG_TS_INACTIVE;
ut->begin_call = NULL;
ut->not_stoppable_count = 0;
ut->evmask = 0;
}
 
static void udebug_wait_for_go(waitq_t *wq)
{
int rc;
66,20 → 74,20
ipl = interrupts_disable();
spinlock_lock(&TASK->lock);
 
nsc = --TASK->not_stoppable_count;
nsc = --TASK->udebug.not_stoppable_count;
 
if (TASK->dt_state == UDEBUG_TS_BEGINNING) {
if (TASK->udebug.dt_state == UDEBUG_TS_BEGINNING) {
klog_printf("udebug_stoppable_begin");
klog_printf(" - nsc := %d", nsc);
}
 
if (TASK->dt_state == UDEBUG_TS_BEGINNING && nsc == 0) {
if (TASK->udebug.dt_state == UDEBUG_TS_BEGINNING && nsc == 0) {
/*
* This was the last non-stoppable thread. Reply to
* DEBUG_BEGIN call.
*/
 
db_call = TASK->debug_begin_call;
db_call = TASK->udebug.begin_call;
ASSERT(db_call);
 
/* Lock order OK, THREAD->debug_lock is after TASK->lock */
87,8 → 95,8
THREAD->debug_stoppable = true;
spinlock_unlock(&THREAD->debug_lock);
 
TASK->dt_state = UDEBUG_TS_ACTIVE;
TASK->debug_begin_call = NULL;
TASK->udebug.dt_state = UDEBUG_TS_ACTIVE;
TASK->udebug.begin_call = NULL;
spinlock_unlock(&TASK->lock);
interrupts_restore(ipl);
 
96,7 → 104,7
//klog_printf("udebug_stoppable_begin/ipc_answer");
ipc_answer(&TASK->answerbox, db_call);
 
} else if (TASK->dt_state == UDEBUG_TS_ACTIVE) {
} else if (TASK->udebug.dt_state == UDEBUG_TS_ACTIVE) {
/*
* Active debugging session
*/
159,7 → 167,7
/* Lock order OK, THREAD->debug_lock is after TASK->lock */
spinlock_lock(&THREAD->debug_lock);
 
if (TASK->dt_state == UDEBUG_TS_ACTIVE) {
if (TASK->udebug.dt_state == UDEBUG_TS_ACTIVE) {
//klog_printf("udebug_stoppable_end");
//klog_printf("debug_stop=%d", THREAD->debug_stop);
}
166,7 → 174,7
 
if (THREAD->debug_active &&
THREAD->debug_stop == true) {
TASK->debug_begin_call = NULL;
TASK->udebug.begin_call = NULL;
spinlock_unlock(&THREAD->debug_lock);
spinlock_unlock(&TASK->lock);
interrupts_restore(ipl);
176,7 → 184,7
goto restart;
/* must try again - have to lose stoppability atomically */
} else {
++TASK->not_stoppable_count;
++TASK->udebug.not_stoppable_count;
THREAD->debug_stoppable = false;
 
spinlock_unlock(&THREAD->debug_lock);
201,7 → 209,7
/* Must only generate events when in debugging session and have go */
if (THREAD->debug_active != true ||
THREAD->debug_stop == true ||
(TASK->debug_evmask & UDEBUG_EVMASK(etype)) == 0) {
(TASK->udebug.evmask & UDEBUG_EVMASK(etype)) == 0) {
spinlock_unlock(&THREAD->debug_lock);
interrupts_restore(ipl);
return;
340,7 → 348,7
/* Must only generate events when in debugging session and have go */
if (THREAD->debug_active != true ||
THREAD->debug_stop == true ||
(TASK->debug_evmask & UDEBUG_EVMASK(etype)) == 0) {
(TASK->udebug.evmask & UDEBUG_EVMASK(etype)) == 0) {
spinlock_unlock(&THREAD->debug_lock);
interrupts_restore(ipl);
return;
396,8 → 404,8
klog_printf("udebug_task_cleanup()");
klog_printf("task %llu", ta->taskid);
 
if (ta->dt_state == UDEBUG_TS_BEGINNING &&
ta->dt_state != UDEBUG_TS_ACTIVE) {
if (ta->udebug.dt_state == UDEBUG_TS_BEGINNING &&
ta->udebug.dt_state != UDEBUG_TS_ACTIVE) {
klog_printf("udebug_task_cleanup(): task not being debugged");
return EINVAL;
}
448,8 → 456,8
spinlock_unlock(&t->debug_lock);
}
 
ta->dt_state = UDEBUG_TS_INACTIVE;
ta->debugger = NULL;
ta->udebug.dt_state = UDEBUG_TS_INACTIVE;
ta->udebug.debugger = NULL;
 
return 0;
}