[gdb] Fix "value is not available" with debug frame
commit2aaba7444679492ae9e2757d7d05ba63bd2ec3c7
authorTom de Vries <tdevries@suse.de>
Mon, 26 Feb 2024 14:31:34 +0000 (26 15:31 +0100)
committerTom de Vries <tdevries@suse.de>
Mon, 26 Feb 2024 14:31:34 +0000 (26 15:31 +0100)
tree4c803b75164e38f742a7f3d884d2fda64c48a271
parent4a4fd10d1707424b9b13aa4af0cec7590c086ea0
[gdb] Fix "value is not available" with debug frame

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
gdb/testsuite/gdb.base/debug-frame-2.c [new file with mode: 0644]
gdb/testsuite/gdb.base/debug-frame.c [new file with mode: 0644]
gdb/testsuite/gdb.base/debug-frame.exp [new file with mode: 0644]