From: "Aktemur, Baris" <TankutBaris.Aktemur@amd.com>
To: "Six, Lancelot" <Lancelot.Six@amd.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH] gdb, amd-dbgapi-target: use PRIu64 and PRIu32
Date: Wed, 1 Jul 2026 16:56:03 +0000 [thread overview]
Message-ID: <DM4PR12MB6470EF1502826A628A53DA75F8F62@DM4PR12MB6470.namprd12.prod.outlook.com> (raw)
In-Reply-To: <6ae6dd2b-9577-4711-a0c8-93663a28e997@amd.com>
AMD General
On Wednesday, July 1, 2026 5:17 PM, Six, Lancelot wrote:
> Hi,
>
> Doesn't GDB have an implicit habit/policy not to use the PRI??? macros?
>
> I do not mind them in amd-dbgapi-target.c, but want to make sure global
> maintainers are fine with this.
I wasn't aware of a policy. There are existing uses in GDB, including
the amd-dbgapi-target.c file. It would be great to clarify.
-Baris
> I guess the alternative is to use pulongest + %s instead of PRIu64.
>
> i.e. something like this:
>
> str += (agent_id != AMD_DBGAPI_AGENT_NONE
> ? string_printf (" %s", pulongest (agent_id.handle))
> : "?");
>
> Lancelot.
>
> On 01/07/2026 15:28, Tankut Baris Aktemur wrote:
> > In amd-dbgapi-target, there are a number of cases where uint64_t and
> > uint32_t types are being printed. The uint64_t cases are in
> > particular about identifier handles obtained from the debug API. For
> > portability, use PRIu64 for uint64_t and PRIu32 for uint32_t values.
> >
> > In one case, `ptid.tid ()` was being printed for the wave id. Change
> > this to use `wave_id.handle` for consistency with the other cases.
> > ---
> > gdb/amd-dbgapi-target.c | 58 ++++++++++++++++++++---------------------
> > 1 file changed, 29 insertions(+), 29 deletions(-)
> >
> > diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c
> > index d0424044e0c..14523fcefb3 100644
> > --- a/gdb/amd-dbgapi-target.c
> > +++ b/gdb/amd-dbgapi-target.c
> > @@ -392,26 +392,26 @@ wave_coordinates::to_string () const
> > std::string str = "AMDGPU Wave";
> >
> > str += (agent_id != AMD_DBGAPI_AGENT_NONE
> > - ? string_printf (" %ld", agent_id.handle)
> > + ? string_printf (" %" PRIu64, agent_id.handle)
> > : " ?");
> >
> > str += (queue_id != AMD_DBGAPI_QUEUE_NONE
> > - ? string_printf (":%ld", queue_id.handle)
> > + ? string_printf (":%" PRIu64, queue_id.handle)
> > : ":?");
> >
> > str += (dispatch_id != AMD_DBGAPI_DISPATCH_NONE
> > - ? string_printf (":%ld", dispatch_id.handle)
> > + ? string_printf (":%" PRIu64, dispatch_id.handle)
> > : ":?");
> >
> > - str += string_printf (":%ld", wave_id.handle);
> > + str += string_printf (":%" PRIu64, wave_id.handle);
> >
> > str += (group_ids[0] != UINT32_MAX
> > - ? string_printf (" (%d,%d,%d)", group_ids[0], group_ids[1],
> > - group_ids[2])
> > + ? string_printf (" (%" PRIu32 ",%" PRIu32 ",%" PRIu32 ")",
> > + group_ids[0], group_ids[1], group_ids[2])
> > : " (?,?,?)");
> >
> > str += (wave_in_group != UINT32_MAX
> > - ? string_printf ("/%d", wave_in_group)
> > + ? string_printf ("/%" PRIu32, wave_in_group)
> > : "/?");
> >
> > return str;
> > @@ -591,8 +591,8 @@ amd_dbgapi_target_breakpoint::check_status (struct bpstat *bs)
> > &action);
> >
> > if (status != AMD_DBGAPI_STATUS_SUCCESS)
> > - error (_("amd_dbgapi_report_breakpoint_hit failed for breakpoint %ld "
> > - "at %s (%s)"),
> > + error (_("amd_dbgapi_report_breakpoint_hit failed for breakpoint %" PRIu64
> > + " at %s (%s)"),
> > breakpoint_id.handle, paddress (inf->arch (), bs->bp_location_at->address),
> > get_status_string (status));
> >
> > @@ -624,7 +624,7 @@ amd_dbgapi_target_breakpoint::check_status (struct bpstat *bs)
> > for our breakpoint_id. */
> > if (resume_breakpoint_id != breakpoint_id)
> > error (_("breakpoint resume event is not for this breakpoint. "
> > - "Expected breakpoint_%ld, got breakpoint_%ld"),
> > + "Expected breakpoint_%" PRIu64 ", got breakpoint_%" PRIu64),
> > breakpoint_id.handle, resume_breakpoint_id.handle);
> >
> > amd_dbgapi_event_processed (resume_event_id);
> > @@ -1055,8 +1055,8 @@ amd_dbgapi_target::resume (ptid_t scope_ptid, int step, enum
> gdb_signal signo)
> > indicate that the process has exited. GDB treats resuming a
> > thread that no longer exists as being successful. */
> > && status != AMD_DBGAPI_STATUS_ERROR_INVALID_WAVE_ID)
> > - error (_("wave_resume for wave_%ld failed (%s)"), wave_id.handle,
> > - get_status_string (status));
> > + error (_("wave_resume for wave_%" PRIu64 " failed (%s)"),
> > + wave_id.handle, get_status_string (status));
> >
> > wi.stopping = false;
> > }
> > @@ -1130,12 +1130,12 @@ amd_dbgapi_target::stop (ptid_t ptid)
> > }
> >
> > if (status != AMD_DBGAPI_STATUS_ERROR_INVALID_WAVE_ID)
> > - error (_("wave_stop for wave_%ld failed (%s)"), wave_id.handle,
> > - get_status_string (status));
> > + error (_("wave_stop for wave_%" PRIu64 " failed (%s)"),
> > + wave_id.handle, get_status_string (status));
> > }
> > else if (status != AMD_DBGAPI_STATUS_ERROR_INVALID_WAVE_ID)
> > - error (_("wave_get_info for wave_%ld failed (%s)"), wave_id.handle,
> > - get_status_string (status));
> > + error (_("wave_get_info for wave_%" PRIu64 " failed (%s)"),
> > + wave_id.handle, get_status_string (status));
> >
> > /* The status is AMD_DBGAPI_STATUS_ERROR_INVALID_WAVE_ID. The wave
> > could have terminated since the last time the wave list was
> > @@ -1145,7 +1145,7 @@ amd_dbgapi_target::stop (ptid_t ptid)
> > wi.stopping = true;
> >
> > amd_dbgapi_debug_printf ("got AMD_DBGAPI_STATUS_ERROR_INVALID_WAVE_ID "
> > - "for wave_%ld, last_resume_mode=%s, "
> > + "for wave_%" PRIu64 ", last_resume_mode=%s, "
> > "report_thread_events=%d",
> > wave_id.handle,
> > resume_mode_to_string (wi.last_resume_mode),
> > @@ -1268,7 +1268,7 @@ dbgapi_notifier_handler (int err, gdb_client_data client_data)
> > sizeof (runtime_state),
> > &runtime_state);
> > if (status != AMD_DBGAPI_STATUS_SUCCESS)
> > - error (_("event_get_info for event_%ld failed (%s)"),
> > + error (_("event_get_info for event_%" PRIu64 " failed (%s)"),
> > event_id.handle, get_status_string (status));
> >
> > switch (runtime_state)
> > @@ -1404,7 +1404,7 @@ add_gpu_thread (inferior *inf, ptid_t wave_ptid)
> >
> > if (!info.wave_info_map.try_emplace (wave_id.handle,
> > wave_info (wave_id)).second)
> > - internal_error ("wave ID %ld already in map", wave_id.handle);
> > + internal_error ("wave ID %" PRIu64 " already in map", wave_id.handle);
> >
> > /* Create new GPU threads silently to avoid spamming the terminal
> > with thousands of "[New Thread ...]" messages. */
> > @@ -1436,7 +1436,7 @@ process_one_event (amd_dbgapi_inferior_info &info,
> > = amd_dbgapi_event_get_info (event_id, AMD_DBGAPI_EVENT_INFO_WAVE,
> > sizeof (wave_id), &wave_id);
> > if (status != AMD_DBGAPI_STATUS_SUCCESS)
> > - error (_("event_get_info for event_%ld failed (%s)"),
> > + error (_("event_get_info for event_%" PRIu64 " failed (%s)"),
> > event_id.handle, get_status_string (status));
> >
> > ptid_t event_ptid = make_gpu_ptid (info.inf->pid, wave_id);
> > @@ -1502,7 +1502,7 @@ process_one_event (amd_dbgapi_inferior_info &info,
> > }
> > }
> > else
> > - error (_("wave_get_info for wave_%ld failed (%s)"),
> > + error (_("wave_get_info for wave_%" PRIu64 " failed (%s)"),
> > wave_id.handle, get_status_string (status));
> >
> > info.wave_events.emplace_back (event_ptid, ws);
> > @@ -1542,7 +1542,7 @@ process_one_event (amd_dbgapi_inferior_info &info,
> > AMD_DBGAPI_EVENT_INFO_RUNTIME_STATE,
> > sizeof (runtime_state), &runtime_state);
> > if (status != AMD_DBGAPI_STATUS_SUCCESS)
> > - error (_("event_get_info for event_%ld failed (%s)"),
> > + error (_("event_get_info for event_%" PRIu64 " failed (%s)"),
> > event_id.handle, get_status_string (status));
> >
> > gdb_assert (runtime_state == AMD_DBGAPI_RUNTIME_STATE_UNLOADED);
> > @@ -2069,14 +2069,14 @@ amd_dbgapi_target::thread_architecture (ptid_t ptid)
> > sizeof (architecture_id),
> > &architecture_id);
> > if (status != AMD_DBGAPI_STATUS_SUCCESS)
> > - error (_("Couldn't get architecture for wave_%ld"), ptid.tid ());
> > + error (_("Couldn't get architecture for wave_%" PRIu64), wave_id.handle);
> >
> > uint32_t elf_amdgpu_machine;
> > status = amd_dbgapi_architecture_get_info
> > (architecture_id, AMD_DBGAPI_ARCHITECTURE_INFO_ELF_AMDGPU_MACHINE,
> > sizeof (elf_amdgpu_machine), &elf_amdgpu_machine);
> > if (status != AMD_DBGAPI_STATUS_SUCCESS)
> > - error (_("Couldn't get elf_amdgpu_machine for architecture_%ld"),
> > + error (_("Couldn't get elf_amdgpu_machine for architecture_%" PRIu64),
> > architecture_id.handle);
> >
> > struct gdbarch_info info;
> > @@ -2154,7 +2154,7 @@ amd_dbgapi_target::update_thread_list ()
> > || wi.stopping)
> > {
> > amd_dbgapi_debug_printf
> > - ("wave_%ld disappeared, keeping it"
> > + ("wave_%" PRIu64 " disappeared, keeping it"
> > " (last_resume_mode=%s, stopping=%d)",
> > wave_id.handle,
> > resume_mode_to_string (wi.last_resume_mode),
> > @@ -2162,8 +2162,8 @@ amd_dbgapi_target::update_thread_list ()
> > }
> > else
> > {
> > - amd_dbgapi_debug_printf ("wave_%ld disappeared, deleting it",
> > - wave_id.handle);
> > + amd_dbgapi_debug_printf ("wave_%" PRIu64 " disappeared, "
> > + "deleting it", wave_id.handle);
> > delete_thread_silent (&tp);
> > }
> > }
> > @@ -2283,8 +2283,8 @@ amd_dbgapi_target::displaced_step_finish (thread_info *thread,
> > sizeof (stop_reason), &stop_reason);
> >
> > if (status != AMD_DBGAPI_STATUS_SUCCESS)
> > - error (_("wave_get_info for wave_%ld failed (%s)"), wave_id.handle,
> > - get_status_string (status));
> > + error (_("wave_get_info for wave_%" PRIu64 " failed (%s)"),
> > + wave_id.handle, get_status_string (status));
> >
> > status = amd_dbgapi_displaced_stepping_complete (wave_id, stepping_id);
> >
next prev parent reply other threads:[~2026-07-01 16:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 14:28 Tankut Baris Aktemur
2026-07-01 15:16 ` Lancelot SIX
2026-07-01 16:56 ` Aktemur, Baris [this message]
2026-07-02 20:15 ` Tom Tromey
2026-07-03 12:59 ` Simon Marchi
2026-07-03 13:47 ` Pedro Alves
2026-07-03 18:15 ` Tom Tromey
2026-07-03 19:18 ` Pedro Alves
2026-07-03 19:22 ` Pedro Alves
2026-07-03 11:03 ` [PATCH v2] gdb, amd-dbgapi-target: use pulongest to print id handles Tankut Baris Aktemur
2026-07-03 11:22 ` 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=DM4PR12MB6470EF1502826A628A53DA75F8F62@DM4PR12MB6470.namprd12.prod.outlook.com \
--to=tankutbaris.aktemur@amd.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