debugger: allow using a local core file with a remote kit

This is a common use case when examining core files from devices without
ssh access or "externally" created core files and used to work with 2.5.

Change-Id: Ie8ee5e2e0216c1e8c3265cf01e59f2c92d8730ef
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
hjk
2012-10-22 11:14:18 +02:00
parent 78b4b8ae6e
commit 7728ed4af1
3 changed files with 61 additions and 30 deletions

View File

@@ -1600,11 +1600,12 @@ void DebuggerPluginPrivate::attachCore()
{ {
AttachCoreDialog dlg(mainWindow()); AttachCoreDialog dlg(mainWindow());
dlg.setKitId(Id(configValue(_("LastExternalProfile")).toString())); dlg.setKitId(Id(configValue(_("LastExternalKit")).toString()));
dlg.setLocalExecutableFile(configValue(_("LastExternalExecutableFile")).toString()); dlg.setLocalExecutableFile(configValue(_("LastExternalExecutableFile")).toString());
dlg.setLocalCoreFile(configValue(_("LastLocalCoreFile")).toString()); dlg.setLocalCoreFile(configValue(_("LastLocalCoreFile")).toString());
dlg.setRemoteCoreFile(configValue(_("LastRemoteCoreFile")).toString()); dlg.setRemoteCoreFile(configValue(_("LastRemoteCoreFile")).toString());
dlg.setOverrideStartScript(configValue(_("LastExternalStartScript")).toString()); dlg.setOverrideStartScript(configValue(_("LastExternalStartScript")).toString());
dlg.setForceLocalCoreFile(configValue(_("LastForceLocalCoreFile")).toBool());
if (dlg.exec() != QDialog::Accepted) if (dlg.exec() != QDialog::Accepted)
return; return;
@@ -1612,11 +1613,12 @@ void DebuggerPluginPrivate::attachCore()
setConfigValue(_("LastExternalExecutableFile"), dlg.localExecutableFile()); setConfigValue(_("LastExternalExecutableFile"), dlg.localExecutableFile());
setConfigValue(_("LastLocalCoreFile"), dlg.localCoreFile()); setConfigValue(_("LastLocalCoreFile"), dlg.localCoreFile());
setConfigValue(_("LastRemoteCoreFile"), dlg.remoteCoreFile()); setConfigValue(_("LastRemoteCoreFile"), dlg.remoteCoreFile());
setConfigValue(_("LastExternalProfile"), dlg.kit()->id().toString()); setConfigValue(_("LastExternalKit"), dlg.kit()->id().toString());
setConfigValue(_("LastExternalStartScript"), dlg.overrideStartScript()); setConfigValue(_("LastExternalStartScript"), dlg.overrideStartScript());
setConfigValue(_("LastForceLocalCoreFile"), dlg.forcesLocalCoreFile());
DebuggerStartParameters sp; DebuggerStartParameters sp;
QString display = dlg.isLocal() ? dlg.localCoreFile() : dlg.remoteCoreFile(); QString display = dlg.useLocalCoreFile() ? dlg.localCoreFile() : dlg.remoteCoreFile();
QTC_ASSERT(fillParameters(&sp, dlg.kit()), return); QTC_ASSERT(fillParameters(&sp, dlg.kit()), return);
sp.masterEngineType = GdbEngineType; sp.masterEngineType = GdbEngineType;
sp.executable = dlg.localExecutableFile(); sp.executable = dlg.localExecutableFile();

View File

@@ -46,6 +46,7 @@
#include <utils/pathchooser.h> #include <utils/pathchooser.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QCheckBox>
#include <QCoreApplication> #include <QCoreApplication>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
@@ -60,6 +61,7 @@
#include <QGridLayout> #include <QGridLayout>
#include <QGroupBox> #include <QGroupBox>
#include <QHeaderView> #include <QHeaderView>
#include <QLabel>
#include <QLineEdit> #include <QLineEdit>
#include <QMessageBox> #include <QMessageBox>
#include <QPushButton> #include <QPushButton>
@@ -224,8 +226,8 @@ class AttachCoreDialogPrivate
public: public:
KitChooser *kitChooser; KitChooser *kitChooser;
QSettings *settings; QCheckBox *forceLocalCheckBox;
QLabel *forceLocalLabel;
PathChooser *localExecFileName; PathChooser *localExecFileName;
PathChooser *localCoreFileName; PathChooser *localCoreFileName;
QLineEdit *remoteCoreFileName; QLineEdit *remoteCoreFileName;
@@ -242,14 +244,16 @@ AttachCoreDialog::AttachCoreDialog(QWidget *parent)
setWindowTitle(tr("Load Core File")); setWindowTitle(tr("Load Core File"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
d->settings = ICore::settings();
d->kitChooser = new DebuggerKitChooser(DebuggerKitChooser::RemoteDebugging, this); d->kitChooser = new DebuggerKitChooser(DebuggerKitChooser::RemoteDebugging, this);
d->kitChooser->populate(); d->kitChooser->populate();
d->selectRemoteCoreButton = new QPushButton(tr("Browse..."), this); d->selectRemoteCoreButton = new QPushButton(tr("Browse..."), this);
d->remoteCoreFileName = new QLineEdit(this); d->remoteCoreFileName = new QLineEdit(this);
d->remoteCoreFileName->setEnabled(false);
d->forceLocalCheckBox = new QCheckBox(this);
d->forceLocalLabel = new QLabel(this);
d->forceLocalLabel->setText(tr("Use local core file:"));
d->forceLocalLabel->setBuddy(d->forceLocalCheckBox);
d->localCoreFileName = new PathChooser(this); d->localCoreFileName = new PathChooser(this);
d->localCoreFileName->setExpectedKind(PathChooser::File); d->localCoreFileName->setExpectedKind(PathChooser::File);
@@ -279,6 +283,7 @@ AttachCoreDialog::AttachCoreDialog(QWidget *parent)
formLayout->setVerticalSpacing(6); formLayout->setVerticalSpacing(6);
formLayout->addRow(tr("Kit:"), d->kitChooser); formLayout->addRow(tr("Kit:"), d->kitChooser);
formLayout->addRow(tr("&Executable:"), d->localExecFileName); formLayout->addRow(tr("&Executable:"), d->localExecFileName);
formLayout->addRow(d->forceLocalLabel, d->forceLocalCheckBox);
formLayout->addRow(tr("Core file:"), coreLayout); formLayout->addRow(tr("Core file:"), coreLayout);
formLayout->addRow(tr("Override &start script:"), d->overrideStartScriptFileName); formLayout->addRow(tr("Override &start script:"), d->overrideStartScriptFileName);
@@ -293,14 +298,6 @@ AttachCoreDialog::AttachCoreDialog(QWidget *parent)
vboxLayout->addStretch(); vboxLayout->addStretch();
vboxLayout->addWidget(line); vboxLayout->addWidget(line);
vboxLayout->addWidget(d->buttonBox); vboxLayout->addWidget(d->buttonBox);
connect(d->selectRemoteCoreButton, SIGNAL(clicked()), SLOT(selectRemoteCoreFile()));
connect(d->remoteCoreFileName, SIGNAL(textChanged(QString)), SLOT(changed()));
connect(d->localCoreFileName, SIGNAL(changed(QString)), SLOT(changed()));
connect(d->kitChooser, SIGNAL(activated(int)), SLOT(changed()));
connect(d->buttonBox, SIGNAL(rejected()), SLOT(reject()));
connect(d->buttonBox, SIGNAL(accepted()), SLOT(accept()));
changed();
} }
AttachCoreDialog::~AttachCoreDialog() AttachCoreDialog::~AttachCoreDialog()
@@ -308,42 +305,60 @@ AttachCoreDialog::~AttachCoreDialog()
delete d; delete d;
} }
bool AttachCoreDialog::isLocal() const int AttachCoreDialog::exec()
{
connect(d->selectRemoteCoreButton, SIGNAL(clicked()), SLOT(selectRemoteCoreFile()));
connect(d->remoteCoreFileName, SIGNAL(textChanged(QString)), SLOT(changed()));
connect(d->localCoreFileName, SIGNAL(changed(QString)), SLOT(changed()));
connect(d->forceLocalCheckBox, SIGNAL(stateChanged(int)), SLOT(changed()));
connect(d->kitChooser, SIGNAL(activated(int)), SLOT(changed()));
connect(d->buttonBox, SIGNAL(rejected()), SLOT(reject()));
connect(d->buttonBox, SIGNAL(accepted()), SLOT(accept()));
changed();
return QDialog::exec();
}
bool AttachCoreDialog::isLocalKit() const
{ {
Kit *k = d->kitChooser->currentKit(); Kit *k = d->kitChooser->currentKit();
QTC_ASSERT(k, return false); QTC_ASSERT(k, return false);
IDevice::ConstPtr device = DeviceKitInformation::device(k); IDevice::ConstPtr device = DeviceKitInformation::device(k);
QTC_ASSERT(device, return false); QTC_ASSERT(device, return false);
SshConnectionParameters sshParams = device->sshParameters(); return device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
d->settings->setValue(QLatin1String("LastProfile"), }
d->kitChooser->currentKitId().toString());
return sshParams.host.isEmpty(); bool AttachCoreDialog::useLocalCoreFile() const
{
return isLocalKit() || d->forceLocalCheckBox->isChecked();
} }
void AttachCoreDialog::changed() void AttachCoreDialog::changed()
{ {
bool isValid = d->kitChooser->currentIndex() >= 0 && d->localExecFileName->isValid(); bool isValid = d->kitChooser->currentIndex() >= 0 && d->localExecFileName->isValid();
bool isKitLocal = isLocalKit();
if (isLocal()) { d->forceLocalLabel->setVisible(!isKitLocal);
d->forceLocalCheckBox->setVisible(!isKitLocal);
if (useLocalCoreFile()) {
d->localCoreFileName->setVisible(true); d->localCoreFileName->setVisible(true);
d->remoteCoreFileName->setVisible(false); d->remoteCoreFileName->setVisible(false);
d->selectRemoteCoreButton->setVisible(false); d->selectRemoteCoreButton->setVisible(false);
if (isValid) isValid = isValid && d->localCoreFileName->isValid();
isValid = d->localCoreFileName->isValid();
} else { } else {
d->localCoreFileName->setVisible(false);
d->remoteCoreFileName->setVisible(true); d->remoteCoreFileName->setVisible(true);
d->selectRemoteCoreButton->setVisible(true); d->selectRemoteCoreButton->setVisible(true);
d->localCoreFileName->setVisible(false); isValid = isValid && !remoteCoreFile().isEmpty();
if (isValid)
isValid = !remoteCoreFile().isEmpty();
} }
d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(isValid); d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(isValid);
} }
void AttachCoreDialog::selectRemoteCoreFile() void AttachCoreDialog::selectRemoteCoreFile()
{ {
changed(); changed();
QTC_ASSERT(!isLocal(), return); QTC_ASSERT(!isLocalKit(), return);
SelectRemoteFileDialog dlg(this); SelectRemoteFileDialog dlg(this);
dlg.setWindowTitle(tr("Select Remote Core File")); dlg.setWindowTitle(tr("Select Remote Core File"));
dlg.attachToDevice(d->kitChooser->currentKit()); dlg.attachToDevice(d->kitChooser->currentKit());
@@ -387,7 +402,16 @@ QString AttachCoreDialog::remoteCoreFile() const
void AttachCoreDialog::setKitId(const Core::Id &id) void AttachCoreDialog::setKitId(const Core::Id &id)
{ {
d->kitChooser->setCurrentKitId(id); d->kitChooser->setCurrentKitId(id);
changed(); }
void AttachCoreDialog::setForceLocalCoreFile(bool on)
{
d->forceLocalCheckBox->setChecked(on);
}
bool AttachCoreDialog::forcesLocalCoreFile() const
{
return d->forceLocalCheckBox->isChecked();
} }
Kit *AttachCoreDialog::kit() const Kit *AttachCoreDialog::kit() const

View File

@@ -48,11 +48,15 @@ public:
explicit AttachCoreDialog(QWidget *parent); explicit AttachCoreDialog(QWidget *parent);
~AttachCoreDialog(); ~AttachCoreDialog();
int exec();
QString localExecutableFile() const; QString localExecutableFile() const;
QString localCoreFile() const; QString localCoreFile() const;
QString remoteCoreFile() const; QString remoteCoreFile() const;
QString overrideStartScript() const; QString overrideStartScript() const;
bool isLocal() const; bool useLocalCoreFile() const;
bool forcesLocalCoreFile() const;
bool isLocalKit() const;
// For persistance. // For persistance.
ProjectExplorer::Kit *kit() const; ProjectExplorer::Kit *kit() const;
@@ -61,6 +65,7 @@ public:
void setRemoteCoreFile(const QString &core); void setRemoteCoreFile(const QString &core);
void setOverrideStartScript(const QString &scriptName); void setOverrideStartScript(const QString &scriptName);
void setKitId(const Core::Id &id); void setKitId(const Core::Id &id);
void setForceLocalCoreFile(bool on);
private slots: private slots:
void changed(); void changed();