From patchwork Mon Dec 23 01:23:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 37070 Received: (qmail 122119 invoked by alias); 23 Dec 2019 01:23:35 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 122107 invoked by uid 89); 23 Dec 2019 01:23:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=centre, 1587, fire, horizontal X-HELO: mail-wr1-f66.google.com Received: from mail-wr1-f66.google.com (HELO mail-wr1-f66.google.com) (209.85.221.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Dec 2019 01:23:34 +0000 Received: by mail-wr1-f66.google.com with SMTP id c9so15040071wrw.8 for ; Sun, 22 Dec 2019 17:23:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=HK/UZZyUgzDMbg5hBB/brALAB0eYEGjM3bxWWvgJzGg=; b=hJKTdu6Y9ICHE138ghutxkGJCqKcmB3omkVrLoqkQsqEN+WQyeklD6Ar5UynQKxkgX NnWL7a4idAhXFOn8RxIB3ClqybfP//0r+HiCAuoJaKbNb28o3pm4DlP5ysrvTF7NZDiJ UK6UaXgoK+bYiVFjnY4/KwQKFRCuBaLYnq+GBFvbC6D6KgfnJZ+SsdjGdoM2vzw9BfDw mKHbV6gv6slpYduXZFJIjiwQutnwxTDU8DosFQrZ+jSR1g7FvYjS+Vn7GWlLhC7d7L4U QnzArBd8R8Csn2aTqG6PihWaETTl11X6QYaw0UAnxFdxWk0qLMGnOa9wWpvOn2HdUbg9 jmwQ== Return-Path: Received: from localhost (host86-186-80-236.range86-186.btcentralplus.com. [86.186.80.236]) by smtp.gmail.com with ESMTPSA id w13sm19056152wru.38.2019.12.22.17.23.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Dec 2019 17:23:31 -0800 (PST) Date: Mon, 23 Dec 2019 01:23:29 +0000 From: Andrew Burgess To: Tom Tromey Cc: Hannes Domani , gdb-patches@sourceware.org Subject: Re: [RFC][PATCH] Call tui_before_prompt in do_scroll_vertical Message-ID: <20191223012329.GG3865@embecosm.com> References: <20191221153325.6961-1-ssbssa.ref@yahoo.de> <20191221153325.6961-1-ssbssa@yahoo.de> <20191222005754.GF3865@embecosm.com> <874kxrc3ha.fsf@tromey.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <874kxrc3ha.fsf@tromey.com> X-Fortune: A soft drink turneth away company. X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes * Tom Tromey [2019-12-22 17:03:45 -0700]: > >>>>> "Andrew" == Andrew Burgess writes: > > >> First I tried it with tui_update_source_windows_with_line, but this didn't > >> reset from_source_symtab (which was set deep in print_source_lines), > >> which resulted in some weird behavior when switching from "layout split" > >> to "layout asm" after scrolling down in the src window (the asm window > >> was then overwritten by the src window). > > I wonder if we really need to change the current source symtab. > If so, I guess the TUI could just call > set_current_source_symtab_and_line directly. > > The patch below removes the call to print_source_lines -- this approach > just seems too roundabout for my taste. I started playing with similar solutions. I also started looking at the role tui_refresh_frame_and_register_information plays in keeping the source/asm windows up to date. My conclusion was it does nothing but add more complication. Tom, the patch below applies on top of yours, it removes all of the source/asm updating from tui_refresh_frame_and_register_information. There's some direct action taken in the symtab changed observer hook. I also now call update_source_window_as_is on all source windows after the vertical scroll - this partly fixes the asm/source scroll synchronisation issue Hannes pointed out. Calling the *_as_is version has (I think) an added benefit - if you scroll horizontally, and then scroll up/down, the horizontal scroll is maintained. This feels much nicer to me, and is what caused me to remove the code from tui_refresh_frame_and_register_information. I said partly fixes the scroll synchronisation issue as scrolling the asm window doesn't (and never has I think) caused the source window to scroll - it kind of feels like it should though... this probably just requires us to add something similar to the asm windows vert scroll code. There is one issue with this patch, but I've run out of time right now to look at this any further, if you fire up gdb on gdb then do: start tui enable # will be in main now. break gdb_main continue The breakpoint line will be the first line in the console, rather than being in the centre of the window. I don't know if this is a worth while direction to go in or not, what do you think? Thanks, Andrew diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c index 8576bb8fccd..a6fbd88e51b 100644 --- a/gdb/tui/tui-hooks.c +++ b/gdb/tui/tui-hooks.c @@ -110,18 +110,13 @@ tui_event_modify_breakpoint (struct breakpoint *b) static bool from_stack; -/* This is set to true if the next window refresh should come from the - current source symtab. */ - -static bool from_source_symtab; - /* 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) + if (!from_stack) return; target_terminal::scoped_restore_terminal_state term_state; @@ -144,6 +139,7 @@ tui_refresh_frame_and_register_information () tui_refreshing_registers = 0; } } +#if 0 else if (!from_stack) { /* Make sure that the source window is displayed. */ @@ -152,6 +148,7 @@ tui_refresh_frame_and_register_information () struct symtab_and_line sal = get_current_source_symtab_and_line (); tui_update_source_windows_with_line (sal); } +#endif } /* Dummy callback for deprecated_print_frame_info_listing_hook which is called @@ -184,7 +181,6 @@ tui_before_prompt (const char *current_gdb_prompt) { tui_refresh_frame_and_register_information (); from_stack = false; - from_source_symtab = false; } /* Observer for the normal_stop notification. */ @@ -208,7 +204,11 @@ tui_context_changed (user_selected_what ignore) static void tui_symtab_changed () { - from_source_symtab = true; + /* Make sure that the source window is displayed. */ + tui_add_win_to_layout (SRC_WIN); + + struct symtab_and_line sal = get_current_source_symtab_and_line (); + tui_update_source_windows_with_line (sal); } /* Token associated with observers registered while TUI hooks are diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index bcba9e176f1..4846ddec0fc 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -145,6 +145,7 @@ tui_source_window::do_scroll_vertical (int num_to_scroll) struct frame_info *fi = get_selected_frame (NULL); s = find_pc_line_symtab (get_frame_pc (fi)); arch = get_frame_arch (fi); + cursal.symtab = s; } else s = cursal.symtab; @@ -158,7 +159,10 @@ tui_source_window::do_scroll_vertical (int num_to_scroll) line_no = 1; cursal.line = line_no; - update_source_window (arch, cursal); + find_line_pc (cursal.symtab, cursal.line, &cursal.pc); + + for (struct tui_source_window_base *win_info : tui_source_windows ()) + win_info->update_source_window_as_is (arch, cursal); } }