From patchwork Thu Jul 4 17:02:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33535 Received: (qmail 103984 invoked by alias); 4 Jul 2019 17:03:18 -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 103948 invoked by uid 89); 4 Jul 2019 17:03:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.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.60.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 Jul 2019 17:03:17 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 56F9C400D7C93 for ; Thu, 4 Jul 2019 11:01:04 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id j58dhxLn84FKpj58dhBuNt; Thu, 04 Jul 2019 12:03:15 -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=mpqmmcEthqUbuVvvwNS5eFArpJqUzgJhWwrYk0PvzpM=; b=CkHMrobKJK1OB/FXK59TcBMOu3 ryOTQ+jidgi68PISfwCYpAgX7Q7LH9Ox0WijyNBE4JaPnCqruHLB1/cpFyNGht0DXly6xIi/v55gb 7l6M//jfm4dRm4Ud5gP/5c+Hy; 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 1hj58d-002sAP-GD; Thu, 04 Jul 2019 12:03:15 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 04/61] Consolidate "if"s in tui_show_frame_info Date: Thu, 4 Jul 2019 11:02:14 -0600 Message-Id: <20190704170311.15982-5-tom@tromey.com> In-Reply-To: <20190704170311.15982-1-tom@tromey.com> References: <20190704170311.15982-1-tom@tromey.com> tui_show_frame_info has two parallel "if"s with the same condition and no intervening code. The second "if" perhaps wasn't obviously identical, but earlier refactorings made it clearer, by pointing out that only source and disassembly windows can be handled here. This merges the two statements. 2019-07-04 Tom Tromey * tui/tui-stack.c (tui_show_frame_info): Consolidate "if"s. --- gdb/ChangeLog | 4 +++ gdb/tui/tui-stack.c | 62 ++++++++++++++++++++------------------------- 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c index f761ac1f701..e1b996d7e6c 100644 --- a/gdb/tui/tui-stack.c +++ b/gdb/tui/tui-stack.c @@ -341,8 +341,6 @@ tui_show_frame_info (struct frame_info *fi) if (fi) { - int start_line; - CORE_ADDR low; struct tui_locator_window *locator = tui_locator_win_info_ptr (); int source_already_displayed; CORE_ADDR pc; @@ -372,32 +370,15 @@ tui_show_frame_info (struct frame_info *fi) return 0; tui_show_locator_content (); - start_line = 0; for (struct tui_source_window_base *win_info : tui_source_windows ()) { if (win_info == TUI_SRC_WIN) { - start_line = (locator->line_no - - (win_info->viewport_height / 2)) + 1; + int start_line = (locator->line_no - + (win_info->viewport_height / 2)) + 1; if (start_line <= 0) start_line = 1; - } - else - { - if (find_pc_partial_function (get_frame_pc (fi), - NULL, &low, NULL) == 0) - { - /* There is no symbol available for current PC. There is no - safe way how to "disassemble backwards". */ - low = get_frame_pc (fi); - } - else - low = tui_get_low_disassembly_address (get_frame_arch (fi), - low, get_frame_pc (fi)); - } - if (win_info == TUI_SRC_WIN) - { struct tui_line_or_address l; l.loa = LOA_LINE; @@ -415,23 +396,34 @@ tui_show_frame_info (struct frame_info *fi) } else { - if (win_info == TUI_DISASM_WIN) + CORE_ADDR low; + + if (find_pc_partial_function (get_frame_pc (fi), + NULL, &low, NULL) == 0) + { + /* There is no symbol available for current PC. There is no + safe way how to "disassemble backwards". */ + low = get_frame_pc (fi); + } + else + low = tui_get_low_disassembly_address (get_frame_arch (fi), + low, get_frame_pc (fi)); + + struct tui_line_or_address a; + + a.loa = LOA_ADDRESS; + a.u.addr = low; + if (!tui_addr_is_displayed (locator->addr, + win_info, TRUE)) + tui_update_source_window (win_info, get_frame_arch (fi), + sal.symtab, a, TRUE); + else { - struct tui_line_or_address a; - - a.loa = LOA_ADDRESS; - a.u.addr = low; - if (!tui_addr_is_displayed (locator->addr, - win_info, TRUE)) - tui_update_source_window (win_info, get_frame_arch (fi), - sal.symtab, a, TRUE); - else - { - a.u.addr = locator->addr; - win_info->set_is_exec_point_at (a); - } + a.u.addr = locator->addr; + win_info->set_is_exec_point_at (a); } } + tui_update_exec_info (win_info); }