From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 033E63858D28 for ; Thu, 8 Sep 2022 01:58:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 033E63858D28 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-79-_E62yyg1OWmMVFjmyPRgNw-1; Wed, 07 Sep 2022 21:58:41 -0400 X-MC-Unique: _E62yyg1OWmMVFjmyPRgNw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 27F98185A794; Thu, 8 Sep 2022 01:58:41 +0000 (UTC) Received: from f36-1.lan (unknown [10.2.16.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66DF0141511A; Thu, 8 Sep 2022 01:58:40 +0000 (UTC) From: Kevin Buettner To: gdb-patches@sourceware.org Cc: lsix@lancelotsix.com, simark@simark.ca, Kevin Buettner Subject: [PATCH v3 0/2] Suppress printing of superfluous BFD error messages Date: Wed, 7 Sep 2022 18:58:10 -0700 Message-Id: <20220908015812.12175-1-kevinb@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Sep 2022 01:58:45 -0000 Tools which use the BFD library will output error messages of the form "BFD: some messsage" when a problem with the file upon which it operating is found. E.g. an actual message (modulo some shortening of the pathname) from the test case in this series is: BFD: bfd-errors-lib.so: invalid string offset 1154 >= 154 for section `.dynstr' For some problems with executable files or libraries, BFD will attempt to output many identical messages. The first patch in this series adds code to GDB to suppress messages which are identical to earlier messages that have already been printed. (The above blurb was adapted from a comment in the test case.) The V2 patch addresses concerns noted by Lancelot SIX: For part 1, I've used one of Lancelot's suggestions for simplifying the implementation of increment_bfd_error_count() in gdb_bfd.c. Regarding the test case, Lancelot found that it failed when tested on Ubuntu. It turned out that attempting to run to a catchpoint whilst using a mangled shared library was fragile. I rewrote parts of the test to instead use 'add-symbol-file -readnow' to load symbols from the mangled shared object into GDB. Also, since the main program is no longer needed, I removed it and all references to in in the .exp file. Lancelot suggested several other improvements which I also put into place. This V3 patch addresses concerns from Simon Marchi: In part 1, I changed the type of the associative array used to keep track of BFD messages from 'map' to 'unordered_map', changed the case of BFD ('bfd' -> 'BFD') in a couple of comments, and used std::move to convert the error string to an xvalue. The changes to part 2 include adding a 'close' along an error path, changing the objcopy invocations to use 'catch "exec ..."' instead of run_on_host, use of 'file size' instead of opening and reading the file to determine its size, and the use of 'clean_restart' in place of discrete invocations of 'gdb_start' and 'gdb_reinitialize_dir'. Kevin Buettner (2): Suppress printing of superfluous BFD error messages BFD error message suppression test case gdb/gdb_bfd.c | 67 +++++++++ gdb/testsuite/gdb.base/bfd-errors-lib.c | 44 ++++++ gdb/testsuite/gdb.base/bfd-errors.exp | 185 ++++++++++++++++++++++++ 3 files changed, 296 insertions(+) create mode 100644 gdb/testsuite/gdb.base/bfd-errors-lib.c create mode 100644 gdb/testsuite/gdb.base/bfd-errors.exp -- 2.37.3