summaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2022-12-16 15:15:10 -0600
committerAlejandro Soto <alejandro@34project.org>2022-12-16 22:20:26 -0600
commit2bbe425b1bbf8f4abc01c584a0033f921de4a780 (patch)
tree3b4a61a71f13b0d40a39d3fbc0bd241d203e738b /sim
parent3a675869ed2d73c9b51941f5b1f753e3d345c5e8 (diff)
Fix graceful gdb detach
Diffstat (limited to 'sim')
-rw-r--r--sim/gdbstub.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/sim/gdbstub.py b/sim/gdbstub.py
index 63bef9b..ccddab9 100644
--- a/sim/gdbstub.py
+++ b/sim/gdbstub.py
@@ -55,7 +55,8 @@ def yield_to_gdb():
if sendStop:
reply(stop_reply)
- while True:
+ detached = False
+ while not detached:
data = client.recv(4096)
if not data:
break
@@ -87,6 +88,7 @@ def yield_to_gdb():
return 'continue'
elif data == b'D':
replyout = b'OK'
+ detached = True
elif data == b'g':
replyout = hexout(read_reg(gdb_reg(r)) for r in range(16))
elif data[0] == b'G':
@@ -129,6 +131,10 @@ def yield_to_gdb():
reply(replyout)
+ if detached:
+ client.close()
+ client = None
+
def reply(replyout):
client.send(b'$' + replyout + b'#' + hexout(sum(replyout) & 0xff, size=1))