public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] gdb/tui: Fix 'layout asm' before the inferior has started
Date: Fri, 10 Jan 2020 03:17:00 -0000	[thread overview]
Message-ID: <b2efe70cf34e2f3ada8d0def69e53f27a6b71578@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT b2efe70cf34e2f3ada8d0def69e53f27a6b71578 ***

commit b2efe70cf34e2f3ada8d0def69e53f27a6b71578
Author:     Andrew Burgess <andrew.burgess@embecosm.com>
AuthorDate: Tue Jan 7 00:41:08 2020 +0000
Commit:     Andrew Burgess <andrew.burgess@embecosm.com>
CommitDate: Thu Jan 9 23:11:45 2020 +0000

    gdb/tui: Fix 'layout asm' before the inferior has started
    
    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

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index fc0656c03d..0ff44e5001 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2020-01-09  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+	* tui/tui.c (tui_enable): Register tui hooks after calling
+	tui_display_main.
+
 2020-01-09  Christian Biesinger  <cbiesinger@google.com>
 
 	* gdbsupport/common-defs.h: Don't define _FORTIFY_SOURCE on MinGW.
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 78880be484..0f2333bc1c 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2020-01-09  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+	* gdb.tui/tui-layout-asm.exp: New file.
+
 2020-01-09  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	* lib/tuiterm.exp (Term::check_box_contents): New proc.
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 0000000000..cec2735764
--- /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 <http://www.gnu.org/licenses/>.
+
+# 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 "<main>"
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index 7ff5825ece..99d30a55a1 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);
 


             reply	other threads:[~2020-01-10  3:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10  3:17 gdb-buildbot [this message]
2020-01-10  3:16 ` Failures on Ubuntu-Aarch64-m64, branch master gdb-buildbot
2020-01-10  3:49 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, " gdb-buildbot
2020-01-10  6:44 ` Failures on Fedora-i686, " gdb-buildbot
2020-01-10  6:56 ` Failures on Fedora-x86_64-cc-with-index, " gdb-buildbot
2020-01-10  7:15 ` Failures on Fedora-x86_64-m64, " gdb-buildbot
2020-01-10  7:26 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2020-01-10  7:37 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot
2020-01-10  7:53 ` Failures on Fedora-x86_64-native-gdbserver-m32, " gdb-buildbot
2020-01-10  7:58 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b2efe70cf34e2f3ada8d0def69e53f27a6b71578@gdb-build \
    --to=gdb-buildbot@sergiodj.net \
    --cc=gdb-testers@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).