summaryrefslogtreecommitdiff
path: root/src/plugins/baremetal
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2019-06-04 10:17:06 +0200
committerhjk <hjk@qt.io>2019-06-05 12:32:04 +0000
commitce59cf6a50d01f77854c4202ce89a9157e1ea80d (patch)
tree584303338d50520646d817b60824e83fd9a484be /src/plugins/baremetal
parent8e7138f06a165b49bf3feaa5320f86204597c093 (diff)
downloadqt-creator-ce59cf6a50d01f77854c4202ce89a9157e1ea80d.tar.gz
BareMetal: Use Utils::CommandLine for gdbserver things
Change-Id: Idf0793636d58b1c6f93a64c94ce5c2b11e4694ce Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/baremetal')
-rw-r--r--src/plugins/baremetal/baremetaldebugsupport.cpp8
-rw-r--r--src/plugins/baremetal/gdbserverprovider.cpp7
-rw-r--r--src/plugins/baremetal/gdbserverprovider.h3
-rw-r--r--src/plugins/baremetal/openocdgdbserverprovider.cpp50
-rw-r--r--src/plugins/baremetal/openocdgdbserverprovider.h5
-rw-r--r--src/plugins/baremetal/stlinkutilgdbserverprovider.cpp32
-rw-r--r--src/plugins/baremetal/stlinkutilgdbserverprovider.h5
7 files changed, 46 insertions, 64 deletions
diff --git a/src/plugins/baremetal/baremetaldebugsupport.cpp b/src/plugins/baremetal/baremetaldebugsupport.cpp
index e8c3a6f01d..cda24139df 100644
--- a/src/plugins/baremetal/baremetaldebugsupport.cpp
+++ b/src/plugins/baremetal/baremetaldebugsupport.cpp
@@ -72,11 +72,9 @@ BareMetalDebugSupport::BareMetalDebugSupport(RunControl *runControl)
if (p->startupMode() == GdbServerProvider::StartupOnNetwork) {
Runnable r;
- r.executable = p->executable();
- // We need to wrap the command arguments depending on a host OS,
- // as the bare metal's GDB servers are launched on a host,
- // but not on a target.
- r.commandLineArguments = Utils::QtcProcess::joinArgs(p->arguments(), Utils::HostOsInfo::hostOs());
+ 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.
m_gdbServer = new SimpleTargetRunner(runControl);
m_gdbServer->setRunnable(r);
addStartDependency(m_gdbServer);
diff --git a/src/plugins/baremetal/gdbserverprovider.cpp b/src/plugins/baremetal/gdbserverprovider.cpp
index 137c260d7d..520e8fb30f 100644
--- a/src/plugins/baremetal/gdbserverprovider.cpp
+++ b/src/plugins/baremetal/gdbserverprovider.cpp
@@ -143,12 +143,7 @@ void GdbServerProvider::setResetCommands(const QString &cmds)
m_resetCommands = cmds;
}
-QString GdbServerProvider::executable() const
-{
- return {};
-}
-
-QStringList GdbServerProvider::arguments() const
+Utils::CommandLine GdbServerProvider::command() const
{
return {};
}
diff --git a/src/plugins/baremetal/gdbserverprovider.h b/src/plugins/baremetal/gdbserverprovider.h
index c25fc363a8..8d91408a2e 100644
--- a/src/plugins/baremetal/gdbserverprovider.h
+++ b/src/plugins/baremetal/gdbserverprovider.h
@@ -84,8 +84,7 @@ public:
virtual QVariantMap toMap() const;
- virtual QString executable() const;
- virtual QStringList arguments() const;
+ virtual Utils::CommandLine command() const;
virtual bool isValid() const;
virtual bool canStartupMode(StartupMode) const;
diff --git a/src/plugins/baremetal/openocdgdbserverprovider.cpp b/src/plugins/baremetal/openocdgdbserverprovider.cpp
index 7417f1476a..b7044defe0 100644
--- a/src/plugins/baremetal/openocdgdbserverprovider.cpp
+++ b/src/plugins/baremetal/openocdgdbserverprovider.cpp
@@ -40,7 +40,8 @@
#include <QFormLayout>
#include <QLineEdit>
#include <QPlainTextEdit>
-#include <QString>
+
+using namespace Utils;
namespace BareMetal {
namespace Internal {
@@ -92,48 +93,43 @@ QString OpenOcdGdbServerProvider::channel() const
// Just return as "host:port" form.
return m_host + QLatin1Char(':') + QString::number(m_port);
case StartupOnPipe: {
- QStringList args;
// In the pipe mode need to add quotes to each item of arguments;
// otherwise running will be stuck.
- for (const QString &a : arguments()) {
- if (a.startsWith(QLatin1Char('\"')) && a.endsWith(QLatin1Char('\"')))
- continue;
- args << (QLatin1Char('\"') + a + QLatin1Char('\"'));
+ CommandLine cmd = command();
+ QStringList args = {"|", cmd.executable().toString()};
+ for (const QString &a : QtcProcess::splitArgs(cmd.arguments())) {
+ if (a.startsWith('\"') && a.endsWith('\"'))
+ args << a;
+ else
+ args << ('\"' + a + '\"');
}
- args.prepend(executable());
- args.prepend(QLatin1String("|"));
- return args.join(QLatin1Char(' '));
+ return args.join(' ');
}
default: // wrong
return {};
}
}
-QString OpenOcdGdbServerProvider::executable() const
-{
- return m_executableFile;
-}
-
-QStringList OpenOcdGdbServerProvider::arguments() const
+CommandLine OpenOcdGdbServerProvider::command() const
{
- QStringList args;
+ CommandLine cmd{m_executableFile, {}};
- args << QLatin1String("-c");
+ cmd.addArg("-c");
if (startupMode() == StartupOnPipe)
- args << QLatin1String("gdb_port pipe");
+ cmd.addArg("gdb_port pipe");
else
- args << (QLatin1String("gdb_port ") + QString::number(m_port));
+ cmd.addArg("gdb_port " + QString::number(m_port));
if (!m_rootScriptsDir.isEmpty())
- args << QLatin1String("-s") << m_rootScriptsDir;
+ cmd.addArgs({"-s", m_rootScriptsDir});
if (!m_configurationFile.isEmpty())
- args << QLatin1String("-f") << m_configurationFile;
+ cmd.addArgs({"-f", m_configurationFile});
if (!m_additionalArguments.isEmpty())
- args << Utils::QtcProcess::splitArgs(m_additionalArguments);
+ cmd.addArgs(m_additionalArguments);
- return args;
+ return cmd;
}
bool OpenOcdGdbServerProvider::canStartupMode(StartupMode m) const
@@ -171,7 +167,7 @@ QVariantMap OpenOcdGdbServerProvider::toMap() const
QVariantMap data = GdbServerProvider::toMap();
data.insert(QLatin1String(hostKeyC), m_host);
data.insert(QLatin1String(portKeyC), m_port);
- data.insert(QLatin1String(executableFileKeyC), m_executableFile);
+ data.insert(QLatin1String(executableFileKeyC), m_executableFile.toVariant());
data.insert(QLatin1String(rootScriptsDirKeyC), m_rootScriptsDir);
data.insert(QLatin1String(configurationFileKeyC), m_configurationFile);
data.insert(QLatin1String(additionalArgumentsKeyC), m_additionalArguments);
@@ -185,7 +181,7 @@ bool OpenOcdGdbServerProvider::fromMap(const QVariantMap &data)
m_host = data.value(QLatin1String(hostKeyC)).toString();
m_port = data.value(QLatin1String(portKeyC)).toInt();
- m_executableFile = data.value(QLatin1String(executableFileKeyC)).toString();
+ m_executableFile = FilePath::fromVariant(data.value(QLatin1String(executableFileKeyC)));
m_rootScriptsDir = data.value(QLatin1String(rootScriptsDirKeyC)).toString();
m_configurationFile = data.value(QLatin1String(configurationFileKeyC)).toString();
m_additionalArguments = data.value(QLatin1String(additionalArgumentsKeyC)).toString();
@@ -326,7 +322,7 @@ void OpenOcdGdbServerProviderConfigWidget::applyImpl()
p->m_host = m_hostWidget->host();
p->m_port = m_hostWidget->port();
- p->m_executableFile = m_executableFileChooser->fileName().toString();
+ 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();
@@ -348,7 +344,7 @@ void OpenOcdGdbServerProviderConfigWidget::setFromProvider()
startupModeChanged();
m_hostWidget->setHost(p->m_host);
m_hostWidget->setPort(p->m_port);
- m_executableFileChooser->setFileName(Utils::FilePath::fromString(p->m_executableFile));
+ m_executableFileChooser->setFileName(p->m_executableFile);
m_rootScriptsDirChooser->setFileName(Utils::FilePath::fromString(p->m_rootScriptsDir));
m_configurationFileChooser->setFileName(Utils::FilePath::fromString(p->m_configurationFile));
m_additionalArgumentsLineEdit->setText(p->m_additionalArguments);
diff --git a/src/plugins/baremetal/openocdgdbserverprovider.h b/src/plugins/baremetal/openocdgdbserverprovider.h
index 63a5afcb3c..229b12bf61 100644
--- a/src/plugins/baremetal/openocdgdbserverprovider.h
+++ b/src/plugins/baremetal/openocdgdbserverprovider.h
@@ -51,8 +51,7 @@ public:
GdbServerProvider *clone() const final;
QString channel() const final;
- QString executable() const final;
- QStringList arguments() const final;
+ Utils::CommandLine command() const final;
bool canStartupMode(StartupMode mode) const final;
bool isValid() const final;
@@ -66,7 +65,7 @@ private:
QString m_host = QLatin1String("localhost");
quint16 m_port = 3333;
- QString m_executableFile = QLatin1String("openocd");
+ Utils::FilePath m_executableFile = Utils::FilePath::fromString("openocd");
QString m_rootScriptsDir;
QString m_configurationFile;
QString m_additionalArguments;
diff --git a/src/plugins/baremetal/stlinkutilgdbserverprovider.cpp b/src/plugins/baremetal/stlinkutilgdbserverprovider.cpp
index a8e32f1c99..552f890c80 100644
--- a/src/plugins/baremetal/stlinkutilgdbserverprovider.cpp
+++ b/src/plugins/baremetal/stlinkutilgdbserverprovider.cpp
@@ -41,7 +41,8 @@
#include <QLineEdit>
#include <QPlainTextEdit>
#include <QSpinBox>
-#include <QString>
+
+using namespace Utils;
namespace BareMetal {
namespace Internal {
@@ -107,26 +108,21 @@ QString StLinkUtilGdbServerProvider::channel() const
}
}
-QString StLinkUtilGdbServerProvider::executable() const
-{
- return m_executableFile;
-}
-
-QStringList StLinkUtilGdbServerProvider::arguments() const
+CommandLine StLinkUtilGdbServerProvider::command() const
{
- QStringList args;
+ CommandLine cmd{m_executableFile, {}};
if (m_extendedMode)
- args << QLatin1String("--multi");
+ cmd.addArg("--multi");
if (!m_resetBoard)
- args << QLatin1String("--no-reset");
+ cmd.addArg("--no-reset");
- args << (QLatin1String("--stlink_version=") + QString::number(m_transport));
- args << (QLatin1String("--listen_port=") + QString::number(m_port));
- args << (QLatin1String("--verbose=") + QString::number(m_verboseLevel));
+ cmd.addArg("--stlink_version=" + QString::number(m_transport));
+ cmd.addArg("--listen_port=" + QString::number(m_port));
+ cmd.addArg("--verbose=" + QString::number(m_verboseLevel));
- return args;
+ return cmd;
}
bool StLinkUtilGdbServerProvider::canStartupMode(StartupMode m) const
@@ -164,7 +160,7 @@ QVariantMap StLinkUtilGdbServerProvider::toMap() const
QVariantMap data = GdbServerProvider::toMap();
data.insert(QLatin1String(hostKeyC), m_host);
data.insert(QLatin1String(portKeyC), m_port);
- data.insert(QLatin1String(executableFileKeyC), m_executableFile);
+ data.insert(QLatin1String(executableFileKeyC), m_executableFile.toVariant());
data.insert(QLatin1String(verboseLevelKeyC), m_verboseLevel);
data.insert(QLatin1String(extendedModeKeyC), m_extendedMode);
data.insert(QLatin1String(resetBoardKeyC), m_resetBoard);
@@ -179,7 +175,7 @@ bool StLinkUtilGdbServerProvider::fromMap(const QVariantMap &data)
m_host = data.value(QLatin1String(hostKeyC)).toString();
m_port = data.value(QLatin1String(portKeyC)).toInt();
- m_executableFile = data.value(QLatin1String(executableFileKeyC)).toString();
+ m_executableFile = FileName::fromVariant(data.value(QLatin1String(executableFileKeyC)));
m_verboseLevel = data.value(QLatin1String(verboseLevelKeyC)).toInt();
m_extendedMode = data.value(QLatin1String(extendedModeKeyC)).toBool();
m_resetBoard = data.value(QLatin1String(resetBoardKeyC)).toBool();
@@ -335,7 +331,7 @@ void StLinkUtilGdbServerProviderConfigWidget::applyImpl()
p->m_host = m_hostWidget->host();
p->m_port = m_hostWidget->port();
- p->m_executableFile = m_executableFileChooser->fileName().toString();
+ p->m_executableFile = m_executableFileChooser->fileName();
p->m_verboseLevel = m_verboseLevelSpinBox->value();
p->m_extendedMode = m_extendedModeCheckBox->isChecked();
p->m_resetBoard = m_resetBoardCheckBox->isChecked();
@@ -393,7 +389,7 @@ void StLinkUtilGdbServerProviderConfigWidget::setFromProvider()
startupModeChanged();
m_hostWidget->setHost(p->m_host);
m_hostWidget->setPort(p->m_port);
- m_executableFileChooser->setFileName(Utils::FilePath::fromString(p->m_executableFile));
+ m_executableFileChooser->setFileName(p->m_executableFile);
m_verboseLevelSpinBox->setValue(p->m_verboseLevel);
m_extendedModeCheckBox->setChecked(p->m_extendedMode);
m_resetBoardCheckBox->setChecked(p->m_resetBoard);
diff --git a/src/plugins/baremetal/stlinkutilgdbserverprovider.h b/src/plugins/baremetal/stlinkutilgdbserverprovider.h
index 98b4249f8b..18b75ad405 100644
--- a/src/plugins/baremetal/stlinkutilgdbserverprovider.h
+++ b/src/plugins/baremetal/stlinkutilgdbserverprovider.h
@@ -56,8 +56,7 @@ public:
GdbServerProvider *clone() const final;
QString channel() const final;
- QString executable() const final;
- QStringList arguments() const final;
+ Utils::CommandLine command() const final;
bool canStartupMode(StartupMode mode) const final;
bool isValid() const final;
@@ -71,7 +70,7 @@ private:
QString m_host = QLatin1String("localhost");
quint16 m_port = 4242;
- QString m_executableFile = QLatin1String("st-util");
+ Utils::FilePath m_executableFile = Utils::FilePath::fromString("st-util");
int m_verboseLevel = 0; // 0..99
bool m_extendedMode = false; // Listening for connections after disconnect
bool m_resetBoard = true;