2023-01-03 15:12:43 +01:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <debugger/debuggerengine.h>
|
2023-07-04 16:32:37 +02:00
|
|
|
|
2023-05-03 17:05:35 +02:00
|
|
|
#include <utils/process.h>
|
2023-01-03 15:12:43 +01:00
|
|
|
|
|
|
|
|
#include <QVariant>
|
|
|
|
|
|
2023-07-13 13:43:59 +02:00
|
|
|
#include <queue>
|
|
|
|
|
|
2023-01-03 15:12:43 +01:00
|
|
|
namespace Debugger::Internal {
|
|
|
|
|
|
|
|
|
|
class DebuggerCommand;
|
|
|
|
|
class GdbMi;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* A debugger engine for the debugger adapter protocol.
|
|
|
|
|
*/
|
|
|
|
|
|
2023-06-27 16:57:51 +02:00
|
|
|
class IDataProvider : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
virtual void start() = 0;
|
|
|
|
|
virtual bool isRunning() const = 0;
|
|
|
|
|
virtual void writeRaw(const QByteArray &input) = 0;
|
|
|
|
|
virtual void kill() = 0;
|
|
|
|
|
virtual QByteArray readAllStandardOutput() = 0;
|
|
|
|
|
virtual QString readAllStandardError() = 0;
|
|
|
|
|
virtual int exitCode() const = 0;
|
|
|
|
|
virtual QString executable() const = 0;
|
|
|
|
|
|
|
|
|
|
virtual QProcess::ExitStatus exitStatus() const = 0;
|
|
|
|
|
virtual QProcess::ProcessError error() const = 0;
|
|
|
|
|
virtual Utils::ProcessResult result() const = 0;
|
|
|
|
|
virtual QString exitMessage() const = 0;
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void started();
|
|
|
|
|
void done();
|
|
|
|
|
void readyReadStandardOutput();
|
|
|
|
|
void readyReadStandardError();
|
|
|
|
|
};
|
|
|
|
|
|
2023-01-03 15:12:43 +01:00
|
|
|
class DapEngine : public DebuggerEngine
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
DapEngine();
|
|
|
|
|
|
2023-08-08 15:37:39 +02:00
|
|
|
protected:
|
2023-01-03 15:12:43 +01:00
|
|
|
void executeStepIn(bool) override;
|
|
|
|
|
void executeStepOut() override;
|
|
|
|
|
void executeStepOver(bool) override;
|
|
|
|
|
|
|
|
|
|
void shutdownInferior() override;
|
|
|
|
|
void shutdownEngine() override;
|
|
|
|
|
|
|
|
|
|
bool canHandleToolTip(const DebuggerToolTipContext &) const override;
|
|
|
|
|
|
|
|
|
|
void continueInferior() override;
|
|
|
|
|
void interruptInferior() override;
|
|
|
|
|
|
|
|
|
|
void executeRunToLine(const ContextData &data) override;
|
|
|
|
|
void executeRunToFunction(const QString &functionName) override;
|
|
|
|
|
void executeJumpToLine(const ContextData &data) override;
|
|
|
|
|
|
|
|
|
|
void activateFrame(int index) override;
|
|
|
|
|
void selectThread(const Thread &thread) override;
|
|
|
|
|
|
|
|
|
|
bool acceptsBreakpoint(const BreakpointParameters &bp) const override;
|
|
|
|
|
void insertBreakpoint(const Breakpoint &bp) override;
|
|
|
|
|
void updateBreakpoint(const Breakpoint &bp) override;
|
|
|
|
|
void removeBreakpoint(const Breakpoint &bp) override;
|
|
|
|
|
|
|
|
|
|
void assignValueInDebugger(WatchItem *item,
|
|
|
|
|
const QString &expr, const QVariant &value) override;
|
|
|
|
|
void executeDebuggerCommand(const QString &command) override;
|
|
|
|
|
|
|
|
|
|
void loadSymbols(const Utils::FilePath &moduleName) override;
|
|
|
|
|
void loadAllSymbols() override;
|
|
|
|
|
void requestModuleSymbols(const Utils::FilePath &moduleName) override;
|
|
|
|
|
void reloadModules() override;
|
|
|
|
|
void reloadRegisters() override {}
|
|
|
|
|
void reloadSourceFiles() override {}
|
|
|
|
|
void reloadFullStack() override {}
|
|
|
|
|
|
|
|
|
|
bool supportsThreads() const { return true; }
|
|
|
|
|
void updateItem(const QString &iname) override;
|
|
|
|
|
|
|
|
|
|
void runCommand(const DebuggerCommand &cmd) override;
|
|
|
|
|
void postDirectCommand(const QJsonObject &ob);
|
|
|
|
|
|
|
|
|
|
void refreshLocation(const GdbMi &reportedLocation);
|
2023-06-16 15:28:50 +02:00
|
|
|
void refreshStack(const QJsonArray &stackFrames);
|
|
|
|
|
void refreshLocals(const QJsonArray &variables);
|
2023-01-03 15:12:43 +01:00
|
|
|
void refreshModules(const GdbMi &modules);
|
|
|
|
|
void refreshState(const GdbMi &reportedState);
|
|
|
|
|
void refreshSymbols(const GdbMi &symbols);
|
|
|
|
|
|
|
|
|
|
QString errorMessage(QProcess::ProcessError error) const;
|
|
|
|
|
bool hasCapability(unsigned cap) const override;
|
|
|
|
|
|
|
|
|
|
void claimInitialBreakpoints();
|
|
|
|
|
|
2023-08-08 15:37:39 +02:00
|
|
|
virtual void handleDapStarted();
|
2023-06-16 15:28:50 +02:00
|
|
|
void handleDapLaunch();
|
|
|
|
|
void handleDapConfigurationDone();
|
2023-01-03 15:12:43 +01:00
|
|
|
|
2023-06-16 15:28:50 +02:00
|
|
|
void dapStackTrace();
|
2023-07-04 16:32:37 +02:00
|
|
|
void dapScopes(int frameId);
|
2023-06-15 15:27:33 +02:00
|
|
|
void threads();
|
2023-06-16 15:28:50 +02:00
|
|
|
void dapVariables(int variablesReference);
|
2023-06-13 17:24:28 +02:00
|
|
|
|
2023-01-03 15:12:43 +01:00
|
|
|
void handleDapDone();
|
|
|
|
|
void readDapStandardOutput();
|
|
|
|
|
void readDapStandardError();
|
|
|
|
|
void handleOutput(const QJsonDocument &data);
|
|
|
|
|
void handleResponse(const QString &ba);
|
|
|
|
|
void updateAll() override;
|
|
|
|
|
void updateLocals() override;
|
2023-08-08 15:37:39 +02:00
|
|
|
void connectDataGeneratorSignals();
|
2023-01-03 15:12:43 +01:00
|
|
|
|
|
|
|
|
QByteArray m_inbuffer;
|
2023-06-27 16:57:51 +02:00
|
|
|
std::unique_ptr<IDataProvider> m_dataGenerator = nullptr;
|
|
|
|
|
|
2023-04-06 14:20:01 +02:00
|
|
|
int m_nextBreakpointId = 1;
|
2023-06-13 17:24:28 +02:00
|
|
|
int m_currentThreadId = -1;
|
2023-07-13 13:43:59 +02:00
|
|
|
|
|
|
|
|
std::queue<std::pair<int, WatchItem *>> m_variablesReferenceQueue;
|
|
|
|
|
WatchItem *m_currentWatchItem = nullptr;
|
|
|
|
|
WatchItem *m_rootWatchItem = nullptr;
|
2023-01-03 15:12:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // Debugger::Internal
|