Commit 01316c28 authored by Marco Bubke's avatar Marco Bubke
Browse files

Clang: Print message if message is lost



If there is a message counter mismatch it is very helpful to get message
content.

Change-Id: I4ea2526bd4b72010627e99de08ff9a8e64ca3d02
Reviewed-by: default avatarTim Jenssen <tim.jenssen@theqtcompany.com>
parent 04b21947
......@@ -47,7 +47,8 @@ SOURCES += $$PWD/ipcserverinterface.cpp \
$$PWD/updatetranslationunitsforeditormessage.cpp \
$$PWD/updatevisibletranslationunitsmessage.cpp \
$$PWD/highlightingchangedmessage.cpp \
$$PWD/highlightingmarkcontainer.cpp
$$PWD/highlightingmarkcontainer.cpp \
$$PWD/messageenvelop.cpp
HEADERS += \
$$PWD/ipcserverinterface.h \
......
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "messageenvelop.h"
#include "cmbcodecompletedmessage.h"
#include "cmbcompletecodemessage.h"
#include "cmbechomessage.h"
#include "cmbregisterprojectsforeditormessage.h"
#include "cmbregistertranslationunitsforeditormessage.h"
#include "cmbunregisterprojectsforeditormessage.h"
#include "cmbunregistertranslationunitsforeditormessage.h"
#include "diagnosticschangedmessage.h"
#include "highlightingchangedmessage.h"
#include "messageenvelop.h"
#include "messageenvelop.h"
#include "projectpartsdonotexistmessage.h"
#include "registerunsavedfilesforeditormessage.h"
#include "requestdiagnosticsmessage.h"
#include "requesthighlightingmessage.h"
#include "translationunitdoesnotexistmessage.h"
#include "unregisterunsavedfilesforeditormessage.h"
#include "updatetranslationunitsforeditormessage.h"
#include "updatevisibletranslationunitsmessage.h"
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const MessageEnvelop &messageEnvelop)
{
debug.nospace() << "MessageEnvelop(";
switch (messageEnvelop.messageType()) {
case MessageType::EndMessage:
qDebug() << "EndMessage()";
break;
case MessageType::RegisterTranslationUnitForEditorMessage:
qDebug() << messageEnvelop.message<RegisterTranslationUnitForEditorMessage>();
break;
case MessageType::UpdateTranslationUnitsForEditorMessage:
qDebug() << messageEnvelop.message<UpdateTranslationUnitsForEditorMessage>();
break;
case MessageType::UnregisterTranslationUnitsForEditorMessage:
qDebug() << messageEnvelop.message<UnregisterTranslationUnitsForEditorMessage>();
break;
case MessageType::RegisterProjectPartsForEditorMessage:
qDebug() << messageEnvelop.message<RegisterProjectPartsForEditorMessage>();
break;
case MessageType::UnregisterProjectPartsForEditorMessage:
qDebug() << messageEnvelop.message<UnregisterProjectPartsForEditorMessage>();
break;
case MessageType::RegisterUnsavedFilesForEditorMessage:
qDebug() << messageEnvelop.message<RegisterUnsavedFilesForEditorMessage>();
break;
case MessageType::UnregisterUnsavedFilesForEditorMessage:
qDebug() << messageEnvelop.message<UnregisterUnsavedFilesForEditorMessage>();
break;
case MessageType::CompleteCodeMessage:
qDebug() << messageEnvelop.message<CompleteCodeMessage>();
break;
case MessageType::RequestDiagnosticsMessage:
qDebug() << messageEnvelop.message<RequestDiagnosticsMessage>();
break;
case MessageType::RequestHighlightingMessage:
qDebug() << messageEnvelop.message<RequestHighlightingMessage>();
break;
case MessageType::UpdateVisibleTranslationUnitsMessage:
qDebug() << messageEnvelop.message<UpdateVisibleTranslationUnitsMessage>();
break;
case MessageType::AliveMessage:
qDebug() << "AliveMessage()";
break;
case MessageType::EchoMessage:
qDebug() << messageEnvelop.message<EchoMessage>();
break;
case MessageType::CodeCompletedMessage:
qDebug() << messageEnvelop.message<CodeCompletedMessage>();
break;
case MessageType::TranslationUnitDoesNotExistMessage:
qDebug() << messageEnvelop.message<TranslationUnitDoesNotExistMessage>();
break;
case MessageType::ProjectPartsDoNotExistMessage:
qDebug() << messageEnvelop.message<ProjectPartsDoNotExistMessage>();
break;
case MessageType::DiagnosticsChangedMessage:
qDebug() << messageEnvelop.message<DiagnosticsChangedMessage>();
break;
case MessageType::HighlightingChangedMessage:
qDebug() << messageEnvelop.message<HighlightingChangedMessage>();
break;
default:
qWarning() << "Unknown Message";
}
debug.nospace() << ")";
return debug;
}
} // namespace ClangBackEnd
......@@ -29,6 +29,7 @@
#include <QByteArray>
#include <QDataStream>
#include <QDebug>
namespace ClangBackEnd {
......@@ -105,6 +106,8 @@ public:
&& first.data == second.data;
}
friend QDebug operator<<(QDebug debug, const MessageEnvelop &messageEnvelop);
private:
mutable QByteArray data;
MessageType messageType_ = MessageType::InvalidMessage;
......
......@@ -41,19 +41,22 @@ ReadMessageBlock::ReadMessageBlock(QIODevice *ioDevice)
{
}
void ReadMessageBlock::checkIfMessageIsLost(QDataStream &in)
bool ReadMessageBlock::checkIfMessageIsLost(QDataStream &in)
{
qint64 currentMessageCounter;
in >> currentMessageCounter;
bool messageIsLost = false;
#ifndef DONT_CHECK_MESSAGE_COUNTER
bool messageLost = !((currentMessageCounter == 0 && messageCounter == 0) || (messageCounter + 1 == currentMessageCounter));
if (messageLost)
qWarning() << "client message lost: " << messageCounter << currentMessageCounter;
messageIsLost = !((currentMessageCounter == 0 && messageCounter == 0) || (messageCounter + 1 == currentMessageCounter));
if (messageIsLost)
qWarning() << "message lost: " << messageCounter << currentMessageCounter;
#endif
messageCounter = currentMessageCounter;
return messageIsLost;
}
MessageEnvelop ReadMessageBlock::read()
......@@ -63,8 +66,12 @@ MessageEnvelop ReadMessageBlock::read()
MessageEnvelop message;
if (isTheWholeMessageReadable(in)) {
checkIfMessageIsLost(in);
bool messageIsLost = checkIfMessageIsLost(in);
in >> message;
if (messageIsLost)
qDebug() << message;
}
return message;
......
......@@ -48,7 +48,7 @@ public:
private:
bool isTheWholeMessageReadable(QDataStream &in);
void checkIfMessageIsLost(QDataStream &in);
bool checkIfMessageIsLost(QDataStream &in);
private:
QIODevice *ioDevice;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment