From ccab8354551ab1e0b4c79bba66469e32945a750b Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Thu, 19 Sep 2019 11:53:11 +0200 Subject: Debugging: Enable Windows debugging for clang tools On Windows the debugging of clang tools is not working due to the nature of how processes are started. This makes it possible to use DebugViewer or DebugViewPP Change-Id: I2c1e4bb7a8fafd6f07570e5d2ba4df5b44e9d44d Reviewed-by: Tobias Hunger --- src/tools/clangbackend/clangbackendmain.cpp | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'src/tools/clangbackend/clangbackendmain.cpp') diff --git a/src/tools/clangbackend/clangbackendmain.cpp b/src/tools/clangbackend/clangbackendmain.cpp index 1e95db3ef3..76aff06d3b 100644 --- a/src/tools/clangbackend/clangbackendmain.cpp +++ b/src/tools/clangbackend/clangbackendmain.cpp @@ -57,25 +57,11 @@ QString processArguments(QCoreApplication &application) } #ifdef Q_OS_WIN -struct MessageHandler { - MessageHandler(QtMessageHandler handler) - { - defaultHandler = qInstallMessageHandler(handler); - } - - ~MessageHandler() - { - qInstallMessageHandler(defaultHandler); - } - - static QtMessageHandler defaultHandler; -}; - -QtMessageHandler MessageHandler::defaultHandler = nullptr; - -static void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) +extern "C" void OutputDebugStringW(const wchar_t* msg); +static void messageOutput(QtMsgType type, const QMessageLogContext &/*context*/, + const QString &msg) { - MessageHandler::defaultHandler(type, context, msg); + OutputDebugStringW(msg.toStdWString().c_str()); std::wcout << msg.toStdWString() << std::endl; if (type == QtFatalMsg) abort(); @@ -85,7 +71,7 @@ static void messageOutput(QtMsgType type, const QMessageLogContext &context, con int main(int argc, char *argv[]) { #ifdef Q_OS_WIN - MessageHandler messageHandler(&messageOutput); + qInstallMessageHandler(&messageOutput); #endif QCoreApplication::setOrganizationName(QStringLiteral("QtProject")); QCoreApplication::setOrganizationDomain(QStringLiteral("qt-project.org")); -- cgit v1.2.1