/branches/tracing/uspace/app/tester/tester.c |
---|
57,6 → 57,7 |
#include "ipc/hangup.def" |
#include "devmap/devmap1.def" |
#include "vfs/vfs1.def" |
#include "tdebug/tdebug1.def" |
{NULL, NULL, NULL} |
}; |
79,9 → 80,10 |
static void run_safe_tests(void) |
{ |
test_t *test; |
int i = 0, n = 0; |
unsigned int i = 0; |
unsigned int n = 0; |
printf("\n*** Running all safe tests\n\n"); |
printf("\n*** Running all safe tests ***\n\n"); |
for (test = tests; test->name != NULL; test++) { |
if (test->safe) { |
92,7 → 94,7 |
} |
} |
printf("\nSafe tests completed, %d tests run, %d passed.\n\n", i + n, i); |
printf("\nSafe tests completed, %u tests run, %u passed.\n\n", i + n, i); |
} |
static void list_tests(void) |
/branches/tracing/uspace/app/tester/tdebug/tdebug1.def |
---|
0,0 → 1,6 |
{ |
"tdebug1", |
"Tdebug interface test", |
&test_tdebug1, |
true |
}, |
/branches/tracing/uspace/app/tester/tdebug/tdebug1.c |
---|
0,0 → 1,147 |
#include <stdio.h> |
#include <unistd.h> |
#include <task.h> |
#include <tdebug.h> |
#include <async.h> |
#include <sys/types.h> |
#include <time.h> |
#include "../tester.h" |
static char *syscall_name[] = { |
"sys_io", |
"sys_tls_set", |
"sys_thread_create", |
"sys_thread_exit", |
"sys_thread_get_id", |
"sys_task_get_id", |
"sys_futex_sleep_timeout", |
"sys_futex_wakeup", |
"sys_as_area_create", |
"sys_as_area_resize", |
"sys_as_area_destroy", |
"sys_ipc_call_sync_fast", |
"sys_ipc_call_sync_slow", |
"sys_ipc_call_async_fast", |
"sys_ipc_call_async_slow", |
"sys_ipc_answer_fast", |
"sys_ipc_answer_slow", |
"sys_ipc_forward_fast", |
"sys_ipc_wait_for_call", |
"sys_ipc_hangup", |
"sys_ipc_register_irq", |
"sys_ipc_unregister_irq", |
"sys_cap_grant", |
"sys_cap_revoke", |
"sys_physmem_map", |
"sys_iospace_enable", |
"sys_preempt_control", |
"sys_sysinfo_valid", |
"sys_sysinfo_value", |
"sys_debug_enable_console", |
"sys_tdebug_attach_task", |
"sys_tdebug_continue_thread", |
"sys_tdebug_get_syscall_args" |
"sys_tdebug_set_event_mask", |
"sys_tdebug_stop_thread", |
"sys_tdebug_stop_task" |
}; |
static void event_syscall(thread_id_t tid, sysarg_t syscall_id, sysarg_t rc) |
{ |
sysarg_t sc_args[6]; |
size_t buf_len; |
int res; |
buf_len = 6; |
res = tdebug_get_syscall_args(tid, sc_args, &buf_len); |
if (res != 0) { |
printf("tdebug_get_syscall_args() -> %d\n", res); |
} |
printf("%s(", syscall_name[syscall_id]); |
switch (syscall_id) { |
case SYS_TLS_SET: printf("0x%08x", sc_args[0]); break; |
case SYS_IPC_WAIT: printf("0x%08x, %u, %d", sc_args[0], sc_args[1], sc_args[2]); break; |
default: |
printf("%u, %u, %u, %u, %u, %u", |
sc_args[0], sc_args[1], sc_args[2], |
sc_args[3], sc_args[4], sc_args[5]); |
break; |
} |
printf(") -> %d\n", rc); |
} |
static void event_exception(sysarg_t exc_no) |
{ |
printf("exception %u\n", exc_no); |
} |
static void notif_handler(ipc_callid_t iid, ipc_call_t *call) |
{ |
thread_id_t tid; |
sysarg_t method; |
sysarg_t tid_lo, tid_hi, ev_type, syscall_id, rc; |
sysarg_t exc_no; |
int res; |
(void)iid; |
method = IPC_GET_METHOD(*call); |
tid_lo = IPC_GET_ARG1(*call); |
tid_hi = IPC_GET_ARG2(*call); |
ev_type = IPC_GET_ARG3(*call); |
tid = (thread_id_t)tid_lo | ((thread_id_t)tid_hi << 32); |
switch (ev_type) { |
case TDEBUG_EV_SYSCALL: |
syscall_id = IPC_GET_ARG4(*call); |
rc = IPC_GET_ARG5(*call); |
event_syscall(tid, syscall_id, rc); |
break; |
case TDEBUG_EV_EXCEPTION: |
exc_no = IPC_GET_ARG4(*call); |
event_exception(exc_no); |
break; |
default: |
printf("unknown tdebug event notification %u\n", ev_type); |
break; |
} |
res = tdebug_continue_thread(tid); |
if (res != 0) { |
printf("tdebug_continue_thread() -> %d\n", res); |
} |
} |
char *test_tdebug1(bool quiet) |
{ |
task_id_t taskid; |
int result; |
async_set_interrupt_received(notif_handler); |
printf("test_tdebug1()\n"); |
taskid = 12; |
// tid = task_get_id(); |
// printf("this task id is %d\n", tid); |
printf("attaching...\n"); |
result = tdebug_attach_task(taskid, 368); |
printf("result is %d\n", result); |
getchar(); |
/* printf("setting event mask...\n"); |
result = tdebug_set_event_mask(taskid, TDEBUG_EVMASK_IAFTER); |
printf("result is %d\n", result); |
getchar(); |
*/ |
printf("detaching...\n"); |
result = tdebug_detach_task(taskid); |
printf("result is %d\n", result); |
return NULL; |
} |
/branches/tracing/uspace/app/tester/ipc/send_sync.c |
---|
38,10 → 38,10 |
static int msgid = 1; |
char c; |
printf("Select phoneid to send msg: 2-9 (Q to skip)\n"); |
printf("Select phoneid to send msg: 2-9 (q to skip)\n"); |
do { |
c = getchar(); |
if (c == 'Q' || c == 'q') |
if ((c == 'Q') || (c == 'q')) |
return TEST_SKIPPED; |
} while (c < '2' || c > '9'); |
phoneid = c - '0'; |
/branches/tracing/uspace/app/tester/ipc/send_async.c |
---|
41,10 → 41,10 |
static int msgid = 1; |
char c; |
printf("Select phoneid to send msg: 2-9 (Q to skip)\n"); |
printf("Select phoneid to send msg: 2-9 (q to skip)\n"); |
do { |
c = getchar(); |
if (c == 'Q' || c == 'q') |
if ((c == 'Q') || (c == 'q')) |
return TEST_SKIPPED; |
} while (c < '2' || c > '9'); |
phoneid = c - '0'; |
/branches/tracing/uspace/app/tester/ipc/connect.c |
---|
36,10 → 36,10 |
int svc; |
int phid; |
printf("Choose one service: 0:10000....9:10009 (Q to skip)\n"); |
printf("Choose one service: 0:10000....9:10009 (q to skip)\n"); |
do { |
c = getchar(); |
if (c == 'Q' || c == 'q') |
if ((c == 'Q') || (c == 'q')) |
return TEST_SKIPPED; |
} while (c < '0' || c > '9'); |
/branches/tracing/uspace/app/tester/tester.h |
---|
70,6 → 70,7 |
extern char * test_hangup(bool quiet); |
extern char * test_devmap1(bool quiet); |
extern char * test_vfs1(bool quiet); |
extern char * test_tdebug1(bool quiet); |
extern test_t tests[]; |
/branches/tracing/uspace/app/tester/Makefile |
---|
53,7 → 53,8 |
ipc/answer.c \ |
ipc/hangup.c \ |
devmap/devmap1.c \ |
vfs/vfs1.c |
vfs/vfs1.c \ |
tdebug/tdebug1.c |
OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) |
/branches/tracing/uspace/app/tetris/tetris.c |
---|
222,6 → 222,7 |
break; |
case 'h': |
*(int *)0 = 0; /* generate a page fault */ |
showscores(firstgame); |
tetris_menu_draw(*level); |
break; |
/branches/tracing/uspace/lib/libc/include/tdebug.h |
---|
0,0 → 1,55 |
/* |
* Copyright (c) 2006 Jakub Jermar |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libc |
* @{ |
*/ |
/** @file |
*/ |
#ifndef LIBC_TDEBUG_H_ |
#define LIBC_TDEBUG_H_ |
#include <task.h> |
#include <thread.h> |
#include <ipc/ipc.h> |
#include <kernel/tdebug/tdebug_type.h> |
int tdebug_attach_task(task_id_t id, ipcarg_t method); |
int tdebug_detach_task(task_id_t id); |
int tdebug_continue_thread(thread_id_t id); |
int tdebug_get_syscall_args(thread_id_t id, sysarg_t *buffer, size_t *len); |
int tdebug_set_event_mask(thread_id_t id, unsigned ev_mask); |
int tdebug_stop_thread(thread_id_t id); |
int tdebug_stop_task(task_id_t id); |
#endif |
/** @} |
*/ |
/branches/tracing/uspace/lib/libc/generic/tdebug.c |
---|
0,0 → 1,118 |
/* |
* Copyright (c) 2006 Jakub Jermar |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libc |
* @{ |
*/ |
/** @file |
*/ |
#include <tdebug.h> |
#include <task.h> |
#include <thread.h> |
#include <ipc/ipc.h> |
#include <libc.h> |
#include <kernel/syscall/sysarg64.h> |
int tdebug_attach_task(task_id_t id, ipcarg_t method) |
{ |
sysarg64_t arg; |
arg.value = (unsigned long long) id; |
return __SYSCALL2(SYS_TDEBUG_ATTACH_TASK, (sysarg_t) &arg, |
(sysarg_t) method); |
} |
int tdebug_detach_task(task_id_t id) |
{ |
sysarg64_t arg; |
arg.value = (unsigned long long) id; |
return __SYSCALL1(SYS_TDEBUG_DETACH_TASK, (sysarg_t) &arg); |
} |
int tdebug_continue_thread(thread_id_t id) |
{ |
sysarg64_t arg; |
arg.value = (unsigned long long) id; |
return __SYSCALL1(SYS_TDEBUG_CONTINUE_THREAD, (sysarg_t) &arg); |
} |
int tdebug_get_syscall_args(thread_id_t id, sysarg_t *buffer, size_t *len) |
{ |
sysarg64_t sa_id; |
sysarg_t sa_len; |
int rc; |
sa_id.value = (unsigned long long) id; |
sa_len = *len; |
rc = __SYSCALL3(SYS_TDEBUG_GET_SYSCALL_ARGS, (sysarg_t) &sa_id, |
(sysarg_t) buffer, (sysarg_t) &sa_len); |
*len = sa_len; |
return rc; |
} |
int tdebug_set_event_mask(task_id_t id, unsigned ev_mask) |
{ |
sysarg64_t arg; |
arg.value = (unsigned long long) id; |
return __SYSCALL2(SYS_TDEBUG_SET_EVENT_MASK, (sysarg_t) &arg, |
(sysarg_t) ev_mask); |
} |
int tdebug_stop_thread(thread_id_t id) |
{ |
sysarg64_t arg; |
arg.value = (unsigned long long) id; |
return __SYSCALL1(SYS_TDEBUG_STOP_THREAD, (sysarg_t) &arg); |
} |
int tdebug_stop_task(task_id_t id) |
{ |
sysarg64_t arg; |
arg.value = (unsigned long long) id; |
return __SYSCALL1(SYS_TDEBUG_STOP_TASK, (sysarg_t) &arg); |
} |
/** @} |
*/ |
/branches/tracing/uspace/lib/libc/Makefile |
---|
54,6 → 54,7 |
generic/thread.c \ |
generic/tls.c \ |
generic/task.c \ |
generic/tdebug.c \ |
generic/futex.c \ |
generic/io/io.c \ |
generic/io/printf.c \ |