Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3015 → Rev 3016

/branches/tracing/kernel/generic/src/udebug/udebug_ops.c
137,14 → 137,11
 
klog_printf("udebug_begin()");
 
ipl = interrupts_disable();
mutex_lock(&TASK->udebug.lock);
klog_printf("debugging task %llu", TASK->taskid);
 
spinlock_lock(&TASK->lock);
 
if (TASK->udebug.dt_state != UDEBUG_TS_INACTIVE) {
spinlock_unlock(&TASK->lock);
interrupts_restore(ipl);
mutex_unlock(&TASK->udebug.lock);
klog_printf("udebug_begin(): busy error");
 
return EBUSY;
167,14 → 164,15
for (cur = TASK->th_head.next; cur != &TASK->th_head; cur = cur->next) {
t = list_get_instance(cur, thread_t, th_link);
 
ipl = interrupts_disable();
spinlock_lock(&t->debug_lock);
if ((t->flags & THREAD_FLAG_USPACE) != 0)
t->debug_active = true;
spinlock_unlock(&t->debug_lock);
interrupts_restore(ipl);
}
 
spinlock_unlock(&TASK->lock);
interrupts_restore(ipl);
mutex_unlock(&TASK->udebug.lock);
 
klog_printf("udebug_begin() done (%s)",
reply ? "reply" : "stoppability wait");
184,40 → 182,30
 
int udebug_end(void)
{
ipl_t ipl;
int rc;
 
klog_printf("udebug_end()");
 
ipl = interrupts_disable();
spinlock_lock(&TASK->lock);
mutex_lock(&TASK->udebug.lock);
klog_printf("task %llu", TASK->taskid);
 
rc = udebug_task_cleanup(TASK);
 
klog_printf("task %llu", TASK->taskid);
mutex_unlock(&TASK->udebug.lock);
 
spinlock_unlock(&TASK->lock);
interrupts_restore(ipl);
 
if (rc < 0) return EINVAL;
 
return 0;
return rc;
}
 
int udebug_set_evmask(udebug_evmask_t mask)
{
ipl_t ipl;
 
klog_printf("udebug_set_mask()");
 
ipl = interrupts_disable();
klog_printf("debugging task %llu", TASK->taskid);
 
spinlock_lock(&TASK->lock);
mutex_lock(&TASK->udebug.lock);
 
if (TASK->udebug.dt_state != UDEBUG_TS_ACTIVE) {
spinlock_unlock(&TASK->lock);
interrupts_restore(ipl);
mutex_unlock(&TASK->udebug.lock);
klog_printf("udebug_set_mask(): not active debuging session");
 
return EINVAL;
225,8 → 213,7
 
TASK->udebug.evmask = mask;
 
spinlock_unlock(&TASK->lock);
interrupts_restore(ipl);
mutex_unlock(&TASK->udebug.lock);
 
return 0;
}
269,6 → 256,7
int rc;
 
klog_printf("udebug_stop()");
mutex_lock(&TASK->udebug.lock);
 
ipl = interrupts_disable();
 
306,13 → 294,13
klog_printf("udebug_stop/ipc_answer");
 
THREAD->cur_event = UDEBUG_EVENT_STOP;
 
_thread_op_end(t);
interrupts_restore(ipl);
 
spinlock_lock(&TASK->lock);
ipc_answer(&TASK->answerbox, call);
spinlock_unlock(&TASK->lock);
mutex_unlock(&TASK->udebug.lock);
 
interrupts_restore(ipl);
klog_printf("udebog_stop/done");
return 0;
}
333,17 → 321,16
/* Allocate a buffer to hold thread IDs */
id_buffer = malloc(buf_size, 0);
 
ipl = interrupts_disable();
spinlock_lock(&TASK->lock);
mutex_lock(&TASK->udebug.lock);
 
/* Verify task state */
if (TASK->udebug.dt_state != UDEBUG_TS_ACTIVE) {
spinlock_unlock(&TASK->lock);
interrupts_restore(ipl);
 
mutex_unlock(&TASK->udebug.lock);
return EINVAL;
}
 
ipl = interrupts_disable();
spinlock_lock(&TASK->lock);
/* Copy down the thread IDs */
 
max_ids = buf_size / sizeof(unative_t);
370,6 → 357,8
spinlock_unlock(&TASK->lock);
interrupts_restore(ipl);
 
mutex_unlock(&TASK->udebug.lock);
 
*buffer = id_buffer;
*n = copied_ids * sizeof(unative_t);
 
492,17 → 481,25
void *data_buffer;
int rc;
 
klog_printf("udebug_mem_read()");
/* Verify task state */
mutex_lock(&TASK->udebug.lock);
 
if (TASK->udebug.dt_state != UDEBUG_TS_ACTIVE) {
mutex_unlock(&TASK->udebug.lock);
return EBUSY;
}
 
data_buffer = malloc(n, 0);
 
klog_printf("udebug_mem_read: src=%u, size=%u", uspace_addr, n);
// klog_printf("udebug_mem_read: src=%u, size=%u", uspace_addr, n);
 
/* NOTE: this is not strictly from a syscall... but that shouldn't
* be a problem */
rc = copy_from_uspace(data_buffer, (void *)uspace_addr, n);
if (rc) return rc;
mutex_unlock(&TASK->udebug.lock);
 
if (rc != 0) return rc;
 
*buffer = data_buffer;
return 0;
}
510,17 → 507,16
int udebug_mem_write(unative_t uspace_addr, void *data, size_t n)
{
int rc;
udebug_task_state_t dts;
 
klog_printf("udebug_mem_write()");
 
/* Verify task state */
spinlock_lock(&TASK->lock);
dts = TASK->udebug.dt_state;
spinlock_unlock(&TASK->lock);
mutex_lock(&TASK->udebug.lock);
 
if (dts != UDEBUG_TS_ACTIVE)
if (TASK->udebug.dt_state != UDEBUG_TS_ACTIVE) {
mutex_unlock(&TASK->udebug.lock);
return EBUSY;
}
klog_printf("dst=%u, size=%u", uspace_addr, n);
 
531,6 → 527,8
 
rc = as_debug_write(uspace_addr, data, n);
 
mutex_unlock(&TASK->udebug.lock);
 
return rc;
}