Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2786 → Rev 2787

/branches/tracing/kernel/arch/ia32/src/tdebug.c
0,0 → 1,51
/** @addtogroup ia32
* @{
*/
/** @file
*/
 
#include <proc/thread.h>
#include <console/klog.h>
#include <arch/tdebug.h>
 
/* trap flag */
#define EFLAGS_TF 0x100
 
/**
* Called when the IAFTER event setting is (potentially) changed.
*
* On this arch the TRAP flag in userspace state is set
* according to the setting of TDEBUG_EVMASK_IAFTER
* in order to stop after the execution of each instruction.
*
* The calling thread must have already locked t.
*
* Returns 0 on success, non-zero on failure. (Mainly if IAFTER is set, but
* architecture does not support it.)
*/
int tdebug_iafter_update(thread_t *t)
{
uint32_t eflags;
 
if (t->tdebug.uspace_state == NULL) {
/* userspace state is not available */
/* FIXME: this should not happen when properly imlemented */
klog_printf("fail: uspace_state not available\n");
return -1;
}
 
eflags = t->tdebug.uspace_state->eflags;
 
if ((t->tdebug.event_mask & TDEBUG_EVMASK_IAFTER) != 0) {
eflags = eflags | EFLAGS_TF;
} else {
eflags = eflags & ~EFLAGS_TF;
}
 
t->tdebug.uspace_state->eflags = eflags;
return 0;
}
 
 
/** @}
*/