|
| 1 | +# Copyright (C) 2023-2024 Free Software Foundation, Inc. |
| 2 | + |
| 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. |
| 7 | +# |
| 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. |
| 12 | +# |
| 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/>. |
| 15 | + |
| 16 | +# This file is part of the GDB testsuite. It tests a corner case |
| 17 | +# where the executed GDB command enables the stdin while running |
| 18 | +# inside a synchronous command, causing the GDB prompt to be displayed |
| 19 | +# prematurely. |
| 20 | + |
| 21 | +load_lib gdb-python.exp |
| 22 | +load_lib gdbserver-support.exp |
| 23 | + |
| 24 | +# We use the start command. |
| 25 | +require !use_gdb_stub |
| 26 | +require allow_python_tests allow_gdbserver_tests |
| 27 | + |
| 28 | +standard_testfile |
| 29 | + |
| 30 | +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { |
| 31 | + return -1 |
| 32 | +} |
| 33 | + |
| 34 | +set bp_line [gdb_get_line_number "break-here"] |
| 35 | +gdb_breakpoint $bp_line |
| 36 | + |
| 37 | +set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py] |
| 38 | +gdb_test_no_output "source $pyfile" "source the script" |
| 39 | + |
| 40 | +set gdbserver [gdbserver_start "" [standard_output_file $binfile]] |
| 41 | +set gdbserver_gdbport [lindex $gdbserver 1] |
| 42 | +gdb_test_no_output "python the_listener.port = '${gdbserver_gdbport}'" |
| 43 | + |
| 44 | +gdb_run_cmd |
| 45 | + |
| 46 | +gdb_test_multiple "" "prompt is positioned correctly" { |
| 47 | + -re -wrap "break-here \[^\r\n\]+" { |
| 48 | + pass $gdb_test_name |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +# Clean up the gdbserver. |
| 53 | +gdb_test "inferior 2" "Switching to inferior 2.*" \ |
| 54 | + "switch to gdbserver for clean up" |
| 55 | +gdbserver_exit 0 |
0 commit comments