From: Simon Marchi Date: Mon, 9 Jun 2025 16:09:01 +0000 (-0400) Subject: gdb/amd-dbgapi: factor out require_forward_progress overload to target one inferior X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9e8e5dd74ee49ce03ab0b0dbd33ba6049ce17779;p=thirdparty%2Fbinutils-gdb.git gdb/amd-dbgapi: factor out require_forward_progress overload to target one inferior A following patch will want to call require_forward_progress for a given inferior. Extract a new require_forward_progress overload from the existing require_forward_progress function that targets a specific inferior. Change-Id: I54f42b83eb8443d4d91747ffbc86eaeb017f1e49 Approved-by: Lancelot Six --- diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c index 819ff201423..fd4f9cba48a 100644 --- a/gdb/amd-dbgapi-target.c +++ b/gdb/amd-dbgapi-target.c @@ -443,19 +443,39 @@ async_event_handler_mark () mark_async_event_handler (amd_dbgapi_async_event_handler); } -/* Set forward progress requirement to REQUIRE for all processes of PROC_TARGET - matching PTID. */ +/* Set forward progress requirement to REQUIRE for inferior INFO. */ static void -require_forward_progress (ptid_t ptid, process_stratum_target *proc_target, - bool require) +require_forward_progress (amd_dbgapi_inferior_info &info, bool require) { /* If we try to disable forward progress requirement but the target expects resumed threads to be committed to the target, we could wait for events that will never arrive. */ if (!require) - gdb_assert (!proc_target->commit_resumed_state); + gdb_assert (!info.inf->process_target ()->commit_resumed_state); + + gdb_assert (info.process_id != AMD_DBGAPI_PROCESS_NONE); + + /* Don't do unnecessary calls to amd-dbgapi to avoid polluting the logs. */ + if (info.forward_progress_required == require) + return; + + const auto progress + = require ? AMD_DBGAPI_PROGRESS_NORMAL : AMD_DBGAPI_PROGRESS_NO_FORWARD; + const auto status + = amd_dbgapi_process_set_progress (info.process_id, progress); + gdb_assert (status == AMD_DBGAPI_STATUS_SUCCESS); + + info.forward_progress_required = require; +} + +/* Set forward progress requirement to REQUIRE for all processes of PROC_TARGET + matching PTID. */ +static void +require_forward_progress (ptid_t ptid, process_stratum_target *proc_target, + bool require) +{ for (inferior *inf : all_inferiors (proc_target)) { if (ptid != minus_one_ptid && inf->pid != ptid.pid ()) @@ -463,21 +483,8 @@ require_forward_progress (ptid_t ptid, process_stratum_target *proc_target, amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf); - if (info->process_id == AMD_DBGAPI_PROCESS_NONE) - continue; - - /* Don't do unnecessary calls to amd-dbgapi to avoid polluting the logs. */ - if (info->forward_progress_required == require) - continue; - - amd_dbgapi_status_t status - = amd_dbgapi_process_set_progress - (info->process_id, (require - ? AMD_DBGAPI_PROGRESS_NORMAL - : AMD_DBGAPI_PROGRESS_NO_FORWARD)); - gdb_assert (status == AMD_DBGAPI_STATUS_SUCCESS); - - info->forward_progress_required = require; + if (info->process_id != AMD_DBGAPI_PROCESS_NONE) + require_forward_progress (*info, require); /* If ptid targets a single inferior and we have found it, no need to continue. */