aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/command-line-input.exp
blob: 9760f1a3974cc2dd3be5c3f65f3a047f17de9da3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Copyright (C) 2016-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Command line input testing.

# Test issuing a command split in multiple lines with continuation
# characters.

clean_restart

set bs "\\"
set re_bs [string_to_regexp $bs]
set re_dollar [string_to_regexp $]

set re \
    [multi_line \
	 ^[string_to_regexp "print 1$bs"] \
	 [string_to_regexp " + 2"] \
	 "$re_dollar$decimal = 3" \
	 "$gdb_prompt $"]
gdb_test_multiple "print 1$bs\n + 2" "print 1$bs${bs}n + 2" {
    -re $re {
	pass $gdb_test_name
    }
}

set re \
    [multi_line \
	 ^[string_to_regexp "print 1$bs"] \
	 "2" \
	 "$re_dollar$decimal = 12" \
	 "$gdb_prompt $"]
gdb_test_multiple "print 1$bs\n2" "print 1$bs${bs}n2" {
    -re $re {
	pass $gdb_test_name
    }
}

with_test_prefix "cancel multiline" {
    send_gdb "print$bs\n 1"
    gdb_test_multiple "" "setup" {
	-re "print$re_bs\r\n 1" {
	    pass $gdb_test_name
	}
    }

    send_gdb "\003"
    gdb_test_multiple "" "cancel" {
	-re -wrap "" {
	    pass $gdb_test_name
	}
    }

    # Regression test for PR cli/33063.
    gdb_test_multiple "print 2" "command after cancel" {
	-re -wrap " = 2" {
	    pass $gdb_test_name
	}
	-re -wrap "" {
	    # Avoid undefined command error.
	    fail $gdb_test_name
	}
    }
}