From patchwork Thu Jul 4 17:02:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33537 Received: (qmail 104397 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 104259 invoked by uid 89); 4 Jul 2019 17:03:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.9 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=Answer X-HELO: gateway23.websitewelcome.com Received: from gateway23.websitewelcome.com (HELO gateway23.websitewelcome.com) (192.185.49.104) 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 gateway23.websitewelcome.com (Postfix) with ESMTP id 132EFC1FA for ; Thu, 4 Jul 2019 12:03:17 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id j58fhYBQIdnCej58fh6Hbk; Thu, 04 Jul 2019 12:03:17 -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=pf0UqDPaNcdky/HeZTXk9KncLUyFfNWVZXM72zG2iRA=; b=VV5A8FVCR54Q6sJHk/IcQ4GjKD SESJmEv9TNIx9hlMv66nH9/oZC8ExJOyCzrsGLMKrB8nhWfMd2sbaa3M43KWwmTx85tQdKmWGgEug PcPmu4j3chwE/AXdSlipO3mif; 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-Rd; Thu, 04 Jul 2019 12:03:16 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 08/61] Introduce tui_data_window::first_reg_element_no_inline Date: Thu, 4 Jul 2019 11:02:18 -0600 Message-Id: <20190704170311.15982-9-tom@tromey.com> In-Reply-To: <20190704170311.15982-1-tom@tromey.com> References: <20190704170311.15982-1-tom@tromey.com> This changes tui_first_reg_element_no_inline to be a method on tui_data_window. This again moves uses of the TUI_DATA_WIN global from this function into other functions that are already using the global. 2019-07-04 Tom Tromey * tui/tui-regs.h (tui_first_reg_element_no_inline): Don't declare. * tui/tui-regs.c (tui_data_window::first_reg_element_no_inline): Rename from tui_first_reg_element_no_inline. (tui_display_reg_element_at_line) (tui_display_registers_from_line): Update. * tui/tui-data.h (struct tui_data_window) : New method. --- gdb/ChangeLog | 11 +++++++++++ gdb/tui/tui-data.h | 4 ++++ gdb/tui/tui-regs.c | 16 +++++++--------- 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 081d0dfa449..676345c528a 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -499,6 +499,10 @@ struct tui_data_window : public tui_win_info elements there are, -1 is returned. */ int line_from_reg_element_no (int element_no) const; + /* Answer the index of the first element in line_no. If line_no is + past the register area (-1) is returned. */ + int first_reg_element_no_inline (int 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 03e91496b0f..d005fe36c23 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -103,16 +103,13 @@ tui_data_window::line_from_reg_element_no (int element_no) const return (-1); } +/* See tui-data.h. */ -/* Answer the index of the first element in line_no. If line_no is - past the register area (-1) is returned. */ int -tui_first_reg_element_no_inline (int line_no) +tui_data_window::first_reg_element_no_inline (int line_no) const { - if ((line_no * TUI_DATA_WIN->regs_column_count) - <= TUI_DATA_WIN->regs_content.size ()) - return (((line_no + 1) * TUI_DATA_WIN->regs_column_count) - - TUI_DATA_WIN->regs_column_count); + if (line_no * regs_column_count <= regs_content.size ()) + return ((line_no + 1) * regs_column_count) - regs_column_count; else return (-1); } @@ -362,7 +359,8 @@ tui_display_reg_element_at_line (int start_element_no, display at. */ if (start_line_no > first_line_on_last_page) element_no - = tui_first_reg_element_no_inline (first_line_on_last_page); + = (TUI_DATA_WIN->first_reg_element_no_inline + (first_line_on_last_page)); } tui_display_registers_from (element_no); } @@ -399,7 +397,7 @@ tui_display_registers_from_line (int line_no, else line = line_no; - element_no = tui_first_reg_element_no_inline (line); + element_no = TUI_DATA_WIN->first_reg_element_no_inline (line); if (element_no < TUI_DATA_WIN->regs_content.size ()) tui_display_reg_element_at_line (element_no, line); else diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h index f6ed8628f2a..866af458e10 100644 --- a/gdb/tui/tui-regs.h +++ b/gdb/tui/tui-regs.h @@ -29,6 +29,5 @@ 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_first_reg_element_no_inline (int lineno); #endif /* TUI_TUI_REGS_H */