From patchwork Tue Jan 31 15:57:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 64023 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 0EB213858428 for ; Tue, 31 Jan 2023 15:57:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0EB213858428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675180669; bh=+/4pFCi2EdAs0UMk7/cOn21UmTnwiupXoA0aXAc4jqM=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=lrIHwMSbvhxDk2nWdsbXkiBNZJ85aV7uL9XuhsXgRoqGVmO7T4HAgbDkUBzCFYzNt a1Jc77BLcDcXppxKXRejmClGcUbtiUZ3jAwvRd+onKz1QU9095iJWcEM6p+2AirovD 0bwb30fegDlMvchANav5xXwvzLCH4DOzNP/3oU2Q= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 875263858D33 for ; Tue, 31 Jan 2023 15:57:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 875263858D33 X-ASG-Debug-ID: 1675180644-0c856e762b881af0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id 5rLYxshkfRN1hk4x (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Tue, 31 Jan 2023 10:57:24 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from smarchi-efficios.internal.efficios.com (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtp.ebox.ca (Postfix) with ESMTP id 96B17441B21; Tue, 31 Jan 2023 10:57:24 -0500 (EST) X-Barracuda-RBL-IP: 192.222.180.24 X-Barracuda-Effective-Source-IP: 192-222-180-24.qc.cable.ebox.net[192.222.180.24] X-Barracuda-Apparent-Source-IP: 192.222.180.24 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 2/2] gdb: add nullptr check to cooked_index_functions::dump Date: Tue, 31 Jan 2023 10:57:21 -0500 X-ASG-Orig-Subj: [PATCH 2/2] gdb: add nullptr check to cooked_index_functions::dump Message-Id: <20230131155721.21847-2-simon.marchi@efficios.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230131155721.21847-1-simon.marchi@efficios.com> References: <20230131155721.21847-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1675180644 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 2217 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.104132 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-3498.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, 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: 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-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Since commit 7d82b08e9e0a ("gdb/dwarf: dump cooked index contents in cooked_index_functions::dump"), we see: maint print objfiles /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.dwarf2/dw2-error/dw2-error^M ^M Object file /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.dwarf2/dw2-error/dw2-error: Objfile at 0x614000005040, bfd at 0x6120000e08c0, 15 minsyms^M ^M Cooked index in use:^M ^M /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/gdb-checked-static-cast.h:58: internal-error: checked_static_cast: Assertion `result != nullptr' failed.^M A problem internal to GDB has been detected,^M further debugging may prove unreliable.^M ----- Backtrace -----^M FAIL: gdb.dwarf2/dw2-error.exp: maint print objfiles /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.dwarf2/dw2-error/dw2-error (GDB internal error) The problem is that when cooked_index_functions fails to build an index, per_objfile->index_table is nullptr. Therefore, add a nullptr check, like other methods of cooked_index_functions already do. Print the "Cooked index in use" message after the nullptr check, such that if the cooked index failed to build, that message is not printed. Change-Id: Id67aef592e76c41b1e3bde9838a4e36cef873253 --- gdb/dwarf2/read.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index e8a3e359adaa..6cee22a3faa6 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -18589,14 +18589,15 @@ struct cooked_index_functions : public dwarf2_base_index_functions void dump (struct objfile *objfile) override { - gdb_printf ("Cooked index in use:\n"); - gdb_printf ("\n"); - dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); cooked_index_vector *index = (gdb::checked_static_cast - (per_objfile->per_bfd->index_table.get ())); + (per_objfile->per_bfd->index_table.get ())); + if (index == nullptr) + return; + gdb_printf ("Cooked index in use:\n"); + gdb_printf ("\n"); index->dump (objfile->arch ()); }