forked from qt-creator/qt-creator
Utils: Add logging category to SynchronousProcess
This helps to debug e.g. runGcc(), which is used for detecting predefined macros or header paths for the code model. The log gives also a (limited) overview of the (blocking) processes that are run on Qt Creator start up. The produced command line is copy-pastable. The generated output looks like this: qtc.utils.synchronousprocess: Starting blocking: /usr/bin/x86_64-linux-gnu-gcc-8 -dumpmachine qtc.utils.synchronousprocess: SynchronousProcessResponse: result=0 ex=0 17 bytes stdout, stderr="" qtc.utils.synchronousprocess: Starting blocking: /usr/lib/icecc/bin/clang++ -x c++ -E -dM - qtc.utils.synchronousprocess: SynchronousProcessResponse: result=1 ex=115 0 bytes stdout, stderr="ICECC[9867] 2019-07-03 13:00:35: couldn't find any clang++\nICECC[9867] 2019-07-03 13:00:35: could not find clang++ in PATH.\n" "The command \"/usr/lib/icecc/bin/clang++\" terminated with exit code 115." Change-Id: I9bc7b24121801b0c98c52416848734d850aa9f4d Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -24,15 +24,18 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "synchronousprocess.h"
|
||||
#include "qtcassert.h"
|
||||
#include "executeondestruction.h"
|
||||
#include "hostosinfo.h"
|
||||
#include "qtcassert.h"
|
||||
#include "qtcprocess.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
#include <QTextCodec>
|
||||
#include <QDir>
|
||||
#include <QLoggingCategory>
|
||||
#include <QMessageBox>
|
||||
#include <QTextCodec>
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
@@ -81,6 +84,8 @@ enum { defaultMaxHangTimerCount = 10 };
|
||||
|
||||
namespace Utils {
|
||||
|
||||
Q_LOGGING_CATEGORY(processLog, "qtc.utils.synchronousprocess", QtWarningMsg);
|
||||
|
||||
// A special QProcess derivative allowing for terminal control.
|
||||
class TerminalControllingProcess : public QProcess {
|
||||
public:
|
||||
@@ -445,8 +450,11 @@ SynchronousProcessResponse SynchronousProcess::run(const QString &binary,
|
||||
const QStringList &args,
|
||||
const QByteArray &writeData)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << '>' << Q_FUNC_INFO << binary << args;
|
||||
qCDebug(processLog).noquote() << "Starting:"
|
||||
<< QtcProcess::joinArgs(QStringList(binary) + args);
|
||||
ExecuteOnDestruction logResult([this] {
|
||||
qCDebug(processLog) << d->m_result;
|
||||
});
|
||||
|
||||
d->clearForRun();
|
||||
|
||||
@@ -492,13 +500,17 @@ SynchronousProcessResponse SynchronousProcess::run(const QString &binary,
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
if (debug)
|
||||
qDebug() << '<' << Q_FUNC_INFO << binary << d->m_result;
|
||||
return d->m_result;
|
||||
}
|
||||
|
||||
SynchronousProcessResponse SynchronousProcess::runBlocking(const QString &binary, const QStringList &args)
|
||||
{
|
||||
qCDebug(processLog).noquote() << "Starting blocking:"
|
||||
<< QtcProcess::joinArgs(QStringList(binary) + args);
|
||||
ExecuteOnDestruction logResult([this] {
|
||||
qCDebug(processLog) << d->m_result;
|
||||
});
|
||||
|
||||
d->clearForRun();
|
||||
|
||||
// On Windows, start failure is triggered immediately if the
|
||||
|
Reference in New Issue
Block a user