From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by sourceware.org (Postfix) with ESMTPS id 4CFA93858D39 for ; Fri, 26 Nov 2021 11:23:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4CFA93858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=seketeli.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=seketeli.org Received: (Authenticated sender: dodji@seketeli.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 8035F24000E; Fri, 26 Nov 2021 11:23:29 +0000 (UTC) Received: by localhost (Postfix, from userid 1000) id B6D165802B4; Fri, 26 Nov 2021 12:23:28 +0100 (CET) From: Dodji Seketeli To: Guillermo Martinez Cc: "Guillermo E. Martinez via Libabigail" Subject: Re: [PATCH v2] Add regression tests for ctf reading Organization: Me, myself and I References: <20211118041625.622972-1-guillermo.e.martinez@oracle.com> <20211122213353.2456208-1-guillermo.e.martinez@oracle.com> <87ee75tsst.fsf@seketeli.org> <4678181.mFG4eHPlM4@sali> X-Operating-System: Fedora 36 X-URL: http://www.seketeli.net/~dodji Date: Fri, 26 Nov 2021 12:23:28 +0100 In-Reply-To: <4678181.mFG4eHPlM4@sali> (Guillermo Martinez's message of "Wed, 24 Nov 2021 18:52:56 +0000") Message-ID: <87r1b3rwi7.fsf@seketeli.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Nov 2021 11:23:33 -0000 Hello, [...] On Nov 24, 2021, at 8:36 AM, Dodji Seketeli wrote >> So where exactly is the CTF test disabled? Guillermo Martinez a =C3=A9crit: > I remove those test entries, so the possible problem detected using exter= nal diff > command in CTF is, for instance, in: test-read-common/test-PR26568-1-ctf.= o.abi, > the first time that runtestreadctf is executed an abixml file is generat= ed: > > ... > > > > > > > > > > > > and this is second execution: > ... > > > > > > > > > > > > As we can see both abixml files have *same nodes information* but the no= des > are in a different order, so the test should be marked as passed, however= using > the external diff command the test fails. so my question is should we rel= y in diff > command to compare the corpus of the ELF input files (abixml files)? So, you see here, this is exactly why we use the diff tool IN ADDITION to abidiff (which only look for ABI changes). Here, you see that two invocations of abidw is yielding possibly two *DIFFERENT* abixml files. They are different because some struct type definition come out in different order. Why? This is because we have two struct types that have the same (empty) name and yet they are different. The abixml writer sorts types using their names, somehow. So some times, one type comes first; some times, it's the other. Let's look at the issue a bit deeper. These are anonymous struct. For various reasons, we need to designate types in the Libabigail system. So every single type needs to be given a name. Even anonymous types. Most of the time, in C, anonymous types are named using typedefs. E.g: typedef struct { int x; } struct_name; "typedef struct_name" is the 'naming typedef' of the struct type. It's used to name it. That's how it's designated to be later used. The libabigail IR has the decl_base::set_naming_typedef() function to set naming typedefs on=20 If you look at the code of the dwarf reader, in the function build_typedef_type, near the end, you'll see that it uses the set_naming_typedef method to set the naming typedef of the underlying anonymous class (or struct) it sees. Once you've done that, the struct will be represented in the abixml file as having the name "struct_name". And your problem will be solved, I think. There are other techniques used in the dwarf-reader to handle anonymous types that are not named by a typedef. But those are super rare, especially in C. So I hope that using naming typedef should be good enough for a start, in practise. It's precisely to detect cases like this that the "diff" tool is used. I hope this helps. [...] Cheers, --=20 Dodji