From 37ef24114cde593ba16e02f3d4c422a969a63317 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 7 Mar 2018 15:31:08 +0100 Subject: [PATCH] Debugger: Move DebugInfoTask handling to plugin This does not involve the engine (currently). Task-number: QTCREATORBUG-19994 Change-Id: I07a628580bf99c988eb0df165d649d5cc0869c0d Reviewed-by: Tobias Hunger --- src/plugins/debugger/debuggercore.h | 2 + src/plugins/debugger/debuggerplugin.cpp | 44 +++++++++++++++++ src/plugins/debugger/gdb/gdbengine.cpp | 64 +------------------------ src/plugins/debugger/gdb/gdbengine.h | 5 -- 4 files changed, 47 insertions(+), 68 deletions(-) diff --git a/src/plugins/debugger/debuggercore.h b/src/plugins/debugger/debuggercore.h index 3f5f1e6a84e..57f9476bf88 100644 --- a/src/plugins/debugger/debuggercore.h +++ b/src/plugins/debugger/debuggercore.h @@ -124,5 +124,7 @@ QAction *addCheckableAction(QMenu *menu, const QString &display, bool on, bool c // Qt's various build paths for unpatched versions QStringList qtBuildPaths(); +void addDebugInfoTask(unsigned id, const QString &cmd); + } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 8e46a9735e3..b58a226b095 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -92,6 +92,7 @@ #include #include #include +#include #include #include #include @@ -578,6 +579,42 @@ static Kit *findUniversalCdbKit() return KitManager::kit(cdbPredicate()); } +/////////////////////////////////////////////////////////////////////// +// +// Debuginfo Taskhandler +// +/////////////////////////////////////////////////////////////////////// + +class DebugInfoTaskHandler : public ITaskHandler +{ +public: + bool canHandle(const Task &task) const final + { + return m_debugInfoTasks.contains(task.taskId); + } + + void handle(const Task &task) final + { + QString cmd = m_debugInfoTasks.value(task.taskId); + QProcess::startDetached(cmd); + } + + void addTask(unsigned id, const QString &cmd) + { + m_debugInfoTasks[id] = cmd; + } + + QAction *createAction(QObject *parent) const final + { + QAction *action = new QAction(DebuggerPlugin::tr("Install &Debug Information"), parent); + action->setToolTip(DebuggerPlugin::tr("Tries to install missing debug information.")); + return action; + } + +private: + QHash m_debugInfoTasks; +}; + /////////////////////////////////////////////////////////////////////// // // DebuggerPluginPrivate @@ -1028,6 +1065,8 @@ public: CommonOptionsPage *m_commonOptionsPage = 0; DummyEngine *m_dummyEngine = 0; const QSharedPointer m_globalDebuggerOptions; + + DebugInfoTaskHandler m_debugInfoTaskHandler; }; DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin) @@ -2955,6 +2994,11 @@ QMessageBox *showMessageBox(int icon, const QString &title, return mb; } +void addDebugInfoTask(unsigned id, const QString &cmd) +{ + dd->m_debugInfoTaskHandler.addTask(id, cmd); +} + bool isReverseDebuggingEnabled() { static bool enabled = qEnvironmentVariableIsSet("QTC_DEBUGGER_ENABLE_REVERSE"); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 9a1381844da..410c30944ce 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -55,7 +55,6 @@ #include #include -#include #include #include @@ -131,52 +130,6 @@ static bool isMostlyHarmlessMessage(const QStringRef &msg) "Invalid argument\\n"; } -/////////////////////////////////////////////////////////////////////// -// -// Debuginfo Taskhandler -// -/////////////////////////////////////////////////////////////////////// - -class DebugInfoTask -{ -public: - QString command; -}; - -class DebugInfoTaskHandler : public ITaskHandler -{ -public: - explicit DebugInfoTaskHandler(GdbEngine *engine) - : m_engine(engine) - {} - - bool canHandle(const Task &task) const override - { - return m_debugInfoTasks.contains(task.taskId); - } - - void handle(const Task &task) override - { - m_engine->requestDebugInformation(m_debugInfoTasks.value(task.taskId)); - } - - void addTask(unsigned id, const DebugInfoTask &task) - { - m_debugInfoTasks[id] = task; - } - - QAction *createAction(QObject *parent) const override - { - QAction *action = new QAction(DebuggerPlugin::tr("Install &Debug Information"), parent); - action->setToolTip(DebuggerPlugin::tr("Tries to install missing debug information.")); - return action; - } - -private: - GdbEngine *m_engine; - QHash m_debugInfoTasks; -}; - /////////////////////////////////////////////////////////////////////// // // GdbEngine @@ -190,9 +143,6 @@ GdbEngine::GdbEngine() m_gdbOutputCodec = QTextCodec::codecForLocale(); m_inferiorOutputCodec = QTextCodec::codecForLocale(); - m_debugInfoTaskHandler = new DebugInfoTaskHandler(this); - //ExtensionSystem::PluginManager::addObject(m_debugInfoTaskHandler); - m_commandTimer.setSingleShot(true); connect(&m_commandTimer, &QTimer::timeout, this, &GdbEngine::commandTimeout); @@ -222,10 +172,6 @@ GdbEngine::GdbEngine() GdbEngine::~GdbEngine() { - //ExtensionSystem::PluginManager::removeObject(m_debugInfoTaskHandler); - delete m_debugInfoTaskHandler; - m_debugInfoTaskHandler = 0; - // Prevent sending error messages afterwards. disconnect(); } @@ -434,10 +380,7 @@ void GdbEngine::handleResponse(const QString &buff) FileName(), 0, Debugger::Constants::TASK_CATEGORY_DEBUGGER_DEBUGINFO); TaskHub::addTask(task); - - DebugInfoTask dit; - dit.command = cmd; - m_debugInfoTaskHandler->addTask(task.taskId, dit); + Internal::addDebugInfoTask(task.taskId, cmd); } } @@ -4177,11 +4120,6 @@ void GdbEngine::scheduleTestResponse(int testCase, const QString &response) m_scheduledTestResponses[token] = response; } -void GdbEngine::requestDebugInformation(const DebugInfoTask &task) -{ - QProcess::startDetached(task.command); -} - QString GdbEngine::msgGdbStopFailed(const QString &why) { return tr("The gdb process could not be stopped:\n%1").arg(why); diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index 17689351691..7ccccd16325 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -381,11 +381,6 @@ private: ////////// General Interface ////////// QHash m_scheduledTestResponses; QSet m_testCases; - // Debug information - friend class DebugInfoTaskHandler; - void requestDebugInformation(const DebugInfoTask &task); - DebugInfoTaskHandler *m_debugInfoTaskHandler; - bool m_systemDumpersLoaded = false; static QString msgGdbStopFailed(const QString &why);