From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 800713858D28; Mon, 26 Feb 2024 14:31:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 800713858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1708957890; bh=jtNQwhMjBgebtfnqqBxXtLu1p18jgFAW1/hfiCWtx9Y=; h=From:To:Subject:Date:From; b=e77uVFwNnAVB8mjSKQhTsebs8lM2Q8VSvF7/8pfnT4hUHPqKfxMLz9zCAs/CZ53Fo jEbXJsWnb//V2cRlZZgx7lVmoa8kVtbdgJ8ytJ84fKNvr8Q5ECbFzSCUcgs3iMErvE HOcnCeexLs0jrb+lJbINUw9i8Q7LnIRb1XvxbOjM= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb] Fix "value is not available" with debug frame X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 4a4fd10d1707424b9b13aa4af0cec7590c086ea0 X-Git-Newrev: 2aaba7444679492ae9e2757d7d05ba63bd2ec3c7 Message-Id: <20240226143130.800713858D28@sourceware.org> Date: Mon, 26 Feb 2024 14:31:30 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D2aaba7444679= 492ae9e2757d7d05ba63bd2ec3c7 commit 2aaba7444679492ae9e2757d7d05ba63bd2ec3c7 Author: Tom de Vries Date: Mon Feb 26 15:31:34 2024 +0100 [gdb] Fix "value is not available" with debug frame =20 On arm-linux, with a started hello world, running "info frame" works fi= ne, 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) ... =20 The problem is here in frame_unwind_register_value: ... if (value->lazy ()) gdb_printf (&debug_file, " lazy"); else { int i; gdb::array_view buf =3D value->contents (= ); ... where we call value->contents () while !value->entirely_available (). =20 Fix this by checking value->entirely_available () and printing: ... [frame] frame_unwind_register_value: -> register=3D91 unavailable ... =20 Tested on arm-linux. =20 PR gdb/31369 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31369 Diff: --- 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 | 57 ++++++++++++++++++++++++++++++= ++++ 4 files changed, 106 insertions(+) diff --git a/gdb/frame.c b/gdb/frame.c index 9c3f0dfd4f2..5c7aae9edf4 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1315,6 +1315,8 @@ frame_unwind_register_value (const frame_info_ptr &ne= xt_frame, int regnum) =20 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.bas= e/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.bas= e/debug-frame.exp new file mode 100644 index 00000000000..f928f19daec --- /dev/null +++ b/gdb/testsuite/gdb.base/debug-frame.exp @@ -0,0 +1,57 @@ +# 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"