From patchwork Sat Jan 4 18:34:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 37189 Received: (qmail 1505 invoked by alias); 4 Jan 2020 18:34:30 -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 670 invoked by uid 89); 4 Jan 2020 18:34:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.3 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=AFTER, sal, 1076, 2810 X-HELO: gateway24.websitewelcome.com Received: from gateway24.websitewelcome.com (HELO gateway24.websitewelcome.com) (192.185.51.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 04 Jan 2020 18:34:18 +0000 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway24.websitewelcome.com (Postfix) with ESMTP id B280BC0D2E for ; Sat, 4 Jan 2020 12:34:16 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id noFciWgE6W4frnoFcinK1y; Sat, 04 Jan 2020 12:34:16 -0600 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=SK5YSV9Yj3Kb6iC9HzTAMub8G7084jdr4qy7Fp5PdU4=; b=BEDJDmEaXTzT+s54V9oK/iUFZ/ pDHm8f/hcbQ4xFRIXTmjTZsZ3ZwJVbTyFg7sMr3WarN8idpuaJ6jGiwC6Qg77mCNW9piLxTt5FuzU lw7IFJqCriOoo/2SZmQd9YXRs; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:48942 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1inoFc-0026Lh-GY; Sat, 04 Jan 2020 11:34:16 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 16/24] TUI windows do not need to store their type Date: Sat, 4 Jan 2020 11:34:02 -0700 Message-Id: <20200104183410.17114-17-tom@tromey.com> In-Reply-To: <20200104183410.17114-1-tom@tromey.com> References: <20200104183410.17114-1-tom@tromey.com> TUI windows no longer need to store their type -- there's only a single spot that uses this information, and it can be changed to use dynamic_cast. (It could be cleaned up even more, by using a virtual method, but I haven't done so.) This patch removes the "type" field from tui_gen_win_info, and this in turn allows removing a couple of enumerator constants. 2020-01-04 Tom Tromey * tui/tui.h (enum tui_win_type) : Remove constants. * tui/tui-winsource.h (struct tui_source_window_base) : Remove parameter. * tui/tui-winsource.c (tui_source_window_base::tui_source_window_base): Remove parameter. (tui_source_window_base::refill): Update. * tui/tui-stack.h (struct tui_locator_window) : Update. * tui/tui-source.h (struct tui_source_window) : Default the constructor. * tui/tui-regs.h (struct tui_data_item_window) : Default the constructor. (struct tui_data_window) : Likewise. * tui/tui-disasm.h (struct tui_disasm_window) : Default the constructor. * tui/tui-data.h (struct tui_gen_win_info) : Default the constructor. : Remove. (struct tui_win_info) : Default the constructor. * tui/tui-data.c (tui_win_info::tui_win_info): Remove. * tui/tui-command.h (struct tui_cmd_window) : Default the constructor. Change-Id: I594cd07d2e0bba71ad594a6fb263904ce2febcd6 --- gdb/ChangeLog | 27 +++++++++++++++++++++++++++ gdb/tui/tui-command.h | 5 +---- gdb/tui/tui-data.c | 5 ----- gdb/tui/tui-data.h | 11 +++-------- gdb/tui/tui-disasm.h | 5 +---- gdb/tui/tui-regs.h | 10 ++-------- gdb/tui/tui-source.h | 5 +---- gdb/tui/tui-stack.h | 1 - gdb/tui/tui-winsource.c | 8 +++----- gdb/tui/tui-winsource.h | 2 +- gdb/tui/tui.h | 3 --- 11 files changed, 39 insertions(+), 43 deletions(-) diff --git a/gdb/tui/tui-command.h b/gdb/tui/tui-command.h index fca1f545730..211d0c8d8a2 100644 --- a/gdb/tui/tui-command.h +++ b/gdb/tui/tui-command.h @@ -27,10 +27,7 @@ /* The TUI command window. */ struct tui_cmd_window : public tui_win_info { - tui_cmd_window () - : tui_win_info (CMD_WIN) - { - } + tui_cmd_window () = default; DISABLE_COPY_AND_ASSIGN (tui_cmd_window); diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index ead8b1043ca..db637d8fbe6 100644 --- a/gdb/tui/tui-data.c +++ b/gdb/tui/tui-data.c @@ -129,11 +129,6 @@ tui_prev_win (struct tui_win_info *cur_win) } -tui_win_info::tui_win_info (enum tui_win_type type) - : tui_gen_win_info (type) -{ -} - void tui_win_info::rerender () { diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index 96265bb4215..56600926636 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -22,7 +22,7 @@ #ifndef TUI_TUI_DATA_H #define TUI_TUI_DATA_H -#include "tui/tui.h" /* For enum tui_win_type. */ +#include "tui/tui.h" #include "gdb_curses.h" /* For WINDOW. */ #include "observable.h" @@ -44,10 +44,7 @@ struct tui_gen_win_info { protected: - explicit tui_gen_win_info (enum tui_win_type t) - : type (t) - { - } + tui_gen_win_info () = default; /* This is called after the window is resized, and should update the window's contents. */ @@ -110,8 +107,6 @@ public: /* Window handle. */ std::unique_ptr handle; - /* Type of window. */ - enum tui_win_type type; /* Window width. */ int width = 0; /* Window height. */ @@ -155,7 +150,7 @@ struct tui_win_info : public tui_gen_win_info { protected: - explicit tui_win_info (enum tui_win_type type); + tui_win_info () = default; DISABLE_COPY_AND_ASSIGN (tui_win_info); /* Scroll the contents vertically. This is only called via diff --git a/gdb/tui/tui-disasm.h b/gdb/tui/tui-disasm.h index 416be95fd8b..dd020310746 100644 --- a/gdb/tui/tui-disasm.h +++ b/gdb/tui/tui-disasm.h @@ -30,10 +30,7 @@ struct tui_disasm_window : public tui_source_window_base { - tui_disasm_window () - : tui_source_window_base (DISASSEM_WIN) - { - } + tui_disasm_window () = default; DISABLE_COPY_AND_ASSIGN (tui_disasm_window); diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h index 97e02b1a47d..8c49888373f 100644 --- a/gdb/tui/tui-regs.h +++ b/gdb/tui/tui-regs.h @@ -28,10 +28,7 @@ struct tui_data_item_window : public tui_gen_win_info { - tui_data_item_window () - : tui_gen_win_info (DATA_ITEM_WIN) - { - } + tui_data_item_window () = default; DISABLE_COPY_AND_ASSIGN (tui_data_item_window); @@ -61,10 +58,7 @@ struct tui_data_item_window : public tui_gen_win_info /* The TUI registers window. */ struct tui_data_window : public tui_win_info { - tui_data_window () - : tui_win_info (DATA_WIN) - { - } + tui_data_window () = default; DISABLE_COPY_AND_ASSIGN (tui_data_window); diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h index 06ca8d52fe4..58dc5e88cf7 100644 --- a/gdb/tui/tui-source.h +++ b/gdb/tui/tui-source.h @@ -31,10 +31,7 @@ struct symtab; struct tui_source_window : public tui_source_window_base { - tui_source_window () - : tui_source_window_base (SRC_WIN) - { - } + tui_source_window () = default; DISABLE_COPY_AND_ASSIGN (tui_source_window); diff --git a/gdb/tui/tui-stack.h b/gdb/tui/tui-stack.h index bea3e79279b..fde7c6dd2c9 100644 --- a/gdb/tui/tui-stack.h +++ b/gdb/tui/tui-stack.h @@ -31,7 +31,6 @@ struct frame_info; struct tui_locator_window : public tui_gen_win_info { tui_locator_window () - : tui_gen_win_info (LOCATOR_WIN) { full_name[0] = 0; proc_name[0] = 0; diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 69070115ec6..bd7a34ebbd5 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -285,10 +285,8 @@ tui_source_window_base::show_source_content () refresh_window (); } -tui_source_window_base::tui_source_window_base (enum tui_win_type type) - : tui_win_info (type) +tui_source_window_base::tui_source_window_base () { - gdb_assert (type == SRC_WIN || type == DISASSEM_WIN); start_line_or_addr.loa = LOA_ADDRESS; start_line_or_addr.u.addr = 0; @@ -333,7 +331,7 @@ tui_source_window_base::rerender () struct gdbarch *gdbarch = get_frame_arch (frame); struct symtab *s = find_pc_line_symtab (get_frame_pc (frame)); - if (type != SRC_WIN) + if (this != TUI_SRC_WIN) find_line_pc (s, cursal.line, &cursal.pc); update_source_window (gdbarch, cursal); } @@ -348,7 +346,7 @@ tui_source_window_base::refill () { symtab_and_line sal {}; - if (type == SRC_WIN) + if (this == TUI_SRC_WIN) { sal = get_current_source_symtab_and_line (); if (sal.symtab == NULL) diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h index cae535fab07..4ac20d80502 100644 --- a/gdb/tui/tui-winsource.h +++ b/gdb/tui/tui-winsource.h @@ -75,7 +75,7 @@ struct tui_source_element struct tui_source_window_base : public tui_win_info { protected: - explicit tui_source_window_base (enum tui_win_type type); + tui_source_window_base (); ~tui_source_window_base (); DISABLE_COPY_AND_ASSIGN (tui_source_window_base); diff --git a/gdb/tui/tui.h b/gdb/tui/tui.h index 6605901f21a..816b1e92851 100644 --- a/gdb/tui/tui.h +++ b/gdb/tui/tui.h @@ -40,9 +40,6 @@ enum tui_win_type CMD_WIN, /* This must ALWAYS be AFTER the major windows last. */ MAX_MAJOR_WINDOWS, - /* Auxiliary windows. */ - LOCATOR_WIN, - DATA_ITEM_WIN }; extern CORE_ADDR tui_get_low_disassembly_address (struct gdbarch *,