From: Andrew Burgess <aburgess@redhat.com>
To: Tom de Vries <tdevries@suse.de>, Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCHv2 3/3] gdb/python: add Corefile.mapped_files method
Date: Tue, 07 Oct 2025 13:21:22 +0100 [thread overview]
Message-ID: <87zfa26gxp.fsf@redhat.com> (raw)
In-Reply-To: <de21b43c-e3bd-4354-aace-bd3f50c1c64c@suse.de>
Tom de Vries <tdevries@suse.de> writes:
> On 10/3/25 21:15, Tom Tromey wrote:
>> Andrew> Add a new Corefile.mapped_files method which returns a list of
>> Andrew> gdb.CorefileMappedFile objects.
>>
>> Andrew> Each gdb.CorefileMappedFile object represents a file that was mapped
>> Andrew> into the process when the core file was created.
>>
>> Andrew> + ** New Inferior.corefile attribute. This read only attribute
>> Andrew> + contains the gdb.Corefile object if a core file is loaded into
>> Andrew> + the inferior, otherwise, this contains None.
>>
>> This hunk is duplicated, it also appears in patch 1.
>>
>> Other than that this looks good to me.
>> Approved-By: Tom Tromey <tom@tromey.com>
>
> Hi,
>
> Starting with this commit, I see:
> ...
> (gdb) check-build-ids^M
> Python Exception <class 'AssertionError'>: build-id mismatch for
> /lib64/libc.so.6^M
> Error occurred in Python: build-id mismatch for /lib64/libc.so.6^M
> (gdb) FAIL: gdb.python/py-corefile.exp: test mapped files data:
> check-build-ids
> ...
So that test is checking that the build-ids of the objfiles that were
loaded match the build-ids pulled from the corefile.
For example, GDB should find a build-id for `/lib64/libc.so.6` in the
core file, then when GDB loads `/lib64/libc.so.6` an objfile is created,
we can also read the build-id via the objfile.
The failure tells us that for some reason these two methods to read the
build-id gave different results.
Now, `/lib64/libc.so.6` must have a build-id, otherwise the objfile
would return None for its build-id, and the check-build-ids command
would ignore this library and we shouldn't see an assert.
So for the assert to trigger one of these things must have happened:
+ Build-id is present in the core file, but GDB failed to extract it,
or extracted the wrong data. Resulting in either None, or a different
build-id, or
+ Build-id is not present in the core file, GDB will return None for
the build-id.
Of these two I suspect the second; for a period of time the GNU linker
was ... changed ... such that it no longer placed the build-id within
the first page of a generated ELF, as a result, the Linux kernel would
not include the build-id in core dumps.
We can check for the second case using:
readelf -WS /lib64/libc.so.6 | grep build-id
The output will be something like:
[ 2] .note.gnu.build-id NOTE 0000000000000370 000370 000024 00 A 0 0 4
It's the '000370' column we're interested in. If this value is greater
than a page size, then GDB isn't going to be able to find the build-id.
You could try applying the patch below. This isn't a real fix, but does
two things:
1. Ignores any None build-id values pulled from the core file. I
suspect this will be enough to get the test passing for you, but
the patch also does
2. prints both build-ids if there is a mismatch.
Unfortunately just doing (1) isn't a long term fix as this would also
ignore the case where a bug in GDB means that we fail to find the
build-id.
So what I'm going to do is try to extend the test so that we can use
maybe readelf like I show above to check if GDB _should_ be able to find
the build-id, and only run the build-id check _if_ we think GDB should
be able to find the build-ids.
Anyway, I'd be interested to hear if the patch resolves the failure for
you. If it doesn't then I'm on completely the wrong path and will need
to rethink.
Thanks,
Andrew
---
diff --git i/gdb/testsuite/gdb.python/py-corefile.py w/gdb/testsuite/gdb.python/py-corefile.py
index cffd037a23b..979a0281d12 100644
--- i/gdb/testsuite/gdb.python/py-corefile.py
+++ w/gdb/testsuite/gdb.python/py-corefile.py
@@ -101,9 +101,12 @@ class CheckBuildIds(gdb.Command):
p = pathlib.Path(m.filename).resolve()
b = m.build_id
+ if b is None:
+ continue
+
if p in path_to_build_id:
count += 1
- assert path_to_build_id[p] == b, "build-id mismatch for %s" % p
+ assert path_to_build_id[p] == b, "build-id mismatch for %s; %s vs %s" % (p, path_to_build_id[p], b)
assert count > 0, "no mapped files checked"
next prev parent reply other threads:[~2025-10-07 12:22 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-02 16:03 [PATCH 0/3] Core file Python API Andrew Burgess
2025-09-02 16:03 ` [PATCH 1/3] gdb/python: introduce gdb.Corefile API Andrew Burgess
2025-09-02 16:26 ` Eli Zaretskii
2025-09-16 17:25 ` Tom Tromey
2025-09-23 13:50 ` Andrew Burgess
2025-09-02 16:03 ` [PATCH 2/3] gdb: make structured core file mappings processing global Andrew Burgess
2025-09-16 17:28 ` Tom Tromey
2025-09-02 16:03 ` [PATCH 3/3] gdb/python: add Corefile.mapped_files method Andrew Burgess
2025-09-16 17:54 ` Tom Tromey
2025-09-23 13:52 ` Andrew Burgess
2025-09-23 13:44 ` [PATCHv2 0/3] Core file Python API Andrew Burgess
2025-09-23 13:44 ` [PATCHv2 1/3] gdb/python: introduce gdb.Corefile API Andrew Burgess
2025-10-03 18:56 ` Tom Tromey
2025-10-06 8:54 ` Andrew Burgess
2025-10-06 15:39 ` Tom Tromey
2025-10-06 16:13 ` Andrew Burgess
2025-09-23 13:44 ` [PATCHv2 2/3] gdb: make structured core file mappings processing global Andrew Burgess
2025-10-13 13:57 ` Lancelot SIX
2025-10-13 14:37 ` Andrew Burgess
2025-10-13 15:16 ` Six, Lancelot
2025-10-14 9:12 ` Lancelot SIX
2025-09-23 13:44 ` [PATCHv2 3/3] gdb/python: add Corefile.mapped_files method Andrew Burgess
2025-10-03 19:15 ` Tom Tromey
2025-10-07 6:24 ` Tom de Vries
2025-10-07 12:21 ` Andrew Burgess [this message]
2025-10-07 13:08 ` Tom de Vries
2025-10-07 13:26 ` Andrew Burgess
2025-10-07 14:38 ` Andrew Burgess
2025-10-07 15:43 ` Tom de Vries
2025-10-07 16:28 ` Andrew Burgess
2025-10-08 9:29 ` Andrew Burgess
2025-10-08 10:36 ` Tom de Vries
2025-10-08 14:14 ` Andrew Burgess
2025-10-08 15:43 ` Tom de Vries
2025-10-08 16:03 ` Andrew Burgess
2025-10-16 20:00 ` Tom Tromey
2025-10-17 10:02 ` Andrew Burgess
2025-10-17 13:32 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zfa26gxp.fsf@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tdevries@suse.de \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox