Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Tom Tromey <tom@tromey.com>, Lancelot SIX <Lancelot.Six@amd.com>
Cc: Tankut Baris Aktemur <tankutbaris.aktemur@amd.com>,
	gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb, amd-dbgapi-target: use PRIu64 and PRIu32
Date: Fri, 3 Jul 2026 14:47:25 +0100	[thread overview]
Message-ID: <20854a3f-d7ab-4fdb-b694-a12a16315de0@palves.net> (raw)
In-Reply-To: <87echlf8s5.fsf@tromey.com>

On 2026-07-02 21:15, Tom Tromey wrote:
>>>>>> Lancelot SIX <Lancelot.Six@amd.com> writes:
> 
>> 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 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))
>>         : "?");
> 
> I don't know if it's a policy exactly, but personally I prefer pulongest
> et al, since I find the PRI* macros pretty ugly and unreadable.

Agreed.  And it's also a portability hazard, like other printf formats, as you have
to match the printf format to the type of the variable.  For typedefs, you have
to either hardcode the underlying type (as here) when it's supposed to be an implementation
detail, or add new PRI-like macros for the typedefs.  The pulongest (and paddress, etc.)
pattern mostly eliminates that, as the printf format is always "%s", at a small runtime cost.

(std::cout << ... << ... tends to be unreadable too IMHO, but we don't use that, thankfully).

{fmt} would be better, but that's either a new external dependency, or 
bump to c++20 for std::format, or c++23 for widely available std::print.

Pedro Alves


  parent reply	other threads:[~2026-07-03 13:47 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
2026-07-02 20:15   ` Tom Tromey
2026-07-03 12:59     ` Simon Marchi
2026-07-03 13:47     ` Pedro Alves [this message]
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=20854a3f-d7ab-4fdb-b694-a12a16315de0@palves.net \
    --to=pedro@palves.net \
    --cc=Lancelot.Six@amd.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tankutbaris.aktemur@amd.com \
    --cc=tom@tromey.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