From patchwork Thu Jul 4 17:02:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33574 Received: (qmail 109503 invoked by alias); 4 Jul 2019 17:03:55 -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 106783 invoked by uid 89); 4 Jul 2019 17:03:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.0 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.60.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 Jul 2019 17:03:30 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway20.websitewelcome.com (Postfix) with ESMTP id A9455400CECF9 for ; Thu, 4 Jul 2019 11:01:17 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id j58rhxLyp4FKpj58rhBuZS; Thu, 04 Jul 2019 12:03:29 -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=7NI2QyXUSi4hpT7w+wprEY5wN4KNwyjBXn09T34sUSw=; b=ZFkw/IUStOavcBd8OIhuVXQTZY AQvhUX9LBogbej75UsFU4J+X4EsPKlcDxQzLZ9zsTM5KYxpZSyxBkTdx9KUXCkQqAFGR1OdagLkpo 5EpMokrCh/e6C1kBW8eBcwPlg; Received: from 174-29-58-150.hlrn.qwest.net ([174.29.58.150]:34702 helo=bapiya.Home) by box5379.bluehost.com with esmtpa (Exim 4.92) (envelope-from ) id 1hj58q-002sKm-QN; Thu, 04 Jul 2019 12:03:28 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 40/61] Change tui_set_layout to return void Date: Thu, 4 Jul 2019 11:02:50 -0600 Message-Id: <20190704170311.15982-41-tom@tromey.com> In-Reply-To: <20190704170311.15982-1-tom@tromey.com> References: <20190704170311.15982-1-tom@tromey.com> tui_set_layout can't meaningfully be called with UNDEFINED_LAYOUT; and instead of trying to handle this case, simply assert and have the function return void. No caller was checking the return value anyway. 2019-07-04 Tom Tromey * tui/tui-layout.h (tui/tui-layout): Return void. * tui/tui-layout.c (tui_set_layout): Return void. Add assert. --- gdb/ChangeLog | 5 ++ gdb/tui/tui-layout.c | 167 +++++++++++++++++++++---------------------- gdb/tui/tui-layout.h | 2 +- 3 files changed, 86 insertions(+), 88 deletions(-) diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index d15df2a37c8..7feadd71ece 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -113,104 +113,97 @@ show_layout (enum tui_layout_type layout) /* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND, SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND. */ -enum tui_status +void tui_set_layout (enum tui_layout_type layout_type) { - enum tui_status status = TUI_SUCCESS; + gdb_assert (layout_type != UNDEFINED_LAYOUT); - if (layout_type != UNDEFINED_LAYOUT) - { - enum tui_layout_type cur_layout = tui_current_layout (); - struct gdbarch *gdbarch; - CORE_ADDR addr; - struct tui_win_info *win_with_focus = tui_win_with_focus (); - struct tui_layout_def *layout_def = tui_layout_def (); + enum tui_layout_type cur_layout = tui_current_layout (); + struct gdbarch *gdbarch; + CORE_ADDR addr; + struct tui_win_info *win_with_focus = tui_win_with_focus (); + struct tui_layout_def *layout_def = tui_layout_def (); - extract_display_start_addr (&gdbarch, &addr); + extract_display_start_addr (&gdbarch, &addr); - enum tui_layout_type new_layout = layout_type; + enum tui_layout_type new_layout = layout_type; - if (new_layout != cur_layout) - { - show_layout (new_layout); + if (new_layout != cur_layout) + { + show_layout (new_layout); - /* Now determine where focus should be. */ - if (win_with_focus != TUI_CMD_WIN) + /* Now determine where focus should be. */ + if (win_with_focus != TUI_CMD_WIN) + { + switch (new_layout) { - switch (new_layout) - { - case SRC_COMMAND: - tui_set_win_focus_to (TUI_SRC_WIN); - layout_def->display_mode = SRC_WIN; - break; - case DISASSEM_COMMAND: - /* The previous layout was not showing code. - This can happen if there is no source - available: - - 1. if the source file is in another dir OR - 2. if target was compiled without -g - We still want to show the assembly though! */ - - tui_get_begin_asm_address (&gdbarch, &addr); - tui_set_win_focus_to (TUI_DISASM_WIN); - layout_def->display_mode = DISASSEM_WIN; - break; - case SRC_DISASSEM_COMMAND: - /* The previous layout was not showing code. - This can happen if there is no source - available: - - 1. if the source file is in another dir OR - 2. if target was compiled without -g - We still want to show the assembly though! */ - - tui_get_begin_asm_address (&gdbarch, &addr); - if (win_with_focus == TUI_SRC_WIN) - tui_set_win_focus_to (TUI_SRC_WIN); - else - tui_set_win_focus_to (TUI_DISASM_WIN); - break; - case SRC_DATA_COMMAND: - if (win_with_focus != TUI_DATA_WIN) - tui_set_win_focus_to (TUI_SRC_WIN); - else - tui_set_win_focus_to (TUI_DATA_WIN); - layout_def->display_mode = SRC_WIN; - break; - case DISASSEM_DATA_COMMAND: - /* The previous layout was not showing code. - This can happen if there is no source - available: - - 1. if the source file is in another dir OR - 2. if target was compiled without -g - We still want to show the assembly though! */ - - tui_get_begin_asm_address (&gdbarch, &addr); - if (win_with_focus != TUI_DATA_WIN) - tui_set_win_focus_to (TUI_DISASM_WIN); - else - tui_set_win_focus_to (TUI_DATA_WIN); - layout_def->display_mode = DISASSEM_WIN; - break; - default: - break; - } + case SRC_COMMAND: + tui_set_win_focus_to (TUI_SRC_WIN); + layout_def->display_mode = SRC_WIN; + break; + case DISASSEM_COMMAND: + /* The previous layout was not showing code. + This can happen if there is no source + available: + + 1. if the source file is in another dir OR + 2. if target was compiled without -g + We still want to show the assembly though! */ + + tui_get_begin_asm_address (&gdbarch, &addr); + tui_set_win_focus_to (TUI_DISASM_WIN); + layout_def->display_mode = DISASSEM_WIN; + break; + case SRC_DISASSEM_COMMAND: + /* The previous layout was not showing code. + This can happen if there is no source + available: + + 1. if the source file is in another dir OR + 2. if target was compiled without -g + We still want to show the assembly though! */ + + tui_get_begin_asm_address (&gdbarch, &addr); + if (win_with_focus == TUI_SRC_WIN) + tui_set_win_focus_to (TUI_SRC_WIN); + else + tui_set_win_focus_to (TUI_DISASM_WIN); + break; + case SRC_DATA_COMMAND: + if (win_with_focus != TUI_DATA_WIN) + tui_set_win_focus_to (TUI_SRC_WIN); + else + tui_set_win_focus_to (TUI_DATA_WIN); + layout_def->display_mode = SRC_WIN; + break; + case DISASSEM_DATA_COMMAND: + /* The previous layout was not showing code. + This can happen if there is no source + available: + + 1. if the source file is in another dir OR + 2. if target was compiled without -g + We still want to show the assembly though! */ + + tui_get_begin_asm_address (&gdbarch, &addr); + if (win_with_focus != TUI_DATA_WIN) + tui_set_win_focus_to (TUI_DISASM_WIN); + else + tui_set_win_focus_to (TUI_DATA_WIN); + layout_def->display_mode = DISASSEM_WIN; + break; + default: + break; } - /* - * Now update the window content. - */ - tui_update_source_windows_with_addr (gdbarch, addr); - if (new_layout == SRC_DATA_COMMAND - || new_layout == DISASSEM_DATA_COMMAND) - tui_show_registers (TUI_DATA_WIN->current_group); } + /* + * Now update the window content. + */ + tui_update_source_windows_with_addr (gdbarch, addr); + if (new_layout == SRC_DATA_COMMAND + || new_layout == DISASSEM_DATA_COMMAND) + tui_show_registers (TUI_DATA_WIN->current_group); } - else - status = TUI_FAILURE; - - return status; } /* Add the specified window to the layout in a logical way. This diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h index bc21d2999e4..5f1993387be 100644 --- a/gdb/tui/tui-layout.h +++ b/gdb/tui/tui-layout.h @@ -30,6 +30,6 @@ extern int tui_default_win_height (enum tui_win_type, enum tui_layout_type); extern int tui_default_win_viewport_height (enum tui_win_type, enum tui_layout_type); -extern enum tui_status tui_set_layout (enum tui_layout_type); +extern void tui_set_layout (enum tui_layout_type); #endif /* TUI_TUI_LAYOUT_H */