/branches/tracing/kernel/generic/include/proc/task.h |
---|
96,11 → 96,7 |
atomic_t active_calls; |
/** Debugging stuff */ |
udebug_task_state_t dt_state; |
call_t *debug_begin_call; |
int not_stoppable_count; |
struct task *debugger; |
udebug_evmask_t debug_evmask; |
udebug_task_t udebug; |
/** Kernel answerbox */ |
answerbox_t kernel_box; |
/branches/tracing/kernel/generic/include/udebug/udebug.h |
---|
35,6 → 35,8 |
#ifndef KERN_UDEBUG_H_ |
#define KERN_UDEBUG_H_ |
#include <ipc/ipc.h> |
typedef enum { /* udebug_method_t */ |
/** Start debugging the recipient. |
184,9 → 186,21 |
UDEBUG_TS_SHUTDOWN |
} udebug_task_state_t; |
/** Debugging part of task_t structure. |
*/ |
typedef struct { |
udebug_task_state_t dt_state; |
call_t *begin_call; |
int not_stoppable_count; |
struct task *debugger; |
udebug_evmask_t evmask; |
} udebug_task_t; |
struct task; |
struct thread; |
void udebug_task_init(udebug_task_t *ut); |
void udebug_syscall_event(unative_t a1, unative_t a2, unative_t a3, |
unative_t a4, unative_t a5, unative_t a6, unative_t id, unative_t rc, |
bool end_variant); |
/branches/tracing/kernel/generic/src/proc/task.c |
---|
172,10 → 172,7 |
ta->cycles = 0; |
/* Init debugging stuff */ |
ta->dt_state = UDEBUG_TS_INACTIVE; |
ta->debug_begin_call = NULL; |
ta->not_stoppable_count = 0; |
ta->debug_evmask = 0; |
udebug_task_init(&ta->udebug); |
/* Init kbox stuff */ |
ipc_answerbox_init(&ta->kernel_box, ta); |
/branches/tracing/kernel/generic/src/ipc/ipc.c |
---|
730,7 → 730,7 |
klog_printf("kbox: handle hangup message"); |
/* Was it our debugger, who hung up? */ |
if (call->sender == TASK->debugger) { |
if (call->sender == TASK->udebug.debugger) { |
/* Terminate debugging session (if any) */ |
klog_printf("kbox: terminate debug session"); |
ipl = interrupts_disable(); |
/branches/tracing/kernel/generic/src/udebug/udebug_ipc.c |
---|
410,7 → 410,7 |
* and the sender can be safely considered valid until |
* control exits this function. |
*/ |
if (TASK->debugger != call->sender) { |
if (TASK->udebug.debugger != call->sender) { |
IPC_SET_RETVAL(call->data, EINVAL); |
ipc_answer(&TASK->kernel_box, call); |
return; |
/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; |
} |
/branches/tracing/kernel/generic/src/udebug/udebug_ops.c |
---|
142,7 → 142,7 |
spinlock_lock(&TASK->lock); |
if (TASK->dt_state != UDEBUG_TS_INACTIVE) { |
if (TASK->udebug.dt_state != UDEBUG_TS_INACTIVE) { |
spinlock_unlock(&TASK->lock); |
interrupts_restore(ipl); |
klog_printf("udebug_begin(): busy error"); |
150,13 → 150,13 |
return EBUSY; |
} |
TASK->dt_state = UDEBUG_TS_BEGINNING; |
TASK->debug_begin_call = call; |
TASK->debugger = call->sender; |
TASK->udebug.dt_state = UDEBUG_TS_BEGINNING; |
TASK->udebug.begin_call = call; |
TASK->udebug.debugger = call->sender; |
if (TASK->not_stoppable_count == 0) { |
TASK->dt_state = UDEBUG_TS_ACTIVE; |
TASK->debug_begin_call = NULL; |
if (TASK->udebug.not_stoppable_count == 0) { |
TASK->udebug.dt_state = UDEBUG_TS_ACTIVE; |
TASK->udebug.begin_call = NULL; |
reply = 1; /* immediate reply */ |
} else { |
reply = 0; /* no reply */ |
215,7 → 215,7 |
spinlock_lock(&TASK->lock); |
if (TASK->dt_state != UDEBUG_TS_ACTIVE) { |
if (TASK->udebug.dt_state != UDEBUG_TS_ACTIVE) { |
spinlock_unlock(&TASK->lock); |
interrupts_restore(ipl); |
klog_printf("udebug_set_mask(): not active debuging session"); |
223,7 → 223,7 |
return EINVAL; |
} |
TASK->debug_evmask = mask; |
TASK->udebug.evmask = mask; |
spinlock_unlock(&TASK->lock); |
interrupts_restore(ipl); |
337,7 → 337,7 |
spinlock_lock(&TASK->lock); |
/* Verify task state */ |
if (TASK->dt_state != UDEBUG_TS_ACTIVE) { |
if (TASK->udebug.dt_state != UDEBUG_TS_ACTIVE) { |
spinlock_unlock(&TASK->lock); |
interrupts_restore(ipl); |
516,7 → 516,7 |
/* Verify task state */ |
spinlock_lock(&TASK->lock); |
dts = TASK->dt_state; |
dts = TASK->udebug.dt_state; |
spinlock_unlock(&TASK->lock); |
if (dts != UDEBUG_TS_ACTIVE) |