Files
binutils-gdb/gdbsupport
Simon Marchi f6022f5390 gdb, gdbsupport, gdbserver: add support for printf 't' length modifier
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
Approved-By: Tom Tromey <tom@tromey.com>
2026-01-15 14:34:54 -05:00
..
2025-12-10 00:25:20 +01:00
2024-11-23 12:40:36 +01:00
2026-01-05 13:16:46 -07:00
2026-01-05 13:16:46 -07:00
2026-01-05 13:16:46 -07:00
2026-01-05 13:16:46 -07:00
2026-01-05 13:16:46 -07:00
2026-01-05 13:16:46 -07:00
2026-01-05 13:16:46 -07:00

This is a helper library that is used by gdb and gdbserver.

To send patches, follow the gdb patch submission instructions in
../gdb/CONTRIBUTE.  For maintainers, see ../gdb/MAINTAINERS.