forked from qt-creator/qt-creator
DAP: Add different log category for different dap engines
Change-Id: Ia21926b860f8fee7399c40ad382ff31f360f73ce Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
static Q_LOGGING_CATEGORY(dapEngineLog, "qtc.dbg.dapengine", QtWarningMsg)
|
||||
|
||||
namespace Debugger::Internal {
|
||||
|
||||
@@ -83,7 +82,7 @@ public:
|
||||
: DapClient(provider, parent)
|
||||
{}
|
||||
|
||||
void sendInitialize()
|
||||
void sendInitialize() override
|
||||
{
|
||||
postRequest("initialize",
|
||||
QJsonObject{{"clientID", "QtCreator"},
|
||||
@@ -91,6 +90,13 @@ public:
|
||||
{"adapterID", "cmake"},
|
||||
{"pathFormat", "path"}});
|
||||
}
|
||||
|
||||
private:
|
||||
const QLoggingCategory &logCategory() override {
|
||||
static const QLoggingCategory logCategory = QLoggingCategory("qtc.dbg.dapengine.cmake",
|
||||
QtWarningMsg);
|
||||
return logCategory;
|
||||
}
|
||||
};
|
||||
|
||||
CMakeDapEngine::CMakeDapEngine()
|
||||
@@ -103,9 +109,9 @@ CMakeDapEngine::CMakeDapEngine()
|
||||
|
||||
void CMakeDapEngine::setupEngine()
|
||||
{
|
||||
QTC_ASSERT(state() == EngineSetupRequested, qCDebug(dapEngineLog) << state());
|
||||
QTC_ASSERT(state() == EngineSetupRequested, qCDebug(logCategory()) << state());
|
||||
|
||||
qCDebug(dapEngineLog) << "build system name"
|
||||
qCDebug(logCategory()) << "build system name"
|
||||
<< ProjectExplorer::ProjectTree::currentBuildSystem()->name();
|
||||
|
||||
IDataProvider *dataProvider;
|
||||
|
@@ -22,6 +22,13 @@ private:
|
||||
/* Needed for CMake support issue:25176 */
|
||||
|
||||
bool hasCapability(unsigned cap) const override;
|
||||
|
||||
const QLoggingCategory &logCategory() override
|
||||
{
|
||||
static const QLoggingCategory logCategory = QLoggingCategory("qtc.dbg.dapengine.cmake",
|
||||
QtWarningMsg);
|
||||
return logCategory;
|
||||
}
|
||||
};
|
||||
|
||||
} // Debugger::Internal
|
||||
|
@@ -13,8 +13,6 @@
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
static Q_LOGGING_CATEGORY(dapEngineLog, "qtc.dbg.dapengine", QtWarningMsg);
|
||||
|
||||
namespace Debugger::Internal {
|
||||
|
||||
DapClient::DapClient(IDataProvider *dataProvider, QObject *parent)
|
||||
@@ -51,7 +49,7 @@ void DapClient::postRequest(const QString &command, const QJsonObject &arguments
|
||||
|
||||
const QByteArray data = QJsonDocument(obseq).toJson(QJsonDocument::Compact);
|
||||
const QByteArray msg = "Content-Length: " + QByteArray::number(data.size()) + "\r\n\r\n" + data;
|
||||
qCDebug(dapEngineLog) << msg;
|
||||
qCDebug(logCategory()) << msg;
|
||||
|
||||
m_dataProvider->writeRaw(msg);
|
||||
}
|
||||
@@ -150,7 +148,7 @@ void DapClient::readOutput()
|
||||
{
|
||||
m_inbuffer.append(m_dataProvider->readAllStandardOutput());
|
||||
|
||||
qCDebug(dapEngineLog) << m_inbuffer;
|
||||
qCDebug(logCategory()) << m_inbuffer;
|
||||
|
||||
while (true) {
|
||||
// Something like
|
||||
@@ -190,7 +188,7 @@ void DapClient::emitSignals(const QJsonDocument &doc)
|
||||
const QJsonValue t = ob.value("type");
|
||||
const QString type = t.toString();
|
||||
|
||||
qCDebug(dapEngineLog) << "dap response" << ob;
|
||||
qCDebug(logCategory()) << "dap response" << ob;
|
||||
|
||||
if (type == "response") {
|
||||
DapResponseType type = DapResponseType::Unknown;
|
||||
|
@@ -7,6 +7,8 @@
|
||||
|
||||
#include <utils/process.h>
|
||||
|
||||
#include <QLoggingCategory>
|
||||
|
||||
namespace Debugger::Internal {
|
||||
|
||||
class IDataProvider : public QObject
|
||||
@@ -109,9 +111,14 @@ signals:
|
||||
private:
|
||||
void readOutput();
|
||||
|
||||
private:
|
||||
IDataProvider *m_dataProvider = nullptr;
|
||||
virtual const QLoggingCategory &logCategory()
|
||||
{
|
||||
static const QLoggingCategory logCategory = QLoggingCategory("qtc.dbg.dapengine",
|
||||
QtWarningMsg);
|
||||
return logCategory;
|
||||
}
|
||||
|
||||
IDataProvider *m_dataProvider = nullptr;
|
||||
QByteArray m_inbuffer;
|
||||
};
|
||||
|
||||
|
@@ -61,13 +61,11 @@
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
static Q_LOGGING_CATEGORY(dapEngineLog, "qtc.dbg.dapengine", QtWarningMsg)
|
||||
|
||||
namespace Debugger::Internal {
|
||||
|
||||
void DapEngine::executeDebuggerCommand(const QString &/*command*/)
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorStopOk, qCDebug(dapEngineLog) << state());
|
||||
QTC_ASSERT(state() == InferiorStopOk, qCDebug(logCategory()) << state());
|
||||
// if (state() == DebuggerNotReady) {
|
||||
// showMessage("DAP PROCESS NOT RUNNING, PLAIN CMD IGNORED: " + command);
|
||||
// return;
|
||||
@@ -92,50 +90,50 @@ void DapEngine::runCommand(const DebuggerCommand &cmd)
|
||||
|
||||
void DapEngine::shutdownInferior()
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorShutdownRequested, qCDebug(dapEngineLog) << state());
|
||||
QTC_ASSERT(state() == InferiorShutdownRequested, qCDebug(logCategory()) << state());
|
||||
|
||||
m_dapClient->sendDisconnect();
|
||||
|
||||
qCDebug(dapEngineLog) << "DapEngine::shutdownInferior()";
|
||||
qCDebug(logCategory()) << "DapEngine::shutdownInferior()";
|
||||
notifyInferiorShutdownFinished();
|
||||
}
|
||||
|
||||
void DapEngine::shutdownEngine()
|
||||
{
|
||||
QTC_ASSERT(state() == EngineShutdownRequested, qCDebug(dapEngineLog) << state());
|
||||
QTC_ASSERT(state() == EngineShutdownRequested, qCDebug(logCategory()) << state());
|
||||
|
||||
m_dapClient->sendTerminate();
|
||||
|
||||
qCDebug(dapEngineLog) << "DapEngine::shutdownEngine()";
|
||||
qCDebug(logCategory()) << "DapEngine::shutdownEngine()";
|
||||
m_dapClient->dataProvider()->kill();
|
||||
}
|
||||
|
||||
void DapEngine::handleDapStarted()
|
||||
{
|
||||
notifyEngineSetupOk();
|
||||
QTC_ASSERT(state() == EngineRunRequested, qCDebug(dapEngineLog) << state());
|
||||
QTC_ASSERT(state() == EngineRunRequested, qCDebug(logCategory()) << state());
|
||||
|
||||
m_dapClient->sendInitialize();
|
||||
|
||||
qCDebug(dapEngineLog) << "handleDapStarted";
|
||||
qCDebug(logCategory()) << "handleDapStarted";
|
||||
}
|
||||
|
||||
void DapEngine::handleDapInitialize()
|
||||
{
|
||||
QTC_ASSERT(state() == EngineRunRequested, qCDebug(dapEngineLog) << state());
|
||||
QTC_ASSERT(state() == EngineRunRequested, qCDebug(logCategory()) << state());
|
||||
|
||||
m_dapClient->sendLaunch(runParameters().inferior.command.executable());
|
||||
|
||||
qCDebug(dapEngineLog) << "handleDapLaunch";
|
||||
qCDebug(logCategory()) << "handleDapLaunch";
|
||||
}
|
||||
|
||||
void DapEngine::handleDapEventInitialized()
|
||||
{
|
||||
QTC_ASSERT(state() == EngineRunRequested, qCDebug(dapEngineLog) << state());
|
||||
QTC_ASSERT(state() == EngineRunRequested, qCDebug(logCategory()) << state());
|
||||
|
||||
m_dapClient->sendConfigurationDone();
|
||||
|
||||
qCDebug(dapEngineLog) << "handleDapConfigurationDone";
|
||||
qCDebug(logCategory()) << "handleDapConfigurationDone";
|
||||
}
|
||||
|
||||
void DapEngine::handleDapConfigurationDone()
|
||||
@@ -271,7 +269,7 @@ void DapEngine::dapInsertBreakpoint(const Breakpoint &bp)
|
||||
|
||||
m_dapClient->setBreakpoints(breakpoints, params.fileName);
|
||||
|
||||
qCDebug(dapEngineLog) << "insertBreakpoint" << bp->modelId() << bp->responseId();
|
||||
qCDebug(logCategory()) << "insertBreakpoint" << bp->modelId() << bp->responseId();
|
||||
}
|
||||
|
||||
void DapEngine::updateBreakpoint(const Breakpoint &bp)
|
||||
@@ -312,7 +310,7 @@ void DapEngine::dapRemoveBreakpoint(const Breakpoint &bp)
|
||||
|
||||
m_dapClient->setBreakpoints(breakpoints, params.fileName);
|
||||
|
||||
qCDebug(dapEngineLog) << "removeBreakpoint" << bp->modelId() << bp->responseId();
|
||||
qCDebug(logCategory()) << "removeBreakpoint" << bp->modelId() << bp->responseId();
|
||||
}
|
||||
|
||||
void DapEngine::loadSymbols(const Utils::FilePath &/*moduleName*/)
|
||||
@@ -474,7 +472,7 @@ void DapEngine::handleDapDone()
|
||||
void DapEngine::readDapStandardError()
|
||||
{
|
||||
QString err = m_dapClient->dataProvider()->readAllStandardError();
|
||||
qCDebug(dapEngineLog) << "DAP STDERR:" << err;
|
||||
qCDebug(logCategory()) << "DAP STDERR:" << err;
|
||||
//qWarning() << "Unexpected DAP stderr:" << err;
|
||||
showMessage("Unexpected DAP stderr: " + err);
|
||||
//handleOutput(err);
|
||||
@@ -486,23 +484,23 @@ void DapEngine::handleResponse(DapResponseType type, const QJsonObject &response
|
||||
|
||||
if (response.contains("success") && !response.value("success").toBool()) {
|
||||
showMessage(QString("DAP COMMAND FAILED: %1").arg(command));
|
||||
qCDebug(dapEngineLog) << "DAP COMMAND FAILED:" << command;
|
||||
qCDebug(logCategory()) << "DAP COMMAND FAILED:" << command;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case DapResponseType::Initialize:
|
||||
qCDebug(dapEngineLog) << "initialize success";
|
||||
qCDebug(logCategory()) << "initialize success";
|
||||
handleDapInitialize();
|
||||
break;
|
||||
case DapResponseType::ConfigurationDone:
|
||||
showMessage("configurationDone", LogDebug);
|
||||
qCDebug(dapEngineLog) << "configurationDone success";
|
||||
qCDebug(logCategory()) << "configurationDone success";
|
||||
handleDapConfigurationDone();
|
||||
break;
|
||||
case DapResponseType::Continue:
|
||||
showMessage("continue", LogDebug);
|
||||
qCDebug(dapEngineLog) << "continue success";
|
||||
qCDebug(logCategory()) << "continue success";
|
||||
notifyInferiorRunOk();
|
||||
break;
|
||||
case DapResponseType::StackTrace:
|
||||
@@ -544,7 +542,7 @@ void DapEngine::handleStackTraceResponse(const QJsonObject &response)
|
||||
const FilePath file = FilePath::fromString(
|
||||
stackFrame.value("source").toObject().value("path").toString());
|
||||
const int line = stackFrame.value("line").toInt();
|
||||
qCDebug(dapEngineLog) << "stackTrace success" << file << line;
|
||||
qCDebug(logCategory()) << "stackTrace success" << file << line;
|
||||
gotoLocation(Location(file, line));
|
||||
|
||||
refreshStack(stackFrames);
|
||||
@@ -605,7 +603,7 @@ void DapEngine::handleEvent(DapEventType type, const QJsonObject &event)
|
||||
|
||||
switch (type) {
|
||||
case DapEventType::Initialized:
|
||||
qCDebug(dapEngineLog) << "initialize success";
|
||||
qCDebug(logCategory()) << "initialize success";
|
||||
claimInitialBreakpoints();
|
||||
handleDapEventInitialized();
|
||||
break;
|
||||
@@ -672,7 +670,7 @@ void DapEngine::handleBreakpointEvent(const QJsonObject &event)
|
||||
|
||||
Breakpoint bp = breakHandler()->findBreakpointByResponseId(
|
||||
QString::number(breakpoint.value("id").toInt()));
|
||||
qCDebug(dapEngineLog) << "breakpoint id :" << breakpoint.value("id").toInt();
|
||||
qCDebug(logCategory()) << "breakpoint id :" << breakpoint.value("id").toInt();
|
||||
|
||||
if (bp) {
|
||||
BreakpointParameters parameters = bp->requestedParameters();
|
||||
@@ -690,10 +688,10 @@ void DapEngine::handleBreakpointEvent(const QJsonObject &event)
|
||||
const BreakpointParameters ¶ms = bp->requestedParameters();
|
||||
if (params.oneShot)
|
||||
continueInferior();
|
||||
qCDebug(dapEngineLog) << "breakpoint inserted";
|
||||
qCDebug(logCategory()) << "breakpoint inserted";
|
||||
} else {
|
||||
notifyBreakpointInsertFailed(bp);
|
||||
qCDebug(dapEngineLog) << "breakpoint insertion failed";
|
||||
qCDebug(logCategory()) << "breakpoint insertion failed";
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -701,10 +699,10 @@ void DapEngine::handleBreakpointEvent(const QJsonObject &event)
|
||||
if (body.value("reason").toString() == "removed") {
|
||||
if (breakpoint.value("verified").toBool()) {
|
||||
notifyBreakpointRemoveOk(bp);
|
||||
qCDebug(dapEngineLog) << "breakpoint removed";
|
||||
qCDebug(logCategory()) << "breakpoint removed";
|
||||
} else {
|
||||
notifyBreakpointRemoveFailed(bp);
|
||||
qCDebug(dapEngineLog) << "breakpoint remove failed";
|
||||
qCDebug(logCategory()) << "breakpoint remove failed";
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -727,7 +725,7 @@ void DapEngine::refreshLocals(const QJsonArray &variables)
|
||||
if (variablesReference > 0)
|
||||
item->wantsChildren = true;
|
||||
|
||||
qCDebug(dapEngineLog) << "variable" << name << variablesReference;
|
||||
qCDebug(logCategory()) << "variable" << name << variablesReference;
|
||||
if (m_isFirstLayer)
|
||||
m_watchItems.append(item);
|
||||
else
|
||||
@@ -800,7 +798,7 @@ bool DapEngine::hasCapability(unsigned cap) const
|
||||
void DapEngine::claimInitialBreakpoints()
|
||||
{
|
||||
BreakpointManager::claimBreakpointsForEngine(this);
|
||||
qCDebug(dapEngineLog) << "claimInitialBreakpoints";
|
||||
qCDebug(logCategory()) << "claimInitialBreakpoints";
|
||||
}
|
||||
|
||||
void DapEngine::connectDataGeneratorSignals()
|
||||
|
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <utils/process.h>
|
||||
|
||||
#include <QLoggingCategory>
|
||||
#include <QVariant>
|
||||
|
||||
#include <queue>
|
||||
@@ -118,6 +119,13 @@ protected:
|
||||
std::queue<int> m_variablesReferenceQueue;
|
||||
WatchItem *m_currentWatchItem = nullptr;
|
||||
QList<WatchItem *> m_watchItems;
|
||||
|
||||
virtual const QLoggingCategory &logCategory()
|
||||
{
|
||||
static const QLoggingCategory logCategory = QLoggingCategory("qtc.dbg.dapengine",
|
||||
QtWarningMsg);
|
||||
return logCategory;
|
||||
}
|
||||
};
|
||||
|
||||
} // Debugger::Internal
|
||||
|
@@ -17,12 +17,10 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QLocalSocket>
|
||||
#include <QLoggingCategory>
|
||||
#include <QVersionNumber>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
static Q_LOGGING_CATEGORY(dapEngineLog, "qtc.dbg.dapengine", QtWarningMsg)
|
||||
|
||||
namespace Debugger::Internal {
|
||||
|
||||
@@ -85,6 +83,22 @@ private:
|
||||
const CommandLine m_cmd;
|
||||
};
|
||||
|
||||
class GdbDapClient : public DapClient
|
||||
{
|
||||
public:
|
||||
GdbDapClient(IDataProvider *provider, QObject *parent = nullptr)
|
||||
: DapClient(provider, parent)
|
||||
{}
|
||||
|
||||
private:
|
||||
const QLoggingCategory &logCategory() override
|
||||
{
|
||||
static const QLoggingCategory logCategory = QLoggingCategory("qtc.dbg.dapengine.gdb",
|
||||
QtWarningMsg);
|
||||
return logCategory;
|
||||
}
|
||||
};
|
||||
|
||||
GdbDapEngine::GdbDapEngine()
|
||||
: DapEngine()
|
||||
{
|
||||
@@ -100,12 +114,11 @@ void GdbDapEngine::handleDapInitialize()
|
||||
return;
|
||||
}
|
||||
|
||||
QTC_ASSERT(state() == EngineRunRequested, qCDebug(dapEngineLog) << state());
|
||||
QTC_ASSERT(state() == EngineRunRequested, qCDebug(logCategory()) << state());
|
||||
m_dapClient->postRequest("attach", QJsonObject{{"__restart", ""}});
|
||||
qCDebug(dapEngineLog) << "handleDapAttach";
|
||||
qCDebug(logCategory()) << "handleDapAttach";
|
||||
}
|
||||
|
||||
|
||||
bool GdbDapEngine::isLocalAttachEngine() const
|
||||
{
|
||||
return runParameters().startMode == AttachToLocalProcess;
|
||||
@@ -123,7 +136,7 @@ void GdbDapEngine::handleDapConfigurationDone()
|
||||
|
||||
void GdbDapEngine::setupEngine()
|
||||
{
|
||||
QTC_ASSERT(state() == EngineSetupRequested, qCDebug(dapEngineLog) << state());
|
||||
QTC_ASSERT(state() == EngineSetupRequested, qCDebug(logCategory()) << state());
|
||||
|
||||
const DebuggerRunParameters &rp = runParameters();
|
||||
CommandLine cmd{rp.debugger.command.executable(), {"-i", "dap"}};
|
||||
@@ -142,7 +155,7 @@ void GdbDapEngine::setupEngine()
|
||||
}
|
||||
|
||||
IDataProvider *dataProvider = new ProcessDataProvider(rp, cmd, this);
|
||||
m_dapClient = new DapClient(dataProvider, this);
|
||||
m_dapClient = new GdbDapClient(dataProvider, this);
|
||||
|
||||
connectDataGeneratorSignals();
|
||||
m_dapClient->dataProvider()->start();
|
||||
|
@@ -19,6 +19,13 @@ private:
|
||||
void handleDapConfigurationDone() override;
|
||||
|
||||
bool isLocalAttachEngine() const;
|
||||
|
||||
const QLoggingCategory &logCategory() override
|
||||
{
|
||||
static const QLoggingCategory logCategory = QLoggingCategory("qtc.dbg.dapengine.gdb",
|
||||
QtWarningMsg);
|
||||
return logCategory;
|
||||
}
|
||||
};
|
||||
|
||||
} // Debugger::Internal
|
||||
|
@@ -20,7 +20,6 @@
|
||||
#include <projectexplorer/projecttree.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QLoggingCategory>
|
||||
#include <QTcpSocket>
|
||||
#include <QTimer>
|
||||
#include <QVersionNumber>
|
||||
@@ -28,11 +27,8 @@
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
static Q_LOGGING_CATEGORY(dapEngineLog, "qtc.dbg.dapengine", QtWarningMsg)
|
||||
|
||||
namespace Debugger::Internal {
|
||||
|
||||
|
||||
const char installDebugPyInfoBarId[] = "Python::InstallDebugPy";
|
||||
|
||||
static bool missingPySideInstallation(const FilePath &pythonPath, const QString &packageName)
|
||||
@@ -88,7 +84,6 @@ public:
|
||||
connect(m_timer, &QTimer::timeout, this, [this]() {
|
||||
m_socket.connectToHost(m_hostName, m_port);
|
||||
m_socket.waitForConnected();
|
||||
qCDebug(dapEngineLog) << "proc id" << m_proc.processId();
|
||||
|
||||
if (m_socket.state() == QTcpSocket::ConnectedState)
|
||||
m_timer->stop();
|
||||
@@ -152,7 +147,7 @@ public:
|
||||
: DapClient(provider, parent)
|
||||
{}
|
||||
|
||||
void sendInitialize()
|
||||
void sendInitialize() override
|
||||
{
|
||||
postRequest("initialize",
|
||||
QJsonObject{{"clientID", "QtCreator"},
|
||||
@@ -160,6 +155,13 @@ public:
|
||||
{"adapterID", "python"},
|
||||
{"pathFormat", "path"}});
|
||||
}
|
||||
private:
|
||||
const QLoggingCategory &logCategory() override
|
||||
{
|
||||
static const QLoggingCategory dapEngineLog = QLoggingCategory("qtc.dbg.dapengine.python",
|
||||
QtWarningMsg);
|
||||
return dapEngineLog;
|
||||
}
|
||||
};
|
||||
|
||||
PyDapEngine::PyDapEngine()
|
||||
@@ -172,11 +174,11 @@ PyDapEngine::PyDapEngine()
|
||||
|
||||
void PyDapEngine::handleDapInitialize()
|
||||
{
|
||||
QTC_ASSERT(state() == EngineRunRequested, qCDebug(dapEngineLog) << state());
|
||||
QTC_ASSERT(state() == EngineRunRequested, qCDebug(logCategory()) << state());
|
||||
|
||||
m_dapClient->sendAttach();
|
||||
|
||||
qCDebug(dapEngineLog) << "handleDapAttach";
|
||||
qCDebug(logCategory()) << "handleDapAttach";
|
||||
}
|
||||
|
||||
void PyDapEngine::quitDebugger()
|
||||
|
@@ -18,6 +18,13 @@ private:
|
||||
|
||||
void setupEngine() override;
|
||||
Utils::Process m_proc;
|
||||
|
||||
const QLoggingCategory &logCategory() override
|
||||
{
|
||||
static const QLoggingCategory logCategory = QLoggingCategory("qtc.dbg.dapengine.python",
|
||||
QtWarningMsg);
|
||||
return logCategory;
|
||||
}
|
||||
};
|
||||
|
||||
} // Debugger::Internal
|
||||
|
Reference in New Issue
Block a user