From patchwork Fri Jun 11 17:04:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 43839 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 D3B983AAB45B for ; Fri, 11 Jun 2021 17:07:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3B983AAB45B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1623431235; bh=PJxJvlzsEOLUutnCo96HAriiBnSsAUj+OG+wNB+yizM=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=I7sfmSQsRP0szNcq8B21Wd8uuNx0+2hOim5bHBpuHJDrV7hYDN/J8cKDHyP9jw4z3 ao6B5EQoJnDrBVIpid4Konhr1qhIg20kY7aDS2kbqDPhmLjjRXkThD1UFRdE5Qws/k 4Art1UebRIBNTDG0yck07Hm/nhaswyAnXxz8NLIo= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by sourceware.org (Postfix) with ESMTPS id 952663B8A40B for ; Fri, 11 Jun 2021 17:04:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 952663B8A40B Received: by mail-qt1-x849.google.com with SMTP id z4-20020ac87f840000b02902488809b6d6so2309328qtj.9 for ; Fri, 11 Jun 2021 10:04:49 -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=PJxJvlzsEOLUutnCo96HAriiBnSsAUj+OG+wNB+yizM=; b=Ow0ZrbeYlT++hDJBxiwpCPCoSff1l9zEPUeWwE/UVXA6vOmEtrOsZ1rKQqzt52xrsY p/OlszAIdkDwMDwkB5N3TvBvOUb8rThMDWLFzCieE3VxjYeGBXE5un4fnrsomU/tcZKu q6NnskKOgC3H/63fnRUUTTnHn3Nk72SOhc43ffEsD7hrJIW20NqJG+HYhbiG2ij5pyn8 EbLxqKJrL1WkUklw9ZjAZC7v4N3nR0Oq5xdppPcRrmNYC62O/vZm8yMCbhZFYpnhSBkI pAC8NZZqazORxn3OEfzBaeNlszU1iERKk3jk8s3/3KdtUQ76qXjnPHFFa5GiEZ/jX0pi 5+1w== X-Gm-Message-State: AOAM531z8jOZ2QpdUnxU7hkJyHJi3QpX5vFcDbaQdpxZZylPhaEd9zhJ 4OG/gIHuyXFOVZT+ii4jNtDp9mcUkQRKiU82ZMnooViKtpTWdiduQqvQWcbK2vT3Hd9aIxiGXuH fxTJ+/Fn5+JlZP+NOIeGzvgLU3YpThnMUZsRQ+x0tz1gvq3LgNTRheK2zrWT3/HZtJUwKdSc= X-Google-Smtp-Source: ABdhPJz+8v77e6nDoplTMdxcc/KKwmuYxkZx3cXrJyumG1VVPVHALvTul11Kf3txv+GNshARNmG1yJIEbomQJw== X-Received: from tef.lon.corp.google.com ([2a00:79e0:d:210:c264:c1f9:cf3c:2c0b]) (user=gprocida job=sendgmr) by 2002:ad4:4dcb:: with SMTP id cw11mr5777418qvb.54.1623431089091; Fri, 11 Jun 2021 10:04:49 -0700 (PDT) Date: Fri, 11 Jun 2021 18:04:41 +0100 In-Reply-To: <20210611170442.845802-1-gprocida@google.com> Message-Id: <20210611170442.845802-2-gprocida@google.com> Mime-Version: 1.0 References: <20210611170442.845802-1-gprocida@google.com> X-Mailer: git-send-email 2.32.0.272.g935e593368-goog Subject: [PATCH 1/2] XML writer: don't emit already emitted types To: libabigail@sourceware.org X-Spam-Status: No, score=-22.0 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+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" The XML writer sometimes emits type definitions entirely duplicated. This happens if for some reason a type is emitted early but is later emitted as one of the canonical types associated with a translation unit. Bug 26591 - detect pathologically redundant types in abixml * src/abg-writer.cc: (writer_context::write_canonical_types_of_scope): Do not emit already emitted types. * tests/data/test-annotate/test14-pr18893.so.abi: Refresh. * tests/data/test-annotate/test15-pr18892.so.abi: Refresh. * tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Refresh. * tests/data/test-annotate/test21-pr19092.so.abi: Refresh. * tests/data/test-read-dwarf/test14-pr18893.so.abi: Refresh. * tests/data/test-read-dwarf/test15-pr18892.so.abi: Refresh. * tests/data/test-read-dwarf/test16-pr18904.so.abi: Refresh. * tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Refresh. * tests/data/test-read-dwarf/test21-pr19092.so.abi: Refresh. * tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Refresh. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Refresh. Signed-off-by: Giuliano Procida --- src/abg-writer.cc | 2 +- .../data/test-annotate/test14-pr18893.so.abi | 2 - .../data/test-annotate/test15-pr18892.so.abi | 8 -- ...19-pr19023-libtcmalloc_and_profiler.so.abi | 4 - .../data/test-annotate/test21-pr19092.so.abi | 79 ------------------- .../test-read-dwarf/test14-pr18893.so.abi | 1 - .../test-read-dwarf/test15-pr18892.so.abi | 4 - .../test-read-dwarf/test16-pr18904.so.abi | 2 - ...19-pr19023-libtcmalloc_and_profiler.so.abi | 2 - .../test-read-dwarf/test21-pr19092.so.abi | 59 -------------- .../test22-pr19097-libstdc++.so.6.0.17.so.abi | 1 - .../test9-pr18818-clang.so.abi | 18 ----- 12 files changed, 1 insertion(+), 181 deletions(-) diff --git a/src/abg-writer.cc b/src/abg-writer.cc index 03959bdc..8aa95948 100644 --- a/src/abg-writer.cc +++ b/src/abg-writer.cc @@ -2211,7 +2211,7 @@ write_canonical_types_of_scope(const scope_decl &scope, { if (is_member_type) write_member_type(*i, ctxt, indent); - else + else if (!ctxt.type_is_emitted(*i)) write_type(*i, ctxt, indent); } diff --git a/tests/data/test-annotate/test14-pr18893.so.abi b/tests/data/test-annotate/test14-pr18893.so.abi index 19be6587..fa106219 100644 --- a/tests/data/test-annotate/test14-pr18893.so.abi +++ b/tests/data/test-annotate/test14-pr18893.so.abi @@ -6327,8 +6327,6 @@ - - diff --git a/tests/data/test-annotate/test15-pr18892.so.abi b/tests/data/test-annotate/test15-pr18892.so.abi index e64f0ff7..a4c34ee5 100644 --- a/tests/data/test-annotate/test15-pr18892.so.abi +++ b/tests/data/test-annotate/test15-pr18892.so.abi @@ -7067,8 +7067,6 @@ - - @@ -7439,8 +7437,6 @@ - - @@ -9213,8 +9209,6 @@ - - @@ -23305,8 +23299,6 @@ - - diff --git a/tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi b/tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi index 131b8078..a494418e 100644 --- a/tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi +++ b/tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi @@ -15691,15 +15691,11 @@ - - - - diff --git a/tests/data/test-annotate/test21-pr19092.so.abi b/tests/data/test-annotate/test21-pr19092.so.abi index c742d7e4..6f769379 100644 --- a/tests/data/test-annotate/test21-pr19092.so.abi +++ b/tests/data/test-annotate/test21-pr19092.so.abi @@ -10448,85 +10448,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/data/test-read-dwarf/test14-pr18893.so.abi b/tests/data/test-read-dwarf/test14-pr18893.so.abi index cbfc0e19..03ef4898 100644 --- a/tests/data/test-read-dwarf/test14-pr18893.so.abi +++ b/tests/data/test-read-dwarf/test14-pr18893.so.abi @@ -4182,7 +4182,6 @@ - diff --git a/tests/data/test-read-dwarf/test15-pr18892.so.abi b/tests/data/test-read-dwarf/test15-pr18892.so.abi index 358000f0..6edc2e0e 100644 --- a/tests/data/test-read-dwarf/test15-pr18892.so.abi +++ b/tests/data/test-read-dwarf/test15-pr18892.so.abi @@ -3938,7 +3938,6 @@ - @@ -4173,7 +4172,6 @@ - @@ -5177,7 +5175,6 @@ - @@ -12961,7 +12958,6 @@ - diff --git a/tests/data/test-read-dwarf/test16-pr18904.so.abi b/tests/data/test-read-dwarf/test16-pr18904.so.abi index 8ee54646..efca4645 100644 --- a/tests/data/test-read-dwarf/test16-pr18904.so.abi +++ b/tests/data/test-read-dwarf/test16-pr18904.so.abi @@ -11234,7 +11234,6 @@ - @@ -18092,7 +18091,6 @@ - diff --git a/tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi b/tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi index 38fd82e3..781d63e8 100644 --- a/tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi +++ b/tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi @@ -9542,11 +9542,9 @@ - - diff --git a/tests/data/test-read-dwarf/test21-pr19092.so.abi b/tests/data/test-read-dwarf/test21-pr19092.so.abi index b4a20a04..77245cd0 100644 --- a/tests/data/test-read-dwarf/test21-pr19092.so.abi +++ b/tests/data/test-read-dwarf/test21-pr19092.so.abi @@ -6744,65 +6744,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi b/tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi index 1739af09..31342d1c 100644 --- a/tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi +++ b/tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi @@ -8244,7 +8244,6 @@ - diff --git a/tests/data/test-read-dwarf/test9-pr18818-clang.so.abi b/tests/data/test-read-dwarf/test9-pr18818-clang.so.abi index 7db018e4..cc3f6554 100644 --- a/tests/data/test-read-dwarf/test9-pr18818-clang.so.abi +++ b/tests/data/test-read-dwarf/test9-pr18818-clang.so.abi @@ -4949,24 +4949,6 @@ - - - - - - - - - - - - - - - - - - From patchwork Fri Jun 11 17:04:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 43840 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 916EE3AAB4B1 for ; Fri, 11 Jun 2021 17:07:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 916EE3AAB4B1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1623431238; bh=ozLmt6pqzbbDBsE5boGCMtG3JkIyH76+lyi8J2sWNSE=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=NX0IAC/GMmW/LKTeLCbNs/9jwh8ip6pwpMviaO61LXEcQOzz4v+L08wFLZOeutu8A N3Dgn9n4sT721xveJijV6dSK4ZO8j3VPB4erbt+0jNtKrrfhWe9LXtoX7HXxSeCPUT hYB28sVN9vvbrCSbEiYT0QokJQbfcmQseyqXAuEo= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-wm1-x34a.google.com (mail-wm1-x34a.google.com [IPv6:2a00:1450:4864:20::34a]) by sourceware.org (Postfix) with ESMTPS id ECA653B8A422 for ; Fri, 11 Jun 2021 17:04:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ECA653B8A422 Received: by mail-wm1-x34a.google.com with SMTP id n8-20020a05600c3b88b02901b6e5bcd841so1850907wms.9 for ; Fri, 11 Jun 2021 10:04: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:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ozLmt6pqzbbDBsE5boGCMtG3JkIyH76+lyi8J2sWNSE=; b=RZU+KqC4xbXVuN2sVFJJwiCaiTR0DCSV5ujydrR/LVMyJ4uXcxDRzmvN9nU1WQlj1z ixRdLqwJ4qac7SpKPJIgYNldUm3x2Ol4v5/4lDwtH8C925mXHxucjTcjX9GkAleWekKr EflrIEO0H8jZytP+IgTQK4MTf8NoNr5KCwRuegXi6qV0PZusqukUf3VvFZA2kKPXZYSo ccLwiuSKoCqpjdB1ROGe8BRiZbfMKGx4Eg9VEdnSYG51SMU/b+zWE1GnNSDfrlVcAoux h7uiX8LwMt2ZdV5l9mfw4jP7kicQYmqB1Z0E2CBJ/tYmdS45X0l9dF5KN6nNbuYfjyRR 7HIg== X-Gm-Message-State: AOAM531H3GYBP1BHSuvxkOO1RyT59RQQJKJDuh5lwbafidWOnAUpkUwp mOFMaU4oVK7xXPFS5Z30n3GulfRqjksALrkcRs5UkS4F5l5xDD/dQZfofULgrtTNybzVNsSBVCl 0/hLu085PQuuaT480/w23WG3yT10h45oCEAGXDcLKO7c6zj59BB45gRqqsoP/fViT6bUS+TY= X-Google-Smtp-Source: ABdhPJyefU1OkNttap07BvVtom3+Nij9DaqKt/eDb9P8fcaxgu9PUiqE8705uIph1D8HygnOSzB5EZJVNt89oQ== X-Received: from tef.lon.corp.google.com ([2a00:79e0:d:210:c264:c1f9:cf3c:2c0b]) (user=gprocida job=sendgmr) by 2002:a5d:60c8:: with SMTP id x8mr5369358wrt.382.1623431091413; Fri, 11 Jun 2021 10:04:51 -0700 (PDT) Date: Fri, 11 Jun 2021 18:04:42 +0100 In-Reply-To: <20210611170442.845802-1-gprocida@google.com> Message-Id: <20210611170442.845802-3-gprocida@google.com> Mime-Version: 1.0 References: <20210611170442.845802-1-gprocida@google.com> X-Mailer: git-send-email 2.32.0.272.g935e593368-goog Subject: [PATCH 2/2] XML writer: emit enclosing types of scoped declarations To: libabigail@sourceware.org X-Spam-Status: No, score=-23.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, 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+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" Bug 26591 - detect pathologically redundant types in abixml One source of duplicated type ids in ABI XML was the writer emitting scoped (nested) typed declarations before a later TU causes the emission of the complete enclosing type declaration. This no longer seems to occur within the current test suite. The code paths responsible are still active though, but don't ever appear to be asked to emit nested member types. This commit was my fix for the issue. It causes the outermost enclosing type declaration to be emitted immediately, rather than a nested member type. This prevents the later duplicate emission of the enclosing type and all its nested member types. This commit still does simplify the code paths and avoids the potential emission of partial types (which were sometimes accompanied by incorrect member-type access attributes). * src/abg-writer.cc: (write_decl_in_scope): Emit the enclosing types of any nested type declaration. Signed-off-by: Giuliano Procida --- src/abg-writer.cc | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/src/abg-writer.cc b/src/abg-writer.cc index 8aa95948..cf2693bf 100644 --- a/src/abg-writer.cc +++ b/src/abg-writer.cc @@ -1941,6 +1941,8 @@ write_decl(const decl_base_sptr& decl, write_context& ctxt, unsigned indent) /// Emit a declaration, along with its scope. /// +/// If the scope includes another type declaration, emit that instead. +/// /// This function is called at the end of emitting a translation unit, /// to emit type declarations that were referenced by types that were /// emitted in the TU already, but that were not emitted themselves. @@ -1972,6 +1974,7 @@ write_decl_in_scope(const decl_base_sptr& decl, stack closing_tags; stack closing_indents; unsigned indent = initial_indent; + bool done = false; for (list::const_iterator i = scopes.begin(); i != scopes.end(); ++i) @@ -1987,43 +1990,29 @@ write_decl_in_scope(const decl_base_sptr& decl, << "'>\n"; closing_tags.push(""); closing_indents.push(indent); + indent += c.get_xml_element_indent(); } - // ... or a class. + // ... or a class ... else if (class_decl* c = is_class_type(*i)) { class_decl_sptr class_type(c, noop_deleter()); - write_class_decl_opening_tag(class_type, "", ctxt, indent, - /*prepare_to_handle_members=*/false); - closing_tags.push(""); - closing_indents.push(indent); - - unsigned nb_ws = get_indent_to_level(ctxt, indent, 1); - write_member_type_opening_tag(type, ctxt, nb_ws); - indent = nb_ws; - closing_tags.push(""); - closing_indents.push(nb_ws); + write_class_decl(class_type, ctxt, indent); + done = true; } + // ... or a union. else if (union_decl *u = is_union_type(*i)) { union_decl_sptr union_type(u, noop_deleter()); - write_union_decl_opening_tag(union_type, "", ctxt, indent, - /*prepare_to_handle_members=*/false); - closing_tags.push(""); - closing_indents.push(indent); - - unsigned nb_ws = get_indent_to_level(ctxt, indent, 1); - write_member_type_opening_tag(type, ctxt, nb_ws); - indent = nb_ws; - closing_tags.push(""); - closing_indents.push(nb_ws); + write_union_decl(union_type, ctxt, indent); + done = true; } else // We should never reach this point. abort(); - indent += c.get_xml_element_indent(); } - write_decl(decl, ctxt, indent); + if (!done) + write_decl(decl, ctxt, indent); while (!closing_tags.empty()) {