Debugger: Move DebugInfoTask handling to plugin

This does not involve the engine (currently).

Task-number: QTCREATORBUG-19994
Change-Id: I07a628580bf99c988eb0df165d649d5cc0869c0d
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
hjk
2018-03-07 15:31:08 +01:00
parent 144bba95e9
commit 37ef24114c
4 changed files with 47 additions and 68 deletions

View File

@@ -55,7 +55,6 @@
#include <coreplugin/messagebox.h>
#include <projectexplorer/devicesupport/deviceprocess.h>
#include <projectexplorer/itaskhandler.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/taskhub.h>
@@ -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<unsigned, DebugInfoTask> 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);