1 # Copyright
(C
) 2014-2023 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 # A collection of tests related to pagination resulting from running
17 # execution commands directly from the command line
, with
"-ex".
21 if {[build_executable
"failed to prepare" $testfile $srcfile debug] == -1} {
27 set file_arg
[remote_download host $file_arg
]
31 set saved_gdbflags $GDBFLAGS
33 # Returns true
if the board can
'gdb -ex "start"', false otherwise.
35 proc probe_can_run_cmdline
{} {
36 global srcfile file_arg
37 global saved_gdbflags GDBFLAGS
40 set GDBFLAGS $saved_gdbflags
41 append GDBFLAGS
" -ex \"set height 0\""
42 append GDBFLAGS
" -ex \"start\""
43 append GDBFLAGS
" --args \"$file_arg\""
45 with_test_prefix
"probe support" {
46 set test
"run to main"
56 gdb_test_multiple
"" $test {
57 -re
"main .* at .*$srcfile.*$gdb_prompt $" {
61 -re
"Don't know how to run.*$gdb_prompt $" {
67 # In case the board file wants to send further commands.
68 gdb_test_no_output
"set height unlimited"
73 # Check that we handle pagination correctly when it triggers due to an
74 # execution command entered directly
on the command line.
76 proc test_fg_execution_pagination_return
{} {
78 global saved_gdbflags GDBFLAGS
79 global gdb_prompt pagination_prompt
81 set GDBFLAGS $saved_gdbflags
82 append GDBFLAGS
" -ex \"set height 2\""
83 append GDBFLAGS
" -ex \"start\""
84 append GDBFLAGS
" --args \"$file_arg\""
86 with_test_prefix
"return" {
87 set test
"run to pagination"
95 gdb_test_multiple
"" $test {
96 -re
"$pagination_prompt$" {
106 set saw_pagination_prompt
0
107 set test
"send \\n to GDB"
108 gdb_test_multiple
"" $test {
109 -re
"$pagination_prompt$" {
110 set saw_pagination_prompt
1
114 -re
"$gdb_prompt $" {
115 gdb_assert $saw_pagination_prompt $test
119 gdb_test
"p 1" " = 1" "GDB accepts further input"
121 # In case the board file wants to send further commands.
122 gdb_test_no_output
"set height unlimited"
126 # Check that we handle canceling pagination correctly when it triggers
127 # due to an execution command entered directly
on the command line.
129 proc test_fg_execution_pagination_cancel
{ how
} {
131 global saved_gdbflags GDBFLAGS
132 global gdb_prompt pagination_prompt
134 set GDBFLAGS $saved_gdbflags
136 append GDBFLAGS
" -ex \"set height 2\""
137 append GDBFLAGS
" -ex \"start\""
138 append GDBFLAGS
" --args \"$file_arg\""
140 with_test_prefix
"cancel with $how" {
141 set test
"run to pagination"
149 gdb_test_multiple
"" $test {
150 -re
"$pagination_prompt$" {
155 set test
"cancel pagination"
156 if { $how
== "ctrl-c" } {
162 gdb_test_multiple
"" $test {
163 -re
"Quit\r\n$gdb_prompt $" {
168 gdb_test
"p 1" " = 1" "GDB accepts further input"
170 # In case the board file wants to send further commands.
171 gdb_test_no_output
"set height unlimited"
175 save_vars
{ INTERNAL_GDBFLAGS
} {
176 set INTERNAL_GDBFLAGS
[string map
{"-q" ""} $INTERNAL_GDBFLAGS]
178 if {[probe_can_run_cmdline
] > 0} {
179 test_fg_execution_pagination_return
180 if ![target_info
exists gdb
,nointerrupts
] {
181 test_fg_execution_pagination_cancel
"ctrl-c"
183 test_fg_execution_pagination_cancel
"quit"
187 set GDBFLAGS $saved_gdbflags