From patchwork Fri Dec 27 23:50:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 37109 Received: (qmail 98858 invoked by alias); 27 Dec 2019 23:50:38 -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 98824 invoked by uid 89); 27 Dec 2019 23:50:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.2 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.50.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 27 Dec 2019 23:50:37 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 7A92D400C4361 for ; Fri, 27 Dec 2019 16:39:22 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id kzNLihFwo3Qi0kzNLiWvEG; Fri, 27 Dec 2019 17:50:35 -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=lpCebbPUTB/Vyi7YGk2mtMB8Hc6UNLkMImaToIUWxP8=; b=ddBZB2sRkgXKJavmT6AyHfC+wP o9+Sbxp0y3iYib0gXdEwIC4YWpUFWy15mrGC1idi35kFcxC/o4EY/KA4bBsjG6R2TqHeOZlM9Sy29 CJU8kMa6MZGzoB1loqGwFld53; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:38936 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1ikzNL-004GrV-Gu; Fri, 27 Dec 2019 16:50:35 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/3] Make "file" clear TUI source window Date: Fri, 27 Dec 2019 16:50:32 -0700 Message-Id: <20191227235034.5453-2-tom@tromey.com> In-Reply-To: <20191227235034.5453-1-tom@tromey.com> References: <20191227235034.5453-1-tom@tromey.com> I noticed that a plain "file" will leave the current source file in the TUI source window. Instead, I think, it should clear the source window. This patch implements this. 2019-12-21 Tom Tromey * tui/tui-winsource.c (tui_update_source_windows_with_line): Handle case where symtab is null. gdb/testsuite/ChangeLog 2019-12-22 Tom Tromey * gdb.tui/main.exp: Add check for plain "file". Change-Id: I8424acf837f1a47f75bc6a833d1e917d4c10b51e --- gdb/ChangeLog | 5 +++++ gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.tui/main.exp | 7 +++++++ gdb/tui/tui-winsource.c | 11 ++++++----- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/gdb/testsuite/gdb.tui/main.exp b/gdb/testsuite/gdb.tui/main.exp index 57ddb52bf36..b62e0f420d9 100644 --- a/gdb/testsuite/gdb.tui/main.exp +++ b/gdb/testsuite/gdb.tui/main.exp @@ -26,9 +26,16 @@ if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} { # Note: don't pass the executable here Term::clean_restart 24 80 +# Later on we'd like to avoid having to answer a question. +gdb_test_no_output "set interactive-mode off" + if {![Term::enter_tui]} { unsupported "TUI not supported" } Term::command "file [standard_output_file $testfile]" Term::check_contents "show main after file" "\\|.*21 *return 0" + +# Ensure that "file" clears the source window. +Term::command "file" +Term::check_contents "file clears window" "No Source Available" diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 1ac650b6987..d720e99c6ab 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -212,11 +212,12 @@ tui_update_source_windows_with_addr (struct gdbarch *gdbarch, CORE_ADDR addr) void tui_update_source_windows_with_line (struct symtab_and_line sal) { - if (!sal.symtab) - return; - - find_line_pc (sal.symtab, sal.line, &sal.pc); - struct gdbarch *gdbarch = get_objfile_arch (SYMTAB_OBJFILE (sal.symtab)); + struct gdbarch *gdbarch = nullptr; + if (sal.symtab != nullptr) + { + find_line_pc (sal.symtab, sal.line, &sal.pc); + gdbarch = get_objfile_arch (SYMTAB_OBJFILE (sal.symtab)); + } for (struct tui_source_window_base *win_info : tui_source_windows ()) win_info->update_source_window (gdbarch, sal);