From patchwork Tue Jan 7 11:52:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 37237 Received: (qmail 22998 invoked by alias); 7 Jan 2020 11:52:33 -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 22933 invoked by uid 89); 7 Jan 2020 11:52:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=presented X-HELO: mail-wr1-f44.google.com Received: from mail-wr1-f44.google.com (HELO mail-wr1-f44.google.com) (209.85.221.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 07 Jan 2020 11:52:30 +0000 Received: by mail-wr1-f44.google.com with SMTP id z3so53623021wru.3 for ; Tue, 07 Jan 2020 03:52:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=nHTDTp5v7oBz7zW+FUA8R9ctyyIyMgbw7r72LsiR33g=; b=Pt656+ThsBH5/c+y3AULliSa65hQmc4i3oNYgerEgHlZoojPpI1F+WFxyjTjwTC0oo qX/INSiJ7zSg5cTejZG680/4fup3IhldXL5HzomUx9ZVVFp2LJNLVB+mGD9uDNr8LBw2 X1CWFP8lDcm3XkyCDQMelj78q3BwAxIOarNRwBzQ9q/8POY533F57lUpRpXZN/yqjJXN ai6J7mqJ+XGZzSMtCXTAOOGN50TWSo5cjuPqNm0IlZaSu4f7EboT3sq7dZ6yky3hgl00 hCxHZyT6anztQDNNqhok/o/rDMnhV5fjGx2TW3oj921ttDqnPvw+hB76oVt3Elg1r9Zx As5w== Return-Path: Received: from localhost (host86-186-80-236.range86-186.btcentralplus.com. [86.186.80.236]) by smtp.gmail.com with ESMTPSA id k13sm76108589wrx.59.2020.01.07.03.52.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jan 2020 03:52:27 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Tom Tromey , Hannes Domani , Andrew Burgess Subject: [PATCH 4/6] gdb/tui: Fix 'layout asm' before the inferior has started Date: Tue, 7 Jan 2020 11:52:17 +0000 Message-Id: In-Reply-To: References: In-Reply-To: References: <874kxrc3ha.fsf@tromey.com> X-IsSubscribed: yes Currently if a user starts the tui with 'layout asm' then they will be presented with the 'src' layout. What happens is: 1. Layout command enables TUI, selecting the SRC layout by default. 2. As part of tui_enable we call tui_display_main, which calls tui_get_begin_asm_address, which calls set_default_source_symtab_and_line. This changes core GDBs current symtab and line, which triggers a call to the symtab changed hook tui_symtab_changed, which sets the flag from_source_symtab. 3. Back in the layout command, the layout is changed from SRC to ASM. After this the layout command completes and we return to core GDB which prints the prompt, however... 4. The before prompt hook is called which sees the from_source_symtab flag is set and forces the SRC window to be displayed. This switches us back to SRC view. The solution I propose here is to delay installing the hooks into core GDB until after we have finished setting up the tui and selecting the default frame to view. In this way we effectively ignore the first symtab changed event triggered when making main the default symtab. gdb/ChangeLog: * tui/tui.c (tui_enable): Register tui hooks after calling tui_display_main. gdb/testsuite/ChangeLog: * gdb.tui/tui-layout-asm.exp: New file. Change-Id: I858ab81a17ffb4aa72deb3f36c3755228a9c9d9a --- gdb/ChangeLog | 5 +++++ gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.tui/tui-layout-asm.exp | 34 ++++++++++++++++++++++++++++++++ gdb/tui/tui.c | 10 ++++++---- 4 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 gdb/testsuite/gdb.tui/tui-layout-asm.exp diff --git a/gdb/testsuite/gdb.tui/tui-layout-asm.exp b/gdb/testsuite/gdb.tui/tui-layout-asm.exp new file mode 100644 index 00000000000..cec2735764e --- /dev/null +++ b/gdb/testsuite/gdb.tui/tui-layout-asm.exp @@ -0,0 +1,34 @@ +# Copyright 2020 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Ensure that 'layout asm' before starting the inferior puts us in the +# asm layout and displays the disassembly for main. + +load_lib "tuiterm.exp" + +standard_testfile tui-layout.c + +if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} { + return -1 +} + +Term::clean_restart 24 80 $testfile +if {![Term::prepare_for_tui]} { + unsupported "TUI not supported" +} + +# This puts us into TUI mode, and should display the ASM window. +Term::command "layout asm" +Term::check_box_contents "check asm box contents" 0 0 80 15 "
" diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c index 7ff5825ece2..99d30a55a15 100644 --- a/gdb/tui/tui.c +++ b/gdb/tui/tui.c @@ -489,10 +489,6 @@ tui_enable (void) clearok (stdscr, TRUE); } - /* Install the TUI specific hooks. */ - tui_install_hooks (); - rl_startup_hook = tui_rl_startup_hook; - if (tui_update_variables ()) tui_rehighlight_all (); @@ -513,6 +509,12 @@ tui_enable (void) else tui_display_main (); + /* Install the TUI specific hooks. This must be done after the call to + tui_display_main so that we don't detect the symtab changed event it + can cause. */ + tui_install_hooks (); + rl_startup_hook = tui_rl_startup_hook; + /* Restore TUI keymap. */ tui_set_key_mode (tui_current_key_mode);