forked from qt-creator/qt-creator
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:
@@ -1600,11 +1600,12 @@ void DebuggerPluginPrivate::attachCore()
|
||||
{
|
||||
AttachCoreDialog dlg(mainWindow());
|
||||
|
||||
dlg.setKitId(Id(configValue(_("LastExternalProfile")).toString()));
|
||||
dlg.setKitId(Id(configValue(_("LastExternalKit")).toString()));
|
||||
dlg.setLocalExecutableFile(configValue(_("LastExternalExecutableFile")).toString());
|
||||
dlg.setLocalCoreFile(configValue(_("LastLocalCoreFile")).toString());
|
||||
dlg.setRemoteCoreFile(configValue(_("LastRemoteCoreFile")).toString());
|
||||
dlg.setOverrideStartScript(configValue(_("LastExternalStartScript")).toString());
|
||||
dlg.setForceLocalCoreFile(configValue(_("LastForceLocalCoreFile")).toBool());
|
||||
|
||||
if (dlg.exec() != QDialog::Accepted)
|
||||
return;
|
||||
@@ -1612,11 +1613,12 @@ void DebuggerPluginPrivate::attachCore()
|
||||
setConfigValue(_("LastExternalExecutableFile"), dlg.localExecutableFile());
|
||||
setConfigValue(_("LastLocalCoreFile"), dlg.localCoreFile());
|
||||
setConfigValue(_("LastRemoteCoreFile"), dlg.remoteCoreFile());
|
||||
setConfigValue(_("LastExternalProfile"), dlg.kit()->id().toString());
|
||||
setConfigValue(_("LastExternalKit"), dlg.kit()->id().toString());
|
||||
setConfigValue(_("LastExternalStartScript"), dlg.overrideStartScript());
|
||||
setConfigValue(_("LastForceLocalCoreFile"), dlg.forcesLocalCoreFile());
|
||||
|
||||
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);
|
||||
sp.masterEngineType = GdbEngineType;
|
||||
sp.executable = dlg.localExecutableFile();
|
||||
|
@@ -46,6 +46,7 @@
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
@@ -60,6 +61,7 @@
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QHeaderView>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
@@ -224,8 +226,8 @@ class AttachCoreDialogPrivate
|
||||
public:
|
||||
KitChooser *kitChooser;
|
||||
|
||||
QSettings *settings;
|
||||
|
||||
QCheckBox *forceLocalCheckBox;
|
||||
QLabel *forceLocalLabel;
|
||||
PathChooser *localExecFileName;
|
||||
PathChooser *localCoreFileName;
|
||||
QLineEdit *remoteCoreFileName;
|
||||
@@ -242,14 +244,16 @@ AttachCoreDialog::AttachCoreDialog(QWidget *parent)
|
||||
setWindowTitle(tr("Load Core File"));
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
d->settings = ICore::settings();
|
||||
|
||||
d->kitChooser = new DebuggerKitChooser(DebuggerKitChooser::RemoteDebugging, this);
|
||||
d->kitChooser->populate();
|
||||
|
||||
d->selectRemoteCoreButton = new QPushButton(tr("Browse..."), 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->setExpectedKind(PathChooser::File);
|
||||
@@ -279,6 +283,7 @@ AttachCoreDialog::AttachCoreDialog(QWidget *parent)
|
||||
formLayout->setVerticalSpacing(6);
|
||||
formLayout->addRow(tr("Kit:"), d->kitChooser);
|
||||
formLayout->addRow(tr("&Executable:"), d->localExecFileName);
|
||||
formLayout->addRow(d->forceLocalLabel, d->forceLocalCheckBox);
|
||||
formLayout->addRow(tr("Core file:"), coreLayout);
|
||||
formLayout->addRow(tr("Override &start script:"), d->overrideStartScriptFileName);
|
||||
|
||||
@@ -293,14 +298,6 @@ AttachCoreDialog::AttachCoreDialog(QWidget *parent)
|
||||
vboxLayout->addStretch();
|
||||
vboxLayout->addWidget(line);
|
||||
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()
|
||||
@@ -308,42 +305,60 @@ AttachCoreDialog::~AttachCoreDialog()
|
||||
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();
|
||||
QTC_ASSERT(k, return false);
|
||||
IDevice::ConstPtr device = DeviceKitInformation::device(k);
|
||||
QTC_ASSERT(device, return false);
|
||||
SshConnectionParameters sshParams = device->sshParameters();
|
||||
d->settings->setValue(QLatin1String("LastProfile"),
|
||||
d->kitChooser->currentKitId().toString());
|
||||
return sshParams.host.isEmpty();
|
||||
return device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
|
||||
}
|
||||
|
||||
bool AttachCoreDialog::useLocalCoreFile() const
|
||||
{
|
||||
return isLocalKit() || d->forceLocalCheckBox->isChecked();
|
||||
}
|
||||
|
||||
void AttachCoreDialog::changed()
|
||||
{
|
||||
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->remoteCoreFileName->setVisible(false);
|
||||
d->selectRemoteCoreButton->setVisible(false);
|
||||
if (isValid)
|
||||
isValid = d->localCoreFileName->isValid();
|
||||
isValid = isValid && d->localCoreFileName->isValid();
|
||||
} else {
|
||||
d->localCoreFileName->setVisible(false);
|
||||
d->remoteCoreFileName->setVisible(true);
|
||||
d->selectRemoteCoreButton->setVisible(true);
|
||||
d->localCoreFileName->setVisible(false);
|
||||
if (isValid)
|
||||
isValid = !remoteCoreFile().isEmpty();
|
||||
isValid = isValid && !remoteCoreFile().isEmpty();
|
||||
}
|
||||
|
||||
d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(isValid);
|
||||
}
|
||||
|
||||
void AttachCoreDialog::selectRemoteCoreFile()
|
||||
{
|
||||
changed();
|
||||
QTC_ASSERT(!isLocal(), return);
|
||||
QTC_ASSERT(!isLocalKit(), return);
|
||||
SelectRemoteFileDialog dlg(this);
|
||||
dlg.setWindowTitle(tr("Select Remote Core File"));
|
||||
dlg.attachToDevice(d->kitChooser->currentKit());
|
||||
@@ -387,7 +402,16 @@ QString AttachCoreDialog::remoteCoreFile() const
|
||||
void AttachCoreDialog::setKitId(const Core::Id &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
|
||||
|
@@ -48,11 +48,15 @@ public:
|
||||
explicit AttachCoreDialog(QWidget *parent);
|
||||
~AttachCoreDialog();
|
||||
|
||||
int exec();
|
||||
|
||||
QString localExecutableFile() const;
|
||||
QString localCoreFile() const;
|
||||
QString remoteCoreFile() const;
|
||||
QString overrideStartScript() const;
|
||||
bool isLocal() const;
|
||||
bool useLocalCoreFile() const;
|
||||
bool forcesLocalCoreFile() const;
|
||||
bool isLocalKit() const;
|
||||
|
||||
// For persistance.
|
||||
ProjectExplorer::Kit *kit() const;
|
||||
@@ -61,6 +65,7 @@ public:
|
||||
void setRemoteCoreFile(const QString &core);
|
||||
void setOverrideStartScript(const QString &scriptName);
|
||||
void setKitId(const Core::Id &id);
|
||||
void setForceLocalCoreFile(bool on);
|
||||
|
||||
private slots:
|
||||
void changed();
|
||||
|
Reference in New Issue
Block a user