This is an automated email from Gerrit. "Tomas Vanek <van...@fbl.cz>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8915
-- gerrit commit 3d233d5b846e067e0c655878b672bfc5cf8cad6b Author: Tim Newsome <t...@sifive.com> Date: Thu Sep 14 14:07:19 2023 -0700 server/gdb_server: Fake resuming unavailable targets. When asked to resume an unavailable target, resume any available targets and report success. Imported from https://github.com/riscv-collab/riscv-openocd/pull/927 Change-Id: Ieafc63794c1a6eba8948c0f9ce84fa74f9765041 Signed-off-by: Tim Newsome <t...@sifive.com> diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index d242dbc3a8..ef94b4cf0d 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -3021,7 +3021,7 @@ static bool gdb_handle_vcont_packet(struct connection *connection, const char *p __attribute__((unused)) int packet_size) { struct gdb_connection *gdb_connection = connection->priv; - struct target *target = get_available_target_from_connection(connection); + struct target *target = get_target_from_connection(connection); const char *parse = packet; int retval; @@ -3042,6 +3042,24 @@ static bool gdb_handle_vcont_packet(struct connection *connection, const char *p /* simple case, a continue packet */ if (parse[0] == 'c') { gdb_running_type = 'c'; + + if (target->state == TARGET_UNAVAILABLE) { + struct target *available_target = get_available_target_from_connection(connection); + if (target == available_target) { + LOG_DEBUG("All targets for this gdb connection " + "are unavailable. Fake to gdb that the resume " + "succeeded and the target is now running."); + gdb_connection->frontend_state = TARGET_RUNNING; + gdb_connection->output_flag = GDB_OUTPUT_ALL; + target_call_event_callbacks(target, TARGET_EVENT_GDB_START); + return true; + } + LOG_TARGET_DEBUG(target, "Target is unavailable. Resume %s instead.", + target_name(available_target)); + /* Resume an available target. */ + target = available_target; + } + LOG_TARGET_DEBUG(target, "target continue"); gdb_connection->output_flag = GDB_OUTPUT_ALL; retval = target_resume(target, true, 0, false, false); --