mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +08:00
a75868f50b
Comparing test results between --target_board=native-gdbserver --target_board=native-stdio-gdbserver I noticed that gdb.base/bigcore.exp is failing with native-stdio-gdbserver: Running src/gdb/testsuite/gdb.base/bigcore.exp ... FAIL: gdb.base/bigcore.exp: continue (timeout) ... The problem is that: 1. When debugging with "target remote | CMD", the inferior's stdout/stderr streams are connected to a pipe. 2. The bigcore.c program prints a lot to the screen before it reaches the breakpoint location that the "continue" shown above wants to reach. 3. GDB is not flushing the inferior's output pipe while the inferior is running. 4. The pipe becomes full. 5. The inferior thus deadlocks. The bug is #3 above, which is what this commit fixes. A new test is added, that specifically exercises this scenario. The test fails before the fix, and passes after, and gdb.base/bigcore.exp also starts passing. gdb/ChangeLog: 2017-10-19 Pedro Alves <palves@redhat.com> * ser-base.c (ser_base_read_error_fd): Delete the file handler if async. (handle_error_fd): New function. (ser_base_async): Add/delete an event loop file handler for error_fd. gdb/testsuite/ChangeLog: 2017-10-19 Pedro Alves <palves@redhat.com> * gdb.base/long-inferior-output.c: New file. * gdb.base/long-inferior-output.exp: New file.
39 lines
1.3 KiB
C
39 lines
1.3 KiB
C
/* This testcase is part of GDB, the GNU debugger.
|
|
|
|
Copyright 2017 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/>. */
|
|
|
|
#include <stdio.h>
|
|
|
|
static size_t total_bytes = 0;
|
|
|
|
int
|
|
main ()
|
|
{
|
|
int i = 0;
|
|
|
|
/* When testing with "target remote |", stdout is a pipe, and thus
|
|
block buffered by default. Force it to be line buffered. */
|
|
setvbuf (stdout, NULL, _IOLBF, 0);
|
|
|
|
/* This outputs > 70 KB which is larger than the default pipe buffer
|
|
size on most systems (typically 16 KB or 64 KB). */
|
|
for (i = 0; i < 3000; i++)
|
|
total_bytes += printf ("this is line number %d\n", i);
|
|
|
|
printf ("total bytes written = %u\n", (unsigned) total_bytes);
|
|
return 0; /* printing done */
|
|
}
|