public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [gdb] Fix "value is not available" with debug frame
@ 2024-02-12 14:55 Tom de Vries
  2024-02-13 16:29 ` Tom de Vries
  0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2024-02-12 14:55 UTC (permalink / raw)
  To: gdb-patches

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<const gdb_byte> 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.exp | 42 ++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
 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.exp b/gdb/testsuite/gdb.base/debug-frame.exp
new file mode 100644
index 00000000000..99511ee820c
--- /dev/null
+++ b/gdb/testsuite/gdb.base/debug-frame.exp
@@ -0,0 +1,42 @@
+# 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 <http://www.gnu.org/licenses/>.
+
+# 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 main.c
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug}]} {
+    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.
+gdb_test "info frame" "\r\n Saved registers:(\r\n \[^\r\n\]+ at $hex)*"

base-commit: 60fed2e57f0219da68ecac3d13d590040f639c67
-- 
2.35.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [gdb] Fix "value is not available" with debug frame
  2024-02-12 14:55 [PATCH] [gdb] Fix "value is not available" with debug frame Tom de Vries
@ 2024-02-13 16:29 ` Tom de Vries
  2024-02-13 17:20   ` Tom de Vries
  0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2024-02-13 16:29 UTC (permalink / raw)
  To: gdb-patches

On 2/12/24 15:55, Tom de Vries wrote:
> +# Check that calling info frame doesn't trigger an exception that escapes to
> +# the CLI.
> +gdb_test "info frame" "\r\n Saved registers:(\r\n \[^\r\n\]+ at $hex)*"

The linaro CI reported this FAIL:
...
(gdb) PASS: gdb.base/debug-frame.exp: set debug frame 1
info frame
Stack level 0, frame at 0xffffffffd280:
  pc = 0xaaaaaaaa0714 in main (main.c:21); saved pc = 0xfffff7e373fc
  source language c.
  Arglist at 0xffffffffd280, args:
  Locals at 0xffffffffd280, Previous frame's sp is 0xffffffffd280
(gdb) FAIL: gdb.base/debug-frame.exp: info frame
...

This fails because no saved registers are printed.

I'll fix this and send a v2.

Thanks,
- Tom


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [gdb] Fix "value is not available" with debug frame
  2024-02-13 16:29 ` Tom de Vries
@ 2024-02-13 17:20   ` Tom de Vries
  0 siblings, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2024-02-13 17:20 UTC (permalink / raw)
  To: gdb-patches

On 2/13/24 17:29, Tom de Vries wrote:
> On 2/12/24 15:55, Tom de Vries wrote:
>> +# Check that calling info frame doesn't trigger an exception that 
>> escapes to
>> +# the CLI.
>> +gdb_test "info frame" "\r\n Saved registers:(\r\n \[^\r\n\]+ at $hex)*"
> 
> The linaro CI reported this FAIL:
> ...
> (gdb) PASS: gdb.base/debug-frame.exp: set debug frame 1
> info frame
> Stack level 0, frame at 0xffffffffd280:
>   pc = 0xaaaaaaaa0714 in main (main.c:21); saved pc = 0xfffff7e373fc
>   source language c.
>   Arglist at 0xffffffffd280, args:
>   Locals at 0xffffffffd280, Previous frame's sp is 0xffffffffd280
> (gdb) FAIL: gdb.base/debug-frame.exp: info frame
> ...
> 
> This fails because no saved registers are printed.
> 
> I'll fix this and send a v2.
> 

Submitted v2 here ( 
https://sourceware.org/pipermail/gdb-patches/2024-February/206577.html ).

changes in v2:
- improved regexp to match more precisely all possible output
- improved test-case source to make it more likely that there are
   saved registers
- added missing cleanups "set debug frame 0" and
   "set logging enabled off"

Thanks,
- Tom


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-13 17:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-12 14:55 [PATCH] [gdb] Fix "value is not available" with debug frame Tom de Vries
2024-02-13 16:29 ` Tom de Vries
2024-02-13 17:20   ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).