From 65ac07441056c6f99c0f57dbee08cf1834775e5e Mon Sep 17 00:00:00 2001 From: dragonmux Date: Wed, 20 Jul 2022 05:33:40 +0100 Subject: [PATCH] gdb_main: Implemented vKill as it's required for GDB 11+ --- src/gdb_main.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/gdb_main.c b/src/gdb_main.c index 591c91f6..23b9b605 100644 --- a/src/gdb_main.c +++ b/src/gdb_main.c @@ -62,6 +62,7 @@ static target *last_target; static void handle_q_packet(char *packet, size_t len); static void handle_v_packet(char *packet, size_t len); static void handle_z_packet(char *packet, size_t len); +static void handle_kill_target(void); static void gdb_target_destroy_callback(struct target_controller *tc, target *t) { @@ -285,12 +286,7 @@ int gdb_main_loop(struct target_controller *tc, bool in_syscall) break; case 'k': /* Kill the target */ - if(cur_target) { - target_reset(cur_target); - target_detach(cur_target); - last_target = cur_target; - cur_target = NULL; - } + handle_kill_target(); break; case 'r': /* Reset the target system */ @@ -483,6 +479,16 @@ static const cmd_executer q_commands[]= {NULL, NULL}, }; +static void handle_kill_target(void) +{ + if (cur_target) { + target_reset(cur_target); + target_detach(cur_target); + last_target = cur_target; + cur_target = NULL; + } +} + static void handle_q_packet(char *packet, const size_t length) { if (exec_command(packet, length, q_commands)) @@ -516,6 +522,11 @@ static void handle_v_packet(char *packet, const size_t plen) } else gdb_putpacketz("E01"); + } else if (!strncmp(packet, "vKill;", 6)) { + /* Kill the target - we don't actually care about the PID that follows "vKill;" */ + handle_kill_target(); + gdb_putpacketz("OK"); + } else if (!strncmp(packet, "vRun", 4)) { /* Parse command line for get_cmdline semihosting call */ char cmdline[83];