Step Cortex-M0 from an owned halt. - #76
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
The acquired target can halt and inspect a processor but cannot advance it by one architectural step. Add stepping that returns halted and restores normal halt control before allowing further target calls. The caller controls cancellation and deadlines. Exceptions can alter the execution path; a step need not retire an instruction. Use DFSR to identify competing stops and leave them unowned. Keep pending step state across failures so release can finish an accepted operation without launching it again. An unconfirmed launch remains blocked rather than claiming an uncertain halt or repeating execution.
Add an optional step to the control example and a separately gated bench that checks PC, R0, and RAM after each increment, store, and branch. Verify resume and release after stepping; instruction effects remain part of the running program rather than being rolled back. Two fresh CMSIS-DAP sessions at 1 MHz passed thirteen steps each on the micro:bit. Both restored initially disabled debug and closed their owners. The program disables configurable interrupts, so these results do not establish exception handling, competing debug events, or cleanup after a physical transport failure.
2997736 to
93257b2
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Add
Target.Step(ctx)to advance an acquired Cortex-M0 through one architectural step and return halted, with stepping disabled. It requires a halt owned by that target, preserves competing debug stops, and leaves register access available after success. The control example gains an optional-step.With a borrowed MEM-AP:
Why
The target could halt, inspect registers, and resume, but could not advance execution by a step.
Stepsettles register transfers before launch and waits for a fresh halt. It checks DFSR before and after launch to distinguish the step's halt from breakpoint, watchpoint, vector-catch, or external events, preserving all event flags. Existing competing flags prevent stepping. A competing stop remains unowned and can prevent restoring initially disabled debug.The caller controls cancellation and deadlines. After launch is attempted, failure leaves only
Releaseavailable. Cleanup can finish an accepted step and retry clearing C_STEP while halted, but never launches another step. An unconfirmed launch, ignored request, reset, changed debug control, or observed loss of the completed halt can prevent automatic cleanup.Interrupt masking is unchanged. An architectural step can enter an exception handler or encounter another debug event, so success does not promise instruction retirement. Execution and peripheral effects cannot be undone.
Documentation
Update the Cortex-M guide, capability table, architecture and composition guidance, and control example. The API remains Cortex-M0 only; the guide describes ownership, event flags, failure states, and the hardware procedure.
Hardware evidence
On September 26, 2026, Nostalgia (macOS) ran two fresh CMSIS-DAP micro:bit sessions through SWD at a requested 1 MHz and AP0. Probe serial
9900360140124e4500279015000000360000000097969901; Cortex-M0 CPUID0x410cc200. The test verified the counter firmware's vectors and instructions before acquiring the target.Each session checked twelve consecutive steps through
adds r0, #1,str r0, [r1], and the branch back to the loop. PC, R0, and the RAM counter matched the expected instruction effects after every step. The processor remained halted with stepping disabled between calls, and the counter stayed unchanged across ten samples 20 milliseconds apart after the sequence. Both sessions then resumed, halted, checked a thirteenth step, and released from that halt. Counter progress returned after resume and release. DHCSR was0x01000000before acquisition and after release in both sessions; initially disabled debug and running state were restored. Both target and Arm debug owners closed successfully.The example also completed with
-provider cmsisdap -serial 9900360140124e4500279015000000360000000097969901 -ap 0 -clock 1000000 -allow-control -step, printing PC before and after the step and resuming.Instruction effects were not rolled back. The firmware disables configurable interrupts; exception entry, competing debug events, and failure cleanup are covered only by behavioral tests. Sleeping instructions and state after Arm owner close were not measured.