From 944fe66f104e356c5fcd2b5c25200cebef9b389c Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Thu, 14 Sep 2023 12:10:45 -0700 Subject: [PATCH] server/gdb_server: Step unavailable targets. When gdb requests to step an unavailable target, report success. When the target becomes available, the step can complete. Change-Id: I969ab56139f72a757552928d59edf6eabd598fa4 Signed-off-by: Tim Newsome --- src/server/gdb_server.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 41a47bf3c..795f141eb 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -3176,9 +3176,15 @@ static bool gdb_handle_vcont_packet(struct connection *connection, const char *p return true; } - retval = target_step(ct, current_pc, 0, 0); - if (retval == ERROR_TARGET_NOT_HALTED) - LOG_INFO("target %s was not halted when step was requested", target_name(ct)); + if (ct->state == TARGET_UNAVAILABLE) { + LOG_TARGET_ERROR(ct, "Target is unavailable, so cannot be stepped. " + "Pretending to gdb that it is running until it's available again."); + retval = ERROR_FAIL; + } else { + retval = target_step(ct, current_pc, 0, 0); + if (retval == ERROR_TARGET_NOT_HALTED) + LOG_INFO("target %s was not halted when step was requested", target_name(ct)); + } /* if step was successful send a reply back to gdb */ if (retval == ERROR_OK) {