1 1.1.1.5 christos # Copyright 2017-2024 Free Software Foundation, Inc. 2 1.1 christos 3 1.1 christos # This program is free software; you can redistribute it and/or modify 4 1.1 christos # it under the terms of the GNU General Public License as published by 5 1.1 christos # the Free Software Foundation; either version 3 of the License, or 6 1.1 christos # (at your option) any later version. 7 1.1 christos # 8 1.1 christos # This program is distributed in the hope that it will be useful, 9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 1.1 christos # GNU General Public License for more details. 12 1.1 christos # 13 1.1 christos # You should have received a copy of the GNU General Public License 14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 1.1 christos 16 1.1 christos # Minimal testcase that just checks that the various "layout $foo" 17 1.1 christos # commands do not cause gdb to crash. 18 1.1 christos 19 1.1.1.5 christos require allow_tui_tests 20 1.1.1.5 christos 21 1.1.1.5 christos tuiterm_env 22 1.1.1.5 christos 23 1.1 christos standard_testfile 24 1.1 christos 25 1.1 christos if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} { 26 1.1 christos return -1 27 1.1 christos } 28 1.1 christos 29 1.1.1.5 christos # Run one test of the 'layout' command, selecting LAYOUT_NAME. 30 1.1.1.5 christos # 31 1.1.1.5 christos # TERMINAL should be either 'dumb' or 'ansi'. When TERMINAL is 'dumb' 32 1.1.1.5 christos # then GDB is started in a terminal that does not support tui mode, in 33 1.1.1.5 christos # this case the layout command is expected to fail. 34 1.1.1.5 christos # 35 1.1.1.5 christos # When TERMINAL is 'ansi' then GDB is started using our emulated ANSI 36 1.1.1.5 christos # terminal, and the layout command is expected to succeed. 37 1.1.1.5 christos # 38 1.1.1.5 christos # When EXECUTION is true then a call to runto_main is used, otherwise 39 1.1.1.5 christos # this call is skipped and the inferior is left in whatever state it 40 1.1.1.5 christos # happens to be in after a call to clean_restart. 41 1.1 christos 42 1.1.1.5 christos proc test_layout_or_focus {layout_name terminal execution} { 43 1.1 christos global binfile gdb_prompt 44 1.1 christos 45 1.1.1.5 christos set dumb_terminal [string equal $terminal "dumb"] 46 1.1.1.5 christos 47 1.1.1.5 christos global env 48 1.1.1.5 christos save_vars { env(TERM) } { 49 1.1.1.5 christos setenv TERM $terminal 50 1.1.1.5 christos if {$dumb_terminal} { 51 1.1.1.5 christos clean_restart $binfile 52 1.1.1.5 christos } else { 53 1.1.1.5 christos Term::clean_restart 24 80 $binfile 54 1.1.1.5 christos if {![Term::prepare_for_tui]} { 55 1.1.1.5 christos unsupported "TUI not supported" 56 1.1.1.5 christos return 57 1.1.1.5 christos } 58 1.1.1.5 christos } 59 1.1.1.5 christos } 60 1.1 christos 61 1.1 christos if {$execution} { 62 1.1.1.4 christos if {![runto_main]} { 63 1.1 christos return 0 64 1.1 christos } 65 1.1 christos } 66 1.1 christos 67 1.1.1.5 christos if {$dumb_terminal} { 68 1.1.1.5 christos if { [is_remote host] } { 69 1.1.1.5 christos # setenv TERM dummy has no effect on remote host. 70 1.1.1.5 christos return 71 1.1.1.5 christos } 72 1.1.1.5 christos gdb_test "layout $layout_name" \ 73 1.1.1.5 christos "Cannot enable the TUI: terminal doesn't support cursor addressing \\\[TERM=dumb\\\]" 74 1.1.1.5 christos } else { 75 1.1.1.5 christos Term::command_no_prompt_prefix "layout $layout_name" 76 1.1.1.5 christos if {$layout_name == "asm"} { 77 1.1.1.5 christos Term::check_box "asm box" 0 0 80 15 78 1.1.1.5 christos } elseif {$layout_name == "reg"} { 79 1.1.1.5 christos Term::check_box "reg box" 0 0 80 8 80 1.1.1.5 christos Term::check_box "src box" 0 7 80 8 81 1.1.1.5 christos } elseif {$layout_name == "src"} { 82 1.1.1.5 christos Term::check_box "src box" 0 0 80 15 83 1.1.1.5 christos } elseif {$layout_name == "split"} { 84 1.1.1.5 christos Term::check_box "src box" 0 0 80 8 85 1.1.1.5 christos Term::check_box "asm box" 0 7 80 8 86 1.1 christos } 87 1.1 christos } 88 1.1 christos } 89 1.1 christos 90 1.1.1.5 christos foreach_with_prefix terminal {ansi dumb} { 91 1.1.1.5 christos foreach_with_prefix execution {false true} { 92 1.1.1.5 christos foreach_with_prefix layout {"asm" "reg" "src" "split"} { 93 1.1.1.5 christos test_layout_or_focus $layout $terminal $execution 94 1.1.1.5 christos } 95 1.1 christos } 96 1.1 christos } 97