aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.tui
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2023-05-16 17:40:32 +0200
committerTom de Vries <tdevries@suse.de>2023-05-16 17:40:32 +0200
commit68b25a74aa492fa84bc530b471036d762cf772bf (patch)
treee7697277818fbe8e475cc324f55afcd5b6fc5a77 /gdb/testsuite/gdb.tui
parentd1792f72bf92ac06be7a4785567e2c7bf78c0496 (diff)
downloadbinutils-68b25a74aa492fa84bc530b471036d762cf772bf.zip
binutils-68b25a74aa492fa84bc530b471036d762cf772bf.tar.gz
binutils-68b25a74aa492fa84bc530b471036d762cf772bf.tar.bz2
[gdb/tui] Don't show line number for lines not in source file
Currently, for a source file containing only 5 lines, we also show line numbers 6 and 7 if they're in scope of the source window: ... 0 +-compact-source.c----------------+ 1 |___3_{ | 2 |___4_ return 0; | 3 |___5_} | 4 |___6_ | 5 |___7_ | 6 +---------------------------------+ ... Fix this by not showing line numbers not in a source file, such that we have instead: ... 0 +-compact-source.c----------------+ 1 |___3_{ | 2 |___4_ return 0; | 3 |___5_} | 4 | | 5 | | 6 +---------------------------------+ ... Tested on x86_64-linux. Suggested-By: Simon Marchi <simon.marchi@efficios.com> Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/testsuite/gdb.tui')
-rw-r--r--gdb/testsuite/gdb.tui/compact-source.exp28
1 files changed, 12 insertions, 16 deletions
diff --git a/gdb/testsuite/gdb.tui/compact-source.exp b/gdb/testsuite/gdb.tui/compact-source.exp
index f972d96..e9703b3 100644
--- a/gdb/testsuite/gdb.tui/compact-source.exp
+++ b/gdb/testsuite/gdb.tui/compact-source.exp
@@ -53,22 +53,18 @@ if {![Term::enter_tui]} {
set re_border "\\|"
-foreach_with_prefix src_window_size {7 8} {
- set src_window_lines [expr $src_window_size - 2]
- set max_line_nr_in_source_file [llength $src_list]
- set max_line_nr_in_source_window \
- [expr $max_line_nr_in_source_file + $src_window_lines - 1]
+set max_line_nr_in_source_file [llength $src_list]
+# Ensure there are more lines in the window than in the source file.
+set src_window_lines [expr $max_line_nr_in_source_file + 2]
+# Account for border size.
+set src_window_size [expr $src_window_lines + 2]
+Term::command "wh src $src_window_size"
- Term::command "wh src $src_window_size"
+set re_left_margin "___4_"
- if { $max_line_nr_in_source_window == 9 } {
- set re_left_margin "___4_"
- } elseif { $max_line_nr_in_source_window == 10 } {
- set re_left_margin "___04_"
- } else {
- error "unhandled max_line_nr_in_source_window"
- }
+Term::check_contents "compact source format" \
+ "$re_border$re_left_margin$re_line_four *$re_border"
- Term::check_contents "compact source format" \
- "$re_border$re_left_margin$re_line_four *$re_border"
-}
+set re_left_margin "___0*[expr $max_line_nr_in_source_file + 1]_"
+Term::check_contents_not "no surplus line number" \
+ "$re_border$re_left_margin *$re_border"