From patchwork Thu Aug 25 11:48:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 57045 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 68555385275A for ; Thu, 25 Aug 2022 11:49:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 68555385275A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1661428153; bh=QPM6vmG1Xv4shS2aAeqolcema5zzL/hmbrcADA1xcDU=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=A0hxFkCY/thRDu4ZzR6ozaU/i34yFRrm3MxtQ7u2Mr67SSG2lvxjvD3/+W3GiCH9v KgTeJteFhNY3Kq7NovVt1twLWDYhTTD5Fj3592uSewkcJ0rvufeD479G+3DEpRDzk/ MVszY2STtU3VpBB/DgRuexoQ8OLxK9p5E75VPTWo= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-ed1-x54a.google.com (mail-ed1-x54a.google.com [IPv6:2a00:1450:4864:20::54a]) by sourceware.org (Postfix) with ESMTPS id 373403858C2F for ; Thu, 25 Aug 2022 11:49:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 373403858C2F Received: by mail-ed1-x54a.google.com with SMTP id m18-20020a056402511200b00446d4abe6c8so7025214edd.12 for ; Thu, 25 Aug 2022 04:49:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc; bh=QPM6vmG1Xv4shS2aAeqolcema5zzL/hmbrcADA1xcDU=; b=j1i9D0qrefUqxB8e9yqvsKTS7nw7WQl945mtc5/mFqvXTzk2CxV+3zEt62RYtwy8Ri Abyd2VuZ2KtYAxbjPk0zKZXWZnMkaYIuUqSLbdg3DetxuLpfgEGAXQOaYXZeqKxHxbAz HiEkslZn4m0iosBKqw9yxKX5ozj+anIYaMzqwc/8UcOZkJGNPcdGCGxdm/lVRf926Ryj eFVzItQb26nL24oAXQH+2kGmvBXnTTS77Rt+knHCnDxlFViFZcYKwfuks/AvgUZ83ZqO 6WaCwiiBDvCzZtZAFibDQyGWJ+Ma1lVmm7kBAPNEzMhPbqU6gxsuZrXHQ9YKRobwdiut qHFg== X-Gm-Message-State: ACgBeo07vT2x881rba6EbV51yJtQb9RHFn7uyPSNYPHZmImeVZcLuGIm DP6PFTnX3HLguonFXUPoD5sZvKsaCWOybTl5nwQoDmqezPmb0Iy9YFVZ0IsXMmxtBT4AhvLfz5/ co+eQGUpN1ZaWN9X2ownvKwesqRrL/5TiyxM9DIEng2EzAl4rxlXcuIpdj+CM2TqIOQ580Jk= X-Google-Smtp-Source: AA6agR4jUjeAUnXPUBpRIfAXXZz/x2c3hQuUMuWll31ARcTEyiW+W3Hj+uvAp6nlzdWmCPuwz8RMC/Me68vGFg== X-Received: from tef.lon.corp.google.com ([2a00:79e0:d:209:e2f1:457f:d595:4f88]) (user=gprocida job=sendgmr) by 2002:a05:6402:2791:b0:447:3193:6b13 with SMTP id b17-20020a056402279100b0044731936b13mr2966920ede.335.1661428146883; Thu, 25 Aug 2022 04:49:06 -0700 (PDT) Date: Thu, 25 Aug 2022 12:48:54 +0100 In-Reply-To: <20220825114856.3137373-1-gprocida@google.com> Message-Id: <20220825114856.3137373-2-gprocida@google.com> Mime-Version: 1.0 References: <20220825114856.3137373-1-gprocida@google.com> X-Mailer: git-send-email 2.37.1.595.g718a3a8f04-goog Subject: [PATCH 1/3] abidw: fix --stats output for resolved classes and enums To: libabigail@sourceware.org X-Spam-Status: No, score=-21.2 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL 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.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Giuliano Procida via Libabigail From: Giuliano Procida Reply-To: Giuliano Procida Cc: maennich@google.com, vvvvvv@google.com, sidnayyar@google.com, dodji@seketeli.org, kernel-team@android.com Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" The code to print out the remaining declaration-only types unintentionally omitted the first such type. This change fixes the logic and uses a single test to decide whether or not to print the stats header line. * src/abg-dwarf-reader.cc (read_context::resolve_declaration_only_classes): Fix conditional logic so that showing stats includes the first unresolved type. (read_context::resolve_declaration_only_enums): Likewise. Signed-off-by: Giuliano Procida --- src/abg-dwarf-reader.cc | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index e5159c89..a954de6d 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -4325,19 +4325,15 @@ public: ++i) declaration_only_classes().erase(*i); - for (string_classes_map::iterator i = declaration_only_classes().begin(); - i != declaration_only_classes().end(); - ++i) + if (show_stats() && !declaration_only_classes().empty()) { - if (show_stats()) - { - if (i == declaration_only_classes().begin()) - cerr << "Here are the " - << num_decl_only_classes - num_resolved - << " unresolved class declarations:\n"; - else - cerr << " " << i->first << "\n"; - } + cerr << "Here are the " + << num_decl_only_classes - num_resolved + << " unresolved class declarations:\n"; + for (string_classes_map::iterator i = declaration_only_classes().begin(); + i != declaration_only_classes().end(); + ++i) + cerr << " " << i->first << "\n"; } } @@ -4527,19 +4523,15 @@ public: ++i) declaration_only_enums().erase(*i); - for (string_enums_map::iterator i = declaration_only_enums().begin(); - i != declaration_only_enums().end(); - ++i) + if (show_stats() && !declaration_only_enums().empty()) { - if (show_stats()) - { - if (i == declaration_only_enums().begin()) - cerr << "Here are the " - << num_decl_only_enums - num_resolved - << " unresolved enum declarations:\n"; - else - cerr << " " << i->first << "\n"; - } + cerr << "Here are the " + << num_decl_only_enums - num_resolved + << " unresolved enum declarations:\n"; + for (string_enums_map::iterator i = declaration_only_enums().begin(); + i != declaration_only_enums().end(); + ++i) + cerr << " " << i->first << "\n"; } } From patchwork Thu Aug 25 11:48:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 57046 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 00C07385ED4D for ; Thu, 25 Aug 2022 11:49:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00C07385ED4D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1661428155; bh=ZoMIj64FRagNqtHpdrSgYUEYNvqT2i/z5SFVhm7Ii2g=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=EFTTjKp2xj6dIKQVuqS5VHXk2ktJzTT2AoQ52tyf56GvMb94NFSjooTx1opGFR22g QnnGtb5fZikAMgcfWCtMRQGupdvME7l6N4tGziYvZW+2bHQPzs98wqMYQrmLwsT6ar D258qzQn94w/TeGn/yL/CT8iESLeWdlWkQ+chHok= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-ed1-x549.google.com (mail-ed1-x549.google.com [IPv6:2a00:1450:4864:20::549]) by sourceware.org (Postfix) with ESMTPS id DA3C9385415D for ; Thu, 25 Aug 2022 11:49:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DA3C9385415D Received: by mail-ed1-x549.google.com with SMTP id y14-20020a056402440e00b0044301c7ccd9so12666329eda.19 for ; Thu, 25 Aug 2022 04:49:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc; bh=ZoMIj64FRagNqtHpdrSgYUEYNvqT2i/z5SFVhm7Ii2g=; b=HAprR8N7zZFEbKEni+ioaEfIjw+eVFeyV5+proQTzgHShf/1frh4zF9YUlkhR4QlHa PGXBZss/DSiuDBqoUvPwqokis/7IXO5x++C3bG2sVSjWGjwd0FQf1fF3GkmBtn7Jj8uR VLKBSjpNzyKy749KLZelFtzWzJtIJf+bNy4WkUh89sNFp83eXeXQ8fxjfkIL3+QUIwnL 5qrE1a07IrKbpnqitcgXd5CNdWK17pg8EiZXKGL75dgP0+IxnzyOlC1AguuyqLuZXMJG 9fLGG7iVkUmBEnO+DdjCqqL2V69mvfraARkcdwKz8PmYFjP4/WdTLUDgD9V4T3n/32Ho V4jQ== X-Gm-Message-State: ACgBeo0+x/659tCQW5nhr+Rz/IGEF+LoqIW6fLN+aeJCmFDB9lLghgg6 vP57p6f3Di8zjWwi5D5/vBBZDe+cuHNiiRxhCGJ2xcPUvFBNI1kaYZcfX61ty10htfE1l+g1BNt W0sOqqkWUr90MyCd1D6afYf1mpt84go/yOdhs40ffHsm+iYObP+SEuuFgCCSF+lXnwYffLSs= X-Google-Smtp-Source: AA6agR5agjcN2JMfWzo3gA1V+ENliZbz9H1kNWRskF/X26IROAufAD44awO8rTDad0qcHf0AIb9dyDfKFvb+Wg== X-Received: from tef.lon.corp.google.com ([2a00:79e0:d:209:e2f1:457f:d595:4f88]) (user=gprocida job=sendgmr) by 2002:a05:6402:35d4:b0:446:88da:9bd5 with SMTP id z20-20020a05640235d400b0044688da9bd5mr2884493edc.415.1661428149688; Thu, 25 Aug 2022 04:49:09 -0700 (PDT) Date: Thu, 25 Aug 2022 12:48:55 +0100 In-Reply-To: <20220825114856.3137373-1-gprocida@google.com> Message-Id: <20220825114856.3137373-3-gprocida@google.com> Mime-Version: 1.0 References: <20220825114856.3137373-1-gprocida@google.com> X-Mailer: git-send-email 2.37.1.595.g718a3a8f04-goog Subject: [PATCH 2/3] abidw: remove always true test in resolve_declaration_only_classes To: libabigail@sourceware.org X-Spam-Status: No, score=-21.4 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL 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.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Giuliano Procida via Libabigail From: Giuliano Procida Reply-To: Giuliano Procida Cc: maennich@google.com, vvvvvv@google.com, sidnayyar@google.com, dodji@seketeli.org, kernel-team@android.com Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" The code that makes the last attempt to resolve declaration-only types was protected by a conditional checking that the number of TUs for a given type was more than 1. The previous branch checked for exactly 1. However, the entire block is inside a conditional where the number of TUs is guaranteed to be greater than 0. Removing the conditional makes it clear that this branch handles all remaining cases. * src/abg-dwarf-reader.cc (read_context::resolve_declaration_only_classes): Remove tautological conditional. Signed-off-by: Giuliano Procida --- src/abg-dwarf-reader.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index a954de6d..b5e60e35 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -4274,7 +4274,7 @@ public: else if (per_tu_class_map.size() == 1) (*j)->set_definition_of_declaration (per_tu_class_map.begin()->second); - else if (per_tu_class_map.size() > 1) + else { // We are in case where there are more than // one definition for the declaration. Let's From patchwork Thu Aug 25 11:48:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 57047 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 C40AB385C41C for ; Thu, 25 Aug 2022 11:49:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C40AB385C41C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1661428158; bh=gifOBxPiTz6wTBuxf3A2FytLOjr1o2CPp6ahHDbZNlY=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=gBAtMZOXItTxvnLRisfzrW9sSjsR/azy81mut8V3YWz9PuVZS547BSXqxhRUmKeA7 eaGxikj4BxLCvJK3mFZQUfISpoR98TnYTYws1xV/IWXG9finditsqzyhrOrFxwp4ed oKUhhncDU5ZY2RxAav79kp2x334tSVGNQrIrdNZ4= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-ej1-x64a.google.com (mail-ej1-x64a.google.com [IPv6:2a00:1450:4864:20::64a]) by sourceware.org (Postfix) with ESMTPS id 53B153852742 for ; Thu, 25 Aug 2022 11:49:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 53B153852742 Received: by mail-ej1-x64a.google.com with SMTP id mp41-20020a1709071b2900b0073d84b11981so4004100ejc.23 for ; Thu, 25 Aug 2022 04:49:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc; bh=gifOBxPiTz6wTBuxf3A2FytLOjr1o2CPp6ahHDbZNlY=; b=dAHB77bZ43mqSkbny4fIpt2WNsL5uwKGL39ItvK4/SbLiLaTP8gZOw4qRiXf3TEmt5 WAnLRFsjuROMeUGZDqMWM5p/7owjFBYQLRyTSQiG+R75A8mVkNnxOjhhY2CgDgBRBlFM czzbzje9i6LJin2F1gHeNAHqkzcCzUPUPgt9KQzRhIe+h147xspWZuY/yEmrS3dPso4G FH7RCca0CHhZ3qMJKBkMq7Wxs89iNbgRcAx3wX9UJM8OSgR9IgTzHB/0GhIcTP4X1n8i altaZ2FoNmQ7TxH4e9l/OQryerLeSVJhoM8QTDBIAW08JnSM2Um+hXp15LCm6If/Qxjc /3QQ== X-Gm-Message-State: ACgBeo3x03iNO77so61PQCPtj8c4L+CDDhWw+1eFOfsfmQ9GGZ+FYeNX V7BLiz5J4lJ4etidDP4pxFp7inZ1jD6+jRoD9HfSKcZ7gvBvM1eUdLQSLnH3E2hCa6bVRFXi/Ev lr8qD83WOb3yLzLV98V/kBdnOWJzpwEqVFxHsaA2FamJDElK/h2kCNLWcPQSOn/nQ9dsVPTE= X-Google-Smtp-Source: AA6agR5wFp8xNIvnUizivKcwm3NTnxOX4uhXpKQF87HawjKm2iUviO24uAdZ1Yn1Uyc2DrX/tNNPxfgp+eJGoQ== X-Received: from tef.lon.corp.google.com ([2a00:79e0:d:209:e2f1:457f:d595:4f88]) (user=gprocida job=sendgmr) by 2002:a05:6402:1041:b0:446:b290:ea94 with SMTP id e1-20020a056402104100b00446b290ea94mr2819144edu.389.1661428152153; Thu, 25 Aug 2022 04:49:12 -0700 (PDT) Date: Thu, 25 Aug 2022 12:48:56 +0100 In-Reply-To: <20220825114856.3137373-1-gprocida@google.com> Message-Id: <20220825114856.3137373-4-gprocida@google.com> Mime-Version: 1.0 References: <20220825114856.3137373-1-gprocida@google.com> X-Mailer: git-send-email 2.37.1.595.g718a3a8f04-goog Subject: [PATCH 3/3] abidw: resolve declaration-only enums the same as classes To: libabigail@sourceware.org X-Spam-Status: No, score=-21.1 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL 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.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Giuliano Procida via Libabigail From: Giuliano Procida Reply-To: Giuliano Procida Cc: maennich@google.com, vvvvvv@google.com, sidnayyar@google.com, dodji@seketeli.org, kernel-team@android.com Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" The logic for resolving declaration-only enums and classes was almost the same. However, the class code had a couple of extra improvements that were missing from the enum code. One of these caused resolution failures with Linux kernel ABIs, resulting in duplicate (declared / defined) enums in ABI XML. This change adds the improvements to the enum resolution code. * src/abg-dwarf-reader.cc (read_context::resolve_declaration_only_enums): Use an ordered map to ensure TUs are always considered in the same order and so improve ABI XML stability. Given multiple possible definitions for a enum declaration, check to see if they are equal and resolve the declaration to the first definition if so. Signed-off-by: Giuliano Procida --- src/abg-dwarf-reader.cc | 42 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index b5e60e35..df50ef7d 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -4460,7 +4460,13 @@ public: if (!enums) continue; - unordered_map per_tu_enum_map; + // This is a map that associates the translation unit path to + // the enum (that potentially defines the declarations that + // we consider) that are defined in that translation unit. It + // should stay ordered by using the TU path as key to ensure + // stability of the order of enum definitions in ABIXML + // output. + map per_tu_enum_map; for (type_base_wptrs_type::const_iterator c = enums->begin(); c != enums->end(); ++c) @@ -4497,13 +4503,45 @@ public: { string tu_path = (*j)->get_translation_unit()->get_absolute_path(); - unordered_map::const_iterator e = + map::const_iterator e = per_tu_enum_map.find(tu_path); if (e != per_tu_enum_map.end()) (*j)->set_definition_of_declaration(e->second); else if (per_tu_enum_map.size() == 1) (*j)->set_definition_of_declaration (per_tu_enum_map.begin()->second); + else + { + // We are in case where there are more than + // one definition for the declaration. Let's + // see if they are all equal. If they are, + // then the declaration resolves to the + // definition. Otherwise, we are in the case + // 3/ described above. + map::const_iterator it; + enum_type_decl_sptr first_enum = + per_tu_enum_map.begin()->second; + bool all_enum_definitions_are_equal = true; + for (it = per_tu_enum_map.begin(); + it != per_tu_enum_map.end(); + ++it) + { + if (it == per_tu_enum_map.begin()) + continue; + else + { + if (!compare_before_canonicalisation(it->second, + first_enum)) + { + all_enum_definitions_are_equal = false; + break; + } + } + } + if (all_enum_definitions_are_equal) + (*j)->set_definition_of_declaration(first_enum); + } } } resolved_enums.push_back(i->first);