From patchwork Sun Jun 23 22:43:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33314 Received: (qmail 56828 invoked by alias); 23 Jun 2019 23:25:52 -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 56758 invoked by uid 89); 23 Jun 2019 23:25:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.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=Always, pushing X-HELO: gateway34.websitewelcome.com Received: from gateway34.websitewelcome.com (HELO gateway34.websitewelcome.com) (192.185.149.105) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 23 Jun 2019 23:25:49 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway34.websitewelcome.com (Postfix) with ESMTP id A42521CE55 for ; Sun, 23 Jun 2019 18:25:48 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id fBrohduVV90onfBrohcHjm; Sun, 23 Jun 2019 18:25:48 -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=ljXdCUxms5wu2lTDCMQkDGHPr+hlmd7aMMnzazdiT7g=; b=fx6sa80HE4Y71lLHaB//rfJBAv 5Ha58k2Y2QXL4NS5Zhvi9rz3Wz/pEvMh81y4v6Kkqk2MmR7jT+mDV7aeAgSHY9wDdu1eIkLNd6i1/ tXgpu3FTGZCelpOXGG+Ewk1WP; Received: from 75-166-12-78.hlrn.qwest.net ([75.166.12.78]:54396 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1hfBDB-000vDQ-TJ; Sun, 23 Jun 2019 17:43:49 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 43/66] Remove some TUI static allocations Date: Sun, 23 Jun 2019 16:43:06 -0600 Message-Id: <20190623224329.16060-44-tom@tromey.com> In-Reply-To: <20190623224329.16060-1-tom@tromey.com> References: <20190623224329.16060-1-tom@tromey.com> The TUI statically allocates the "execution_info" for the source and disassembly windows. However, there's no deep reason to do this, and this approach makes it harder to allow multiple such windows. This patch removes the static data and changes the code to simply allocate these windows as needed. This required pushing some code into the tui_gen_win_info destructor, but that seems like a good idea anyhow. 2019-06-23 Tom Tromey * tui/tui-layout.c (make_source_or_disasm_window): Always use init_and_make_win for EXEC_INFO_WIN. * tui/tui-data.h (struct tui_gen_win_info) <~tui_gen_win_info>: No longer inline. (struct tui_win_info) <~tui_win_info>: Inline. (tui_source_exec_info_win_ptr, tui_disassem_exec_info_win_ptr): Don't declare. * tui/tui-data.c (source_win, disasm_win): Remove globals. (tui_source_exec_info_win_ptr, tui_disassem_exec_info_win_ptr): Remove. (tui_initialize_static_data): Update. (~tui_gen_win_info): Handle more cleanup here. (~tui_source_window_base): Delete "execution_info". (~tui_win_info): Move code to ~tui_gen_win_info; remove. --- gdb/ChangeLog | 17 +++++++++++++++ gdb/tui/tui-data.c | 52 ++++++++++---------------------------------- gdb/tui/tui-data.h | 10 ++++----- gdb/tui/tui-layout.c | 24 +++++++------------- 4 files changed, 41 insertions(+), 62 deletions(-) diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index 5bb79156e70..7af9c19fa4d 100644 --- a/gdb/tui/tui-data.c +++ b/gdb/tui/tui-data.c @@ -37,8 +37,6 @@ struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS]; static enum tui_layout_type current_layout = UNDEFINED_LAYOUT; static int term_height, term_width; static struct tui_gen_win_info _locator (LOCATOR_WIN); -static struct tui_gen_win_info source_win (EXEC_INFO_WIN); -static struct tui_gen_win_info disasm_win (EXEC_INFO_WIN); static struct std::vector source_windows; static struct tui_win_info *win_with_focus = NULL; static struct tui_layout_def layout_def = { @@ -185,22 +183,6 @@ tui_data_window::clear_detail () display_regs = false; } -/* Accessor for the source execution info ptr. */ -struct tui_gen_win_info * -tui_source_exec_info_win_ptr (void) -{ - return &source_win; -} - - -/* Accessor for the disassem execution info ptr. */ -struct tui_gen_win_info * -tui_disassem_exec_info_win_ptr (void) -{ - return &disasm_win; -} - - /* Accessor for the locator win info. Answers a pointer to the static locator win info struct. */ struct tui_gen_win_info * @@ -354,8 +336,6 @@ tui_partial_win_by_name (const char *name) void tui_initialize_static_data (void) { - tui_init_generic_part (tui_source_exec_info_win_ptr ()); - tui_init_generic_part (tui_disassem_exec_info_win_ptr ()); tui_init_generic_part (tui_locator_win_info_ptr ()); } @@ -525,16 +505,21 @@ tui_add_content_elements (struct tui_gen_win_info *win_info, return index_start; } -tui_source_window_base::~tui_source_window_base () +tui_gen_win_info::~tui_gen_win_info () { - xfree (fullname); - struct tui_gen_win_info *generic_win = execution_info; - if (generic_win != NULL) + if (handle != NULL) { - tui_delete_win (generic_win->handle); - generic_win->handle = NULL; - tui_free_win_content (generic_win); + tui_delete_win (handle); + handle = NULL; + tui_free_win_content (this); } + xfree (title); +} + +tui_source_window_base::~tui_source_window_base () +{ + xfree (fullname); + delete execution_info; } tui_data_window::~tui_data_window () @@ -554,19 +539,6 @@ tui_data_window::~tui_data_window () } } -tui_win_info::~tui_win_info () -{ - if (handle != NULL) - { - tui_delete_win (handle); - handle = NULL; - tui_free_win_content (this); - } - if (title) - xfree (title); -} - - void tui_free_all_source_wins_content () { diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index be34afa70aa..a79331144dd 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -44,9 +44,7 @@ struct tui_gen_win_info { } - virtual ~tui_gen_win_info () - { - } + virtual ~tui_gen_win_info (); /* Call to refresh this window. */ virtual void refresh_window (); @@ -272,7 +270,9 @@ protected: public: - ~tui_win_info () override; + ~tui_win_info () override + { + } /* Clear the pertinent detail in the window. */ virtual void clear_detail () = 0; @@ -524,8 +524,6 @@ extern void tui_set_term_height_to (int); extern int tui_term_width (void); extern void tui_set_term_width_to (int); extern struct tui_gen_win_info *tui_locator_win_info_ptr (void); -extern struct tui_gen_win_info *tui_source_exec_info_win_ptr (void); -extern struct tui_gen_win_info *tui_disassem_exec_info_win_ptr (void); extern struct std::vector &tui_source_windows (); extern void tui_clear_source_windows (void); extern void tui_clear_source_windows_detail (void); diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index f586d703d43..695fa3560b2 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -814,22 +814,14 @@ static struct tui_win_info * make_source_or_disasm_window (enum tui_win_type type, int height, int origin_y) { - struct tui_gen_win_info *execution_info = NULL; - - /* Create the exeuction info window. */ - if (type == SRC_WIN) - execution_info = tui_source_exec_info_win_ptr (); - else - execution_info = tui_disassem_exec_info_win_ptr (); - execution_info - = ((struct tui_gen_win_info *) - init_and_make_win (execution_info, - EXEC_INFO_WIN, - height, - 3, - 0, - origin_y, - DONT_BOX_WINDOW)); + struct tui_gen_win_info *execution_info + = init_and_make_win (nullptr, + EXEC_INFO_WIN, + height, + 3, + 0, + origin_y, + DONT_BOX_WINDOW); /* Now create the source window. */ struct tui_source_window_base *result