Debugger: Added a start script (gdbinit) field in attach to core and in remote debugging

Merge-request: 2191
Reviewed-by: hjk <qtc-committer@nokia.com>
This commit is contained in:
Orgad Shaneh
2011-05-03 14:57:05 +02:00
committed by hjk
parent 326ea080c5
commit 2849d3e270
7 changed files with 83 additions and 8 deletions

View File

@@ -2,6 +2,14 @@
<ui version="4.0"> <ui version="4.0">
<class>AttachCoreDialog</class> <class>AttachCoreDialog</class>
<widget class="QDialog" name="AttachCoreDialog"> <widget class="QDialog" name="AttachCoreDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>246</width>
<height>147</height>
</rect>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Start Debugger</string> <string>Start Debugger</string>
</property> </property>
@@ -59,6 +67,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0">
<widget class="QLabel" name="overrideStartScriptLabel">
<property name="text">
<string>Override &amp;Start script:</string>
</property>
<property name="buddy">
<cstring>overrideStartScriptFileName</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="Utils::PathChooser" name="overrideStartScriptFileName"/>
</item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="Debugger::Internal::DebuggerToolChainComboBox" name="toolchainComboBox"/> <widget class="Debugger::Internal::DebuggerToolChainComboBox" name="toolchainComboBox"/>
</item> </item>
@@ -104,7 +125,7 @@
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>DebuggerToolChainComboBox</class> <class>Debugger::Internal::DebuggerToolChainComboBox</class>
<extends>QComboBox</extends> <extends>QComboBox</extends>
<header>debuggertoolchaincombobox.h</header> <header>debuggertoolchaincombobox.h</header>
</customwidget> </customwidget>

View File

@@ -189,12 +189,14 @@ AttachCoreDialog::AttachCoreDialog(QWidget *parent)
m_ui->coreFileName->setExpectedKind(PathChooser::File); m_ui->coreFileName->setExpectedKind(PathChooser::File);
m_ui->coreFileName->setPromptDialogTitle(tr("Select Core File")); m_ui->coreFileName->setPromptDialogTitle(tr("Select Core File"));
m_ui->overrideStartScriptFileName->setExpectedKind(PathChooser::File);
m_ui->overrideStartScriptFileName->setPromptDialogTitle(tr("Select Startup Script"));
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject())); connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(m_ui->coreFileName, SIGNAL(changed(QString)), this, SLOT(changed())); connect(m_ui->coreFileName, SIGNAL(changed(QString)), this, SLOT(changed()));
connect(m_ui->execFileName, SIGNAL(changed(QString)), this, SLOT(changed()));
changed(); changed();
} }
@@ -246,6 +248,16 @@ QString AttachCoreDialog::debuggerCommand()
return m_ui->toolchainComboBox->debuggerCommand(); return m_ui->toolchainComboBox->debuggerCommand();
} }
QString AttachCoreDialog::overrideStartScript() const
{
return m_ui->overrideStartScriptFileName->path();
}
void AttachCoreDialog::setOverrideStartScript(const QString &scriptName)
{
m_ui->overrideStartScriptFileName->setPath(scriptName);
}
bool AttachCoreDialog::isValid() const bool AttachCoreDialog::isValid() const
{ {
return m_ui->toolchainComboBox->currentIndex() >= 0 && return m_ui->toolchainComboBox->currentIndex() >= 0 &&
@@ -632,8 +644,10 @@ StartRemoteDialog::StartRemoteDialog(QWidget *parent)
m_ui->executablePathChooser->setExpectedKind(PathChooser::File); m_ui->executablePathChooser->setExpectedKind(PathChooser::File);
m_ui->executablePathChooser->setPromptDialogTitle(tr("Select Executable")); m_ui->executablePathChooser->setPromptDialogTitle(tr("Select Executable"));
m_ui->sysrootPathChooser->setPromptDialogTitle(tr("Select Sysroot")); m_ui->sysrootPathChooser->setPromptDialogTitle(tr("Select Sysroot"));
m_ui->overrideStartScriptPathChooser->setExpectedKind(PathChooser::File);
m_ui->overrideStartScriptPathChooser->setPromptDialogTitle(tr("Select GDB Start Script"));
m_ui->serverStartScript->setExpectedKind(PathChooser::File); m_ui->serverStartScript->setExpectedKind(PathChooser::File);
m_ui->serverStartScript->setPromptDialogTitle(tr("Select Start Script")); m_ui->serverStartScript->setPromptDialogTitle(tr("Select Server Start Script"));
connect(m_ui->useServerStartScriptCheckBox, SIGNAL(toggled(bool)), connect(m_ui->useServerStartScriptCheckBox, SIGNAL(toggled(bool)),
this, SLOT(updateState())); this, SLOT(updateState()));
@@ -721,6 +735,16 @@ void StartRemoteDialog::setGnuTarget(const QString &gnuTarget)
m_ui->gnuTargetComboBox->setCurrentIndex(index); m_ui->gnuTargetComboBox->setCurrentIndex(index);
} }
QString StartRemoteDialog::overrideStartScript() const
{
return m_ui->overrideStartScriptPathChooser->path();
}
void StartRemoteDialog::setOverrideStartScript(const QString &scriptName)
{
m_ui->overrideStartScriptPathChooser->setPath(scriptName);
}
void StartRemoteDialog::setServerStartScript(const QString &scriptName) void StartRemoteDialog::setServerStartScript(const QString &scriptName)
{ {
m_ui->serverStartScript->setPath(scriptName); m_ui->serverStartScript->setPath(scriptName);

View File

@@ -88,6 +88,9 @@ public:
ProjectExplorer::Abi abi() const; ProjectExplorer::Abi abi() const;
QString debuggerCommand(); QString debuggerCommand();
QString overrideStartScript() const;
void setOverrideStartScript(const QString &scriptName);
private slots: private slots:
void changed(); void changed();
@@ -186,6 +189,9 @@ public:
void setGnuTarget(const QString &gnuTarget); void setGnuTarget(const QString &gnuTarget);
void setGnuTargets(const QStringList &gnuTargets); void setGnuTargets(const QStringList &gnuTargets);
QString overrideStartScript() const;
void setOverrideStartScript(const QString &scriptName);
bool useServerStartScript() const; bool useServerStartScript() const;
void setUseServerStartScript(bool on); void setUseServerStartScript(bool on);
QString serverStartScript() const; QString serverStartScript() const;

View File

@@ -695,6 +695,7 @@ public slots:
void attachCore(); void attachCore();
void attachCore(const QString &core, const QString &exeFileName, void attachCore(const QString &core, const QString &exeFileName,
const ProjectExplorer::Abi &abi = ProjectExplorer::Abi(), const ProjectExplorer::Abi &abi = ProjectExplorer::Abi(),
const QString &overrideStartScript = QString(),
const QString &debuggerCommand = QString()); const QString &debuggerCommand = QString());
void attachRemote(const QString &spec); void attachRemote(const QString &spec);
@@ -1441,6 +1442,7 @@ void DebuggerPluginPrivate::attachCore()
dlg.setExecutableFile(configValue(_("LastExternalExecutableFile")).toString()); dlg.setExecutableFile(configValue(_("LastExternalExecutableFile")).toString());
dlg.setCoreFile(configValue(_("LastExternalCoreFile")).toString()); dlg.setCoreFile(configValue(_("LastExternalCoreFile")).toString());
dlg.setAbiIndex(configValue(_("LastExternalCoreAbiIndex")).toInt()); dlg.setAbiIndex(configValue(_("LastExternalCoreAbiIndex")).toInt());
dlg.setOverrideStartScript(configValue(_("LastExternalStartScript")).toString());
if (dlg.exec() != QDialog::Accepted) if (dlg.exec() != QDialog::Accepted)
return; return;
@@ -1448,12 +1450,14 @@ void DebuggerPluginPrivate::attachCore()
setConfigValue(_("LastExternalExecutableFile"), dlg.executableFile()); setConfigValue(_("LastExternalExecutableFile"), dlg.executableFile());
setConfigValue(_("LastExternalCoreFile"), dlg.coreFile()); setConfigValue(_("LastExternalCoreFile"), dlg.coreFile());
setConfigValue(_("LastExternalCoreAbiIndex"), QVariant(dlg.abiIndex())); setConfigValue(_("LastExternalCoreAbiIndex"), QVariant(dlg.abiIndex()));
attachCore(dlg.coreFile(), dlg.executableFile(), dlg.abi()); setConfigValue(_("LastExternalStartScript"), dlg.overrideStartScript());
attachCore(dlg.coreFile(), dlg.executableFile(), dlg.abi(), dlg.overrideStartScript());
} }
void DebuggerPluginPrivate::attachCore(const QString &core, void DebuggerPluginPrivate::attachCore(const QString &core,
const QString &exe, const QString &exe,
const ProjectExplorer::Abi &abi, const ProjectExplorer::Abi &abi,
const QString &overrideStartScript,
const QString &debuggerCommand) const QString &debuggerCommand)
{ {
DebuggerStartParameters sp; DebuggerStartParameters sp;
@@ -1463,6 +1467,7 @@ void DebuggerPluginPrivate::attachCore(const QString &core,
sp.startMode = AttachCore; sp.startMode = AttachCore;
sp.debuggerCommand = debuggerCommand; sp.debuggerCommand = debuggerCommand;
sp.toolChainAbi = abi.isValid() ? abi : abiOfBinary(sp.coreFile); sp.toolChainAbi = abi.isValid() ? abi : abiOfBinary(sp.coreFile);
sp.overrideStartScript = overrideStartScript;
if (DebuggerRunControl *rc = createDebugger(sp)) if (DebuggerRunControl *rc = createDebugger(sp))
startDebugger(rc); startDebugger(rc);
} }
@@ -1534,6 +1539,7 @@ void DebuggerPluginPrivate::startRemoteApplication()
dlg.setDebugger(configValue(_("LastDebugger")).toString()); dlg.setDebugger(configValue(_("LastDebugger")).toString());
dlg.setRemoteArchitecture(lastUsed); dlg.setRemoteArchitecture(lastUsed);
dlg.setGnuTarget(lastUsedGnuTarget); dlg.setGnuTarget(lastUsedGnuTarget);
dlg.setOverrideStartScript(configValue(_("LastRemoteStartScript")).toString());
dlg.setServerStartScript( dlg.setServerStartScript(
configValue(_("LastServerStartScript")).toString()); configValue(_("LastServerStartScript")).toString());
dlg.setUseServerStartScript( dlg.setUseServerStartScript(
@@ -1546,6 +1552,7 @@ void DebuggerPluginPrivate::startRemoteApplication()
setConfigValue(_("LastDebugger"), dlg.debugger()); setConfigValue(_("LastDebugger"), dlg.debugger());
setConfigValue(_("LastRemoteArchitecture"), dlg.remoteArchitecture()); setConfigValue(_("LastRemoteArchitecture"), dlg.remoteArchitecture());
setConfigValue(_("LastGnuTarget"), dlg.gnuTarget()); setConfigValue(_("LastGnuTarget"), dlg.gnuTarget());
setConfigValue(_("LastRemoteStartScript"), dlg.overrideStartScript());
setConfigValue(_("LastServerStartScript"), dlg.serverStartScript()); setConfigValue(_("LastServerStartScript"), dlg.serverStartScript());
setConfigValue(_("LastUseServerStartScript"), dlg.useServerStartScript()); setConfigValue(_("LastUseServerStartScript"), dlg.useServerStartScript());
setConfigValue(_("LastSysroot"), dlg.sysRoot()); setConfigValue(_("LastSysroot"), dlg.sysRoot());
@@ -1558,6 +1565,7 @@ void DebuggerPluginPrivate::startRemoteApplication()
if (!sp.debuggerCommand.isEmpty()) if (!sp.debuggerCommand.isEmpty())
sp.toolChainAbi = ProjectExplorer::Abi(); sp.toolChainAbi = ProjectExplorer::Abi();
sp.startMode = AttachToRemote; sp.startMode = AttachToRemote;
sp.overrideStartScript = dlg.overrideStartScript();
sp.useServerStartScript = dlg.useServerStartScript(); sp.useServerStartScript = dlg.useServerStartScript();
sp.serverStartScript = dlg.serverStartScript(); sp.serverStartScript = dlg.serverStartScript();
sp.sysRoot = dlg.sysRoot(); sp.sysRoot = dlg.sysRoot();

View File

@@ -80,6 +80,7 @@ public:
QString displayName; // Used in the Snapshots view. QString displayName; // Used in the Snapshots view.
QString startMessage; // First status message shown. QString startMessage; // First status message shown.
QString coreFile; QString coreFile;
QString overrideStartScript; // Used in attach to core and remote debugging
bool isSnapshot; // Set if created internally. bool isSnapshot; // Set if created internally.
QString processArgs; QString processArgs;
Utils::Environment environment; Utils::Environment environment;

View File

@@ -4438,7 +4438,9 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &settingsIdHint)
loadPythonDumpers(); loadPythonDumpers();
QString scriptFileName = debuggerCore()->stringSetting(GdbScriptFile); QString scriptFileName = sp.overrideStartScript;
if (scriptFileName.isEmpty())
scriptFileName = debuggerCore()->stringSetting(GdbScriptFile);
if (!scriptFileName.isEmpty()) { if (!scriptFileName.isEmpty()) {
if (QFileInfo(scriptFileName).isReadable()) { if (QFileInfo(scriptFileName).isReadable()) {
postCommand("source " + scriptFileName.toLocal8Bit()); postCommand("source " + scriptFileName.toLocal8Bit());

View File

@@ -107,6 +107,19 @@
<widget class="Utils::PathChooser" name="sysrootPathChooser"/> <widget class="Utils::PathChooser" name="sysrootPathChooser"/>
</item> </item>
<item row="6" column="0"> <item row="6" column="0">
<widget class="QLabel" name="overrideStartScriptLabel">
<property name="text">
<string>Override S&amp;tart script:</string>
</property>
<property name="buddy">
<cstring>overrideStartScriptPathChooser</cstring>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="Utils::PathChooser" name="overrideStartScriptPathChooser"/>
</item>
<item row="7" column="0">
<widget class="QLabel" name="useServerStartScriptLabel"> <widget class="QLabel" name="useServerStartScriptLabel">
<property name="text"> <property name="text">
<string>&amp;Use server start script:</string> <string>&amp;Use server start script:</string>
@@ -116,10 +129,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1"> <item row="7" column="1">
<widget class="QCheckBox" name="useServerStartScriptCheckBox"/> <widget class="QCheckBox" name="useServerStartScriptCheckBox"/>
</item> </item>
<item row="7" column="0"> <item row="8" column="0">
<widget class="QLabel" name="serverStartScriptLabel"> <widget class="QLabel" name="serverStartScriptLabel">
<property name="text"> <property name="text">
<string>&amp;Server start script:</string> <string>&amp;Server start script:</string>
@@ -129,7 +142,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1"> <item row="8" column="1">
<widget class="Utils::PathChooser" name="serverStartScript"/> <widget class="Utils::PathChooser" name="serverStartScript"/>
</item> </item>
</layout> </layout>