Bug 28600 - "layout reg" nor "kill" refresh the TUI registers window
Summary: "layout reg" nor "kill" refresh the TUI registers window
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: tui (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: 15.1
Assignee: Tom Tromey
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-17 19:17 UTC by Pedro Alves
Modified: 2024-02-08 19:36 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pedro Alves 2021-11-17 19:17:29 UTC
If you run to main in CLI mode, and then issue 'layout reg', the register window shows:

  "[ Register Values Unavailable ]"

... even though the process is live and we have a frame selected.

If you step/stepi/next, etc. at this point, then the registers window refreshes itself and shows registers.

In the "step" case, we show registers because we get here:

 (top-gdb) bt
 #0 tui_data_window::show_registers (this=0x5555590decf0, group=0x0) at 
 ../../src/gdb/tui/tui-regs.c:183
 #1 0x0000555555d22bfd in tui_data_window::check_register_values (this=0x5555590decf0, frame=0x555558d59450) at ../../src/gdb/tui/tui-regs.c:468
 #2 0x0000555555d07aa0 in tui_refresh_frame_and_register_information () at ../../src/gdb/tui/tui-hooks.c:143
 #3 0x0000555555d07b9b in tui_before_prompt (current_gdb_prompt=0x5555564e3af0 <top_prompt+16> "(top-gdb) ") at ../../src/gdb/tui/tui-hooks.c:185


In the "layout reg" case, we get to tui_refresh_frame_and_register_information as well, but hit the early return:

 /* Refresh TUI's frame and register information.  This is a hook intended to be
    used to update the screen after potential frame and register changes.  */

 static void
 tui_refresh_frame_and_register_information ()
 {
   if (!from_stack && !from_source_symtab)
     return;


These two "from_stack" and "from_source_symtab" globals are set by the tui_normal_stop, tui_context_changed, tui_symtab_changed observers, AFAICT.

So any state change refreshes the TUI registers, but doing "layout reg" does not as it doesn't cause these observers to be called.

I also noticed that if you're in "layout reg", and the register window is showing something, and then do "kill", the process is now gone but the register window continues showing the values of the registers from before the kill.
Off-hand, I'd think "kill" should have resulted in the tui_context_changed observer being called.  I didn't try it, but I'd get "detach", "disconnect" and perhaps other commands have the same issue.
Comment 1 Tom de Vries 2023-11-24 10:28:12 UTC
(In reply to Pedro Alves from comment #0)
> If you run to main in CLI mode, and then issue 'layout reg', the register
> window shows:
> 
>   "[ Register Values Unavailable ]"
> 
> ... even though the process is live and we have a frame selected.
> 

https://sourceware.org/pipermail/gdb-patches/2023-November/204464.html
Comment 2 Sourceware Commits 2023-12-16 08:31:07 UTC
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=86a6f9a9fb112614c15cc17630b29fbc62d3bca5

commit 86a6f9a9fb112614c15cc17630b29fbc62d3bca5
Author: Tom de Vries <tdevries@suse.de>
Date:   Sat Dec 16 09:31:29 2023 +0100

    [gdb/tui] Show regs when switching to regs layout
    
    When starting gdb in CLI mode, running to main and switching into the TUI regs
    layout:
    ...
    $ gdb -q a.out -ex start -ex "layout regs"
    ...
    we get:
    ...
    +---------------------------------+
    |                                 |
    | [ Register Values Unavailable ] |
    |                                 |
    +---------------------------------+
    ...
    
    Fix this by handling this case in tui_data_window::rerender.
    
    Tested on x86_64-linux.
    
    Approved-By: Tom Tromey <tom@tromey.com>
    
    PR tui/28600
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28600
Comment 3 Tom de Vries 2023-12-16 08:37:52 UTC
(In reply to Sourceware Commits from comment #2)

>     [gdb/tui] Show regs when switching to regs layout

This doesn't change the behaviour when killing, so the bug is not completely fixed yet.
Comment 4 Tom Tromey 2023-12-17 19:37:33 UTC
I have a fix.
Comment 5 Sourceware Commits 2024-02-08 19:34:25 UTC
The master branch has been updated by Tom Tromey <tromey@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=66ab1a14e196a5ad1f5fd8d225647bd48ff02a25

commit 66ab1a14e196a5ad1f5fd8d225647bd48ff02a25
Author: Tom Tromey <tom@tromey.com>
Date:   Sun Dec 17 12:38:15 2023 -0700

    Update TUI register window when the inferior exits
    
    When the inferior exits, the TUI register window should clear.
    
    Fixing this was mostly a matter of sticking an assignment into
    tui_inferior_exit.  However, some changes to the register window
    itself were also needed.
    
    While working on this, I realized that the TUI register window would
    not work correctly when moving between frames of different
    architectures.  This patch attempts to fix this as well, though I have
    no way to test it.
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28600
    Tested-By: Tom de Vries <tdevries@suse.de>
    Reviewed-By: Andrew Burgess <aburgess@redhat.com>
    Approved-By: Andrew Burgess <aburgess@redhat.com>
Comment 6 Tom Tromey 2024-02-08 19:36:12 UTC
Fixed.