From patchwork Thu Jul 4 17:02:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33538 Received: (qmail 104193 invoked by alias); 4 Jul 2019 17:03:20 -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 104128 invoked by uid 89); 4 Jul 2019 17:03:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.7 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=PUBLIC, Answer X-HELO: gateway36.websitewelcome.com Received: from gateway36.websitewelcome.com (HELO gateway36.websitewelcome.com) (192.185.192.36) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 Jul 2019 17:03:17 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway36.websitewelcome.com (Postfix) with ESMTP id AD095400C828F for ; Thu, 4 Jul 2019 11:25:52 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id j58ehuwOQ2PzOj58eh7dFe; 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=a8kN6cPxNtAvYlT1Gkpz5++cHJxW2sVcyPrLJXd0vSg=; b=e8TeMGqx5shHLKnGzWZPdBqU2n GI11uazkFGZZ9lck1Y4b2hrbImjpvCGen2xjBMCHEWx4qc60FA64YylOd6gm/4Vw5BHHtliZ17p1T Kl565kLy/ozmnvbT3aS+qgBBD; 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 1hj58e-002sAP-5j; Thu, 04 Jul 2019 12:03:16 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 06/61] Introduce tui_data_window::last_regs_line_no method Date: Thu, 4 Jul 2019 11:02:16 -0600 Message-Id: <20190704170311.15982-7-tom@tromey.com> In-Reply-To: <20190704170311.15982-1-tom@tromey.com> References: <20190704170311.15982-1-tom@tromey.com> This changes tui_last_regs_line_no into a method on tui_data_window, allowing the removal of uses of the TUI_DATA_WIN global. 2019-07-04 Tom Tromey * tui/tui-regs.h (tui_last_regs_line_no): Don't declare. * tui/tui-regs.c (tui_data_window::last_regs_line_no): Rename from tui_last_regs_line_no. (tui_display_reg_element_at_line) (tui_display_registers_from_line): Update. * tui/tui-data.h (struct tui_data_window) : New method. --- gdb/ChangeLog | 10 ++++++++++ gdb/tui/tui-data.h | 4 ++++ gdb/tui/tui-regs.c | 17 ++++++++--------- gdb/tui/tui-regs.h | 1 - 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index 6a243c3d2f9..9b1e892aefe 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -490,6 +490,10 @@ struct tui_data_window : public tui_win_info bool display_regs = false; struct reggroup *current_group = nullptr; + /* Answer the number of the last line in the regs display. If there + are no registers (-1) is returned. */ + int last_regs_line_no () const; + protected: void do_scroll_vertical (int num_to_scroll) override; diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c index 32e82b23482..e9fbf4b0752 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -63,18 +63,17 @@ static enum tui_status tui_get_register (struct frame_info *frame, ** PUBLIC FUNCTIONS ** ******************************************/ -/* Answer the number of the last line in the regs display. If there - are no registers (-1) is returned. */ +/* See tui-data.h. */ + int -tui_last_regs_line_no (void) +tui_data_window::last_regs_line_no () const { int num_lines = (-1); - if (!TUI_DATA_WIN->regs_content.empty ()) + if (!regs_content.empty ()) { - num_lines = (TUI_DATA_WIN->regs_content.size () - / TUI_DATA_WIN->regs_column_count); - if (TUI_DATA_WIN->regs_content.size () % TUI_DATA_WIN->regs_column_count) + num_lines = regs_content.size () / regs_column_count; + if (regs_content.size () % regs_column_count) num_lines++; } return num_lines; @@ -354,7 +353,7 @@ tui_display_reg_element_at_line (int start_element_no, { int last_line_no, first_line_on_last_page; - last_line_no = tui_last_regs_line_no (); + last_line_no = TUI_DATA_WIN->last_regs_line_no (); first_line_on_last_page = last_line_no - (TUI_DATA_WIN->height - 2); if (first_line_on_last_page < 0) @@ -390,7 +389,7 @@ tui_display_registers_from_line (int line_no, { /* If we must display regs (force_display is true), then make sure that we don't display off the end of the registers. */ - if (line_no >= tui_last_regs_line_no ()) + if (line_no >= TUI_DATA_WIN->last_regs_line_no ()) { if ((line = tui_line_from_reg_element_no ( TUI_DATA_WIN->regs_content.size () - 1)) < 0) diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h index 54b1b0870f7..fcb440dcf11 100644 --- a/gdb/tui/tui-regs.h +++ b/gdb/tui/tui-regs.h @@ -28,7 +28,6 @@ extern void tui_check_register_values (struct frame_info *); extern void tui_show_registers (struct reggroup *group); extern void tui_display_registers_from (int); extern int tui_display_registers_from_line (int, int); -extern int tui_last_regs_line_no (void); extern int tui_first_reg_element_inline (int); extern int tui_line_from_reg_element_no (int); extern int tui_first_reg_element_no_inline (int lineno);