Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tankut Baris Aktemur <tankutbaris.aktemur@amd.com>
To: <gdb-patches@sourceware.org>
Cc: <lancelot.six@amd.com>
Subject: [PATCH 2/2] gdb, amd-dbgapi-target: split wave_coordinates::to_string
Date: Fri, 3 Jul 2026 07:50:58 -0500	[thread overview]
Message-ID: <20260703125058.1828518-2-tankutbaris.aktemur@amd.com> (raw)
In-Reply-To: <20260703125058.1828518-1-tankutbaris.aktemur@amd.com>

wave_coordinates::to_string() produces a string in the following format:

  AMDGPU Wave a:q:d:w (x,y,z)/i

Split the method into smaller pieces:

  a:q:d:w   : hierarchy_str
  (x,y,z)   : workgroup_coord_str
  (x,y,z)/i : dispatch_pos_str

This is a refactoring to allow reusing pieces.  Currently the reuse
opportunity exists in the downstream debugger.
---
 gdb/amd-dbgapi-target.c | 55 +++++++++++++++++++++++++++++++++--------
 1 file changed, 45 insertions(+), 10 deletions(-)

diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c
index 923b790664e..33512695fb5 100644
--- a/gdb/amd-dbgapi-target.c
+++ b/gdb/amd-dbgapi-target.c
@@ -147,6 +147,17 @@ struct wave_coordinates
     : wave_id (wave_id)
   {}
 
+  /* Return the string showing the agent -> queue -> dispatch -> wave
+     hierarchy.  */
+  std::string hierarchy_str () const;
+
+  /* Return the workgroup coordinates as a string.  */
+  std::string workgroup_coord_str () const;
+
+  /* Return the dispatch position string for the wave this
+     wave_coordinates is for.  */
+  std::string dispatch_pos_str () const;
+
   /* Return the target ID string for the wave this wave_coordinates is
      for.  */
   std::string to_string () const;
@@ -387,13 +398,12 @@ get_amd_dbgapi_inferior_info (inferior *inferior)
 static async_event_handler *amd_dbgapi_async_event_handler = nullptr;
 
 std::string
-wave_coordinates::to_string () const
+wave_coordinates::hierarchy_str () const
 {
-  std::string str = "AMDGPU Wave";
-
-  str += (agent_id != AMD_DBGAPI_AGENT_NONE
-	  ? string_printf (" %s", pulongest (agent_id.handle))
-	  : " ?");
+  std::string str
+    = (agent_id != AMD_DBGAPI_AGENT_NONE
+       ? string_printf (" %s", pulongest (agent_id.handle))
+       : "?");
 
   str += (queue_id != AMD_DBGAPI_QUEUE_NONE
 	  ? string_printf (":%s", pulongest (queue_id.handle))
@@ -405,11 +415,25 @@ wave_coordinates::to_string () const
 
   str += string_printf (":%s", pulongest (wave_id.handle));
 
-  str += (group_ids[0] != UINT32_MAX
-	  ? string_printf (" (%u,%u,%u)", group_ids[0], group_ids[1],
-			   group_ids[2])
-	  : " (?,?,?)");
+  return str;
+}
+
+std::string
+wave_coordinates::workgroup_coord_str () const
+{
+  std::string str
+    = (group_ids[0] != UINT32_MAX
+       ? string_printf ("(%u,%u,%u)", group_ids[0], group_ids[1],
+			group_ids[2])
+       : "(?,?,?)");
 
+  return str;
+}
+
+std::string
+wave_coordinates::dispatch_pos_str () const
+{
+  std::string str = workgroup_coord_str ();
   str += (wave_in_group != UINT32_MAX
 	  ? string_printf ("/%u", wave_in_group)
 	  : "/?");
@@ -417,6 +441,17 @@ wave_coordinates::to_string () const
   return str;
 }
 
+std::string
+wave_coordinates::to_string () const
+{
+  std::string str = "AMDGPU Wave";
+
+  str += " " + hierarchy_str ();
+  str += " " + dispatch_pos_str ();
+
+  return str;
+}
+
 /* Read in wave_info for WAVE_ID.  */
 
 void
-- 
2.34.1


  reply	other threads:[~2026-07-03 12:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-03 12:50 [PATCH 1/2] gdb, amd-dbgapi-target: use '%u' instead of '%d' in wave_coordinates::to_string Tankut Baris Aktemur
2026-07-03 12:50 ` Tankut Baris Aktemur [this message]
2026-07-03 13:16   ` [PATCH 2/2] gdb, amd-dbgapi-target: split wave_coordinates::to_string Simon Marchi
2026-07-06 10:45     ` Lancelot SIX
2026-07-03 13:12 ` [PATCH 1/2] gdb, amd-dbgapi-target: use '%u' instead of '%d' in wave_coordinates::to_string Simon Marchi
2026-07-03 13:27   ` Aktemur, Baris
2026-07-03 13:42 ` [PATCH v2 1/2] gdb, amd-dbgapi-target: use pulongest more Tankut Baris Aktemur
2026-07-06 10:31   ` Lancelot SIX

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=20260703125058.1828518-2-tankutbaris.aktemur@amd.com \
    --to=tankutbaris.aktemur@amd.com \
    --cc=gdb-patches@sourceware.org \
    --cc=lancelot.six@amd.com \
    /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