35,7 → 35,6 |
#include <stdio.h> |
#include <stdlib.h> |
#include <sys/types.h> |
#include <bool.h> |
#include <udebug.h> |
|
#include <kernel/arch/context_offset.h> |
46,23 → 45,6 |
|
#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]; |
146,10 → 128,15 |
active_bkpt = NULL; |
} |
|
rc = _set_trap_flag(dt, false); |
dt->arch.singlestep = false; |
|
singlestep_hit(); |
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(); |
} |
} |
|
void arch_dump_regs(thash_t thash) |
168,14 → 155,21 |
istate.ds, istate.es, istate.fs, istate.gs); |
} |
|
void arch_singlestep(dthread_t *dt) |
void arch_set_singlestep(dthread_t *dt, int enable) |
{ |
static istate_t istate; |
int rc; |
|
rc = _set_trap_flag(dt, true); |
if (rc != 0) return; |
rc = udebug_regs_read(app_phone, dt->hash, &istate); |
if (rc < 0) { printf("regs read failed\n"); return; } |
|
dthread_resume(dt); |
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; |
} |
|
/** @} |