forked from qt-creator/qt-creator
BareMetal: Minimize dependency from GDB engine
The problem is that this plugin was originally developed
only for working with the GDB debugging engine. This hard
dependency penetrates to all plugin logic, that excludes an
easy addition of other types of a debugger engines.
This patch tries to minimize the GDB dependency and improves
code a bit in the following way:
* A code that belongs to the GDB engine moved to the separate
debugservers/gdb directory.
* A classes having a common functionality are renamed with
'Debug' suffixes instead of 'Gdb' suffixes.
* Introduced a new interface IDebugServerProvider{Factory|ConfigWidget}
whih are used as a base for all derived debug servers
providers (e.g. for the OpenOCD, STLink and etc).
* The IDebugServerProvider interface has a new virtual
engineType() method to show a supported debugger engine by
a specific debugger server provider. This method is used in
BareMetalDebugSupport class to detect a provider engine
for an additional initialization (which depends on an used
debugger engine).
* The IDebugServerProvider interface has a new virtual hasProcess()
method. E.g. this is required for a future debug server providers
which has not a remote processes. In this case the
BareMetalDevice::canCreateProcess() will report about that in
a right way.
Thus, this approach allowed us to preserve a previous behavior
of an already implemented GDB providers. Also it makes possible
to add a new providers in a future with a minimized costs.
Change-Id: I1be84b9178d4aa78c3ef5108a9e6b381e245f36f
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -12,18 +12,19 @@ add_qtc_plugin(BareMetal
|
|||||||
baremetaldeviceconfigurationwizardpages.cpp baremetaldeviceconfigurationwizardpages.h
|
baremetaldeviceconfigurationwizardpages.cpp baremetaldeviceconfigurationwizardpages.h
|
||||||
baremetalplugin.cpp baremetalplugin.h
|
baremetalplugin.cpp baremetalplugin.h
|
||||||
baremetalrunconfiguration.cpp baremetalrunconfiguration.h
|
baremetalrunconfiguration.cpp baremetalrunconfiguration.h
|
||||||
defaultgdbserverprovider.cpp defaultgdbserverprovider.h
|
debugserverproviderchooser.cpp debugserverproviderchooser.h
|
||||||
gdbserverprovider.cpp gdbserverprovider.h
|
debugserverprovidermanager.cpp debugserverprovidermanager.h
|
||||||
gdbserverproviderchooser.cpp gdbserverproviderchooser.h
|
debugserverproviderssettingspage.cpp debugserverproviderssettingspage.h
|
||||||
gdbserverprovidermanager.cpp gdbserverprovidermanager.h
|
debugservers/gdb/defaultgdbserverprovider.cpp debugservers/gdb/defaultgdbserverprovider.h
|
||||||
gdbserverproviderprocess.cpp gdbserverproviderprocess.h
|
debugservers/gdb/gdbserverprovider.cpp debugservers/gdb/gdbserverprovider.h
|
||||||
gdbserverproviderssettingspage.cpp gdbserverproviderssettingspage.h
|
debugservers/gdb/gdbserverproviderprocess.cpp debugservers/gdb/gdbserverproviderprocess.h
|
||||||
|
debugservers/gdb/openocdgdbserverprovider.cpp debugservers/gdb/openocdgdbserverprovider.h
|
||||||
|
debugservers/gdb/stlinkutilgdbserverprovider.cpp debugservers/gdb/stlinkutilgdbserverprovider.h
|
||||||
iarewparser.cpp iarewparser.h
|
iarewparser.cpp iarewparser.h
|
||||||
iarewtoolchain.cpp iarewtoolchain.h
|
iarewtoolchain.cpp iarewtoolchain.h
|
||||||
|
idebugserverprovider.cpp idebugserverprovider.h
|
||||||
keilparser.cpp keilparser.h
|
keilparser.cpp keilparser.h
|
||||||
keiltoolchain.cpp keiltoolchain.h
|
keiltoolchain.cpp keiltoolchain.h
|
||||||
sdccparser.cpp sdccparser.h
|
sdccparser.cpp sdccparser.h
|
||||||
sdcctoolchain.cpp sdcctoolchain.h
|
sdcctoolchain.cpp sdcctoolchain.h
|
||||||
openocdgdbserverprovider.cpp openocdgdbserverprovider.h
|
|
||||||
stlinkutilgdbserverprovider.cpp stlinkutilgdbserverprovider.h
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,54 +1,51 @@
|
|||||||
QT += network
|
QT += network
|
||||||
include(../../qtcreatorplugin.pri)
|
include(../../qtcreatorplugin.pri)
|
||||||
|
|
||||||
|
# GDB debug servers
|
||||||
|
include(debugservers/gdb/gdbservers.pri)
|
||||||
|
|
||||||
# BareMetal files
|
# BareMetal files
|
||||||
|
|
||||||
SOURCES += baremetalplugin.cpp \
|
SOURCES += \
|
||||||
baremetalcustomrunconfiguration.cpp\
|
baremetalcustomrunconfiguration.cpp\
|
||||||
baremetaldevice.cpp \
|
|
||||||
baremetalrunconfiguration.cpp \
|
|
||||||
baremetaldeviceconfigurationwizardpages.cpp \
|
|
||||||
baremetaldeviceconfigurationwizard.cpp \
|
|
||||||
baremetaldeviceconfigurationwidget.cpp \
|
|
||||||
baremetaldebugsupport.cpp \
|
baremetaldebugsupport.cpp \
|
||||||
gdbserverproviderprocess.cpp \
|
baremetaldevice.cpp \
|
||||||
gdbserverproviderssettingspage.cpp \
|
baremetaldeviceconfigurationwidget.cpp \
|
||||||
gdbserverprovider.cpp \
|
baremetaldeviceconfigurationwizard.cpp \
|
||||||
gdbserverproviderchooser.cpp \
|
baremetaldeviceconfigurationwizardpages.cpp \
|
||||||
gdbserverprovidermanager.cpp \
|
baremetalplugin.cpp \
|
||||||
openocdgdbserverprovider.cpp \
|
baremetalrunconfiguration.cpp \
|
||||||
defaultgdbserverprovider.cpp \
|
debugserverproviderchooser.cpp \
|
||||||
stlinkutilgdbserverprovider.cpp \
|
debugserverprovidermanager.cpp \
|
||||||
iarewtoolchain.cpp \
|
debugserverproviderssettingspage.cpp \
|
||||||
keiltoolchain.cpp \
|
|
||||||
sdcctoolchain.cpp \
|
|
||||||
iarewparser.cpp \
|
iarewparser.cpp \
|
||||||
|
iarewtoolchain.cpp \
|
||||||
|
idebugserverprovider.cpp \
|
||||||
keilparser.cpp \
|
keilparser.cpp \
|
||||||
|
keiltoolchain.cpp \
|
||||||
sdccparser.cpp \
|
sdccparser.cpp \
|
||||||
|
sdcctoolchain.cpp
|
||||||
|
|
||||||
HEADERS += baremetalplugin.h \
|
HEADERS += \
|
||||||
baremetalconstants.h \
|
baremetalconstants.h \
|
||||||
baremetalcustomrunconfiguration.h \
|
baremetalcustomrunconfiguration.h \
|
||||||
|
baremetaldebugsupport.h \
|
||||||
baremetaldevice.h \
|
baremetaldevice.h \
|
||||||
baremetalrunconfiguration.h \
|
|
||||||
baremetaldeviceconfigurationwidget.h \
|
baremetaldeviceconfigurationwidget.h \
|
||||||
baremetaldeviceconfigurationwizard.h \
|
baremetaldeviceconfigurationwizard.h \
|
||||||
baremetaldeviceconfigurationwizardpages.h \
|
baremetaldeviceconfigurationwizardpages.h \
|
||||||
baremetaldebugsupport.h \
|
baremetalplugin.h \
|
||||||
gdbserverproviderprocess.h \
|
baremetalrunconfiguration.h \
|
||||||
gdbserverproviderssettingspage.h \
|
debugserverproviderchooser.h \
|
||||||
gdbserverprovider.h \
|
debugserverprovidermanager.h \
|
||||||
gdbserverproviderchooser.h \
|
debugserverproviderssettingspage.h \
|
||||||
gdbserverprovidermanager.h \
|
|
||||||
openocdgdbserverprovider.h \
|
|
||||||
defaultgdbserverprovider.h \
|
|
||||||
stlinkutilgdbserverprovider.h \
|
|
||||||
iarewtoolchain.h \
|
|
||||||
keiltoolchain.h \
|
|
||||||
sdcctoolchain.h \
|
|
||||||
iarewparser.h \
|
iarewparser.h \
|
||||||
|
iarewtoolchain.h \
|
||||||
|
idebugserverprovider.h \
|
||||||
keilparser.h \
|
keilparser.h \
|
||||||
|
keiltoolchain.h \
|
||||||
sdccparser.h \
|
sdccparser.h \
|
||||||
|
sdcctoolchain.h
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
baremetal.qrc
|
baremetal.qrc
|
||||||
|
|||||||
@@ -12,30 +12,41 @@ QtcPlugin {
|
|||||||
Depends { name: "ProjectExplorer" }
|
Depends { name: "ProjectExplorer" }
|
||||||
Depends { name: "TextEditor" }
|
Depends { name: "TextEditor" }
|
||||||
|
|
||||||
files: [
|
Group {
|
||||||
"baremetal.qrc",
|
name: "General"
|
||||||
"baremetalconstants.h",
|
files: [
|
||||||
"baremetalcustomrunconfiguration.cpp", "baremetalcustomrunconfiguration.h",
|
"baremetal.qrc",
|
||||||
"baremetaldevice.cpp", "baremetaldevice.h",
|
"baremetalconstants.h",
|
||||||
"baremetaldeviceconfigurationwidget.cpp", "baremetaldeviceconfigurationwidget.h",
|
"baremetalcustomrunconfiguration.cpp", "baremetalcustomrunconfiguration.h",
|
||||||
"baremetaldeviceconfigurationwizard.cpp", "baremetaldeviceconfigurationwizard.h",
|
"baremetaldebugsupport.cpp", "baremetaldebugsupport.h",
|
||||||
"baremetaldeviceconfigurationwizardpages.cpp", "baremetaldeviceconfigurationwizardpages.h",
|
"baremetaldevice.cpp", "baremetaldevice.h",
|
||||||
"baremetalplugin.cpp", "baremetalplugin.h",
|
"baremetaldeviceconfigurationwidget.cpp", "baremetaldeviceconfigurationwidget.h",
|
||||||
"baremetalrunconfiguration.cpp", "baremetalrunconfiguration.h",
|
"baremetaldeviceconfigurationwizard.cpp", "baremetaldeviceconfigurationwizard.h",
|
||||||
"baremetaldebugsupport.cpp", "baremetaldebugsupport.h",
|
"baremetaldeviceconfigurationwizardpages.cpp", "baremetaldeviceconfigurationwizardpages.h",
|
||||||
"gdbserverproviderprocess.cpp", "gdbserverproviderprocess.h",
|
"baremetalplugin.cpp", "baremetalplugin.h",
|
||||||
"gdbserverproviderssettingspage.cpp", "gdbserverproviderssettingspage.h",
|
"baremetalrunconfiguration.cpp", "baremetalrunconfiguration.h",
|
||||||
"gdbserverprovider.cpp", "gdbserverprovider.h",
|
"debugserverproviderchooser.cpp", "debugserverproviderchooser.h",
|
||||||
"gdbserverproviderchooser.cpp", "gdbserverproviderchooser.h",
|
"debugserverprovidermanager.cpp", "debugserverprovidermanager.h",
|
||||||
"gdbserverprovidermanager.cpp", "gdbserverprovidermanager.h",
|
"debugserverproviderssettingspage.cpp", "debugserverproviderssettingspage.h",
|
||||||
"openocdgdbserverprovider.cpp", "openocdgdbserverprovider.h",
|
"iarewparser.cpp", "iarewparser.h",
|
||||||
"defaultgdbserverprovider.cpp", "defaultgdbserverprovider.h",
|
"iarewtoolchain.cpp", "iarewtoolchain.h",
|
||||||
"stlinkutilgdbserverprovider.cpp", "stlinkutilgdbserverprovider.h",
|
"idebugserverprovider.cpp", "idebugserverprovider.h",
|
||||||
"iarewtoolchain.cpp", "iarewtoolchain.h",
|
"keilparser.cpp", "keilparser.h",
|
||||||
"keiltoolchain.cpp", "keiltoolchain.h",
|
"keiltoolchain.cpp", "keiltoolchain.h",
|
||||||
"sdcctoolchain.cpp", "sdcctoolchain.h",
|
"sdccparser.cpp", "sdccparser.h",
|
||||||
"iarewparser.cpp", "iarewparser.h",
|
"sdcctoolchain.cpp", "sdcctoolchain.h",
|
||||||
"keilparser.cpp", "keilparser.h",
|
]
|
||||||
"sdccparser.cpp", "sdccparser.h",
|
}
|
||||||
]
|
|
||||||
|
Group {
|
||||||
|
name: "GDB Servers"
|
||||||
|
prefix: "debugservers/gdb/"
|
||||||
|
files: [
|
||||||
|
"defaultgdbserverprovider.cpp", "defaultgdbserverprovider.h",
|
||||||
|
"gdbserverprovider.cpp", "gdbserverprovider.h",
|
||||||
|
"gdbserverproviderprocess.cpp", "gdbserverproviderprocess.h",
|
||||||
|
"openocdgdbserverprovider.cpp", "openocdgdbserverprovider.h",
|
||||||
|
"stlinkutilgdbserverprovider.cpp", "stlinkutilgdbserverprovider.h",
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,10 @@
|
|||||||
#include "baremetaldebugsupport.h"
|
#include "baremetaldebugsupport.h"
|
||||||
#include "baremetaldevice.h"
|
#include "baremetaldevice.h"
|
||||||
|
|
||||||
#include "gdbserverprovider.h"
|
#include "debugserverprovidermanager.h"
|
||||||
#include "gdbserverprovidermanager.h"
|
#include "idebugserverprovider.h"
|
||||||
|
|
||||||
|
#include "debugservers/gdb/gdbserverprovider.h"
|
||||||
|
|
||||||
#include <debugger/debuggerkitinformation.h>
|
#include <debugger/debuggerkitinformation.h>
|
||||||
#include <debugger/debuggerruncontrol.h>
|
#include <debugger/debuggerruncontrol.h>
|
||||||
@@ -54,18 +56,6 @@ namespace Internal {
|
|||||||
|
|
||||||
// BareMetalDebugSupport
|
// BareMetalDebugSupport
|
||||||
|
|
||||||
class BareMetalGdbServer : public SimpleTargetRunner
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
BareMetalGdbServer(RunControl *runControl, const Runnable &runnable)
|
|
||||||
: SimpleTargetRunner(runControl)
|
|
||||||
{
|
|
||||||
setId("BareMetalGdbServer");
|
|
||||||
// Baremetal's GDB servers are launched on the host, not on the target.
|
|
||||||
setStarter([this, runnable] { doStart(runnable, {}); });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
BareMetalDebugSupport::BareMetalDebugSupport(RunControl *runControl)
|
BareMetalDebugSupport::BareMetalDebugSupport(RunControl *runControl)
|
||||||
: Debugger::DebuggerRunTool(runControl)
|
: Debugger::DebuggerRunTool(runControl)
|
||||||
{
|
{
|
||||||
@@ -75,42 +65,48 @@ BareMetalDebugSupport::BareMetalDebugSupport(RunControl *runControl)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString providerId = dev->gdbServerProviderId();
|
const QString providerId = dev->debugServerProviderId();
|
||||||
const GdbServerProvider *p = GdbServerProviderManager::findProvider(providerId);
|
const IDebugServerProvider *p = DebugServerProviderManager::findProvider(providerId);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
reportFailure(tr("No GDB server provider found for %1").arg(providerId));
|
reportFailure(tr("No debug server provider found for %1").arg(providerId));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->startupMode() == GdbServerProvider::StartupOnNetwork) {
|
addTargetRunnerForProvider(p, runControl);
|
||||||
Runnable r;
|
|
||||||
r.setCommandLine(p->command());
|
|
||||||
// Command arguments are in host OS style as the bare metal's GDB servers are launched
|
|
||||||
// on the host, not on that target.
|
|
||||||
auto gdbServer = new BareMetalGdbServer(runControl, r);
|
|
||||||
addStartDependency(gdbServer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BareMetalDebugSupport::start()
|
void BareMetalDebugSupport::start()
|
||||||
{
|
{
|
||||||
|
const auto dev = qSharedPointerCast<const BareMetalDevice>(device());
|
||||||
|
QTC_ASSERT(dev, reportFailure(); return);
|
||||||
|
const IDebugServerProvider *p = DebugServerProviderManager::findProvider(
|
||||||
|
dev->debugServerProviderId());
|
||||||
|
QTC_ASSERT(p, reportFailure(); return);
|
||||||
|
|
||||||
|
if (aboutToStart(p))
|
||||||
|
DebuggerRunTool::start();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BareMetalDebugSupport::aboutToStart(const IDebugServerProvider *provider)
|
||||||
|
{
|
||||||
|
if (provider->engineType() != Debugger::GdbEngineType)
|
||||||
|
return true;
|
||||||
|
|
||||||
const auto exeAspect = runControl()->aspect<ExecutableAspect>();
|
const auto exeAspect = runControl()->aspect<ExecutableAspect>();
|
||||||
QTC_ASSERT(exeAspect, reportFailure(); return);
|
QTC_ASSERT(exeAspect, reportFailure(); return false);
|
||||||
|
|
||||||
const FilePath bin = exeAspect->executable();
|
const FilePath bin = exeAspect->executable();
|
||||||
if (bin.isEmpty()) {
|
if (bin.isEmpty()) {
|
||||||
reportFailure(tr("Cannot debug: Local executable is not set."));
|
reportFailure(tr("Cannot debug: Local executable is not set."));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if (!bin.exists()) {
|
if (!bin.exists()) {
|
||||||
reportFailure(tr("Cannot debug: Could not find executable for \"%1\".").arg(bin.toString()));
|
reportFailure(tr("Cannot debug: Could not find executable for \"%1\".")
|
||||||
return;
|
.arg(bin.toString()));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto dev = qSharedPointerCast<const BareMetalDevice>(device());
|
const auto gdbProvider = static_cast<const GdbServerProvider *>(provider);
|
||||||
QTC_ASSERT(dev, reportFailure(); return);
|
|
||||||
const GdbServerProvider *p = GdbServerProviderManager::findProvider(dev->gdbServerProviderId());
|
|
||||||
QTC_ASSERT(p, reportFailure(); return);
|
|
||||||
|
|
||||||
Runnable inferior;
|
Runnable inferior;
|
||||||
inferior.executable = bin;
|
inferior.executable = bin;
|
||||||
@@ -119,13 +115,28 @@ void BareMetalDebugSupport::start()
|
|||||||
setInferior(inferior);
|
setInferior(inferior);
|
||||||
setSymbolFile(bin);
|
setSymbolFile(bin);
|
||||||
setStartMode(AttachToRemoteServer);
|
setStartMode(AttachToRemoteServer);
|
||||||
setCommandsAfterConnect(p->initCommands()); // .. and here?
|
setCommandsAfterConnect(gdbProvider->initCommands()); // .. and here?
|
||||||
setCommandsForReset(p->resetCommands());
|
setCommandsForReset(gdbProvider->resetCommands());
|
||||||
setRemoteChannel(p->channelString());
|
setRemoteChannel(gdbProvider->channelString());
|
||||||
setUseContinueInsteadOfRun(true);
|
setUseContinueInsteadOfRun(true);
|
||||||
setUseExtendedRemote(p->useExtendedRemote());
|
setUseExtendedRemote(gdbProvider->useExtendedRemote());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
DebuggerRunTool::start();
|
void BareMetalDebugSupport::addTargetRunnerForProvider(const IDebugServerProvider *provider,
|
||||||
|
ProjectExplorer::RunControl *runControl)
|
||||||
|
{
|
||||||
|
if (provider->engineType() != Debugger::GdbEngineType)
|
||||||
|
return;
|
||||||
|
const auto gdbProvider = static_cast<const GdbServerProvider *>(provider);
|
||||||
|
if (gdbProvider->startupMode() == GdbServerProvider::StartupOnNetwork) {
|
||||||
|
Runnable r;
|
||||||
|
r.setCommandLine(gdbProvider->command());
|
||||||
|
// Command arguments are in host OS style as the bare metal's GDB servers are launched
|
||||||
|
// on the host, not on that target.
|
||||||
|
const auto gdbServer = new GdbServerProviderRunner(runControl, r);
|
||||||
|
addStartDependency(gdbServer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -27,9 +27,15 @@
|
|||||||
|
|
||||||
#include <debugger/debuggerruncontrol.h>
|
#include <debugger/debuggerruncontrol.h>
|
||||||
|
|
||||||
|
namespace ProjectExplorer {
|
||||||
|
class RunControl;
|
||||||
|
}
|
||||||
|
|
||||||
namespace BareMetal {
|
namespace BareMetal {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
class IDebugServerProvider;
|
||||||
|
|
||||||
// BareMetalDebugSupport
|
// BareMetalDebugSupport
|
||||||
|
|
||||||
class BareMetalDebugSupport final : public Debugger::DebuggerRunTool
|
class BareMetalDebugSupport final : public Debugger::DebuggerRunTool
|
||||||
@@ -41,6 +47,9 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void start() final;
|
void start() final;
|
||||||
|
bool aboutToStart(const IDebugServerProvider *provider);
|
||||||
|
void addTargetRunnerForProvider(const IDebugServerProvider *provider,
|
||||||
|
ProjectExplorer::RunControl *runControl);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -28,11 +28,11 @@
|
|||||||
#include "baremetaldevice.h"
|
#include "baremetaldevice.h"
|
||||||
#include "baremetaldeviceconfigurationwidget.h"
|
#include "baremetaldeviceconfigurationwidget.h"
|
||||||
#include "baremetaldeviceconfigurationwizard.h"
|
#include "baremetaldeviceconfigurationwizard.h"
|
||||||
|
#include "debugserverprovidermanager.h"
|
||||||
|
|
||||||
#include "defaultgdbserverprovider.h"
|
// GDB server providers.
|
||||||
|
#include "debugservers/gdb/defaultgdbserverprovider.h"
|
||||||
#include "gdbserverprovidermanager.h"
|
#include "debugservers/gdb/gdbserverproviderprocess.h"
|
||||||
#include "gdbserverproviderprocess.h"
|
|
||||||
|
|
||||||
#include <coreplugin/id.h>
|
#include <coreplugin/id.h>
|
||||||
|
|
||||||
@@ -46,63 +46,72 @@ using namespace ProjectExplorer;
|
|||||||
namespace BareMetal {
|
namespace BareMetal {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
const char gdbServerProviderIdKeyC[] = "GdbServerProviderId";
|
const char debugServerProviderIdKeyC[] = "IDebugServerProviderId";
|
||||||
|
|
||||||
// BareMetalDevice
|
// BareMetalDevice
|
||||||
|
|
||||||
BareMetalDevice::BareMetalDevice()
|
BareMetalDevice::BareMetalDevice()
|
||||||
{
|
{
|
||||||
setDisplayType(QCoreApplication::translate("BareMetal::Internal::BareMetalDevice", "Bare Metal"));
|
setDisplayType(QCoreApplication::translate("BareMetal::Internal::BareMetalDevice",
|
||||||
|
"Bare Metal"));
|
||||||
setDefaultDisplayName(defaultDisplayName());
|
setDefaultDisplayName(defaultDisplayName());
|
||||||
setOsType(Utils::OsTypeOther);
|
setOsType(Utils::OsTypeOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
BareMetalDevice::~BareMetalDevice()
|
BareMetalDevice::~BareMetalDevice()
|
||||||
{
|
{
|
||||||
if (GdbServerProvider *provider = GdbServerProviderManager::findProvider(m_gdbServerProviderId))
|
if (IDebugServerProvider *provider = DebugServerProviderManager::findProvider(
|
||||||
|
m_debugServerProviderId))
|
||||||
provider->unregisterDevice(this);
|
provider->unregisterDevice(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BareMetalDevice::defaultDisplayName()
|
QString BareMetalDevice::defaultDisplayName()
|
||||||
{
|
{
|
||||||
return QCoreApplication::translate("BareMetal::Internal::BareMetalDevice", "Bare Metal Device");
|
return QCoreApplication::translate("BareMetal::Internal::BareMetalDevice",
|
||||||
|
"Bare Metal Device");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BareMetalDevice::gdbServerProviderId() const
|
QString BareMetalDevice::debugServerProviderId() const
|
||||||
{
|
{
|
||||||
return m_gdbServerProviderId;
|
return m_debugServerProviderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BareMetalDevice::setGdbServerProviderId(const QString &id)
|
void BareMetalDevice::setDebugServerProviderId(const QString &id)
|
||||||
{
|
{
|
||||||
if (id == m_gdbServerProviderId)
|
if (id == m_debugServerProviderId)
|
||||||
return;
|
return;
|
||||||
if (GdbServerProvider *currentProvider = GdbServerProviderManager::findProvider(m_gdbServerProviderId))
|
if (IDebugServerProvider *currentProvider =
|
||||||
|
DebugServerProviderManager::findProvider(m_debugServerProviderId))
|
||||||
currentProvider->unregisterDevice(this);
|
currentProvider->unregisterDevice(this);
|
||||||
m_gdbServerProviderId = id;
|
m_debugServerProviderId = id;
|
||||||
if (GdbServerProvider *provider = GdbServerProviderManager::findProvider(id)) {
|
if (IDebugServerProvider *provider = DebugServerProviderManager::findProvider(id)) {
|
||||||
setChannelByServerProvider(provider);
|
setChannelByServerProvider(provider);
|
||||||
provider->registerDevice(this);
|
provider->registerDevice(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BareMetalDevice::unregisterProvider(GdbServerProvider *provider)
|
void BareMetalDevice::unregisterDebugServerProvider(IDebugServerProvider *provider)
|
||||||
{
|
{
|
||||||
if (provider->id() == m_gdbServerProviderId)
|
if (provider->id() == m_debugServerProviderId)
|
||||||
m_gdbServerProviderId.clear();
|
m_debugServerProviderId.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BareMetalDevice::providerUpdated(GdbServerProvider *provider)
|
void BareMetalDevice::debugServerProviderUpdated(IDebugServerProvider *provider)
|
||||||
{
|
{
|
||||||
GdbServerProvider *myProvider = GdbServerProviderManager::findProvider(m_gdbServerProviderId);
|
IDebugServerProvider *myProvider = DebugServerProviderManager::findProvider(
|
||||||
|
m_debugServerProviderId);
|
||||||
if (provider == myProvider)
|
if (provider == myProvider)
|
||||||
setChannelByServerProvider(provider);
|
setChannelByServerProvider(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BareMetalDevice::setChannelByServerProvider(GdbServerProvider *provider)
|
void BareMetalDevice::setChannelByServerProvider(IDebugServerProvider *provider)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(provider, return);
|
QTC_ASSERT(provider, return);
|
||||||
const QString channel = provider->channelString();
|
if (provider->engineType() != Debugger::GdbEngineType)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const auto gdbProvider = static_cast<GdbServerProvider *>(provider);
|
||||||
|
const QString channel = gdbProvider->channelString();
|
||||||
const int colon = channel.indexOf(QLatin1Char(':'));
|
const int colon = channel.indexOf(QLatin1Char(':'));
|
||||||
if (colon < 0)
|
if (colon < 0)
|
||||||
return;
|
return;
|
||||||
@@ -115,29 +124,30 @@ void BareMetalDevice::setChannelByServerProvider(GdbServerProvider *provider)
|
|||||||
void BareMetalDevice::fromMap(const QVariantMap &map)
|
void BareMetalDevice::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
IDevice::fromMap(map);
|
IDevice::fromMap(map);
|
||||||
QString gdbServerProvider = map.value(QLatin1String(gdbServerProviderIdKeyC)).toString();
|
QString providerId = map.value(QLatin1String(debugServerProviderIdKeyC)).toString();
|
||||||
if (gdbServerProvider.isEmpty()) {
|
if (providerId.isEmpty()) {
|
||||||
const QString name = displayName();
|
const QString name = displayName();
|
||||||
if (GdbServerProvider *provider = GdbServerProviderManager::findByDisplayName(name)) {
|
if (IDebugServerProvider *provider =
|
||||||
gdbServerProvider = provider->id();
|
DebugServerProviderManager::findByDisplayName(name)) {
|
||||||
|
providerId = provider->id();
|
||||||
} else {
|
} else {
|
||||||
const QSsh::SshConnectionParameters sshParams = sshParameters();
|
const QSsh::SshConnectionParameters sshParams = sshParameters();
|
||||||
const auto newProvider = new DefaultGdbServerProvider;
|
const auto newProvider = new DefaultGdbServerProvider;
|
||||||
newProvider->setChannel(sshParams.url);
|
newProvider->setChannel(sshParams.url);
|
||||||
newProvider->setDisplayName(name);
|
newProvider->setDisplayName(name);
|
||||||
if (GdbServerProviderManager::registerProvider(newProvider))
|
if (DebugServerProviderManager::registerProvider(newProvider))
|
||||||
gdbServerProvider = newProvider->id();
|
providerId = newProvider->id();
|
||||||
else
|
else
|
||||||
delete newProvider;
|
delete newProvider;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setGdbServerProviderId(gdbServerProvider);
|
setDebugServerProviderId(providerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap BareMetalDevice::toMap() const
|
QVariantMap BareMetalDevice::toMap() const
|
||||||
{
|
{
|
||||||
QVariantMap map = IDevice::toMap();
|
QVariantMap map = IDevice::toMap();
|
||||||
map.insert(QLatin1String(gdbServerProviderIdKeyC), gdbServerProviderId());
|
map.insert(QLatin1String(debugServerProviderIdKeyC), debugServerProviderId());
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,9 +161,26 @@ IDeviceWidget *BareMetalDevice::createWidget()
|
|||||||
return new BareMetalDeviceConfigurationWidget(sharedFromThis());
|
return new BareMetalDeviceConfigurationWidget(sharedFromThis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BareMetalDevice::canCreateProcess() const
|
||||||
|
{
|
||||||
|
if (IDebugServerProvider *provider = DebugServerProviderManager::findProvider(
|
||||||
|
m_debugServerProviderId)) {
|
||||||
|
if (provider->engineType() == Debugger::GdbEngineType)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
DeviceProcess *BareMetalDevice::createProcess(QObject *parent) const
|
DeviceProcess *BareMetalDevice::createProcess(QObject *parent) const
|
||||||
{
|
{
|
||||||
return new GdbServerProviderProcess(sharedFromThis(), parent);
|
if (IDebugServerProvider *provider = DebugServerProviderManager::findProvider(
|
||||||
|
m_debugServerProviderId)) {
|
||||||
|
if (provider->engineType() == Debugger::GdbEngineType)
|
||||||
|
return new GdbServerProviderProcess(sharedFromThis(), parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Factory
|
// Factory
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
namespace BareMetal {
|
namespace BareMetal {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class GdbServerProvider;
|
class IDebugServerProvider;
|
||||||
|
|
||||||
// BareMetalDevice
|
// BareMetalDevice
|
||||||
|
|
||||||
@@ -51,13 +51,13 @@ public:
|
|||||||
|
|
||||||
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const final;
|
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const final;
|
||||||
|
|
||||||
bool canCreateProcess() const final { return true; }
|
bool canCreateProcess() const final;
|
||||||
ProjectExplorer::DeviceProcess *createProcess(QObject *parent) const final;
|
ProjectExplorer::DeviceProcess *createProcess(QObject *parent) const final;
|
||||||
|
|
||||||
QString gdbServerProviderId() const;
|
QString debugServerProviderId() const;
|
||||||
void setGdbServerProviderId(const QString &id);
|
void setDebugServerProviderId(const QString &id);
|
||||||
void unregisterProvider(GdbServerProvider *provider);
|
void unregisterDebugServerProvider(IDebugServerProvider *provider);
|
||||||
void providerUpdated(GdbServerProvider *provider);
|
void debugServerProviderUpdated(IDebugServerProvider *provider);
|
||||||
|
|
||||||
void fromMap(const QVariantMap &map) final;
|
void fromMap(const QVariantMap &map) final;
|
||||||
QVariantMap toMap() const final;
|
QVariantMap toMap() const final;
|
||||||
@@ -65,8 +65,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
BareMetalDevice();
|
BareMetalDevice();
|
||||||
|
|
||||||
void setChannelByServerProvider(GdbServerProvider *provider);
|
// Only for GDB servers!
|
||||||
QString m_gdbServerProviderId;
|
void setChannelByServerProvider(IDebugServerProvider *provider);
|
||||||
|
|
||||||
|
QString m_debugServerProviderId;
|
||||||
};
|
};
|
||||||
|
|
||||||
// BareMetalDeviceFactory
|
// BareMetalDeviceFactory
|
||||||
|
|||||||
@@ -27,8 +27,8 @@
|
|||||||
#include "baremetaldevice.h"
|
#include "baremetaldevice.h"
|
||||||
#include "baremetaldeviceconfigurationwidget.h"
|
#include "baremetaldeviceconfigurationwidget.h"
|
||||||
|
|
||||||
#include "gdbserverprovider.h"
|
#include "debugserverproviderchooser.h"
|
||||||
#include "gdbserverproviderchooser.h"
|
#include "idebugserverprovider.h"
|
||||||
|
|
||||||
#include <utils/pathchooser.h>
|
#include <utils/pathchooser.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -50,13 +50,13 @@ BareMetalDeviceConfigurationWidget::BareMetalDeviceConfigurationWidget(
|
|||||||
const auto formLayout = new QFormLayout(this);
|
const auto formLayout = new QFormLayout(this);
|
||||||
formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
||||||
|
|
||||||
m_gdbServerProviderChooser = new GdbServerProviderChooser(true, this);
|
m_debugServerProviderChooser = new DebugServerProviderChooser(true, this);
|
||||||
m_gdbServerProviderChooser->populate();
|
m_debugServerProviderChooser->populate();
|
||||||
m_gdbServerProviderChooser->setCurrentProviderId(dev->gdbServerProviderId());
|
m_debugServerProviderChooser->setCurrentProviderId(dev->debugServerProviderId());
|
||||||
formLayout->addRow(tr("GDB server provider:"), m_gdbServerProviderChooser);
|
formLayout->addRow(tr("Debug server provider:"), m_debugServerProviderChooser);
|
||||||
|
|
||||||
connect(m_gdbServerProviderChooser, &GdbServerProviderChooser::providerChanged,
|
connect(m_debugServerProviderChooser, &DebugServerProviderChooser::providerChanged,
|
||||||
this, &BareMetalDeviceConfigurationWidget::gdbServerProviderChanged);
|
this, &BareMetalDeviceConfigurationWidget::debugServerProviderChanged);
|
||||||
|
|
||||||
m_peripheralDescriptionFileChooser = new Utils::PathChooser(this);
|
m_peripheralDescriptionFileChooser = new Utils::PathChooser(this);
|
||||||
m_peripheralDescriptionFileChooser->setExpectedKind(Utils::PathChooser::File);
|
m_peripheralDescriptionFileChooser->setExpectedKind(Utils::PathChooser::File);
|
||||||
@@ -72,11 +72,11 @@ BareMetalDeviceConfigurationWidget::BareMetalDeviceConfigurationWidget(
|
|||||||
this, &BareMetalDeviceConfigurationWidget::peripheralDescriptionFileChanged);
|
this, &BareMetalDeviceConfigurationWidget::peripheralDescriptionFileChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BareMetalDeviceConfigurationWidget::gdbServerProviderChanged()
|
void BareMetalDeviceConfigurationWidget::debugServerProviderChanged()
|
||||||
{
|
{
|
||||||
const auto dev = qSharedPointerCast<BareMetalDevice>(device());
|
const auto dev = qSharedPointerCast<BareMetalDevice>(device());
|
||||||
QTC_ASSERT(dev, return);
|
QTC_ASSERT(dev, return);
|
||||||
dev->setGdbServerProviderId(m_gdbServerProviderChooser->currentProviderId());
|
dev->setDebugServerProviderId(m_debugServerProviderChooser->currentProviderId());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BareMetalDeviceConfigurationWidget::peripheralDescriptionFileChanged()
|
void BareMetalDeviceConfigurationWidget::peripheralDescriptionFileChanged()
|
||||||
@@ -88,7 +88,7 @@ void BareMetalDeviceConfigurationWidget::peripheralDescriptionFileChanged()
|
|||||||
|
|
||||||
void BareMetalDeviceConfigurationWidget::updateDeviceFromUi()
|
void BareMetalDeviceConfigurationWidget::updateDeviceFromUi()
|
||||||
{
|
{
|
||||||
gdbServerProviderChanged();
|
debugServerProviderChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace Utils { class PathChooser; }
|
|||||||
namespace BareMetal {
|
namespace BareMetal {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class GdbServerProviderChooser;
|
class DebugServerProviderChooser;
|
||||||
|
|
||||||
// BareMetalDeviceConfigurationWidget
|
// BareMetalDeviceConfigurationWidget
|
||||||
|
|
||||||
@@ -46,11 +46,11 @@ public:
|
|||||||
explicit BareMetalDeviceConfigurationWidget(const ProjectExplorer::IDevice::Ptr &deviceConfig);
|
explicit BareMetalDeviceConfigurationWidget(const ProjectExplorer::IDevice::Ptr &deviceConfig);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void gdbServerProviderChanged();
|
void debugServerProviderChanged();
|
||||||
void peripheralDescriptionFileChanged();
|
void peripheralDescriptionFileChanged();
|
||||||
void updateDeviceFromUi() final;
|
void updateDeviceFromUi() final;
|
||||||
|
|
||||||
GdbServerProviderChooser *m_gdbServerProviderChooser = nullptr;
|
DebugServerProviderChooser *m_debugServerProviderChooser = nullptr;
|
||||||
Utils::PathChooser *m_peripheralDescriptionFileChooser = nullptr;
|
Utils::PathChooser *m_peripheralDescriptionFileChooser = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ ProjectExplorer::IDevice::Ptr BareMetalDeviceConfigurationWizard::device() const
|
|||||||
dev->setDisplayName(m_setupPage->configurationName());
|
dev->setDisplayName(m_setupPage->configurationName());
|
||||||
dev->setType(Constants::BareMetalOsType);
|
dev->setType(Constants::BareMetalOsType);
|
||||||
dev->setMachineType(ProjectExplorer::IDevice::Hardware);
|
dev->setMachineType(ProjectExplorer::IDevice::Hardware);
|
||||||
dev->setGdbServerProviderId(m_setupPage->gdbServerProviderId());
|
dev->setDebugServerProviderId(m_setupPage->debugServerProviderId());
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
#include "baremetaldevice.h"
|
#include "baremetaldevice.h"
|
||||||
#include "baremetaldeviceconfigurationwizardpages.h"
|
#include "baremetaldeviceconfigurationwizardpages.h"
|
||||||
|
|
||||||
#include "gdbserverproviderchooser.h"
|
#include "debugserverproviderchooser.h"
|
||||||
|
|
||||||
#include <coreplugin/variablechooser.h>
|
#include <coreplugin/variablechooser.h>
|
||||||
#include <projectexplorer/devicesupport/idevice.h>
|
#include <projectexplorer/devicesupport/idevice.h>
|
||||||
@@ -44,19 +44,19 @@ BareMetalDeviceConfigurationWizardSetupPage::BareMetalDeviceConfigurationWizardS
|
|||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
: QWizardPage(parent)
|
: QWizardPage(parent)
|
||||||
{
|
{
|
||||||
setTitle(tr("Set up GDB Server or Hardware Debugger"));
|
setTitle(tr("Set up Debug Server or Hardware Debugger"));
|
||||||
|
|
||||||
const auto formLayout = new QFormLayout(this);
|
const auto formLayout = new QFormLayout(this);
|
||||||
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
||||||
m_nameLineEdit = new QLineEdit(this);
|
m_nameLineEdit = new QLineEdit(this);
|
||||||
formLayout->addRow(tr("Name:"), m_nameLineEdit);
|
formLayout->addRow(tr("Name:"), m_nameLineEdit);
|
||||||
m_gdbServerProviderChooser = new GdbServerProviderChooser(false, this);
|
m_debugServerProviderChooser = new DebugServerProviderChooser(false, this);
|
||||||
m_gdbServerProviderChooser->populate();
|
m_debugServerProviderChooser->populate();
|
||||||
formLayout->addRow(tr("GDB server provider:"), m_gdbServerProviderChooser);
|
formLayout->addRow(tr("Debug server provider:"), m_debugServerProviderChooser);
|
||||||
|
|
||||||
connect(m_nameLineEdit, &QLineEdit::textChanged,
|
connect(m_nameLineEdit, &QLineEdit::textChanged,
|
||||||
this, &BareMetalDeviceConfigurationWizardSetupPage::completeChanged);
|
this, &BareMetalDeviceConfigurationWizardSetupPage::completeChanged);
|
||||||
connect(m_gdbServerProviderChooser, &GdbServerProviderChooser::providerChanged,
|
connect(m_debugServerProviderChooser, &DebugServerProviderChooser::providerChanged,
|
||||||
this, &QWizardPage::completeChanged);
|
this, &QWizardPage::completeChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,9 +75,9 @@ QString BareMetalDeviceConfigurationWizardSetupPage::configurationName() const
|
|||||||
return m_nameLineEdit->text().trimmed();
|
return m_nameLineEdit->text().trimmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BareMetalDeviceConfigurationWizardSetupPage::gdbServerProviderId() const
|
QString BareMetalDeviceConfigurationWizardSetupPage::debugServerProviderId() const
|
||||||
{
|
{
|
||||||
return m_gdbServerProviderChooser->currentProviderId();
|
return m_debugServerProviderChooser->currentProviderId();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ QT_END_NAMESPACE
|
|||||||
namespace BareMetal {
|
namespace BareMetal {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class GdbServerProviderChooser;
|
class DebugServerProviderChooser;
|
||||||
|
|
||||||
// BareMetalDeviceConfigurationWizardSetupPage
|
// BareMetalDeviceConfigurationWizardSetupPage
|
||||||
|
|
||||||
@@ -49,11 +49,11 @@ public:
|
|||||||
void initializePage() final;
|
void initializePage() final;
|
||||||
bool isComplete() const final;
|
bool isComplete() const final;
|
||||||
QString configurationName() const;
|
QString configurationName() const;
|
||||||
QString gdbServerProviderId() const;
|
QString debugServerProviderId() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QLineEdit *m_nameLineEdit = nullptr;
|
QLineEdit *m_nameLineEdit = nullptr;
|
||||||
GdbServerProviderChooser *m_gdbServerProviderChooser = nullptr;
|
DebugServerProviderChooser *m_debugServerProviderChooser = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -31,8 +31,8 @@
|
|||||||
#include "baremetalplugin.h"
|
#include "baremetalplugin.h"
|
||||||
#include "baremetalrunconfiguration.h"
|
#include "baremetalrunconfiguration.h"
|
||||||
|
|
||||||
#include "gdbserverprovidermanager.h"
|
#include "debugserverprovidermanager.h"
|
||||||
#include "gdbserverproviderssettingspage.h"
|
#include "debugserverproviderssettingspage.h"
|
||||||
|
|
||||||
#include "iarewtoolchain.h"
|
#include "iarewtoolchain.h"
|
||||||
#include "keiltoolchain.h"
|
#include "keiltoolchain.h"
|
||||||
@@ -76,8 +76,8 @@ public:
|
|||||||
BareMetalDeviceFactory deviceFactory;
|
BareMetalDeviceFactory deviceFactory;
|
||||||
BareMetalRunConfigurationFactory runConfigurationFactory;
|
BareMetalRunConfigurationFactory runConfigurationFactory;
|
||||||
BareMetalCustomRunConfigurationFactory customRunConfigurationFactory;
|
BareMetalCustomRunConfigurationFactory customRunConfigurationFactory;
|
||||||
GdbServerProvidersSettingsPage gdbServerProviderSettinsPage;
|
DebugServerProvidersSettingsPage debugServerProviderSettinsPage;
|
||||||
GdbServerProviderManager gdbServerProviderManager;
|
DebugServerProviderManager debugServerProviderManager;
|
||||||
BareMetalDeployConfigurationFactory deployConfigurationFactory;
|
BareMetalDeployConfigurationFactory deployConfigurationFactory;
|
||||||
|
|
||||||
RunWorkerFactory runWorkerFactory{
|
RunWorkerFactory runWorkerFactory{
|
||||||
@@ -105,7 +105,7 @@ bool BareMetalPlugin::initialize(const QStringList &arguments, QString *errorStr
|
|||||||
|
|
||||||
void BareMetalPlugin::extensionsInitialized()
|
void BareMetalPlugin::extensionsInitialized()
|
||||||
{
|
{
|
||||||
GdbServerProviderManager::instance()->restoreProviders();
|
DebugServerProviderManager::instance()->restoreProviders();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
#include "baremetalconstants.h"
|
#include "baremetalconstants.h"
|
||||||
|
|
||||||
#include "gdbserverprovider.h"
|
#include "debugserverproviderchooser.h"
|
||||||
#include "gdbserverproviderchooser.h"
|
#include "debugserverprovidermanager.h"
|
||||||
#include "gdbserverprovidermanager.h"
|
#include "idebugserverprovider.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
@@ -39,9 +39,9 @@
|
|||||||
namespace BareMetal {
|
namespace BareMetal {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
// GdbServerProviderChooser
|
// DebugServerProviderChooser
|
||||||
|
|
||||||
GdbServerProviderChooser::GdbServerProviderChooser(
|
DebugServerProviderChooser::DebugServerProviderChooser(
|
||||||
bool useManageButton, QWidget *parent)
|
bool useManageButton, QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
@@ -58,20 +58,20 @@ GdbServerProviderChooser::GdbServerProviderChooser(
|
|||||||
setFocusProxy(m_manageButton);
|
setFocusProxy(m_manageButton);
|
||||||
|
|
||||||
connect(m_chooser, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
connect(m_chooser, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &GdbServerProviderChooser::currentIndexChanged);
|
this, &DebugServerProviderChooser::currentIndexChanged);
|
||||||
connect(m_manageButton, &QAbstractButton::clicked,
|
connect(m_manageButton, &QAbstractButton::clicked,
|
||||||
this, &GdbServerProviderChooser::manageButtonClicked);
|
this, &DebugServerProviderChooser::manageButtonClicked);
|
||||||
connect(GdbServerProviderManager::instance(), &GdbServerProviderManager::providersChanged,
|
connect(DebugServerProviderManager::instance(), &DebugServerProviderManager::providersChanged,
|
||||||
this, &GdbServerProviderChooser::populate);
|
this, &DebugServerProviderChooser::populate);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GdbServerProviderChooser::currentProviderId() const
|
QString DebugServerProviderChooser::currentProviderId() const
|
||||||
{
|
{
|
||||||
const int idx = m_chooser->currentIndex();
|
const int idx = m_chooser->currentIndex();
|
||||||
return qvariant_cast<QString>(m_chooser->itemData(idx));
|
return qvariant_cast<QString>(m_chooser->itemData(idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProviderChooser::setCurrentProviderId(const QString &id)
|
void DebugServerProviderChooser::setCurrentProviderId(const QString &id)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_chooser->count(); ++i) {
|
for (int i = 0; i < m_chooser->count(); ++i) {
|
||||||
if (id != qvariant_cast<QString>(m_chooser->itemData(i)))
|
if (id != qvariant_cast<QString>(m_chooser->itemData(i)))
|
||||||
@@ -80,34 +80,34 @@ void GdbServerProviderChooser::setCurrentProviderId(const QString &id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProviderChooser::manageButtonClicked()
|
void DebugServerProviderChooser::manageButtonClicked()
|
||||||
{
|
{
|
||||||
Core::ICore::showOptionsDialog(Constants::GDB_PROVIDERS_SETTINGS_ID, this);
|
Core::ICore::showOptionsDialog(Constants::GDB_PROVIDERS_SETTINGS_ID, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProviderChooser::currentIndexChanged(int index)
|
void DebugServerProviderChooser::currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
Q_UNUSED(index)
|
Q_UNUSED(index)
|
||||||
emit providerChanged();
|
emit providerChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GdbServerProviderChooser::providerMatches(const GdbServerProvider *provider) const
|
bool DebugServerProviderChooser::providerMatches(const IDebugServerProvider *provider) const
|
||||||
{
|
{
|
||||||
return provider->isValid();
|
return provider->isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GdbServerProviderChooser::providerText(const GdbServerProvider *provider) const
|
QString DebugServerProviderChooser::providerText(const IDebugServerProvider *provider) const
|
||||||
{
|
{
|
||||||
return provider->displayName();
|
return provider->displayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProviderChooser::populate()
|
void DebugServerProviderChooser::populate()
|
||||||
{
|
{
|
||||||
const QSignalBlocker blocker(m_chooser);
|
const QSignalBlocker blocker(m_chooser);
|
||||||
m_chooser->clear();
|
m_chooser->clear();
|
||||||
m_chooser->addItem(tr("None"));
|
m_chooser->addItem(tr("None"));
|
||||||
|
|
||||||
for (const GdbServerProvider *p : GdbServerProviderManager::providers()) {
|
for (const IDebugServerProvider *p : DebugServerProviderManager::providers()) {
|
||||||
if (!providerMatches(p))
|
if (!providerMatches(p))
|
||||||
continue;
|
continue;
|
||||||
m_chooser->addItem(providerText(p), QVariant::fromValue(p->id()));
|
m_chooser->addItem(providerText(p), QVariant::fromValue(p->id()));
|
||||||
@@ -37,16 +37,16 @@ namespace Core { class Id; }
|
|||||||
namespace BareMetal {
|
namespace BareMetal {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class GdbServerProvider;
|
class IDebugServerProvider;
|
||||||
|
|
||||||
// GdbServerProviderChooser
|
// DebugServerProviderChooser
|
||||||
|
|
||||||
class GdbServerProviderChooser final : public QWidget
|
class DebugServerProviderChooser final : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GdbServerProviderChooser(
|
explicit DebugServerProviderChooser(
|
||||||
bool useManageButton = true, QWidget *parent = nullptr);
|
bool useManageButton = true, QWidget *parent = nullptr);
|
||||||
|
|
||||||
QString currentProviderId() const;
|
QString currentProviderId() const;
|
||||||
@@ -59,8 +59,8 @@ signals:
|
|||||||
private:
|
private:
|
||||||
void currentIndexChanged(int index);
|
void currentIndexChanged(int index);
|
||||||
void manageButtonClicked();
|
void manageButtonClicked();
|
||||||
bool providerMatches(const GdbServerProvider *) const;
|
bool providerMatches(const IDebugServerProvider *) const;
|
||||||
QString providerText(const GdbServerProvider *) const;
|
QString providerText(const IDebugServerProvider *) const;
|
||||||
|
|
||||||
QComboBox *m_chooser = nullptr;
|
QComboBox *m_chooser = nullptr;
|
||||||
QPushButton *m_manageButton = nullptr;
|
QPushButton *m_manageButton = nullptr;
|
||||||
@@ -23,12 +23,13 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "gdbserverprovider.h"
|
#include "debugserverprovidermanager.h"
|
||||||
#include "gdbserverprovidermanager.h"
|
#include "idebugserverprovider.h"
|
||||||
|
|
||||||
#include "defaultgdbserverprovider.h"
|
// GDB debug servers.
|
||||||
#include "openocdgdbserverprovider.h"
|
#include "debugservers/gdb/defaultgdbserverprovider.h"
|
||||||
#include "stlinkutilgdbserverprovider.h"
|
#include "debugservers/gdb/openocdgdbserverprovider.h"
|
||||||
|
#include "debugservers/gdb/stlinkutilgdbserverprovider.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
@@ -43,16 +44,16 @@
|
|||||||
namespace BareMetal {
|
namespace BareMetal {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
const char dataKeyC[] = "GdbServerProvider.";
|
const char dataKeyC[] = "DebugServerProvider.";
|
||||||
const char countKeyC[] = "GdbServerProvider.Count";
|
const char countKeyC[] = "DebugServerProvider.Count";
|
||||||
const char fileVersionKeyC[] = "Version";
|
const char fileVersionKeyC[] = "Version";
|
||||||
const char fileNameKeyC[] = "/gdbserverproviders.xml";
|
const char fileNameKeyC[] = "/debugserverproviders.xml";
|
||||||
|
|
||||||
static GdbServerProviderManager *m_instance = nullptr;
|
static DebugServerProviderManager *m_instance = nullptr;
|
||||||
|
|
||||||
// GdbServerProviderManager
|
// DebugServerProviderManager
|
||||||
|
|
||||||
GdbServerProviderManager::GdbServerProviderManager()
|
DebugServerProviderManager::DebugServerProviderManager()
|
||||||
: m_configFile(Utils::FilePath::fromString(Core::ICore::userResourcePath() + fileNameKeyC))
|
: m_configFile(Utils::FilePath::fromString(Core::ICore::userResourcePath() + fileNameKeyC))
|
||||||
, m_factories({new DefaultGdbServerProviderFactory,
|
, m_factories({new DefaultGdbServerProviderFactory,
|
||||||
new OpenOcdGdbServerProviderFactory,
|
new OpenOcdGdbServerProviderFactory,
|
||||||
@@ -60,20 +61,20 @@ GdbServerProviderManager::GdbServerProviderManager()
|
|||||||
{
|
{
|
||||||
m_instance = this;
|
m_instance = this;
|
||||||
m_writer = new Utils::PersistentSettingsWriter(
|
m_writer = new Utils::PersistentSettingsWriter(
|
||||||
m_configFile, QLatin1String("QtCreatorGdbServerProviders"));
|
m_configFile, QLatin1String("QtCreatorDebugServerProviders"));
|
||||||
|
|
||||||
connect(Core::ICore::instance(), &Core::ICore::saveSettingsRequested,
|
connect(Core::ICore::instance(), &Core::ICore::saveSettingsRequested,
|
||||||
this, &GdbServerProviderManager::saveProviders);
|
this, &DebugServerProviderManager::saveProviders);
|
||||||
|
|
||||||
connect(this, &GdbServerProviderManager::providerAdded,
|
connect(this, &DebugServerProviderManager::providerAdded,
|
||||||
this, &GdbServerProviderManager::providersChanged);
|
this, &DebugServerProviderManager::providersChanged);
|
||||||
connect(this, &GdbServerProviderManager::providerRemoved,
|
connect(this, &DebugServerProviderManager::providerRemoved,
|
||||||
this, &GdbServerProviderManager::providersChanged);
|
this, &DebugServerProviderManager::providersChanged);
|
||||||
connect(this, &GdbServerProviderManager::providerUpdated,
|
connect(this, &DebugServerProviderManager::providerUpdated,
|
||||||
this, &GdbServerProviderManager::providersChanged);
|
this, &DebugServerProviderManager::providersChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
GdbServerProviderManager::~GdbServerProviderManager()
|
DebugServerProviderManager::~DebugServerProviderManager()
|
||||||
{
|
{
|
||||||
qDeleteAll(m_providers);
|
qDeleteAll(m_providers);
|
||||||
m_providers.clear();
|
m_providers.clear();
|
||||||
@@ -82,12 +83,12 @@ GdbServerProviderManager::~GdbServerProviderManager()
|
|||||||
m_instance = nullptr;
|
m_instance = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
GdbServerProviderManager *GdbServerProviderManager::instance()
|
DebugServerProviderManager *DebugServerProviderManager::instance()
|
||||||
{
|
{
|
||||||
return m_instance;
|
return m_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProviderManager::restoreProviders()
|
void DebugServerProviderManager::restoreProviders()
|
||||||
{
|
{
|
||||||
Utils::PersistentSettingsReader reader;
|
Utils::PersistentSettingsReader reader;
|
||||||
if (!reader.load(m_configFile))
|
if (!reader.load(m_configFile))
|
||||||
@@ -106,9 +107,9 @@ void GdbServerProviderManager::restoreProviders()
|
|||||||
|
|
||||||
const QVariantMap map = data.value(key).toMap();
|
const QVariantMap map = data.value(key).toMap();
|
||||||
bool restored = false;
|
bool restored = false;
|
||||||
for (GdbServerProviderFactory *f : qAsConst(m_factories)) {
|
for (IDebugServerProviderFactory *f : qAsConst(m_factories)) {
|
||||||
if (f->canRestore(map)) {
|
if (f->canRestore(map)) {
|
||||||
if (GdbServerProvider *p = f->restore(map)) {
|
if (IDebugServerProvider *p = f->restore(map)) {
|
||||||
registerProvider(p);
|
registerProvider(p);
|
||||||
restored = true;
|
restored = true;
|
||||||
break;
|
break;
|
||||||
@@ -117,20 +118,20 @@ void GdbServerProviderManager::restoreProviders()
|
|||||||
}
|
}
|
||||||
if (!restored)
|
if (!restored)
|
||||||
qWarning("Warning: Unable to restore provider '%s' stored in %s.",
|
qWarning("Warning: Unable to restore provider '%s' stored in %s.",
|
||||||
qPrintable(GdbServerProviderFactory::idFromMap(map)),
|
qPrintable(IDebugServerProviderFactory::idFromMap(map)),
|
||||||
qPrintable(m_configFile.toUserOutput()));
|
qPrintable(m_configFile.toUserOutput()));
|
||||||
}
|
}
|
||||||
|
|
||||||
emit providersLoaded();
|
emit providersLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProviderManager::saveProviders()
|
void DebugServerProviderManager::saveProviders()
|
||||||
{
|
{
|
||||||
QVariantMap data;
|
QVariantMap data;
|
||||||
data.insert(QLatin1String(fileVersionKeyC), 1);
|
data.insert(QLatin1String(fileVersionKeyC), 1);
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (const GdbServerProvider *p : qAsConst(m_providers)) {
|
for (const IDebugServerProvider *p : qAsConst(m_providers)) {
|
||||||
if (p->isValid()) {
|
if (p->isValid()) {
|
||||||
const QVariantMap tmp = p->toMap();
|
const QVariantMap tmp = p->toMap();
|
||||||
if (tmp.isEmpty())
|
if (tmp.isEmpty())
|
||||||
@@ -144,45 +145,45 @@ void GdbServerProviderManager::saveProviders()
|
|||||||
m_writer->save(data, Core::ICore::mainWindow());
|
m_writer->save(data, Core::ICore::mainWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<GdbServerProvider *> GdbServerProviderManager::providers()
|
QList<IDebugServerProvider *> DebugServerProviderManager::providers()
|
||||||
{
|
{
|
||||||
return m_instance->m_providers;
|
return m_instance->m_providers;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<GdbServerProviderFactory *> GdbServerProviderManager::factories()
|
QList<IDebugServerProviderFactory *> DebugServerProviderManager::factories()
|
||||||
{
|
{
|
||||||
return m_instance->m_factories;
|
return m_instance->m_factories;
|
||||||
}
|
}
|
||||||
|
|
||||||
GdbServerProvider *GdbServerProviderManager::findProvider(const QString &id)
|
IDebugServerProvider *DebugServerProviderManager::findProvider(const QString &id)
|
||||||
{
|
{
|
||||||
if (id.isEmpty() || !m_instance)
|
if (id.isEmpty() || !m_instance)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return Utils::findOrDefault(m_instance->m_providers, Utils::equal(&GdbServerProvider::id, id));
|
return Utils::findOrDefault(m_instance->m_providers, Utils::equal(&IDebugServerProvider::id, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
GdbServerProvider *GdbServerProviderManager::findByDisplayName(const QString &displayName)
|
IDebugServerProvider *DebugServerProviderManager::findByDisplayName(const QString &displayName)
|
||||||
{
|
{
|
||||||
if (displayName.isEmpty())
|
if (displayName.isEmpty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return Utils::findOrDefault(m_instance->m_providers,
|
return Utils::findOrDefault(m_instance->m_providers,
|
||||||
Utils::equal(&GdbServerProvider::displayName, displayName));
|
Utils::equal(&IDebugServerProvider::displayName, displayName));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProviderManager::notifyAboutUpdate(GdbServerProvider *provider)
|
void DebugServerProviderManager::notifyAboutUpdate(IDebugServerProvider *provider)
|
||||||
{
|
{
|
||||||
if (!provider || !m_instance->m_providers.contains(provider))
|
if (!provider || !m_instance->m_providers.contains(provider))
|
||||||
return;
|
return;
|
||||||
emit m_instance->providerUpdated(provider);
|
emit m_instance->providerUpdated(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GdbServerProviderManager::registerProvider(GdbServerProvider *provider)
|
bool DebugServerProviderManager::registerProvider(IDebugServerProvider *provider)
|
||||||
{
|
{
|
||||||
if (!provider || m_instance->m_providers.contains(provider))
|
if (!provider || m_instance->m_providers.contains(provider))
|
||||||
return true;
|
return true;
|
||||||
for (const GdbServerProvider *current : qAsConst(m_instance->m_providers)) {
|
for (const IDebugServerProvider *current : qAsConst(m_instance->m_providers)) {
|
||||||
if (*provider == *current)
|
if (*provider == *current)
|
||||||
return false;
|
return false;
|
||||||
QTC_ASSERT(current->id() != provider->id(), return false);
|
QTC_ASSERT(current->id() != provider->id(), return false);
|
||||||
@@ -193,7 +194,7 @@ bool GdbServerProviderManager::registerProvider(GdbServerProvider *provider)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProviderManager::deregisterProvider(GdbServerProvider *provider)
|
void DebugServerProviderManager::deregisterProvider(IDebugServerProvider *provider)
|
||||||
{
|
{
|
||||||
if (!provider || !m_instance->m_providers.contains(provider))
|
if (!provider || !m_instance->m_providers.contains(provider))
|
||||||
return;
|
return;
|
||||||
@@ -37,48 +37,48 @@ namespace Internal {
|
|||||||
|
|
||||||
class BareMetalPlugin;
|
class BareMetalPlugin;
|
||||||
class BareMetalPluginPrivate;
|
class BareMetalPluginPrivate;
|
||||||
class GdbServerProvider;
|
class IDebugServerProvider;
|
||||||
class GdbServerProviderFactory;
|
class IDebugServerProviderFactory;
|
||||||
|
|
||||||
// GdbServerProviderManager
|
// DebugServerProviderManager
|
||||||
|
|
||||||
class GdbServerProviderManager final : public QObject
|
class DebugServerProviderManager final : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static GdbServerProviderManager *instance();
|
static DebugServerProviderManager *instance();
|
||||||
~GdbServerProviderManager() final;
|
~DebugServerProviderManager() final;
|
||||||
|
|
||||||
static QList<GdbServerProvider *> providers();
|
static QList<IDebugServerProvider *> providers();
|
||||||
static QList<GdbServerProviderFactory *> factories();
|
static QList<IDebugServerProviderFactory *> factories();
|
||||||
static GdbServerProvider *findProvider(const QString &id);
|
static IDebugServerProvider *findProvider(const QString &id);
|
||||||
static GdbServerProvider *findByDisplayName(const QString &displayName);
|
static IDebugServerProvider *findByDisplayName(const QString &displayName);
|
||||||
static bool registerProvider(GdbServerProvider *);
|
static bool registerProvider(IDebugServerProvider *provider);
|
||||||
static void deregisterProvider(GdbServerProvider *);
|
static void deregisterProvider(IDebugServerProvider *provider);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void providerAdded(GdbServerProvider *);
|
void providerAdded(IDebugServerProvider *provider);
|
||||||
void providerRemoved(GdbServerProvider *);
|
void providerRemoved(IDebugServerProvider *provider);
|
||||||
void providerUpdated(GdbServerProvider *);
|
void providerUpdated(IDebugServerProvider *provider);
|
||||||
void providersChanged();
|
void providersChanged();
|
||||||
void providersLoaded();
|
void providersLoaded();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void saveProviders();
|
void saveProviders();
|
||||||
GdbServerProviderManager();
|
DebugServerProviderManager();
|
||||||
|
|
||||||
void restoreProviders();
|
void restoreProviders();
|
||||||
static void notifyAboutUpdate(GdbServerProvider *);
|
static void notifyAboutUpdate(IDebugServerProvider *provider);
|
||||||
|
|
||||||
Utils::PersistentSettingsWriter *m_writer = nullptr;
|
Utils::PersistentSettingsWriter *m_writer = nullptr;
|
||||||
QList<GdbServerProvider *> m_providers;
|
QList<IDebugServerProvider *> m_providers;
|
||||||
const Utils::FilePath m_configFile;
|
const Utils::FilePath m_configFile;
|
||||||
const QList<GdbServerProviderFactory *> m_factories;
|
const QList<IDebugServerProviderFactory *> m_factories;
|
||||||
|
|
||||||
friend class BareMetalPlugin; // for restoreProviders
|
friend class BareMetalPlugin; // for restoreProviders
|
||||||
friend class BareMetalPluginPrivate; // for constructor
|
friend class BareMetalPluginPrivate; // for constructor
|
||||||
friend class GdbServerProvider;
|
friend class IDebugServerProvider;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
@@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
#include "baremetalconstants.h"
|
#include "baremetalconstants.h"
|
||||||
|
|
||||||
#include "gdbserverprovider.h"
|
#include "debugserverprovidermanager.h"
|
||||||
#include "gdbserverprovidermanager.h"
|
#include "debugserverproviderssettingspage.h"
|
||||||
#include "gdbserverproviderssettingspage.h"
|
#include "idebugserverprovider.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
@@ -56,12 +56,12 @@ using namespace Utils;
|
|||||||
namespace BareMetal {
|
namespace BareMetal {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
// GdbServerProviderNode
|
// DebugServerProviderNode
|
||||||
|
|
||||||
class GdbServerProviderNode final : public TreeItem
|
class DebugServerProviderNode final : public TreeItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit GdbServerProviderNode(GdbServerProvider *provider, bool changed = false)
|
explicit DebugServerProviderNode(IDebugServerProvider *provider, bool changed = false)
|
||||||
: provider(provider), changed(changed)
|
: provider(provider), changed(changed)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -83,54 +83,54 @@ public:
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
GdbServerProvider *provider = nullptr;
|
IDebugServerProvider *provider = nullptr;
|
||||||
GdbServerProviderConfigWidget *widget = nullptr;
|
IDebugServerProviderConfigWidget *widget = nullptr;
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// GdbServerProviderModel
|
// DebugServerProviderModel
|
||||||
|
|
||||||
GdbServerProviderModel::GdbServerProviderModel()
|
DebugServerProviderModel::DebugServerProviderModel()
|
||||||
{
|
{
|
||||||
setHeader({tr("Name"), tr("Type")});
|
setHeader({tr("Name"), tr("Type")});
|
||||||
|
|
||||||
const GdbServerProviderManager *manager = GdbServerProviderManager::instance();
|
const DebugServerProviderManager *manager = DebugServerProviderManager::instance();
|
||||||
|
|
||||||
connect(manager, &GdbServerProviderManager::providerAdded,
|
connect(manager, &DebugServerProviderManager::providerAdded,
|
||||||
this, &GdbServerProviderModel::addProvider);
|
this, &DebugServerProviderModel::addProvider);
|
||||||
connect(manager, &GdbServerProviderManager::providerRemoved,
|
connect(manager, &DebugServerProviderManager::providerRemoved,
|
||||||
this, &GdbServerProviderModel::removeProvider);
|
this, &DebugServerProviderModel::removeProvider);
|
||||||
|
|
||||||
for (GdbServerProvider *p : GdbServerProviderManager::providers())
|
for (IDebugServerProvider *p : DebugServerProviderManager::providers())
|
||||||
addProvider(p);
|
addProvider(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
GdbServerProvider *GdbServerProviderModel::provider(const QModelIndex &index) const
|
IDebugServerProvider *DebugServerProviderModel::provider(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (const GdbServerProviderNode *node = nodeForIndex(index))
|
if (const DebugServerProviderNode *node = nodeForIndex(index))
|
||||||
return node->provider;
|
return node->provider;
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
GdbServerProviderNode *GdbServerProviderModel::nodeForIndex(const QModelIndex &index) const
|
DebugServerProviderNode *DebugServerProviderModel::nodeForIndex(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return static_cast<GdbServerProviderNode *>(itemForIndex(index));
|
return static_cast<DebugServerProviderNode *>(itemForIndex(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProviderModel::apply()
|
void DebugServerProviderModel::apply()
|
||||||
{
|
{
|
||||||
// Remove unused providers
|
// Remove unused providers
|
||||||
for (GdbServerProvider *provider : qAsConst(m_providersToRemove))
|
for (IDebugServerProvider *provider : qAsConst(m_providersToRemove))
|
||||||
GdbServerProviderManager::deregisterProvider(provider);
|
DebugServerProviderManager::deregisterProvider(provider);
|
||||||
QTC_ASSERT(m_providersToRemove.isEmpty(), m_providersToRemove.clear());
|
QTC_ASSERT(m_providersToRemove.isEmpty(), m_providersToRemove.clear());
|
||||||
|
|
||||||
// Update providers
|
// Update providers
|
||||||
for (TreeItem *item : *rootItem()) {
|
for (TreeItem *item : *rootItem()) {
|
||||||
const auto n = static_cast<GdbServerProviderNode *>(item);
|
const auto n = static_cast<DebugServerProviderNode *>(item);
|
||||||
if (!n->changed)
|
if (!n->changed)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -144,8 +144,8 @@ void GdbServerProviderModel::apply()
|
|||||||
|
|
||||||
// Add new (and already updated) providers
|
// Add new (and already updated) providers
|
||||||
QStringList skippedProviders;
|
QStringList skippedProviders;
|
||||||
for (GdbServerProvider *provider: qAsConst(m_providersToAdd)) {
|
for (IDebugServerProvider *provider: qAsConst(m_providersToAdd)) {
|
||||||
if (!GdbServerProviderManager::registerProvider(provider))
|
if (!DebugServerProviderManager::registerProvider(provider))
|
||||||
skippedProviders << provider->displayName();
|
skippedProviders << provider->displayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,24 +161,24 @@ void GdbServerProviderModel::apply()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GdbServerProviderNode *GdbServerProviderModel::findNode(const GdbServerProvider *provider) const
|
DebugServerProviderNode *DebugServerProviderModel::findNode(const IDebugServerProvider *provider) const
|
||||||
{
|
{
|
||||||
auto test = [provider](TreeItem *item) {
|
auto test = [provider](TreeItem *item) {
|
||||||
return static_cast<GdbServerProviderNode *>(item)->provider == provider;
|
return static_cast<DebugServerProviderNode *>(item)->provider == provider;
|
||||||
};
|
};
|
||||||
|
|
||||||
return static_cast<GdbServerProviderNode *>(Utils::findOrDefault(*rootItem(), test));
|
return static_cast<DebugServerProviderNode *>(Utils::findOrDefault(*rootItem(), test));
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex GdbServerProviderModel::indexForProvider(GdbServerProvider *provider) const
|
QModelIndex DebugServerProviderModel::indexForProvider(IDebugServerProvider *provider) const
|
||||||
{
|
{
|
||||||
const GdbServerProviderNode *n = findNode(provider);
|
const DebugServerProviderNode *n = findNode(provider);
|
||||||
return n ? indexForItem(n) : QModelIndex();
|
return n ? indexForItem(n) : QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProviderModel::markForRemoval(GdbServerProvider *provider)
|
void DebugServerProviderModel::markForRemoval(IDebugServerProvider *provider)
|
||||||
{
|
{
|
||||||
GdbServerProviderNode *n = findNode(provider);
|
DebugServerProviderNode *n = findNode(provider);
|
||||||
QTC_ASSERT(n, return);
|
QTC_ASSERT(n, return);
|
||||||
destroyItem(n);
|
destroyItem(n);
|
||||||
|
|
||||||
@@ -190,26 +190,26 @@ void GdbServerProviderModel::markForRemoval(GdbServerProvider *provider)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProviderModel::markForAddition(GdbServerProvider *provider)
|
void DebugServerProviderModel::markForAddition(IDebugServerProvider *provider)
|
||||||
{
|
{
|
||||||
GdbServerProviderNode *n = createNode(provider, true);
|
DebugServerProviderNode *n = createNode(provider, true);
|
||||||
rootItem()->appendChild(n);
|
rootItem()->appendChild(n);
|
||||||
m_providersToAdd.append(provider);
|
m_providersToAdd.append(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
GdbServerProviderNode *GdbServerProviderModel::createNode(
|
DebugServerProviderNode *DebugServerProviderModel::createNode(
|
||||||
GdbServerProvider *provider, bool changed)
|
IDebugServerProvider *provider, bool changed)
|
||||||
{
|
{
|
||||||
const auto node = new GdbServerProviderNode(provider, changed);
|
const auto node = new DebugServerProviderNode(provider, changed);
|
||||||
node->widget = provider->configurationWidget();
|
node->widget = provider->configurationWidget();
|
||||||
connect(node->widget, &GdbServerProviderConfigWidget::dirty, this, [node] {
|
connect(node->widget, &IDebugServerProviderConfigWidget::dirty, this, [node] {
|
||||||
node->changed = true;
|
node->changed = true;
|
||||||
node->update();
|
node->update();
|
||||||
});
|
});
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProviderModel::addProvider(GdbServerProvider *provider)
|
void DebugServerProviderModel::addProvider(IDebugServerProvider *provider)
|
||||||
{
|
{
|
||||||
if (findNode(provider))
|
if (findNode(provider))
|
||||||
m_providersToAdd.removeOne(provider);
|
m_providersToAdd.removeOne(provider);
|
||||||
@@ -219,34 +219,34 @@ void GdbServerProviderModel::addProvider(GdbServerProvider *provider)
|
|||||||
emit providerStateChanged();
|
emit providerStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProviderModel::removeProvider(GdbServerProvider *provider)
|
void DebugServerProviderModel::removeProvider(IDebugServerProvider *provider)
|
||||||
{
|
{
|
||||||
m_providersToRemove.removeAll(provider);
|
m_providersToRemove.removeAll(provider);
|
||||||
if (GdbServerProviderNode *n = findNode(provider))
|
if (DebugServerProviderNode *n = findNode(provider))
|
||||||
destroyItem(n);
|
destroyItem(n);
|
||||||
|
|
||||||
emit providerStateChanged();
|
emit providerStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
// GdbServerProvidersSettingsWidget
|
// DebugServerProvidersSettingsWidget
|
||||||
|
|
||||||
class GdbServerProvidersSettingsWidget final : public QWidget
|
class DebugServerProvidersSettingsWidget final : public QWidget
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(BareMetal::Internal::GdbServerProvidersSettingsPage)
|
Q_DECLARE_TR_FUNCTIONS(BareMetal::Internal::DebugServerProvidersSettingsPage)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GdbServerProvidersSettingsWidget(GdbServerProvidersSettingsPage *page);
|
explicit DebugServerProvidersSettingsWidget(DebugServerProvidersSettingsPage *page);
|
||||||
|
|
||||||
void providerSelectionChanged();
|
void providerSelectionChanged();
|
||||||
void removeProvider();
|
void removeProvider();
|
||||||
void updateState();
|
void updateState();
|
||||||
|
|
||||||
void createProvider(GdbServerProviderFactory *f);
|
void createProvider(IDebugServerProviderFactory *f);
|
||||||
QModelIndex currentIndex() const;
|
QModelIndex currentIndex() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GdbServerProvidersSettingsPage *m_page = nullptr;
|
DebugServerProvidersSettingsPage *m_page = nullptr;
|
||||||
GdbServerProviderModel m_model;
|
DebugServerProviderModel m_model;
|
||||||
QItemSelectionModel *m_selectionModel = nullptr;
|
QItemSelectionModel *m_selectionModel = nullptr;
|
||||||
QTreeView *m_providerView = nullptr;
|
QTreeView *m_providerView = nullptr;
|
||||||
Utils::DetailsWidget *m_container = nullptr;
|
Utils::DetailsWidget *m_container = nullptr;
|
||||||
@@ -255,8 +255,8 @@ public:
|
|||||||
QPushButton *m_delButton = nullptr;
|
QPushButton *m_delButton = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
GdbServerProvidersSettingsWidget::GdbServerProvidersSettingsWidget
|
DebugServerProvidersSettingsWidget::DebugServerProvidersSettingsWidget
|
||||||
(GdbServerProvidersSettingsPage *page)
|
(DebugServerProvidersSettingsPage *page)
|
||||||
: m_page(page)
|
: m_page(page)
|
||||||
{
|
{
|
||||||
m_providerView = new QTreeView(this);
|
m_providerView = new QTreeView(this);
|
||||||
@@ -289,14 +289,14 @@ GdbServerProvidersSettingsWidget::GdbServerProvidersSettingsWidget
|
|||||||
horizontalLayout->addLayout(verticalLayout);
|
horizontalLayout->addLayout(verticalLayout);
|
||||||
horizontalLayout->addWidget(m_container);
|
horizontalLayout->addWidget(m_container);
|
||||||
|
|
||||||
const auto groupBox = new QGroupBox(tr("GDB Server Providers"), this);
|
const auto groupBox = new QGroupBox(tr("Debug Server Providers"), this);
|
||||||
groupBox->setLayout(horizontalLayout);
|
groupBox->setLayout(horizontalLayout);
|
||||||
|
|
||||||
const auto topLayout = new QVBoxLayout(this);
|
const auto topLayout = new QVBoxLayout(this);
|
||||||
topLayout->addWidget(groupBox);
|
topLayout->addWidget(groupBox);
|
||||||
|
|
||||||
connect(&m_model, &GdbServerProviderModel::providerStateChanged,
|
connect(&m_model, &DebugServerProviderModel::providerStateChanged,
|
||||||
this, &GdbServerProvidersSettingsWidget::updateState);
|
this, &DebugServerProvidersSettingsWidget::updateState);
|
||||||
|
|
||||||
m_providerView->setModel(&m_model);
|
m_providerView->setModel(&m_model);
|
||||||
|
|
||||||
@@ -308,15 +308,15 @@ GdbServerProvidersSettingsWidget::GdbServerProvidersSettingsWidget
|
|||||||
m_selectionModel = m_providerView->selectionModel();
|
m_selectionModel = m_providerView->selectionModel();
|
||||||
|
|
||||||
connect(m_selectionModel, &QItemSelectionModel::selectionChanged,
|
connect(m_selectionModel, &QItemSelectionModel::selectionChanged,
|
||||||
this, &GdbServerProvidersSettingsWidget::providerSelectionChanged);
|
this, &DebugServerProvidersSettingsWidget::providerSelectionChanged);
|
||||||
|
|
||||||
connect(GdbServerProviderManager::instance(), &GdbServerProviderManager::providersChanged,
|
connect(DebugServerProviderManager::instance(), &DebugServerProviderManager::providersChanged,
|
||||||
this, &GdbServerProvidersSettingsWidget::providerSelectionChanged);
|
this, &DebugServerProvidersSettingsWidget::providerSelectionChanged);
|
||||||
|
|
||||||
// Set up add menu:
|
// Set up add menu:
|
||||||
const auto addMenu = new QMenu(m_addButton);
|
const auto addMenu = new QMenu(m_addButton);
|
||||||
|
|
||||||
for (const auto f : GdbServerProviderManager::factories()) {
|
for (const auto f : DebugServerProviderManager::factories()) {
|
||||||
const auto action = new QAction(addMenu);
|
const auto action = new QAction(addMenu);
|
||||||
action->setText(f->displayName());
|
action->setText(f->displayName());
|
||||||
connect(action, &QAction::triggered, this, [this, f] { createProvider(f); });
|
connect(action, &QAction::triggered, this, [this, f] { createProvider(f); });
|
||||||
@@ -328,12 +328,12 @@ GdbServerProvidersSettingsWidget::GdbServerProvidersSettingsWidget
|
|||||||
m_addButton->setMenu(addMenu);
|
m_addButton->setMenu(addMenu);
|
||||||
|
|
||||||
connect(m_delButton, &QPushButton::clicked,
|
connect(m_delButton, &QPushButton::clicked,
|
||||||
this, &GdbServerProvidersSettingsWidget::removeProvider);
|
this, &DebugServerProvidersSettingsWidget::removeProvider);
|
||||||
|
|
||||||
updateState();
|
updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProvidersSettingsWidget::providerSelectionChanged()
|
void DebugServerProvidersSettingsWidget::providerSelectionChanged()
|
||||||
{
|
{
|
||||||
if (!m_container)
|
if (!m_container)
|
||||||
return;
|
return;
|
||||||
@@ -342,18 +342,18 @@ void GdbServerProvidersSettingsWidget::providerSelectionChanged()
|
|||||||
if (w)
|
if (w)
|
||||||
w->setVisible(false);
|
w->setVisible(false);
|
||||||
|
|
||||||
const GdbServerProviderNode *node = m_model.nodeForIndex(current);
|
const DebugServerProviderNode *node = m_model.nodeForIndex(current);
|
||||||
w = node ? node->widget : nullptr;
|
w = node ? node->widget : nullptr;
|
||||||
m_container->setWidget(w);
|
m_container->setWidget(w);
|
||||||
m_container->setVisible(w != nullptr);
|
m_container->setVisible(w != nullptr);
|
||||||
updateState();
|
updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProvidersSettingsWidget::createProvider(GdbServerProviderFactory *f)
|
void DebugServerProvidersSettingsWidget::createProvider(IDebugServerProviderFactory *f)
|
||||||
{
|
{
|
||||||
GdbServerProvider *provider = nullptr;
|
IDebugServerProvider *provider = nullptr;
|
||||||
if (!f) {
|
if (!f) {
|
||||||
const GdbServerProvider *old = m_model.provider(currentIndex());
|
const IDebugServerProvider *old = m_model.provider(currentIndex());
|
||||||
if (!old)
|
if (!old)
|
||||||
return;
|
return;
|
||||||
provider = old->clone();
|
provider = old->clone();
|
||||||
@@ -372,20 +372,20 @@ void GdbServerProvidersSettingsWidget::createProvider(GdbServerProviderFactory *
|
|||||||
| QItemSelectionModel::Rows);
|
| QItemSelectionModel::Rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProvidersSettingsWidget::removeProvider()
|
void DebugServerProvidersSettingsWidget::removeProvider()
|
||||||
{
|
{
|
||||||
if (GdbServerProvider *p = m_model.provider(currentIndex()))
|
if (IDebugServerProvider *p = m_model.provider(currentIndex()))
|
||||||
m_model.markForRemoval(p);
|
m_model.markForRemoval(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProvidersSettingsWidget::updateState()
|
void DebugServerProvidersSettingsWidget::updateState()
|
||||||
{
|
{
|
||||||
if (!m_cloneButton)
|
if (!m_cloneButton)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool canCopy = false;
|
bool canCopy = false;
|
||||||
bool canDelete = false;
|
bool canDelete = false;
|
||||||
if (const GdbServerProvider *p = m_model.provider(currentIndex())) {
|
if (const IDebugServerProvider *p = m_model.provider(currentIndex())) {
|
||||||
canCopy = p->isValid();
|
canCopy = p->isValid();
|
||||||
canDelete = true;
|
canDelete = true;
|
||||||
}
|
}
|
||||||
@@ -394,7 +394,7 @@ void GdbServerProvidersSettingsWidget::updateState()
|
|||||||
m_delButton->setEnabled(canDelete);
|
m_delButton->setEnabled(canDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex GdbServerProvidersSettingsWidget::currentIndex() const
|
QModelIndex DebugServerProvidersSettingsWidget::currentIndex() const
|
||||||
{
|
{
|
||||||
if (!m_selectionModel)
|
if (!m_selectionModel)
|
||||||
return {};
|
return {};
|
||||||
@@ -406,31 +406,31 @@ QModelIndex GdbServerProvidersSettingsWidget::currentIndex() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GdbServerProvidersSettingsPage::GdbServerProvidersSettingsPage()
|
DebugServerProvidersSettingsPage::DebugServerProvidersSettingsPage()
|
||||||
{
|
{
|
||||||
setId(Constants::GDB_PROVIDERS_SETTINGS_ID);
|
setId(Constants::GDB_PROVIDERS_SETTINGS_ID);
|
||||||
setDisplayName(tr("Bare Metal"));
|
setDisplayName(tr("Bare Metal"));
|
||||||
setCategory(ProjectExplorer::Constants::DEVICE_SETTINGS_CATEGORY);
|
setCategory(ProjectExplorer::Constants::DEVICE_SETTINGS_CATEGORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *GdbServerProvidersSettingsPage::widget()
|
QWidget *DebugServerProvidersSettingsPage::widget()
|
||||||
{
|
{
|
||||||
if (!m_configWidget)
|
if (!m_configWidget)
|
||||||
m_configWidget = new GdbServerProvidersSettingsWidget(this);
|
m_configWidget = new DebugServerProvidersSettingsWidget(this);
|
||||||
return m_configWidget;
|
return m_configWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProvidersSettingsPage::apply()
|
void DebugServerProvidersSettingsPage::apply()
|
||||||
{
|
{
|
||||||
if (m_configWidget)
|
if (m_configWidget)
|
||||||
m_configWidget->m_model.apply();
|
m_configWidget->m_model.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProvidersSettingsPage::finish()
|
void DebugServerProvidersSettingsPage::finish()
|
||||||
{
|
{
|
||||||
if (m_configWidget)
|
if (m_configWidget)
|
||||||
disconnect(GdbServerProviderManager::instance(), &GdbServerProviderManager::providersChanged,
|
disconnect(DebugServerProviderManager::instance(), &DebugServerProviderManager::providersChanged,
|
||||||
m_configWidget, &GdbServerProvidersSettingsWidget::providerSelectionChanged);
|
m_configWidget, &DebugServerProvidersSettingsWidget::providerSelectionChanged);
|
||||||
|
|
||||||
delete m_configWidget;
|
delete m_configWidget;
|
||||||
m_configWidget = nullptr;
|
m_configWidget = nullptr;
|
||||||
@@ -40,61 +40,61 @@ namespace Utils { class DetailsWidget; }
|
|||||||
namespace BareMetal {
|
namespace BareMetal {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class GdbServerProvider;
|
class DebugServerProviderNode;
|
||||||
class GdbServerProviderConfigWidget;
|
class DebugServerProvidersSettingsWidget;
|
||||||
class GdbServerProviderFactory;
|
class IDebugServerProvider;
|
||||||
class GdbServerProviderNode;
|
class IDebugServerProviderConfigWidget;
|
||||||
class GdbServerProvidersSettingsWidget;
|
class IDebugServerProviderFactory;
|
||||||
|
|
||||||
// GdbServerProviderModel
|
// DebugServerProviderModel
|
||||||
|
|
||||||
class GdbServerProviderModel final
|
class DebugServerProviderModel final
|
||||||
: public Utils::TreeModel<Utils::TypedTreeItem<GdbServerProviderNode>, GdbServerProviderNode>
|
: public Utils::TreeModel<Utils::TypedTreeItem<DebugServerProviderNode>, DebugServerProviderNode>
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GdbServerProviderModel();
|
explicit DebugServerProviderModel();
|
||||||
|
|
||||||
GdbServerProvider *provider(const QModelIndex &) const;
|
IDebugServerProvider *provider(const QModelIndex &) const;
|
||||||
GdbServerProviderConfigWidget *widget(const QModelIndex &) const;
|
IDebugServerProviderConfigWidget *widget(const QModelIndex &) const;
|
||||||
GdbServerProviderNode *nodeForIndex(const QModelIndex &index) const;
|
DebugServerProviderNode *nodeForIndex(const QModelIndex &index) const;
|
||||||
QModelIndex indexForProvider(GdbServerProvider *provider) const;
|
QModelIndex indexForProvider(IDebugServerProvider *provider) const;
|
||||||
|
|
||||||
void apply();
|
void apply();
|
||||||
|
|
||||||
void markForRemoval(GdbServerProvider *);
|
void markForRemoval(IDebugServerProvider *);
|
||||||
void markForAddition(GdbServerProvider *);
|
void markForAddition(IDebugServerProvider *);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void providerStateChanged();
|
void providerStateChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addProvider(GdbServerProvider *);
|
void addProvider(IDebugServerProvider *);
|
||||||
void removeProvider(GdbServerProvider *);
|
void removeProvider(IDebugServerProvider *);
|
||||||
|
|
||||||
GdbServerProviderNode *findNode(const GdbServerProvider *provider) const;
|
DebugServerProviderNode *findNode(const IDebugServerProvider *provider) const;
|
||||||
GdbServerProviderNode *createNode(GdbServerProvider *, bool changed);
|
DebugServerProviderNode *createNode(IDebugServerProvider *, bool changed);
|
||||||
|
|
||||||
QList<GdbServerProvider *> m_providersToAdd;
|
QList<IDebugServerProvider *> m_providersToAdd;
|
||||||
QList<GdbServerProvider *> m_providersToRemove;
|
QList<IDebugServerProvider *> m_providersToRemove;
|
||||||
};
|
};
|
||||||
|
|
||||||
// GdbServerProvidersSettingsPage
|
// DebugServerProvidersSettingsPage
|
||||||
|
|
||||||
class GdbServerProvidersSettingsPage final : public Core::IOptionsPage
|
class DebugServerProvidersSettingsPage final : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GdbServerProvidersSettingsPage();
|
DebugServerProvidersSettingsPage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *widget() final;
|
QWidget *widget() final;
|
||||||
void apply() final;
|
void apply() final;
|
||||||
void finish() final;
|
void finish() final;
|
||||||
|
|
||||||
GdbServerProvidersSettingsWidget *m_configWidget = nullptr;
|
DebugServerProvidersSettingsWidget *m_configWidget = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
@@ -23,14 +23,15 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "baremetalconstants.h"
|
|
||||||
#include "defaultgdbserverprovider.h"
|
#include "defaultgdbserverprovider.h"
|
||||||
#include "gdbserverprovidermanager.h"
|
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <baremetal/baremetalconstants.h>
|
||||||
|
#include <baremetal/debugserverprovidermanager.h>
|
||||||
|
|
||||||
#include <coreplugin/variablechooser.h>
|
#include <coreplugin/variablechooser.h>
|
||||||
|
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
@@ -126,25 +127,27 @@ DefaultGdbServerProviderConfigWidget::DefaultGdbServerProviderConfigWidget(
|
|||||||
this, &GdbServerProviderConfigWidget::dirty);
|
this, &GdbServerProviderConfigWidget::dirty);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultGdbServerProviderConfigWidget::applyImpl()
|
void DefaultGdbServerProviderConfigWidget::apply()
|
||||||
{
|
{
|
||||||
auto p = static_cast<DefaultGdbServerProvider *>(provider());
|
const auto p = static_cast<DefaultGdbServerProvider *>(m_provider);
|
||||||
Q_ASSERT(p);
|
Q_ASSERT(p);
|
||||||
|
|
||||||
p->setChannel(m_hostWidget->channel());
|
p->setChannel(m_hostWidget->channel());
|
||||||
p->setUseExtendedRemote(m_useExtendedRemoteCheckBox->isChecked());
|
p->setUseExtendedRemote(m_useExtendedRemoteCheckBox->isChecked());
|
||||||
p->setInitCommands(m_initCommandsTextEdit->toPlainText());
|
p->setInitCommands(m_initCommandsTextEdit->toPlainText());
|
||||||
p->setResetCommands(m_resetCommandsTextEdit->toPlainText());
|
p->setResetCommands(m_resetCommandsTextEdit->toPlainText());
|
||||||
|
IDebugServerProviderConfigWidget::apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultGdbServerProviderConfigWidget::discardImpl()
|
void DefaultGdbServerProviderConfigWidget::discard()
|
||||||
{
|
{
|
||||||
setFromProvider();
|
setFromProvider();
|
||||||
|
IDebugServerProviderConfigWidget::discard();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultGdbServerProviderConfigWidget::setFromProvider()
|
void DefaultGdbServerProviderConfigWidget::setFromProvider()
|
||||||
{
|
{
|
||||||
const auto p = static_cast<DefaultGdbServerProvider *>(provider());
|
const auto p = static_cast<DefaultGdbServerProvider *>(m_provider);
|
||||||
Q_ASSERT(p);
|
Q_ASSERT(p);
|
||||||
|
|
||||||
const QSignalBlocker blocker(this);
|
const QSignalBlocker blocker(this);
|
||||||
@@ -27,12 +27,14 @@
|
|||||||
|
|
||||||
#include "gdbserverprovider.h"
|
#include "gdbserverprovider.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QCheckBox;
|
||||||
|
class QPlainTextEdit;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace BareMetal {
|
namespace BareMetal {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class DefaultGdbServerProviderConfigWidget;
|
|
||||||
class DefaultGdbServerProviderFactory;
|
|
||||||
|
|
||||||
// DefaultGdbServerProvider
|
// DefaultGdbServerProvider
|
||||||
|
|
||||||
class DefaultGdbServerProvider final : public GdbServerProvider
|
class DefaultGdbServerProvider final : public GdbServerProvider
|
||||||
@@ -51,7 +53,8 @@ private:
|
|||||||
|
|
||||||
// DefaultGdbServerProviderFactory
|
// DefaultGdbServerProviderFactory
|
||||||
|
|
||||||
class DefaultGdbServerProviderFactory final : public GdbServerProviderFactory
|
class DefaultGdbServerProviderFactory final
|
||||||
|
: public IDebugServerProviderFactory
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -66,16 +69,18 @@ public:
|
|||||||
|
|
||||||
// DefaultGdbServerProviderConfigWidget
|
// DefaultGdbServerProviderConfigWidget
|
||||||
|
|
||||||
class DefaultGdbServerProviderConfigWidget final : public GdbServerProviderConfigWidget
|
class DefaultGdbServerProviderConfigWidget final
|
||||||
|
: public GdbServerProviderConfigWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DefaultGdbServerProviderConfigWidget(DefaultGdbServerProvider *);
|
explicit DefaultGdbServerProviderConfigWidget(
|
||||||
|
DefaultGdbServerProvider *provider);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void applyImpl() final;
|
void apply() final;
|
||||||
void discardImpl() final;
|
void discard() final;
|
||||||
|
|
||||||
void setFromProvider();
|
void setFromProvider();
|
||||||
|
|
||||||
@@ -23,27 +23,22 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "baremetaldevice.h"
|
|
||||||
#include "gdbserverprovider.h"
|
#include "gdbserverprovider.h"
|
||||||
#include "gdbserverprovidermanager.h"
|
|
||||||
|
#include <baremetal/baremetaldevice.h>
|
||||||
|
#include <baremetal/debugserverprovidermanager.h>
|
||||||
|
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QLabel>
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPlainTextEdit>
|
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QUuid>
|
|
||||||
|
|
||||||
namespace BareMetal {
|
namespace BareMetal {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
const char idKeyC[] = "BareMetal.GdbServerProvider.Id";
|
|
||||||
const char displayNameKeyC[] = "BareMetal.GdbServerProvider.DisplayName";
|
|
||||||
const char startupModeKeyC[] = "BareMetal.GdbServerProvider.Mode";
|
const char startupModeKeyC[] = "BareMetal.GdbServerProvider.Mode";
|
||||||
const char initCommandsKeyC[] = "BareMetal.GdbServerProvider.InitCommands";
|
const char initCommandsKeyC[] = "BareMetal.GdbServerProvider.InitCommands";
|
||||||
const char resetCommandsKeyC[] = "BareMetal.GdbServerProvider.ResetCommands";
|
const char resetCommandsKeyC[] = "BareMetal.GdbServerProvider.ResetCommands";
|
||||||
@@ -52,58 +47,20 @@ const char useExtendedRemoteKeyC[] = "BareMetal.GdbServerProvider.UseExtendedRem
|
|||||||
const char hostKeySuffixC[] = ".Host";
|
const char hostKeySuffixC[] = ".Host";
|
||||||
const char portKeySuffixC[] = ".Port";
|
const char portKeySuffixC[] = ".Port";
|
||||||
|
|
||||||
static QString createId(const QString &id)
|
|
||||||
{
|
|
||||||
QString newId = id.left(id.indexOf(QLatin1Char(':')));
|
|
||||||
newId.append(QLatin1Char(':') + QUuid::createUuid().toString());
|
|
||||||
return newId;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GdbServerProvider
|
// GdbServerProvider
|
||||||
|
|
||||||
GdbServerProvider::GdbServerProvider(const QString &id)
|
GdbServerProvider::GdbServerProvider(const QString &id)
|
||||||
: m_id(createId(id))
|
: IDebugServerProvider(id)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
GdbServerProvider::GdbServerProvider(const GdbServerProvider &other)
|
GdbServerProvider::GdbServerProvider(const GdbServerProvider &other)
|
||||||
: m_id(createId(other.m_id))
|
: IDebugServerProvider(other.id())
|
||||||
, m_startupMode(other.m_startupMode)
|
, m_startupMode(other.m_startupMode)
|
||||||
, m_initCommands(other.m_initCommands)
|
, m_initCommands(other.m_initCommands)
|
||||||
, m_resetCommands(other.m_resetCommands)
|
, m_resetCommands(other.m_resetCommands)
|
||||||
, m_useExtendedRemote(other.useExtendedRemote())
|
, m_useExtendedRemote(other.useExtendedRemote())
|
||||||
{
|
{
|
||||||
m_displayName = QCoreApplication::translate(
|
|
||||||
"BareMetal::GdbServerProvider", "Clone of %1")
|
|
||||||
.arg(other.displayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
GdbServerProvider::~GdbServerProvider()
|
|
||||||
{
|
|
||||||
const QSet<BareMetalDevice *> devices = m_devices;
|
|
||||||
for (BareMetalDevice *device : devices)
|
|
||||||
device->unregisterProvider(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString GdbServerProvider::displayName() const
|
|
||||||
{
|
|
||||||
if (m_displayName.isEmpty())
|
|
||||||
return typeDisplayName();
|
|
||||||
return m_displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GdbServerProvider::setDisplayName(const QString &name)
|
|
||||||
{
|
|
||||||
if (m_displayName == name)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_displayName = name;
|
|
||||||
providerUpdated();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString GdbServerProvider::id() const
|
|
||||||
{
|
|
||||||
return m_id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GdbServerProvider::StartupMode GdbServerProvider::startupMode() const
|
GdbServerProvider::StartupMode GdbServerProvider::startupMode() const
|
||||||
@@ -131,11 +88,6 @@ bool GdbServerProvider::useExtendedRemote() const
|
|||||||
return m_useExtendedRemote;
|
return m_useExtendedRemote;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GdbServerProvider::typeDisplayName() const
|
|
||||||
{
|
|
||||||
return m_typeDisplayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GdbServerProvider::setUseExtendedRemote(bool useExtendedRemote)
|
void GdbServerProvider::setUseExtendedRemote(bool useExtendedRemote)
|
||||||
{
|
{
|
||||||
m_useExtendedRemote = useExtendedRemote;
|
m_useExtendedRemote = useExtendedRemote;
|
||||||
@@ -172,21 +124,17 @@ Utils::CommandLine GdbServerProvider::command() const
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GdbServerProvider::operator==(const GdbServerProvider &other) const
|
bool GdbServerProvider::operator==(const IDebugServerProvider &other) const
|
||||||
{
|
{
|
||||||
if (this == &other)
|
if (!IDebugServerProvider::operator==(other))
|
||||||
return true;
|
return false;
|
||||||
|
|
||||||
const QString thisId = id().left(id().indexOf(QLatin1Char(':')));
|
const auto p = static_cast<const GdbServerProvider *>(&other);
|
||||||
const QString otherId = other.id().left(other.id().indexOf(QLatin1Char(':')));
|
return m_channel == p->m_channel
|
||||||
|
&& m_startupMode == p->m_startupMode
|
||||||
// We ignore displayname
|
&& m_initCommands == p->m_initCommands
|
||||||
return thisId == otherId
|
&& m_resetCommands == p->m_resetCommands
|
||||||
&& m_channel == other.m_channel
|
&& m_useExtendedRemote == p->m_useExtendedRemote;
|
||||||
&& m_startupMode == other.m_startupMode
|
|
||||||
&& m_initCommands == other.m_initCommands
|
|
||||||
&& m_resetCommands == other.m_resetCommands
|
|
||||||
&& m_useExtendedRemote == other.m_useExtendedRemote;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GdbServerProvider::channelString() const
|
QString GdbServerProvider::channelString() const
|
||||||
@@ -199,16 +147,14 @@ QString GdbServerProvider::channelString() const
|
|||||||
|
|
||||||
QVariantMap GdbServerProvider::toMap() const
|
QVariantMap GdbServerProvider::toMap() const
|
||||||
{
|
{
|
||||||
return {
|
QVariantMap data = IDebugServerProvider::toMap();
|
||||||
{QLatin1String(idKeyC), m_id},
|
data.insert(startupModeKeyC, m_startupMode);
|
||||||
{QLatin1String(displayNameKeyC), m_displayName},
|
data.insert(initCommandsKeyC, m_initCommands);
|
||||||
{QLatin1String(startupModeKeyC), m_startupMode},
|
data.insert(resetCommandsKeyC, m_resetCommands);
|
||||||
{QLatin1String(initCommandsKeyC), m_initCommands},
|
data.insert(useExtendedRemoteKeyC, m_useExtendedRemote);
|
||||||
{QLatin1String(resetCommandsKeyC), m_resetCommands},
|
data.insert(m_settingsBase + hostKeySuffixC, m_channel.host());
|
||||||
{QLatin1String(useExtendedRemoteKeyC), m_useExtendedRemote},
|
data.insert(m_settingsBase + portKeySuffixC, m_channel.port());
|
||||||
{m_settingsBase + hostKeySuffixC, m_channel.host()},
|
return data;
|
||||||
{m_settingsBase + portKeySuffixC, m_channel.port()},
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GdbServerProvider::isValid() const
|
bool GdbServerProvider::isValid() const
|
||||||
@@ -221,94 +167,31 @@ bool GdbServerProvider::canStartupMode(StartupMode m) const
|
|||||||
return m == NoStartup;
|
return m == NoStartup;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProvider::registerDevice(BareMetalDevice *device)
|
|
||||||
{
|
|
||||||
m_devices.insert(device);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GdbServerProvider::unregisterDevice(BareMetalDevice *device)
|
|
||||||
{
|
|
||||||
m_devices.remove(device);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GdbServerProvider::providerUpdated()
|
|
||||||
{
|
|
||||||
GdbServerProviderManager::notifyAboutUpdate(this);
|
|
||||||
for (BareMetalDevice *device : qAsConst(m_devices))
|
|
||||||
device->providerUpdated(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GdbServerProvider::fromMap(const QVariantMap &data)
|
bool GdbServerProvider::fromMap(const QVariantMap &data)
|
||||||
{
|
{
|
||||||
m_id = data.value(QLatin1String(idKeyC)).toString();
|
if (!IDebugServerProvider::fromMap(data))
|
||||||
m_displayName = data.value(QLatin1String(displayNameKeyC)).toString();
|
return false;
|
||||||
m_startupMode = static_cast<StartupMode>(data.value(QLatin1String(startupModeKeyC)).toInt());
|
|
||||||
m_initCommands = data.value(QLatin1String(initCommandsKeyC)).toString();
|
m_startupMode = static_cast<StartupMode>(data.value(startupModeKeyC).toInt());
|
||||||
m_resetCommands = data.value(QLatin1String(resetCommandsKeyC)).toString();
|
m_initCommands = data.value(initCommandsKeyC).toString();
|
||||||
m_useExtendedRemote = data.value(QLatin1String(useExtendedRemoteKeyC)).toBool();
|
m_resetCommands = data.value(resetCommandsKeyC).toString();
|
||||||
|
m_useExtendedRemote = data.value(useExtendedRemoteKeyC).toBool();
|
||||||
m_channel.setHost(data.value(m_settingsBase + hostKeySuffixC).toString());
|
m_channel.setHost(data.value(m_settingsBase + hostKeySuffixC).toString());
|
||||||
m_channel.setPort(data.value(m_settingsBase + portKeySuffixC).toInt());
|
m_channel.setPort(data.value(m_settingsBase + portKeySuffixC).toInt());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProvider::setTypeDisplayName(const QString &typeDisplayName)
|
|
||||||
{
|
|
||||||
m_typeDisplayName = typeDisplayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GdbServerProvider::setSettingsKeyBase(const QString &settingsBase)
|
void GdbServerProvider::setSettingsKeyBase(const QString &settingsBase)
|
||||||
{
|
{
|
||||||
m_settingsBase = settingsBase;
|
m_settingsBase = settingsBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GdbServerProviderFactory
|
|
||||||
|
|
||||||
QString GdbServerProviderFactory::id() const
|
|
||||||
{
|
|
||||||
return m_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GdbServerProviderFactory::setId(const QString &id)
|
|
||||||
{
|
|
||||||
m_id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString GdbServerProviderFactory::displayName() const
|
|
||||||
{
|
|
||||||
return m_displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GdbServerProviderFactory::setDisplayName(const QString &name)
|
|
||||||
{
|
|
||||||
m_displayName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString GdbServerProviderFactory::idFromMap(const QVariantMap &data)
|
|
||||||
{
|
|
||||||
return data.value(QLatin1String(idKeyC)).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GdbServerProviderFactory::idToMap(QVariantMap &data, const QString &id)
|
|
||||||
{
|
|
||||||
data.insert(QLatin1String(idKeyC), id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// GdbServerProviderConfigWidget
|
// GdbServerProviderConfigWidget
|
||||||
|
|
||||||
GdbServerProviderConfigWidget::GdbServerProviderConfigWidget(
|
GdbServerProviderConfigWidget::GdbServerProviderConfigWidget(
|
||||||
GdbServerProvider *provider)
|
GdbServerProvider *provider)
|
||||||
: m_provider(provider)
|
: IDebugServerProviderConfigWidget(provider)
|
||||||
{
|
{
|
||||||
Q_ASSERT(provider);
|
|
||||||
|
|
||||||
m_mainLayout = new QFormLayout(this);
|
|
||||||
m_mainLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
|
||||||
|
|
||||||
m_nameLineEdit = new QLineEdit(this);
|
|
||||||
m_nameLineEdit->setToolTip(tr("Enter the name of the GDB server provider."));
|
|
||||||
m_mainLayout->addRow(tr("Name:"), m_nameLineEdit);
|
|
||||||
|
|
||||||
m_startupModeComboBox = new QComboBox(this);
|
m_startupModeComboBox = new QComboBox(this);
|
||||||
m_startupModeComboBox->setToolTip(tr("Choose the desired startup mode "
|
m_startupModeComboBox->setToolTip(tr("Choose the desired startup mode "
|
||||||
"of the GDB server provider."));
|
"of the GDB server provider."));
|
||||||
@@ -317,8 +200,6 @@ GdbServerProviderConfigWidget::GdbServerProviderConfigWidget(
|
|||||||
populateStartupModes();
|
populateStartupModes();
|
||||||
setFromProvider();
|
setFromProvider();
|
||||||
|
|
||||||
connect(m_nameLineEdit, &QLineEdit::textChanged,
|
|
||||||
this, &GdbServerProviderConfigWidget::dirty);
|
|
||||||
connect(m_startupModeComboBox,
|
connect(m_startupModeComboBox,
|
||||||
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &GdbServerProviderConfigWidget::dirty);
|
this, &GdbServerProviderConfigWidget::dirty);
|
||||||
@@ -326,30 +207,14 @@ GdbServerProviderConfigWidget::GdbServerProviderConfigWidget(
|
|||||||
|
|
||||||
void GdbServerProviderConfigWidget::apply()
|
void GdbServerProviderConfigWidget::apply()
|
||||||
{
|
{
|
||||||
m_provider->setDisplayName(m_nameLineEdit->text());
|
static_cast<GdbServerProvider *>(m_provider)->setStartupMode(startupMode());
|
||||||
m_provider->setStartupMode(startupMode());
|
IDebugServerProviderConfigWidget::apply();
|
||||||
|
|
||||||
applyImpl();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProviderConfigWidget::discard()
|
void GdbServerProviderConfigWidget::discard()
|
||||||
{
|
{
|
||||||
m_nameLineEdit->setText(m_provider->displayName());
|
setFromProvider();
|
||||||
discardImpl();
|
IDebugServerProviderConfigWidget::discard();
|
||||||
}
|
|
||||||
|
|
||||||
GdbServerProvider *GdbServerProviderConfigWidget::provider() const
|
|
||||||
{
|
|
||||||
return m_provider;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GdbServerProviderConfigWidget::addErrorLabel()
|
|
||||||
{
|
|
||||||
if (!m_errorLabel) {
|
|
||||||
m_errorLabel = new QLabel;
|
|
||||||
m_errorLabel->setVisible(false);
|
|
||||||
}
|
|
||||||
m_mainLayout->addRow(m_errorLabel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GdbServerProvider::StartupMode GdbServerProviderConfigWidget::startupModeFromIndex(
|
GdbServerProvider::StartupMode GdbServerProviderConfigWidget::startupModeFromIndex(
|
||||||
@@ -379,7 +244,7 @@ void GdbServerProviderConfigWidget::populateStartupModes()
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < GdbServerProvider::StartupModesCount; ++i) {
|
for (int i = 0; i < GdbServerProvider::StartupModesCount; ++i) {
|
||||||
const auto m = static_cast<GdbServerProvider::StartupMode>(i);
|
const auto m = static_cast<GdbServerProvider::StartupMode>(i);
|
||||||
if (!m_provider->canStartupMode(m))
|
if (!static_cast<GdbServerProvider *>(m_provider)->canStartupMode(m))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const int idx = m_startupModeComboBox->count();
|
const int idx = m_startupModeComboBox->count();
|
||||||
@@ -394,31 +259,9 @@ void GdbServerProviderConfigWidget::populateStartupModes()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerProviderConfigWidget::setErrorMessage(const QString &m)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(m_errorLabel, return);
|
|
||||||
if (m.isEmpty()) {
|
|
||||||
clearErrorMessage();
|
|
||||||
} else {
|
|
||||||
m_errorLabel->setText(m);
|
|
||||||
m_errorLabel->setStyleSheet(QLatin1String("background-color: \"red\""));
|
|
||||||
m_errorLabel->setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GdbServerProviderConfigWidget::clearErrorMessage()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(m_errorLabel, return);
|
|
||||||
m_errorLabel->clear();
|
|
||||||
m_errorLabel->setStyleSheet(QString());
|
|
||||||
m_errorLabel->setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GdbServerProviderConfigWidget::setFromProvider()
|
void GdbServerProviderConfigWidget::setFromProvider()
|
||||||
{
|
{
|
||||||
const QSignalBlocker blocker(this);
|
setStartupMode(static_cast<GdbServerProvider *>(m_provider)->startupMode());
|
||||||
m_nameLineEdit->setText(m_provider->displayName());
|
|
||||||
setStartupMode(m_provider->startupMode());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GdbServerProviderConfigWidget::defaultInitCommandsTooltip()
|
QString GdbServerProviderConfigWidget::defaultInitCommandsTooltip()
|
||||||
@@ -435,6 +278,17 @@ QString GdbServerProviderConfigWidget::defaultResetCommandsTooltip()
|
|||||||
"The MCU should be halted after these commands.");
|
"The MCU should be halted after these commands.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GdbServerProviderRunner
|
||||||
|
|
||||||
|
GdbServerProviderRunner::GdbServerProviderRunner(ProjectExplorer::RunControl *runControl,
|
||||||
|
const ProjectExplorer::Runnable &runnable)
|
||||||
|
: SimpleTargetRunner(runControl)
|
||||||
|
{
|
||||||
|
setId("BareMetalGdbServer");
|
||||||
|
// Baremetal's GDB servers are launched on the host, not on the target.
|
||||||
|
setStarter([this, runnable] { doStart(runnable, {}); });
|
||||||
|
}
|
||||||
|
|
||||||
// HostWidget
|
// HostWidget
|
||||||
|
|
||||||
HostWidget::HostWidget(QWidget *parent)
|
HostWidget::HostWidget(QWidget *parent)
|
||||||
@@ -25,33 +25,23 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QObject>
|
#include <baremetal/idebugserverprovider.h>
|
||||||
#include <QSet>
|
|
||||||
#include <QVariantMap>
|
#include <projectexplorer/runcontrol.h>
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QCheckBox;
|
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QFormLayout;
|
|
||||||
class QLabel;
|
|
||||||
class QLineEdit;
|
|
||||||
class QPlainTextEdit;
|
|
||||||
class QSpinBox;
|
class QSpinBox;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace BareMetal {
|
namespace BareMetal {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class BareMetalDevice;
|
|
||||||
class GdbServerProviderConfigWidget;
|
|
||||||
class GdbServerProviderManager;
|
|
||||||
|
|
||||||
// GdbServerProvider
|
// GdbServerProvider
|
||||||
|
|
||||||
class GdbServerProvider
|
class GdbServerProvider : public IDebugServerProvider
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum StartupMode {
|
enum StartupMode {
|
||||||
@@ -61,137 +51,81 @@ public:
|
|||||||
StartupModesCount
|
StartupModesCount
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~GdbServerProvider();
|
|
||||||
|
|
||||||
QString displayName() const;
|
|
||||||
void setDisplayName(const QString &name);
|
|
||||||
|
|
||||||
QString id() const;
|
|
||||||
|
|
||||||
StartupMode startupMode() const;
|
StartupMode startupMode() const;
|
||||||
QString initCommands() const;
|
QString initCommands() const;
|
||||||
QString resetCommands() const;
|
QString resetCommands() const;
|
||||||
bool useExtendedRemote() const;
|
bool useExtendedRemote() const;
|
||||||
QString typeDisplayName() const;
|
|
||||||
|
|
||||||
virtual bool operator==(const GdbServerProvider &) const;
|
bool operator==(const IDebugServerProvider &other) const override;
|
||||||
|
|
||||||
virtual GdbServerProviderConfigWidget *configurationWidget() = 0;
|
|
||||||
|
|
||||||
virtual QString channelString() const;
|
virtual QString channelString() const;
|
||||||
virtual GdbServerProvider *clone() const = 0;
|
|
||||||
|
|
||||||
virtual QVariantMap toMap() const;
|
QVariantMap toMap() const override;
|
||||||
|
|
||||||
virtual Utils::CommandLine command() const;
|
virtual Utils::CommandLine command() const;
|
||||||
|
|
||||||
virtual bool isValid() const;
|
bool isValid() const override;
|
||||||
|
Debugger::DebuggerEngineType engineType() const final {
|
||||||
|
return Debugger::DebuggerEngineType::GdbEngineType; }
|
||||||
virtual bool canStartupMode(StartupMode) const;
|
virtual bool canStartupMode(StartupMode) const;
|
||||||
|
|
||||||
void registerDevice(BareMetalDevice *);
|
|
||||||
void unregisterDevice(BareMetalDevice *);
|
|
||||||
|
|
||||||
QUrl channel() const;
|
QUrl channel() const;
|
||||||
void setChannel(const QUrl &channelString);
|
void setChannel(const QUrl &channelString);
|
||||||
void setDefaultChannel(const QString &host, int port);
|
void setDefaultChannel(const QString &host, int port);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit GdbServerProvider(const QString &id);
|
explicit GdbServerProvider(const QString &id);
|
||||||
explicit GdbServerProvider(const GdbServerProvider &);
|
explicit GdbServerProvider(const GdbServerProvider &other);
|
||||||
|
|
||||||
void setStartupMode(StartupMode);
|
void setStartupMode(StartupMode);
|
||||||
void setInitCommands(const QString &);
|
void setInitCommands(const QString &);
|
||||||
void setResetCommands(const QString &);
|
void setResetCommands(const QString &);
|
||||||
void setUseExtendedRemote(bool);
|
void setUseExtendedRemote(bool);
|
||||||
void setSettingsKeyBase(const QString &settingsBase);
|
void setSettingsKeyBase(const QString &settingsBase);
|
||||||
void setTypeDisplayName(const QString &typeDisplayName);
|
|
||||||
|
|
||||||
void providerUpdated();
|
bool fromMap(const QVariantMap &data) override;
|
||||||
|
|
||||||
virtual bool fromMap(const QVariantMap &data);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_id;
|
|
||||||
QString m_settingsBase;
|
QString m_settingsBase;
|
||||||
mutable QString m_displayName;
|
|
||||||
QString m_typeDisplayName;
|
|
||||||
QUrl m_channel;
|
QUrl m_channel;
|
||||||
StartupMode m_startupMode = NoStartup;
|
StartupMode m_startupMode = NoStartup;
|
||||||
QString m_initCommands;
|
QString m_initCommands;
|
||||||
QString m_resetCommands;
|
QString m_resetCommands;
|
||||||
QSet<BareMetalDevice *> m_devices;
|
|
||||||
bool m_useExtendedRemote = false;
|
bool m_useExtendedRemote = false;
|
||||||
|
|
||||||
friend class GdbServerProviderConfigWidget;
|
friend class GdbServerProviderConfigWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
// GdbServerProviderFactory
|
|
||||||
|
|
||||||
class GdbServerProviderFactory : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
QString id() const;
|
|
||||||
QString displayName() const;
|
|
||||||
|
|
||||||
virtual GdbServerProvider *create() = 0;
|
|
||||||
|
|
||||||
virtual bool canRestore(const QVariantMap &data) const = 0;
|
|
||||||
virtual GdbServerProvider *restore(const QVariantMap &data) = 0;
|
|
||||||
|
|
||||||
static QString idFromMap(const QVariantMap &data);
|
|
||||||
static void idToMap(QVariantMap &data, const QString &id);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void setId(const QString &id);
|
|
||||||
void setDisplayName(const QString &name);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_displayName;
|
|
||||||
QString m_id;
|
|
||||||
};
|
|
||||||
|
|
||||||
// GdbServerProviderConfigWidget
|
// GdbServerProviderConfigWidget
|
||||||
|
|
||||||
class GdbServerProviderConfigWidget : public QWidget
|
class GdbServerProviderConfigWidget : public IDebugServerProviderConfigWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GdbServerProviderConfigWidget(GdbServerProvider *);
|
explicit GdbServerProviderConfigWidget(GdbServerProvider *provider);
|
||||||
GdbServerProvider *provider() const;
|
void apply() override;
|
||||||
void apply();
|
void discard() override;
|
||||||
void discard();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void dirty();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void applyImpl() = 0;
|
|
||||||
virtual void discardImpl() = 0;
|
|
||||||
|
|
||||||
void setErrorMessage(const QString &);
|
|
||||||
void clearErrorMessage();
|
|
||||||
void addErrorLabel();
|
|
||||||
|
|
||||||
GdbServerProvider::StartupMode startupModeFromIndex(int idx) const;
|
GdbServerProvider::StartupMode startupModeFromIndex(int idx) const;
|
||||||
GdbServerProvider::StartupMode startupMode() const;
|
GdbServerProvider::StartupMode startupMode() const;
|
||||||
void setStartupMode(GdbServerProvider::StartupMode mode);
|
void setStartupMode(GdbServerProvider::StartupMode mode);
|
||||||
void populateStartupModes();
|
void populateStartupModes();
|
||||||
|
void setFromProvider();
|
||||||
|
|
||||||
static QString defaultInitCommandsTooltip();
|
static QString defaultInitCommandsTooltip();
|
||||||
static QString defaultResetCommandsTooltip();
|
static QString defaultResetCommandsTooltip();
|
||||||
|
|
||||||
QFormLayout *m_mainLayout = nullptr;
|
|
||||||
QLineEdit *m_nameLineEdit = nullptr;
|
|
||||||
QComboBox *m_startupModeComboBox = nullptr;
|
QComboBox *m_startupModeComboBox = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
// GdbServerProviderRunner
|
||||||
void setFromProvider();
|
|
||||||
|
|
||||||
GdbServerProvider *m_provider = nullptr;
|
class GdbServerProviderRunner final : public ProjectExplorer::SimpleTargetRunner
|
||||||
QLabel *m_errorLabel = nullptr;
|
{
|
||||||
|
public:
|
||||||
|
explicit GdbServerProviderRunner(ProjectExplorer::RunControl *runControl,
|
||||||
|
const ProjectExplorer::Runnable &runnable);
|
||||||
};
|
};
|
||||||
|
|
||||||
// HostWidget
|
// HostWidget
|
||||||
@@ -209,7 +143,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void dataChanged();
|
void dataChanged();
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
QLineEdit *m_hostLineEdit = nullptr;
|
QLineEdit *m_hostLineEdit = nullptr;
|
||||||
QSpinBox *m_portSpinBox = nullptr;
|
QSpinBox *m_portSpinBox = nullptr;
|
||||||
};
|
};
|
||||||
13
src/plugins/baremetal/debugservers/gdb/gdbservers.pri
Normal file
13
src/plugins/baremetal/debugservers/gdb/gdbservers.pri
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
HEADERS += \
|
||||||
|
$$PWD/defaultgdbserverprovider.h \
|
||||||
|
$$PWD/gdbserverprovider.h \
|
||||||
|
$$PWD/gdbserverproviderprocess.h \
|
||||||
|
$$PWD/openocdgdbserverprovider.h \
|
||||||
|
$$PWD/stlinkutilgdbserverprovider.h \
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
$$PWD/defaultgdbserverprovider.cpp \
|
||||||
|
$$PWD/gdbserverprovider.cpp \
|
||||||
|
$$PWD/gdbserverproviderprocess.cpp \
|
||||||
|
$$PWD/openocdgdbserverprovider.cpp \
|
||||||
|
$$PWD/stlinkutilgdbserverprovider.cpp \
|
||||||
@@ -23,20 +23,19 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "baremetalconstants.h"
|
|
||||||
|
|
||||||
#include "gdbserverprovidermanager.h"
|
|
||||||
#include "openocdgdbserverprovider.h"
|
#include "openocdgdbserverprovider.h"
|
||||||
|
|
||||||
|
#include <baremetal/baremetalconstants.h>
|
||||||
|
#include <baremetal/debugserverprovidermanager.h>
|
||||||
|
|
||||||
|
#include <coreplugin/variablechooser.h>
|
||||||
|
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/pathchooser.h>
|
#include <utils/pathchooser.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
|
|
||||||
#include <coreplugin/variablechooser.h>
|
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
@@ -158,10 +157,10 @@ GdbServerProvider *OpenOcdGdbServerProvider::clone() const
|
|||||||
QVariantMap OpenOcdGdbServerProvider::toMap() const
|
QVariantMap OpenOcdGdbServerProvider::toMap() const
|
||||||
{
|
{
|
||||||
QVariantMap data = GdbServerProvider::toMap();
|
QVariantMap data = GdbServerProvider::toMap();
|
||||||
data.insert(QLatin1String(executableFileKeyC), m_executableFile.toVariant());
|
data.insert(executableFileKeyC, m_executableFile.toVariant());
|
||||||
data.insert(QLatin1String(rootScriptsDirKeyC), m_rootScriptsDir);
|
data.insert(rootScriptsDirKeyC, m_rootScriptsDir);
|
||||||
data.insert(QLatin1String(configurationFileKeyC), m_configurationFile);
|
data.insert(configurationFileKeyC, m_configurationFile);
|
||||||
data.insert(QLatin1String(additionalArgumentsKeyC), m_additionalArguments);
|
data.insert(additionalArgumentsKeyC, m_additionalArguments);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,14 +169,14 @@ bool OpenOcdGdbServerProvider::fromMap(const QVariantMap &data)
|
|||||||
if (!GdbServerProvider::fromMap(data))
|
if (!GdbServerProvider::fromMap(data))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_executableFile = FilePath::fromVariant(data.value(QLatin1String(executableFileKeyC)));
|
m_executableFile = FilePath::fromVariant(data.value(executableFileKeyC));
|
||||||
m_rootScriptsDir = data.value(QLatin1String(rootScriptsDirKeyC)).toString();
|
m_rootScriptsDir = data.value(rootScriptsDirKeyC).toString();
|
||||||
m_configurationFile = data.value(QLatin1String(configurationFileKeyC)).toString();
|
m_configurationFile = data.value(configurationFileKeyC).toString();
|
||||||
m_additionalArguments = data.value(QLatin1String(additionalArgumentsKeyC)).toString();
|
m_additionalArguments = data.value(additionalArgumentsKeyC).toString();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenOcdGdbServerProvider::operator==(const GdbServerProvider &other) const
|
bool OpenOcdGdbServerProvider::operator==(const IDebugServerProvider &other) const
|
||||||
{
|
{
|
||||||
if (!GdbServerProvider::operator==(other))
|
if (!GdbServerProvider::operator==(other))
|
||||||
return false;
|
return false;
|
||||||
@@ -227,10 +226,10 @@ GdbServerProvider *OpenOcdGdbServerProviderFactory::restore(const QVariantMap &d
|
|||||||
// OpenOcdGdbServerProviderConfigWidget
|
// OpenOcdGdbServerProviderConfigWidget
|
||||||
|
|
||||||
OpenOcdGdbServerProviderConfigWidget::OpenOcdGdbServerProviderConfigWidget(
|
OpenOcdGdbServerProviderConfigWidget::OpenOcdGdbServerProviderConfigWidget(
|
||||||
OpenOcdGdbServerProvider *p)
|
OpenOcdGdbServerProvider *provider)
|
||||||
: GdbServerProviderConfigWidget(p)
|
: GdbServerProviderConfigWidget(provider)
|
||||||
{
|
{
|
||||||
Q_ASSERT(p);
|
Q_ASSERT(provider);
|
||||||
|
|
||||||
m_hostWidget = new HostWidget(this);
|
m_hostWidget = new HostWidget(this);
|
||||||
m_mainLayout->addRow(tr("Host:"), m_hostWidget);
|
m_mainLayout->addRow(tr("Host:"), m_hostWidget);
|
||||||
@@ -285,6 +284,27 @@ OpenOcdGdbServerProviderConfigWidget::OpenOcdGdbServerProviderConfigWidget(
|
|||||||
this, &OpenOcdGdbServerProviderConfigWidget::startupModeChanged);
|
this, &OpenOcdGdbServerProviderConfigWidget::startupModeChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenOcdGdbServerProviderConfigWidget::apply()
|
||||||
|
{
|
||||||
|
const auto p = static_cast<OpenOcdGdbServerProvider *>(m_provider);
|
||||||
|
Q_ASSERT(p);
|
||||||
|
|
||||||
|
p->setChannel(m_hostWidget->channel());
|
||||||
|
p->m_executableFile = m_executableFileChooser->fileName();
|
||||||
|
p->m_rootScriptsDir = m_rootScriptsDirChooser->fileName().toString();
|
||||||
|
p->m_configurationFile = m_configurationFileChooser->fileName().toString();
|
||||||
|
p->m_additionalArguments = m_additionalArgumentsLineEdit->text();
|
||||||
|
p->setInitCommands(m_initCommandsTextEdit->toPlainText());
|
||||||
|
p->setResetCommands(m_resetCommandsTextEdit->toPlainText());
|
||||||
|
GdbServerProviderConfigWidget::apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenOcdGdbServerProviderConfigWidget::discard()
|
||||||
|
{
|
||||||
|
setFromProvider();
|
||||||
|
GdbServerProviderConfigWidget::discard();
|
||||||
|
}
|
||||||
|
|
||||||
void OpenOcdGdbServerProviderConfigWidget::startupModeChanged()
|
void OpenOcdGdbServerProviderConfigWidget::startupModeChanged()
|
||||||
{
|
{
|
||||||
const GdbServerProvider::StartupMode m = startupMode();
|
const GdbServerProvider::StartupMode m = startupMode();
|
||||||
@@ -302,28 +322,9 @@ void OpenOcdGdbServerProviderConfigWidget::startupModeChanged()
|
|||||||
m_mainLayout->labelForField(m_hostWidget)->setVisible(isNetwork);
|
m_mainLayout->labelForField(m_hostWidget)->setVisible(isNetwork);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenOcdGdbServerProviderConfigWidget::applyImpl()
|
|
||||||
{
|
|
||||||
const auto p = static_cast<OpenOcdGdbServerProvider *>(provider());
|
|
||||||
Q_ASSERT(p);
|
|
||||||
|
|
||||||
p->setChannel(m_hostWidget->channel());
|
|
||||||
p->m_executableFile = m_executableFileChooser->fileName();
|
|
||||||
p->m_rootScriptsDir = m_rootScriptsDirChooser->fileName().toString();
|
|
||||||
p->m_configurationFile = m_configurationFileChooser->fileName().toString();
|
|
||||||
p->m_additionalArguments = m_additionalArgumentsLineEdit->text();
|
|
||||||
p->setInitCommands(m_initCommandsTextEdit->toPlainText());
|
|
||||||
p->setResetCommands(m_resetCommandsTextEdit->toPlainText());
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenOcdGdbServerProviderConfigWidget::discardImpl()
|
|
||||||
{
|
|
||||||
setFromProvider();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenOcdGdbServerProviderConfigWidget::setFromProvider()
|
void OpenOcdGdbServerProviderConfigWidget::setFromProvider()
|
||||||
{
|
{
|
||||||
const auto p = static_cast<OpenOcdGdbServerProvider *>(provider());
|
const auto p = static_cast<OpenOcdGdbServerProvider *>(m_provider);
|
||||||
Q_ASSERT(p);
|
Q_ASSERT(p);
|
||||||
|
|
||||||
const QSignalBlocker blocker(this);
|
const QSignalBlocker blocker(this);
|
||||||
@@ -27,14 +27,15 @@
|
|||||||
|
|
||||||
#include "gdbserverprovider.h"
|
#include "gdbserverprovider.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QPlainTextEdit;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Utils { class PathChooser; }
|
namespace Utils { class PathChooser; }
|
||||||
|
|
||||||
namespace BareMetal {
|
namespace BareMetal {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class OpenOcdGdbServerProviderConfigWidget;
|
|
||||||
class OpenOcdGdbServerProviderFactory;
|
|
||||||
|
|
||||||
// OpenOcdGdbServerProvider
|
// OpenOcdGdbServerProvider
|
||||||
|
|
||||||
class OpenOcdGdbServerProvider final : public GdbServerProvider
|
class OpenOcdGdbServerProvider final : public GdbServerProvider
|
||||||
@@ -43,7 +44,7 @@ public:
|
|||||||
QVariantMap toMap() const final;
|
QVariantMap toMap() const final;
|
||||||
bool fromMap(const QVariantMap &data) final;
|
bool fromMap(const QVariantMap &data) final;
|
||||||
|
|
||||||
bool operator==(const GdbServerProvider &) const final;
|
bool operator==(const IDebugServerProvider &other) const final;
|
||||||
|
|
||||||
GdbServerProviderConfigWidget *configurationWidget() final;
|
GdbServerProviderConfigWidget *configurationWidget() final;
|
||||||
GdbServerProvider *clone() const final;
|
GdbServerProvider *clone() const final;
|
||||||
@@ -53,6 +54,7 @@ public:
|
|||||||
|
|
||||||
bool canStartupMode(StartupMode mode) const final;
|
bool canStartupMode(StartupMode mode) const final;
|
||||||
bool isValid() const final;
|
bool isValid() const final;
|
||||||
|
bool hasProcess() const final { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit OpenOcdGdbServerProvider();
|
explicit OpenOcdGdbServerProvider();
|
||||||
@@ -71,7 +73,8 @@ private:
|
|||||||
|
|
||||||
// OpenOcdGdbServerProviderFactory
|
// OpenOcdGdbServerProviderFactory
|
||||||
|
|
||||||
class OpenOcdGdbServerProviderFactory final : public GdbServerProviderFactory
|
class OpenOcdGdbServerProviderFactory final
|
||||||
|
: public IDebugServerProviderFactory
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -82,25 +85,24 @@ public:
|
|||||||
|
|
||||||
bool canRestore(const QVariantMap &data) const final;
|
bool canRestore(const QVariantMap &data) const final;
|
||||||
GdbServerProvider *restore(const QVariantMap &data) final;
|
GdbServerProvider *restore(const QVariantMap &data) final;
|
||||||
|
|
||||||
GdbServerProviderConfigWidget *configurationWidget(GdbServerProvider *);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// OpenOcdGdbServerProviderConfigWidget
|
// OpenOcdGdbServerProviderConfigWidget
|
||||||
|
|
||||||
class OpenOcdGdbServerProviderConfigWidget final : public GdbServerProviderConfigWidget
|
class OpenOcdGdbServerProviderConfigWidget final
|
||||||
|
: public GdbServerProviderConfigWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit OpenOcdGdbServerProviderConfigWidget(OpenOcdGdbServerProvider *);
|
explicit OpenOcdGdbServerProviderConfigWidget(
|
||||||
|
OpenOcdGdbServerProvider *provider);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void apply() final;
|
||||||
|
void discard() final;
|
||||||
|
|
||||||
void startupModeChanged();
|
void startupModeChanged();
|
||||||
|
|
||||||
void applyImpl() final;
|
|
||||||
void discardImpl() final;
|
|
||||||
|
|
||||||
void setFromProvider();
|
void setFromProvider();
|
||||||
|
|
||||||
HostWidget *m_hostWidget = nullptr;
|
HostWidget *m_hostWidget = nullptr;
|
||||||
@@ -23,22 +23,20 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "baremetalconstants.h"
|
|
||||||
|
|
||||||
#include "gdbserverprovidermanager.h"
|
|
||||||
#include "stlinkutilgdbserverprovider.h"
|
#include "stlinkutilgdbserverprovider.h"
|
||||||
|
|
||||||
|
#include <baremetal/baremetalconstants.h>
|
||||||
|
#include <baremetal/debugserverprovidermanager.h>
|
||||||
|
|
||||||
|
#include <coreplugin/variablechooser.h>
|
||||||
|
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/pathchooser.h>
|
#include <utils/pathchooser.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <coreplugin/variablechooser.h>
|
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
|
|
||||||
@@ -152,11 +150,11 @@ GdbServerProvider *StLinkUtilGdbServerProvider::clone() const
|
|||||||
QVariantMap StLinkUtilGdbServerProvider::toMap() const
|
QVariantMap StLinkUtilGdbServerProvider::toMap() const
|
||||||
{
|
{
|
||||||
QVariantMap data = GdbServerProvider::toMap();
|
QVariantMap data = GdbServerProvider::toMap();
|
||||||
data.insert(QLatin1String(executableFileKeyC), m_executableFile.toVariant());
|
data.insert(executableFileKeyC, m_executableFile.toVariant());
|
||||||
data.insert(QLatin1String(verboseLevelKeyC), m_verboseLevel);
|
data.insert(verboseLevelKeyC, m_verboseLevel);
|
||||||
data.insert(QLatin1String(extendedModeKeyC), m_extendedMode);
|
data.insert(extendedModeKeyC, m_extendedMode);
|
||||||
data.insert(QLatin1String(resetBoardKeyC), m_resetBoard);
|
data.insert(resetBoardKeyC, m_resetBoard);
|
||||||
data.insert(QLatin1String(transportLayerKeyC), m_transport);
|
data.insert(transportLayerKeyC, m_transport);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,16 +163,16 @@ bool StLinkUtilGdbServerProvider::fromMap(const QVariantMap &data)
|
|||||||
if (!GdbServerProvider::fromMap(data))
|
if (!GdbServerProvider::fromMap(data))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_executableFile = FilePath::fromVariant(data.value(QLatin1String(executableFileKeyC)));
|
m_executableFile = FilePath::fromVariant(data.value(executableFileKeyC));
|
||||||
m_verboseLevel = data.value(QLatin1String(verboseLevelKeyC)).toInt();
|
m_verboseLevel = data.value(verboseLevelKeyC).toInt();
|
||||||
m_extendedMode = data.value(QLatin1String(extendedModeKeyC)).toBool();
|
m_extendedMode = data.value(extendedModeKeyC).toBool();
|
||||||
m_resetBoard = data.value(QLatin1String(resetBoardKeyC)).toBool();
|
m_resetBoard = data.value(resetBoardKeyC).toBool();
|
||||||
m_transport = static_cast<TransportLayer>(
|
m_transport = static_cast<TransportLayer>(
|
||||||
data.value(QLatin1String(transportLayerKeyC)).toInt());
|
data.value(transportLayerKeyC).toInt());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StLinkUtilGdbServerProvider::operator==(const GdbServerProvider &other) const
|
bool StLinkUtilGdbServerProvider::operator==(const IDebugServerProvider &other) const
|
||||||
{
|
{
|
||||||
if (!GdbServerProvider::operator==(other))
|
if (!GdbServerProvider::operator==(other))
|
||||||
return false;
|
return false;
|
||||||
@@ -296,25 +294,9 @@ StLinkUtilGdbServerProviderConfigWidget::StLinkUtilGdbServerProviderConfigWidget
|
|||||||
this, &StLinkUtilGdbServerProviderConfigWidget::startupModeChanged);
|
this, &StLinkUtilGdbServerProviderConfigWidget::startupModeChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StLinkUtilGdbServerProviderConfigWidget::startupModeChanged()
|
void StLinkUtilGdbServerProviderConfigWidget::apply()
|
||||||
{
|
{
|
||||||
const GdbServerProvider::StartupMode m = startupMode();
|
const auto p = static_cast<StLinkUtilGdbServerProvider *>(m_provider);
|
||||||
const bool isStartup = m != GdbServerProvider::NoStartup;
|
|
||||||
m_executableFileChooser->setVisible(isStartup);
|
|
||||||
m_mainLayout->labelForField(m_executableFileChooser)->setVisible(isStartup);
|
|
||||||
m_verboseLevelSpinBox->setVisible(isStartup);
|
|
||||||
m_mainLayout->labelForField(m_verboseLevelSpinBox)->setVisible(isStartup);
|
|
||||||
m_extendedModeCheckBox->setVisible(isStartup);
|
|
||||||
m_mainLayout->labelForField(m_extendedModeCheckBox)->setVisible(isStartup);
|
|
||||||
m_resetBoardCheckBox->setVisible(isStartup);
|
|
||||||
m_mainLayout->labelForField(m_resetBoardCheckBox)->setVisible(isStartup);
|
|
||||||
m_transportLayerComboBox->setVisible(isStartup);
|
|
||||||
m_mainLayout->labelForField(m_transportLayerComboBox)->setVisible(isStartup);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StLinkUtilGdbServerProviderConfigWidget::applyImpl()
|
|
||||||
{
|
|
||||||
const auto p = static_cast<StLinkUtilGdbServerProvider *>(provider());
|
|
||||||
Q_ASSERT(p);
|
Q_ASSERT(p);
|
||||||
|
|
||||||
p->setChannel(m_hostWidget->channel());
|
p->setChannel(m_hostWidget->channel());
|
||||||
@@ -325,11 +307,13 @@ void StLinkUtilGdbServerProviderConfigWidget::applyImpl()
|
|||||||
p->m_transport = transportLayer();
|
p->m_transport = transportLayer();
|
||||||
p->setInitCommands(m_initCommandsTextEdit->toPlainText());
|
p->setInitCommands(m_initCommandsTextEdit->toPlainText());
|
||||||
p->setResetCommands(m_resetCommandsTextEdit->toPlainText());
|
p->setResetCommands(m_resetCommandsTextEdit->toPlainText());
|
||||||
|
GdbServerProviderConfigWidget::apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StLinkUtilGdbServerProviderConfigWidget::discardImpl()
|
void StLinkUtilGdbServerProviderConfigWidget::discard()
|
||||||
{
|
{
|
||||||
setFromProvider();
|
setFromProvider();
|
||||||
|
GdbServerProviderConfigWidget::discard();
|
||||||
}
|
}
|
||||||
|
|
||||||
StLinkUtilGdbServerProvider::TransportLayer
|
StLinkUtilGdbServerProvider::TransportLayer
|
||||||
@@ -357,6 +341,22 @@ void StLinkUtilGdbServerProviderConfigWidget::setTransportLayer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StLinkUtilGdbServerProviderConfigWidget::startupModeChanged()
|
||||||
|
{
|
||||||
|
const GdbServerProvider::StartupMode m = startupMode();
|
||||||
|
const bool isStartup = m != GdbServerProvider::NoStartup;
|
||||||
|
m_executableFileChooser->setVisible(isStartup);
|
||||||
|
m_mainLayout->labelForField(m_executableFileChooser)->setVisible(isStartup);
|
||||||
|
m_verboseLevelSpinBox->setVisible(isStartup);
|
||||||
|
m_mainLayout->labelForField(m_verboseLevelSpinBox)->setVisible(isStartup);
|
||||||
|
m_extendedModeCheckBox->setVisible(isStartup);
|
||||||
|
m_mainLayout->labelForField(m_extendedModeCheckBox)->setVisible(isStartup);
|
||||||
|
m_resetBoardCheckBox->setVisible(isStartup);
|
||||||
|
m_mainLayout->labelForField(m_resetBoardCheckBox)->setVisible(isStartup);
|
||||||
|
m_transportLayerComboBox->setVisible(isStartup);
|
||||||
|
m_mainLayout->labelForField(m_transportLayerComboBox)->setVisible(isStartup);
|
||||||
|
}
|
||||||
|
|
||||||
void StLinkUtilGdbServerProviderConfigWidget::populateTransportLayers()
|
void StLinkUtilGdbServerProviderConfigWidget::populateTransportLayers()
|
||||||
{
|
{
|
||||||
m_transportLayerComboBox->insertItem(
|
m_transportLayerComboBox->insertItem(
|
||||||
@@ -369,7 +369,7 @@ void StLinkUtilGdbServerProviderConfigWidget::populateTransportLayers()
|
|||||||
|
|
||||||
void StLinkUtilGdbServerProviderConfigWidget::setFromProvider()
|
void StLinkUtilGdbServerProviderConfigWidget::setFromProvider()
|
||||||
{
|
{
|
||||||
const auto p = static_cast<StLinkUtilGdbServerProvider *>(provider());
|
const auto p = static_cast<StLinkUtilGdbServerProvider *>(m_provider);
|
||||||
Q_ASSERT(p);
|
Q_ASSERT(p);
|
||||||
|
|
||||||
const QSignalBlocker blocker(this);
|
const QSignalBlocker blocker(this);
|
||||||
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
|
class QPlainTextEdit;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Utils { class PathChooser; }
|
namespace Utils { class PathChooser; }
|
||||||
@@ -36,9 +37,6 @@ namespace Utils { class PathChooser; }
|
|||||||
namespace BareMetal {
|
namespace BareMetal {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class StLinkUtilGdbServerProviderConfigWidget;
|
|
||||||
class StLinkUtilGdbServerProviderFactory;
|
|
||||||
|
|
||||||
// StLinkUtilGdbServerProvider
|
// StLinkUtilGdbServerProvider
|
||||||
|
|
||||||
class StLinkUtilGdbServerProvider final : public GdbServerProvider
|
class StLinkUtilGdbServerProvider final : public GdbServerProvider
|
||||||
@@ -49,7 +47,7 @@ public:
|
|||||||
QVariantMap toMap() const final;
|
QVariantMap toMap() const final;
|
||||||
bool fromMap(const QVariantMap &data) final;
|
bool fromMap(const QVariantMap &data) final;
|
||||||
|
|
||||||
bool operator==(const GdbServerProvider &) const final;
|
bool operator==(const IDebugServerProvider &other) const final;
|
||||||
|
|
||||||
GdbServerProviderConfigWidget *configurationWidget() final;
|
GdbServerProviderConfigWidget *configurationWidget() final;
|
||||||
GdbServerProvider *clone() const final;
|
GdbServerProvider *clone() const final;
|
||||||
@@ -59,6 +57,7 @@ public:
|
|||||||
|
|
||||||
bool canStartupMode(StartupMode mode) const final;
|
bool canStartupMode(StartupMode mode) const final;
|
||||||
bool isValid() const final;
|
bool isValid() const final;
|
||||||
|
bool hasProcess() const final { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit StLinkUtilGdbServerProvider();
|
explicit StLinkUtilGdbServerProvider();
|
||||||
@@ -79,7 +78,8 @@ private:
|
|||||||
|
|
||||||
// StLinkUtilGdbServerProviderFactory
|
// StLinkUtilGdbServerProviderFactory
|
||||||
|
|
||||||
class StLinkUtilGdbServerProviderFactory final : public GdbServerProviderFactory
|
class StLinkUtilGdbServerProviderFactory final
|
||||||
|
: public IDebugServerProviderFactory
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -90,8 +90,6 @@ public:
|
|||||||
|
|
||||||
bool canRestore(const QVariantMap &data) const final;
|
bool canRestore(const QVariantMap &data) const final;
|
||||||
GdbServerProvider *restore(const QVariantMap &data) final;
|
GdbServerProvider *restore(const QVariantMap &data) final;
|
||||||
|
|
||||||
GdbServerProviderConfigWidget *configurationWidget(GdbServerProvider *);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// StLinkUtilGdbServerProviderConfigWidget
|
// StLinkUtilGdbServerProviderConfigWidget
|
||||||
@@ -102,18 +100,18 @@ class StLinkUtilGdbServerProviderConfigWidget final
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StLinkUtilGdbServerProviderConfigWidget(StLinkUtilGdbServerProvider *);
|
explicit StLinkUtilGdbServerProviderConfigWidget(
|
||||||
|
StLinkUtilGdbServerProvider *provider);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void startupModeChanged();
|
void apply() final;
|
||||||
|
void discard() final;
|
||||||
void applyImpl() final;
|
|
||||||
void discardImpl() final;
|
|
||||||
|
|
||||||
StLinkUtilGdbServerProvider::TransportLayer transportLayerFromIndex(int idx) const;
|
StLinkUtilGdbServerProvider::TransportLayer transportLayerFromIndex(int idx) const;
|
||||||
StLinkUtilGdbServerProvider::TransportLayer transportLayer() const;
|
StLinkUtilGdbServerProvider::TransportLayer transportLayer() const;
|
||||||
void setTransportLayer(StLinkUtilGdbServerProvider::TransportLayer);
|
void setTransportLayer(StLinkUtilGdbServerProvider::TransportLayer);
|
||||||
|
|
||||||
|
void startupModeChanged();
|
||||||
void populateTransportLayers();
|
void populateTransportLayers();
|
||||||
void setFromProvider();
|
void setFromProvider();
|
||||||
|
|
||||||
248
src/plugins/baremetal/idebugserverprovider.cpp
Normal file
248
src/plugins/baremetal/idebugserverprovider.cpp
Normal file
@@ -0,0 +1,248 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "baremetaldevice.h"
|
||||||
|
#include "debugserverprovidermanager.h"
|
||||||
|
#include "idebugserverprovider.h"
|
||||||
|
|
||||||
|
#include <utils/environment.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QFormLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QUuid>
|
||||||
|
|
||||||
|
namespace BareMetal {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
const char idKeyC[] = "BareMetal.IDebugServerProvider.Id";
|
||||||
|
const char displayNameKeyC[] = "BareMetal.IDebugServerProvider.DisplayName";
|
||||||
|
|
||||||
|
static QString createId(const QString &id)
|
||||||
|
{
|
||||||
|
QString newId = id.left(id.indexOf(QLatin1Char(':')));
|
||||||
|
newId.append(QLatin1Char(':') + QUuid::createUuid().toString());
|
||||||
|
return newId;
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDebugServerProvider
|
||||||
|
|
||||||
|
IDebugServerProvider::IDebugServerProvider(const QString &id)
|
||||||
|
: m_id(createId(id))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
IDebugServerProvider::IDebugServerProvider(const IDebugServerProvider &provider)
|
||||||
|
: m_id(createId(provider.m_id))
|
||||||
|
{
|
||||||
|
m_displayName = QCoreApplication::translate(
|
||||||
|
"BareMetal::IDebugServerProvider", "Clone of %1")
|
||||||
|
.arg(provider.displayName());
|
||||||
|
}
|
||||||
|
|
||||||
|
IDebugServerProvider::~IDebugServerProvider()
|
||||||
|
{
|
||||||
|
const QSet<BareMetalDevice *> devices = m_devices;
|
||||||
|
for (BareMetalDevice *device : devices)
|
||||||
|
device->unregisterDebugServerProvider(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IDebugServerProvider::displayName() const
|
||||||
|
{
|
||||||
|
if (m_displayName.isEmpty())
|
||||||
|
return typeDisplayName();
|
||||||
|
return m_displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDebugServerProvider::setDisplayName(const QString &name)
|
||||||
|
{
|
||||||
|
if (m_displayName == name)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_displayName = name;
|
||||||
|
providerUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IDebugServerProvider::id() const
|
||||||
|
{
|
||||||
|
return m_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IDebugServerProvider::typeDisplayName() const
|
||||||
|
{
|
||||||
|
return m_typeDisplayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IDebugServerProvider::operator==(const IDebugServerProvider &other) const
|
||||||
|
{
|
||||||
|
if (this == &other)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
const QString thisId = id().left(id().indexOf(QLatin1Char(':')));
|
||||||
|
const QString otherId = other.id().left(other.id().indexOf(QLatin1Char(':')));
|
||||||
|
|
||||||
|
// We ignore displayname
|
||||||
|
return thisId == otherId;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap IDebugServerProvider::toMap() const
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
{QLatin1String(idKeyC), m_id},
|
||||||
|
{QLatin1String(displayNameKeyC), m_displayName},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDebugServerProvider::registerDevice(BareMetalDevice *device)
|
||||||
|
{
|
||||||
|
m_devices.insert(device);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDebugServerProvider::unregisterDevice(BareMetalDevice *device)
|
||||||
|
{
|
||||||
|
m_devices.remove(device);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDebugServerProvider::providerUpdated()
|
||||||
|
{
|
||||||
|
DebugServerProviderManager::notifyAboutUpdate(this);
|
||||||
|
for (BareMetalDevice *device : qAsConst(m_devices))
|
||||||
|
device->debugServerProviderUpdated(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IDebugServerProvider::fromMap(const QVariantMap &data)
|
||||||
|
{
|
||||||
|
m_id = data.value(QLatin1String(idKeyC)).toString();
|
||||||
|
m_displayName = data.value(QLatin1String(displayNameKeyC)).toString();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDebugServerProvider::setTypeDisplayName(const QString &typeDisplayName)
|
||||||
|
{
|
||||||
|
m_typeDisplayName = typeDisplayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDebugServerProviderFactory
|
||||||
|
|
||||||
|
QString IDebugServerProviderFactory::id() const
|
||||||
|
{
|
||||||
|
return m_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDebugServerProviderFactory::setId(const QString &id)
|
||||||
|
{
|
||||||
|
m_id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IDebugServerProviderFactory::displayName() const
|
||||||
|
{
|
||||||
|
return m_displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDebugServerProviderFactory::setDisplayName(const QString &name)
|
||||||
|
{
|
||||||
|
m_displayName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IDebugServerProviderFactory::idFromMap(const QVariantMap &data)
|
||||||
|
{
|
||||||
|
return data.value(QLatin1String(idKeyC)).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDebugServerProviderFactory::idToMap(QVariantMap &data, const QString &id)
|
||||||
|
{
|
||||||
|
data.insert(QLatin1String(idKeyC), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDebugServerProviderConfigWidget
|
||||||
|
|
||||||
|
IDebugServerProviderConfigWidget::IDebugServerProviderConfigWidget(
|
||||||
|
IDebugServerProvider *provider)
|
||||||
|
: m_provider(provider)
|
||||||
|
{
|
||||||
|
Q_ASSERT(provider);
|
||||||
|
|
||||||
|
m_mainLayout = new QFormLayout(this);
|
||||||
|
m_mainLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
||||||
|
|
||||||
|
m_nameLineEdit = new QLineEdit(this);
|
||||||
|
m_nameLineEdit->setToolTip(tr("Enter the name of the debugger server provider."));
|
||||||
|
m_mainLayout->addRow(tr("Name:"), m_nameLineEdit);
|
||||||
|
|
||||||
|
setFromProvider();
|
||||||
|
|
||||||
|
connect(m_nameLineEdit, &QLineEdit::textChanged,
|
||||||
|
this, &IDebugServerProviderConfigWidget::dirty);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDebugServerProviderConfigWidget::apply()
|
||||||
|
{
|
||||||
|
m_provider->setDisplayName(m_nameLineEdit->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDebugServerProviderConfigWidget::discard()
|
||||||
|
{
|
||||||
|
setFromProvider();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDebugServerProviderConfigWidget::addErrorLabel()
|
||||||
|
{
|
||||||
|
if (!m_errorLabel) {
|
||||||
|
m_errorLabel = new QLabel;
|
||||||
|
m_errorLabel->setVisible(false);
|
||||||
|
}
|
||||||
|
m_mainLayout->addRow(m_errorLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDebugServerProviderConfigWidget::setErrorMessage(const QString &m)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(m_errorLabel, return);
|
||||||
|
if (m.isEmpty()) {
|
||||||
|
clearErrorMessage();
|
||||||
|
} else {
|
||||||
|
m_errorLabel->setText(m);
|
||||||
|
m_errorLabel->setStyleSheet(QLatin1String("background-color: \"red\""));
|
||||||
|
m_errorLabel->setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDebugServerProviderConfigWidget::clearErrorMessage()
|
||||||
|
{
|
||||||
|
QTC_ASSERT(m_errorLabel, return);
|
||||||
|
m_errorLabel->clear();
|
||||||
|
m_errorLabel->setStyleSheet(QString());
|
||||||
|
m_errorLabel->setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDebugServerProviderConfigWidget::setFromProvider()
|
||||||
|
{
|
||||||
|
const QSignalBlocker blocker(this);
|
||||||
|
m_nameLineEdit->setText(m_provider->displayName());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace BareMetal
|
||||||
151
src/plugins/baremetal/idebugserverprovider.h
Normal file
151
src/plugins/baremetal/idebugserverprovider.h
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QSet>
|
||||||
|
#include <QVariantMap>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include <coreplugin/id.h>
|
||||||
|
#include <debugger/debuggerconstants.h>
|
||||||
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QFormLayout;
|
||||||
|
class QLabel;
|
||||||
|
class QLineEdit;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace BareMetal {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class BareMetalDevice;
|
||||||
|
class IDebugServerProviderConfigWidget;
|
||||||
|
|
||||||
|
// IDebugServerProvider
|
||||||
|
|
||||||
|
class IDebugServerProvider
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IDebugServerProvider();
|
||||||
|
|
||||||
|
QString displayName() const;
|
||||||
|
void setDisplayName(const QString &name);
|
||||||
|
|
||||||
|
QString id() const;
|
||||||
|
|
||||||
|
QString typeDisplayName() const;
|
||||||
|
|
||||||
|
virtual bool operator==(const IDebugServerProvider &other) const;
|
||||||
|
|
||||||
|
virtual IDebugServerProviderConfigWidget *configurationWidget() = 0;
|
||||||
|
|
||||||
|
virtual IDebugServerProvider *clone() const = 0;
|
||||||
|
|
||||||
|
virtual QVariantMap toMap() const;
|
||||||
|
|
||||||
|
virtual bool isValid() const = 0;
|
||||||
|
virtual bool hasProcess() const { return false; }
|
||||||
|
virtual Debugger::DebuggerEngineType engineType() const = 0;
|
||||||
|
|
||||||
|
void registerDevice(BareMetalDevice *device);
|
||||||
|
void unregisterDevice(BareMetalDevice *device);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
explicit IDebugServerProvider(const QString &id);
|
||||||
|
explicit IDebugServerProvider(const IDebugServerProvider &provider);
|
||||||
|
|
||||||
|
void setTypeDisplayName(const QString &typeDisplayName);
|
||||||
|
|
||||||
|
void providerUpdated();
|
||||||
|
|
||||||
|
virtual bool fromMap(const QVariantMap &data);
|
||||||
|
|
||||||
|
QString m_id;
|
||||||
|
mutable QString m_displayName;
|
||||||
|
QString m_typeDisplayName;
|
||||||
|
QSet<BareMetalDevice *> m_devices;
|
||||||
|
|
||||||
|
friend class IDebugServerProviderConfigWidget;
|
||||||
|
};
|
||||||
|
|
||||||
|
// IDebugServerProviderFactory
|
||||||
|
|
||||||
|
class IDebugServerProviderFactory : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
QString id() const;
|
||||||
|
QString displayName() const;
|
||||||
|
|
||||||
|
virtual IDebugServerProvider *create() = 0;
|
||||||
|
|
||||||
|
virtual bool canRestore(const QVariantMap &data) const = 0;
|
||||||
|
virtual IDebugServerProvider *restore(const QVariantMap &data) = 0;
|
||||||
|
|
||||||
|
static QString idFromMap(const QVariantMap &data);
|
||||||
|
static void idToMap(QVariantMap &data, const QString &id);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void setId(const QString &id);
|
||||||
|
void setDisplayName(const QString &name);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_displayName;
|
||||||
|
QString m_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
// IDebugServerProviderConfigWidget
|
||||||
|
|
||||||
|
class IDebugServerProviderConfigWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit IDebugServerProviderConfigWidget(IDebugServerProvider *provider);
|
||||||
|
|
||||||
|
virtual void apply();
|
||||||
|
virtual void discard();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void dirty();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void setErrorMessage(const QString &);
|
||||||
|
void clearErrorMessage();
|
||||||
|
void addErrorLabel();
|
||||||
|
void setFromProvider();
|
||||||
|
|
||||||
|
IDebugServerProvider *m_provider = nullptr;
|
||||||
|
QFormLayout *m_mainLayout = nullptr;
|
||||||
|
QLineEdit *m_nameLineEdit = nullptr;
|
||||||
|
QLabel *m_errorLabel = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace BareMetal
|
||||||
Reference in New Issue
Block a user