Fix null pointer dereference in process_debug_info()
[binutils-gdb.git] / gdb / testsuite / gdb.tui / compact-source.exp
blob79c8c853722caa1b83bb758ec0a9f852a353b1b3
1 # Copyright 2023-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 # Check that "set tui compact-source on" has the intended effect.
18 require allow_tui_tests
20 tuiterm_env
22 standard_testfile
24 # Let's generate the source file. We want a short file, with less than 10
25 # lines, and the copyright notice by itself is already more that that.
26 set src_list \
27 [list \
28 "int" \
29 "main (void)" \
30 "{" \
31 " return 0;" \
32 "}"]
33 set re_line_four [string_to_regexp [lindex $src_list 3]]
34 set src_txt [join $src_list "\n"]
35 set srcfile [standard_output_file $srcfile]
36 set fd [open $srcfile w]
37 puts $fd $src_txt
38 close $fd
40 if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} {
41 return -1
44 Term::clean_restart 24 80 $binfile
46 gdb_test_no_output "maint set tui-left-margin-verbose on"
47 gdb_test_no_output "set tui compact-source on"
49 if {![Term::enter_tui]} {
50 unsupported "TUI not supported"
51 return
54 set re_border "\\|"
56 set max_line_nr_in_source_file [llength $src_list]
57 # Ensure there are more lines in the window than in the source file.
58 set src_window_lines [expr $max_line_nr_in_source_file + 2]
59 # Account for border size.
60 set src_window_size [expr $src_window_lines + 2]
61 Term::command "wh src $src_window_size"
63 set re_left_margin "___4_"
65 Term::check_contents "compact source format" \
66 "$re_border$re_left_margin$re_line_four *$re_border"
68 set re_left_margin "___0*[expr $max_line_nr_in_source_file + 1]_"
69 Term::check_contents_not "no surplus line number" \
70 "$re_border$re_left_margin *$re_border"