BareMetal: Choose peripheral description file on debug provider page

... instead of device page.

Reason is that a path to the peripheral description file comes from the
inside of the provider for some providers (e.g. for the UVSC provider at
parsing the selected "Software Device Pack" file).

This complicates a code for assigning of the selected peripheral
description file path to the device configuration page.

So, it is makes sense to make it possible to choose a peripheral
description file from the debug server provider page. In this case we
will pass a path to the selected peripheral description file via the
runnable's extra data variable.

Tested with STM32 NUCLEO-F767ZI board on Windows.

Change-Id: Iec4d738dd236449969fd669e7fbe58da3a660938
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Denis Shienkov
2020-03-06 13:47:08 +03:00
parent 4894afee52
commit fdf383cf37
8 changed files with 64 additions and 54 deletions

View File

@@ -28,9 +28,7 @@
#include "baremetaldeviceconfigurationwidget.h"
#include "debugserverproviderchooser.h"
#include "idebugserverprovider.h"
#include <utils/pathchooser.h>
#include <utils/qtcassert.h>
#include <QFormLayout>
@@ -57,19 +55,6 @@ BareMetalDeviceConfigurationWidget::BareMetalDeviceConfigurationWidget(
connect(m_debugServerProviderChooser, &DebugServerProviderChooser::providerChanged,
this, &BareMetalDeviceConfigurationWidget::debugServerProviderChanged);
m_peripheralDescriptionFileChooser = new Utils::PathChooser(this);
m_peripheralDescriptionFileChooser->setExpectedKind(Utils::PathChooser::File);
m_peripheralDescriptionFileChooser->setPromptDialogFilter(
tr("Peripheral description files (*.svd)"));
m_peripheralDescriptionFileChooser->setPromptDialogTitle(
tr("Select Peripheral Description File"));
m_peripheralDescriptionFileChooser->setPath(dev->peripheralDescriptionFilePath());
formLayout->addRow(tr("Peripheral description file:"),
m_peripheralDescriptionFileChooser);
connect(m_peripheralDescriptionFileChooser, &Utils::PathChooser::pathChanged,
this, &BareMetalDeviceConfigurationWidget::peripheralDescriptionFileChanged);
}
void BareMetalDeviceConfigurationWidget::debugServerProviderChanged()
@@ -79,13 +64,6 @@ void BareMetalDeviceConfigurationWidget::debugServerProviderChanged()
dev->setDebugServerProviderId(m_debugServerProviderChooser->currentProviderId());
}
void BareMetalDeviceConfigurationWidget::peripheralDescriptionFileChanged()
{
const auto dev = qSharedPointerCast<BareMetalDevice>(device());
QTC_ASSERT(dev, return);
dev->setPeripheralDescriptionFilePath(m_peripheralDescriptionFileChooser->path());
}
void BareMetalDeviceConfigurationWidget::updateDeviceFromUi()
{
debugServerProviderChanged();

View File

@@ -28,8 +28,6 @@
#include <projectexplorer/devicesupport/idevicewidget.h>
namespace Utils { class PathChooser; }
namespace BareMetal {
namespace Internal {
@@ -47,11 +45,9 @@ public:
private:
void debugServerProviderChanged();
void peripheralDescriptionFileChanged();
void updateDeviceFromUi() final;
DebugServerProviderChooser *m_debugServerProviderChooser = nullptr;
Utils::PathChooser *m_peripheralDescriptionFileChooser = nullptr;
};
} // namespace Internal

View File

@@ -33,6 +33,7 @@
#include <utils/environment.h>
#include <utils/qtcassert.h>
#include <utils/pathchooser.h>
#include <ssh/sshconnection.h>
@@ -49,6 +50,7 @@ namespace BareMetal {
namespace Internal {
const char startupModeKeyC[] = "BareMetal.GdbServerProvider.Mode";
const char peripheralDescriptionFileKeyC[] = "BareMetal.GdbServerProvider.PeripheralDescriptionFile";
const char initCommandsKeyC[] = "BareMetal.GdbServerProvider.InitCommands";
const char resetCommandsKeyC[] = "BareMetal.GdbServerProvider.ResetCommands";
const char useExtendedRemoteKeyC[] = "BareMetal.GdbServerProvider.UseExtendedRemote";
@@ -64,6 +66,7 @@ GdbServerProvider::GdbServerProvider(const QString &id)
GdbServerProvider::GdbServerProvider(const GdbServerProvider &other)
: IDebugServerProvider(other.id())
, m_startupMode(other.m_startupMode)
, m_peripheralDescriptionFile(other.m_peripheralDescriptionFile)
, m_initCommands(other.m_initCommands)
, m_resetCommands(other.m_resetCommands)
, m_useExtendedRemote(other.useExtendedRemote())
@@ -76,11 +79,21 @@ GdbServerProvider::StartupMode GdbServerProvider::startupMode() const
return m_startupMode;
}
Utils::FilePath GdbServerProvider::peripheralDescriptionFile() const
{
return m_peripheralDescriptionFile;
}
void GdbServerProvider::setStartupMode(StartupMode m)
{
m_startupMode = m;
}
void GdbServerProvider::setPeripheralDescriptionFile(const FilePath &file)
{
m_peripheralDescriptionFile = file;
}
QString GdbServerProvider::initCommands() const
{
return m_initCommands;
@@ -123,6 +136,7 @@ bool GdbServerProvider::operator==(const IDebugServerProvider &other) const
const auto p = static_cast<const GdbServerProvider *>(&other);
return m_startupMode == p->m_startupMode
&& m_peripheralDescriptionFile == p->m_peripheralDescriptionFile
&& m_initCommands == p->m_initCommands
&& m_resetCommands == p->m_resetCommands
&& m_useExtendedRemote == p->m_useExtendedRemote;
@@ -132,6 +146,7 @@ QVariantMap GdbServerProvider::toMap() const
{
QVariantMap data = IDebugServerProvider::toMap();
data.insert(startupModeKeyC, m_startupMode);
data.insert(peripheralDescriptionFileKeyC, m_peripheralDescriptionFile.toVariant());
data.insert(initCommandsKeyC, m_initCommands);
data.insert(resetCommandsKeyC, m_resetCommands);
data.insert(useExtendedRemoteKeyC, m_useExtendedRemote);
@@ -166,6 +181,8 @@ bool GdbServerProvider::aboutToRun(DebuggerRunTool *runTool,
Runnable inferior;
inferior.executable = bin;
inferior.extraData.insert(Debugger::Constants::kPeripheralDescriptionFile,
m_peripheralDescriptionFile.toVariant());
if (const auto argAspect = runControl->aspect<ArgumentsAspect>())
inferior.commandLineArguments = argAspect->arguments(runControl->macroExpander());
runTool->setInferior(inferior);
@@ -197,6 +214,7 @@ bool GdbServerProvider::fromMap(const QVariantMap &data)
return false;
m_startupMode = static_cast<StartupMode>(data.value(startupModeKeyC).toInt());
m_peripheralDescriptionFile = FilePath::fromVariant(data.value(peripheralDescriptionFileKeyC));
m_initCommands = data.value(initCommandsKeyC).toString();
m_resetCommands = data.value(resetCommandsKeyC).toString();
m_useExtendedRemote = data.value(useExtendedRemoteKeyC).toBool();
@@ -214,17 +232,31 @@ GdbServerProviderConfigWidget::GdbServerProviderConfigWidget(
"of the GDB server provider."));
m_mainLayout->addRow(tr("Startup mode:"), m_startupModeComboBox);
m_peripheralDescriptionFileChooser = new Utils::PathChooser(this);
m_peripheralDescriptionFileChooser->setExpectedKind(Utils::PathChooser::File);
m_peripheralDescriptionFileChooser->setPromptDialogFilter(
tr("Peripheral description files (*.svd)"));
m_peripheralDescriptionFileChooser->setPromptDialogTitle(
tr("Select Peripheral Description File"));
m_mainLayout->addRow(tr("Peripheral description file:"),
m_peripheralDescriptionFileChooser);
populateStartupModes();
setFromProvider();
connect(m_startupModeComboBox,
QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &GdbServerProviderConfigWidget::dirty);
connect(m_peripheralDescriptionFileChooser, &Utils::PathChooser::pathChanged,
this, &GdbServerProviderConfigWidget::dirty);
}
void GdbServerProviderConfigWidget::apply()
{
static_cast<GdbServerProvider *>(m_provider)->setStartupMode(startupMode());
const auto p = static_cast<GdbServerProvider *>(m_provider);
p->setStartupMode(startupMode());
p->setPeripheralDescriptionFile(peripheralDescriptionFile());
IDebugServerProviderConfigWidget::apply();
}
@@ -277,9 +309,21 @@ void GdbServerProviderConfigWidget::populateStartupModes()
m_startupModeComboBox->addItem(startupModeName(mode), mode);
}
Utils::FilePath GdbServerProviderConfigWidget::peripheralDescriptionFile() const
{
return m_peripheralDescriptionFileChooser->fileName();
}
void GdbServerProviderConfigWidget::setPeripheralDescriptionFile(const Utils::FilePath &file)
{
m_peripheralDescriptionFileChooser->setFileName(file);
}
void GdbServerProviderConfigWidget::setFromProvider()
{
setStartupMode(static_cast<GdbServerProvider *>(m_provider)->startupMode());
const auto p = static_cast<GdbServerProvider *>(m_provider);
setStartupMode(p->startupMode());
setPeripheralDescriptionFile(p->peripheralDescriptionFile());
}
QString GdbServerProviderConfigWidget::defaultInitCommandsTooltip()

View File

@@ -35,6 +35,8 @@ QT_BEGIN_NAMESPACE
class QComboBox;
QT_END_NAMESPACE
namespace Utils { class PathChooser; }
namespace BareMetal {
namespace Internal {
@@ -51,6 +53,7 @@ public:
};
StartupMode startupMode() const;
Utils::FilePath peripheralDescriptionFile() const;
QString initCommands() const;
QString resetCommands() const;
bool useExtendedRemote() const;
@@ -74,6 +77,7 @@ protected:
explicit GdbServerProvider(const GdbServerProvider &other);
void setStartupMode(StartupMode);
void setPeripheralDescriptionFile(const Utils::FilePath &file);
void setInitCommands(const QString &);
void setResetCommands(const QString &);
void setUseExtendedRemote(bool);
@@ -81,6 +85,7 @@ protected:
bool fromMap(const QVariantMap &data) override;
StartupMode m_startupMode = StartupOnNetwork;
Utils::FilePath m_peripheralDescriptionFile;
QString m_initCommands;
QString m_resetCommands;
bool m_useExtendedRemote = false;
@@ -104,12 +109,15 @@ protected:
GdbServerProvider::StartupMode startupMode() const;
void setStartupMode(GdbServerProvider::StartupMode mode);
void populateStartupModes();
Utils::FilePath peripheralDescriptionFile() const;
void setPeripheralDescriptionFile(const Utils::FilePath &file);
void setFromProvider();
static QString defaultInitCommandsTooltip();
static QString defaultResetCommandsTooltip();
QComboBox *m_startupModeComboBox = nullptr;
Utils::PathChooser *m_peripheralDescriptionFileChooser = nullptr;
};
// GdbServerProviderRunner

View File

@@ -36,6 +36,9 @@ const char MODE_DEBUG[] = "Mode.Debug";
// Debug mode context
const char C_DEBUGMODE[] = "Debugger.DebugMode";
// Common debugger constants.
const char kPeripheralDescriptionFile[] = "PeripheralDescriptionFile";
// UVSC-specific debugger constants.
const char kUVisionProjectFilePath[] = "UVisionProjectFilePath";
const char kUVisionOptionsFilePath[] = "UVisionOptionsFilePath";

View File

@@ -682,9 +682,9 @@ static void handleGroup(QXmlStreamReader &in, PeripheralRegisterGroups &groups)
groups.push_back(group);
}
static PeripheralRegisterGroups availablePeripheralRegisterGroups(const QString &filePath)
static PeripheralRegisterGroups availablePeripheralRegisterGroups(const FilePath &filePath)
{
QFile f(filePath);
QFile f(filePath.toString());
if (!f.open(QIODevice::ReadOnly))
return {};
@@ -716,14 +716,13 @@ void PeripheralRegisterHandler::updateRegisterGroups()
{
clear();
const auto dev = m_engine->device();
QTC_ASSERT(dev, return);
const DebuggerRunParameters &rp = m_engine->runParameters();
const FilePath peripheralDescriptionFile = FilePath::fromVariant(
rp.inferior.extraData.value(Debugger::Constants::kPeripheralDescriptionFile));
const QString filePath = dev->peripheralDescriptionFilePath();
if (filePath.isEmpty())
if (!peripheralDescriptionFile.exists())
return;
m_peripheralRegisterGroups = availablePeripheralRegisterGroups(filePath);
m_peripheralRegisterGroups = availablePeripheralRegisterGroups(peripheralDescriptionFile);
}
void PeripheralRegisterHandler::updateRegister(quint64 address, quint64 value)

View File

@@ -124,7 +124,6 @@ const char TimeoutKey[] = "Timeout";
const char HostKeyCheckingKey[] = "HostKeyChecking";
const char DebugServerKey[] = "DebugServerKey";
const char PeripheralDescriptionFileKey[] = "PeripheralDescriptionFileKey";
const char QmlsceneKey[] = "QmlsceneKey";
using AuthType = QSsh::SshConnectionParameters::AuthenticationType;
@@ -152,7 +151,6 @@ public:
QSsh::SshConnectionParameters sshParameters;
Utils::PortList freePorts;
QString debugServerPath;
QString peripheralDescriptionFilePath;
QString qmlsceneCommand;
QList<Utils::Icon> deviceIcons;
@@ -392,7 +390,6 @@ void IDevice::fromMap(const QVariantMap &map)
d->version = map.value(QLatin1String(VersionKey), 0).toInt();
d->debugServerPath = map.value(QLatin1String(DebugServerKey)).toString();
d->peripheralDescriptionFilePath = map.value(QLatin1String(PeripheralDescriptionFileKey)).toString();
d->qmlsceneCommand = map.value(QLatin1String(QmlsceneKey)).toString();
d->extraData = map.value(ExtraDataKey).toMap();
}
@@ -424,7 +421,6 @@ QVariantMap IDevice::toMap() const
map.insert(QLatin1String(VersionKey), d->version);
map.insert(QLatin1String(DebugServerKey), d->debugServerPath);
map.insert(QLatin1String(PeripheralDescriptionFileKey), d->peripheralDescriptionFilePath);
map.insert(QLatin1String(QmlsceneKey), d->qmlsceneCommand);
map.insert(ExtraDataKey, d->extraData);
@@ -508,17 +504,6 @@ void IDevice::setDebugServerPath(const QString &path)
d->debugServerPath = path;
}
QString IDevice::peripheralDescriptionFilePath() const
{
return d->peripheralDescriptionFilePath;
}
void IDevice::setPeripheralDescriptionFilePath(const QString &path)
{
d->peripheralDescriptionFilePath = path;
}
QString IDevice::qmlsceneCommand() const
{
return d->qmlsceneCommand;

View File

@@ -210,9 +210,6 @@ public:
QString debugServerPath() const;
void setDebugServerPath(const QString &path);
QString peripheralDescriptionFilePath() const;
void setPeripheralDescriptionFilePath(const QString &path);
QString qmlsceneCommand() const;
void setQmlsceneCommand(const QString &path);