Skip to content

Commit

Permalink
Merge pull request #979 from flit/bugfix/gdbserver_range_step
Browse files Browse the repository at this point in the history
Fix interrupting gdbserver range step
  • Loading branch information
flit committed Oct 12, 2020
1 parent 1a44970 commit dabc470
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 5 additions & 3 deletions pyocd/coresight/cortex_m.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ def step(self, disable_interrupts=True, start=0, end=0, hook_cb=None):
# Get the step timeout. A timeout of 0 means no timeout, so we have to pass None to the Timeout class.
step_timeout = self.session.options.get('cpu.step.instruction.timeout') or None

exit_step_loop = False
while True:
# Single step using current C_MASKINTS setting
self.write32(CortexM.DHCSR, dhcsr_step)
Expand All @@ -550,14 +551,15 @@ def step(self, disable_interrupts=True, start=0, end=0, hook_cb=None):
# for Privileged code in the case of UDE.
with timeout.Timeout(step_timeout) as tmo:
while tmo.check():
if (self.read32(CortexM.DHCSR) & CortexM.C_HALT) != 0:
break
# Invoke the callback if provided. If it returns True, then exit the loop.
if (hook_cb is not None) and hook_cb():
exit_step_loop = True
break
if (self.read32(CortexM.DHCSR) & CortexM.C_HALT) != 0:
break

# Range is empty, 'range step' will degenerate to 'step'
if start == end:
if (start == end) or exit_step_loop:
break

# Read program counter and compare to [start, end)
Expand Down
3 changes: 1 addition & 2 deletions pyocd/gdbserver/gdbserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def handle_message(self, msg):
reply = handler(msg[msgStart:])
self.lock.release()

detach = 1 if msg[1:2] in self.DETACH_COMMANDS else 0
detach = msg[1:2] in self.DETACH_COMMANDS
return reply, detach

except Exception as e:
Expand All @@ -441,7 +441,6 @@ def kill(self):
if not self.persist:
self.board.target.set_vector_catch(Target.VectorCatch.NONE)
self.board.target.resume()
return self.create_rsp_packet(b"")

def restart(self, data):
self.target.reset_and_halt()
Expand Down

0 comments on commit dabc470

Please sign in to comment.