Skip to content

Commit

Permalink
GDBServer: use hook callback for step() to check for gdb interrupt.
Browse files Browse the repository at this point in the history
  • Loading branch information
flit committed Sep 25, 2020
1 parent 5cf0255 commit a403b1d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions pyocd/gdbserver/gdbserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,22 @@ def resume(self, data):
def step(self, data, start=0, end=0):
addr = self._get_resume_step_addr(data)
LOG.debug("GDB step: %s (start=0x%x, end=0x%x)", data, start, end)
self.target.step(not self.step_into_interrupt, start, end)
return self.create_rsp_packet(self.get_t_response())

# Use the step hook to check for an interrupt event.
def step_hook():
# Note we don't clear the interrupt event here!
return self.packet_io.interrupt_event.is_set()
self.target.step(not self.step_into_interrupt, start, end, hook_cb=step_hook)

# Clear and handle an interrupt.
if self.packet_io.interrupt_event.is_set():
LOG.debug("Received Ctrl-C during step")
self.packet_io.interrupt_event.clear()
response = self.get_t_response(forceSignal=signals.SIGINT)
else:
response = self.get_t_response()

return self.create_rsp_packet(response)

def halt(self):
self.target.halt()
Expand Down

0 comments on commit a403b1d

Please sign in to comment.