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

Guinevere Larsen
2026-01-20T12:30:33Z

On 1/19/26 3:09 PM, Simon Marchi wrote:
> On 1/19/26 12:29 PM, Guinevere Larsen wrote:
>> On 1/12/26 3:24 PM, simon.marchi@polymtl.ca wrote:
>>> From: Simon Marchi <simon.marchi@polymtl.ca>
>>>
>>> Tom de Vries reported [1] that a use of the `t` printf length modifier
>>> (used for ptrdiff_t) breaks "set debug dwarf-die 1":
>>>
>>> +break -qualified main
>>> Reading Reading compcomp unit at offset unit at offset 0x00x39
>>>
>>> Reading comp unit at offset 0x1a8
>>> Reading comp unit at offset 0x1e9
>>> Reading comp unit at offset 0x2c5
>>> Reading comp unit at offset 0x2a2
>>> Reading comp unit at offset 0x904
>>> Unrecognized format specifier 't' in printf
>>>
>>> This use is in dwarf2/read.c:
>>>
>>> gdb_printf (gdb_stdlog, "Read die from %s@0x%tx of %s:\n",
>>> m_die_section->get_name (),
>>> (begin_info_ptr - m_die_section->buffer),
>>> bfd_get_filename (m_abfd));
>>>
>>> Add support for the `t` length modifier in format_pieces, which
>>> gdb_printf ultimately uses (through ui_out::vmessage). Modify the three
>>> users of format_pieces: gdb's printf command, gdb's ui_out::vmessage
>>> function and gdbserver's ax_printf function.
>>>
>>> The implementation is mostly copied from what we do for size_t.
>>>
>>> Since format_pieces is also used to implement the printf command, this
>>> patch brings user-visible changes. Before:
>>>
>>> (gdb) printf "%td\n", -123
>>> ❌️ Unrecognized format specifier 't' in printf
>>>
>>> After:
>>>
>>> (gdb) printf "%td\n", -123
>>> -123
>>>
>>> [1] https://inbox.sourceware.org/gdb-patches/d4ccce34-aad5-4e3d-8fc9-efb2fc11275c@suse.de/
>>>
>>> Change-Id: Ie9fce78f5f48082d8f8a9ca2847b5ae26acaa60d
>>> ---
>> This commit seems to have caused a regression. After this, when starting GDB without the quiet flag I get the following:
>>
>> 0x7ffc6b9bc520s
>> Copyright (C) 2026 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later <0x7ffc6b9bc560s>
>> This is free software: you are free to change and redistribute it
>> There is NO WARRANTY, to the extent permitted by law.
>> Type "0x7ffc6b9bc5e0s" and "0x7ffc6b9bc5a0s" for details.
>> This GDB was configured as "x86_64-pc-linux-gnu".
>> Type "0x7ffc6b9bc620s" for configuration details.
>> For bug reporting instructions, please see:
>> 0x7ffc6b9bc660s.
>>
>> That is, anywhere where GDB would print a styled string, we seem to be printing a pointer address instead.
>
> Hmm, I don't see this. I see a pink "GNU gdb (GDB)
> 18.0.50.20260119-git" where you see the "0x7ffc6b9bc660s".
> We will need to figure out what is different between our setups.
>
> Simon
>
Oh, oops, turns out it was my bad.

I was running make on the gdb subdirectory instead of the build
directory and never compiled gdbsupport

Once I did that things magically started working again!

Sorry about the noise

--
Cheers,
Guinevere Larsen
It/she