Commit 6a6c5e5a authored by hjk's avatar hjk
Browse files

debugger: port 'Attach to Core' over to new Profile architecture



Change-Id: I89e743314025fe715982b4c43849ce128e014f55
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent b7d926c3
......@@ -70,20 +70,10 @@
<item row="2" column="1">
<widget class="Debugger::Internal::DebuggerToolChainComboBox" name="toolchainComboBox"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="sysrootLabel">
<property name="text">
<string>Sys&amp;root:</string>
</property>
<property name="buddy">
<cstring>sysrootPathChooser</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="Utils::PathChooser" name="sysrootPathChooser" native="true"/>
<widget class="Utils::PathChooser" name="overrideStartScriptFileName" native="true"/>
</item>
<item row="4" column="0">
<item row="3" column="0">
<widget class="QLabel" name="overrideStartScriptLabel">
<property name="text">
<string>Override &amp;start script:</string>
......@@ -93,9 +83,6 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="Utils::PathChooser" name="overrideStartScriptFileName" native="true"/>
</item>
</layout>
</item>
<item>
......
......@@ -34,6 +34,7 @@
#include "debuggerstartparameters.h"
#include "debuggerconstants.h"
#include "debuggerprofileinformation.h"
#include "debuggerstringutils.h"
#include "cdb/cdbengine.h"
#include "shared/hostutils.h"
......@@ -47,6 +48,7 @@
#include <coreplugin/icore.h>
#include <projectexplorer/abi.h>
#include <projectexplorer/profileinformation.h>
#include <utils/historycompleter.h>
#include <utils/qtcassert.h>
#include <utils/synchronousprocess.h>
......@@ -68,6 +70,7 @@
#include <QStandardItemModel>
#include <QGridLayout>
using namespace ProjectExplorer;
using namespace Utils;
namespace Debugger {
......@@ -191,9 +194,6 @@ AttachCoreDialog::AttachCoreDialog(QWidget *parent)
m_ui->coreFileName->setExpectedKind(PathChooser::File);
m_ui->coreFileName->setPromptDialogTitle(tr("Select Core File"));
m_ui->sysrootPathChooser->setExpectedKind(PathChooser::Directory);
m_ui->sysrootPathChooser->setPromptDialogTitle(tr("Select Sysroot"));
m_ui->overrideStartScriptFileName->setExpectedKind(PathChooser::File);
m_ui->overrideStartScriptFileName->setPromptDialogTitle(tr("Select Startup Script"));
......@@ -232,37 +232,22 @@ void AttachCoreDialog::setCoreFile(const QString &fileName)
changed();
}
ProjectExplorer::Abi AttachCoreDialog::abi() const
Profile *AttachCoreDialog::profile() const
{
return m_ui->toolchainComboBox->abi();
return m_ui->toolchainComboBox->profile();
}
void AttachCoreDialog::setAbiIndex(int i)
void AttachCoreDialog::setProfileIndex(int i)
{
if (i >= 0 && i < m_ui->toolchainComboBox->count())
m_ui->toolchainComboBox->setCurrentIndex(i);
}
int AttachCoreDialog::abiIndex() const
int AttachCoreDialog::profileIndex() const
{
return m_ui->toolchainComboBox->currentIndex();
}
QString AttachCoreDialog::debuggerCommand()
{
return m_ui->toolchainComboBox->debuggerCommand();
}
QString AttachCoreDialog::sysroot() const
{
return m_ui->sysrootPathChooser->path();
}
void AttachCoreDialog::setSysroot(const QString &sysroot)
{
m_ui->sysrootPathChooser->setPath(sysroot);
}
QString AttachCoreDialog::overrideStartScript() const
{
return m_ui->overrideStartScriptFileName->path();
......@@ -394,27 +379,22 @@ QString AttachExternalDialog::executable() const
return m_model->executableForPid(attachPIDText());
}
ProjectExplorer::Abi AttachExternalDialog::abi() const
Profile *AttachExternalDialog::profile() const
{
return m_ui->toolchainComboBox->abi();
return m_ui->toolchainComboBox->profile();
}
void AttachExternalDialog::setAbiIndex(int i)
void AttachExternalDialog::setProfileIndex(int i)
{
if (i >= 0 && i < m_ui->toolchainComboBox->count())
m_ui->toolchainComboBox->setCurrentIndex(i);
}
int AttachExternalDialog::abiIndex() const
int AttachExternalDialog::profileIndex() const
{
return m_ui->toolchainComboBox->currentIndex();
}
QString AttachExternalDialog::debuggerCommand()
{
return m_ui->toolchainComboBox->debuggerCommand();
}
void AttachExternalDialog::pidChanged(const QString &pid)
{
const bool enabled = !pid.isEmpty() && pid != QLatin1String("0") && pid != m_selfPid
......@@ -607,14 +587,9 @@ QString StartExternalDialog::executableFile() const
return m_ui->execFile->path();
}
ProjectExplorer::Abi StartExternalDialog::abi() const
{
return m_ui->toolChainComboBox->abi();
}
QString StartExternalDialog::debuggerCommand()
Profile *StartExternalDialog::profile() const
{
return m_ui->toolChainComboBox->debuggerCommand();
return m_ui->toolChainComboBox->profile();
}
bool StartExternalDialog::isValid() const
......@@ -695,10 +670,15 @@ bool StartExternalDialog::run(QWidget *parent,
writeParameterHistory(history, settings, settingsGroup, arrayName);
}
Profile *profile = dialog.profile();
QTC_ASSERT(profile, return false);
ToolChain *tc = ToolChainProfileInformation::toolChain(profile);
QTC_ASSERT(tc, return false);
sp->executable = newParameters.executableFile;
sp->startMode = StartExternal;
sp->toolChainAbi = dialog.abi();
sp->debuggerCommand = dialog.debuggerCommand();
sp->toolChainAbi = tc->targetAbi();
sp->debuggerCommand = DebuggerProfileInformation::debuggerCommand(profile).toString();
sp->workingDirectory = newParameters.workingDirectory;
sp->displayName = sp->executable;
sp->useTerminal = newParameters.runInTerminal;
......@@ -707,10 +687,10 @@ bool StartExternalDialog::run(QWidget *parent,
// Fixme: 1 of 3 testing hacks.
if (sp->processArgs.startsWith(QLatin1String("@tcf@ ")) || sp->processArgs.startsWith(QLatin1String("@sym@ ")))
// Set up an ARM Symbian Abi
sp->toolChainAbi = ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture,
ProjectExplorer::Abi::SymbianOS,
ProjectExplorer::Abi::SymbianDeviceFlavor,
ProjectExplorer::Abi::ElfFormat, false);
sp->toolChainAbi = Abi(Abi::ArmArchitecture,
Abi::SymbianOS,
Abi::SymbianDeviceFlavor,
Abi::ElfFormat, false);
sp->breakOnMain = newParameters.breakAtMain;
return true;
......@@ -870,12 +850,17 @@ bool StartRemoteDialog::run(QWidget *parent,
writeParameterHistory(history, settings, settingsGroup, arrayName);
}
Profile *profile = dialog.profile();
QTC_ASSERT(profile, return false);
ToolChain *tc = ToolChainProfileInformation::toolChain(profile);
QTC_ASSERT(tc, return false);
sp->remoteChannel = newParameters.remoteChannel;
sp->remoteArchitecture = newParameters.remoteArchitecture;
sp->executable = newParameters.localExecutable;
sp->displayName = tr("Remote: \"%1\"").arg(sp->remoteChannel);
sp->debuggerCommand = dialog.debuggerCommand();
sp->toolChainAbi = dialog.abi();
sp->debuggerCommand = DebuggerProfileInformation::debuggerCommand(profile).toString();
sp->toolChainAbi = tc->targetAbi();
sp->overrideStartScript = newParameters.overrideStartScript;
sp->useServerStartScript = newParameters.useServerStartScript;
sp->serverStartScript = newParameters.serverStartScript;
......@@ -933,14 +918,9 @@ void StartRemoteDialog::historyIndexChanged(int index)
setParameters(v.value<StartRemoteParameters>());
}
ProjectExplorer::Abi StartRemoteDialog::abi() const
{
return m_ui->toolchainComboBox->abi();
}
QString StartRemoteDialog::debuggerCommand() const
Profile *StartRemoteDialog::profile() const
{
return m_ui->toolchainComboBox->debuggerCommand();
return m_ui->toolchainComboBox->profile();
}
void StartRemoteDialog::setRemoteArchitectures(const QStringList &list)
......
......@@ -33,10 +33,9 @@
#ifndef DEBUGGER_DIALOGS_H
#define DEBUGGER_DIALOGS_H
#include <QDialog>
#include <QHash>
#include <QStringList>
#include <QDialog>
#include <QVBoxLayout>
QT_BEGIN_NAMESPACE
class QModelIndex;
......@@ -46,7 +45,7 @@ class QDialogButtonBox;
class QSettings;
QT_END_NAMESPACE
namespace ProjectExplorer { class Abi; }
namespace ProjectExplorer { class Profile; }
namespace Debugger {
class DebuggerStartParameters;
......@@ -80,13 +79,9 @@ public:
QString executableFile() const;
QString coreFile() const;
int abiIndex() const;
void setAbiIndex(int);
ProjectExplorer::Abi abi() const;
QString debuggerCommand();
QString sysroot() const;
void setSysroot(const QString &sysroot);
int profileIndex() const;
void setProfileIndex(int);
ProjectExplorer::Profile *profile() const;
QString overrideStartScript() const;
void setOverrideStartScript(const QString &scriptName);
......@@ -111,12 +106,11 @@ public:
qint64 attachPID() const;
QString executable() const;
int abiIndex() const;
void setAbiIndex(int);
ProjectExplorer::Abi abi() const;
QString debuggerCommand();
int profileIndex() const;
void setProfileIndex(int);
ProjectExplorer::Profile *profile() const;
virtual void accept();
void accept();
private slots:
void rebuildProcessList();
......@@ -156,9 +150,7 @@ private:
QString executableFile() const;
void setExecutableFile(const QString &executable);
ProjectExplorer::Abi abi() const;
QString debuggerCommand();
ProjectExplorer::Profile *profile() const;
bool isValid() const;
Ui::StartExternalDialog *m_ui;
......@@ -186,8 +178,7 @@ private:
void setRemoteArchitectures(const QStringList &list);
ProjectExplorer::Abi abi() const;
QString debuggerCommand() const;
ProjectExplorer::Profile *profile() const;
Ui::StartRemoteDialog *m_ui;
};
......@@ -224,12 +215,12 @@ public:
QString connection() const;
void setConnection(const QString &);
virtual void accept();
private slots:
void textChanged(const QString &);
private:
void accept();
QPushButton *m_okButton;
QLineEdit *m_lineEdit;
};
......@@ -243,12 +234,12 @@ public:
void setAddress(quint64 a);
quint64 address() const;
virtual void accept();
private slots:
void textChanged();
private:
void accept();
void setOkButtonEnabled(bool v);
bool isOkButtonEnabled() const;
......
......@@ -1534,7 +1534,7 @@ void DebuggerPluginPrivate::startExternalApplication()
void DebuggerPluginPrivate::attachExternalApplication()
{
AttachExternalDialog dlg(mainWindow());
dlg.setAbiIndex(configValue(_("LastAttachExternalAbiIndex")).toInt());
dlg.setProfileIndex(configValue(_("LastAttachExternalProfileIndex")).toInt());
if (dlg.exec() != QDialog::Accepted)
return;
......@@ -1545,7 +1545,12 @@ void DebuggerPluginPrivate::attachExternalApplication()
return;
}
setConfigValue(_("LastAttachExternalAbiIndex"), QVariant(dlg.abiIndex()));
setConfigValue(_("LastAttachExternalProfileIndex"), QVariant(dlg.profileIndex()));
Profile *profile = dlg.profile();
QTC_ASSERT(profile, return);
ToolChain *tc = ToolChainProfileInformation::toolChain(profile);
QTC_ASSERT(tc, return);
DebuggerStartParameters sp;
sp.attachPID = dlg.attachPID();
......@@ -1553,8 +1558,8 @@ void DebuggerPluginPrivate::attachExternalApplication()
sp.executable = dlg.executable();
sp.startMode = AttachExternal;
sp.closeMode = DetachAtClose;
sp.toolChainAbi = dlg.abi();
sp.debuggerCommand = dlg.debuggerCommand();
sp.toolChainAbi = tc->targetAbi();
sp.debuggerCommand = DebuggerProfileInformation::debuggerCommand(profile).toString();
if (DebuggerRunControl *rc = createDebugger(sp))
startDebugger(rc);
}
......@@ -1576,8 +1581,7 @@ void DebuggerPluginPrivate::attachCore()
AttachCoreDialog dlg(mainWindow());
dlg.setExecutableFile(configValue(_("LastExternalExecutableFile")).toString());
dlg.setCoreFile(configValue(_("LastExternalCoreFile")).toString());
dlg.setAbiIndex(configValue(_("LastExternalAbiIndex")).toInt());
dlg.setSysroot(configValue(_("LastSysroot")).toString());
dlg.setProfileIndex(configValue(_("LastExternalProfileIndex")).toInt());
dlg.setOverrideStartScript(configValue(_("LastExternalStartScript")).toString());
if (dlg.exec() != QDialog::Accepted)
......@@ -1585,19 +1589,23 @@ void DebuggerPluginPrivate::attachCore()
setConfigValue(_("LastExternalExecutableFile"), dlg.executableFile());
setConfigValue(_("LastExternalCoreFile"), dlg.coreFile());
setConfigValue(_("LastExternalAbiIndex"), QVariant(dlg.abiIndex()));
setConfigValue(_("LastSysroot"), dlg.sysroot());
setConfigValue(_("LastExternalProfileIndex"), QVariant(dlg.profileIndex()));
setConfigValue(_("LastExternalStartScript"), dlg.overrideStartScript());
Profile *profile = dlg.profile();
QTC_ASSERT(profile, return);
ToolChain *tc = ToolChainProfileInformation::toolChain(profile);
QTC_ASSERT(tc, return);
DebuggerStartParameters sp;
sp.executable = dlg.executableFile();
sp.coreFile = dlg.coreFile();
sp.displayName = tr("Core file \"%1\"").arg(dlg.coreFile());
sp.startMode = AttachCore;
sp.closeMode = DetachAtClose;
sp.debuggerCommand = dlg.debuggerCommand();
sp.toolChainAbi = dlg.abi();
sp.sysroot = dlg.sysroot();
sp.debuggerCommand = DebuggerProfileInformation::debuggerCommand(profile).toString();
sp.toolChainAbi = tc->targetAbi();
sp.sysroot = SysRootProfileInformation::sysRoot(profile).toString();
sp.overrideStartScript = dlg.overrideStartScript();
if (DebuggerRunControl *rc = createDebugger(sp))
startDebugger(rc);
......
......@@ -46,10 +46,6 @@
using namespace ProjectExplorer;
typedef QPair<Abi, QString> AbiDebuggerCommandPair;
Q_DECLARE_METATYPE(AbiDebuggerCommandPair)
namespace Debugger {
namespace Internal {
......@@ -75,77 +71,50 @@ void DebuggerToolChainComboBox::init(bool hostAbiOnly)
if (debuggerCommand.isEmpty())
continue;
const AbiDebuggerCommandPair data(abi, debuggerCommand);
const QString completeBase = QFileInfo(debuggerCommand).completeBaseName();
const QString name = tr("%1 (%2)").arg(st->displayName(), completeBase);
addItem(name, qVariantFromValue(data));
addItem(name, qVariantFromValue(st->id()));
QString debugger = QDir::toNativeSeparators(debuggerCommand);
debugger.replace(QString(QLatin1Char(' ')), QLatin1String("&nbsp;"));
QString toolTip = tr("<html><head/><body><table>"
"<tr><td>ABI:</td><td><i>%1</i></td></tr>"
"<tr><td>Debugger:</td><td>%2</td></tr>")
.arg(st->displayName(), QDir::toNativeSeparators(debugger));
setItemData(count() - 1, toolTip, Qt::ToolTipRole);
}
setEnabled(count() > 1);
}
void DebuggerToolChainComboBox::setAbi(const Abi &abi)
void DebuggerToolChainComboBox::setProfile(const Profile *profile)
{
QTC_ASSERT(abi.isValid(), return);
QTC_ASSERT(profile->isValid(), return);
const int c = count();
for (int i = 0; i < c; i++) {
if (abiAt(i) == abi) {
if (profileAt(i) == profile) {
setCurrentIndex(i);
break;
}
}
}
Abi DebuggerToolChainComboBox::abi() const
Profile *DebuggerToolChainComboBox::profile() const
{
return abiAt(currentIndex());
return profileAt(currentIndex());
}
QString DebuggerToolChainComboBox::debuggerCommand() const
{
return debuggerCommandAt(currentIndex());
}
//QString DebuggerToolChainComboBox::debuggerCommand() const
//{
// int index = currentIndex();
// Core::Id id = qvariant_cast<Core::Id>(itemData(index));
// Profile *st = ProfileManager::instance()->find(id);
// QTC_ASSERT(st, return QString());
// return DebuggerProfileInformation::debuggerCommand(st).toString();
//}
QString DebuggerToolChainComboBox::debuggerCommandAt(int index) const
Profile *DebuggerToolChainComboBox::profileAt(int index) const
{
if (index >= 0 && index < count()) {
const AbiDebuggerCommandPair abiCommandPair = qvariant_cast<AbiDebuggerCommandPair>(itemData(index));
return abiCommandPair.second;
}
return QString();
}
Abi DebuggerToolChainComboBox::abiAt(int index) const
{
if (index >= 0 && index < count()) {
const AbiDebuggerCommandPair abiCommandPair = qvariant_cast<AbiDebuggerCommandPair>(itemData(index));
return abiCommandPair.first;
}
return Abi();
}
static inline QString abiToolTip(const AbiDebuggerCommandPair &abiCommandPair)
{
QString debugger = QDir::toNativeSeparators(abiCommandPair.second);
debugger.replace(QString(QLatin1Char(' ')), QLatin1String("&nbsp;"));
return DebuggerToolChainComboBox::tr(
"<html><head/><body><table><tr><td>ABI:</td><td><i>%1</i></td></tr>"
"<tr><td>Debugger:</td><td>%2</td></tr>").
arg(abiCommandPair.first.toString(),
QDir::toNativeSeparators(debugger));
}
bool DebuggerToolChainComboBox::event(QEvent *event)
{
if (event->type() == QEvent::ToolTip) {
const int index = currentIndex();
if (index >= 0) {
const AbiDebuggerCommandPair abiCommandPair = qvariant_cast<AbiDebuggerCommandPair>(itemData(index));
setToolTip(abiToolTip(abiCommandPair));
} else {
setToolTip(QString());
}
}
return QComboBox::event(event);
Core::Id id = qvariant_cast<Core::Id>(itemData(index));
return ProfileManager::instance()->find(id);
}
} // namespace Debugger
......
......@@ -35,32 +35,27 @@
#include <QComboBox>
namespace ProjectExplorer {
class Abi;
}
namespace ProjectExplorer { class Profile; }
namespace Debugger {
namespace Internal {
// Let the user pick a tool chain/ABI associated with a debugger.
// Let the user pick a profile associated with a debugger.
class DebuggerToolChainComboBox : public QComboBox
{
Q_OBJECT
public:
explicit DebuggerToolChainComboBox(QWidget *parent);
void init(bool hostAbiOnly);
void setAbi(const ProjectExplorer::Abi &abi);
ProjectExplorer::Abi abi() const;
QString debuggerCommand() const;
protected:
virtual bool event(QEvent *event);
void setProfile(const ProjectExplorer::Profile *profile);
ProjectExplorer::Profile *profile() const;
//QString debuggerCommand() const;
private:
QString debuggerCommandAt(int index) const;
ProjectExplorer::Abi abiAt(int index) const;
ProjectExplorer::Profile *profileAt(int index) const;
};
} // namespace Debugger
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment