From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTP id 7CEF4384403E for ; Thu, 1 Apr 2021 17:58:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7CEF4384403E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 4282756152; Thu, 1 Apr 2021 13:58:34 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 2Kp0v5rwHiAE; Thu, 1 Apr 2021 13:58:34 -0400 (EDT) Received: from murgatroyd.Home (71-211-182-15.hlrn.qwest.net [71.211.182.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id F2F6D5612C; Thu, 1 Apr 2021 13:58:33 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/2] Use common_val_print_checked in print_variable_and_value Date: Thu, 1 Apr 2021 11:58:30 -0600 Message-Id: <20210401175831.3373671-2-tromey@adacore.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210401175831.3373671-1-tromey@adacore.com> References: <20210401175831.3373671-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, SPF_HELO_NONE, SPF_PASS, TXREP 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: 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, 01 Apr 2021 17:58:35 -0000 GDB was crashing in "bt full" for a large Ada program. I tracked this down to a combination of bugs. The first bug, fixed here, is that print_variable_and_value calls common_val_print. Normally only the value-printing implementation should call this; from the top level, common_val_print_checked is preferred, because it correctly handles values that are wholly optimized out. I wasn't able to write a test case for this. gdb/ChangeLog 2021-04-01 Tom Tromey * printcmd.c (print_variable_and_value): Use common_val_print_checked. --- gdb/ChangeLog | 5 +++++ gdb/printcmd.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gdb/printcmd.c b/gdb/printcmd.c index c82f709136f..a4f62f207d0 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -2387,7 +2387,7 @@ print_variable_and_value (const char *name, struct symbol *var, val = read_var_value (var, NULL, frame); get_user_print_options (&opts); opts.deref_ref = 1; - common_val_print (val, stream, indent, &opts, current_language); + common_val_print_checked (val, stream, indent, &opts, current_language); /* common_val_print invalidates FRAME when a pretty printer calls inferior function. */ -- 2.26.2