/branches/tracing/kernel/generic/include/proc/task.h |
---|
52,6 → 52,7 |
#include <arch/cpu.h> |
#include <mm/tlb.h> |
#include <proc/scheduler.h> |
#include <udebug/udebug.h> |
struct thread; |
95,8 → 96,7 |
atomic_t active_calls; |
/** Debugging stuff */ |
bool being_debugged; |
bool stop_request; |
udebug_task_state_t dt_state; |
call_t *debug_begin_call; |
call_t *debug_go_call; |
int not_stoppable_count; |
/branches/tracing/kernel/generic/include/proc/thread.h |
---|
208,6 → 208,7 |
waitq_t go_wq; |
unative_t syscall_args[6]; |
istate_t *uspace_state; |
bool debug_stop; |
} thread_t; |
/** Thread list lock. |
/branches/tracing/kernel/generic/include/udebug/udebug.h |
---|
128,6 → 128,17 |
#ifdef KERNEL |
typedef enum { |
/** Task is not being debugged */ |
UDEBUG_TS_INACTIVE, |
/** BEGIN operation in progress (waiting for threads to stop) */ |
UDEBUG_TS_BEGINNING, |
/** Debugger fully connected */ |
UDEBUG_TS_ACTIVE, |
/** Task is shutting down, no more debug activities allowed */ |
UDEBUG_TS_SHUTDOWN |
} udebug_task_state_t; |
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); |
void udebug_stoppable_begin(void); |
/branches/tracing/kernel/generic/src/proc/task.c |
---|
171,8 → 171,8 |
ta->capabilities = 0; |
ta->cycles = 0; |
ta->being_debugged = false; |
ta->stop_request = false; |
/* Init debugging stuff */ |
ta->dt_state = UDEBUG_TS_INACTIVE; |
ta->debug_begin_call = NULL; |
ta->debug_go_call = NULL; |
ta->not_stoppable_count = 0; |
/branches/tracing/kernel/generic/src/proc/thread.c |
---|
345,6 → 345,7 |
/* Init debugging stuff */ |
waitq_initialize(&t->go_wq); |
t->uspace_state = NULL; |
t->debug_stop = true; |
/* might depend on previous initialization */ |
thread_create_arch(t); |
/branches/tracing/kernel/generic/src/udebug/udebug_ipc.c |
---|
76,7 → 76,7 |
ta = get_lock_callee_task(phone); |
klog_printf("debugging task %llu", ta->taskid); |
if (ta->being_debugged != false) { |
if (ta->dt_state != UDEBUG_TS_INACTIVE) { |
spinlock_unlock(&ta->lock); |
interrupts_restore(ipl); |
klog_printf("debug_begin(): busy error"); |
83,13 → 83,12 |
return EBUSY; |
} |
ta->being_debugged = true; |
ta->stop_request = true; |
ta->dt_state = UDEBUG_TS_BEGINNING; |
ta->debug_begin_call = call; |
if (ta->not_stoppable_count == 0) { |
ta->dt_state = UDEBUG_TS_ACTIVE; |
ta->debug_begin_call = NULL; |
ta->stop_request = false; |
spinlock_unlock(&ta->lock); |
interrupts_restore(ipl); |
klog_printf("debug_begin(): immediate backsend"); |
120,6 → 119,7 |
ipl = interrupts_disable(); |
spinlock_lock(&threads_lock); |
if (!thread_exists(t)) { |
spinlock_unlock(&threads_lock); |
interrupts_restore(ipl); |
126,7 → 126,9 |
return ENOENT; |
} |
t->debug_stop = false; |
waitq_wakeup(&t->go_wq, WAKEUP_FIRST); |
spinlock_unlock(&threads_lock); |
interrupts_restore(ipl); |
/branches/tracing/kernel/generic/src/udebug/udebug.c |
---|
24,13 → 24,13 |
nsc = --TASK->not_stoppable_count; |
db_call = TASK->debug_begin_call; |
if (TASK->stop_request == true) { |
if (TASK->dt_state == UDEBUG_TS_BEGINNING) { |
klog_printf("udebug_stoppable_begin"); |
klog_printf(" - nsc := %d", nsc); |
} |
if (TASK->stop_request == true && nsc == 0) { |
TASK->stop_request = false; |
if (TASK->dt_state == UDEBUG_TS_BEGINNING && nsc == 0) { |
TASK->dt_state = UDEBUG_TS_ACTIVE; |
TASK->debug_begin_call = NULL; |
spinlock_unlock(&TASK->lock); |
interrupts_restore(ipl); |
52,7 → 52,9 |
ipl = interrupts_disable(); |
spinlock_lock(&TASK->lock); |
if (TASK->stop_request) { |
if ((TASK->dt_state == UDEBUG_TS_BEGINNING || |
TASK->dt_state == UDEBUG_TS_ACTIVE) && |
THREAD->debug_stop == true) { |
TASK->debug_begin_call = NULL; |
spinlock_unlock(&TASK->lock); |
interrupts_restore(ipl); |
77,8 → 79,7 |
ipl = interrupts_disable(); |
spinlock_lock(&TASK->lock); |
/* being debugged + have go */ |
if (TASK->being_debugged && !TASK->stop_request) { |
if (TASK->dt_state == UDEBUG_TS_ACTIVE) { |
klog_printf("udebug_syscall_event"); |
call = TASK->debug_go_call; |
IPC_SET_RETVAL(call->data, 0); |
94,6 → 95,13 |
THREAD->syscall_args[4] = a5; |
THREAD->syscall_args[5] = a6; |
/* |
* Make sure debug_stop is true when going to sleep |
* in case we get woken up by DEBUG_END. (At which |
* point it must be back to the initial true value). |
*/ |
THREAD->debug_stop = true; |
ipc_answer(&TASK->answerbox, TASK->debug_go_call); |
spinlock_unlock(&TASK->lock); |
interrupts_restore(ipl); |