I ran into this FAIL: ... FAIL: gdb.base/info-types-c.exp: info types (state == 1) ... It was not 100% reproducible, due to gdb printing speed and matching order. And it was not one of the cases caught by check-read1, instead, check-read1 made it pass reliably. Which made me wonder, can we make the opposite: make something similar to read1, but instead of forcing read to return 1 byte at the a time, try to make read more patient and try to read a bit more. I gave it a try: ... $ git diff diff --git a/gdb/testsuite/lib/read1.c b/gdb/testsuite/lib/read1.c index 7dabdd4ca0c..960db7933dc 100644 --- a/gdb/testsuite/lib/read1.c +++ b/gdb/testsuite/lib/read1.c @@ -29,6 +29,7 @@ ssize_t read (int fd, void *buf, size_t count) { static ssize_t (*read2) (int fd, void *buf, size_t count) = NULL; + ssize_t res, res2; if (read2 == NULL) { /* Use setenv (v, "", 1) rather than unsetenv (v) to work around @@ -38,7 +39,18 @@ read (int fd, void *buf, size_t count) setenv ("LD_PRELOAD", "", 1); read2 = dlsym (RTLD_NEXT, "read"); } - if (count > 1 && isatty (fd) >= 1) - count = 1; - return read2 (fd, buf, count); + res = read2 (fd, buf, count); + if (isatty (fd) == 0) + return res; + + if (res == count || res == -1) + return res; + + sleep (1); + + res2 = read2 (fd, (char *)buf + res, count - res); + if (res2 == -1) + res2 = 0; + + return res + res2; } ...
Posted RFC: https://sourceware.org/pipermail/gdb-patches/2021-June/179675.html
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=fa9ce2c143ce7ee6bc4f22a0577fe5c0858beddd