Index: kernel/generic/src/udebug/udebug.c
===================================================================
--- kernel/generic/src/udebug/udebug.c	(revision 073c9e61a18eccb87f9fe939f4f206dd9422a55f)
+++ kernel/generic/src/udebug/udebug.c	(revision 3b8fe85c2724c9334d223f7746537735cb1b95e0)
@@ -33,5 +33,7 @@
 /**
  * @file
- * @brief	Udebug.
+ * @brief	Udebug hooks and data structure management.
+ *
+ * Udebug is an interface that makes userspace debuggers possible.
  *
  * Functions in this file are executed directly in each thread, which
@@ -64,4 +66,9 @@
 }
 
+/** Initialize udebug part of task structure.
+ *
+ * Called as part of task structure initialization.
+ * @param ut	Pointer to the structure to initialize.
+ */
 void udebug_task_init(udebug_task_t *ut)
 {
@@ -73,4 +80,9 @@
 }
 
+/** Initialize udebug part of thread structure.
+ *
+ * Called as part of thread structure initialization.
+ * @param ut	Pointer to the structure to initialize.
+ */
 void udebug_thread_initialize(udebug_thread_t *ut)
 {
@@ -90,4 +102,12 @@
 }
 
+/** Wait for a GO message.
+ *
+ * When a debugging event occurs in a thread or the thread is stopped,
+ * this function is called to block the thread until a GO message
+ * is received.
+ *
+ * @param wq	The wait queue used by the thread to wait for GO messages.
+ */
 static void udebug_wait_for_go(waitq_t *wq)
 {
@@ -105,8 +125,11 @@
 /** 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.
+ * 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)
@@ -121,4 +144,14 @@
 }
 
+/** Start of stoppable section.
+ *
+ * A stoppable section is a section of code where if the thread can be stoped. In other words,
+ * if a STOP operation is issued, the thread is guaranteed not to execute
+ * any userspace instructions until the thread is resumed.
+ *
+ * Having stoppable sections is better than having stopping points, since
+ * a thread can be stopped even when it is blocked indefinitely in a system
+ * call (whereas it would not reach any stopping point).
+ */
 void udebug_stoppable_begin(void)
 {
@@ -189,4 +222,9 @@
 }
 
+/** End of a stoppable section.
+ *
+ * This is the point where the thread will block if it is stopped.
+ * (As, by definition, a stopped thread must not leave its stoppable section).
+ */
 void udebug_stoppable_end(void)
 {
@@ -259,4 +297,9 @@
 }
 
+/** Syscall event hook.
+ *
+ * Must be called before and after servicing a system call. This generates
+ * a SYSCALL_B or SYSCALL_E event, depending on the value of @a end_variant.
+ */
 void udebug_syscall_event(unative_t a1, unative_t a2, unative_t a3,
     unative_t a4, unative_t a5, unative_t a6, unative_t id, unative_t rc,
@@ -323,4 +366,12 @@
 }
 
+/** Thread-creation event hook.
+ *
+ * Must be called when a new userspace thread is created in the debugged
+ * task. Generates a THREAD_B event.
+ *
+ * @param t	Structure of the thread being created. Not locked, as the
+ *		thread is not executing yet.
+ */
 void udebug_thread_b_event(struct thread *t)
 {
@@ -372,4 +423,9 @@
 }
 
+/** Thread-termination event hook.
+ *
+ * Must be called when the current thread is terminating.
+ * Generates a THREAD_E event.
+ */
 void udebug_thread_e_event(void)
 {
@@ -418,6 +474,10 @@
  * Terminate task debugging session.
  *
- * \param ta->udebug.lock must be already locked.
- * \return Zero on success or negative error code.
+ * Gracefully terminates the debugging session for a task. If the debugger
+ * is still waiting for events on some threads, it will receive a
+ * FINISHED event for each of them.
+ *
+ * @param ta	Task structure. ta->udebug.lock must be already locked.
+ * @return	Zero on success or negative error code.
  */
 int udebug_task_cleanup(struct task *ta)
Index: kernel/generic/src/udebug/udebug_ipc.c
===================================================================
--- kernel/generic/src/udebug/udebug_ipc.c	(revision 073c9e61a18eccb87f9fe939f4f206dd9422a55f)
+++ kernel/generic/src/udebug/udebug_ipc.c	(revision 3b8fe85c2724c9334d223f7746537735cb1b95e0)
@@ -34,4 +34,7 @@
  * @file
  * @brief	Udebug IPC message handling.
+ *
+ * This module handles udebug IPC messages and calls the appropriate
+ * functions from the udebug_ops module which implement them.
  */
  
Index: kernel/generic/src/udebug/udebug_ops.c
===================================================================
--- kernel/generic/src/udebug/udebug_ops.c	(revision 073c9e61a18eccb87f9fe939f4f206dd9422a55f)
+++ kernel/generic/src/udebug/udebug_ops.c	(revision 3b8fe85c2724c9334d223f7746537735cb1b95e0)
@@ -34,4 +34,8 @@
  * @file
  * @brief	Udebug operations.
+ *
+ * Udebug operations on tasks and threads are implemented here. The
+ * functions defined here are called from the udebug_ipc module
+ * when servicing udebug IPC messages.
  */
  
@@ -66,4 +70,7 @@
  * the t->lock spinlock to the t->udebug.lock mutex.
  *
+ * @param t		Pointer, need not at all be valid.
+ * @param having_go	Required thread state.
+ *
  * Returns EOK if all went well, or an error code otherwise.
  */
@@ -147,5 +154,5 @@
 }
 
-
+/** End debugging operation on a thread. */
 static void _thread_op_end(thread_t *t)
 {
@@ -153,6 +160,17 @@
 }
 
-/**
- * \return 0 (ok, but not done yet), 1 (done) or negative error code.
+/** Begin debugging the current task.
+ *
+ * Initiates a debugging session for the current task (and its threads).
+ * When the debugging session has started a reply will be sent to the
+ * UDEBUG_BEGIN call. This may happen immediately in this function if
+ * all the threads in this task are stoppable at the moment and in this
+ * case the function returns 1.
+ *
+ * Otherwise the function returns 0 and the reply will be sent as soon as
+ * all the threads become stoppable (i.e. they can be considered stopped).
+ *
+ * @param call	The BEGIN call we are servicing.
+ * @return 	0 (OK, but not done yet), 1 (done) or negative error code.
  */
 int udebug_begin(call_t *call)
@@ -206,4 +224,9 @@
 }
 
+/** Finish debugging the current task.
+ *
+ * Closes the debugging session for the current task.
+ * @return Zero on success or negative error code.
+ */
 int udebug_end(void)
 {
@@ -222,4 +245,11 @@
 }
 
+/** Set the event mask.
+ *
+ * Sets the event mask that determines which events are enabled.
+ *
+ * @param mask	Or combination of events that should be enabled.
+ * @return	Zero on success or negative error code.
+ */
 int udebug_set_evmask(udebug_evmask_t mask)
 {
@@ -242,5 +272,13 @@
 }
 
-
+/** Give thread GO.
+ *
+ * Upon recieving a go message, the thread is given GO. Having GO
+ * means the thread is allowed to execute userspace code (until
+ * a debugging event or STOP occurs, at which point the thread loses GO.
+ *
+ * @param t	The thread to operate on (unlocked and need not be valid).
+ * @param call	The GO call that we are servicing.
+ */
 int udebug_go(thread_t *t, call_t *call)
 {
@@ -267,4 +305,12 @@
 }
 
+/** Stop a thread (i.e. take its GO away)
+ *
+ * Generates a STOP event as soon as the thread becomes stoppable (i.e.
+ * can be considered stopped).
+ *
+ * @param t	The thread to operate on (unlocked and need not be valid).
+ * @param call	The GO call that we are servicing.
+ */
 int udebug_stop(thread_t *t, call_t *call)
 {
@@ -316,4 +362,23 @@
 }
 
+/** Read the list of userspace threads in the current task.
+ *
+ * The list takes the form of a sequence of thread hashes (i.e. the pointers
+ * to thread structures). A buffer of size @a buf_size is allocated and
+ * a pointer to it written to @a buffer. The sequence of hashes is written
+ * into this buffer.
+ *
+ * If the sequence is longer than @a buf_size bytes, only as much hashes
+ * as can fit are copied. The number of thread hashes copied is stored
+ * in @a n.
+ *
+ * The rationale for having @a buf_size is that this function is only
+ * used for servicing the THREAD_READ message, which always specifies
+ * a maximum size for the userspace buffer.
+ *
+ * @param buffer	The buffer for storing thread hashes.
+ * @param buf_size	Buffer size in bytes.
+ * @param n		The actual number of hashes copied will be stored here.
+ */
 int udebug_thread_read(void **buffer, size_t buf_size, size_t *n)
 {
@@ -377,4 +442,16 @@
 }
 
+/** Read the arguments of a system call.
+ *
+ * The arguments of the system call being being executed are copied
+ * to an allocated buffer and a pointer to it is written to @a buffer.
+ * The size of the buffer is exactly such that it can hold the maximum number
+ * of system-call arguments.
+ *
+ * Unless the thread is currently blocked in a SYSCALL_B or SYSCALL_E event,
+ * this function will fail with an EINVAL error code.
+ *
+ * @param buffer	The buffer for storing thread hashes.
+ */
 int udebug_args_read(thread_t *t, void **buffer)
 {
@@ -407,4 +484,14 @@
 }
 
+/** Read the memory of the debugged task.
+ *
+ * Reads @a n bytes from the address space of the debugged task, starting
+ * from @a uspace_addr. The bytes are copied into an allocated buffer
+ * and a pointer to it is written into @a buffer.
+ *
+ * @param uspace_addr	Address from where to start reading.
+ * @param n		Number of bytes to read.
+ * @param buffer	For storing a pointer to the allocated buffer.
+ */
 int udebug_mem_read(unative_t uspace_addr, size_t n, void **buffer)
 {
