1# Copyright 2017-2023 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# When debugging with "target remote |", the inferior's output is 17# connected to a pipe, and if GDB doesn't flush the pipe while the 18# inferior is running and the pipe becomes full, then the inferior 19# deadlocks: 20# 21# 1. User sets breakpoint, and types "continue" 22# 23# 2. Inferior prints to stdout/stderr before reaching breakpoint 24# location. 25# 26# 3. The output pipe becomes full, so the inferior blocks forever in 27# the printf/write call. 28# 29# 4. The breakpoint is never reached. 30 31if [target_info exists gdb,noinferiorio] { 32 verbose "Skipping because of noinferiorio." 33 return 34} 35 36standard_testfile 37 38if [prepare_for_testing "failed to prepare" $testfile {} {debug}] { 39 return -1 40} 41 42if {![runto_main]} { 43 return 44} 45 46set printing_done_line [gdb_get_line_number "printing done"] 47gdb_test "break $printing_done_line" ".*" "set breakpoint after printing" 48 49send_gdb "continue\n" 50 51set expected_lines 3000 52set more 1 53set i 0 54while {$more} { 55 set more 0 56 gdb_expect { 57 -i $inferior_spawn_id 58 -ex "this is line number $i" { 59 incr i 60 if {$i != $expected_lines} { 61 set more 1 62 } 63 } 64 } 65} 66 67gdb_assert {$i == $expected_lines} "saw all lines" 68 69set test "breakpoint reached" 70gdb_test_multiple "" $test { 71 -re "Breakpoint .* main .*$srcfile:$printing_done_line.*$gdb_prompt $" { 72 pass $test 73 } 74} 75