Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3092 → Rev 3093

/branches/tracing/uspace/app/debug/arch/ia32/src/ia32.c
35,6 → 35,7
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <bool.h>
#include <udebug.h>
 
#include <kernel/arch/context_offset.h>
45,6 → 46,23
 
#define OPCODE_INT3 0xCC
 
static int _set_trap_flag(dthread_t *dt, bool enable)
{
static istate_t istate;
int rc;
 
rc = udebug_regs_read(app_phone, dt->hash, &istate);
if (rc < 0) { printf("regs read failed\n"); return; }
 
if (enable) istate.eflags |= 0x0100; /* trap flag */
else if (!active_bkpt) istate.eflags &= ~0x0100; /* trap flag */
 
rc = udebug_regs_write(app_phone, dt->hash, &istate);
if (rc < 0) { printf("regs write failed\n"); return; }
 
return 0;
}
 
int arch_breakpoint_set(breakpoint_t *b)
{
char brkp[1];
128,15 → 146,10
active_bkpt = NULL;
}
 
if (!dt->arch.singlestep) {
rc = udebug_regs_read(app_phone, dt->hash, &istate);
// cons_printf("udebug_regs_read -> %d\n", rc);
istate.eflags &= ~0x0100; /* trap flag */
rc = udebug_regs_write(app_phone, dt->hash, &istate);
} else {
// printf("ss-hit\n");
singlestep_hit();
}
rc = _set_trap_flag(dt, false);
dt->arch.singlestep = false;
 
singlestep_hit();
}
 
void arch_dump_regs(thash_t thash)
155,21 → 168,14
istate.ds, istate.es, istate.fs, istate.gs);
}
 
void arch_set_singlestep(dthread_t *dt, int enable)
void arch_singlestep(dthread_t *dt)
{
static istate_t istate;
int rc;
 
rc = udebug_regs_read(app_phone, dt->hash, &istate);
if (rc < 0) { printf("regs read failed\n"); return; }
rc = _set_trap_flag(dt, true);
if (rc != 0) return;
 
if (enable) istate.eflags |= 0x0100; /* trap flag */
else if (!active_bkpt) istate.eflags &= ~0x0100; /* trap flag */
 
rc = udebug_regs_write(app_phone, dt->hash, &istate);
if (rc < 0) { printf("regs write failed\n"); return; }
 
dt->arch.singlestep = enable;
dthread_resume(dt);
}
 
/** @}