From patchwork Sun Jun 23 22:42:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33286 Received: (qmail 48010 invoked by alias); 23 Jun 2019 22:43:45 -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 47767 invoked by uid 89); 23 Jun 2019 22:43:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.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= X-HELO: gateway20.websitewelcome.com Received: from gateway20.websitewelcome.com (HELO gateway20.websitewelcome.com) (192.185.51.6) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 23 Jun 2019 22:43:40 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway20.websitewelcome.com (Postfix) with ESMTP id DFA3F400E5A89 for ; Sun, 23 Jun 2019 16:42:00 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id fBD1hIMZ92PzOfBD1hXxta; Sun, 23 Jun 2019 17:43:39 -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=/ofrAtpjhrn6ugEeflQrEcvFDGtVuEtfKKc4slVNG5k=; b=AcdH8AelhsImU1q6YKroOT/Aqd vAe4zgLVoeQkv9QFKtmNEWllYw/L1EfwSDHChSf6R9sj4glH3mYeHycYVMPlpe0lXL7a40JlHtfAb +hexd5UEP3DVq6Ds67HmWatOa; 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 1hfBD0-000vDQ-Ur; Sun, 23 Jun 2019 17:43:39 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 05/66] Simplify command window creation Date: Sun, 23 Jun 2019 16:42:28 -0600 Message-Id: <20190623224329.16060-6-tom@tromey.com> In-Reply-To: <20190623224329.16060-1-tom@tromey.com> References: <20190623224329.16060-1-tom@tromey.com> make_command_window is never called when *win_info_ptr is non-NULL, so this patch simplifies the function by removing the parameter and having it return its result directly. This in turn makes it more obvious that a NULL check in show_source_disasm_command can be removed. gdb/ChangeLog 2019-06-23 Tom Tromey * tui/tui-layout.c (make_command_window): Remove win_info_ptr parameter. Return the new window. (show_source_disasm_command): Update and remove NULL check. (show_source_or_disasm_and_command): Update. --- gdb/ChangeLog | 7 +++ gdb/tui/tui-layout.c | 146 ++++++++++++++++++++----------------------- 2 files changed, 76 insertions(+), 77 deletions(-) diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 695c56012c1..3eddc56578b 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -52,7 +52,7 @@ static void show_source_or_disasm_and_command (enum tui_layout_type); static void make_source_or_disasm_window (struct tui_win_info **, enum tui_win_type, int, int); -static void make_command_window (struct tui_win_info **, int, int); +static struct tui_win_info *make_command_window (int, int); static void make_source_window (struct tui_win_info **, int, int); static void make_disasm_window (struct tui_win_info **, int, int); static void make_data_window (struct tui_win_info **, int, int); @@ -540,20 +540,19 @@ prev_layout (void) -static void -make_command_window (struct tui_win_info **win_info_ptr, - int height, int origin_y) +static struct tui_win_info * +make_command_window (int height, int origin_y) { - *win_info_ptr - = (struct tui_win_info *) init_and_make_win (*win_info_ptr, + struct tui_win_info *result + = (struct tui_win_info *) init_and_make_win (NULL, CMD_WIN, height, tui_term_width (), 0, origin_y, DONT_BOX_WINDOW); - - (*win_info_ptr)->can_highlight = FALSE; + result->can_highlight = FALSE; + return result; } @@ -650,76 +649,69 @@ show_source_disasm_command (void) tui_make_visible (TUI_SRC_WIN->detail.source_info.execution_info); TUI_SRC_WIN->detail.source_info.has_locator = FALSE;; } - if (TUI_SRC_WIN != NULL) - { - struct tui_gen_win_info *locator = tui_locator_win_info_ptr (); - tui_show_source_content (TUI_SRC_WIN); - if (TUI_DISASM_WIN == NULL) - { - make_disasm_window (&TUI_DISASM_WIN, asm_height, src_height - 1); - locator - = ((struct tui_gen_win_info *) - init_and_make_win (locator, - LOCATOR_WIN, - 2 /* 1 */ , - tui_term_width (), - 0, - (src_height + asm_height) - 1, - DONT_BOX_WINDOW)); - } - else - { - init_gen_win_info (locator, - LOCATOR_WIN, - 2 /* 1 */ , - tui_term_width (), - 0, - (src_height + asm_height) - 1); - TUI_DISASM_WIN->detail.source_info.has_locator = TRUE; - init_gen_win_info (&TUI_DISASM_WIN->generic, - TUI_DISASM_WIN->generic.type, - asm_height, - TUI_DISASM_WIN->generic.width, - TUI_DISASM_WIN->detail.source_info.execution_info->width, - src_height - 1); - init_gen_win_info (TUI_DISASM_WIN->detail.source_info.execution_info, - EXEC_INFO_WIN, - asm_height, - 3, - 0, - src_height - 1); - TUI_DISASM_WIN->can_highlight = TRUE; - tui_make_visible (&TUI_DISASM_WIN->generic); - tui_make_visible (TUI_DISASM_WIN->detail.source_info.execution_info); - } - if (TUI_DISASM_WIN != NULL) - { - TUI_SRC_WIN->detail.source_info.has_locator = FALSE; - TUI_DISASM_WIN->detail.source_info.has_locator = TRUE; - tui_make_visible (locator); - tui_show_locator_content (); - tui_show_source_content (TUI_DISASM_WIN); - - if (TUI_CMD_WIN == NULL) - make_command_window (&TUI_CMD_WIN, - cmd_height, - tui_term_height () - cmd_height); - else - { - init_gen_win_info (&TUI_CMD_WIN->generic, - TUI_CMD_WIN->generic.type, - TUI_CMD_WIN->generic.height, - TUI_CMD_WIN->generic.width, - 0, - TUI_CMD_WIN->generic.origin.y); - TUI_CMD_WIN->can_highlight = FALSE; - tui_make_visible (&TUI_CMD_WIN->generic); - } - if (TUI_CMD_WIN != NULL) - tui_refresh_win (&TUI_CMD_WIN->generic); - } + struct tui_gen_win_info *locator = tui_locator_win_info_ptr (); + + tui_show_source_content (TUI_SRC_WIN); + if (TUI_DISASM_WIN == NULL) + { + make_disasm_window (&TUI_DISASM_WIN, asm_height, src_height - 1); + locator + = ((struct tui_gen_win_info *) + init_and_make_win (locator, + LOCATOR_WIN, + 2 /* 1 */ , + tui_term_width (), + 0, + (src_height + asm_height) - 1, + DONT_BOX_WINDOW)); + } + else + { + init_gen_win_info (locator, + LOCATOR_WIN, + 2 /* 1 */ , + tui_term_width (), + 0, + (src_height + asm_height) - 1); + TUI_DISASM_WIN->detail.source_info.has_locator = TRUE; + init_gen_win_info (&TUI_DISASM_WIN->generic, + TUI_DISASM_WIN->generic.type, + asm_height, + TUI_DISASM_WIN->generic.width, + TUI_DISASM_WIN->detail.source_info.execution_info->width, + src_height - 1); + init_gen_win_info (TUI_DISASM_WIN->detail.source_info.execution_info, + EXEC_INFO_WIN, + asm_height, + 3, + 0, + src_height - 1); + TUI_DISASM_WIN->can_highlight = TRUE; + tui_make_visible (&TUI_DISASM_WIN->generic); + tui_make_visible (TUI_DISASM_WIN->detail.source_info.execution_info); + } + TUI_SRC_WIN->detail.source_info.has_locator = FALSE; + TUI_DISASM_WIN->detail.source_info.has_locator = TRUE; + tui_make_visible (locator); + tui_show_locator_content (); + tui_show_source_content (TUI_DISASM_WIN); + + if (TUI_CMD_WIN == NULL) + TUI_CMD_WIN = make_command_window (cmd_height, + tui_term_height () - cmd_height); + else + { + init_gen_win_info (&TUI_CMD_WIN->generic, + TUI_CMD_WIN->generic.type, + TUI_CMD_WIN->generic.height, + TUI_CMD_WIN->generic.width, + 0, + TUI_CMD_WIN->generic.origin.y); + TUI_CMD_WIN->can_highlight = FALSE; + tui_make_visible (&TUI_CMD_WIN->generic); } + tui_refresh_win (&TUI_CMD_WIN->generic); tui_set_current_layout_to (SRC_DISASSEM_COMMAND); } } @@ -964,7 +956,7 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type) if (TUI_CMD_WIN == NULL) { - make_command_window (&TUI_CMD_WIN, cmd_height, src_height); + TUI_CMD_WIN = make_command_window (cmd_height, src_height); tui_refresh_win (&TUI_CMD_WIN->generic); } else