From fc55400aad8f71ee353de4157ed3c28034685d02 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Wed, 20 Jul 2022 23:23:04 +0100 Subject: [PATCH] gdb_main: Implemented a notification to GDB that the "process" has exited when the user runs a new bus scan while attached to a target --- src/gdb_main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gdb_main.c b/src/gdb_main.c index 4f64fd49..bd17ae95 100644 --- a/src/gdb_main.c +++ b/src/gdb_main.c @@ -58,6 +58,7 @@ static char pbuf[BUF_SIZE + 1U]; static target *cur_target; static target *last_target; +static bool gdb_needs_detach_notify = false; static void handle_q_packet(char *packet, size_t len); static void handle_v_packet(char *packet, size_t len); @@ -68,8 +69,10 @@ static void gdb_target_destroy_callback(struct target_controller *tc, target *t) { (void)tc; if (cur_target == t) { + gdb_put_notificationz("%Stop:W00"); gdb_out("You are now detached from the previous target.\n"); cur_target = NULL; + gdb_needs_detach_notify = true; } if (last_target == t) @@ -635,6 +638,13 @@ static void handle_v_packet(char *packet, const size_t plen) gdb_putpacketz(target_flash_done(cur_target) ? "EFF" : "OK"); flash_mode = 0; + } else if (!strcmp(packet, "vStopped")) { + if (gdb_needs_detach_notify) { + gdb_putpacketz("W00"); + gdb_needs_detach_notify = false; + } else + gdb_putpacketz("OK"); + } else { DEBUG_GDB("*** Unsupported packet: %s\n", packet); gdb_putpacket("", 0);