From 6a6c5e5af53288a91657b4d040d9bb8a4aa70d26 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 26 Jun 2012 15:25:49 +0200 Subject: [PATCH] debugger: port 'Attach to Core' over to new Profile architecture Change-Id: I89e743314025fe715982b4c43849ce128e014f55 Reviewed-by: hjk --- src/plugins/debugger/attachcoredialog.ui | 17 +--- src/plugins/debugger/debuggerdialogs.cpp | 86 +++++++------------ src/plugins/debugger/debuggerdialogs.h | 39 ++++----- src/plugins/debugger/debuggerplugin.cpp | 30 ++++--- .../debugger/debuggertoolchaincombobox.cpp | 79 ++++++----------- .../debugger/debuggertoolchaincombobox.h | 19 ++-- 6 files changed, 100 insertions(+), 170 deletions(-) diff --git a/src/plugins/debugger/attachcoredialog.ui b/src/plugins/debugger/attachcoredialog.ui index 680a603d3ba..1eab1b5dea6 100644 --- a/src/plugins/debugger/attachcoredialog.ui +++ b/src/plugins/debugger/attachcoredialog.ui @@ -70,20 +70,10 @@ - - - - Sys&root: - - - sysrootPathChooser - - - - + - + Override &start script: @@ -93,9 +83,6 @@ - - - diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp index 2e86f8dcad8..0f47f9166d1 100644 --- a/src/plugins/debugger/debuggerdialogs.cpp +++ b/src/plugins/debugger/debuggerdialogs.cpp @@ -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 #include +#include #include #include #include @@ -68,6 +70,7 @@ #include #include +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 +Profile *StartExternalDialog::profile() const { - return m_ui->toolChainComboBox->abi(); -} - -QString StartExternalDialog::debuggerCommand() -{ - 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()); } -ProjectExplorer::Abi StartRemoteDialog::abi() const +Profile *StartRemoteDialog::profile() const { - return m_ui->toolchainComboBox->abi(); -} - -QString StartRemoteDialog::debuggerCommand() const -{ - return m_ui->toolchainComboBox->debuggerCommand(); + return m_ui->toolchainComboBox->profile(); } void StartRemoteDialog::setRemoteArchitectures(const QStringList &list) diff --git a/src/plugins/debugger/debuggerdialogs.h b/src/plugins/debugger/debuggerdialogs.h index 1243c685b44..69b20832aa6 100644 --- a/src/plugins/debugger/debuggerdialogs.h +++ b/src/plugins/debugger/debuggerdialogs.h @@ -33,10 +33,9 @@ #ifndef DEBUGGER_DIALOGS_H #define DEBUGGER_DIALOGS_H +#include #include #include -#include -#include 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; diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index fecdfa25e7e..8a11ecefb21 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -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); diff --git a/src/plugins/debugger/debuggertoolchaincombobox.cpp b/src/plugins/debugger/debuggertoolchaincombobox.cpp index 31b3beb04a4..5e552b98774 100644 --- a/src/plugins/debugger/debuggertoolchaincombobox.cpp +++ b/src/plugins/debugger/debuggertoolchaincombobox.cpp @@ -46,10 +46,6 @@ using namespace ProjectExplorer; -typedef QPair 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(" ")); + QString toolTip = 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(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(itemData(index)); - return abiCommandPair.second; - } - return QString(); -} - -Abi DebuggerToolChainComboBox::abiAt(int index) const -{ - if (index >= 0 && index < count()) { - const AbiDebuggerCommandPair abiCommandPair = qvariant_cast(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(" ")); - return DebuggerToolChainComboBox::tr( - "
ABI:%1
Debugger:%2
" - ""). - 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(itemData(index)); - setToolTip(abiToolTip(abiCommandPair)); - } else { - setToolTip(QString()); - } - } - return QComboBox::event(event); + Core::Id id = qvariant_cast(itemData(index)); + return ProfileManager::instance()->find(id); } } // namespace Debugger diff --git a/src/plugins/debugger/debuggertoolchaincombobox.h b/src/plugins/debugger/debuggertoolchaincombobox.h index 6501dedd2ac..4dbd05dc012 100644 --- a/src/plugins/debugger/debuggertoolchaincombobox.h +++ b/src/plugins/debugger/debuggertoolchaincombobox.h @@ -35,32 +35,27 @@ #include -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
ABI:%1
Debugger:%2