From patchwork Wed Jul 1 12:36:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 7441 Received: (qmail 87800 invoked by alias); 1 Jul 2015 12:37:19 -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 87787 invoked by uid 89); 1 Jul 2015 12:37:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_20, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: mail-qk0-f179.google.com Received: from mail-qk0-f179.google.com (HELO mail-qk0-f179.google.com) (209.85.220.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 01 Jul 2015 12:37:17 +0000 Received: by qkei195 with SMTP id i195so27904435qke.3 for ; Wed, 01 Jul 2015 05:37:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=MFmze4koc4iqrQtMqkpkOOXn8WPX2TyyzVlbGJpohGk=; b=c59ocJnrBT6df4Hg9L/yaOEP7enfyI/eDYkDbaCJcYIUz78Y2xyIPKsPmzTcOmwm8V /cpEus0PTjMNqAQkxF26HK3n4eUQv0xaOlEUQbuZQirIKOw5laewwrqrxzS/yGiLMP50 U9zKXufL3hmtjoyBcnN/taDuR9G3HyFieaoN1FrRB+WaHuDfGaZsZFKxtXUizbrwYyYy m7k0lmQPS4QMQxRceE9Ev80g+hKqrSaKtyMKQXtosHoWZN8Tv4GPIM6n2BKgAcAuyAM7 7GuJzHxkIaRF4RLIusDESOLe2zbAe/3XAdNcRSDHr9CFupB6vglLhWBdaJe+WGYL4Pow XFnQ== X-Gm-Message-State: ALoCoQkUfh1JaF+BzdcL0NiyooaBNEbu3wkKqDYOahw0wgfvsJNy0gUvmTrQyDRbNcQWfvTksF5W X-Received: by 10.55.31.155 with SMTP id n27mr54937638qkh.5.1435754235647; Wed, 01 Jul 2015 05:37:15 -0700 (PDT) Received: from localhost.localdomain (ool-4353acd8.dyn.optonline.net. [67.83.172.216]) by mx.google.com with ESMTPSA id 3sm858112qhc.19.2015.07.01.05.37.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Jul 2015 05:37:14 -0700 (PDT) From: Patrick Palka To: gdb-patches@sourceware.org Cc: Patrick Palka Subject: [PATCH] Make sure to update registers if frame information has changed Date: Wed, 1 Jul 2015 08:36:56 -0400 Message-Id: <1435754216-31399-1-git-send-email-patrick@parcs.ath.cx> When I removed TUI's frame_changed hook to fix PR tui/13378 I assumed that there's no reason to refresh register information following a call to "up", "down" or "frame". This assumption was made to fix the problem of refreshing frame information twice following a sync-execution normal stop (once in tui_normal_stop and then in tui_before_prompt) -- the second refresh removing any highlights made by the first. I was wrong about that -- GDB's snapshot of register information is per-frame, and when the frame changes, registers do too (most prominently the %rip and %rsp registers). So e.g. GDB 7.8 would highlight such register changes after invoking "up", "down" or "frame", and current GDB does not. To fix this regression, I added another (sufficient) condition for refreshing register information: in tui_refresh_frame_and_register_information, always refresh register information if frame information has changed. This makes register information get refreshed following a call to "up", "down" or "frame" while still avoiding the "double refresh" issue following a normal stop. This condition may seem to obsolete the existing registers_too_p parameter, but it does not: following a normal stop, it is possible that registers may have changed while frame information had not. We could be on the exact same PC with different register values. The new condition would not catch such a case, but the registers_too_p condition will. So both conditions seem necessary (and either one is sufficient). gdb/ChangeLog: * tui/tui-hooks.c (tui_refresh_frame_and_register_information): Update commentary. Always refresh the registers when frame information has changed. * tui/tui-stack.c (tui_show_frame_info): Update commentary. Change return type to int. Return 1 if frame information has changed, 1 otherwise. (tui_before_prompt): Update commentary. * tui/tui-stack.h (tui_show_frame_info): Change return type to int. --- gdb/tui/tui-hooks.c | 14 +++++++++----- gdb/tui/tui-stack.c | 15 +++++++++++---- gdb/tui/tui-stack.h | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c index 5987209..0eb2f07 100644 --- a/gdb/tui/tui-hooks.c +++ b/gdb/tui/tui-hooks.c @@ -122,7 +122,8 @@ tui_about_to_proceed (void) /* 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. - REGISTERS_TOO_P controls whether to refresh our register information. */ + REGISTERS_TOO_P controls whether to refresh our register information even + if frame information hasn't changed. */ static void tui_refresh_frame_and_register_information (int registers_too_p) @@ -130,6 +131,7 @@ tui_refresh_frame_and_register_information (int registers_too_p) struct frame_info *fi; CORE_ADDR pc; struct cleanup *old_chain; + int frame_info_changed_p; if (!has_stack_frames ()) return; @@ -156,10 +158,11 @@ tui_refresh_frame_and_register_information (int registers_too_p) /* Display the frame position (even if there is no symbols or the PC is not known). */ - tui_show_frame_info (fi); + frame_info_changed_p = tui_show_frame_info (fi); /* Refresh the register window if it's visible. */ - if (tui_is_window_visible (DATA_WIN) && registers_too_p) + if (tui_is_window_visible (DATA_WIN) + && (frame_info_changed_p || registers_too_p)) { tui_refreshing_registers = 1; tui_check_data_values (fi); @@ -199,8 +202,9 @@ tui_before_prompt (const char *current_gdb_prompt) { /* This refresh is intended to catch changes to the selected frame following a call to "up", "down" or "frame". As such we don't necessarily want to - refresh registers here as they could not have changed. Registers will be - refreshed after a normal stop or by our tui_register_changed_hook. */ + refresh registers here unless the frame actually changed by one of these + commands. Registers will otherwise be refreshed after a normal stop or by + our tui_register_changed_hook. */ tui_refresh_frame_and_register_information (/*registers_too_p=*/0); } diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c index 5b12330..910842d 100644 --- a/gdb/tui/tui-stack.c +++ b/gdb/tui/tui-stack.c @@ -349,9 +349,12 @@ tui_update_locator_fullname (const char *fullname) } /* Function to print the frame information for the TUI. The windows are - refreshed only if frame information has changed since the last refresh. */ + refreshed only if frame information has changed since the last refresh. -void + Return 1 if frame information has changed (and windows subsequently + refreshed), 0 otherwise. */ + +int tui_show_frame_info (struct frame_info *fi) { struct tui_win_info *win_info; @@ -389,7 +392,7 @@ tui_show_frame_info (struct frame_info *fi) not changed. If frame information has not changed, then the windows' contents will not change. So don't bother refreshing the windows. */ if (!locator_changed_p) - return; + return 0; tui_show_locator_content (); start_line = 0; @@ -460,6 +463,8 @@ tui_show_frame_info (struct frame_info *fi) } tui_update_exec_info (win_info); } + + return 1; } else { @@ -467,7 +472,7 @@ tui_show_frame_info (struct frame_info *fi) = tui_set_locator_info (NULL, NULL, NULL, 0, (CORE_ADDR) 0); if (!locator_changed_p) - return; + return 0; tui_show_locator_content (); for (i = 0; i < (tui_source_windows ())->count; i++) @@ -476,6 +481,8 @@ tui_show_frame_info (struct frame_info *fi) tui_clear_source_content (win_info, EMPTY_SOURCE_PROMPT); tui_update_exec_info (win_info); } + + return 1; } } diff --git a/gdb/tui/tui-stack.h b/gdb/tui/tui-stack.h index 2a34f9e..b89ddc4 100644 --- a/gdb/tui/tui-stack.h +++ b/gdb/tui/tui-stack.h @@ -26,6 +26,6 @@ struct frame_info; extern void tui_update_locator_fullname (const char *); extern void tui_show_locator_content (void); -extern void tui_show_frame_info (struct frame_info *); +extern int tui_show_frame_info (struct frame_info *); #endif