From patchwork Mon Oct 10 11:55:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 58581 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 7A63D3857C70 for ; Mon, 10 Oct 2022 11:55:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A63D3857C70 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665402914; bh=UeXLDlHs6dZhQ1ROL1Tjx1LG3jVmApLHNYTnR/RM8Es=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=ku60IWulEFhe9rLz5wFB0YTmcpDwjDC4wKO4Nnlk2Yg1V0FaqgacA557lOL2bMQWH HxnSErVbmShPqhZqLqwqmEgoRrkC53zQgE0ZYfM6j7CiPtcXCtgKp0GefYNO5/g9aC 9BQyh1qNllBz/2C0LV93nxd2VK9sq/ELs6cuR4FA= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 90E843858D37 for ; Mon, 10 Oct 2022 11:55:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 90E843858D37 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-371-J4Y_YqVDMkmYo1GDHm77Mg-1; Mon, 10 Oct 2022 07:55:04 -0400 X-MC-Unique: J4Y_YqVDMkmYo1GDHm77Mg-1 Received: by mail-wm1-f71.google.com with SMTP id k2-20020a05600c1c8200b003c3dd3aa638so4410053wms.1 for ; Mon, 10 Oct 2022 04:55:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:organization:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UeXLDlHs6dZhQ1ROL1Tjx1LG3jVmApLHNYTnR/RM8Es=; b=47Vr7oUkaiXYJp6IOE48HU+FbCtk+3hpaUdyaC4Kp85vaVoJrnFL29x5VNj/pWhcAu 62Z06oPqBOsc0H9FEWTK8rESXUlfXuCdFna/OYHZVR4Lz/Aiis/KjgEPntnaQFCay17a Lut4E9VFutyXPdPQzYJ99L3iaIQJ5I5Y9Oqk92SfZxSb45YShbnaGrE2gAvOnqjNF7O3 IoNjG+YQg+IAtYJzAz9k9c0qNzJUj+ym1VsS7ACXytWcpSw6kWNwjLfnczrZgSgDUcS0 RbE1My4iidx3nhpO5eWPd4nS9OImalGwXrurWu55MNH1wd8jTw5V/8BCgHbTgKJNIfZT exFw== X-Gm-Message-State: ACrzQf3OpGUKQW6/o0iM/GOj0GxpUgJL7A3VdePT+pJcFZxqGOl7Tl5o nSgSbOItUB3q/ZdGjqQxchHtJuV2kr0mthbYfbRNGV/+cwCZV6ND2VfczNC2eVXEO+KlZdC9F3x 4iSr/O9d9XRZkO0+0JtliCHhV4JSlliD3Rdp7YqNmsnCEctoOgobjtn8433ppUFDikS7K X-Received: by 2002:a5d:4804:0:b0:22e:2e39:1f7c with SMTP id l4-20020a5d4804000000b0022e2e391f7cmr10764307wrq.265.1665402902641; Mon, 10 Oct 2022 04:55:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM78cepGXV53hkSvbgFIohq0VEpygGxU21nXclAh1h0U0kF0urm8lZ4vxIJ9rYM5ynLQTGtgcw== X-Received: by 2002:a5d:4804:0:b0:22e:2e39:1f7c with SMTP id l4-20020a5d4804000000b0022e2e391f7cmr10764296wrq.265.1665402902363; Mon, 10 Oct 2022 04:55:02 -0700 (PDT) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id q6-20020a05600c46c600b003c3c2df83ddsm8755872wmo.26.2022.10.10.04.55.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 04:55:01 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id F0B12581C53; Mon, 10 Oct 2022 13:55:00 +0200 (CEST) To: libabigail@sourceware.org Subject: [PATCH, applied] abidiff: add a --debug-tc option Organization: Red Hat / France X-Operating-System: Fedora 38 X-URL: http://www.redhat.com Date: Mon, 10 Oct 2022 13:55:00 +0200 Message-ID: <8735bv3ncb.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP 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: Dodji Seketeli via Libabigail From: Dodji Seketeli Reply-To: Dodji Seketeli Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" Hello, Like what was done for abidw, this patch adds a --debug-tc option to abidiff to debug type canonicalization issues. With this option, just like for abidw, during type canonicalization, each type comparison is done twice: once using structural comparison and once using canonical comparison. Both comparisons should yield the same result otherwise, an abort signal is emitted, asking for in-depth debugging to understand reason of the difference. This option is enabled by the configure option --enable-debug-type-canonicalization. It proved useful in debugging some comparison errors I was looking at recently. * doc/manuals/abidiff.rst: Add documentation for the new --debug-tc option. Fix the existing documentation for --debug-self-comparison. * tools/abidiff.cc (options::do_debug_self_comparison): Renamed options::do_debug into this. (options::do_debug_type_canonicalization): Add new data member. (display_usage): Fix help string for the --debug option that is now --debug-self-comparison. Also, add a help string for the new option --debug-tc option. (main): Adjust use options::do_debug into options::do_debug_self_comparison. Call environment::debug_type_canonicalization() if the user provided the --debug-tc option. Signed-off-by: Dodji Seketeli --- doc/manuals/abidiff.rst | 31 +++++++++++++++++++++++++++---- tools/abidiff.cc | 31 +++++++++++++++++++++++++------ 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/doc/manuals/abidiff.rst b/doc/manuals/abidiff.rst index 0c711d9e..c728b373 100644 --- a/doc/manuals/abidiff.rst +++ b/doc/manuals/abidiff.rst @@ -65,14 +65,37 @@ Options Display a short help about the command and exit. - * ``--debug`` + * ``--debug-self-comparison`` - In this mode, error messages are emitted for types which fail type canonicalization. + In this mode, error messages are emitted for types which fail type + canonicalization, in some circumstances, when comparing a binary + against itself. - This is an optional ebugging and sanity check option. To enable + When comparing a binary against itself, canonical types of the + second binary should be equal (as much as possible) to canonical + types of the first binary. When some discrepancies are detected + in this mode, an abort signal is emitted and execution is halted. + This option should be used while executing the tool in a debugger, + for troubleshooting purposes. + + This is an optional debugging and sanity check option. To enable it the libabigail package needs to be configured with - the --enable-debug-self-comparison option. + the --enable-debug-self-comparison configure option. + + * ``--debug-tc`` + In this mode, the process of type canonicalization is put under + heavy scrutiny. Basically, during type canonicalization, each + type comparison is performed twice: once in a structural mode + (comparing every sub-type member-wise), and once using canonical + comparison. The two comparisons should yield the same result. + Otherwise, an abort signal is emitted and the process can be + debugged to understand why the two kinds of comparison yield + different results. + + This is an optional debugging and sanity check option. To enable + it the libabigail package needs to be configured with + the --enable-debug-type-canonicalization configure option. * ``--version | -v`` diff --git a/tools/abidiff.cc b/tools/abidiff.cc index e0bb35ac..9b2ab784 100644 --- a/tools/abidiff.cc +++ b/tools/abidiff.cc @@ -109,7 +109,10 @@ struct options bool show_stats; bool do_log; #ifdef WITH_DEBUG_SELF_COMPARISON - bool do_debug; + bool do_debug_self_comparison; +#endif +#ifdef WITH_DEBUG_TYPE_CANONICALIZATION + bool do_debug_type_canonicalization; #endif #ifdef WITH_CTF bool use_ctf; @@ -162,7 +165,11 @@ struct options #endif #ifdef WITH_DEBUG_SELF_COMPARISON , - do_debug() + do_debug_self_comparison() +#endif +#ifdef WITH_DEBUG_TYPE_CANONICALIZATION + , + do_debug_type_canonicalization() #endif {} @@ -256,7 +263,11 @@ display_usage(const string& prog_name, ostream& out) << " --ctf use CTF instead of DWARF in ELF files\n" #endif #ifdef WITH_DEBUG_SELF_COMPARISON - << " --debug debug the process of comparing an ABI corpus against itself" + << " --debug-self-comparison debug the process of comparing " + "an ABI corpus against itself" +#endif +#ifdef WITH_DEBUG_TYPE_CANONICALIZATION + << " --debug-tc debug the type canonicalization process" #endif << " --verbose show verbose messages about internal stuff\n"; } @@ -612,8 +623,12 @@ parse_command_line(int argc, char* argv[], options& opts) opts.use_ctf = true; #endif #ifdef WITH_DEBUG_SELF_COMPARISON - else if (!strcmp(argv[i], "--debug")) - opts.do_debug = true; + else if (!strcmp(argv[i], "--debug-self-comparison")) + opts.do_debug_self_comparison = true; +#endif +#ifdef WITH_DEBUG_TYPE_CANONICALIZATION + else if (!strcmp(argv[i], "--debug-tc")) + opts.do_debug_type_canonicalization = true; #endif else { @@ -1143,8 +1158,12 @@ main(int argc, char* argv[]) env->analyze_exported_interfaces_only(*opts.exported_interfaces_only); #ifdef WITH_DEBUG_SELF_COMPARISON - if (opts.do_debug) + if (opts.do_debug_self_comparison) env->self_comparison_debug_is_on(true); +#endif +#ifdef WITH_DEBUG_TYPE_CANONICALIZATION + if (opts.do_debug_type_canonicalization) + env->debug_type_canonicalization_is_on(true); #endif translation_unit_sptr t1, t2; abigail::elf_reader::status c1_status =