Re: [PATCH] gdb, gdbsupport, gdbserver: add support for printf 't' length modifier

Simon Marchi
2026-01-15T19:37:27Z

On 1/15/26 2:24 PM, Tom Tromey wrote:
>>>>>> "Simon" == simon marchi <simon.marchi@polymtl.ca> writes:
>
> Simon> Add support for the `t` length modifier in format_pieces, which
> Simon> gdb_printf ultimately uses (through ui_out::vmessage). Modify the three
> Simon> users of format_pieces: gdb's printf command, gdb's ui_out::vmessage
> Simon> function and gdbserver's ax_printf function.
>
> Thanks.
>
> These modifiers are one of the clearest reasons that printf should be
> replaced. I think we should generally avoid them. We've already got
> plongest, etc; which seem safer. See commit a1537331 (the "other
> direction") but there's also commit a5adb8f3 and probably more.
>
> Anyway, it's ok.
> Approved-By: Tom Tromey <tom@tromey.com>
>
> Tom

I think the reason for plongest is more that LONGEST can vary from build
to build. We could otherwise have PRILONGEST / PRIULONGEST / etc
macros, just like there is PRIu64 & co. But yeah if we do a move
nowadays, it would make more sense to move to std::format/{fmt}.

I pushed the patch, thanks.

Simon