From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id LIsRLvEF5Wit6yIAWB0awg (envelope-from ) for ; Tue, 07 Oct 2025 08:22:09 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cCcLWqXe; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id ACC281E047; Tue, 07 Oct 2025 08:22:09 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 8978E1E047 for ; Tue, 07 Oct 2025 08:22:05 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4A4633858C98 for ; Tue, 7 Oct 2025 12:22:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A4633858C98 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cCcLWqXe Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 810F63858C83 for ; Tue, 7 Oct 2025 12:21:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 810F63858C83 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 810F63858C83 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1759839687; cv=none; b=DYY3iSaHxOCLHhaKdn1kps7HuGf+22iyN+iy8YZ6dkRx5muSpwcW4RVY7hLdDGOYkHGTj00YYwg14QgqByXUDRZ5kboyL4wfKy2tNZHMwf7sof/565+pC8ZyF/d0gBGkgwDO9gHr4Q51UZzkYT4nNC6CrmMJ+/pEUVCfPzhy2vM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1759839687; c=relaxed/simple; bh=pduexC/wlHOrk8LIWJD5B164C+TxhVrJt6bytqQ6Ig4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=gbG+w+tOWJ1yuuj/9IypAdkWh6porZgJGcukqaZjtqWu+y4Vf4MFdq5D84na+Ele0t9djzWlF4DxiNGBVxymAgsuedUmX5w6MNEH5FMXARYJF+WHENqQulUeQnORVh6p7qtV7UWNHYJXSnoxwE6zhtVDR2NmsUFEyeunzkNU7ww= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 810F63858C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759839687; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Mt3V9su1eNwauXEYDNp79ILi4qXgtZ0RUOlsAtas+UY=; b=cCcLWqXeqr7bbo164ESnSJt8pdUQSd9ML1DQwdFoUN2lD9h0Qk+1+/BdjPhbpllr7QrHWu IF8bcT4DqMidRQ0mbX0+SeFKZSdUSuRZ0uAovQb3ijsBtu5M8TVSg+tIXpWukt5YZp+9CZ lFm8kiAi2c2AuLyU5/27sJRtEJHUqdU= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-346-0xaUjSWvOama1cX1rIviHQ-1; Tue, 07 Oct 2025 08:21:25 -0400 X-MC-Unique: 0xaUjSWvOama1cX1rIviHQ-1 X-Mimecast-MFC-AGG-ID: 0xaUjSWvOama1cX1rIviHQ_1759839684 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3f3787688b0so3275402f8f.0 for ; Tue, 07 Oct 2025 05:21:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759839684; x=1760444484; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Mt3V9su1eNwauXEYDNp79ILi4qXgtZ0RUOlsAtas+UY=; b=DiOcPMOdpMIkAv1v2nW4xeM6kWUs+G/nmPkb5LV8X7jmKl6hmWhC+hyQnS2xgTSy0p FsEK4yvhQCvnJH8aI5iBCF++WTLexZc3yHs+g46GRTI+rMhwDiLkZkbvcmVvVAQAzuFd 2S7Mxfq4EaiQ2PPjVJMicX15+0HdYeaey0Rhbrgu4NA0xH9MmUB+XgKn29f4UEzYvbuH aEG6/S8o2hPi0bBGuXKbD99caBFewHNGO2bpE6OmPx/MfG62n3hUCvpwerkQQEiKtyy/ I4GF2cKf1Bfw+Faq+JXz54AbPyrdVUNaMtiKj23TRi1FIwTK1R+NtUtp0XJa/pRMmyVY giHw== X-Gm-Message-State: AOJu0Yyx7G//x2yRrYe7P5gh6W7yo/VmrAQXG9Q5Zh5Bc7FfkW0cOEDl ypspWEHEnYcsot+q2/LQOqJ/A1IfU2LvJFIuEZkyGY/f99sb5YUxPpfwQkIAWTOcJk5jEkYbxZF Nes6Rz/V8w8DfCnTopDqyLSwtAVQkLKa/yQbOhyTR3kdV2cIRb5Ac5TZe1WZY3FSBaPD2e78= X-Gm-Gg: ASbGnctn+RY7dGV0ctf1NlNitzPthT7GHMjVAiCpzsxQaqsWC+Fl7I8td7XKV77piQl ev4IqJ4FahSrikZw0lfzhHQ7RNedUWWHuQwimj00I/tHEXb8HNypnCADsuCVbvH7pGuX/68QQJl GdT8ZRI4JkaokCIGuJqW+0MoOC5VwsdQZ/fmQp43GtjQLZg/J+x6WldSD+kZvaV5eNL5FqFCCGs SH/qCQuT00x2yCJL0CtGBRPnB328qSwvKXr/jj6xlL1Vttt//kxrg2MTZvpNfcdGQA/UW6z0oWh P2B6vejPLVtPnCyviG7K2uw0a3viZGdDIu9HajmH X-Received: by 2002:a05:6000:481e:b0:425:7c3c:82cf with SMTP id ffacd0b85a97d-4257c3c8349mr5075789f8f.11.1759839683618; Tue, 07 Oct 2025 05:21:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkDNzk9u2JK1szswcx7iY8hO3qTBXoqeyDbZo96szw1gM9bilztMJosNpkhJKxQjX7xju0vA== X-Received: by 2002:a05:6000:481e:b0:425:7c3c:82cf with SMTP id ffacd0b85a97d-4257c3c8349mr5075766f8f.11.1759839683131; Tue, 07 Oct 2025 05:21:23 -0700 (PDT) Received: from localhost ([31.111.84.207]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8a6bbesm25107327f8f.12.2025.10.07.05.21.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Oct 2025 05:21:22 -0700 (PDT) From: Andrew Burgess To: Tom de Vries , Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCHv2 3/3] gdb/python: add Corefile.mapped_files method In-Reply-To: References: <9ab589510f784da2752b72d0b1385afa33aca406.1758634958.git.aburgess@redhat.com> <87cy737q50.fsf@tromey.com> Date: Tue, 07 Oct 2025 13:21:22 +0100 Message-ID: <87zfa26gxp.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ch6dAodGkujg7DKo1bpUeFt_ZxorCVrhKt2qXBHqvQk_1759839684 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Tom de Vries 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 > > Hi, > > Starting with this commit, I see: > ... > (gdb) check-build-ids^M > Python Exception : 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"