From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <3LFirXggKCoUvjnwwrlqpxxpun.lxvurkjkrpjru1x30ln5j0n.x0p@flex--maennich.bounces.google.com> Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by sourceware.org (Postfix) with ESMTPS id CBAB6395C408 for ; Thu, 30 Apr 2020 22:58:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CBAB6395C408 Received: by mail-yb1-xb4a.google.com with SMTP id i13so9661329ybl.13 for ; Thu, 30 Apr 2020 15:58:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=TN4GCEo4FE0zTfELNq86SbuAos2CFpiacVOE2u1FXho=; b=pCxyH73sGrX9fNESUErceSrvYJbbOvuFSMkQuovFRymKH8/SC5qC++Aq6Vz1gF9CQP EcGC3yY1wHh1rZxiEMWQt7pp4Xz7zORJS7kBjYTc2IUHClskhl0EXtptRM1aEPGH6Lj9 wUid92X5sEIjvkH9ld1LUk5zp8AJUOWkLbbyBzd8e9UgrymxN2lNfztlXSeBv+FdsVwo yn6S6/CqhH35FAoHqD4T6orfvHeYqrCmcQZmlGBxITBa2JgnkLPWRAx/Qu5bmdDMsEDJ HgnbjaDymyPSUYoEohzLUvdRmMVdBztI6ZFwaRGdKokixL+f191A7nOho9LbIg9K7gvl dqOQ== X-Gm-Message-State: AGi0PuYNzdmiRcK5QPd4t8pksawExXmnxzEgu/GClSqcESUHIJt9Sz3x JCDVlVNs2uEHaqAVfmWYx+BYxsU43UesOrqmlLCuF6UGl1jY3BLVrMo93zmJuPHCyLk0LpCis+l yxg/U5gMBx0+mQHQHIaAGLFGn6L/O46i55eOkTZH+Fyi/k+u7++V64vNmaUslESsDkKIYZA8= X-Google-Smtp-Source: APiQypIr14GXRQzFlvZMt2GXwvCKa/6GEqGiK54BORhwNIBj4Qmk1YBnCh8tys4YYlJG2XWEcbiURkYuYqCMVw== X-Received: by 2002:a25:aa24:: with SMTP id s33mr2111076ybi.68.1588287532246; Thu, 30 Apr 2020 15:58:52 -0700 (PDT) Date: Fri, 1 May 2020 00:58:01 +0200 Message-Id: <20200430225800.28768-1-maennich@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.26.2.526.g744177e7f7-goog Subject: [RESEND PATCH] corpus/writer: sort emitted translation units by path name From: Matthias Maennich To: libabigail@sourceware.org Cc: dodji@seketeli.org, gprocida@google.com, kernel-team@android.com, maennich@google.com, mark@klomp.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-33.9 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libabigail mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Apr 2020 22:58:54 -0000 By sorting the corpora output, we achieve determinism for the emitted XML file across multiple runs of abidw. For that to happen, change the collection of translation units to a std::set (instead of std::vector), sorted by absolute path name. Test data needed adjustments, but changes are fully compatible. * include/abg-fwd.h: remove translation_units fwd declaration. * include/abg-ir.h: add SharedTranslationUnitComparator and add translation_units fwd declaration as a set using said comparator. * src/abg-corpus.cc (corpus::add): do checked insert into the translation_units set (rather than vector::pushback) * tests/data/test-annotate/test13-pr18894.so.abi: Adjust test data. * tests/data/test-annotate/test14-pr18893.so.abi: Likewise. * tests/data/test-annotate/test15-pr18892.so.abi: Likewise. * tests/data/test-annotate/test17-pr19027.so.abi: Likewise. * tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise. * tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise. * tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise. * tests/data/test-annotate/test21-pr19092.so.abi: Likewise. Signed-off-by: Matthias Maennich --- I cut out the test data changes when sending this PATCH to avoid a crazy large email. The test data can be restored quite easily, but I also staged the change in the mm/sort-tu-by-name branch [1] easily cherry pickable as d5bdebdbd3a8 ("corpus/writer: sort emitted translation units by path name") Cheers, Matthias [1] https://sourceware.org/git/?p=libabigail.git;a=commit;h=d5bdebdbd3a8a5abd804b314ded517ae6fa26d2e include/abg-fwd.h | 2 - include/abg-ir.h | 15 + src/abg-corpus.cc | 3 +- .../data/test-annotate/test13-pr18894.so.abi | 562 +- .../data/test-annotate/test14-pr18893.so.abi | 11708 +-- .../data/test-annotate/test15-pr18892.so.abi | 71712 +++++++-------- .../data/test-annotate/test17-pr19027.so.abi | 54448 +++++------ ...st18-pr19037-libvtkRenderingLIC-6.1.so.abi | 58 +- ...19-pr19023-libtcmalloc_and_profiler.so.abi | 76289 ++++++++-------- ...st20-pr19025-libvtkParallelCore-6.1.so.abi | 9220 +- .../data/test-annotate/test21-pr19092.so.abi | 12358 +-- 11 files changed, 118387 insertions(+), 117988 deletions(-) diff --git a/include/abg-fwd.h b/include/abg-fwd.h index 1aab70a663de..cffa3f0d1aa3 100644 --- a/include/abg-fwd.h +++ b/include/abg-fwd.h @@ -119,8 +119,6 @@ class translation_unit; /// Convenience typedef for a shared pointer on a @ref /// translation_unit type. typedef shared_ptr translation_unit_sptr; -/// Convenience typedef for a vector of @ref translation_unit_sptr. -typedef std::vector translation_units; /// Convenience typedef for a map that associates a string to a /// translation unit. typedef unordered_map string_tu_map_type; diff --git a/include/abg-ir.h b/include/abg-ir.h index fda10de5c537..83dbe02f605d 100644 --- a/include/abg-ir.h +++ b/include/abg-ir.h @@ -33,6 +33,7 @@ #include #include #include +#include #include "abg-cxx-compat.h" #include "abg-fwd.h" #include "abg-hash.h" @@ -707,6 +708,20 @@ public: translation_unit& tu); };//end class translation_unit +struct SharedTranslationUnitComparator +{ + bool + operator()(const translation_unit_sptr& lhs, + const translation_unit_sptr& rhs) const + { + return lhs->get_absolute_path() < rhs->get_absolute_path(); + } +}; + +/// Convenience typedef for a vector of @ref translation_unit_sptr. +typedef std::set + translation_units; + string translation_unit_language_to_string(translation_unit::language); diff --git a/src/abg-corpus.cc b/src/abg-corpus.cc index 12f44fd1e4cf..e01c20f75b4d 100644 --- a/src/abg-corpus.cc +++ b/src/abg-corpus.cc @@ -560,7 +560,8 @@ corpus::add(const translation_unit_sptr tu) ABG_ASSERT(tu->get_environment() == get_environment()); - priv_->members.push_back(tu); + ABG_ASSERT(priv_->members.insert(tu).second); + if (!tu->get_absolute_path().empty()) { // Update the path -> translation_unit map. -- 2.26.2.526.g744177e7f7-goog