Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Lancelot Six <Lancelot.Six@amd.com>,
	Simon Marchi <simon.marchi@efficios.com>,
	Lancelot Six <lancelot.six@amd.com>
Subject: [PATCH v2 5/6] gdb/amd-dbgapi: factor out require_forward_progress overload to target one inferior
Date: Mon,  9 Jun 2025 12:09:01 -0400	[thread overview]
Message-ID: <20250609161004.97787-5-simon.marchi@efficios.com> (raw)
In-Reply-To: <20250609161004.97787-1-simon.marchi@efficios.com>

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 | 49 +++++++++++++++++++++++------------------
 1 file changed, 28 insertions(+), 21 deletions(-)

diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c
index 80111359c8cd..2512083db5d9 100644
--- a/gdb/amd-dbgapi-target.c
+++ b/gdb/amd-dbgapi-target.c
@@ -443,6 +443,32 @@ async_event_handler_mark ()
   mark_async_event_handler (amd_dbgapi_async_event_handler);
 }
 
+/* Set forward progress requirement to REQUIRE for inferior INFO.  */
+
+static void
+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 (!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.  */
 
@@ -450,12 +476,6 @@ static void
 require_forward_progress (ptid_t ptid, process_stratum_target *proc_target,
 			  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);
-
   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.  */
-- 
2.49.0


  parent reply	other threads:[~2025-06-09 16:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-09 16:08 [PATCH v2 1/6] gdb/amd-dbgapi: remove unnecessary AMD_DBGAPI_EVENT_KIND_NONE argument Simon Marchi
2025-06-09 16:08 ` [PATCH v2 2/6] gdb/amd-dbgapi: add assert in require_forward_progress Simon Marchi
2025-06-09 16:08 ` [PATCH v2 3/6] gdb/amd-dbgapi: pass amd_dbgapi_inferior_info to process_event_queue Simon Marchi
2025-06-16 10:29   ` Lancelot SIX
2025-06-09 16:09 ` [PATCH v2 4/6] gdb/amd-dbgapi: pass amd_dbgapi_inferior_info to process_one_event Simon Marchi
2025-06-16 10:32   ` Lancelot SIX
2025-06-16 14:24     ` Simon Marchi
2025-06-09 16:09 ` Simon Marchi [this message]
2025-06-09 16:09 ` [PATCH v2 6/6] gdb/amd-dbgapi: disable forward progress requirement in amd_dbgapi_target_breakpoint::check_status Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250609161004.97787-5-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=Lancelot.Six@amd.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox