From patchwork Tue Sep 22 11:29:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 40469 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 AD69D386F430; Tue, 22 Sep 2020 11:29:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD69D386F430 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1600774174; bh=5IZ363Hn5UnBKTszqVwfyVOHx0qUwJnaU0I+HcpHa3o=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=MsX0SL2k7gAVn8sTIpumkHz+6+9Mz0b4bENc8mQqcGiPzcXoTUKFwKYM34Svq0/cE pLlZVmWxCkcEdXqkdTR/T0FH+M5ji6fNSzjR7i5mNEF4TT0clgvGycZranOwG5r59Q oWfmtIm+Hn5VBj09+HNenADIrwI9ItKmWIeieLqQ= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-wm1-x349.google.com (mail-wm1-x349.google.com [IPv6:2a00:1450:4864:20::349]) by sourceware.org (Postfix) with ESMTPS id 185AA38708C5 for ; Tue, 22 Sep 2020 11:29:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 185AA38708C5 Received: by mail-wm1-x349.google.com with SMTP id w3so790845wmg.4 for ; Tue, 22 Sep 2020 04:29:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=5IZ363Hn5UnBKTszqVwfyVOHx0qUwJnaU0I+HcpHa3o=; b=YhMjVszSzZaWoOBtQi5cqaQx1XrmpDET9BzlCE8mts39T1uq+WUtTNRVoOecLhoEfC CH9weQpv/K0/JmYM2a6kUHHSZx8IQ4Hi6KanQSZJrQrxkO9gjSaAlh7RQrJUF3cNj7AG yTCD6im98slD1pOxpk7xMQ+tPn/rO0XhSxQa831uUSyPihU3/jwQKQlemFlITB7XeAtu 698dUJDt79lggCLOzAcp0tat+5CiJdgipzu+ZA2Pq9ksmNfaVjHcxgnMLj/16WBXuexA LqWg/3sXbCGZDQK9+dvAgZNf6+n5YBRf7UYlzoQ903UlRzpHdwid3nyZ7lrvBMWSHekX w/Eg== X-Gm-Message-State: AOAM531kd8h8BGtHGTMAJK6S07URZzxTkhdzCTJTgFv3neYb4PwSbHj7 lRHvqafUjQ705TCgBmcwj/q3RYbdXgAKllFXUtdT78tZ3ZSGEZJzi8i26mQ/zvgztowrMzydv7W GFQtd4TemXsvf2YfVHeo1/32ODQw9EyQEjCPn6f6s4eW2/4BAvoO8IYfoKu/Sng6kg4viNBg= X-Google-Smtp-Source: ABdhPJxCSRVfktZyoUtJMRN2PGvHAnbAevmXWjxZL01GrMS8zteF3iltpP8r4DcwqomN24njxeIYm+oXjBZDdQ== X-Received: from tef.lon.corp.google.com ([2a00:79e0:d:110:a6ae:11ff:fe11:4f04]) (user=gprocida job=sendgmr) by 2002:a7b:c14f:: with SMTP id z15mr479106wmi.1.1600774170481; Tue, 22 Sep 2020 04:29:30 -0700 (PDT) Date: Tue, 22 Sep 2020 12:29:21 +0100 In-Reply-To: <20200922112921.449335-1-gprocida@google.com> Message-Id: <20200922112921.449335-2-gprocida@google.com> Mime-Version: 1.0 References: <20200922112921.449335-1-gprocida@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH 1/1] DWARF reader workaround for declaration-only types To: libabigail@sourceware.org X-Spam-Status: No, score=-22.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, 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" abidw sometimes unexpectedly emits types as declaration-only (often just preserving the size information associated with full definitions elsewhere in the corpus. This workaround illustrates the issue (it breaks some tests). Signed-off-by: Giuliano Procida --- src/abg-dwarf-reader.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 7257052e6..2ff2d0b0f 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -4808,6 +4808,23 @@ public: cn_timer.start(); } + { + // Partition the types so that definitions appear before declarations. + struct Partition { + read_context * ctxt; + die_source source; + bool operator()(Dwarf_Off off) const + { + type_base_sptr t = ctxt->lookup_type_from_die_offset(off, source); + decl_base * db = dynamic_cast(t.get()); + return !db || !db->get_is_declaration_only(); + } + }; + Partition partition { this, source }; + std::vector& types = types_to_canonicalize(source); + std::partition(types.begin(), types.end(), partition); + } + if (!types_to_canonicalize(source).empty()) { tools_utils::timer single_type_cn_timer;