Debugger: Support sysroot override

Sometimes the same toolchain can be used with different versions of
sysroots. Support this in command-line and dialogs.

Change-Id: Id49f8e8c50f4856e979eecbbdebc680b57dc69b2
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Orgad Shaneh
2020-06-29 18:14:20 +03:00
committed by Orgad Shaneh
parent b60ab85c13
commit 8951ddfd62
5 changed files with 54 additions and 3 deletions

View File

@@ -22,15 +22,15 @@
\"Description\" : \"Attach to local process\"
},
{
\"Name\" : \"-debug <executable>[,kit=<kit>][,terminal={0,1}]\",
\"Name\" : \"-debug <executable>[,kit=<kit>][,terminal={0,1}][,sysroot=<sysroot>]\",
\"Description\" : \"Start and debug executable\"
},
{
\"Name\" : \"-debug [executable,]core=<corefile>[,kit=<kit>]\",
\"Name\" : \"-debug [executable,]core=<corefile>[,kit=<kit>][,sysroot=<sysroot>]\",
\"Description\" : \"Attach to core file\"
},
{
\"Name\" : \"-debug <executable>,server=<server:port>[,kit=<kit>]\",
\"Name\" : \"-debug <executable>,server=<server:port>[,kit=<kit>][,sysroot=<sysroot>]\",
\"Description\" : \"Attach to remote debug server\"
},
{

View File

@@ -86,6 +86,8 @@ public:
PathChooser *debuginfoPathChooser;
QLabel *serverStartScriptLabel;
PathChooser *serverStartScriptPathChooser;
QLabel *sysRootLabel;
PathChooser *sysRootPathChooser;
QLabel *serverInitCommandsLabel;
QPlainTextEdit *serverInitCommandsTextEdit;
QLabel *serverResetCommandsLabel;
@@ -126,6 +128,7 @@ public:
bool breakAtMain = false;
bool runInTerminal = false;
FilePath serverStartScript;
FilePath sysRoot;
QString serverInitCommands;
QString serverResetCommands;
QString debugInfoLocation;
@@ -140,6 +143,7 @@ bool StartApplicationParameters::equals(const StartApplicationParameters &rhs) c
&& breakAtMain == rhs.breakAtMain
&& runInTerminal == rhs.runInTerminal
&& serverStartScript == rhs.serverStartScript
&& sysRoot == rhs.sysRoot
&& serverInitCommands == rhs.serverInitCommands
&& serverResetCommands == rhs.serverResetCommands
&& kitId == rhs.kitId
@@ -181,6 +185,7 @@ void StartApplicationParameters::toSettings(QSettings *settings) const
settings->setValue("LastServerInitCommands", serverInitCommands);
settings->setValue("LastServerResetCommands", serverResetCommands);
settings->setValue("LastDebugInfoLocation", debugInfoLocation);
settings->setValue("LastSysRoot", sysRoot.toVariant());
}
void StartApplicationParameters::fromSettings(const QSettings *settings)
@@ -197,6 +202,7 @@ void StartApplicationParameters::fromSettings(const QSettings *settings)
serverInitCommands = settings->value("LastServerInitCommands").toString();
serverResetCommands = settings->value("LastServerResetCommands").toString();
debugInfoLocation = settings->value("LastDebugInfoLocation").toString();
sysRoot = FilePath::fromVariant(settings->value("LastSysRoot"));
}
///////////////////////////////////////////////////////////////////////
@@ -259,6 +265,16 @@ StartApplicationDialog::StartApplicationDialog(QWidget *parent)
d->serverStartScriptLabel->setBuddy(d->serverStartScriptPathChooser);
d->serverStartScriptLabel->setToolTip(d->serverStartScriptPathChooser->toolTip());
d->sysRootPathChooser = new PathChooser(this);
d->sysRootPathChooser->setExpectedKind(PathChooser::Directory);
d->sysRootPathChooser->setHistoryCompleter("Debugger.SysRoot.History");
d->sysRootPathChooser->setPromptDialogTitle(tr("Select SysRoot Directory"));
d->sysRootPathChooser->setToolTip(tr(
"This option can be used to override the kit's SysRoot setting."));
d->sysRootLabel = new QLabel(tr("Override S&ysRoot:"), this);
d->sysRootLabel->setBuddy(d->sysRootPathChooser);
d->sysRootLabel->setToolTip(d->sysRootPathChooser->toolTip());
d->serverInitCommandsTextEdit = new QPlainTextEdit(this);
d->serverInitCommandsTextEdit->setToolTip(tr(
"This option can be used to send the target init commands."));
@@ -306,6 +322,7 @@ StartApplicationDialog::StartApplicationDialog(QWidget *parent)
formLayout->addRow(tr("Run in &terminal:"), d->runInTerminalCheckBox);
formLayout->addRow(tr("Break at \"&main\":"), d->breakAtMainCheckBox);
formLayout->addRow(d->serverStartScriptLabel, d->serverStartScriptPathChooser);
formLayout->addRow(d->sysRootLabel, d->sysRootPathChooser);
formLayout->addRow(d->serverInitCommandsLabel, d->serverInitCommandsTextEdit);
formLayout->addRow(d->serverResetCommandsLabel, d->serverResetCommandsTextEdit);
formLayout->addRow(tr("Debug &information:"), d->debuginfoPathChooser);
@@ -445,6 +462,7 @@ void StartApplicationDialog::run(bool attachRemote)
debugger->setCommandsAfterConnect(newParameters.serverInitCommands);
debugger->setCommandsForReset(newParameters.serverResetCommands);
debugger->setUseTerminal(newParameters.runInTerminal);
debugger->setSysRoot(newParameters.sysRoot);
bool isLocal = !dev || (dev->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
if (isLocal) {
@@ -481,6 +499,7 @@ StartApplicationParameters StartApplicationDialog::parameters() const
result.serverAddress = d->channelOverrideEdit->text();
result.runnable.executable = d->localExecutablePathChooser->filePath();
result.serverStartScript = d->serverStartScriptPathChooser->filePath();
result.sysRoot = d->sysRootPathChooser->filePath();
result.serverInitCommands = d->serverInitCommandsTextEdit->toPlainText();
result.serverResetCommands = d->serverResetCommandsTextEdit->toPlainText();
result.kitId = d->kitChooser->currentKitId();
@@ -499,6 +518,7 @@ void StartApplicationDialog::setParameters(const StartApplicationParameters &p)
d->channelOverrideEdit->setText(p.serverAddress);
d->localExecutablePathChooser->setFilePath(p.runnable.executable);
d->serverStartScriptPathChooser->setFilePath(p.serverStartScript);
d->sysRootPathChooser->setFilePath(p.sysRoot);
d->serverInitCommandsTextEdit->setPlainText(p.serverInitCommands);
d->serverResetCommandsTextEdit->setPlainText(p.serverResetCommands);
d->debuginfoPathChooser->setPath(p.debugInfoLocation);

View File

@@ -1278,6 +1278,7 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
FilePath executable;
QString remoteChannel;
QString coreFile;
QString sysRoot;
bool useTerminal = false;
if (!pid) {
@@ -1305,6 +1306,8 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
coreFile = val;
} else if (key == "terminal") {
useTerminal = true;
} else if (key == "sysroot") {
sysRoot = val;
}
}
}
@@ -1315,6 +1318,8 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
runControl->setKit(kit);
auto debugger = new DebuggerRunTool(runControl);
debugger->setInferiorExecutable(executable);
if (!sysRoot.isEmpty())
debugger->setSysRoot(FilePath::fromUserInput(sysRoot));
if (pid) {
debugger->setStartMode(AttachExternal);
debugger->setCloseMode(DetachAtClose);
@@ -1541,6 +1546,7 @@ void DebuggerPluginPrivate::attachCore()
dlg.setLocalCoreFile(configValue("LastLocalCoreFile").toString());
dlg.setRemoteCoreFile(configValue("LastRemoteCoreFile").toString());
dlg.setOverrideStartScript(configValue("LastExternalStartScript").toString());
dlg.setSysRoot(configValue("LastSysRoot").toString());
dlg.setForceLocalCoreFile(configValue("LastForceLocalCoreFile").toBool());
if (dlg.exec() != QDialog::Accepted)
@@ -1551,6 +1557,7 @@ void DebuggerPluginPrivate::attachCore()
setConfigValue("LastRemoteCoreFile", dlg.remoteCoreFile());
setConfigValue("LastExternalKit", dlg.kit()->id().toSetting());
setConfigValue("LastExternalStartScript", dlg.overrideStartScript());
setConfigValue("LastSysRoot", dlg.sysRoot().toString());
setConfigValue("LastForceLocalCoreFile", dlg.forcesLocalCoreFile());
auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE);
@@ -1563,6 +1570,9 @@ void DebuggerPluginPrivate::attachCore()
debugger->setStartMode(AttachCore);
debugger->setCloseMode(DetachAtClose);
debugger->setOverrideStartScript(dlg.overrideStartScript());
const FilePath sysRoot = dlg.sysRoot();
if (!sysRoot.isEmpty())
debugger->setSysRoot(sysRoot);
debugger->startRunControl();
}

View File

@@ -212,6 +212,7 @@ public:
QPushButton *selectRemoteCoreButton;
PathChooser *overrideStartScriptFileName;
PathChooser *sysRootDirectory;
QDialogButtonBox *buttonBox;
@@ -287,6 +288,13 @@ AttachCoreDialog::AttachCoreDialog(QWidget *parent)
d->overrideStartScriptFileName->setExpectedKind(PathChooser::File);
d->overrideStartScriptFileName->setPromptDialogTitle(tr("Select Startup Script"));
d->sysRootDirectory = new PathChooser(this);
d->sysRootDirectory->setHistoryCompleter("Debugger.SysRoot.History");
d->sysRootDirectory->setExpectedKind(PathChooser::Directory);
d->sysRootDirectory->setPromptDialogTitle(tr("Select SysRoot Directory"));
d->sysRootDirectory->setToolTip(tr(
"This option can be used to override the kit's SysRoot setting"));
auto coreLayout = new QHBoxLayout;
coreLayout->addWidget(d->localCoreFileName);
coreLayout->addWidget(d->remoteCoreFileName);
@@ -301,6 +309,7 @@ AttachCoreDialog::AttachCoreDialog(QWidget *parent)
formLayout->addRow(tr("Core file:"), coreLayout);
formLayout->addRow(tr("&Executable or symbol file:"), d->symbolFileName);
formLayout->addRow(tr("Override &start script:"), d->overrideStartScriptFileName);
formLayout->addRow(tr("Override S&ysRoot:"), d->sysRootDirectory);
auto line = new QFrame(this);
line->setFrameShape(QFrame::HLine);
@@ -469,5 +478,15 @@ void AttachCoreDialog::setOverrideStartScript(const QString &scriptName)
d->overrideStartScriptFileName->setPath(scriptName);
}
FilePath AttachCoreDialog::sysRoot() const
{
return d->sysRootDirectory->filePath();
}
void AttachCoreDialog::setSysRoot(const QString &sysRoot)
{
d->sysRootDirectory->setPath(sysRoot);
}
} // namespace Internal
} // namespace Debugger

View File

@@ -51,6 +51,7 @@ public:
QString localCoreFile() const;
QString remoteCoreFile() const;
QString overrideStartScript() const;
Utils::FilePath sysRoot() const;
bool useLocalCoreFile() const;
bool forcesLocalCoreFile() const;
bool isLocalKit() const;
@@ -61,6 +62,7 @@ public:
void setLocalCoreFile(const QString &core);
void setRemoteCoreFile(const QString &core);
void setOverrideStartScript(const QString &scriptName);
void setSysRoot(const QString &sysRoot);
void setKitId(Utils::Id id);
void setForceLocalCoreFile(bool on);