From patchwork Thu Mar 25 21:51:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 42780 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 ECA133854801; Thu, 25 Mar 2021 21:52:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ECA133854801 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1616709145; bh=HciouxOvNM2thMTy8tqVKblL7VMaq9wCpqY1gPsm3ts=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=s+pevrzJSMY+Mc5XJD/5E2EfVIk9Yq/UjCMVVY+H4scCmn5kEMMkEP1nII/OnKzs7 mE3rFQX+OMVuvFvjqRVweNbpuxUxLctn/L8tdwRm1rnNTcVUhXrrquQbgUDTU/EuUz EaXUjheih3vGP2LHQ1XUARJkGXR//qgN6HrOInnk= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by sourceware.org (Postfix) with ESMTPS id 0E919385800D for ; Thu, 25 Mar 2021 21:52:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0E919385800D Received: by mail-qk1-x74a.google.com with SMTP id b136so4867489qkc.20 for ; Thu, 25 Mar 2021 14:52:17 -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:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=HciouxOvNM2thMTy8tqVKblL7VMaq9wCpqY1gPsm3ts=; b=gdTkDpwzasLwdRAoyXt8y8Qcyl9+txpCWOuuwUUpHndXrBYYtloaI3H1IpivzaPUo3 PeZZMm4D8c1qPQq7C+T9L9sY/BPZwRXx/QfZp7dyPTGcK/moFsuId5ag6UMpIMxO0Wjt Gmqia3UkO1Yaiv0IPHWI9+COxdRVunW+BpQ+odE8rVCybslRjbEG/t+NxfZ3XaYD3W1Q B/18lhp+O9hTudP6jOZuM6IwxfYOC7sGQaFL8Uz05kAfAij1oKl2mYI7duftD4QGpB/6 MeiteXFZWIlX9g4Erga/VuKp8IjexKYu8KF2x2PodHTUs1ksR4SUQ25VXi7iCUJx2EKv 1ImQ== X-Gm-Message-State: AOAM531j/EmmIIOGywgCvkvJuFZdyZha0Y3llo81s5senAQY3Pkvsn5R yktuYHD8omHLCpZ59IBS/DJuSCdf++nbeCtRHtkXSiHSRZrRtcgD19y4wDFAqJ/FxZaBz8FKV51 UevUzPasVVGopJArl/p3F+cRflsjdjebaEObfEm6IvHH5Udajog6nLFtqE8O06DFBVesXLUc= X-Google-Smtp-Source: ABdhPJyhRh4nvgyqQswl8jr0xVZlO4QLdKLgTY7m6H6tMClyeCDV98i3vAtfNFF0lojP3R16xfmNMFpcNj8UUg== X-Received: from tef.lon.corp.google.com ([2a00:79e0:d:110:2df6:f24a:7f54:86a8]) (user=gprocida job=sendgmr) by 2002:a0c:e38f:: with SMTP id a15mr10677802qvl.18.1616709136554; Thu, 25 Mar 2021 14:52:16 -0700 (PDT) Date: Thu, 25 Mar 2021 21:51:43 +0000 In-Reply-To: <20210325215146.3597963-1-gprocida@google.com> Message-Id: <20210325215146.3597963-7-gprocida@google.com> Mime-Version: 1.0 References: <20210316165509.2658452-1-gprocida@google.com> <20210325215146.3597963-1-gprocida@google.com> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog Subject: [RFC PATCH 6/9] Add pass to report duplicate type ids To: libabigail@sourceware.org X-Spam-Status: No, score=-22.8 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, 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: 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, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" Duplicate type ids sometimes appear ABI XML files. If these relate to subrange elements, they are innocuous, otherwise they represent some duplication or even inconsistency in libabigail output. See https://sourceware.org/bugzilla/show_bug.cgi?id=26591. * scripts/abitidy.pl (report_duplicate_types): New function to report duplicate types. Signed-off-by: Giuliano Procida --- scripts/abitidy.pl | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/scripts/abitidy.pl b/scripts/abitidy.pl index 321363d7..d5ddd7ea 100755 --- a/scripts/abitidy.pl +++ b/scripts/abitidy.pl @@ -376,6 +376,22 @@ sub normalise_anonymous_type_names($) { } } +sub report_duplicate_types($dom) { + my %hash; + for my $type ($dom->findnodes('*[@id]')) { + # subranges are not really types and shouldn't be considered + next if $type->getName() eq 'subrange'; + my $id = $type->getAttribute('id'); + for my $ids ($hash{$id}) { + $ids //= []; + push @$ids, $type; + } + } + for my $id (keys %hash) { + warn "residual duplicated types with id $id\n"; + } +} + # Parse arguments. my $input_opt; my $output_opt; @@ -384,15 +400,17 @@ my $all_opt; my $drop_opt; my $prune_opt; my $normalise_opt; +my $report_opt; GetOptions('i|input=s' => \$input_opt, 'o|output=s' => \$output_opt, 's|symbols=s' => \$symbols_opt, 'a|all' => sub { - $drop_opt = $prune_opt = $normalise_opt = 1 + $drop_opt = $prune_opt = $normalise_opt = $report_opt = 1 }, 'd|drop-empty!' => \$drop_opt, 'p|prune-unreachable!' => \$prune_opt, 'n|normalise-anonymous!' => \$normalise_opt, + 'r|report-duplicates!' => \$report_opt, ) and !@ARGV or die("usage: $0", map { (' ', $_) } ( '[-i|--input file]', @@ -402,6 +420,7 @@ GetOptions('i|input=s' => \$input_opt, '[-d|--[no-]drop-empty]', '[-p|--[no-]prune-unreachable]', '[-n|--[no-]normalise-anonymous]', + '[-r|--[no-]report-duplicates]', ), "\n"); exit 0 unless defined $input_opt; @@ -420,6 +439,9 @@ filter_symbols(read_symbols($symbols_opt), $dom) if defined $symbols_opt; # Normalise anonymous type names. normalise_anonymous_type_names($dom) if $normalise_opt; +# Check for duplicate types. +report_duplicate_types($dom) if $report_opt; + # Prune unreachable elements. prune_unreachable($dom) if $prune_opt;