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