[PATCH 18/27] gdb: %p => host_address_to_string, target-section owner token
Pedro Alves <[email protected]> Thu, 23 Jul 2026 14:01:09 +0100
| Newsgroups | gmane.comp.gdb.patches |
|---|---|
| Message-ID | <[email protected]> |
"maintenance info target-sections" prints an owner token for each
section, formatted with %p:
gdb_printf ("%*sStart: %s, End: %s, Owner token: %p\n", ...
The exact rendering of %p is implementation-defined. glibc prints it
with a leading "0x", but the MSVC C runtime prints it zero-padded and
with no "0x" prefix, e.g.:
Owner token: 000001833bd9bde0
gdb.base/maint-info-sections.exp expects a "0x"-prefixed value there,
so on windows-msvc the auxiliary-information line does not match and
the test fails:
FAIL: gdb.base/maint-info-sections.exp: with executable: maint info target-sections
Fix this by using host_address_to_string, which always renders a host
pointer with a "0x" prefix regardless of the C runtime, as GDB does
elsewhere for this reason.
Tested on x86_64-pc-linux-gnu and x86_64-pc-windows-msvc.
Change-Id: Ib9f081b65f02e2820783f87cfaffcff81e46e983
---
gdb/maint.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gdb/maint.c b/gdb/maint.c
index 1daa6ce1d2e..cbcdf59001b 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -522,11 +522,11 @@ maintenance_info_target_sections (const char *arg, int from_tty)
digits);
/* The magic '8 + digits' here ensures that the 'Start' is aligned
with the output of print_bfd_section_info. */
- gdb_printf ("%*sStart: %s, End: %s, Owner token: %p\n",
+ gdb_printf ("%*sStart: %s, End: %s, Owner token: %s\n",
(8 + digits), "",
hex_string_custom (sec.addr, addr_size),
hex_string_custom (sec.endaddr, addr_size),
- sec.owner.v ());
+ host_address_to_string (sec.owner.v ()));
}
}
--
2.54.0