Index: kernel/generic/src/udebug/udebug.c
===================================================================
--- kernel/generic/src/udebug/udebug.c	(revision 1b20da07baaa3e3c424f62c927274e676e4295cd)
+++ kernel/generic/src/udebug/udebug.c	(revision fd57cf17d12bbe3b41626a0b8708f075134a073e)
@@ -75,5 +75,5 @@
 	waitq_initialize(&ut->go_wq);
 	condvar_initialize(&ut->active_cv);
-	
+
 	ut->go_call = NULL;
 	ut->uspace_state = NULL;
@@ -96,5 +96,5 @@
 {
 	ipl_t ipl = waitq_sleep_prepare(wq);
-	
+
 	wq->missed_wakeups = 0;  /* Enforce blocking. */
 	bool blocked;
@@ -119,14 +119,14 @@
 	assert(THREAD);
 	assert(TASK);
-	
+
 	mutex_lock(&TASK->udebug.lock);
-	
+
 	int nsc = --TASK->udebug.not_stoppable_count;
-	
+
 	/* Lock order OK, THREAD->udebug.lock is after TASK->udebug.lock */
 	mutex_lock(&THREAD->udebug.lock);
 	assert(THREAD->udebug.stoppable == false);
 	THREAD->udebug.stoppable = true;
-	
+
 	if ((TASK->udebug.dt_state == UDEBUG_TS_BEGINNING) && (nsc == 0)) {
 		/*
@@ -135,11 +135,11 @@
 		 *
 		 */
-		
+
 		call_t *db_call = TASK->udebug.begin_call;
 		assert(db_call);
-		
+
 		TASK->udebug.dt_state = UDEBUG_TS_ACTIVE;
 		TASK->udebug.begin_call = NULL;
-		
+
 		IPC_SET_RETVAL(db_call->data, 0);
 		ipc_answer(&TASK->answerbox, db_call);
@@ -148,5 +148,5 @@
 		 * Active debugging session
 		 */
-		
+
 		if (THREAD->udebug.active == true &&
 		    THREAD->udebug.go == false) {
@@ -155,18 +155,18 @@
 			 *
 			 */
-			
+
 			/* Make sure nobody takes this call away from us */
 			call_t *go_call = THREAD->udebug.go_call;
 			THREAD->udebug.go_call = NULL;
 			assert(go_call);
-			
+
 			IPC_SET_RETVAL(go_call->data, 0);
 			IPC_SET_ARG1(go_call->data, UDEBUG_EVENT_STOP);
-			
+
 			THREAD->udebug.cur_event = UDEBUG_EVENT_STOP;
 			ipc_answer(&TASK->answerbox, go_call);
 		}
 	}
-	
+
 	mutex_unlock(&THREAD->udebug.lock);
         mutex_unlock(&TASK->udebug.lock);
@@ -185,11 +185,11 @@
 	mutex_lock(&TASK->udebug.lock);
 	mutex_lock(&THREAD->udebug.lock);
-	
+
 	if ((THREAD->udebug.active) && (THREAD->udebug.go == false)) {
 		mutex_unlock(&THREAD->udebug.lock);
 		mutex_unlock(&TASK->udebug.lock);
-		
+
 		udebug_wait_for_go(&THREAD->udebug.go_wq);
-		
+
 		goto restart;
 		/* Must try again - have to lose stoppability atomically. */
@@ -198,5 +198,5 @@
 		assert(THREAD->udebug.stoppable == true);
 		THREAD->udebug.stoppable = false;
-		
+
 		mutex_unlock(&THREAD->udebug.lock);
 		mutex_unlock(&TASK->udebug.lock);
@@ -228,8 +228,8 @@
 	udebug_event_t etype =
 	    end_variant ? UDEBUG_EVENT_SYSCALL_E : UDEBUG_EVENT_SYSCALL_B;
-	
+
 	mutex_lock(&TASK->udebug.lock);
 	mutex_lock(&THREAD->udebug.lock);
-	
+
 	/* Must only generate events when in debugging session and is go. */
 	if (THREAD->udebug.active != true || THREAD->udebug.go == false ||
@@ -239,14 +239,14 @@
 		return;
 	}
-	
+
 	/* Fill in the GO response. */
 	call_t *call = THREAD->udebug.go_call;
 	THREAD->udebug.go_call = NULL;
-	
+
 	IPC_SET_RETVAL(call->data, 0);
 	IPC_SET_ARG1(call->data, etype);
 	IPC_SET_ARG2(call->data, id);
 	IPC_SET_ARG3(call->data, rc);
-	
+
 	THREAD->udebug.syscall_args[0] = a1;
 	THREAD->udebug.syscall_args[1] = a2;
@@ -255,5 +255,5 @@
 	THREAD->udebug.syscall_args[4] = a5;
 	THREAD->udebug.syscall_args[5] = a6;
-	
+
 	/*
 	 * Make sure udebug.go is false when going to sleep
@@ -264,10 +264,10 @@
 	THREAD->udebug.go = false;
 	THREAD->udebug.cur_event = etype;
-	
+
 	ipc_answer(&TASK->answerbox, call);
-	
+
 	mutex_unlock(&THREAD->udebug.lock);
 	mutex_unlock(&TASK->udebug.lock);
-	
+
 	udebug_wait_for_go(&THREAD->udebug.go_wq);
 }
@@ -294,9 +294,9 @@
 	mutex_lock(&TASK->udebug.lock);
 	mutex_lock(&THREAD->udebug.lock);
-	
+
 	thread_attach(thread, task);
-	
+
 	LOG("Check state");
-	
+
 	/* Must only generate events when in debugging session */
 	if (THREAD->udebug.active != true) {
@@ -304,19 +304,19 @@
 		    THREAD->udebug.active ? "Yes(+)" : "No",
 		    THREAD->udebug.go ? "Yes(-)" : "No");
-		
+
 		mutex_unlock(&THREAD->udebug.lock);
 		mutex_unlock(&TASK->udebug.lock);
 		return;
 	}
-	
+
 	LOG("Trigger event");
-	
+
 	call_t *call = THREAD->udebug.go_call;
-	
+
 	THREAD->udebug.go_call = NULL;
 	IPC_SET_RETVAL(call->data, 0);
 	IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_B);
 	IPC_SET_ARG2(call->data, (sysarg_t) thread);
-	
+
 	/*
 	 * Make sure udebug.go is false when going to sleep
@@ -327,10 +327,10 @@
 	THREAD->udebug.go = false;
 	THREAD->udebug.cur_event = UDEBUG_EVENT_THREAD_B;
-	
+
 	ipc_answer(&TASK->answerbox, call);
-	
+
 	mutex_unlock(&THREAD->udebug.lock);
 	mutex_unlock(&TASK->udebug.lock);
-	
+
 	LOG("Wait for Go");
 	udebug_wait_for_go(&THREAD->udebug.go_wq);
@@ -347,7 +347,7 @@
 	mutex_lock(&TASK->udebug.lock);
 	mutex_lock(&THREAD->udebug.lock);
-	
+
 	LOG("Check state");
-	
+
 	/* Must only generate events when in debugging session. */
 	if (THREAD->udebug.active != true) {
@@ -355,28 +355,28 @@
 		    THREAD->udebug.active ? "Yes" : "No",
 		    THREAD->udebug.go ? "Yes" : "No");
-		
+
 		mutex_unlock(&THREAD->udebug.lock);
 		mutex_unlock(&TASK->udebug.lock);
 		return;
 	}
-	
+
 	LOG("Trigger event");
-	
+
 	call_t *call = THREAD->udebug.go_call;
-	
+
 	THREAD->udebug.go_call = NULL;
 	IPC_SET_RETVAL(call->data, 0);
 	IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_E);
-	
+
 	/* Prevent any further debug activity in thread. */
 	THREAD->udebug.active = false;
 	THREAD->udebug.cur_event = 0;   /* None */
 	THREAD->udebug.go = false;      /* Set to initial value */
-	
+
 	ipc_answer(&TASK->answerbox, call);
-	
+
 	mutex_unlock(&THREAD->udebug.lock);
 	mutex_unlock(&TASK->udebug.lock);
-	
+
 	/*
 	 * This event does not sleep - debugging has finished
@@ -405,11 +405,11 @@
 		return EINVAL;
 	}
-	
+
 	LOG("Task %" PRIu64, task->taskid);
-	
+
 	/* Finish debugging of all userspace threads */
 	list_foreach(task->threads, th_link, thread_t, thread) {
 		mutex_lock(&thread->udebug.lock);
-		
+
 		/* Only process userspace threads. */
 		if (thread->uspace) {
@@ -417,5 +417,5 @@
 			thread->udebug.active = false;
 			thread->udebug.cur_event = 0;   /* None */
-			
+
 			/* Is the thread still go? */
 			if (thread->udebug.go == true) {
@@ -426,12 +426,12 @@
 				 */
 				thread->udebug.go = false;
-				
+
 				/* Answer GO call */
 				LOG("Answer GO call with EVENT_FINISHED.");
-				
+
 				IPC_SET_RETVAL(thread->udebug.go_call->data, 0);
 				IPC_SET_ARG1(thread->udebug.go_call->data,
 				    UDEBUG_EVENT_FINISHED);
-				
+
 				ipc_answer(&task->answerbox, thread->udebug.go_call);
 				thread->udebug.go_call = NULL;
@@ -442,5 +442,5 @@
 				 *
 				 */
-				
+
 				/*
 				 * thread's lock must not be held when calling
@@ -450,5 +450,5 @@
 				waitq_wakeup(&thread->udebug.go_wq, WAKEUP_FIRST);
 			}
-			
+
 			mutex_unlock(&thread->udebug.lock);
 			condvar_broadcast(&thread->udebug.active_cv);
@@ -456,8 +456,8 @@
 			mutex_unlock(&thread->udebug.lock);
 	}
-	
+
 	task->udebug.dt_state = UDEBUG_TS_INACTIVE;
 	task->udebug.debugger = NULL;
-	
+
 	return 0;
 }
@@ -474,5 +474,5 @@
 {
 	udebug_stoppable_begin();
-	
+
 	/* Wait until a debugger attends to us. */
 	mutex_lock(&THREAD->udebug.lock);
@@ -480,5 +480,5 @@
 		condvar_wait(&THREAD->udebug.active_cv, &THREAD->udebug.lock);
 	mutex_unlock(&THREAD->udebug.lock);
-	
+
 	/* Make sure the debugging session is over before proceeding. */
 	mutex_lock(&THREAD->udebug.lock);
@@ -486,5 +486,5 @@
 		condvar_wait(&THREAD->udebug.active_cv, &THREAD->udebug.lock);
 	mutex_unlock(&THREAD->udebug.lock);
-	
+
 	udebug_stoppable_end();
 }
Index: kernel/generic/src/udebug/udebug_ops.c
===================================================================
--- kernel/generic/src/udebug/udebug_ops.c	(revision 1b20da07baaa3e3c424f62c927274e676e4295cd)
+++ kernel/generic/src/udebug/udebug_ops.c	(revision fd57cf17d12bbe3b41626a0b8708f075134a073e)
@@ -82,8 +82,8 @@
 {
 	mutex_lock(&TASK->udebug.lock);
-	
+
 	/* thread_exists() must be called with threads_lock held */
 	irq_spinlock_lock(&threads_lock, true);
-	
+
 	if (!thread_exists(thread)) {
 		irq_spinlock_unlock(&threads_lock, true);
@@ -91,8 +91,8 @@
 		return ENOENT;
 	}
-	
+
 	/* thread->lock is enough to ensure the thread's existence */
 	irq_spinlock_exchange(&threads_lock, &thread->lock);
-	
+
 	/* Verify that 'thread' is a userspace thread. */
 	if (!thread->uspace) {
@@ -102,5 +102,5 @@
 		return ENOENT;
 	}
-	
+
 	/* Verify debugging state. */
 	if (thread->udebug.active != true) {
@@ -110,5 +110,5 @@
 		return ENOENT;
 	}
-	
+
 	/*
 	 * Since the thread has active == true, TASK->udebug.lock
@@ -118,7 +118,7 @@
 	 */
 	irq_spinlock_unlock(&thread->lock, true);
-	
+
 	/* Only mutex TASK->udebug.lock left. */
-	
+
 	/* Now verify that the thread belongs to the current task. */
 	if (thread->task != TASK) {
@@ -127,5 +127,5 @@
 		return ENOENT;
 	}
-	
+
 	/*
 	 * Now we need to grab the thread's debug lock for synchronization
@@ -134,8 +134,8 @@
 	 */
 	mutex_lock(&thread->udebug.lock);
-	
+
 	/* The big task mutex is no longer needed. */
 	mutex_unlock(&TASK->udebug.lock);
-	
+
 	if (thread->udebug.go != being_go) {
 		/* Not in debugging session or undesired GO state. */
@@ -143,7 +143,7 @@
 		return EINVAL;
 	}
-	
+
 	/* Only thread->udebug.lock left. */
-	
+
 	return EOK;  /* All went well. */
 }
@@ -177,16 +177,16 @@
 {
 	LOG("Debugging task %" PRIu64, TASK->taskid);
-	
-	mutex_lock(&TASK->udebug.lock);
-	
+
+	mutex_lock(&TASK->udebug.lock);
+
 	if (TASK->udebug.dt_state != UDEBUG_TS_INACTIVE) {
 		mutex_unlock(&TASK->udebug.lock);
 		return EBUSY;
 	}
-	
+
 	TASK->udebug.dt_state = UDEBUG_TS_BEGINNING;
 	TASK->udebug.begin_call = call;
 	TASK->udebug.debugger = call->sender;
-	
+
 	if (TASK->udebug.not_stoppable_count == 0) {
 		TASK->udebug.dt_state = UDEBUG_TS_ACTIVE;
@@ -195,7 +195,7 @@
 	} else
 		*active = false;  /* only in beginning state */
-	
+
 	/* Set udebug.active on all of the task's userspace threads. */
-	
+
 	list_foreach(TASK->threads, th_link, thread_t, thread) {
 		mutex_lock(&thread->udebug.lock);
@@ -207,5 +207,5 @@
 			mutex_unlock(&thread->udebug.lock);
 	}
-	
+
 	mutex_unlock(&TASK->udebug.lock);
 	return EOK;
@@ -222,9 +222,9 @@
 {
 	LOG("Task %" PRIu64, TASK->taskid);
-	
+
 	mutex_lock(&TASK->udebug.lock);
 	errno_t rc = udebug_task_cleanup(TASK);
 	mutex_unlock(&TASK->udebug.lock);
-	
+
 	return rc;
 }
@@ -242,15 +242,15 @@
 {
 	LOG("mask = 0x%x", mask);
-	
-	mutex_lock(&TASK->udebug.lock);
-	
+
+	mutex_lock(&TASK->udebug.lock);
+
 	if (TASK->udebug.dt_state != UDEBUG_TS_ACTIVE) {
 		mutex_unlock(&TASK->udebug.lock);
 		return EINVAL;
 	}
-	
+
 	TASK->udebug.evmask = mask;
 	mutex_unlock(&TASK->udebug.lock);
-	
+
 	return EOK;
 }
@@ -272,9 +272,9 @@
 	if (rc != EOK)
 		return rc;
-	
+
 	thread->udebug.go_call = call;
 	thread->udebug.go = true;
 	thread->udebug.cur_event = 0;  /* none */
-	
+
 	/*
 	 * Neither thread's lock nor threads_lock may be held during wakeup.
@@ -282,7 +282,7 @@
 	 */
 	waitq_wakeup(&thread->udebug.go_wq, WAKEUP_FIRST);
-	
+
 	_thread_op_end(thread);
-	
+
 	return EOK;
 }
@@ -300,5 +300,5 @@
 {
 	LOG("udebug_stop()");
-	
+
 	/*
 	 * On success, this will lock thread->udebug.lock. Note that this
@@ -309,8 +309,8 @@
 	if (rc != EOK)
 		return rc;
-	
+
 	/* Take GO away from the thread. */
 	thread->udebug.go = false;
-	
+
 	if (thread->udebug.stoppable != true) {
 		/* Answer will be sent when the thread becomes stoppable. */
@@ -318,25 +318,25 @@
 		return EOK;
 	}
-	
+
 	/*
 	 * Answer GO call.
 	 *
 	 */
-	
+
 	/* Make sure nobody takes this call away from us. */
 	call = thread->udebug.go_call;
 	thread->udebug.go_call = NULL;
-	
+
 	IPC_SET_RETVAL(call->data, 0);
 	IPC_SET_ARG1(call->data, UDEBUG_EVENT_STOP);
-	
+
 	THREAD->udebug.cur_event = UDEBUG_EVENT_STOP;
-	
+
 	_thread_op_end(thread);
-	
+
 	mutex_lock(&TASK->udebug.lock);
 	ipc_answer(&TASK->answerbox, call);
 	mutex_unlock(&TASK->udebug.lock);
-	
+
 	return EOK;
 }
@@ -368,10 +368,10 @@
 {
 	LOG("udebug_thread_read()");
-	
+
 	/* Allocate a buffer to hold thread IDs */
 	sysarg_t *id_buffer = malloc(buf_size + 1, 0);
-	
-	mutex_lock(&TASK->udebug.lock);
-	
+
+	mutex_lock(&TASK->udebug.lock);
+
 	/* Verify task state */
 	if (TASK->udebug.dt_state != UDEBUG_TS_ACTIVE) {
@@ -380,13 +380,13 @@
 		return EINVAL;
 	}
-	
+
 	irq_spinlock_lock(&TASK->lock, true);
-	
+
 	/* Copy down the thread IDs */
-	
+
 	size_t max_ids = buf_size / sizeof(sysarg_t);
 	size_t copied_ids = 0;
 	size_t extra_ids = 0;
-	
+
 	/* FIXME: make sure the thread isn't past debug shutdown... */
 	list_foreach(TASK->threads, th_link, thread_t, thread) {
@@ -394,9 +394,9 @@
 		bool uspace = thread->uspace;
 		irq_spinlock_unlock(&thread->lock, false);
-		
+
 		/* Not interested in kernel threads. */
 		if (!uspace)
 			continue;
-		
+
 		if (copied_ids < max_ids) {
 			/* Using thread struct pointer as identification hash */
@@ -405,13 +405,13 @@
 			extra_ids++;
 	}
-	
+
 	irq_spinlock_unlock(&TASK->lock, true);
-	
-	mutex_unlock(&TASK->udebug.lock);
-	
+
+	mutex_unlock(&TASK->udebug.lock);
+
 	*buffer = id_buffer;
 	*stored = copied_ids * sizeof(sysarg_t);
 	*needed = (copied_ids + extra_ids) * sizeof(sysarg_t);
-	
+
 	return EOK;
 }
@@ -431,10 +431,10 @@
 {
 	size_t name_size = str_size(TASK->name) + 1;
-	
+
 	*data = malloc(name_size, 0);
 	*data_size = name_size;
-	
+
 	memcpy(*data, TASK->name, name_size);
-	
+
 	return EOK;
 }
@@ -463,5 +463,5 @@
 	if (rc != EOK)
 		return rc;
-	
+
 	/* Additionally we need to verify that we are inside a syscall. */
 	if ((thread->udebug.cur_event != UDEBUG_EVENT_SYSCALL_B) &&
@@ -470,13 +470,13 @@
 		return EINVAL;
 	}
-	
+
 	/* Prepare a buffer to hold the arguments. */
 	sysarg_t *arg_buffer = malloc(6 * sizeof(sysarg_t), 0);
-	
+
 	/* Copy to a local buffer before releasing the lock. */
 	memcpy(arg_buffer, thread->udebug.syscall_args, 6 * sizeof(sysarg_t));
-	
+
 	_thread_op_end(thread);
-	
+
 	*buffer = arg_buffer;
 	return EOK;
@@ -506,5 +506,5 @@
 	if (rc != EOK)
 		return rc;
-	
+
 	istate_t *state = thread->udebug.uspace_state;
 	if (state == NULL) {
@@ -512,13 +512,13 @@
 		return EBUSY;
 	}
-	
+
 	/* Prepare a buffer to hold the data. */
 	istate_t *state_buf = malloc(sizeof(istate_t), 0);
-	
+
 	/* Copy to the allocated buffer */
 	memcpy(state_buf, state, sizeof(istate_t));
-	
+
 	_thread_op_end(thread);
-	
+
 	*buffer = (void *) state_buf;
 	return EOK;
@@ -540,12 +540,12 @@
 	/* Verify task state */
 	mutex_lock(&TASK->udebug.lock);
-	
+
 	if (TASK->udebug.dt_state != UDEBUG_TS_ACTIVE) {
 		mutex_unlock(&TASK->udebug.lock);
 		return EBUSY;
 	}
-	
+
 	void *data_buffer = malloc(n, 0);
-	
+
 	/*
 	 * NOTE: this is not strictly from a syscall... but that shouldn't
@@ -555,8 +555,8 @@
 	errno_t rc = copy_from_uspace(data_buffer, (void *) uspace_addr, n);
 	mutex_unlock(&TASK->udebug.lock);
-	
+
 	if (rc != EOK)
 		return rc;
-	
+
 	*buffer = data_buffer;
 	return EOK;
