forked from qt-creator/qt-creator
Clang: Shorten debug output
...by writing unsaved file content and project part arguments to temporary dirs. Change-Id: Ic411700cb3da756788bbb315851ff38b0100fe71 Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
This commit is contained in:
@@ -36,7 +36,8 @@ SOURCES += $$PWD/ipcserverinterface.cpp \
|
|||||||
$$PWD/codecompletionchunk.cpp \
|
$$PWD/codecompletionchunk.cpp \
|
||||||
$$PWD/projectpartcontainer.cpp \
|
$$PWD/projectpartcontainer.cpp \
|
||||||
$$PWD/projectpartsdonotexistcommand.cpp \
|
$$PWD/projectpartsdonotexistcommand.cpp \
|
||||||
$$PWD/lineprefixer.cpp
|
$$PWD/lineprefixer.cpp \
|
||||||
|
$$PWD/clangbackendipcdebugutils.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/ipcserverinterface.h \
|
$$PWD/ipcserverinterface.h \
|
||||||
@@ -67,6 +68,7 @@ HEADERS += \
|
|||||||
$$PWD/projectpartsdonotexistcommand.h \
|
$$PWD/projectpartsdonotexistcommand.h \
|
||||||
$$PWD/container_common.h \
|
$$PWD/container_common.h \
|
||||||
$$PWD/clangbackendipc_global.h \
|
$$PWD/clangbackendipc_global.h \
|
||||||
$$PWD/lineprefixer.h
|
$$PWD/lineprefixer.h \
|
||||||
|
$$PWD/clangbackendipcdebugutils.h
|
||||||
|
|
||||||
contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
|
contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
|
||||||
|
|||||||
99
src/libs/clangbackendipc/clangbackendipcdebugutils.cpp
Normal file
99
src/libs/clangbackendipc/clangbackendipcdebugutils.cpp
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "clangbackendipcdebugutils.h"
|
||||||
|
|
||||||
|
#include "filecontainer.h"
|
||||||
|
|
||||||
|
#include <utf8string.h>
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
#include <QString>
|
||||||
|
#include <QTemporaryDir>
|
||||||
|
#include <QTemporaryFile>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class DebugInspectionDir : public QTemporaryDir
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DebugInspectionDir()
|
||||||
|
: QTemporaryDir(QDir::tempPath() + QLatin1String("/qtc-clangbackendipc-XXXXXX"))
|
||||||
|
{
|
||||||
|
setAutoRemove(false); // Keep around for later inspection.
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class DebugInspectionFile : public QTemporaryFile
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DebugInspectionFile(const QString &directoryPath,
|
||||||
|
const Utf8String &id,
|
||||||
|
const Utf8String &fileContent)
|
||||||
|
: QTemporaryFile(directoryPath + QString::fromUtf8("/%1-XXXXXX").arg(id.toString()))
|
||||||
|
{
|
||||||
|
setAutoRemove(false); // Keep around for later inspection.
|
||||||
|
m_isValid = open() && write(fileContent.constData(), fileContent.byteSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isValid() const
|
||||||
|
{
|
||||||
|
return m_isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_isValid = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace ClangBackEnd {
|
||||||
|
|
||||||
|
Utf8String debugWriteFileForInspection(const Utf8String &fileContent, const Utf8String &id)
|
||||||
|
{
|
||||||
|
static DebugInspectionDir debugInspectionDir;
|
||||||
|
if (!debugInspectionDir.isValid())
|
||||||
|
return Utf8String();
|
||||||
|
|
||||||
|
DebugInspectionFile file(debugInspectionDir.path(), id, fileContent);
|
||||||
|
if (file.isValid())
|
||||||
|
return Utf8String::fromString(file.fileName());
|
||||||
|
return Utf8String();
|
||||||
|
}
|
||||||
|
|
||||||
|
Utf8String debugId(const FileContainer &fileContainer)
|
||||||
|
{
|
||||||
|
const Utf8String filePath = fileContainer.filePath();
|
||||||
|
Utf8String id(Utf8StringLiteral("unsavedfilecontent-"));
|
||||||
|
id.append(QFileInfo(filePath).fileName());
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ClangBackEnd
|
||||||
44
src/libs/clangbackendipc/clangbackendipcdebugutils.h
Normal file
44
src/libs/clangbackendipc/clangbackendipcdebugutils.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CLANGBACKENDIPCDEBUGUTILS_H
|
||||||
|
#define CLANGBACKENDIPCDEBUGUTILS_H
|
||||||
|
|
||||||
|
class FileContainer;
|
||||||
|
class Utf8String;
|
||||||
|
|
||||||
|
namespace ClangBackEnd {
|
||||||
|
|
||||||
|
Utf8String debugWriteFileForInspection(const Utf8String &fileContent, const Utf8String &id);
|
||||||
|
Utf8String debugId(const FileContainer &fileContainer);
|
||||||
|
|
||||||
|
} // namespace ClangBackEnd
|
||||||
|
|
||||||
|
#endif // CLANGBACKENDIPCDEBUGUTILS_H
|
||||||
@@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
#include "filecontainer.h"
|
#include "filecontainer.h"
|
||||||
|
|
||||||
|
#include "clangbackendipcdebugutils.h"
|
||||||
|
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
@@ -108,9 +110,13 @@ QDebug operator<<(QDebug debug, const FileContainer &container)
|
|||||||
<< ", "
|
<< ", "
|
||||||
<< container.projectPartId();
|
<< container.projectPartId();
|
||||||
|
|
||||||
if (container.hasUnsavedFileContent())
|
if (container.hasUnsavedFileContent()) {
|
||||||
|
const Utf8String fileWithContent = debugWriteFileForInspection(
|
||||||
|
container.unsavedFileContent(),
|
||||||
|
debugId(container));
|
||||||
debug.nospace() << ", "
|
debug.nospace() << ", "
|
||||||
<< container.unsavedFileContent();
|
<< "<" << fileWithContent << ">";
|
||||||
|
}
|
||||||
|
|
||||||
debug.nospace() << ")";
|
debug.nospace() << ")";
|
||||||
|
|
||||||
|
|||||||
@@ -30,9 +30,10 @@
|
|||||||
|
|
||||||
#include "projectpartcontainer.h"
|
#include "projectpartcontainer.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include "clangbackendipcdebugutils.h"
|
||||||
|
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
@@ -91,10 +92,15 @@ static Utf8String quotedArguments(const Utf8StringVector &arguments)
|
|||||||
|
|
||||||
QDebug operator<<(QDebug debug, const ProjectPartContainer &container)
|
QDebug operator<<(QDebug debug, const ProjectPartContainer &container)
|
||||||
{
|
{
|
||||||
|
const Utf8String arguments = quotedArguments(container.arguments());
|
||||||
|
const Utf8String fileWithArguments = debugWriteFileForInspection(
|
||||||
|
arguments,
|
||||||
|
Utf8StringLiteral("projectpartargs-"));
|
||||||
|
|
||||||
debug.nospace() << "ProjectPartContainer("
|
debug.nospace() << "ProjectPartContainer("
|
||||||
<< container.projectPartId()
|
<< container.projectPartId()
|
||||||
<< ","
|
<< ","
|
||||||
<< quotedArguments(container.arguments())
|
<< "<" << fileWithArguments << ">"
|
||||||
<< ")";
|
<< ")";
|
||||||
|
|
||||||
return debug;
|
return debug;
|
||||||
|
|||||||
Reference in New Issue
Block a user