Subversion Repositories HelenOS

Compare Revisions

Regard whitespace Rev 2835 → Rev 2834

/branches/tracing/kernel/generic/src/udebug/udebug_ipc.c
132,27 → 132,34
ta = get_lock_callee_task(phone);
klog_printf("task %llu", ta->taskid);
 
if (ta->dt_state == UDEBUG_TS_BEGINNING &&
ta->dt_state != UDEBUG_TS_ACTIVE) {
//TODO: UDEBUG_TS_BEGINNING
if (ta->dt_state != UDEBUG_TS_ACTIVE) {
spinlock_unlock(&ta->lock);
interrupts_restore(ipl);
klog_printf("udebug_rp_begin(): task not being debugged");
klog_printf("udebug_rp_begin(): task not in TS_BEGINNING");
return EINVAL;
}
 
/* Finish debugging of all userspace threads */
/* Clear debug_active from all of the task's userspace threads */
 
for (cur = ta->th_head.next; cur != &ta->th_head; cur = cur->next) {
t = list_get_instance(cur, thread_t, th_link);
 
spinlock_lock(&t->lock);
if ((t->flags & THREAD_FLAG_USPACE) != 0)
t->debug_active = true;
spinlock_unlock(&t->lock);
}
 
/* Only process userspace threads */
if ((t->flags & THREAD_FLAG_USPACE) != 0) {
/* Prevent any further debug activity in thread */
t->debug_active = false;
/* Now respond to unanswered GO calls and reset thread states */
for (cur = ta->th_head.next; cur != &ta->th_head; cur = cur->next) {
t = list_get_instance(cur, thread_t, th_link);
 
spinlock_lock(&t->lock);
 
/* Still has go? */
if (t->debug_stop == false) {
if ((t->flags & THREAD_FLAG_USPACE) != 0 &&
t->debug_stop == false) {
/*
* Yes, so clear go. As debug_active == false,
* this doesn't affect anything.
168,8 → 175,6
*/
waitq_wakeup(&t->go_wq, WAKEUP_FIRST);
}
}
 
spinlock_unlock(&t->lock);
}
 
/branches/tracing/uspace/app/sctrace/debug_api.c
7,7 → 7,6
#include <stdio.h>
#include <syscall.h>
#include <ipc/ipc.h>
#include <async.h>
#include <udebug.h>
 
#include "debug_api.h"
14,31 → 13,26
 
int debug_begin(unsigned phoneid)
{
return async_req_1_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_BEGIN);
return ipc_call_sync_1_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_BEGIN);
}
 
int debug_end(unsigned phoneid)
{
return async_req_1_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_END);
}
 
int debug_thread_read(unsigned phoneid, void *buffer, unsigned n,
unsigned *copied, unsigned *needed)
{
printf("send IPC_M_DEBUG_THREAD_READ message\n");
return async_req_3_2(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_THREAD_READ,
return ipc_call_sync_3_2(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_THREAD_READ,
(sysarg_t)buffer, n, copied, needed);
}
 
int debug_mem_read(unsigned phoneid, void *buffer, unsigned addr, unsigned n)
{
return async_req_4_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_MEM_READ,
return ipc_call_sync_4_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_MEM_READ,
(sysarg_t)buffer, addr, n);
}
 
int debug_args_read(unsigned phoneid, unsigned tid, unsigned *buffer)
{
return async_req_3_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_ARGS_READ,
return ipc_call_sync_3_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_ARGS_READ,
tid, (sysarg_t)buffer);
}
 
46,7 → 40,7
unsigned *sc_id, unsigned *sc_rc)
{
/* Run thread until a syscall is executed */
return async_req_2_3(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_GO,
return ipc_call_sync_2_3(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_GO,
tid, (sysarg_t)ev_type, (sysarg_t)sc_id, (sysarg_t)sc_rc);
}
 
/branches/tracing/uspace/app/sctrace/debug_api.h
8,7 → 8,6
#define DEBUG_API_H_
 
int debug_begin(unsigned phoneid);
int debug_end(unsigned phoneid);
int debug_thread_read(unsigned phoneid, void *buffer, unsigned n,
unsigned *copied, unsigned *needed);
int debug_mem_read(unsigned phoneid, void *buffer, unsigned addr, unsigned n);
/branches/tracing/uspace/app/sctrace/sctrace.c
8,8 → 8,7
#include <unistd.h>
#include <syscall.h>
#include <ipc/ipc.h>
#include <fibril.h>
#include <errno.h>
#include <udebug.h>
 
#include "syscalls.h"
#include "errors.h"
19,7 → 18,6
unsigned threadid_buf[TIDBUF_SIZE];
 
int phoneid;
int abort_trace;
 
int task_connect(int taskid)
{
116,22 → 114,6
}
}
 
int keyboard_fibril(void *arg)
{
(void)arg;
 
printf("keyboard fibril started\n");
 
getchar();
printf("keyboard fibril setting abort_trace\n");
abort_trace = 1;
printf("keyboard fibril sending debug_end()\n");
debug_end(phoneid);
printf("keyboard fibril exitting\n");
 
return EOK;
}
 
void trace_loop(void)
{
int rc;
141,18 → 123,8
unsigned sc_id;
int sc_rc;
int rv_type;
fid_t kb_fid;
 
abort_trace = 0;
kb_fid = fibril_create(keyboard_fibril, NULL);
if (kb_fid == 0) {
printf("Failed creating keyboard fibril\n");
return;
}
fibril_add_ready(kb_fid);
 
while (!abort_trace) {
 
while (1) {
/* Run thread until a syscall is executed */
rc = debug_go(phoneid, threadid_buf[0],
&ev_type, &sc_id, &sc_rc);
179,8 → 151,6
break;
}
}
 
printf("trace_loop() exiting\n");
}
 
 
211,14 → 181,7
}
 
trace_loop();
/*
printf("press 'd' to disconnect\n");
while ((i = getchar()) != 'd')
putchar(i);
 
printf("call debug_end()\n");
debug_end(phoneid);
*/
printf("done\n");
return;
}
225,10 → 188,8
 
int main(void)
{
while (1) {
trace_active_task();
}
}
 
/** @}
*/