From patchwork Thu Aug 29 16:07:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 96722 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3E0B73860760 for ; Thu, 29 Aug 2024 16:07:31 +0000 (GMT) X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 8C12B385DDD2 for ; Thu, 29 Aug 2024 16:07:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8C12B385DDD2 Authentication-Results: sourceware.org; dmarc=pass (p=none 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 8C12B385DDD2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724947645; cv=none; b=RZIWKS4PFWKXqHJtkTGl1UzRXDTSteaHoZv2AtlYtgZB+sxOXmNynNXepMkCzdhNmjDSayoHWJV8q5BYZtLL6YvpZfgAqynSSM/ONt8tHUI4G2Jm5Q9x2aSjzeCVS1X7Vu+pN8dFAmrry95B9bh+5c9Vqray3cUlF+/33gttap0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724947645; c=relaxed/simple; bh=P+Ou/beks2ULSrpEpE3dzW0zFWBkSBLiPEQlAzja9ag=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=EAaM7j3mdkbdKfE1ZqxnDSBT2aQqMz6lIX3mrd1KITtqe8KbJado/W8uEnUinZzfZaHd6Sw54tYF3z4PEry/D0FfpqzyJBu8l8pVyT+LRye84NVSawdEN6wnPkxPbtZ7rkhkkYyuWooFGucc498ZuGxnFxzeQA+SRiKMz1xBPB0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724947642; 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=P1eqzhqr7WlDIxYZn8JwQZwEr3zCls6E/1IwhKMMd0U=; b=FYmuky178xROR1fsrmCSFl2yUA1cdH9g0JAaZJ18K+8YIW8w8nXgovefR5PltgSbIrUFVC D3XJnmW5PHtcbzy8eLJUvl6w5N31G2gtHZwrh5mQONHKnJf38BGPFTrTW30/sSxE7DM9uJ v2/osOnebUuBCNdhhj+Nx8ftdydT9wc= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-487-HxrCDld-NVaklSzjwrygfA-1; Thu, 29 Aug 2024 12:07:20 -0400 X-MC-Unique: HxrCDld-NVaklSzjwrygfA-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-44fe92a34d2so12327241cf.0 for ; Thu, 29 Aug 2024 09:07:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724947640; x=1725552440; h=mime-version:user-agent:message-id:in-reply-to:date:references :organization:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P1eqzhqr7WlDIxYZn8JwQZwEr3zCls6E/1IwhKMMd0U=; b=qYQkpEzNuP5VWGGvx1MpUpr+wIlxptxCZtYuFUv09yICdgg+eTxV8pL1AgxVPe/t2h 0R8FS3+Sp16iStZxYy3oGTD+2gRl7n0S0JhlL+Dt5Pzu5UMBFKOiU2A3at/ZRuQIvZnU C3UUkTFCKHXxdiOeKK1ytUbjuQwkAS3X7eYKQyppI2VgbdJVj7rzhCZC+XOODTaNRq17 p+0Dbx7Dp5Tvout7oCqAeDA37ekMnqY6QhztSzy7iqNPp0bLmo5egr/Q04WgDVi/BQ32 53lzZP0NeNserN39a3kTL6fVxL53i8OfXUavIdlo3SNuZaVztx0XhjjqN50Qgd9tm9zz fTqQ== X-Gm-Message-State: AOJu0YyK7UIH8s9ZLGRel7VX5GpnSHLNo48Zia1ecsXMYL/wP1pm7rQw r2hqXSctr4+/Q+YMSLWB58E+0fjbDAKA+Kfs+C67XsTFcMIcDSmxJFMGdXHfNok21CGTUw3EdAt EMHTmj8b9+P4UEOw3k14k0nYr1SCzb9vrEPv2Rqd7Gc1yWDZdtFQo0aMken772yxb0A== X-Received: by 2002:a05:622a:1e8b:b0:451:d7d4:c927 with SMTP id d75a77b69052e-4567f55b7f4mr39508481cf.24.1724947639785; Thu, 29 Aug 2024 09:07:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFlUH7/oTFlDC9jlBB+NWgf90DQGUMke5UfQk4uaBFlwZwV48lrVTdxQz6eamVRDlXyq2BOg== X-Received: by 2002:a05:622a:1e8b:b0:451:d7d4:c927 with SMTP id d75a77b69052e-4567f55b7f4mr39508061cf.24.1724947639104; Thu, 29 Aug 2024 09:07:19 -0700 (PDT) Received: from localhost (88-120-130-27.subs.proxad.net. [88.120.130.27]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-45682d66c3dsm5963311cf.70.2024.08.29.09.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 09:07:18 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id 52976503C602; Thu, 29 Aug 2024 18:07:17 +0200 (CEST) From: Dodji Seketeli To: dodji@redhat.com Cc: libabigail@sourceware.org Subject: [PATCH 19/27] {btf,ctf,dwarf}-reader, ir: Fix self-comparison debugging for corpus groups Organization: Me, myself and I References: <20240829154711.1883174-1-dodji@redhat.com> X-Operating-System: AlmaLinux 9.4 X-URL: http://www.seketeli.net/~dodji Date: Thu, 29 Aug 2024 18:07:17 +0200 In-Reply-To: <20240829154711.1883174-1-dodji@redhat.com> (dodji@redhat.com's message of "Thu, 29 Aug 2024 17:46:29 +0200") Message-ID: <87zfovjosq.fsf@seketeli.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libabigail-bounces~patchwork=sourceware.org@sourceware.org Hello, When debugging the self comparison of a corpus group, libabigail fails to detect that two ABI artifacts belong to the same corpus group. This is because it only takes into account each individual corpus, not the fact that several corpora can be grouped into one corpus group. This patch introduces a new function type_originates_from_corpus which can detect that a type originates from a corpus or a from a corpus group. That function is used to detect that the type being canonicalized belongs to the ABIXML corpus group and so its canonical type must match the one of its originating ELF type. * src/abg-btf-reader.cc (reader::read_debug_info_into_corpus): When reading an ELF binary, which is part of a corpus group, for the purpose of self-comparison, set that corpus group as the comparison input. Otherwise, if the ELF binary is not part of the corpus group, set its corpus as the comparison input. This is done only when we are debugging the self-comparison process by doing abidw --debug-abidiff. * src/abg-ctf-reader.cc (reader::read_corpus): Likewise. * src/abg-dwarf-reader.cc (reader::read_debug_info_into_corpus): Likewise. * src/abg-ir-priv.h (type_originates_from_corpus): Declare ... * src/abg-ir.cc (type_originates_from_corpus): ... new function. (type_base::get_canonical_type_for): When debugging the self-comparison process, use the new type_originates_from_corpus to know if the current type being canonicalized originates from the second corpus. Signed-off-by: Dodji Seketeli --- src/abg-btf-reader.cc | 11 +++++++++++ src/abg-ctf-reader.cc | 11 +++++++++++ src/abg-dwarf-reader.cc | 8 +++++++- src/abg-ir-priv.h | 3 ++- src/abg-ir.cc | 35 ++++++++++++++++++++++++++++++++++- 5 files changed, 65 insertions(+), 3 deletions(-) diff --git a/src/abg-btf-reader.cc b/src/abg-btf-reader.cc index 5ca1f2db..ff0cc91d 100644 --- a/src/abg-btf-reader.cc +++ b/src/abg-btf-reader.cc @@ -552,6 +552,17 @@ public: corpus()->add(artificial_tu); cur_tu(artificial_tu); +#ifdef WITH_DEBUG_SELF_COMPARISON + if (env().self_comparison_debug_is_on()) + { + corpus_group_sptr g = corpus_group(); + if (g) + env().set_self_comparison_debug_input(g); + else + env().set_self_comparison_debug_input(corpus()); + } +#endif + int number_of_types = nr_btf_types(btf_handle()); int first_type_id = 1; // Are we looking at the BTF for a kernel module? diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc index 7a92ecee..1a94fb21 100644 --- a/src/abg-ctf-reader.cc +++ b/src/abg-ctf-reader.cc @@ -707,6 +707,17 @@ public: && (status & fe_iface::STATUS_DEBUG_INFO_NOT_FOUND)) return corp; +#ifdef WITH_DEBUG_SELF_COMPARISON + if (env().self_comparison_debug_is_on()) + { + corpus_group_sptr g = corpus_group(); + if (g) + env().set_self_comparison_debug_input(g); + else + env().set_self_comparison_debug_input(corpus()); + } +#endif + tools_utils::timer t; if (do_log()) t.start(); diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 5ce68ab1..d067a5a3 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -2296,7 +2296,13 @@ public: #ifdef WITH_DEBUG_SELF_COMPARISON if (env().self_comparison_debug_is_on()) - env().set_self_comparison_debug_input(corpus()); + { + corpus_group_sptr g = corpus_group(); + if (g) + env().set_self_comparison_debug_input(g); + else + env().set_self_comparison_debug_input(corpus()); + } #endif env().priv_->do_log(do_log()); diff --git a/src/abg-ir-priv.h b/src/abg-ir-priv.h index 2d55e68b..d77e4ff7 100644 --- a/src/abg-ir-priv.h +++ b/src/abg-ir-priv.h @@ -1841,7 +1841,8 @@ struct function_type::priv size_t get_canonical_type_index(const type_base& t); - +bool +type_originates_from_corpus(type_base_sptr t, corpus_sptr& c); } // end namespace ir } // end namespace abigail diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 398b4efa..a4f5b634 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -363,6 +363,37 @@ size_t get_canonical_type_index(const type_base_sptr& t) {return get_canonical_type_index(t.get());} +/// Test if a type originates from a corpus. +/// +/// Note that this function supports testing if a type originates from +/// a corpus group. +/// +/// @param t the type to consider. +/// +/// @param c the corpus or corpus group to consider. +/// +/// @return true iff the type @p t originates from the corpus (or +/// group) @p c. +bool +type_originates_from_corpus(type_base_sptr t, corpus_sptr& c) +{ + bool result = false; + if (c && t->get_corpus()) + { + corpus_group_sptr g = is_corpus_group(c); + if (g) + { + if (t->get_corpus()->get_group() == g.get()) + result = true; + } + else + { + if (t->get_corpus() == c.get()) + result = true; + } + } + return result; +} /// @brief the location of a token represented in its simplest form. /// Instances of this type are to be stored in a sorted vector, so the /// type must have proper relational operators. @@ -15453,7 +15484,9 @@ type_base::get_canonical_type_for(type_base_sptr t) // possibly via the use of 'abidw --debug-abidiff '. corpus_sptr corp1, corp2; env.get_self_comparison_debug_inputs(corp1, corp2); - if (corp1 && corp2 && t->get_corpus() == corp2.get()) + if (corp1 && corp2 && type_originates_from_corpus(t, corp2) + && corp1->get_origin() != corp2->get_origin() + && corp2->get_origin() & corpus::NATIVE_XML_ORIGIN) { // If 't' comes from the second corpus, then it *must* // be equal to its matching canonical type coming from