forked from qt-creator/qt-creator
BareMetal: Use Utils::CommandLine for gdbserver things
Change-Id: Idf0793636d58b1c6f93a64c94ce5c2b11e4694ce Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -72,11 +72,9 @@ BareMetalDebugSupport::BareMetalDebugSupport(RunControl *runControl)
|
|||||||
|
|
||||||
if (p->startupMode() == GdbServerProvider::StartupOnNetwork) {
|
if (p->startupMode() == GdbServerProvider::StartupOnNetwork) {
|
||||||
Runnable r;
|
Runnable r;
|
||||||
r.executable = p->executable();
|
r.setCommandLine(p->command());
|
||||||
// We need to wrap the command arguments depending on a host OS,
|
// Command arguments are in host OS style as the bare metal's GDB servers are launched
|
||||||
// as the bare metal's GDB servers are launched on a host,
|
// on the host, not on that target.
|
||||||
// but not on a target.
|
|
||||||
r.commandLineArguments = Utils::QtcProcess::joinArgs(p->arguments(), Utils::HostOsInfo::hostOs());
|
|
||||||
m_gdbServer = new SimpleTargetRunner(runControl);
|
m_gdbServer = new SimpleTargetRunner(runControl);
|
||||||
m_gdbServer->setRunnable(r);
|
m_gdbServer->setRunnable(r);
|
||||||
addStartDependency(m_gdbServer);
|
addStartDependency(m_gdbServer);
|
||||||
|
@@ -143,12 +143,7 @@ void GdbServerProvider::setResetCommands(const QString &cmds)
|
|||||||
m_resetCommands = cmds;
|
m_resetCommands = cmds;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GdbServerProvider::executable() const
|
Utils::CommandLine GdbServerProvider::command() const
|
||||||
{
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList GdbServerProvider::arguments() const
|
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@@ -84,8 +84,7 @@ public:
|
|||||||
|
|
||||||
virtual QVariantMap toMap() const;
|
virtual QVariantMap toMap() const;
|
||||||
|
|
||||||
virtual QString executable() const;
|
virtual Utils::CommandLine command() const;
|
||||||
virtual QStringList arguments() const;
|
|
||||||
|
|
||||||
virtual bool isValid() const;
|
virtual bool isValid() const;
|
||||||
virtual bool canStartupMode(StartupMode) const;
|
virtual bool canStartupMode(StartupMode) const;
|
||||||
|
@@ -40,7 +40,8 @@
|
|||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <QString>
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace BareMetal {
|
namespace BareMetal {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -92,48 +93,43 @@ QString OpenOcdGdbServerProvider::channel() const
|
|||||||
// Just return as "host:port" form.
|
// Just return as "host:port" form.
|
||||||
return m_host + QLatin1Char(':') + QString::number(m_port);
|
return m_host + QLatin1Char(':') + QString::number(m_port);
|
||||||
case StartupOnPipe: {
|
case StartupOnPipe: {
|
||||||
QStringList args;
|
|
||||||
// In the pipe mode need to add quotes to each item of arguments;
|
// In the pipe mode need to add quotes to each item of arguments;
|
||||||
// otherwise running will be stuck.
|
// otherwise running will be stuck.
|
||||||
for (const QString &a : arguments()) {
|
CommandLine cmd = command();
|
||||||
if (a.startsWith(QLatin1Char('\"')) && a.endsWith(QLatin1Char('\"')))
|
QStringList args = {"|", cmd.executable().toString()};
|
||||||
continue;
|
for (const QString &a : QtcProcess::splitArgs(cmd.arguments())) {
|
||||||
args << (QLatin1Char('\"') + a + QLatin1Char('\"'));
|
if (a.startsWith('\"') && a.endsWith('\"'))
|
||||||
|
args << a;
|
||||||
|
else
|
||||||
|
args << ('\"' + a + '\"');
|
||||||
}
|
}
|
||||||
args.prepend(executable());
|
return args.join(' ');
|
||||||
args.prepend(QLatin1String("|"));
|
|
||||||
return args.join(QLatin1Char(' '));
|
|
||||||
}
|
}
|
||||||
default: // wrong
|
default: // wrong
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString OpenOcdGdbServerProvider::executable() const
|
CommandLine OpenOcdGdbServerProvider::command() const
|
||||||
{
|
{
|
||||||
return m_executableFile;
|
CommandLine cmd{m_executableFile, {}};
|
||||||
}
|
|
||||||
|
|
||||||
QStringList OpenOcdGdbServerProvider::arguments() const
|
cmd.addArg("-c");
|
||||||
{
|
|
||||||
QStringList args;
|
|
||||||
|
|
||||||
args << QLatin1String("-c");
|
|
||||||
if (startupMode() == StartupOnPipe)
|
if (startupMode() == StartupOnPipe)
|
||||||
args << QLatin1String("gdb_port pipe");
|
cmd.addArg("gdb_port pipe");
|
||||||
else
|
else
|
||||||
args << (QLatin1String("gdb_port ") + QString::number(m_port));
|
cmd.addArg("gdb_port " + QString::number(m_port));
|
||||||
|
|
||||||
if (!m_rootScriptsDir.isEmpty())
|
if (!m_rootScriptsDir.isEmpty())
|
||||||
args << QLatin1String("-s") << m_rootScriptsDir;
|
cmd.addArgs({"-s", m_rootScriptsDir});
|
||||||
|
|
||||||
if (!m_configurationFile.isEmpty())
|
if (!m_configurationFile.isEmpty())
|
||||||
args << QLatin1String("-f") << m_configurationFile;
|
cmd.addArgs({"-f", m_configurationFile});
|
||||||
|
|
||||||
if (!m_additionalArguments.isEmpty())
|
if (!m_additionalArguments.isEmpty())
|
||||||
args << Utils::QtcProcess::splitArgs(m_additionalArguments);
|
cmd.addArgs(m_additionalArguments);
|
||||||
|
|
||||||
return args;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenOcdGdbServerProvider::canStartupMode(StartupMode m) const
|
bool OpenOcdGdbServerProvider::canStartupMode(StartupMode m) const
|
||||||
@@ -171,7 +167,7 @@ QVariantMap OpenOcdGdbServerProvider::toMap() const
|
|||||||
QVariantMap data = GdbServerProvider::toMap();
|
QVariantMap data = GdbServerProvider::toMap();
|
||||||
data.insert(QLatin1String(hostKeyC), m_host);
|
data.insert(QLatin1String(hostKeyC), m_host);
|
||||||
data.insert(QLatin1String(portKeyC), m_port);
|
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(rootScriptsDirKeyC), m_rootScriptsDir);
|
||||||
data.insert(QLatin1String(configurationFileKeyC), m_configurationFile);
|
data.insert(QLatin1String(configurationFileKeyC), m_configurationFile);
|
||||||
data.insert(QLatin1String(additionalArgumentsKeyC), m_additionalArguments);
|
data.insert(QLatin1String(additionalArgumentsKeyC), m_additionalArguments);
|
||||||
@@ -185,7 +181,7 @@ bool OpenOcdGdbServerProvider::fromMap(const QVariantMap &data)
|
|||||||
|
|
||||||
m_host = data.value(QLatin1String(hostKeyC)).toString();
|
m_host = data.value(QLatin1String(hostKeyC)).toString();
|
||||||
m_port = data.value(QLatin1String(portKeyC)).toInt();
|
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_rootScriptsDir = data.value(QLatin1String(rootScriptsDirKeyC)).toString();
|
||||||
m_configurationFile = data.value(QLatin1String(configurationFileKeyC)).toString();
|
m_configurationFile = data.value(QLatin1String(configurationFileKeyC)).toString();
|
||||||
m_additionalArguments = data.value(QLatin1String(additionalArgumentsKeyC)).toString();
|
m_additionalArguments = data.value(QLatin1String(additionalArgumentsKeyC)).toString();
|
||||||
@@ -326,7 +322,7 @@ void OpenOcdGdbServerProviderConfigWidget::applyImpl()
|
|||||||
|
|
||||||
p->m_host = m_hostWidget->host();
|
p->m_host = m_hostWidget->host();
|
||||||
p->m_port = m_hostWidget->port();
|
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_rootScriptsDir = m_rootScriptsDirChooser->fileName().toString();
|
||||||
p->m_configurationFile = m_configurationFileChooser->fileName().toString();
|
p->m_configurationFile = m_configurationFileChooser->fileName().toString();
|
||||||
p->m_additionalArguments = m_additionalArgumentsLineEdit->text();
|
p->m_additionalArguments = m_additionalArgumentsLineEdit->text();
|
||||||
@@ -348,7 +344,7 @@ void OpenOcdGdbServerProviderConfigWidget::setFromProvider()
|
|||||||
startupModeChanged();
|
startupModeChanged();
|
||||||
m_hostWidget->setHost(p->m_host);
|
m_hostWidget->setHost(p->m_host);
|
||||||
m_hostWidget->setPort(p->m_port);
|
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_rootScriptsDirChooser->setFileName(Utils::FilePath::fromString(p->m_rootScriptsDir));
|
||||||
m_configurationFileChooser->setFileName(Utils::FilePath::fromString(p->m_configurationFile));
|
m_configurationFileChooser->setFileName(Utils::FilePath::fromString(p->m_configurationFile));
|
||||||
m_additionalArgumentsLineEdit->setText(p->m_additionalArguments);
|
m_additionalArgumentsLineEdit->setText(p->m_additionalArguments);
|
||||||
|
@@ -51,8 +51,7 @@ public:
|
|||||||
GdbServerProvider *clone() const final;
|
GdbServerProvider *clone() const final;
|
||||||
|
|
||||||
QString channel() const final;
|
QString channel() const final;
|
||||||
QString executable() const final;
|
Utils::CommandLine command() const final;
|
||||||
QStringList arguments() const final;
|
|
||||||
|
|
||||||
bool canStartupMode(StartupMode mode) const final;
|
bool canStartupMode(StartupMode mode) const final;
|
||||||
bool isValid() const final;
|
bool isValid() const final;
|
||||||
@@ -66,7 +65,7 @@ private:
|
|||||||
|
|
||||||
QString m_host = QLatin1String("localhost");
|
QString m_host = QLatin1String("localhost");
|
||||||
quint16 m_port = 3333;
|
quint16 m_port = 3333;
|
||||||
QString m_executableFile = QLatin1String("openocd");
|
Utils::FilePath m_executableFile = Utils::FilePath::fromString("openocd");
|
||||||
QString m_rootScriptsDir;
|
QString m_rootScriptsDir;
|
||||||
QString m_configurationFile;
|
QString m_configurationFile;
|
||||||
QString m_additionalArguments;
|
QString m_additionalArguments;
|
||||||
|
@@ -41,7 +41,8 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QString>
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace BareMetal {
|
namespace BareMetal {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -107,26 +108,21 @@ QString StLinkUtilGdbServerProvider::channel() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString StLinkUtilGdbServerProvider::executable() const
|
CommandLine StLinkUtilGdbServerProvider::command() const
|
||||||
{
|
{
|
||||||
return m_executableFile;
|
CommandLine cmd{m_executableFile, {}};
|
||||||
}
|
|
||||||
|
|
||||||
QStringList StLinkUtilGdbServerProvider::arguments() const
|
|
||||||
{
|
|
||||||
QStringList args;
|
|
||||||
|
|
||||||
if (m_extendedMode)
|
if (m_extendedMode)
|
||||||
args << QLatin1String("--multi");
|
cmd.addArg("--multi");
|
||||||
|
|
||||||
if (!m_resetBoard)
|
if (!m_resetBoard)
|
||||||
args << QLatin1String("--no-reset");
|
cmd.addArg("--no-reset");
|
||||||
|
|
||||||
args << (QLatin1String("--stlink_version=") + QString::number(m_transport));
|
cmd.addArg("--stlink_version=" + QString::number(m_transport));
|
||||||
args << (QLatin1String("--listen_port=") + QString::number(m_port));
|
cmd.addArg("--listen_port=" + QString::number(m_port));
|
||||||
args << (QLatin1String("--verbose=") + QString::number(m_verboseLevel));
|
cmd.addArg("--verbose=" + QString::number(m_verboseLevel));
|
||||||
|
|
||||||
return args;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StLinkUtilGdbServerProvider::canStartupMode(StartupMode m) const
|
bool StLinkUtilGdbServerProvider::canStartupMode(StartupMode m) const
|
||||||
@@ -164,7 +160,7 @@ QVariantMap StLinkUtilGdbServerProvider::toMap() const
|
|||||||
QVariantMap data = GdbServerProvider::toMap();
|
QVariantMap data = GdbServerProvider::toMap();
|
||||||
data.insert(QLatin1String(hostKeyC), m_host);
|
data.insert(QLatin1String(hostKeyC), m_host);
|
||||||
data.insert(QLatin1String(portKeyC), m_port);
|
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(verboseLevelKeyC), m_verboseLevel);
|
||||||
data.insert(QLatin1String(extendedModeKeyC), m_extendedMode);
|
data.insert(QLatin1String(extendedModeKeyC), m_extendedMode);
|
||||||
data.insert(QLatin1String(resetBoardKeyC), m_resetBoard);
|
data.insert(QLatin1String(resetBoardKeyC), m_resetBoard);
|
||||||
@@ -179,7 +175,7 @@ bool StLinkUtilGdbServerProvider::fromMap(const QVariantMap &data)
|
|||||||
|
|
||||||
m_host = data.value(QLatin1String(hostKeyC)).toString();
|
m_host = data.value(QLatin1String(hostKeyC)).toString();
|
||||||
m_port = data.value(QLatin1String(portKeyC)).toInt();
|
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_verboseLevel = data.value(QLatin1String(verboseLevelKeyC)).toInt();
|
||||||
m_extendedMode = data.value(QLatin1String(extendedModeKeyC)).toBool();
|
m_extendedMode = data.value(QLatin1String(extendedModeKeyC)).toBool();
|
||||||
m_resetBoard = data.value(QLatin1String(resetBoardKeyC)).toBool();
|
m_resetBoard = data.value(QLatin1String(resetBoardKeyC)).toBool();
|
||||||
@@ -335,7 +331,7 @@ void StLinkUtilGdbServerProviderConfigWidget::applyImpl()
|
|||||||
|
|
||||||
p->m_host = m_hostWidget->host();
|
p->m_host = m_hostWidget->host();
|
||||||
p->m_port = m_hostWidget->port();
|
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_verboseLevel = m_verboseLevelSpinBox->value();
|
||||||
p->m_extendedMode = m_extendedModeCheckBox->isChecked();
|
p->m_extendedMode = m_extendedModeCheckBox->isChecked();
|
||||||
p->m_resetBoard = m_resetBoardCheckBox->isChecked();
|
p->m_resetBoard = m_resetBoardCheckBox->isChecked();
|
||||||
@@ -393,7 +389,7 @@ void StLinkUtilGdbServerProviderConfigWidget::setFromProvider()
|
|||||||
startupModeChanged();
|
startupModeChanged();
|
||||||
m_hostWidget->setHost(p->m_host);
|
m_hostWidget->setHost(p->m_host);
|
||||||
m_hostWidget->setPort(p->m_port);
|
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_verboseLevelSpinBox->setValue(p->m_verboseLevel);
|
||||||
m_extendedModeCheckBox->setChecked(p->m_extendedMode);
|
m_extendedModeCheckBox->setChecked(p->m_extendedMode);
|
||||||
m_resetBoardCheckBox->setChecked(p->m_resetBoard);
|
m_resetBoardCheckBox->setChecked(p->m_resetBoard);
|
||||||
|
@@ -56,8 +56,7 @@ public:
|
|||||||
GdbServerProvider *clone() const final;
|
GdbServerProvider *clone() const final;
|
||||||
|
|
||||||
QString channel() const final;
|
QString channel() const final;
|
||||||
QString executable() const final;
|
Utils::CommandLine command() const final;
|
||||||
QStringList arguments() const final;
|
|
||||||
|
|
||||||
bool canStartupMode(StartupMode mode) const final;
|
bool canStartupMode(StartupMode mode) const final;
|
||||||
bool isValid() const final;
|
bool isValid() const final;
|
||||||
@@ -71,7 +70,7 @@ private:
|
|||||||
|
|
||||||
QString m_host = QLatin1String("localhost");
|
QString m_host = QLatin1String("localhost");
|
||||||
quint16 m_port = 4242;
|
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
|
int m_verboseLevel = 0; // 0..99
|
||||||
bool m_extendedMode = false; // Listening for connections after disconnect
|
bool m_extendedMode = false; // Listening for connections after disconnect
|
||||||
bool m_resetBoard = true;
|
bool m_resetBoard = true;
|
||||||
|
Reference in New Issue
Block a user