Commit 2d142a20 authored by Peifeng Yu's avatar Peifeng Yu
Browse files

KDEvMI: avoid duplicating tool views by loading/unloading them with debug session

parent ccc9c940
......@@ -63,41 +63,10 @@ MIDebuggerPlugin::MIDebuggerPlugin(const QString &componentName, QObject *parent
core()->debugController()->initializeUi();
setupToolviews();
setupActions();
setupDBus();
}
void MIDebuggerPlugin::setupToolviews()
{
// TODO: port tool views
/*
disassemblefactory = new DebuggerToolFactory<DisassembleWidget>(
this, "org.kdevelop.debugger.DisassemblerView", Qt::BottomDockWidgetArea);
lldbfactory = new DebuggerToolFactory<LLDBOutputWidget>(
this, "org.kdevelop.debugger.ConsoleView",Qt::BottomDockWidgetArea);
core()->uiController()->addToolView(
i18n("Disassemble/Registers"),
disassemblefactory);
core()->uiController()->addToolView(
i18n("LLDB"),
lldbfactory);
#ifndef WITH_OKTETA
memoryviewerfactory = nullptr;
#else
memoryviewerfactory = new DebuggerToolFactory<MemoryViewerWidget>(
this, "org.kdevelop.debugger.MemoryView", Qt::BottomDockWidgetArea);
core()->uiController()->addToolView(
i18n("Memory"),
memoryviewerfactory);
#endif
*/
}
void MIDebuggerPlugin::setupActions()
{
KActionCollection* ac = actionCollection();
......@@ -147,12 +116,7 @@ void MIDebuggerPlugin::setupDBus()
void MIDebuggerPlugin::unload()
{
// TODO: port tool views
/*
core()->uiController()->removeToolView(disassemblefactory);
core()->uiController()->removeToolView(lldbfactory);
core()->uiController()->removeToolView(memoryviewerfactory);
*/
unloadToolviews();
}
MIDebuggerPlugin::~MIDebuggerPlugin()
......
......@@ -58,7 +58,14 @@ public:
void unload() override;
KDevelop::ContextMenuExtension contextMenuExtension( KDevelop::Context* ) override;
virtual MIDebugSession *createSession() const = 0;
virtual MIDebugSession *createSession() = 0;
virtual void setupToolviews() = 0;
/**
* The implementation should be sure it's safe to call
* even when tool views are already unloaded.
*/
virtual void unloadToolviews() = 0;
//BEGIN IStatus
public:
......@@ -97,7 +104,6 @@ protected Q_SLOTS:
void slotCloseDrKonqi();
protected:
void setupToolviews();
void setupActions();
void setupDBus();
......
......@@ -63,7 +63,7 @@ using namespace KDevelop;
using namespace KDevMI;
using namespace KDevMI::MI;
MIDebugSession::MIDebugSession()
MIDebugSession::MIDebugSession(MIDebuggerPlugin *plugin)
: m_procLineMaker(new ProcessLineMaker(this))
, m_commandQueue(new CommandQueue)
, m_sessionState(NotStartedState)
......@@ -74,6 +74,7 @@ MIDebugSession::MIDebugSession()
, m_tty(nullptr)
, m_hasCrashed(false)
, m_sourceInitFile(true)
, m_plugin(plugin)
{
// setup signals
connect(m_procLineMaker, &ProcessLineMaker::receivedStdoutLines,
......
......@@ -52,13 +52,14 @@ class CommandQueue;
}
class MIDebugger;
class MIDebuggerPlugin;
class MIVariable;
class STTY;
class MIDebugSession : public KDevelop::IDebugSession
{
Q_OBJECT
public:
MIDebugSession();
explicit MIDebugSession(MIDebuggerPlugin *plugin = nullptr);
~MIDebugSession() override;
Q_SIGNALS:
......@@ -344,6 +345,8 @@ protected:
// Map from GDB varobj name to MIVariable.
QMap<QString, MIVariable*> m_allVariables;
MIDebuggerPlugin *m_plugin;
};
template<class Handler>
......
......@@ -93,8 +93,6 @@ private:
QActionGroup* m_disassemblyFlavorActionGroup;
};
class Breakpoint;
class DebugSession;
class MIDebuggerPlugin;
......
......@@ -48,9 +48,24 @@ K_PLUGIN_FACTORY_WITH_JSON(CppDebuggerFactory, "kdevgdb.json", registerPlugin<Cp
CppDebuggerPlugin::CppDebuggerPlugin(QObject *parent, const QVariantList &)
: MIDebuggerPlugin("kdevgdb", parent)
, disassemblefactory(nullptr)
, gdbfactory(nullptr)
, memoryviewerfactory(nullptr)
{
setXMLFile("kdevgdbui.rc");
QList<IPlugin*> plugins = KDevelop::ICore::self()->pluginController()->allPluginsForExtension("org.kdevelop.IExecutePlugin");
foreach(IPlugin* plugin, plugins) {
IExecutePlugin* iface = plugin->extension<IExecutePlugin>();
Q_ASSERT(iface);
KDevelop::LaunchConfigurationType* type = core()->runController()->launchConfigurationTypeForId( iface->nativeAppConfigTypeId() );
Q_ASSERT(type);
type->addLauncher( new GdbLauncher( this, iface ) );
}
}
void CppDebuggerPlugin::setupToolviews()
{
disassemblefactory = new DebuggerToolFactory<DisassembleWidget>(
this, "org.kdevelop.debugger.DisassemblerView", Qt::BottomDockWidgetArea);
......@@ -74,31 +89,31 @@ CppDebuggerPlugin::CppDebuggerPlugin(QObject *parent, const QVariantList &)
i18n("Memory"),
memoryviewerfactory);
#endif
QList<IPlugin*> plugins = KDevelop::ICore::self()->pluginController()->allPluginsForExtension("org.kdevelop.IExecutePlugin");
foreach(IPlugin* plugin, plugins) {
IExecutePlugin* iface = plugin->extension<IExecutePlugin>();
Q_ASSERT(iface);
KDevelop::LaunchConfigurationType* type = core()->runController()->launchConfigurationTypeForId( iface->nativeAppConfigTypeId() );
Q_ASSERT(type);
type->addLauncher( new GdbLauncher( this, iface ) );
}
}
void CppDebuggerPlugin::unload()
void CppDebuggerPlugin::unloadToolviews()
{
core()->uiController()->removeToolView(disassemblefactory);
core()->uiController()->removeToolView(gdbfactory);
core()->uiController()->removeToolView(memoryviewerfactory);
if (disassemblefactory) {
core()->uiController()->removeToolView(disassemblefactory);
disassemblefactory = nullptr;
}
if (gdbfactory) {
core()->uiController()->removeToolView(gdbfactory);
gdbfactory = nullptr;
}
if (memoryviewerfactory) {
core()->uiController()->removeToolView(memoryviewerfactory);
memoryviewerfactory = nullptr;
}
}
CppDebuggerPlugin::~CppDebuggerPlugin()
{
}
DebugSession* CppDebuggerPlugin::createSession() const
DebugSession* CppDebuggerPlugin::createSession()
{
DebugSession *session = new DebugSession();
DebugSession *session = new DebugSession(this);
KDevelop::ICore::self()->debugController()->addSession(session);
connect(session, &DebugSession::showMessage, this, &CppDebuggerPlugin::showStatusMessage);
connect(session, &DebugSession::reset, this, &CppDebuggerPlugin::reset);
......
......@@ -70,11 +70,9 @@ public:
CppDebuggerPlugin(QObject *parent, const QVariantList & = QVariantList());
~CppDebuggerPlugin() override;
DebugSession *createSession() const override;
void unload() override;
private:
void setupToolviews();
DebugSession *createSession() override;
void unloadToolviews() override;
void setupToolviews() override;
private:
DebuggerToolFactory<DisassembleWidget>* disassemblefactory;
......
......@@ -26,6 +26,7 @@
#include "debugsession.h"
#include "debuglog.h"
#include "debuggerplugin.h"
#include "gdb.h"
#include "gdbbreakpointcontroller.h"
#include "gdbframestackmodel.h"
......@@ -55,8 +56,8 @@ using namespace KDevMI::GDB;
using namespace KDevMI::MI;
using namespace KDevelop;
DebugSession::DebugSession()
: MIDebugSession()
DebugSession::DebugSession(CppDebuggerPlugin *plugin)
: MIDebugSession(plugin)
, m_breakpointController(nullptr)
, m_variableController(nullptr)
, m_frameStackModel(nullptr)
......@@ -65,10 +66,13 @@ DebugSession::DebugSession()
m_breakpointController = new BreakpointController(this);
m_variableController = new VariableController(this);
m_frameStackModel = new GdbFrameStackModel(this);
if (m_plugin) m_plugin->setupToolviews();
}
DebugSession::~DebugSession()
{
if (m_plugin) m_plugin->unloadToolviews();
}
void DebugSession::setAutoDisableASLR(bool enable)
......
......@@ -61,11 +61,12 @@ class CommandQueue;
namespace GDB {
class CppDebuggerPlugin;
class DebugSession : public MIDebugSession
{
Q_OBJECT
public:
DebugSession();
explicit DebugSession(CppDebuggerPlugin *plugin = nullptr);
~DebugSession() override;
BreakpointController * breakpointController() const override;
......
......@@ -24,7 +24,7 @@
* disassembly widget
* memory view
- Find a way to avoid duplicate tool views for GDB and LLDB plugin
- [DONE] Find a way to avoid duplicate tool views for GDB and LLDB plugin
- Remove duplicate breakpoint: look at breakpointController()->setDeleteDuplicateBreakpoints(true)
......@@ -52,7 +52,8 @@
* when hit watch point, nothing is output, which confuses the controller
* thread-info returns malformated result
+ there should be only one 'frame' key for each thread in the list
+ [FIXED] there shoule be a current-thread-id field (fixed at least in revision 265858)
+ [FIXED] there shoule be a current-thread-id field (Fixed at least in revision 265858)
* [FIXED] lldb-mi crashes when break on a point where multiple threads running. (Fixed at least in revision 265858)
* var-update doesn't support * as variable name
* can't have space in environment cd
* -inferior-tty-set only has dummy implementation
......
......@@ -22,6 +22,7 @@
#include "debuggerplugin.h"
#include "debuglog.h"
#include "lldblauncher.h"
#include "widgets/lldbconfigpage.h"
#include "widgets/debuggerconsoleview.h"
......@@ -45,8 +46,6 @@ LldbDebuggerPlugin::LldbDebuggerPlugin(QObject *parent, const QVariantList &)
{
setXMLFile("kdevlldbui.rc");
setupToolviews();
auto plugins = core()->pluginController()->allPluginsForExtension("org.kdevelop.IExecutePlugin");
for (auto plugin : plugins) {
auto iexec = plugin->extension<IExecutePlugin>();
......@@ -70,9 +69,13 @@ void LldbDebuggerPlugin::setupToolviews()
*/
}
void LldbDebuggerPlugin::unload()
void LldbDebuggerPlugin::unloadToolviews()
{
core()->uiController()->removeToolView(m_consoleFactory);
if (m_consoleFactory) {
qCDebug(DEBUGGERLLDB) << "Removing toolview";
core()->uiController()->removeToolView(m_consoleFactory);
m_consoleFactory = nullptr;
}
/*
core()->uiController()->removeToolView(m_disassembleFactory);
core()->uiController()->removeToolView(memoryviewerfactory);
......@@ -83,9 +86,9 @@ LldbDebuggerPlugin::~LldbDebuggerPlugin()
{
}
DebugSession* LldbDebuggerPlugin::createSession() const
DebugSession* LldbDebuggerPlugin::createSession()
{
DebugSession *session = new DebugSession();
DebugSession *session = new DebugSession(this);
core()->debugController()->addSession(session);
connect(session, &DebugSession::showMessage, this, &LldbDebuggerPlugin::showStatusMessage);
connect(session, &DebugSession::reset, this, &LldbDebuggerPlugin::reset);
......
......@@ -51,14 +51,11 @@ public:
LldbDebuggerPlugin(QObject *parent, const QVariantList & = QVariantList());
~LldbDebuggerPlugin() override;
DebugSession *createSession() const override;
void unload() override;
DebugSession *createSession() override;
void unloadToolviews() override;
void setupToolviews() override;
private:
void setupToolviews();
private:
DebuggerToolFactory<NonInterruptDebuggerConsoleView> *m_consoleFactory;
DebuggerToolFactory<DisassembleWidget> *m_disassembleFactory;
};
......
......@@ -24,6 +24,7 @@
#include "controllers/variable.h"
#include "dbgglobal.h"
#include "debuggerplugin.h"
#include "debuglog.h"
#include "lldbcommand.h"
#include "mi/micommand.h"
......@@ -59,8 +60,8 @@ QString doubleQuoteArg(QString arg)
return '"' + arg + '"';
}
DebugSession::DebugSession()
: MIDebugSession()
DebugSession::DebugSession(LldbDebuggerPlugin *plugin)
: MIDebugSession(plugin)
, m_breakpointController(nullptr)
, m_variableController(nullptr)
, m_frameStackModel(nullptr)
......@@ -68,10 +69,13 @@ DebugSession::DebugSession()
m_breakpointController = new BreakpointController(this);
m_variableController = new VariableController(this);
m_frameStackModel = new LldbFrameStackModel(this);
if (m_plugin) m_plugin->setupToolviews();
}
DebugSession::~DebugSession()
{
if (m_plugin) m_plugin->unloadToolviews();
}
BreakpointController *DebugSession::breakpointController() const
......
......@@ -25,11 +25,10 @@
#include "midebugsession.h"
#include "lldbdebugger.h"
#include "controllers/breakpointcontroller.h"
#include "controllers/framestackmodel.h"
#include "controllers/variablecontroller.h"
#include "lldbdebugger.h"
namespace KDevelop {
class ILaunchConfiguration;
......@@ -43,11 +42,12 @@ struct ResultRecord;
namespace LLDB {
class LldbDebuggerPlugin;
class DebugSession : public MIDebugSession
{
Q_OBJECT
public:
DebugSession();
explicit DebugSession(LldbDebuggerPlugin *plugin = nullptr);
~DebugSession() override;
BreakpointController * breakpointController() const override;
......@@ -72,6 +72,9 @@ protected:
void ensureDebuggerListening() override;
void setupToolviews();
void unloadToolviews();
private Q_SLOTS:
void handleFileExecAndSymbols(const MI::ResultRecord& r);
void handleTargetSelect(const MI::ResultRecord& r);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment