Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4688 → Rev 4348

/branches/dynload/kernel/generic/src/main/main.c
250,10 → 250,10
count_t i;
for (i = 0; i < init.cnt; i++)
LOG("init[%" PRIc "].addr=%#" PRIp ", init[%" PRIc
"].size=%#" PRIs, i, init.tasks[i].addr, i,
"].size=%#" PRIs "\n", i, init.tasks[i].addr, i,
init.tasks[i].size);
} else
printf("No init binaries found.\n");
printf("No init binaries found\n");
LOG_EXEC(ipc_init());
LOG_EXEC(event_init());
/branches/dynload/kernel/generic/src/syscall/syscall.c
66,19 → 66,9
unative_t a4, unative_t a5, unative_t a6, unative_t id)
{
unative_t rc;
 
#ifdef CONFIG_UDEBUG
bool debug;
 
/*
* Early check for undebugged tasks. We do not lock anything as this
* test need not be precise in either way.
*/
debug = THREAD->udebug.active;
if (debug) {
udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, 0, false);
}
udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, 0, false);
#endif
if (id < SYSCALL_END) {
93,17 → 83,14
thread_exit();
#ifdef CONFIG_UDEBUG
if (debug) {
udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, rc, true);
udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, rc, true);
/*
* Stopping point needed for tasks that only invoke
* non-blocking system calls. Not needed if the task
* is not being debugged (it cannot block here).
*/
udebug_stoppable_begin();
udebug_stoppable_end();
}
/*
* Stopping point needed for tasks that only invoke non-blocking
* system calls.
*/
udebug_stoppable_begin();
udebug_stoppable_end();
#endif
return rc;
/branches/dynload/kernel/generic/src/ipc/kbox.c
84,10 → 84,10
interrupts_restore(ipl);
if (have_kb_thread) {
LOG("Join kb.thread.");
LOG("join kb.thread..\n");
thread_join(TASK->kb.thread);
thread_detach(TASK->kb.thread);
LOG("...join done.");
LOG("join done\n");
TASK->kb.thread = NULL;
}
 
108,10 → 108,12
{
ipl_t ipl;
 
LOG("kbox_proc_phone_hungup()\n");
 
/* Was it our debugger, who hung up? */
if (call->sender == TASK->udebug.debugger) {
/* Terminate debugging session (if any). */
LOG("Terminate debugging session.");
LOG("kbox: terminate debug session\n");
ipl = interrupts_disable();
spinlock_lock(&TASK->lock);
udebug_task_cleanup(TASK);
118,10 → 120,10
spinlock_unlock(&TASK->lock);
interrupts_restore(ipl);
} else {
LOG("Was not debugger.");
LOG("kbox: was not debugger\n");
}
 
LOG("Continue with hangup message.");
LOG("kbox: continue with hangup message\n");
IPC_SET_RETVAL(call->data, 0);
ipc_answer(&TASK->kb.box, call);
 
143,7 → 145,7
}
mutex_unlock(&TASK->kb.cleanup_lock);
 
LOG("Phone list is empty.");
LOG("phone list is empty\n");
*last = true;
} else {
*last = false;
167,7 → 169,7
bool done;
 
(void)arg;
LOG("Starting.");
LOG("kbox_thread_proc()\n");
done = false;
 
while (!done) {
199,7 → 201,7
}
}
 
LOG("Exiting.");
LOG("kbox: finished\n");
}
 
 
/branches/dynload/kernel/generic/src/udebug/udebug.c
98,6 → 98,27
waitq_sleep_finish(wq, rc, ipl);
}
 
/** Do a preliminary check that a debugging session is in progress.
*
* This only requires the THREAD->udebug.lock mutex (and not TASK->udebug.lock
* mutex). For an undebugged task, this will never block (while there could be
* collisions by different threads on the TASK mutex), thus improving SMP
* perormance for undebugged tasks.
*
* @return True if the thread was in a debugging session when the function
* checked, false otherwise.
*/
static bool udebug_thread_precheck(void)
{
bool res;
 
mutex_lock(&THREAD->udebug.lock);
res = THREAD->udebug.active;
mutex_unlock(&THREAD->udebug.lock);
 
return res;
}
 
/** Start of stoppable section.
*
* A stoppable section is a section of code where if the thread can be stoped. In other words,
116,6 → 137,11
ASSERT(THREAD);
ASSERT(TASK);
 
/* Early check for undebugged tasks */
if (!udebug_thread_precheck()) {
return;
}
 
mutex_lock(&TASK->udebug.lock);
 
nsc = --TASK->udebug.not_stoppable_count;
176,6 → 202,11
*/
void udebug_stoppable_end(void)
{
/* Early check for undebugged tasks */
if (!udebug_thread_precheck()) {
return;
}
 
restart:
mutex_lock(&TASK->udebug.lock);
mutex_lock(&THREAD->udebug.lock);
224,6 → 255,11
 
etype = end_variant ? UDEBUG_EVENT_SYSCALL_E : UDEBUG_EVENT_SYSCALL_B;
 
/* Early check for undebugged tasks */
if (!udebug_thread_precheck()) {
return;
}
 
mutex_lock(&TASK->udebug.lock);
mutex_lock(&THREAD->udebug.lock);
 
235,7 → 271,7
return;
}
 
/* Fill in the GO response. */
//printf("udebug_syscall_event\n");
call = THREAD->udebug.go_call;
THREAD->udebug.go_call = NULL;
 
243,6 → 279,7
IPC_SET_ARG1(call->data, etype);
IPC_SET_ARG2(call->data, id);
IPC_SET_ARG3(call->data, rc);
//printf("udebug_syscall_event/ipc_answer\n");
 
THREAD->udebug.syscall_args[0] = a1;
THREAD->udebug.syscall_args[1] = a2;
292,19 → 329,21
 
thread_attach(t, ta);
 
LOG("Check state");
LOG("udebug_thread_b_event\n");
LOG("- check state\n");
 
/* Must only generate events when in debugging session */
if (THREAD->udebug.active != true) {
LOG("udebug.active: %s, udebug.go: %s",
THREAD->udebug.active ? "Yes(+)" : "No",
THREAD->udebug.go ? "Yes(-)" : "No");
LOG("- udebug.active: %s, udebug.go: %s\n",
THREAD->udebug.active ? "yes(+)" : "no(-)",
THREAD->udebug.go ? "yes(-)" : "no(+)");
mutex_unlock(&THREAD->udebug.lock);
mutex_unlock(&TASK->udebug.lock);
return;
}
 
LOG("Trigger event");
LOG("- trigger event\n");
 
call = THREAD->udebug.go_call;
THREAD->udebug.go_call = NULL;
IPC_SET_RETVAL(call->data, 0);
324,7 → 363,7
mutex_unlock(&THREAD->udebug.lock);
mutex_unlock(&TASK->udebug.lock);
 
LOG("Wait for Go");
LOG("- sleep\n");
udebug_wait_for_go(&THREAD->udebug.go_wq);
}
 
340,19 → 379,21
mutex_lock(&TASK->udebug.lock);
mutex_lock(&THREAD->udebug.lock);
 
LOG("Check state");
LOG("udebug_thread_e_event\n");
LOG("- check state\n");
 
/* Must only generate events when in debugging session. */
if (THREAD->udebug.active != true) {
LOG("udebug.active: %s, udebug.go: %s",
THREAD->udebug.active ? "Yes" : "No",
THREAD->udebug.go ? "Yes" : "No");
/* printf("- udebug.active: %s, udebug.go: %s\n",
THREAD->udebug.active ? "yes(+)" : "no(-)",
THREAD->udebug.go ? "yes(-)" : "no(+)");*/
mutex_unlock(&THREAD->udebug.lock);
mutex_unlock(&TASK->udebug.lock);
return;
}
 
LOG("Trigger event");
LOG("- trigger event\n");
 
call = THREAD->udebug.go_call;
THREAD->udebug.go_call = NULL;
IPC_SET_RETVAL(call->data, 0);
391,13 → 432,15
int flags;
ipl_t ipl;
 
LOG("udebug_task_cleanup()\n");
LOG("task %" PRIu64 "\n", ta->taskid);
 
if (ta->udebug.dt_state != UDEBUG_TS_BEGINNING &&
ta->udebug.dt_state != UDEBUG_TS_ACTIVE) {
LOG("udebug_task_cleanup(): task not being debugged\n");
return EINVAL;
}
 
LOG("Task %" PRIu64, ta->taskid);
 
/* Finish debugging of all userspace threads */
for (cur = ta->th_head.next; cur != &ta->th_head; cur = cur->next) {
t = list_get_instance(cur, thread_t, th_link);
427,7 → 470,7
t->udebug.go = false;
 
/* Answer GO call */
LOG("Answer GO call with EVENT_FINISHED.");
LOG("answer GO call with EVENT_FINISHED\n");
IPC_SET_RETVAL(t->udebug.go_call->data, 0);
IPC_SET_ARG1(t->udebug.go_call->data,
UDEBUG_EVENT_FINISHED);
/branches/dynload/kernel/generic/src/udebug/udebug_ops.c
181,11 → 181,15
thread_t *t;
link_t *cur;
 
LOG("Debugging task %llu", TASK->taskid);
LOG("udebug_begin()\n");
 
mutex_lock(&TASK->udebug.lock);
LOG("debugging task %llu\n", TASK->taskid);
 
if (TASK->udebug.dt_state != UDEBUG_TS_INACTIVE) {
mutex_unlock(&TASK->udebug.lock);
LOG("udebug_begin(): busy error\n");
 
return EBUSY;
}
 
213,6 → 217,10
}
 
mutex_unlock(&TASK->udebug.lock);
 
LOG("udebug_begin() done (%s)\n",
reply ? "reply" : "stoppability wait");
 
return reply;
}
 
225,10 → 233,13
{
int rc;
 
LOG("Task %" PRIu64, TASK->taskid);
LOG("udebug_end()\n");
 
mutex_lock(&TASK->udebug.lock);
LOG("task %" PRIu64 "\n", TASK->taskid);
 
rc = udebug_task_cleanup(TASK);
 
mutex_unlock(&TASK->udebug.lock);
 
return rc;
243,16 → 254,19
*/
int udebug_set_evmask(udebug_evmask_t mask)
{
LOG("mask = 0x%x", mask);
LOG("udebug_set_mask()\n");
 
mutex_lock(&TASK->udebug.lock);
 
if (TASK->udebug.dt_state != UDEBUG_TS_ACTIVE) {
mutex_unlock(&TASK->udebug.lock);
LOG("udebug_set_mask(): not active debuging session\n");
 
return EINVAL;
}
 
TASK->udebug.evmask = mask;
 
mutex_unlock(&TASK->udebug.lock);
 
return 0;
303,7 → 317,7
{
int rc;
 
LOG("udebug_stop()");
LOG("udebug_stop()\n");
 
/*
* On success, this will lock t->udebug.lock. Note that this makes sure
326,6 → 340,7
/*
* Answer GO call.
*/
LOG("udebug_stop - answering go call\n");
 
/* Make sure nobody takes this call away from us. */
call = t->udebug.go_call;
333,6 → 348,7
 
IPC_SET_RETVAL(call->data, 0);
IPC_SET_ARG1(call->data, UDEBUG_EVENT_STOP);
LOG("udebug_stop/ipc_answer\n");
 
THREAD->udebug.cur_event = UDEBUG_EVENT_STOP;
 
342,6 → 358,7
ipc_answer(&TASK->answerbox, call);
mutex_unlock(&TASK->udebug.lock);
 
LOG("udebog_stop/done\n");
return 0;
}
 
375,7 → 392,7
int flags;
size_t max_ids;
 
LOG("udebug_thread_read()");
LOG("udebug_thread_read()\n");
 
/* Allocate a buffer to hold thread IDs */
id_buffer = malloc(buf_size, 0);
/branches/dynload/kernel/arch/ia64/src/drivers/ski.c
44,18 → 44,12
#include <string.h>
#include <arch.h>
 
enum {
/** Interval between polling in microseconds */
POLL_INTERVAL = 10000, /* 0.01 s */
#define POLL_INTERVAL 10000 /* 10 ms */
 
/** Max. number of characters to pull out at a time */
POLL_LIMIT = 30,
#define SKI_INIT_CONSOLE 20
#define SKI_GETCHAR 21
#define SKI_PUTCHAR 31
 
SKI_INIT_CONSOLE = 20,
SKI_GETCHAR = 21,
SKI_PUTCHAR = 31
};
 
static void ski_putchar(outdev_t *, const wchar_t, bool);
 
static outdev_operations_t skiout_ops = {
160,29 → 154,16
return (wchar_t) ch;
}
 
/** Ask keyboard if a key was pressed.
*
* If so, it will repeat and pull up to POLL_LIMIT characters.
*/
/** Ask keyboard if a key was pressed. */
static void poll_keyboard(ski_instance_t *instance)
{
wchar_t ch;
int count;
 
if (kbd_disabled)
return;
 
count = POLL_LIMIT;
 
while (count > 0) {
ch = ski_getchar();
 
if (ch == '\0')
break;
 
wchar_t ch = ski_getchar();
if (ch != 0)
indev_push_character(instance->srlnin, ch);
--count;
}
}
 
/** Kernel thread for polling keyboard. */