Re: [PATCH 3/3] Replace TUI's select_frame hook (PR tui/13378)

Patrick Palka
2015-06-30T12:16:27Z

On Tue, Jun 30, 2015 at 5:32 AM, Pedro Alves <palves@redhat.com> wrote:
> On 06/27/2015 03:50 AM, Patrick Palka wrote:
>> Actually, we should not call tui_show_frame_info(NULL) when there are no
>> stack frames, because doing so empties the source window after invoking
>> "continue&". That was a last-minute change with no justification anyway.
>>
>> Here is a revised patch with a much smaller diffstat.
>
> On 06/27/2015 03:35 AM, Patrick Palka wrote:
>
>> Effectively, with this patch, frame/PC changes that do not immediately
>> precede an inferior-stop event or a prompt display event no longer cause
>> TUI's frame and register information to be updated.
>
> It seems to me that this doesn't update the info when the
> program stops after continue& ...

Oops, yeah..

>
>> @@ -107,6 +108,9 @@ tui_on_sync_execution_done (void)
>> {
>> if (!interp_quiet_p (tui_interp))
>> display_gdb_prompt (NULL);
>> +
>> + if (tui_active)
>> + tui_refresh_frame_and_register_information ();
>> }
>>
>
> ... when sync/foreground execution is done, we show the
> prompt (display_gdb_prompt above), so the before_prompt observer
> is already taking care of refreshing.
>
> But when background/async execution is done, we don't call
> sync_execution_done observers, so this hook isn't called.
> So I'm not seeing what this bit in tui_on_sync_execution_done
> is for.

Good point... the sync_execution_done addendum is useless.

>
> I think that for for stops (either after background or foreground
> execution), the TUI refreshes itself from within the
> deprecated_print_frame_info_listing_hook, called from:
>
> #0 tui_show_frame_info (fi=0xf20b50) at /home/pedro/gdb/mygit/build/../src/gdb/tui/tui-stack.c:337
> #1 0x00000000005266c5 in tui_print_frame_info_listing_hook (s=0x1978100, line=92, stopline=93, noerror=0) at /home/pedro/gdb/mygit/build/../src/gdb/tui/tui-hooks.c:177
> #2 0x000000000063a6f7 in print_frame_info (frame=0xf20b50, print_level=0, print_what=SRC_AND_LOC, print_args=1, set_current_sal=1)
> at /home/pedro/gdb/mygit/build/../src/gdb/stack.c:895
> #3 0x0000000000638e2f in print_stack_frame (frame=0xf20b50, print_level=0, print_what=SRC_AND_LOC, set_current_sal=1)
> at /home/pedro/gdb/mygit/build/../src/gdb/stack.c:162
> #4 0x0000000000632c14 in print_stop_event (ws=0x7fffffffd120) at /home/pedro/gdb/mygit/build/../src/gdb/infrun.c:6536
> #5 0x0000000000632fa5 in normal_stop () at /home/pedro/gdb/mygit/build/../src/gdb/infrun.c:6701
>
> I think this hooking in deprecated_print_frame_info_listing_hook
> is also a too-low-level place, and is likely contributing
> to flicker in other situations. I think we should move
> to doing whatever we do in it to a normal_stop observer instead.
> (tbc, doesn't have to be this patch.)

That make sense.

>
>> And as a result of this change and of the previous change to
>> tui_show_frame_info, the TUI is much more disciplined about updating the
>> screen, and so the flicker as described in the PR is totally gone.
>
> I think we should sort out patch 3 before patch 2. AFAICS, the
> important one is this one, right?

This one is more important, but by itself it causes source/asm-window
scrolling to be reset after each command (due to the before_prompt
observer) even if the frame information hasn't been changed in the
meantime. Other than that they are mostly unrelated.

I'll post a revised patch in a bit.

>
> Thanks,
> Pedro Alves
>