*reg_list_size = x86_32->cache->num_regs;
LOG_DEBUG("num_regs=%d, reg_class=%d", (*reg_list_size), reg_class);
*reg_list = malloc(sizeof(struct reg *) * (*reg_list_size));
*reg_list_size = x86_32->cache->num_regs;
LOG_DEBUG("num_regs=%d, reg_class=%d", (*reg_list_size), reg_class);
*reg_list = malloc(sizeof(struct reg *) * (*reg_list_size));
x86_32->num_hw_bpoints = MAX_DEBUG_REGS;
x86_32->hw_break_list = calloc(x86_32->num_hw_bpoints,
sizeof(struct x86_32_dbg_reg));
x86_32->num_hw_bpoints = MAX_DEBUG_REGS;
x86_32->hw_break_list = calloc(x86_32->num_hw_bpoints,
sizeof(struct x86_32_dbg_reg));
if (iter->physaddr >= phys_address && iter->physaddr < phys_address+(size*count)) {
uint32_t offset = iter->physaddr - phys_address;
buffer[offset] = iter->orig_byte;
if (iter->physaddr >= phys_address && iter->physaddr < phys_address+(size*count)) {
uint32_t offset = iter->physaddr - phys_address;
buffer[offset] = iter->orig_byte;
}
/* TODO: After reading memory from target, we must replace
* software breakpoints with the original instructions again.
}
/* TODO: After reading memory from target, we must replace
* software breakpoints with the original instructions again.
LOG_ERROR("%s out of memory", __func__);
return ERROR_FAIL;
}
memcpy(newbuffer, buffer, size*count);
struct swbp_mem_patch *iter = x86_32->swbbp_mem_patch_list;
LOG_ERROR("%s out of memory", __func__);
return ERROR_FAIL;
}
memcpy(newbuffer, buffer, size*count);
struct swbp_mem_patch *iter = x86_32->swbbp_mem_patch_list;
if (iter->physaddr >= phys_address && iter->physaddr < phys_address+(size*count)) {
uint32_t offset = iter->physaddr - phys_address;
newbuffer[offset] = SW_BP_OPCODE;
/* update the breakpoint */
struct breakpoint *pbiter = t->breakpoints;
if (iter->physaddr >= phys_address && iter->physaddr < phys_address+(size*count)) {
uint32_t offset = iter->physaddr - phys_address;
newbuffer[offset] = SW_BP_OPCODE;
/* update the breakpoint */
struct breakpoint *pbiter = t->breakpoints;
/* read_hw_reg() will write to 4 bytes (uint32_t)
* Watch out, the buffer passed into read_mem() might be 1 or 2 bytes.
*/
/* read_hw_reg() will write to 4 bytes (uint32_t)
* Watch out, the buffer passed into read_mem() might be 1 or 2 bytes.
*/
retval = x86_32->transaction_status(t);
if (retval != ERROR_OK) {
LOG_ERROR("%s error on mem write", __func__);
retval = x86_32->transaction_status(t);
if (retval != ERROR_OK) {
LOG_ERROR("%s error on mem write", __func__);
uint32_t pdpt_base = cr3 & 0xFFFFF000; /* lower 12 bits of CR3 must always be 0 */
uint32_t pdpt_index = (addr & 0xC0000000) >> 30; /* A[31:30] index to PDPT */
uint32_t pdpt_addr = pdpt_base + (8 * pdpt_index);
uint32_t pdpt_base = cr3 & 0xFFFFF000; /* lower 12 bits of CR3 must always be 0 */
uint32_t pdpt_index = (addr & 0xC0000000) >> 30; /* A[31:30] index to PDPT */
uint32_t pdpt_addr = pdpt_base + (8 * pdpt_index);
&& x86_32_common_read_phys_mem(t, physaddr, size, count, buf) != ERROR_OK) {
LOG_ERROR("%s failed to read memory from physical address " TARGET_ADDR_FMT,
__func__, physaddr);
&& x86_32_common_read_phys_mem(t, physaddr, size, count, buf) != ERROR_OK) {
LOG_ERROR("%s failed to read memory from physical address " TARGET_ADDR_FMT,
__func__, physaddr);
}
/* restore PG bit if it was cleared prior (regardless of retval) */
retval = x86_32->enable_paging(t);
}
/* restore PG bit if it was cleared prior (regardless of retval) */
retval = x86_32->enable_paging(t);
&& x86_32_common_write_phys_mem(t, physaddr, size, count, buf) != ERROR_OK) {
LOG_ERROR("%s failed to write memory to physical address " TARGET_ADDR_FMT,
__func__, physaddr);
&& x86_32_common_write_phys_mem(t, physaddr, size, count, buf) != ERROR_OK) {
LOG_ERROR("%s failed to write memory to physical address " TARGET_ADDR_FMT,
__func__, physaddr);
}
/* restore PG bit if it was cleared prior (regardless of retval) */
retval = x86_32->enable_paging(t);
}
/* restore PG bit if it was cleared prior (regardless of retval) */
retval = x86_32->enable_paging(t);
uint32_t regval = 0;
retval = x86_32->read_hw_reg(t, EAX, ®val, 0);
if (retval != ERROR_OK) {
uint32_t regval = 0;
retval = x86_32->read_hw_reg(t, EAX, ®val, 0);
if (retval != ERROR_OK) {
retval = x86_32->transaction_status(t);
if (retval != ERROR_OK) {
LOG_ERROR("%s error on io write", __func__);
retval = x86_32->transaction_status(t);
if (retval != ERROR_OK) {
LOG_ERROR("%s error on io write", __func__);
* when we exit PM
*/
buf_set_u32(x86_32->cache->reg_list[bp_num+DR0].value, 0, 32, address);
* when we exit PM
*/
buf_set_u32(x86_32->cache->reg_list[bp_num+DR0].value, 0, 32, address);
buf_set_u32(x86_32->cache->reg_list[DR6].value, 0, 32, PM_DR6);
buf_set_u32(x86_32->cache->reg_list[DR6].value, 0, 32, PM_DR6);
buf_set_u32(x86_32->cache->reg_list[DR7].value, 0, 32, dr7);
buf_set_u32(x86_32->cache->reg_list[DR7].value, 0, 32, dr7);
* when we exit PM
*/
buf_set_u32(x86_32->cache->reg_list[bp_num+DR0].value, 0, 32, 0);
* when we exit PM
*/
buf_set_u32(x86_32->cache->reg_list[bp_num+DR0].value, 0, 32, 0);
buf_set_u32(x86_32->cache->reg_list[DR6].value, 0, 32, PM_DR6);
buf_set_u32(x86_32->cache->reg_list[DR6].value, 0, 32, PM_DR6);
buf_set_u32(x86_32->cache->reg_list[DR7].value, 0, 32, dr7);
buf_set_u32(x86_32->cache->reg_list[DR7].value, 0, 32, dr7);
new_patch->swbp_unique_id = bp->unique_id;
struct swbp_mem_patch *addto = x86_32->swbbp_mem_patch_list;
new_patch->swbp_unique_id = bp->unique_id;
struct swbp_mem_patch *addto = x86_32->swbbp_mem_patch_list;
if (iter->swbp_unique_id == bp->unique_id) {
/* it's the first item */
x86_32->swbbp_mem_patch_list = iter->next;
free(iter);
} else {
if (iter->swbp_unique_id == bp->unique_id) {
/* it's the first item */
x86_32->swbbp_mem_patch_list = iter->next;
free(iter);
} else {
struct target *target, uint32_t address, unsigned size,
unsigned count, const uint8_t *buffer)
{
struct target *target, uint32_t address, unsigned size,
unsigned count, const uint8_t *buffer)
{
uint8_t *buffer = calloc(count, size);
struct target *target = get_current_target(CMD_CTX);
int retval = x86_32_common_read_io(target, address, size, buffer);
uint8_t *buffer = calloc(count, size);
struct target *target = get_current_target(CMD_CTX);
int retval = x86_32_common_read_io(target, address, size, buffer);
- if (ERROR_OK == retval)
- handle_iod_output(CMD_CTX, target, address, size, count, buffer);
+ if (retval == ERROR_OK)
+ handle_iod_output(CMD, target, address, size, count, buffer);