37,6 → 37,8 |
#include <sys/types.h> |
#include <udebug.h> |
|
#include <kernel/arch/context_offset.h> |
|
#include "../../../cons.h" |
#include "../../../main.h" |
#include "../../../include/arch.h" |
72,7 → 74,7 |
brk->set = 1; |
} |
|
static unsigned buffer[1024]; |
static istate_t istate; |
static breakpoint_t *lifted_brkpt; |
|
void arch_event_breakpoint(thash_t thread_hash) |
79,10 → 81,10 |
{ |
int rc; |
|
rc = udebug_regs_read(app_phone, thread_hash, buffer); |
rc = udebug_regs_read(app_phone, thread_hash, &istate); |
cons_printf("udebug_regs_read -> %d\n", rc); |
cons_printf("EIP was 0x%08x\n", buffer[ISTATE_OFF_EIP]); |
int brk_addr = buffer[ISTATE_OFF_EIP] - 1; |
cons_printf("EIP was 0x%08x\n", istate.eip); |
int brk_addr = istate.eip - 1; |
int bi; |
for (bi = 0; bi < MAX_BRKPTS; bi++) { |
if (brk_list[bi].set && brk_list[bi].addr == brk_addr) |
93,10 → 95,10 |
cons_printf("breakpoint %d hit\n", bi); |
breakpoint_hit(); |
|
buffer[ISTATE_OFF_EIP] = brk_addr; |
buffer[ISTATE_OFF_EFLAGS] |= 0x0100; /* trap flag */ |
cons_printf("setting EIP to 0x%08x\n", buffer[ISTATE_OFF_EIP]); |
rc = udebug_regs_write(app_phone, thread_hash, buffer); |
istate.eip = brk_addr; |
istate.eflags |= 0x0100; /* trap flag */ |
cons_printf("setting EIP to 0x%08x\n", istate.eip); |
rc = udebug_regs_write(app_phone, thread_hash, &istate); |
rc = udebug_mem_write(app_phone, &brk_list[bi].arch.back, brk_addr, 1); |
cons_printf("udebug_mem_write(phone, 0x%x, 0x%02x, 1) -> %d\n", brk_addr, brk_list[bi].arch.back, rc); |
lifted_brkpt = &brk_list[bi]; |
117,11 → 119,28 |
rc = udebug_mem_write(app_phone, brkinstr, lb->addr, 1); |
cons_printf("restore breakpoint -> %d\n", rc); |
|
rc = udebug_regs_read(app_phone, thread_hash, buffer); |
rc = udebug_regs_read(app_phone, thread_hash, &istate); |
cons_printf("udebug_regs_read -> %d\n", rc); |
buffer[ISTATE_OFF_EFLAGS] &= ~0x0100; /* trap flag */ |
rc = udebug_regs_write(app_phone, thread_hash, buffer); |
istate.eflags &= ~0x0100; /* trap flag */ |
rc = udebug_regs_write(app_phone, thread_hash, &istate); |
} |
|
void arch_dump_regs(thash_t thash) |
{ |
int rc; |
|
printf("arch_dump_regs...\n"); |
|
rc = udebug_regs_read(app_phone, thash, &istate); |
if (rc < 0) { cons_printf("Error reading regs\n"); return; } |
|
cons_printf( |
"eip:%08x eflags:%08x eax:%08x ebx:%08x ecx:%08x edx:%08x\n" |
"esi:%08x edi:%08x cs:%04x ds:%04x es:%04x fs:%04x gs:%04x\n", |
istate.eip, istate.eflags, istate.eax, istate.ebx, |
istate.ecx, istate.edx, istate.esi, istate.edi, istate.cs, |
istate.ds, istate.es, istate.fs, istate.gs); |
} |
|
/** @} |
*/ |