I got some pointers from Michael Bruck in email and was
able to put together the attached patch w/single stepping
support for arm11 hardware that does not support single
stepping in hardware, e.g. i.MX31.
Are there any downsides to always simulating the instruction
to calculate next PC and using that as a breakpoint, as oposed
to using the hardware single stepping capability?
Objections?
Comments?
--
Øyvind Harboe
Embedded software and hardware consulting services
http://www.zylin.com
### Eclipse Workspace Patch 1.0
#P openocd
Index: src/target/arm11.c
===================================================================
--- src/target/arm11.c (revision 2642)
+++ src/target/arm11.c (working copy)
@@ -976,7 +976,6 @@
int arm11_step(struct target_s *target, int current, uint32_t address, int
handle_breakpoints)
{
FNC_INFO;
- int retval;
LOG_DEBUG("target->state: %s",
target_state_name(target));
@@ -995,15 +994,6 @@
LOG_DEBUG("STEP PC %08" PRIx32 "%s", R(PC), !current ? "!" : "");
- /* TODO: to implement single stepping on arm11 devices that can't
- * do single stepping in hardware we need to calculate the next
- * pc and set up breakpoints accordingingly. */
- uint32_t next_pc;
- retval = arm11_simulate_step(target, &next_pc);
- if (retval != ERROR_OK)
- return retval;
-
-
/** \todo TODO: Thumb not supported here */
uint32_t next_instruction;
@@ -1040,6 +1030,12 @@
/** \todo TODO: check if disabling IRQs might be a good idea
here. Alternatively
* the VCR might be something worth looking into. */
+ int retval;
+ uint32_t next_pc;
+ retval = arm11_simulate_step(target, &next_pc);
+ if (retval != ERROR_OK)
+ return retval;
+
/* Set up breakpoint for stepping */
@@ -1047,10 +1043,20 @@
brp[0].write = 1;
brp[0].address = ARM11_SC7_BVR0;
- brp[0].value = R(PC);
+ brp[0].value = next_pc;
brp[1].write = 1;
brp[1].address = ARM11_SC7_BCR0;
- brp[1].value = 0x1 | (3 << 1) | (0x0F << 5) | (0 << 14) | (0
<< 16) | (0 << 20) | (2 << 21);
+ brp[1].value = 0x1 | (3 << 1) | (0x0F << 5) | (0 << 14) | (0
<< 16) | (0 << 20) | (0 << 21);
+
+ /* The above code sets a breakpoint on the next PC(calculated
by simulation),
+ * whereas the code in this comment uses the hardware to
perform the single stepping.
+ *
+ * Should hardware single stepping be used if possible or is it
better to
+ * always use the same code path?
+ *
+ * brp[0].value = R(PC);
+ * brp[1].value = 0x1 | (3 << 1) | (0x0F << 5) | (0 << 14) | (0
<< 16) | (0 << 20) | (2 << 21);
+ */
CHECK_RETVAL(arm11_sc7_run(arm11, brp, asizeof(brp)));
@@ -1102,11 +1108,6 @@
CHECK_RETVAL(target_call_event_callbacks(target, TARGET_EVENT_HALTED));
- if (R(PC) != next_pc)
- {
- LOG_WARNING("next pc != simulated address %08" PRIx32 "!=%08"
PRIx32, R(PC), next_pc);
- }
-
return ERROR_OK;
}
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development