/** @addtogroup generic
 * @{
 */

/**
 * @file
 * @brief	Tdebug.
 */
 
#include <synch/waitq.h>
#include <console/klog.h>
#include <udebug.h>
#include <arch.h>

void udebug_stopping_point(void)
{
	if (TASK->stop_request) { /* locking! */
		klog_printf("udebug_stopping_point");
		IPC_SET_RETVAL(TASK->debug_begin_call->data, 0);
		ipc_answer(&TASK->answerbox, TASK->debug_begin_call);
		TASK->stop_request = false;
		TASK->debug_begin_call = NULL;
		waitq_sleep(&THREAD->go_wq);
	}
}

void udebug_syscall_event(void)
{
	/* being debugged + have go */
	if (TASK->being_debugged && !TASK->stop_request) { /* locking! */
		klog_printf("udebug_syscall_event");
		IPC_SET_RETVAL(TASK->debug_go_call->data, 0);
		ipc_answer(&TASK->answerbox, TASK->debug_go_call);
		waitq_sleep(&THREAD->go_wq);
	}
}

/** @}
 */
