forked from qt-creator/qt-creator
BareMetal: Share the 'channel' property for all providers
Change-Id: I619d0ced6231ab57a4ac556f50030112295c58ea Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -53,9 +53,6 @@ const char initCommandsKeyC[] = "BareMetal.GdbServerProvider.InitCommands";
|
||||
const char resetCommandsKeyC[] = "BareMetal.GdbServerProvider.ResetCommands";
|
||||
const char useExtendedRemoteKeyC[] = "BareMetal.GdbServerProvider.UseExtendedRemote";
|
||||
|
||||
const char hostKeySuffixC[] = ".Host";
|
||||
const char portKeySuffixC[] = ".Port";
|
||||
|
||||
// GdbServerProvider
|
||||
|
||||
GdbServerProvider::GdbServerProvider(const QString &id)
|
||||
@@ -114,22 +111,6 @@ void GdbServerProvider::setResetCommands(const QString &cmds)
|
||||
m_resetCommands = cmds;
|
||||
}
|
||||
|
||||
void GdbServerProvider::setChannel(const QUrl &channel)
|
||||
{
|
||||
m_channel = channel;
|
||||
}
|
||||
|
||||
void GdbServerProvider::setDefaultChannel(const QString &host, int port)
|
||||
{
|
||||
m_channel.setHost(host);
|
||||
m_channel.setPort(port);
|
||||
}
|
||||
|
||||
QUrl GdbServerProvider::channel() const
|
||||
{
|
||||
return m_channel;
|
||||
}
|
||||
|
||||
Utils::CommandLine GdbServerProvider::command() const
|
||||
{
|
||||
return {};
|
||||
@@ -141,21 +122,12 @@ bool GdbServerProvider::operator==(const IDebugServerProvider &other) const
|
||||
return false;
|
||||
|
||||
const auto p = static_cast<const GdbServerProvider *>(&other);
|
||||
return m_channel == p->m_channel
|
||||
&& m_startupMode == p->m_startupMode
|
||||
return m_startupMode == p->m_startupMode
|
||||
&& m_initCommands == p->m_initCommands
|
||||
&& m_resetCommands == p->m_resetCommands
|
||||
&& m_useExtendedRemote == p->m_useExtendedRemote;
|
||||
}
|
||||
|
||||
QString GdbServerProvider::channelString() const
|
||||
{
|
||||
// Just return as "host:port" form.
|
||||
if (m_channel.port() <= 0)
|
||||
return m_channel.host();
|
||||
return m_channel.host() + ':' + QString::number(m_channel.port());
|
||||
}
|
||||
|
||||
QVariantMap GdbServerProvider::toMap() const
|
||||
{
|
||||
QVariantMap data = IDebugServerProvider::toMap();
|
||||
@@ -163,8 +135,6 @@ QVariantMap GdbServerProvider::toMap() const
|
||||
data.insert(initCommandsKeyC, m_initCommands);
|
||||
data.insert(resetCommandsKeyC, m_resetCommands);
|
||||
data.insert(useExtendedRemoteKeyC, m_useExtendedRemote);
|
||||
data.insert(m_settingsBase + hostKeySuffixC, m_channel.host());
|
||||
data.insert(m_settingsBase + portKeySuffixC, m_channel.port());
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -230,16 +200,9 @@ bool GdbServerProvider::fromMap(const QVariantMap &data)
|
||||
m_initCommands = data.value(initCommandsKeyC).toString();
|
||||
m_resetCommands = data.value(resetCommandsKeyC).toString();
|
||||
m_useExtendedRemote = data.value(useExtendedRemoteKeyC).toBool();
|
||||
m_channel.setHost(data.value(m_settingsBase + hostKeySuffixC).toString());
|
||||
m_channel.setPort(data.value(m_settingsBase + portKeySuffixC).toInt());
|
||||
return true;
|
||||
}
|
||||
|
||||
void GdbServerProvider::setSettingsKeyBase(const QString &settingsBase)
|
||||
{
|
||||
m_settingsBase = settingsBase;
|
||||
}
|
||||
|
||||
// GdbServerProviderConfigWidget
|
||||
|
||||
GdbServerProviderConfigWidget::GdbServerProviderConfigWidget(
|
||||
|
@@ -55,8 +55,6 @@ public:
|
||||
|
||||
bool operator==(const IDebugServerProvider &other) const override;
|
||||
|
||||
virtual QString channelString() const;
|
||||
|
||||
QVariantMap toMap() const override;
|
||||
|
||||
virtual Utils::CommandLine command() const;
|
||||
@@ -69,10 +67,6 @@ public:
|
||||
bool isValid() const override;
|
||||
virtual QSet<StartupMode> supportedStartupModes() const = 0;
|
||||
|
||||
QUrl channel() const;
|
||||
void setChannel(const QUrl &channelString);
|
||||
void setDefaultChannel(const QString &host, int port);
|
||||
|
||||
protected:
|
||||
explicit GdbServerProvider(const QString &id);
|
||||
explicit GdbServerProvider(const GdbServerProvider &other);
|
||||
@@ -81,12 +75,9 @@ protected:
|
||||
void setInitCommands(const QString &);
|
||||
void setResetCommands(const QString &);
|
||||
void setUseExtendedRemote(bool);
|
||||
void setSettingsKeyBase(const QString &settingsBase);
|
||||
|
||||
bool fromMap(const QVariantMap &data) override;
|
||||
|
||||
QString m_settingsBase;
|
||||
QUrl m_channel;
|
||||
StartupMode m_startupMode = StartupOnNetwork;
|
||||
QString m_initCommands;
|
||||
QString m_resetCommands;
|
||||
|
@@ -62,7 +62,7 @@ JLinkGdbServerProvider::JLinkGdbServerProvider()
|
||||
{
|
||||
setInitCommands(defaultInitCommands());
|
||||
setResetCommands(defaultResetCommands());
|
||||
setDefaultChannel("localhost", 2331);
|
||||
setChannel("localhost", 2331);
|
||||
setSettingsKeyBase("BareMetal.JLinkGdbServerProvider");
|
||||
setTypeDisplayName(JLinkGdbServerProviderFactory::tr("JLink"));
|
||||
}
|
||||
|
@@ -57,7 +57,7 @@ OpenOcdGdbServerProvider::OpenOcdGdbServerProvider()
|
||||
{
|
||||
setInitCommands(defaultInitCommands());
|
||||
setResetCommands(defaultResetCommands());
|
||||
setDefaultChannel("localhost", 3333);
|
||||
setChannel("localhost", 3333);
|
||||
setSettingsKeyBase("BareMetal.OpenOcdGdbServerProvider");
|
||||
setTypeDisplayName(OpenOcdGdbServerProviderFactory::tr("OpenOCD"));
|
||||
}
|
||||
|
@@ -58,7 +58,7 @@ StLinkUtilGdbServerProvider::StLinkUtilGdbServerProvider()
|
||||
{
|
||||
setInitCommands(defaultInitCommands());
|
||||
setResetCommands(defaultResetCommands());
|
||||
setDefaultChannel("localhost", 4242);
|
||||
setChannel("localhost", 4242);
|
||||
setSettingsKeyBase("BareMetal.StLinkUtilGdbServerProvider");
|
||||
setTypeDisplayName(StLinkUtilGdbServerProviderFactory::tr("ST-LINK Utility"));
|
||||
}
|
||||
|
@@ -44,6 +44,9 @@ const char idKeyC[] = "BareMetal.IDebugServerProvider.Id";
|
||||
const char displayNameKeyC[] = "BareMetal.IDebugServerProvider.DisplayName";
|
||||
const char engineTypeKeyC[] = "BareMetal.IDebugServerProvider.EngineType";
|
||||
|
||||
const char hostKeySuffixC[] = ".Host";
|
||||
const char portKeySuffixC[] = ".Port";
|
||||
|
||||
static QString createId(const QString &id)
|
||||
{
|
||||
QString newId = id.left(id.indexOf(':'));
|
||||
@@ -89,6 +92,30 @@ void IDebugServerProvider::setDisplayName(const QString &name)
|
||||
providerUpdated();
|
||||
}
|
||||
|
||||
void IDebugServerProvider::setChannel(const QUrl &channel)
|
||||
{
|
||||
m_channel = channel;
|
||||
}
|
||||
|
||||
void IDebugServerProvider::setChannel(const QString &host, int port)
|
||||
{
|
||||
m_channel.setHost(host);
|
||||
m_channel.setPort(port);
|
||||
}
|
||||
|
||||
QUrl IDebugServerProvider::channel() const
|
||||
{
|
||||
return m_channel;
|
||||
}
|
||||
|
||||
QString IDebugServerProvider::channelString() const
|
||||
{
|
||||
// Just return as "host:port" form.
|
||||
if (m_channel.port() <= 0)
|
||||
return m_channel.host();
|
||||
return m_channel.host() + ':' + QString::number(m_channel.port());
|
||||
}
|
||||
|
||||
QString IDebugServerProvider::id() const
|
||||
{
|
||||
return m_id;
|
||||
@@ -117,6 +144,11 @@ void IDebugServerProvider::setEngineType(Debugger::DebuggerEngineType engineType
|
||||
providerUpdated();
|
||||
}
|
||||
|
||||
void IDebugServerProvider::setSettingsKeyBase(const QString &settingsBase)
|
||||
{
|
||||
m_settingsBase = settingsBase;
|
||||
}
|
||||
|
||||
bool IDebugServerProvider::operator==(const IDebugServerProvider &other) const
|
||||
{
|
||||
if (this == &other)
|
||||
@@ -127,7 +159,8 @@ bool IDebugServerProvider::operator==(const IDebugServerProvider &other) const
|
||||
|
||||
// We ignore displayname
|
||||
return thisId == otherId
|
||||
&& m_engineType == other.m_engineType;
|
||||
&& m_engineType == other.m_engineType
|
||||
&& m_channel == other.m_channel;
|
||||
}
|
||||
|
||||
QVariantMap IDebugServerProvider::toMap() const
|
||||
@@ -135,7 +168,9 @@ QVariantMap IDebugServerProvider::toMap() const
|
||||
return {
|
||||
{idKeyC, m_id},
|
||||
{displayNameKeyC, m_displayName},
|
||||
{engineTypeKeyC, m_engineType}
|
||||
{engineTypeKeyC, m_engineType},
|
||||
{m_settingsBase + hostKeySuffixC, m_channel.host()},
|
||||
{m_settingsBase + portKeySuffixC, m_channel.port()},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -160,6 +195,8 @@ bool IDebugServerProvider::fromMap(const QVariantMap &data)
|
||||
m_displayName = data.value(displayNameKeyC).toString();
|
||||
m_engineType = static_cast<Debugger::DebuggerEngineType>(
|
||||
data.value(engineTypeKeyC, Debugger::NoEngineType).toInt());
|
||||
m_channel.setHost(data.value(m_settingsBase + hostKeySuffixC).toString());
|
||||
m_channel.setPort(data.value(m_settingsBase + portKeySuffixC).toInt());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -67,6 +67,12 @@ public:
|
||||
QString displayName() const;
|
||||
void setDisplayName(const QString &name);
|
||||
|
||||
QUrl channel() const;
|
||||
void setChannel(const QUrl &channel);
|
||||
void setChannel(const QString &host, int port);
|
||||
|
||||
virtual QString channelString() const;
|
||||
|
||||
QString id() const;
|
||||
QString typeDisplayName() const;
|
||||
Debugger::DebuggerEngineType engineType() const;
|
||||
@@ -95,6 +101,7 @@ protected:
|
||||
|
||||
void setTypeDisplayName(const QString &typeDisplayName);
|
||||
void setEngineType(Debugger::DebuggerEngineType engineType);
|
||||
void setSettingsKeyBase(const QString &settingsBase);
|
||||
|
||||
void providerUpdated();
|
||||
|
||||
@@ -103,6 +110,8 @@ protected:
|
||||
QString m_id;
|
||||
mutable QString m_displayName;
|
||||
QString m_typeDisplayName;
|
||||
QString m_settingsBase;
|
||||
QUrl m_channel;
|
||||
Debugger::DebuggerEngineType m_engineType = Debugger::NoEngineType;
|
||||
QSet<BareMetalDevice *> m_devices;
|
||||
|
||||
|
Reference in New Issue
Block a user