gdb/testsuite: fix failure from gdb.python/py-corefile.exp
After commit:
commit
f69c1d03c4d6c68ae3f90facd63245426c028047
Date: Mon Aug 25 16:48:22 2025 +0100
gdb/python: add Corefile.mapped_files method
Tom reported a failure:
(gdb) check-build-ids
Python Exception <class 'AssertionError'>: build-id mismatch for /lib64/libc.so.6
Error occurred in Python: build-id mismatch for /lib64/libc.so.6
(gdb) FAIL: gdb.python/py-corefile.exp: test mapped files data: check-build-ids
The discussion thread can be found here:
https://inbox.sourceware.org/gdb-patches/
de21b43c-e3bd-4354-aace-
bd3f50c1c64c@suse.de
There are a couple of problems.
First, there is an issue where some versions of the linker didn't
place the build-id within the first page of an ELF. As a result, the
Linux kernel would not include the build-id in the generated core
file, and so GDB cannot to find the build-id.
In this patch I've added mitigation for this problem.
I changed the 'check-build-ids' command (added via Python as part of
the test) to 'show-build-ids'. The updated command prints a table
containing the build-ids for each objfile as found via GDB's
Progspace.objfiles, and via the Corefile.mapped_files. This table is
then read by the TCL test script, and the build-ids are checked. If
there's a difference, then GDB can analyse the on disk ELF and work
out if the difference is due to the linker issue mentioned above. If
it is, then the difference is ignored.
In order to check for this linker issue I added a new helper proc to
lib/gdb.exp, expect_build_id_in_core_file.
The second problem with the original test is that it would consider
separate debug files as files that should appear in the core file.
There was Python code in the test that filtered the objfile list to
disregard entries that would not appear in the core file, but this
code needed extending to cover separate debug files.
The final issue is that I'm only aware of GNU/Linux forcing the first
page of every mapped ELF into the generated core files, so this test
would likely fail on non-Linux systems. I've made the part of the
test that relies on this behaviour Linux only.
This change should resolve the FAIL that Tom reported. Giving Tom a
Co-Author credit as he fixed the second issue, and helped a lot
debugging the first issue.
Co-Authored-By: Tom de Vries <tdevries@suse.de>