From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 990D53858D35; Tue, 19 Mar 2024 09:29:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 990D53858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1710840573; bh=qZonFxDFmg6FGBGEVstMKW4ihhAHY2AqPv4pAO8fJAQ=; h=From:To:Subject:Date:From; b=fBNiVXx3nLiscmW1AZvkwXN6cQ6U7VqhAii0UjfnyhhAS1bENwuUpAINxQjEn+MII 6mZnfoo6iW6T9u11pmp+hkFBHGzOVZta/jrn+8XvQBFf0ELkVlQNBg0QAhI8xPn5z4 m6d+cQ3mzY1BC57MbsdF0TZtyrYKr60w7THewueY= 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] Further 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: 97ce7870440d6b00181c2162ff5e56bb39b2e475 X-Git-Newrev: 306361f0687a60b06503a2df3c0ba949afca215f Message-Id: <20240319092933.990D53858D35@sourceware.org> Date: Tue, 19 Mar 2024 09:29:33 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D306361f0687a= 60b06503a2df3c0ba949afca215f commit 306361f0687a60b06503a2df3c0ba949afca215f Author: Tom de Vries Date: Tue Mar 19 10:30:36 2024 +0100 [gdb] Further fix "value is not available" with debug frame =20 In commit 2aaba744467 ("[gdb] Fix "value is not available" with debug f= rame") I fixed a case in frame_unwind_register_value where using "set debug fr= ame on" caused an "info frame" command to abort, reporting a "value is not avai= lable" error, due to the tpidruro register being unavailable. =20 Subsequently, commit bbb12eb9c84 ("gdb/arm: Remove tpidruro register fr= om non-FreeBSD target descriptions") removed the unavailable register, whi= ch caused a progression on test-case gdb.base/inline-frame-cycle-unwind.ex= p. =20 While investigating the progression (see PR python/31437), I found that= the "debug frame" output of the test-case (when reverting commit bbb12eb9c8= 4) showed a smilar problem: ... Python Exception : value is not available^M ... that was absent without "debug frame". =20 Fix this likewise in fetch_lazy_register, and update the test-case to c= heck for the exception. =20 Furthermore, I realized that there's both value::entirely_available and value::entirely_unavailable, and that commit 2aaba744467 handled the ca= se of !entirely_available by printing unavailable. =20 Instead, print: - "unavailable" for entirely_unavailable, and - "partly unavailable" for !entirely_unavailable && !entirely_available. =20 Tested on x86_64-linux and arm-linux. Diff: --- gdb/frame.c | 8 +++++--- .../gdb.base/inline-frame-cycle-unwind.exp | 7 ++++++- gdb/value.c | 23 ++++++++++++++----= ---- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/gdb/frame.c b/gdb/frame.c index d3c4c9640aa..f1f97040ff0 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1315,9 +1315,7 @@ 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 + else if (value->entirely_available ()) { int i; gdb::array_view buf =3D value->contents (); @@ -1328,6 +1326,10 @@ frame_unwind_register_value (const frame_info_ptr &n= ext_frame, int regnum) gdb_printf (&debug_file, "%02x", buf[i]); gdb_printf (&debug_file, "]"); } + else if (value->entirely_unavailable ()) + gdb_printf (&debug_file, " unavailable"); + else + gdb_printf (&debug_file, " partly unavailable"); } =20 frame_debug_printf ("%s", debug_file.c_str ()); diff --git a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp b/gdb/tes= tsuite/gdb.base/inline-frame-cycle-unwind.exp index 82632757f13..85e3cc32f0e 100644 --- a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp +++ b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp @@ -131,9 +131,14 @@ with_test_prefix "cycle at level 1" { gdb_test "maint flush register-cache" \ "Register cache flushed\\." "" gdb_test_no_output "set debug frame 1" +set ok 1 gdb_test_multiple "bt" "backtrace with debugging on" { -re "^$gdb_prompt $" { - pass $gdb_test_name + gdb_assert { $ok } $gdb_test_name + } + -re "Python Exception : \[^\r\n\]*\r\n" { + set ok 0 + exp_continue } -re "\[^\r\n\]+\r\n" { exp_continue diff --git a/gdb/value.c b/gdb/value.c index a2b2721d183..7ddfeb7c728 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -4014,9 +4014,6 @@ value::fetch_lazy_register () } else { - int i; - gdb::array_view buf =3D new_val->contents (); - if (new_val->lval () =3D=3D lval_register) gdb_printf (&debug_file, " register=3D%d", new_val->regnum ()); else if (new_val->lval () =3D=3D lval_memory) @@ -4026,11 +4023,21 @@ value::fetch_lazy_register () else gdb_printf (&debug_file, " computed"); =20 - gdb_printf (&debug_file, " bytes=3D"); - gdb_printf (&debug_file, "["); - for (i =3D 0; i < register_size (gdbarch, regnum); i++) - gdb_printf (&debug_file, "%02x", buf[i]); - gdb_printf (&debug_file, "]"); + if (new_val->entirely_available ()) + { + int i; + gdb::array_view buf =3D new_val->contents (); + + gdb_printf (&debug_file, " bytes=3D"); + gdb_printf (&debug_file, "["); + for (i =3D 0; i < register_size (gdbarch, regnum); i++) + gdb_printf (&debug_file, "%02x", buf[i]); + gdb_printf (&debug_file, "]"); + } + else if (new_val->entirely_unavailable ()) + gdb_printf (&debug_file, " unavailable"); + else + gdb_printf (&debug_file, " partly unavailable"); } =20 frame_debug_printf ("%s", debug_file.c_str ());