diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp
index 429c40d..8a59938 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -38,6 +38,7 @@
 #include "qdiriterator.h"
 #include "qset.h"
 #include <QtCore/qdebug.h>
+#include <algorithm>
 
 #ifndef QT_NO_FSFILEENGINE
 
@@ -432,10 +433,13 @@ bool QFSFileEnginePrivate::flushFh()
 
     // Never try to flush again if the last flush failed. Otherwise you can
     // get crashes on some systems (AIX).
-    if (lastFlushFailed)
+    if (lastFlushFailed) {
+        qDebug() << __FUNCTION__ << "lastFlushFailed";
         return false;
+    }
 
     int ret = fflush(fh);
+    qDebug() << __FUNCTION__ << "fflush rets" << ret;
 
     lastFlushFailed = (ret != 0);
     lastIOCommand = QFSFileEnginePrivate::IOFlushCommand;
@@ -510,6 +514,7 @@ qint64 QFSFileEnginePrivate::posFdFh() const
 */
 bool QFSFileEngine::seek(qint64 pos)
 {
+    qDebug() << __FUNCTION__ << pos;
     Q_D(QFSFileEngine);
     return d->nativeSeek(pos);
 }
@@ -519,6 +524,7 @@ bool QFSFileEngine::seek(qint64 pos)
 */
 bool QFSFileEnginePrivate::seekFdFh(qint64 pos)
 {
+    qDebug() << __FUNCTION__ << pos;
     Q_Q(QFSFileEngine);
 
     // On Windows' stdlib implementation, the results of calling fread and
@@ -566,13 +572,16 @@ int QFSFileEngine::handle() const
 */
 qint64 QFSFileEngine::read(char *data, qint64 maxlen)
 {
+
     Q_D(QFSFileEngine);
+    qDebug() << __FUNCTION__ << d->fileEntry.fileName() << "1) maxlen=" << maxlen;
 
     // On Windows' stdlib implementation, the results of calling fread and
     // fwrite are undefined if not called either in sequence, or if preceded
     // with a call to fflush().
     if (d->lastIOCommand != QFSFileEnginePrivate::IOReadCommand) {
         flush();
+        qDebug() << __FUNCTION__ << d->fileEntry.fileName() <<  "flush";
         d->lastIOCommand = QFSFileEnginePrivate::IOReadCommand;
     }
 
@@ -584,6 +593,7 @@ qint64 QFSFileEngine::read(char *data, qint64 maxlen)
 */
 qint64 QFSFileEnginePrivate::readFdFh(char *data, qint64 len)
 {
+     qDebug() << __FUNCTION__ << "len=" << len;
     Q_Q(QFSFileEngine);
 
     if (len < 0 || len != qint64(size_t(len))) {
@@ -600,7 +610,11 @@ qint64 QFSFileEnginePrivate::readFdFh(char *data, qint64 len)
         size_t result;
         bool retry = true;
         do {
-            result = fread(data + readBytes, 1, size_t(len - readBytes), fh);
+            char *dStart = data + readBytes;
+            result = fread(dStart, 1, size_t(len - readBytes), fh);
+            qDebug() << __FUNCTION__ << "fread(" << (void *)(dStart)
+                     <<  size_t(len - readBytes) << ")->" << result;
+
             eof = feof(fh);
             if (retry && eof && result == 0) {
                 // On OS X, this is needed, e.g., if a file was written to
@@ -611,6 +625,10 @@ qint64 QFSFileEnginePrivate::readFdFh(char *data, qint64 len)
                 continue;
             }
             readBytes += result;
+            qDebug() << __FUNCTION__ << "len=" << len << "result=" << result
+                     << "readBytes=" << readBytes << "eof=" << eof
+                     << "NL=" << std::count(dStart, dStart + result, '\n');
+
         } while (!eof && (result == 0 ? errno == EINTR : readBytes < len));
 
     } else if (fd != -1) {
@@ -644,6 +662,7 @@ qint64 QFSFileEnginePrivate::readFdFh(char *data, qint64 len)
 */
 qint64 QFSFileEngine::readLine(char *data, qint64 maxlen)
 {
+    qDebug() << __FUNCTION__ << "maxlen=" << maxlen;
     Q_D(QFSFileEngine);
 
     // On Windows' stdlib implementation, the results of calling fread and
@@ -662,6 +681,7 @@ qint64 QFSFileEngine::readLine(char *data, qint64 maxlen)
 */
 qint64 QFSFileEnginePrivate::readLineFdFh(char *data, qint64 maxlen)
 {
+    qDebug() << __FUNCTION__ << "maxlen=" << maxlen;
     Q_Q(QFSFileEngine);
     if (!fh)
         return q->QAbstractFileEngine::readLine(data, maxlen);
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index cfd5095..7e496c4 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -345,6 +345,7 @@ bool QFSFileEnginePrivate::nativeSeek(qint64 pos)
 */
 qint64 QFSFileEnginePrivate::nativeRead(char *data, qint64 maxlen)
 {
+    qDebug() << __FUNCTION__ << fileEntry.fileName() << "maxlen=" << maxlen;
     Q_Q(QFSFileEngine);
 
     if (fh || fd != -1) {
@@ -356,6 +357,7 @@ qint64 QFSFileEnginePrivate::nativeRead(char *data, qint64 maxlen)
 
         return readFdFh(data, maxlen);
     }
+    qDebug() << __FUNCTION__ << fileEntry.fileName()  << "NATIVE MODE";
 
     // Windows native mode.
     if (fileHandle == INVALID_HANDLE_VALUE)
diff --git a/tests/auto/corelib/io/qprocess/fileWriterProcess/main.cpp b/tests/auto/corelib/io/qprocess/fileWriterProcess/main.cpp
index 411c7e3..bc1b17a 100644
--- a/tests/auto/corelib/io/qprocess/fileWriterProcess/main.cpp
+++ b/tests/auto/corelib/io/qprocess/fileWriterProcess/main.cpp
@@ -32,6 +32,7 @@
 ****************************************************************************/
 #include <QCoreApplication>
 #include <QFile>
+#include <QDebug>
 
 int main(int argc, char **argv)
 {
@@ -41,8 +42,14 @@ int main(int argc, char **argv)
     QString input;
     char buf[1024];
     qint64 len;
-    while ((len = f.read(buf, 1024)) > 0)
-        input += QByteArray(buf, len);
+    int l=0;
+    while ((len = f.read(buf, 1024)) > 0) {
+        QByteArray b(buf, len);
+        input += b;
+        qDebug() << __FUNCTION__ << l ++ << "len=" << len << "\\n" << b.count('\n')
+                 << "\\r" << b.count('\r')  ;
+    }
+    qDebug() << __FUNCTION__ << "read" << input.size();
     f.close();
     QFile f2("fileWriterProcess.txt");
     f2.open(QIODevice::WriteOnly | QIODevice::Truncate);
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index 2b8f2ae..428a496 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -2110,6 +2110,8 @@ void tst_QProcess::fileWriterProcess()
             QVERIFY(process.waitForBytesWritten(2000));
         }
         QVERIFY(process.waitForFinished());
+        qDebug().noquote() << '\n' << process.exitStatus() << process.exitCode()
+                       << process.readAllStandardError();
         QCOMPARE(QFile("fileWriterProcess.txt").size(), qint64(stdinStr.size()));
     } while (stopWatch.elapsed() < 3000);
 }
