Browse Source

cortex_m3: add BKPT_TYPE_BY_ADDR define

Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
tags/v0.5.0-rc1
Peter Horn 12 years ago
committed by Spencer Oliver
parent
commit
e53f7e5fc0
1 changed files with 22 additions and 14 deletions
  1. +22
    -14
      src/target/cortex_m3.c

+ 22
- 14
src/target/cortex_m3.c View File

@@ -51,6 +51,11 @@
* any longer. * any longer.
*/ */


/**
* Returns the type of a break point required by address location
*/
#define BKPT_TYPE_BY_ADDR(addr) ((addr) < 0x20000000 ? BKPT_HARD : BKPT_SOFT)



/* forward declarations */ /* forward declarations */
static int cortex_m3_set_breakpoint(struct target *target, struct breakpoint *breakpoint); static int cortex_m3_set_breakpoint(struct target *target, struct breakpoint *breakpoint);
@@ -864,10 +869,11 @@ static int cortex_m3_step(struct target *target, int current,
if (!current) if (!current)
buf_set_u32(pc->value, 0, 32, address); buf_set_u32(pc->value, 0, 32, address);


uint32_t pc_value = buf_get_u32(pc->value, 0, 32);

/* the front-end may request us not to handle breakpoints */ /* the front-end may request us not to handle breakpoints */
if (handle_breakpoints) { if (handle_breakpoints) {
breakpoint = breakpoint_find(target,
buf_get_u32(pc->value, 0, 32));
breakpoint = breakpoint_find(target, pc_value);
if (breakpoint) if (breakpoint)
cortex_m3_unset_breakpoint(target, breakpoint); cortex_m3_unset_breakpoint(target, breakpoint);
} }
@@ -1071,7 +1077,7 @@ cortex_m3_set_breakpoint(struct target *target, struct breakpoint *breakpoint)


if (cortex_m3->auto_bp_type) if (cortex_m3->auto_bp_type)
{ {
breakpoint->type = (breakpoint->address < 0x20000000) ? BKPT_HARD : BKPT_SOFT;
breakpoint->type = BKPT_TYPE_BY_ADDR(breakpoint->address);
} }


if (breakpoint->type == BKPT_HARD) if (breakpoint->type == BKPT_HARD)
@@ -1191,7 +1197,7 @@ cortex_m3_add_breakpoint(struct target *target, struct breakpoint *breakpoint)


if (cortex_m3->auto_bp_type) if (cortex_m3->auto_bp_type)
{ {
breakpoint->type = (breakpoint->address < 0x20000000) ? BKPT_HARD : BKPT_SOFT;
breakpoint->type = BKPT_TYPE_BY_ADDR(breakpoint->address);
#ifdef ARMV7_GDB_HACKS #ifdef ARMV7_GDB_HACKS
if (breakpoint->length != 2) { if (breakpoint->length != 2) {
/* XXX Hack: Replace all breakpoints with length != 2 with /* XXX Hack: Replace all breakpoints with length != 2 with
@@ -1202,16 +1208,18 @@ cortex_m3_add_breakpoint(struct target *target, struct breakpoint *breakpoint)
#endif #endif
} }


if ((breakpoint->type == BKPT_HARD) && (breakpoint->address >= 0x20000000))
{
LOG_INFO("flash patch comparator requested outside code memory region");
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
if(breakpoint->type != BKPT_TYPE_BY_ADDR(breakpoint->address)) {
if (breakpoint->type == BKPT_HARD)
{
LOG_INFO("flash patch comparator requested outside code memory region");
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}


if ((breakpoint->type == BKPT_SOFT) && (breakpoint->address < 0x20000000))
{
LOG_INFO("soft breakpoint requested in code (flash) memory region");
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
if (breakpoint->type == BKPT_SOFT)
{
LOG_INFO("soft breakpoint requested in code (flash) memory region");
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
} }


if ((breakpoint->type == BKPT_HARD) && (cortex_m3->fp_code_available < 1)) if ((breakpoint->type == BKPT_HARD) && (cortex_m3->fp_code_available < 1))
@@ -1246,7 +1254,7 @@ cortex_m3_remove_breakpoint(struct target *target, struct breakpoint *breakpoint


if (cortex_m3->auto_bp_type) if (cortex_m3->auto_bp_type)
{ {
breakpoint->type = (breakpoint->address < 0x20000000) ? BKPT_HARD : BKPT_SOFT;
breakpoint->type = BKPT_TYPE_BY_ADDR(breakpoint->address);
} }


if (breakpoint->set) if (breakpoint->set)


Loading…
Cancel
Save