From patchwork Thu Jul 4 17:02:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33536 Received: (qmail 104276 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 104196 invoked by uid 89); 4 Jul 2019 17:03:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.8 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=decreased, Answer 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:18 +0000 Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway34.websitewelcome.com (Postfix) with ESMTP id B1879F8939 for ; Thu, 4 Jul 2019 12:03:16 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id j58ehYBQ0dnCej58eh6HbS; 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=/VEUKhY6+iPRTAdapVXQsh+9pe927fijuISpkfNGm7c=; b=PMRYmJeTQypPxc2M433kTRSGKL E7RnMVblfsE9L1AbT7ZPH2mZvbCLHLYswp2WFHxiIUIX7k7+ZZUvGp5TG19zl5ykQenaKdWjC8Lvz z8b8wN8NgUtWXUFFgl+Rs9xvO; 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-GX; Thu, 04 Jul 2019 12:03:16 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 07/61] Introduce tui_data_window::line_from_reg_element_no method Date: Thu, 4 Jul 2019 11:02:17 -0600 Message-Id: <20190704170311.15982-8-tom@tromey.com> In-Reply-To: <20190704170311.15982-1-tom@tromey.com> References: <20190704170311.15982-1-tom@tromey.com> This changes tui_line_from_reg_element_no to be a method on tui_data_window, allowing for the removal of some uses of the TUI_DATA_WIN global. (Actually, in this particular patch, the number of uses is not decreased, but rather the uses are moved to spots that are already using the global, i.e., increasing the clustering.) 2019-07-04 Tom Tromey * tui/tui-windata.c (tui_display_data_from) (tui_data_window::do_scroll_vertical): Update. * tui/tui-regs.h (tui_line_from_reg_element_no): Don't declare. * tui/tui-regs.c (tui_data_window::line_from_reg_element_no): Rename from tui_line_from_reg_element_no. (tui_display_registers_from_line): Update. * tui/tui-data.h (struct tui_data_window) : New method. --- gdb/ChangeLog | 11 +++++++++++ gdb/tui/tui-data.h | 5 +++++ gdb/tui/tui-regs.c | 12 +++++------- gdb/tui/tui-regs.h | 1 - gdb/tui/tui-windata.c | 4 ++-- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index 9b1e892aefe..081d0dfa449 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -494,6 +494,11 @@ struct tui_data_window : public tui_win_info are no registers (-1) is returned. */ int last_regs_line_no () const; + /* Answer the line number that the register element at element_no is + on. If element_no is greater than the number of register + elements there are, -1 is returned. */ + int line_from_reg_element_no (int element_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 e9fbf4b0752..03e91496b0f 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -79,21 +79,19 @@ tui_data_window::last_regs_line_no () const return num_lines; } +/* See tui-data.h. */ -/* Answer the line number that the register element at element_no is - on. If element_no is greater than the number of register elements - there are, -1 is returned. */ int -tui_line_from_reg_element_no (int element_no) +tui_data_window::line_from_reg_element_no (int element_no) const { - if (element_no < TUI_DATA_WIN->regs_content.size ()) + if (element_no < regs_content.size ()) { int i, line = (-1); i = 1; while (line == (-1)) { - if (element_no < TUI_DATA_WIN->regs_column_count * i) + if (element_no < regs_column_count * i) line = i - 1; else i++; @@ -391,7 +389,7 @@ tui_display_registers_from_line (int line_no, registers. */ if (line_no >= TUI_DATA_WIN->last_regs_line_no ()) { - if ((line = tui_line_from_reg_element_no ( + if ((line = TUI_DATA_WIN->line_from_reg_element_no ( TUI_DATA_WIN->regs_content.size () - 1)) < 0) line = 0; } diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h index fcb440dcf11..f6ed8628f2a 100644 --- a/gdb/tui/tui-regs.h +++ b/gdb/tui/tui-regs.h @@ -29,7 +29,6 @@ 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_first_reg_element_inline (int); -extern int tui_line_from_reg_element_no (int); extern int tui_first_reg_element_no_inline (int lineno); #endif /* TUI_TUI_REGS_H */ diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c index 7ff50a0c905..ac3e6d6e097 100644 --- a/gdb/tui/tui-windata.c +++ b/gdb/tui/tui-windata.c @@ -134,7 +134,7 @@ tui_display_data_from (int element_no, int reuse_windows) int first_line = (-1); if (element_no < TUI_DATA_WIN->regs_content.size ()) - first_line = tui_line_from_reg_element_no (element_no); + first_line = TUI_DATA_WIN->line_from_reg_element_no (element_no); else { /* Calculate the first_line from the element number. */ } @@ -173,7 +173,7 @@ tui_data_window::do_scroll_vertical (int num_to_scroll) first_element_no = first_data_item_displayed (); if (first_element_no < regs_content.size ()) - first_line = tui_line_from_reg_element_no (first_element_no); + first_line = line_from_reg_element_no (first_element_no); else { /* Calculate the first line from the element number which is in the general data content. */