From patchwork Thu Jul 4 17:02:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33542 Received: (qmail 104884 invoked by alias); 4 Jul 2019 17:03:23 -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 104678 invoked by uid 89); 4 Jul 2019 17:03:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=494, 7, notified X-HELO: gateway22.websitewelcome.com Received: from gateway22.websitewelcome.com (HELO gateway22.websitewelcome.com) (192.185.46.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 Jul 2019 17:03:19 +0000 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway22.websitewelcome.com (Postfix) with ESMTP id AD22D14D13 for ; Thu, 4 Jul 2019 12:03:16 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id j58ehGibU2qH7j58ehNq1w; Thu, 04 Jul 2019 12:03:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=QHPlke0j2SQLUi2KcsXiPxZ7FgvZWz3jZd23p5Tyv7I=; b=OUpRIcF0sgxU+20YqyNEZw+nIO tah1iVt0YAxoRxRbCbz0l5qL32GJfQxud6fdGBWVfBSY1IWYPc9obySQkIwWGWt7B7NgFBT0+6oaA m73dZ/cnEiJt8q27rX1R78N5w; Received: from 174-29-58-150.hlrn.qwest.net ([174.29.58.150]:34690 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1hj58d-002sAP-R4; Thu, 04 Jul 2019 12:03:15 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 05/61] Remove deleted breakpoint from TUI display Date: Thu, 4 Jul 2019 11:02:15 -0600 Message-Id: <20190704170311.15982-6-tom@tromey.com> In-Reply-To: <20190704170311.15982-1-tom@tromey.com> References: <20190704170311.15982-1-tom@tromey.com> PR tui/24722 points out that deleting a breakpoint does not cause the "b" to be removed from the breakpoint display. The issue here was that the breakpoint still exists at the moment the breakpoint-deleted observer is notified. This fixes the problem by specially handling the case where a breakpoint is being removed. 2019-07-04 Tom Tromey PR tui/24722: * tui/tui-winsource.h (tui_update_all_breakpoint_info) (tui_update_breakpoint_info): Add "being_deleted" parameter. * tui/tui-winsource.c (tui_update_source_window_as_is): Update. (tui_update_all_breakpoint_info): Add "being_deleted" parameter. (tui_update_breakpoint_info): Likewise. * tui/tui-hooks.c (tui_event_create_breakpoint) (tui_event_delete_breakpoint, tui_event_modify_breakpoint): Update. --- gdb/ChangeLog | 12 ++++++++++++ gdb/tui/tui-hooks.c | 6 +++--- gdb/tui/tui-winsource.c | 29 ++++++++++++++++------------- gdb/tui/tui-winsource.h | 19 +++++++++++++------ 4 files changed, 44 insertions(+), 22 deletions(-) diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c index 9bac4a883aa..71010530749 100644 --- a/gdb/tui/tui-hooks.c +++ b/gdb/tui/tui-hooks.c @@ -91,7 +91,7 @@ tui_register_changed (struct frame_info *frame, int regno) static void tui_event_create_breakpoint (struct breakpoint *b) { - tui_update_all_breakpoint_info (); + tui_update_all_breakpoint_info (nullptr); } /* Breakpoint deletion hook. @@ -99,13 +99,13 @@ tui_event_create_breakpoint (struct breakpoint *b) static void tui_event_delete_breakpoint (struct breakpoint *b) { - tui_update_all_breakpoint_info (); + tui_update_all_breakpoint_info (b); } static void tui_event_modify_breakpoint (struct breakpoint *b) { - tui_update_all_breakpoint_info (); + tui_update_all_breakpoint_info (nullptr); } /* Refresh TUI's frame and register information. This is a hook intended to be diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index c7c04dfe816..22cd54ee9b8 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -106,7 +106,7 @@ tui_update_source_window_as_is (struct tui_source_window_base *win_info, } else { - tui_update_breakpoint_info (win_info, 0); + tui_update_breakpoint_info (win_info, nullptr, false); tui_show_source_content (win_info); tui_update_exec_info (win_info); if (win_info->type == SRC_WIN) @@ -382,15 +382,14 @@ tui_source_window_base::set_is_exec_point_at (struct tui_line_or_address l) refill (); } -/* Update the execution windows to show the active breakpoints. - This is called whenever a breakpoint is inserted, removed or - has its state changed. */ +/* See tui-winsource.h. */ + void -tui_update_all_breakpoint_info () +tui_update_all_breakpoint_info (struct breakpoint *being_deleted) { for (tui_source_window_base *win : tui_source_windows ()) { - if (tui_update_breakpoint_info (win, FALSE)) + if (tui_update_breakpoint_info (win, being_deleted, false)) { tui_update_exec_info (win); } @@ -398,18 +397,19 @@ tui_update_all_breakpoint_info () } -/* Scan the source window and the breakpoints to update the has_break +/* Scan the source window and the breakpoints to update the break_mode information for each line. - Returns 1 if something changed and the execution window must be + Returns true if something changed and the execution window must be refreshed. */ -int -tui_update_breakpoint_info (struct tui_source_window_base *win, - int current_only) +bool +tui_update_breakpoint_info (struct tui_source_window_base *win, + struct breakpoint *being_deleted, + bool current_only) { int i; - int need_refresh = 0; + bool need_refresh = false; tui_source_window_base *src = (tui_source_window_base *) win; for (i = 0; i < win->content.size (); i++) @@ -435,6 +435,9 @@ tui_update_breakpoint_info (struct tui_source_window_base *win, gdb_assert (line->line_or_addr.loa == LOA_LINE || line->line_or_addr.loa == LOA_ADDRESS); + if (bp == being_deleted) + continue; + for (loc = bp->loc; loc != NULL; loc = loc->next) { if ((win == TUI_SRC_WIN @@ -491,7 +494,7 @@ tui_set_exec_info_content (struct tui_source_window_base *win_info) tui_exec_info_content *content = win_info->execution_info->maybe_allocate_content (win_info->height); - tui_update_breakpoint_info (win_info, 1); + tui_update_breakpoint_info (win_info, nullptr, true); for (int i = 0; i < win_info->content.size (); i++) { tui_exec_info_content &element = content[i]; diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h index 2a85a008812..c1087f4490a 100644 --- a/gdb/tui/tui-winsource.h +++ b/gdb/tui/tui-winsource.h @@ -28,14 +28,21 @@ struct tui_win_info; /* Update the execution windows to show the active breakpoints. This is called whenever a breakpoint is inserted, removed or has its - state changed. */ -extern void tui_update_all_breakpoint_info (void); + state changed. Normally BEING_DELETED is nullptr; if not nullptr, + it indicates a breakpoint that is in the process of being deleted, + and which should therefore be ignored by the update. This is done + because the relevant observer is notified before the breakpoint is + removed from the list of breakpoints. */ +extern void tui_update_all_breakpoint_info (struct breakpoint *being_deleted); /* Scan the source window and the breakpoints to update the break_mode - information for each line. Returns 1 if something changed and the - execution window must be refreshed. */ -extern int tui_update_breakpoint_info (struct tui_source_window_base *win, - int current_only); + information for each line. Returns true if something changed and + the execution window must be refreshed. See + tui_update_all_breakpoint_info for a description of + BEING_DELETED. */ +extern bool tui_update_breakpoint_info (struct tui_source_window_base *win, + struct breakpoint *being_deleted, + bool current_only); /* Function to display the "main" routine. */ extern void tui_display_main (void);