Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2817 → Rev 2818

/branches/tracing/kernel/generic/include/udebug/udebug.h
100,7 → 100,7
*/
UDEBUG_M_THREAD_READ,
 
/** Read the list of the debugged tasks's memory.
/** Read the debugged tasks's memory.
*
* - ARG2 - destination address in the caller's address space
* - ARG3 - source address in the recipient's address space
107,8 → 107,18
* - ARG4 - size of receiving buffer in bytes
*
*/
UDEBUG_M_MEM_READ
UDEBUG_M_MEM_READ,
 
/** Write the debugged tasks's memory.
*
* - ARG2 - source address in the caller's address space
* - ARG3 - destination address in the recipient's address space
* - ARG4 - size of receiving buffer in bytes
*
*/
UDEBUG_M_MEM_WRITE
 
 
} udebug_method_t;
 
 
/branches/tracing/kernel/generic/src/udebug/udebug_ipc.c
276,6 → 276,34
return 1; /* actually need becksend with retval 0 */
}
 
static int udebug_rp_mem_write(call_t *call, phone_t *phone)
{
void *uspace_data;
unative_t to_copy;
int rc;
void *buffer;
 
klog_printf("udebug_rp_mem_write()");
// FIXME: verify task/thread state
 
uspace_data = (void *)IPC_GET_ARG2(call->data);
to_copy = IPC_GET_ARG4(call->data);
 
buffer = malloc(to_copy, 0); // ???
 
rc = copy_from_uspace(buffer, uspace_data, to_copy);
if (rc != 0) {
klog_printf(" - copy failed");
return rc;
}
 
call->buffer = buffer;
 
klog_printf(" - done");
return 1; /* actually need becksend with retval 0 */
}
 
 
int udebug_request_preprocess(call_t *call, phone_t *phone)
{
int rc;
298,6 → 326,8
return rc;
case UDEBUG_M_THREAD_READ:
rc = udebug_rp_thread_read(call, phone);
case UDEBUG_M_MEM_WRITE:
rc = udebug_rp_mem_write(call, phone);
return rc;
default:
break;
343,6 → 373,37
ipc_answer(&TASK->kernel_box, call);
}
 
static void udebug_receive_mem_write(call_t *call)
{
void *uspace_dst;
unsigned size;
void *buffer;
int rc;
 
klog_printf("udebug_receive_mem_write()");
uspace_dst = (void *)IPC_GET_ARG3(call->data);
size = IPC_GET_ARG4(call->data);
 
buffer = call->buffer;
klog_printf("dst=%u, size=%u", uspace_dst, size);
 
/* NOTE: this is not strictly from a syscall... but that shouldn't
* be a problem */
rc = copy_to_uspace(uspace_dst, buffer, size);
if (rc) {
IPC_SET_RETVAL(call->data, rc);
return;
}
 
IPC_SET_RETVAL(call->data, 0);
 
free(call->buffer);
call->buffer = NULL;
 
ipc_answer(&TASK->kernel_box, call);
}
 
 
/**
* Handle a debug call received on the kernel answerbox.
*
358,6 → 419,9
case UDEBUG_M_MEM_READ:
udebug_receive_mem_read(call);
break;
case UDEBUG_M_MEM_WRITE:
udebug_receive_mem_write(call);
break;
}
}