1*1424dfb3Schristos# Copyright 2017-2020 Free Software Foundation, Inc. 207163879Schristos 307163879Schristos# This program is free software; you can redistribute it and/or modify 407163879Schristos# it under the terms of the GNU General Public License as published by 507163879Schristos# the Free Software Foundation; either version 3 of the License, or 607163879Schristos# (at your option) any later version. 707163879Schristos# 807163879Schristos# This program is distributed in the hope that it will be useful, 907163879Schristos# but WITHOUT ANY WARRANTY; without even the implied warranty of 1007163879Schristos# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1107163879Schristos# GNU General Public License for more details. 1207163879Schristos# 1307163879Schristos# You should have received a copy of the GNU General Public License 1407163879Schristos# along with this program. If not, see <http://www.gnu.org/licenses/>. 1507163879Schristos 1607163879Schristos# When debugging with "target remote |", the inferior's output is 1707163879Schristos# connected to a pipe, and if GDB doesn't flush the pipe while the 1807163879Schristos# inferior is running and the pipe becomes full, then the inferior 1907163879Schristos# deadlocks: 2007163879Schristos# 2107163879Schristos# 1. User sets breakpoint, and types "continue" 2207163879Schristos# 2307163879Schristos# 2. Inferior prints to stdout/stderr before reaching breakpoint 2407163879Schristos# location. 2507163879Schristos# 2607163879Schristos# 3. The output pipe becomes full, so the inferior blocks forever in 2707163879Schristos# the printf/write call. 2807163879Schristos# 2907163879Schristos# 4. The breakpoint is never reached. 3007163879Schristos 3107163879Schristosif [target_info exists gdb,noinferiorio] { 3207163879Schristos verbose "Skipping because of noinferiorio." 3307163879Schristos return 3407163879Schristos} 3507163879Schristos 3607163879Schristosstandard_testfile 3707163879Schristos 3807163879Schristosif [prepare_for_testing "failed to prepare" $testfile {} {debug}] { 3907163879Schristos return -1 4007163879Schristos} 4107163879Schristos 4207163879Schristosif { ![runto_main] } then { 4307163879Schristos fail "run to main" 4407163879Schristos return 4507163879Schristos} 4607163879Schristos 4707163879Schristosset printing_done_line [gdb_get_line_number "printing done"] 4807163879Schristosgdb_test "break $printing_done_line" ".*" "set breakpoint after printing" 4907163879Schristos 5007163879Schristossend_gdb "continue\n" 5107163879Schristos 5207163879Schristosset expected_lines 3000 5307163879Schristosset more 1 5407163879Schristosset i 0 5507163879Schristoswhile {$more} { 5607163879Schristos set more 0 5707163879Schristos gdb_expect { 5807163879Schristos -i $inferior_spawn_id 5907163879Schristos -ex "this is line number $i" { 6007163879Schristos incr i 6107163879Schristos if {$i != $expected_lines} { 6207163879Schristos set more 1 6307163879Schristos } 6407163879Schristos } 6507163879Schristos } 6607163879Schristos} 6707163879Schristos 6807163879Schristosgdb_assert {$i == $expected_lines} "saw all lines" 6907163879Schristos 7007163879Schristosset test "breakpoint reached" 7107163879Schristosgdb_test_multiple "" $test { 7207163879Schristos -re "Breakpoint .* main .*$srcfile:$printing_done_line.*$gdb_prompt $" { 7307163879Schristos pass $test 7407163879Schristos } 7507163879Schristos} 76