forked from qt-creator/qt-creator
DAP: Add attach function to gdb dap engine
Change-Id: Id1c886cf3bbdbf85d4eed39f288107fc71317496 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -120,7 +120,16 @@ void DapEngine::handleDapStarted()
|
|||||||
qCDebug(dapEngineLog) << "handleDapStarted";
|
qCDebug(dapEngineLog) << "handleDapStarted";
|
||||||
}
|
}
|
||||||
|
|
||||||
void DapEngine::handleDapConfigurationDone()
|
void DapEngine::handleDapInitialize()
|
||||||
|
{
|
||||||
|
QTC_ASSERT(state() == EngineRunRequested, qCDebug(dapEngineLog) << state());
|
||||||
|
|
||||||
|
m_dapClient->sendLaunch(runParameters().inferior.command.executable());
|
||||||
|
|
||||||
|
qCDebug(dapEngineLog) << "handleDapLaunch";
|
||||||
|
}
|
||||||
|
|
||||||
|
void DapEngine::handleDapEventInitialized()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(state() == EngineRunRequested, qCDebug(dapEngineLog) << state());
|
QTC_ASSERT(state() == EngineRunRequested, qCDebug(dapEngineLog) << state());
|
||||||
|
|
||||||
@@ -129,14 +138,9 @@ void DapEngine::handleDapConfigurationDone()
|
|||||||
qCDebug(dapEngineLog) << "handleDapConfigurationDone";
|
qCDebug(dapEngineLog) << "handleDapConfigurationDone";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DapEngine::handleDapConfigurationDone()
|
||||||
void DapEngine::handleDapInitialize()
|
|
||||||
{
|
{
|
||||||
QTC_ASSERT(state() == EngineRunRequested, qCDebug(dapEngineLog) << state());
|
notifyEngineRunAndInferiorRunOk();
|
||||||
|
|
||||||
m_dapClient->sendLaunch(runParameters().inferior.command.executable());
|
|
||||||
|
|
||||||
qCDebug(dapEngineLog) << "handleDapLaunch";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DapEngine::interruptInferior()
|
void DapEngine::interruptInferior()
|
||||||
@@ -480,6 +484,12 @@ void DapEngine::handleResponse(DapResponseType type, const QJsonObject &response
|
|||||||
{
|
{
|
||||||
const QString command = response.value("command").toString();
|
const QString command = response.value("command").toString();
|
||||||
|
|
||||||
|
if (response.contains("success") && !response.value("success").toBool()) {
|
||||||
|
showMessage(QString("DAP COMMAND FAILED: %1").arg(command));
|
||||||
|
qCDebug(dapEngineLog) << "DAP COMMAND FAILED:" << command;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DapResponseType::Initialize:
|
case DapResponseType::Initialize:
|
||||||
qCDebug(dapEngineLog) << "initialize success";
|
qCDebug(dapEngineLog) << "initialize success";
|
||||||
@@ -488,7 +498,7 @@ void DapEngine::handleResponse(DapResponseType type, const QJsonObject &response
|
|||||||
case DapResponseType::ConfigurationDone:
|
case DapResponseType::ConfigurationDone:
|
||||||
showMessage("configurationDone", LogDebug);
|
showMessage("configurationDone", LogDebug);
|
||||||
qCDebug(dapEngineLog) << "configurationDone success";
|
qCDebug(dapEngineLog) << "configurationDone success";
|
||||||
notifyEngineRunAndInferiorRunOk();
|
handleDapConfigurationDone();
|
||||||
break;
|
break;
|
||||||
case DapResponseType::Continue:
|
case DapResponseType::Continue:
|
||||||
showMessage("continue", LogDebug);
|
showMessage("continue", LogDebug);
|
||||||
@@ -597,7 +607,7 @@ void DapEngine::handleEvent(DapEventType type, const QJsonObject &event)
|
|||||||
case DapEventType::Initialized:
|
case DapEventType::Initialized:
|
||||||
qCDebug(dapEngineLog) << "initialize success";
|
qCDebug(dapEngineLog) << "initialize success";
|
||||||
claimInitialBreakpoints();
|
claimInitialBreakpoints();
|
||||||
handleDapConfigurationDone();
|
handleDapEventInitialized();
|
||||||
break;
|
break;
|
||||||
case DapEventType::Stopped:
|
case DapEventType::Stopped:
|
||||||
handleStoppedEvent(event);
|
handleStoppedEvent(event);
|
||||||
|
@@ -85,7 +85,8 @@ protected:
|
|||||||
|
|
||||||
void handleDapStarted();
|
void handleDapStarted();
|
||||||
virtual void handleDapInitialize();
|
virtual void handleDapInitialize();
|
||||||
void handleDapConfigurationDone();
|
void handleDapEventInitialized();
|
||||||
|
virtual void handleDapConfigurationDone();
|
||||||
|
|
||||||
void dapRemoveBreakpoint(const Breakpoint &bp);
|
void dapRemoveBreakpoint(const Breakpoint &bp);
|
||||||
void dapInsertBreakpoint(const Breakpoint &bp);
|
void dapInsertBreakpoint(const Breakpoint &bp);
|
||||||
|
@@ -93,12 +93,43 @@ GdbDapEngine::GdbDapEngine()
|
|||||||
setDebuggerType("DAP");
|
setDebuggerType("DAP");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GdbDapEngine::handleDapInitialize()
|
||||||
|
{
|
||||||
|
if (!isLocalAttachEngine()) {
|
||||||
|
DapEngine::handleDapInitialize();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTC_ASSERT(state() == EngineRunRequested, qCDebug(dapEngineLog) << state());
|
||||||
|
m_dapClient->postRequest("attach", QJsonObject{{"__restart", ""}});
|
||||||
|
qCDebug(dapEngineLog) << "handleDapAttach";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GdbDapEngine::isLocalAttachEngine() const
|
||||||
|
{
|
||||||
|
return runParameters().startMode == AttachToLocalProcess;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GdbDapEngine::handleDapConfigurationDone()
|
||||||
|
{
|
||||||
|
if (!isLocalAttachEngine()) {
|
||||||
|
DapEngine::handleDapConfigurationDone();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
notifyEngineRunAndInferiorStopOk();
|
||||||
|
}
|
||||||
|
|
||||||
void GdbDapEngine::setupEngine()
|
void GdbDapEngine::setupEngine()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(state() == EngineSetupRequested, qCDebug(dapEngineLog) << state());
|
QTC_ASSERT(state() == EngineSetupRequested, qCDebug(dapEngineLog) << state());
|
||||||
|
|
||||||
const DebuggerRunParameters &rp = runParameters();
|
const DebuggerRunParameters &rp = runParameters();
|
||||||
const CommandLine cmd{rp.debugger.command.executable(), {"-i", "dap"}};
|
CommandLine cmd{rp.debugger.command.executable(), {"-i", "dap"}};
|
||||||
|
|
||||||
|
if (isLocalAttachEngine())
|
||||||
|
cmd.addArgs({"-p", QString::number(rp.attachPID.pid())});
|
||||||
|
|
||||||
QVersionNumber oldestVersion(14, 0, 50);
|
QVersionNumber oldestVersion(14, 0, 50);
|
||||||
QVersionNumber version = QVersionNumber::fromString(rp.version);
|
QVersionNumber version = QVersionNumber::fromString(rp.version);
|
||||||
|
@@ -14,6 +14,11 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void setupEngine() override;
|
void setupEngine() override;
|
||||||
|
|
||||||
|
void handleDapInitialize() override;
|
||||||
|
void handleDapConfigurationDone() override;
|
||||||
|
|
||||||
|
bool isLocalAttachEngine() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Debugger::Internal
|
} // Debugger::Internal
|
||||||
|
@@ -88,6 +88,8 @@ public:
|
|||||||
connect(m_timer, &QTimer::timeout, this, [this]() {
|
connect(m_timer, &QTimer::timeout, this, [this]() {
|
||||||
m_socket.connectToHost(m_hostName, m_port);
|
m_socket.connectToHost(m_hostName, m_port);
|
||||||
m_socket.waitForConnected();
|
m_socket.waitForConnected();
|
||||||
|
qCDebug(dapEngineLog) << "proc id" << m_proc.processId();
|
||||||
|
|
||||||
if (m_socket.state() == QTcpSocket::ConnectedState)
|
if (m_socket.state() == QTcpSocket::ConnectedState)
|
||||||
m_timer->stop();
|
m_timer->stop();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user