From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Fj4qFDCky2Vw2RwAWB0awg (envelope-from ) for ; Tue, 13 Feb 2024 12:17:36 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=eoV2OM3C; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=TcPPWsoY; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=eoV2OM3C; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=TcPPWsoY; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 3FE401E0D2; Tue, 13 Feb 2024 12:17:36 -0500 (EST) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id CB8D91E030 for ; Tue, 13 Feb 2024 12:17:33 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 45D513858011 for ; Tue, 13 Feb 2024 17:17:33 +0000 (GMT) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 8B7C83858000 for ; Tue, 13 Feb 2024 17:17:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8B7C83858000 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8B7C83858000 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707844630; cv=none; b=Q04fBYJtes0E5FwopDEEMy2Nc3fr6Kj6W0OFEBf+jnHY5eOimP3zGVgEJQ1SA5U/okv/sicuWuktNpnr4McM9U8IRfzE6wX7SkWWs2MprKPhcGOCrDvx/woveC7Q+zUwdgEcAimHJWQRLnWAZ1QoKCmEaVRg5emH4k+P3PHHuO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707844630; c=relaxed/simple; bh=CZSrmcQSlugiJPIaucsBBzeJrq4iZKPO4Yu/eFfcxd0=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=W7/W6ApjZvHx1aB6P/sTU/b6EF8C5B5tCat3LL2YR+TToiTjhvgc6GFch7efSHd5ShGaWOenzmMvlJx+ZJsg2+sCk+aRZIMoyiAaeCCazPRyEDiMWK9bLcXzoI2DN0Edso2KaOdxHo3MD2yvbJjMRSZH/0jSeI+rHPEphf87tCI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 30CCE21AB1 for ; Tue, 13 Feb 2024 17:17:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707844626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=XBZyyluNs1QU6dDzw5Ktux1Zc35tYUn62EFkxQjXkpU=; b=eoV2OM3CoQ3IvULpK7gEjpljOLIH/iZqr/TrOrgvTQA1keXwMeC9AcwJgfxmxHSSODJEs9 7jhfVJeeR6h5ZvBtSsoHsCOXdSMU5vYqq20r4Vthb6qRa+QcQh7MO/gF/Tyy7qUw49EYjq k1RLtwD9BeeiuWZNqFM35RsklP9jvu0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707844626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=XBZyyluNs1QU6dDzw5Ktux1Zc35tYUn62EFkxQjXkpU=; b=TcPPWsoYhHpCux2jSkzEUUx8f1xwY5+xjT9toMUedylkAfvgr4l+0sTtcxz2IXCvwadp9S njaRsAEKbfw2Y7DQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707844626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=XBZyyluNs1QU6dDzw5Ktux1Zc35tYUn62EFkxQjXkpU=; b=eoV2OM3CoQ3IvULpK7gEjpljOLIH/iZqr/TrOrgvTQA1keXwMeC9AcwJgfxmxHSSODJEs9 7jhfVJeeR6h5ZvBtSsoHsCOXdSMU5vYqq20r4Vthb6qRa+QcQh7MO/gF/Tyy7qUw49EYjq k1RLtwD9BeeiuWZNqFM35RsklP9jvu0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707844626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=XBZyyluNs1QU6dDzw5Ktux1Zc35tYUn62EFkxQjXkpU=; b=TcPPWsoYhHpCux2jSkzEUUx8f1xwY5+xjT9toMUedylkAfvgr4l+0sTtcxz2IXCvwadp9S njaRsAEKbfw2Y7DQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D895513A6D for ; Tue, 13 Feb 2024 17:17:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id fBJzMxGky2U1XwAAD6G6ig (envelope-from ) for ; Tue, 13 Feb 2024 17:17:05 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH v2] [gdb] Fix "value is not available" with debug frame Date: Tue, 13 Feb 2024 18:17:18 +0100 Message-Id: <20240213171718.8934-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: 8.80 X-Spamd-Result: default: False [8.80 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; BAYES_SPAM(5.10)[100.00%]; R_MISSING_CHARSET(2.50)[]; TO_DN_NONE(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-0.20)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCPT_COUNT_ONE(0.00)[1]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MID_CONTAINS_FROM(1.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[] X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org On arm-linux, with a started hello world, running "info frame" works fine, but when I set debug frame to on, I run into: ... (gdb) info frame ... [frame] frame_unwind_register_value: exit value is not available (gdb) ... The problem is here in frame_unwind_register_value: ... if (value->lazy ()) gdb_printf (&debug_file, " lazy"); else { int i; gdb::array_view buf = value->contents (); ... where we call value->contents () while !value->entirely_available (). Fix this by checking value->entirely_available () and printing: ... [frame] frame_unwind_register_value: -> register=91 unavailable ... Tested on arm-linux. PR gdb/31369 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31369 --- gdb/frame.c | 2 + gdb/testsuite/gdb.base/debug-frame-2.c | 22 ++++++++++ gdb/testsuite/gdb.base/debug-frame.c | 25 +++++++++++ gdb/testsuite/gdb.base/debug-frame.exp | 58 ++++++++++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 gdb/testsuite/gdb.base/debug-frame-2.c create mode 100644 gdb/testsuite/gdb.base/debug-frame.c create mode 100644 gdb/testsuite/gdb.base/debug-frame.exp diff --git a/gdb/frame.c b/gdb/frame.c index 72a34fcfedc..7060a2d00ec 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1314,6 +1314,8 @@ frame_unwind_register_value (frame_info_ptr next_frame, int regnum) if (value->lazy ()) gdb_printf (&debug_file, " lazy"); + else if (!value->entirely_available ()) + gdb_printf (&debug_file, " unavailable"); else { int i; diff --git a/gdb/testsuite/gdb.base/debug-frame-2.c b/gdb/testsuite/gdb.base/debug-frame-2.c new file mode 100644 index 00000000000..571b1407374 --- /dev/null +++ b/gdb/testsuite/gdb.base/debug-frame-2.c @@ -0,0 +1,22 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2024 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +void +foo (void) +{ + +} diff --git a/gdb/testsuite/gdb.base/debug-frame.c b/gdb/testsuite/gdb.base/debug-frame.c new file mode 100644 index 00000000000..629c3097aaf --- /dev/null +++ b/gdb/testsuite/gdb.base/debug-frame.c @@ -0,0 +1,25 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2024 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +extern void foo (void); + +int +main (void) +{ + foo (); + return 0; +} diff --git a/gdb/testsuite/gdb.base/debug-frame.exp b/gdb/testsuite/gdb.base/debug-frame.exp new file mode 100644 index 00000000000..f00ca256266 --- /dev/null +++ b/gdb/testsuite/gdb.base/debug-frame.exp @@ -0,0 +1,58 @@ +# Copyright 2024 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test relies on checking gdb debug output. Do not run if gdb debug is +# enabled as any debug will be redirected to the log. +require !gdb_debug_enabled + +standard_testfile .c -2.c +set srcfiles [list $srcfile $srcfile2] +if {[prepare_for_testing "failed to prepare" $testfile $srcfiles]} { + return -1 +} + +if ![runto_main] { + return -1 +} + +# Redirect debug output to file. +set logfile [host_standard_output_file gdb.txt] +gdb_test_no_output "set logging file $logfile" \ + "set logging file [file tail $logfile]" +gdb_test_no_output "set logging debugredirect on" +gdb_test "set logging enabled on" + +# Enable debug frame. +gdb_test "set debug frame 1" + +# Check that calling info frame doesn't trigger an exception that escapes to +# the CLI. +set re_locals " Locals at \[^\r\n\]*" +set re_regs1 " Saved registers:" +set re_reg "\[^ \]+ at $hex" +set re_regs2 " $re_reg,( $re_reg,)*" +set re_regs3 " ${re_reg}(, $re_reg)*" + +set re1 $re_locals +set re2 \ + [multi_line \ + $re_locals\ + $re_regs1 \ + ($re_regs2\r\n)*$re_regs3] +gdb_test "info frame" "\r\n($re1|$re2)" + +gdb_test_no_output "set debug frame 0" +gdb_test "set logging enabled off" + base-commit: a16034bf6417dc2259fef43fd5bcc2dd1dac562f -- 2.35.3