]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/amd-dbgapi: factor out require_forward_progress overload to target one inferior
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 9 Jun 2025 16:09:01 +0000 (12:09 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 16 Jun 2025 14:23:16 +0000 (10:23 -0400)
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 <lancelot.six@amd.com>
gdb/amd-dbgapi-target.c

index 819ff2014231322248ec363b48bbda82e53cef98..fd4f9cba48ad855ec80dca7d3d2d42b1f4bed39c 100644 (file)
@@ -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.  */