From patchwork Thu Jul 4 17:02:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33558 Received: (qmail 106984 invoked by alias); 4 Jul 2019 17:03:38 -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 105816 invoked by uid 89); 4 Jul 2019 17:03:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.5 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= X-HELO: gateway34.websitewelcome.com Received: from gateway34.websitewelcome.com (HELO gateway34.websitewelcome.com) (192.185.149.62) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 Jul 2019 17:03:24 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway34.websitewelcome.com (Postfix) with ESMTP id 30A401093A6 for ; Thu, 4 Jul 2019 12:03:23 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id j58lhF0MX90onj58lhBMZZ; Thu, 04 Jul 2019 12:03:23 -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=X1354hP71jFXI+CZj/037RK0/ntdThrbXXaLtCaCsts=; b=PNxO6ReGItKteNloKK2ikzP2Xl gbbZTTmi2R3Fb2gpbMGMTRQGJ2MUHatLGg+dHTsoesAc6b7BmblLvcNKwkaWPS3lyKkzUbtyTbIzY yumN+ePyHWJ8JTxjcrjOmXEis; Received: from 174-29-58-150.hlrn.qwest.net ([174.29.58.150]:34694 helo=bapiya.Home) by box5379.bluehost.com with esmtpa (Exim 4.92) (envelope-from ) id 1hj58k-002sFu-UA; Thu, 04 Jul 2019 12:03:23 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 24/61] Introduce tui_source_window_base::location_matches_p method Date: Thu, 4 Jul 2019 11:02:34 -0600 Message-Id: <20190704170311.15982-25-tom@tromey.com> In-Reply-To: <20190704170311.15982-1-tom@tromey.com> References: <20190704170311.15982-1-tom@tromey.com> This introduces the location_matches_p method, removing a spot that explicitly examines a window's type. 2019-07-04 Tom Tromey * tui/tui-winsource.c (tui_update_breakpoint_info): Use location_matches_p. * tui/tui-source.c (tui_source_window::location_matches_p): New method. * tui/tui-disasm.c (tui_disasm_window::location_matches_p): New method. * tui/tui-data.h (struct tui_source_window_base) : New method. (struct tui_source_window, struct tui_disasm_window) : Likewise. --- gdb/ChangeLog | 13 +++++++++++++ gdb/tui/tui-data.h | 6 ++++++ gdb/tui/tui-disasm.c | 7 +++++++ gdb/tui/tui-source.c | 10 ++++++++++ gdb/tui/tui-winsource.c | 11 +---------- 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index c456bd7db84..c0f1801ffc1 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -404,6 +404,8 @@ public: void update_tab_width () override; + virtual bool location_matches_p (struct bp_location *loc, int line_no) = 0; + /* Does the locator belong to this window? */ bool m_has_locator = false; /* Execution information window. */ @@ -435,6 +437,8 @@ struct tui_source_window : public tui_source_window_base return SRC_NAME; } + bool location_matches_p (struct bp_location *loc, int line_no) override; + protected: void do_scroll_vertical (int num_to_scroll) override; @@ -463,6 +467,8 @@ struct tui_disasm_window : public tui_source_window_base return DISASSEM_NAME; } + bool location_matches_p (struct bp_location *loc, int line_no) override; + protected: void do_scroll_vertical (int num_to_scroll) override; diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index b22368eccf7..af1a7406be8 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -375,3 +375,10 @@ tui_disasm_window::do_scroll_vertical (int num_to_scroll) NULL, val, FALSE); } } + +bool +tui_disasm_window::location_matches_p (struct bp_location *loc, int line_no) +{ + return (content[line_no].line_or_addr.loa == LOA_ADDRESS + && content[line_no].line_or_addr.u.addr == loc->address); +} diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index 34cb38b31af..2ca21dcc845 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -345,3 +345,13 @@ tui_source_window::style_changed () if (tui_active && is_visible) refill (); } + +bool +tui_source_window::location_matches_p (struct bp_location *loc, int line_no) +{ + return (content[line_no].line_or_addr.loa == LOA_LINE + && content[line_no].line_or_addr.u.line_no == loc->line_number + && loc->symtab != NULL + && filename_cmp (fullname, + symtab_to_fullname (loc->symtab)) == 0); +} diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 22cd54ee9b8..03dd1b4af81 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -410,7 +410,6 @@ tui_update_breakpoint_info (struct tui_source_window_base *win, { int i; bool need_refresh = false; - tui_source_window_base *src = (tui_source_window_base *) win; for (i = 0; i < win->content.size (); i++) { @@ -440,15 +439,7 @@ tui_update_breakpoint_info (struct tui_source_window_base *win, for (loc = bp->loc; loc != NULL; loc = loc->next) { - if ((win == TUI_SRC_WIN - && loc->symtab != NULL - && filename_cmp (src->fullname, - symtab_to_fullname (loc->symtab)) == 0 - && line->line_or_addr.loa == LOA_LINE - && loc->line_number == line->line_or_addr.u.line_no) - || (win == TUI_DISASM_WIN - && line->line_or_addr.loa == LOA_ADDRESS - && loc->address == line->line_or_addr.u.addr)) + if (win->location_matches_p (loc, i)) { if (bp->enable_state == bp_disabled) mode |= TUI_BP_DISABLED;