Add translations for various sub-directories
[binutils-gdb.git] / gdb / testsuite / gdb.tui / tui-layout-asm.exp
blob91566ca51af7290e502692aa66a34cae9c79b840
1 # Copyright 2020-2024 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Ensure that 'layout asm' before starting the inferior puts us in the
17 # asm layout and displays the disassembly for main.
19 tuiterm_env
21 standard_testfile tui-layout.c
23 if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} {
24     return -1
27 # PPC currently needs a minimum window width of 90 to work correctly.
28 set tui_asm_window_width 90
30 Term::clean_restart 24 ${tui_asm_window_width} $testfile
31 if {![Term::prepare_for_tui]} {
32     unsupported "TUI not supported"
33     return
36 # Helper proc, returns a count of the ' ' characters in STRING.
37 proc count_whitespace { string } {
38     return [expr {[llength [split $string { }]] - 1}]
41 # This puts us into TUI mode, and should display the ASM window.
42 Term::command_no_prompt_prefix "layout asm"
43 Term::check_box_contents "check asm box contents" 0 0 ${tui_asm_window_width} 15 "<main>"
45 # Scroll the ASM window down using the down arrow key.  In an ideal
46 # world we'd like to use PageDown here, but currently our terminal
47 # library doesn't support such advanced things.
48 set testname "scroll to end of assembler"
49 set down_count 0
50 while (1) {
51     # Grab the second line, this is about to become the first line.
52     set line [Term::get_line 2]
54     # Except, if the second line is blank then we are at the end of
55     # the available asm output.  Pressing down again _shouldn't_
56     # change the output, however, if GDB is working, and we press down
57     # then the screen won't change, so the call to Term::wait_for
58     # below will just timeout.  So for now we avoid testing the edge
59     # case.
60     if {[regexp -- "^\\| +\\|$" $line]} {
61         # Second line is blank, we're at the end of the assembler.
62         pass $testname
63         break
64     }
66     # Send the down key to GDB.
67     send_gdb "\033\[B"
68     incr down_count
69     set re_line [string_to_regexp $line]
70     # Ignore whitespace mismatches.
71     regsub -all {\s+} $re_line {\s+} re_line
72     if {[Term::wait_for $re_line] \
73             && [regexp $re_line [Term::get_line 1]]} {
74         # We scrolled successfully.
75     } else {
76         if {[count_whitespace ${line}] != \
77                 [count_whitespace [Term::get_line 1]]} {
78             # GDB's TUI assembler display will widen columns based on
79             # the longest item that appears in a column on any line.
80             # As we have just scrolled, and so revealed a new line, it
81             # is possible that the width of some columns has changed.
82             #
83             # As a result it is possible that part of the line we were
84             # expected to see in the output is now off the screen. And
85             # this test will fail.
86             #
87             # This is unfortunate, but, right now, there's no easy way
88             # to "lock" the format of the TUI assembler window.  The
89             # only option appears to be making the window width wider,
90             # this can be done by adjusting TUI_ASM_WINDOW_WIDTH.
91             verbose -log "WARNING: The following failure is probably due to the TUI window"
92             verbose -log "         width.  See the comments in the test script for more"
93             verbose -log "         details."
94         }
96         fail "$testname (scroll failed)"
97         Term::dump_screen
98         break
99     }
101     if { $down_count > 250 } {
102         # Maybe we should accept this as a pass in case a target
103         # really does have loads of assembler to scroll through.
104         fail "$testname (too much assembler)"
105         Term::dump_screen
106         break
107     }