From 2bbe425b1bbf8f4abc01c584a0033f921de4a780 Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Fri, 16 Dec 2022 15:15:10 -0600 Subject: Fix graceful gdb detach --- sim/gdbstub.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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)) -- cgit v1.2.3