forked from qt-creator/qt-creator
ProjectExplorer: Introduce per-kit debugger configuration page
Change-Id: I65c76f3ff43e1479075926c7e3fa460cca74d8fe Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -786,10 +786,8 @@ void AndroidConfigurations::updateAutomaticKitList()
|
|||||||
ToolChainKitInformation::setToolChain(newKit, tc);
|
ToolChainKitInformation::setToolChain(newKit, tc);
|
||||||
QtSupport::QtKitInformation::setQtVersion(newKit, qt);
|
QtSupport::QtKitInformation::setQtVersion(newKit, qt);
|
||||||
DeviceKitInformation::setDevice(newKit, device);
|
DeviceKitInformation::setDevice(newKit, device);
|
||||||
Debugger::DebuggerKitInformation::DebuggerItem item;
|
Debugger::DebuggerKitInformation::setDebuggerItem(newKit,
|
||||||
item.engineType = Debugger::GdbEngineType;
|
Debugger::GdbEngineType, tc->suggestedDebugger());
|
||||||
item.binary = tc->suggestedDebugger();
|
|
||||||
Debugger::DebuggerKitInformation::setDebuggerItem(newKit, item);
|
|
||||||
AndroidGdbServerKitInformation::setGdbSever(newKit, tc->suggestedGdbServer());
|
AndroidGdbServerKitInformation::setGdbSever(newKit, tc->suggestedGdbServer());
|
||||||
newKit->makeSticky();
|
newKit->makeSticky();
|
||||||
newKits << newKit;
|
newKits << newKit;
|
||||||
|
@@ -121,7 +121,7 @@ bool DebuggerKitChooser::kitMatches(const ProjectExplorer::Kit *k) const
|
|||||||
|
|
||||||
QString DebuggerKitChooser::kitToolTip(Kit *k) const
|
QString DebuggerKitChooser::kitToolTip(Kit *k) const
|
||||||
{
|
{
|
||||||
return DebuggerKitInformation::userOutput(DebuggerKitInformation::debuggerItem(k));
|
return DebuggerKitInformation::debuggerItem(k).userOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -30,29 +30,91 @@
|
|||||||
#ifndef DEBUGGER_DEBUGGERKITCONFIGWIDGET_H
|
#ifndef DEBUGGER_DEBUGGERKITCONFIGWIDGET_H
|
||||||
#define DEBUGGER_DEBUGGERKITCONFIGWIDGET_H
|
#define DEBUGGER_DEBUGGERKITCONFIGWIDGET_H
|
||||||
|
|
||||||
#include <projectexplorer/kitconfigwidget.h>
|
|
||||||
|
|
||||||
#include "debuggerkitinformation.h"
|
#include "debuggerkitinformation.h"
|
||||||
|
|
||||||
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
#include <projectexplorer/kitconfigwidget.h>
|
||||||
|
#include <projectexplorer/abi.h>
|
||||||
|
#include <utils/detailswidget.h>
|
||||||
|
#include <utils/fileutils.h>
|
||||||
|
#include <utils/pathchooser.h>
|
||||||
|
#include <utils/persistentsettings.h>
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QStandardItemModel>
|
||||||
|
#include <QTreeView>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QLabel;
|
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
|
class QLabel;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace ProjectExplorer { class Kit; }
|
|
||||||
namespace Utils {
|
|
||||||
class PathChooser;
|
|
||||||
class FileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
class DebuggerItemConfigWidget;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
// DebuggerKitConfigWidget:
|
// DebuggerItemManager
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
class DebuggerItemManager : public QStandardItemModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
DebuggerItemManager(QObject *parent);
|
||||||
|
~DebuggerItemManager();
|
||||||
|
|
||||||
|
QList<DebuggerItem *> debuggers() const { return m_debuggers; }
|
||||||
|
QList<DebuggerItem *> findDebuggers(const ProjectExplorer::Abi &abi) const;
|
||||||
|
DebuggerItem *currentDebugger() const { return m_currentDebugger; }
|
||||||
|
static DebuggerItem *debuggerFromId(const QVariant &id);
|
||||||
|
QModelIndex currentIndex() const;
|
||||||
|
void setCurrentIndex(const QModelIndex &index);
|
||||||
|
|
||||||
|
bool isLoaded() const;
|
||||||
|
void updateCurrentItem();
|
||||||
|
// Returns id.
|
||||||
|
QVariant defaultDebugger(ProjectExplorer::ToolChain *tc);
|
||||||
|
// Adds item unless present. Return id of a matching item.
|
||||||
|
QVariant maybeAddDebugger(const DebuggerItem &item, bool makeCurrent = true);
|
||||||
|
static void restoreDebuggers();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void saveDebuggers();
|
||||||
|
void autoDetectDebuggers();
|
||||||
|
void addDebugger();
|
||||||
|
void cloneDebugger();
|
||||||
|
void removeDebugger();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void debuggerAdded(DebuggerItem *item);
|
||||||
|
void debuggerRemoved(DebuggerItem *item);
|
||||||
|
void debuggerUpdated(DebuggerItem *item);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class DebuggerOptionsPage;
|
||||||
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||||
|
|
||||||
|
void autoDetectCdbDebugger();
|
||||||
|
|
||||||
|
QMap<QString, Utils::FileName> m_abiToDebugger;
|
||||||
|
Utils::PersistentSettingsWriter *m_writer;
|
||||||
|
QList<DebuggerItem *> m_debuggers;
|
||||||
|
DebuggerItem *m_currentDebugger;
|
||||||
|
|
||||||
|
QStandardItem *m_autoRoot;
|
||||||
|
QStandardItem *m_manualRoot;
|
||||||
|
QStringList added;
|
||||||
|
QStringList removed;
|
||||||
|
QHash<DebuggerItem *, QStandardItem *> m_itemFromDebugger;
|
||||||
|
QHash<QStandardItem *, DebuggerItem *> m_debuggerFromItem;
|
||||||
|
};
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
// DebuggerKitConfigWidget
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
class DebuggerKitConfigWidget : public ProjectExplorer::KitConfigWidget
|
class DebuggerKitConfigWidget : public ProjectExplorer::KitConfigWidget
|
||||||
@@ -64,48 +126,63 @@ public:
|
|||||||
|
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
QString toolTip() const;
|
QString toolTip() const;
|
||||||
|
|
||||||
void makeReadOnly();
|
void makeReadOnly();
|
||||||
|
|
||||||
void refresh();
|
void refresh();
|
||||||
|
|
||||||
QWidget *buttonWidget() const;
|
QWidget *buttonWidget() const;
|
||||||
QWidget *mainWidget() const;
|
QWidget *mainWidget() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void autoDetectDebugger();
|
void manageDebuggers();
|
||||||
void showDialog();
|
void currentDebuggerChanged(int idx);
|
||||||
|
void onDebuggerAdded(DebuggerItem *);
|
||||||
|
void onDebuggerUpdated(DebuggerItem *);
|
||||||
|
void onDebuggerRemoved(DebuggerItem *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *m_main;
|
int indexOf(const DebuggerItem *debugger);
|
||||||
QLabel *m_label;
|
QVariant currentId() const;
|
||||||
QPushButton *m_autoDetectButton;
|
void updateComboBox(const QVariant &id);
|
||||||
QPushButton *m_editButton;
|
|
||||||
|
bool m_isReadOnly;
|
||||||
|
QComboBox *m_comboBox;
|
||||||
|
QPushButton *m_manageButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DebuggerKitConfigDialog : public QDialog
|
// --------------------------------------------------------------------------
|
||||||
|
// DebuggerOptionsPage
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class DebuggerOptionsPage : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
|
||||||
explicit DebuggerKitConfigDialog(QWidget *parent = 0);
|
|
||||||
|
|
||||||
void setDebuggerItem(const DebuggerKitInformation::DebuggerItem &item);
|
public:
|
||||||
DebuggerKitInformation::DebuggerItem item() const
|
DebuggerOptionsPage();
|
||||||
{ return DebuggerKitInformation::DebuggerItem(engineType(), fileName()); }
|
|
||||||
|
QWidget *createPage(QWidget *parent);
|
||||||
|
void apply();
|
||||||
|
void finish();
|
||||||
|
bool matches(const QString &) const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void refreshLabel();
|
void debuggerSelectionChanged();
|
||||||
|
void debuggerModelChanged();
|
||||||
|
void updateState();
|
||||||
|
void cloneDebugger();
|
||||||
|
void addDebugger();
|
||||||
|
void removeDebugger();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DebuggerEngineType engineType() const;
|
QWidget *m_configWidget;
|
||||||
void setEngineType(DebuggerEngineType et);
|
QString m_searchKeywords;
|
||||||
|
|
||||||
Utils::FileName fileName() const;
|
DebuggerItemManager *m_manager;
|
||||||
void setFileName(const Utils::FileName &fn);
|
DebuggerItemConfigWidget *m_itemConfigWidget;
|
||||||
|
QTreeView *m_debuggerView;
|
||||||
QComboBox *m_comboBox;
|
Utils::DetailsWidget *m_container;
|
||||||
QLabel *m_label;
|
QPushButton *m_addButton;
|
||||||
Utils::PathChooser *m_chooser;
|
QPushButton *m_cloneButton;
|
||||||
|
QPushButton *m_delButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -26,358 +26,3 @@
|
|||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "debuggerkitinformation.h"
|
|
||||||
|
|
||||||
#include "debuggerkitconfigwidget.h"
|
|
||||||
|
|
||||||
#include <projectexplorer/abi.h>
|
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
|
||||||
#include <projectexplorer/toolchain.h>
|
|
||||||
#include <projectexplorer/toolchainmanager.h>
|
|
||||||
|
|
||||||
#include <utils/environment.h>
|
|
||||||
#include <utils/qtcassert.h>
|
|
||||||
|
|
||||||
#include <QDir>
|
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
|
||||||
using namespace Utils;
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
// Helpers:
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
|
|
||||||
static QPair<QString, QString> autoDetectCdbDebugger()
|
|
||||||
{
|
|
||||||
QPair<QString, QString> result;
|
|
||||||
QList<FileName> cdbs;
|
|
||||||
|
|
||||||
QStringList programDirs;
|
|
||||||
programDirs.append(QString::fromLocal8Bit(qgetenv("ProgramFiles")));
|
|
||||||
programDirs.append(QString::fromLocal8Bit(qgetenv("ProgramFiles(x86)")));
|
|
||||||
programDirs.append(QString::fromLocal8Bit(qgetenv("ProgramW6432")));
|
|
||||||
|
|
||||||
foreach (const QString &dirName, programDirs) {
|
|
||||||
if (dirName.isEmpty())
|
|
||||||
continue;
|
|
||||||
QDir dir(dirName);
|
|
||||||
// Windows SDK's starting from version 8 live in
|
|
||||||
// "ProgramDir\Windows Kits\<version>"
|
|
||||||
const QString windowsKitsFolderName = QLatin1String("Windows Kits");
|
|
||||||
if (dir.exists(windowsKitsFolderName)) {
|
|
||||||
QDir windowKitsFolder = dir;
|
|
||||||
if (windowKitsFolder.cd(windowsKitsFolderName)) {
|
|
||||||
// Check in reverse order (latest first)
|
|
||||||
const QFileInfoList kitFolders =
|
|
||||||
windowKitsFolder.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot,
|
|
||||||
QDir::Time | QDir::Reversed);
|
|
||||||
foreach (const QFileInfo &kitFolderFi, kitFolders) {
|
|
||||||
const QString path = kitFolderFi.absoluteFilePath();
|
|
||||||
const QFileInfo cdb32(path + QLatin1String("/Debuggers/x86/cdb.exe"));
|
|
||||||
if (cdb32.isExecutable())
|
|
||||||
cdbs.push_back(FileName::fromString(cdb32.absoluteFilePath()));
|
|
||||||
const QFileInfo cdb64(path + QLatin1String("/Debuggers/x64/cdb.exe"));
|
|
||||||
if (cdb64.isExecutable())
|
|
||||||
cdbs.push_back(FileName::fromString(cdb64.absoluteFilePath()));
|
|
||||||
} // for Kits
|
|
||||||
} // can cd to "Windows Kits"
|
|
||||||
} // "Windows Kits" exists
|
|
||||||
|
|
||||||
// Pre Windows SDK 8: Check 'Debugging Tools for Windows'
|
|
||||||
foreach (const QFileInfo &fi, dir.entryInfoList(QStringList(QLatin1String("Debugging Tools for Windows*")),
|
|
||||||
QDir::Dirs | QDir::NoDotAndDotDot)) {
|
|
||||||
FileName filePath(fi);
|
|
||||||
filePath.appendPath(QLatin1String("cdb.exe"));
|
|
||||||
if (!cdbs.contains(filePath))
|
|
||||||
cdbs.append(filePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (const FileName &cdb, cdbs) {
|
|
||||||
QList<Abi> abis = Abi::abisOfBinary(cdb);
|
|
||||||
if (abis.isEmpty())
|
|
||||||
continue;
|
|
||||||
if (abis.first().wordWidth() == 32)
|
|
||||||
result.first = cdb.toString();
|
|
||||||
else if (abis.first().wordWidth() == 64)
|
|
||||||
result.second = cdb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// prefer 64bit debugger, even for 32bit binaries:
|
|
||||||
if (!result.second.isEmpty())
|
|
||||||
result.first = result.second;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Debugger {
|
|
||||||
|
|
||||||
static DebuggerEngineType engineTypeFromBinary(const QString &binary)
|
|
||||||
{
|
|
||||||
if (binary.contains(QLatin1String("cdb"), Qt::CaseInsensitive))
|
|
||||||
return CdbEngineType;
|
|
||||||
if (binary.contains(QLatin1String("lldb"), Qt::CaseInsensitive))
|
|
||||||
return LldbEngineType;
|
|
||||||
return GdbEngineType;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
// DebuggerKitInformation:
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
|
|
||||||
static const char DEBUGGER_INFORMATION[] = "Debugger.Information";
|
|
||||||
|
|
||||||
DebuggerKitInformation::DebuggerItem::DebuggerItem()
|
|
||||||
: engineType(NoEngineType)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
DebuggerKitInformation::DebuggerItem::DebuggerItem(DebuggerEngineType et, const Utils::FileName &fn)
|
|
||||||
: engineType(et)
|
|
||||||
, binary(fn)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
DebuggerKitInformation::DebuggerKitInformation()
|
|
||||||
{
|
|
||||||
setObjectName(QLatin1String("DebuggerKitInformation"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::Id DebuggerKitInformation::dataId() const
|
|
||||||
{
|
|
||||||
static Core::Id id = Core::Id(DEBUGGER_INFORMATION);
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int DebuggerKitInformation::priority() const
|
|
||||||
{
|
|
||||||
return 28000;
|
|
||||||
}
|
|
||||||
|
|
||||||
DebuggerKitInformation::DebuggerItem DebuggerKitInformation::autoDetectItem(const Kit *k)
|
|
||||||
{
|
|
||||||
if (DebuggerKitInformation::isValidDebugger(k))
|
|
||||||
return DebuggerKitInformation::debuggerItem(k);
|
|
||||||
|
|
||||||
DebuggerItem result;
|
|
||||||
const ToolChain *tc = ToolChainKitInformation::toolChain(k);
|
|
||||||
Abi abi = Abi::hostAbi();
|
|
||||||
if (tc)
|
|
||||||
abi = tc->targetAbi();
|
|
||||||
|
|
||||||
// CDB for windows:
|
|
||||||
if (abi.os() == Abi::WindowsOS && abi.osFlavor() != Abi::WindowsMSysFlavor) {
|
|
||||||
QPair<QString, QString> cdbs = autoDetectCdbDebugger();
|
|
||||||
result.binary = Utils::FileName::fromString(abi.wordWidth() == 32 ? cdbs.first : cdbs.second);
|
|
||||||
result.engineType = CdbEngineType;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check suggestions from the SDK.
|
|
||||||
Environment env = Environment::systemEnvironment();
|
|
||||||
if (tc) {
|
|
||||||
tc->addToEnvironment(env); // Find MinGW gdb in toolchain environment.
|
|
||||||
QString path = tc->suggestedDebugger().toString();
|
|
||||||
if (!path.isEmpty()) {
|
|
||||||
const QFileInfo fi(path);
|
|
||||||
if (!fi.isAbsolute())
|
|
||||||
path = env.searchInPath(path);
|
|
||||||
result.binary = Utils::FileName::fromString(path);
|
|
||||||
result.engineType = engineTypeFromBinary(path);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default to GDB, system GDB
|
|
||||||
result.engineType = GdbEngineType;
|
|
||||||
QString gdb;
|
|
||||||
const QString systemGdb = QLatin1String("gdb");
|
|
||||||
// MinGW: Search for the python-enabled gdb first.
|
|
||||||
if (abi.os() == Abi::WindowsOS && abi.osFlavor() == Abi::WindowsMSysFlavor)
|
|
||||||
gdb = env.searchInPath(QLatin1String("gdb-i686-pc-mingw32"));
|
|
||||||
if (gdb.isEmpty())
|
|
||||||
gdb = env.searchInPath(systemGdb);
|
|
||||||
result.binary = Utils::FileName::fromString(env.searchInPath(gdb.isEmpty() ? systemGdb : gdb));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerKitInformation::setup(Kit *k)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(ToolChainManager::instance()->isLoaded(), return);
|
|
||||||
setDebuggerItem(k, autoDetectItem(k));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the configuration errors and return a flag mask. Provide a quick check and
|
|
||||||
// a verbose one with a list of errors.
|
|
||||||
|
|
||||||
enum DebuggerConfigurationErrors {
|
|
||||||
NoDebugger = 0x1,
|
|
||||||
DebuggerNotFound = 0x2,
|
|
||||||
DebuggerNotExecutable = 0x4,
|
|
||||||
DebuggerNeedsAbsolutePath = 0x8
|
|
||||||
};
|
|
||||||
|
|
||||||
static unsigned debuggerConfigurationErrors(const ProjectExplorer::Kit *k)
|
|
||||||
{
|
|
||||||
unsigned result = 0;
|
|
||||||
const DebuggerKitInformation::DebuggerItem item = DebuggerKitInformation::debuggerItem(k);
|
|
||||||
if (item.engineType == NoEngineType || item.binary.isEmpty())
|
|
||||||
return NoDebugger;
|
|
||||||
|
|
||||||
const QFileInfo fi = item.binary.toFileInfo();
|
|
||||||
if (!fi.exists() || fi.isDir())
|
|
||||||
result |= DebuggerNotFound;
|
|
||||||
else if (!fi.isExecutable())
|
|
||||||
result |= DebuggerNotExecutable;
|
|
||||||
|
|
||||||
if (!fi.exists() || fi.isDir())
|
|
||||||
// We need an absolute path to be able to locate Python on Windows.
|
|
||||||
if (item.engineType == GdbEngineType)
|
|
||||||
if (const ToolChain *tc = ToolChainKitInformation::toolChain(k))
|
|
||||||
if (tc->targetAbi().os() == Abi::WindowsOS && !fi.isAbsolute())
|
|
||||||
result |= DebuggerNeedsAbsolutePath;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DebuggerKitInformation::isValidDebugger(const ProjectExplorer::Kit *k)
|
|
||||||
{
|
|
||||||
return debuggerConfigurationErrors(k) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<ProjectExplorer::Task> DebuggerKitInformation::validateDebugger(const ProjectExplorer::Kit *k)
|
|
||||||
{
|
|
||||||
const unsigned errors = debuggerConfigurationErrors(k);
|
|
||||||
const Core::Id id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
|
|
||||||
QList<Task> result;
|
|
||||||
if (errors & NoDebugger)
|
|
||||||
result << Task(Task::Warning, tr("No debugger set up."), FileName(), -1, id);
|
|
||||||
|
|
||||||
if (errors & DebuggerNotFound) {
|
|
||||||
const QString path = DebuggerKitInformation::debuggerCommand(k).toUserOutput();
|
|
||||||
result << Task(Task::Error, tr("Debugger '%1' not found.").arg(path),
|
|
||||||
FileName(), -1, id);
|
|
||||||
}
|
|
||||||
if (errors & DebuggerNotExecutable) {
|
|
||||||
const QString path = DebuggerKitInformation::debuggerCommand(k).toUserOutput();
|
|
||||||
result << Task(Task::Error, tr("Debugger '%1' not executable.").arg(path), FileName(), -1, id);
|
|
||||||
}
|
|
||||||
if (errors & DebuggerNeedsAbsolutePath) {
|
|
||||||
const QString path = DebuggerKitInformation::debuggerCommand(k).toUserOutput();
|
|
||||||
const QString message =
|
|
||||||
tr("The debugger location must be given as an "
|
|
||||||
"absolute path (%1).").arg(path);
|
|
||||||
result << Task(Task::Error, message, FileName(), -1, id);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
KitConfigWidget *DebuggerKitInformation::createConfigWidget(Kit *k) const
|
|
||||||
{
|
|
||||||
return new Internal::DebuggerKitConfigWidget(k, isSticky(k));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString DebuggerKitInformation::userOutput(const DebuggerItem &item)
|
|
||||||
{
|
|
||||||
const QString binary = item.binary.toUserOutput();
|
|
||||||
const QString name = debuggerEngineName(item.engineType);
|
|
||||||
return binary.isEmpty() ? tr("%1 <None>").arg(name) : tr("%1 using \"%2\"").arg(name, binary);
|
|
||||||
}
|
|
||||||
|
|
||||||
KitInformation::ItemList DebuggerKitInformation::toUserOutput(const Kit *k) const
|
|
||||||
{
|
|
||||||
return ItemList() << qMakePair(tr("Debugger"), DebuggerKitInformation::userOutput(DebuggerKitInformation::debuggerItem(k)));
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char engineTypeKeyC[] = "EngineType";
|
|
||||||
static const char binaryKeyC[] = "Binary";
|
|
||||||
|
|
||||||
DebuggerKitInformation::DebuggerItem DebuggerKitInformation::variantToItem(const QVariant &v)
|
|
||||||
{
|
|
||||||
DebuggerItem result;
|
|
||||||
if (v.isNull())
|
|
||||||
return result;
|
|
||||||
if (v.type() == QVariant::String) { // Convert legacy config items, remove later.
|
|
||||||
const QString binary = v.toString();
|
|
||||||
result.binary = Utils::FileName::fromString(binary);
|
|
||||||
result.engineType = engineTypeFromBinary(binary);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
QTC_ASSERT(v.type() == QVariant::Map, return result);
|
|
||||||
const QVariantMap vmap = v.toMap();
|
|
||||||
result.engineType = static_cast<DebuggerEngineType>(vmap.value(QLatin1String(engineTypeKeyC)).toInt());
|
|
||||||
QString binary = vmap.value(QLatin1String(binaryKeyC)).toString();
|
|
||||||
// Check for special 'auto' entry for binary written by the sdktool during
|
|
||||||
// installation. Try to autodetect.
|
|
||||||
if (binary == QLatin1String("auto")) {
|
|
||||||
binary.clear();
|
|
||||||
switch (result.engineType) {
|
|
||||||
case Debugger::GdbEngineType: // Auto-detect system gdb on Unix
|
|
||||||
if (Abi::hostAbi().os() != Abi::WindowsOS)
|
|
||||||
binary = Environment::systemEnvironment().searchInPath(QLatin1String("gdb"));
|
|
||||||
break;
|
|
||||||
case Debugger::CdbEngineType: { // Auto-detect system CDB on Windows.
|
|
||||||
const QPair<QString, QString> cdbs = autoDetectCdbDebugger();
|
|
||||||
binary = cdbs.second.isEmpty() ? cdbs.first : cdbs.second;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result.binary = Utils::FileName::fromUserInput(binary);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant DebuggerKitInformation::itemToVariant(const DebuggerItem &i)
|
|
||||||
{
|
|
||||||
QVariantMap vmap;
|
|
||||||
vmap.insert(QLatin1String(binaryKeyC), QVariant(i.binary.toString()));
|
|
||||||
vmap.insert(QLatin1String(engineTypeKeyC), QVariant(int(i.engineType)));
|
|
||||||
return QVariant(vmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
DebuggerKitInformation::DebuggerItem DebuggerKitInformation::debuggerItem(const ProjectExplorer::Kit *k)
|
|
||||||
{
|
|
||||||
return k ?
|
|
||||||
DebuggerKitInformation::variantToItem(k->value(Core::Id(DEBUGGER_INFORMATION))) :
|
|
||||||
DebuggerItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerKitInformation::setDebuggerItem(ProjectExplorer::Kit *k, const DebuggerItem &item)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(k, return);
|
|
||||||
k->setValue(Core::Id(DEBUGGER_INFORMATION), itemToVariant(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerKitInformation::setDebuggerCommand(ProjectExplorer::Kit *k, const FileName &command)
|
|
||||||
{
|
|
||||||
setDebuggerItem(k, DebuggerItem(engineType(k), command));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerKitInformation::setEngineType(ProjectExplorer::Kit *k, DebuggerEngineType type)
|
|
||||||
{
|
|
||||||
setDebuggerItem(k, DebuggerItem(type, debuggerCommand(k)));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString DebuggerKitInformation::debuggerEngineName(DebuggerEngineType t)
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case Debugger::GdbEngineType:
|
|
||||||
return tr("GDB Engine");
|
|
||||||
case Debugger::CdbEngineType:
|
|
||||||
return tr("CDB Engine");
|
|
||||||
case Debugger::LldbEngineType:
|
|
||||||
return tr("LLDB Engine");
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerKitInformation::makeSticky(Kit *k)
|
|
||||||
{
|
|
||||||
k->makeSticky(DEBUGGER_INFORMATION);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Debugger
|
|
||||||
|
@@ -33,34 +33,47 @@
|
|||||||
#include "debugger_global.h"
|
#include "debugger_global.h"
|
||||||
#include "debuggerconstants.h"
|
#include "debuggerconstants.h"
|
||||||
|
|
||||||
|
#include <projectexplorer/abi.h>
|
||||||
#include <projectexplorer/kitinformation.h>
|
#include <projectexplorer/kitinformation.h>
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
|
||||||
|
class DEBUGGER_EXPORT DebuggerItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DebuggerItem();
|
||||||
|
|
||||||
|
bool looksLike(const DebuggerItem &rhs) const;
|
||||||
|
bool canClone() const { return true; }
|
||||||
|
bool isValid() const { return true; }
|
||||||
|
QString engineTypeName() const;
|
||||||
|
QString userOutput() const;
|
||||||
|
|
||||||
|
QVariantMap toMap() const;
|
||||||
|
void fromMap(const QVariantMap &data);
|
||||||
|
void reinitializeFromFile();
|
||||||
|
|
||||||
|
public:
|
||||||
|
QVariant id;
|
||||||
|
QString displayName;
|
||||||
|
DebuggerEngineType engineType;
|
||||||
|
Utils::FileName command;
|
||||||
|
bool isAutoDetected;
|
||||||
|
QList<ProjectExplorer::Abi> abis;
|
||||||
|
};
|
||||||
|
|
||||||
class DEBUGGER_EXPORT DebuggerKitInformation : public ProjectExplorer::KitInformation
|
class DEBUGGER_EXPORT DebuggerKitInformation : public ProjectExplorer::KitInformation
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class DEBUGGER_EXPORT DebuggerItem {
|
|
||||||
public:
|
|
||||||
DebuggerItem();
|
|
||||||
DebuggerItem(DebuggerEngineType engineType, const Utils::FileName &fn);
|
|
||||||
bool equals(const DebuggerItem &rhs) const { return engineType == rhs.engineType && binary == rhs.binary; }
|
|
||||||
|
|
||||||
DebuggerEngineType engineType;
|
|
||||||
Utils::FileName binary;
|
|
||||||
};
|
|
||||||
|
|
||||||
DebuggerKitInformation();
|
DebuggerKitInformation();
|
||||||
|
|
||||||
Core::Id dataId() const;
|
Core::Id dataId() const;
|
||||||
|
|
||||||
unsigned int priority() const; // the higher the closer to the top.
|
unsigned int priority() const; // the higher the closer to the top.
|
||||||
|
|
||||||
static DebuggerItem autoDetectItem(const ProjectExplorer::Kit *k);
|
QVariant defaultValue(ProjectExplorer::Kit *k) const;
|
||||||
QVariant defaultValue(ProjectExplorer::Kit *k) const
|
|
||||||
{ return DebuggerKitInformation::itemToVariant(DebuggerKitInformation::autoDetectItem(k)); }
|
|
||||||
|
|
||||||
QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const
|
QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const
|
||||||
{ return DebuggerKitInformation::validateDebugger(k); }
|
{ return DebuggerKitInformation::validateDebugger(k); }
|
||||||
@@ -73,34 +86,26 @@ public:
|
|||||||
ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const;
|
ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const;
|
||||||
|
|
||||||
ItemList toUserOutput(const ProjectExplorer::Kit *k) const;
|
ItemList toUserOutput(const ProjectExplorer::Kit *k) const;
|
||||||
static QString userOutput(const DebuggerItem &item);
|
|
||||||
|
|
||||||
static DebuggerItem debuggerItem(const ProjectExplorer::Kit *k);
|
static DebuggerItem debuggerItem(const ProjectExplorer::Kit *k);
|
||||||
static void setDebuggerItem(ProjectExplorer::Kit *k, const DebuggerItem &item);
|
static void setDebuggerItem(ProjectExplorer::Kit *k,
|
||||||
|
DebuggerEngineType type, const Utils::FileName &command);
|
||||||
|
|
||||||
static Utils::FileName debuggerCommand(const ProjectExplorer::Kit *k)
|
static Utils::FileName debuggerCommand(const ProjectExplorer::Kit *k)
|
||||||
{ return debuggerItem(k).binary; }
|
{ return debuggerItem(k).command; }
|
||||||
|
|
||||||
static void setDebuggerCommand(ProjectExplorer::Kit *k, const Utils::FileName &command);
|
static void setDebuggerCommand(ProjectExplorer::Kit *k, const Utils::FileName &command);
|
||||||
|
|
||||||
static DebuggerEngineType engineType(const ProjectExplorer::Kit *k)
|
static DebuggerEngineType engineType(const ProjectExplorer::Kit *k)
|
||||||
{ return debuggerItem(k).engineType; }
|
{ return debuggerItem(k).engineType; }
|
||||||
|
|
||||||
static void setEngineType(ProjectExplorer::Kit *k, DebuggerEngineType type);
|
|
||||||
|
|
||||||
static QString debuggerEngineName(DebuggerEngineType t);
|
|
||||||
|
|
||||||
static void makeSticky(ProjectExplorer::Kit *k);
|
static void makeSticky(ProjectExplorer::Kit *k);
|
||||||
|
|
||||||
private:
|
|
||||||
static DebuggerItem variantToItem(const QVariant &v);
|
|
||||||
static QVariant itemToVariant(const DebuggerItem &i);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool operator==(const DebuggerKitInformation::DebuggerItem &i1, const DebuggerKitInformation::DebuggerItem &i2)
|
inline bool operator==(const DebuggerItem &i1, const DebuggerItem &i2)
|
||||||
{ return i1.equals(i2); }
|
{ return i1.looksLike(i2); }
|
||||||
inline bool operator!=(const DebuggerKitInformation::DebuggerItem &i1, const DebuggerKitInformation::DebuggerItem &i2)
|
inline bool operator!=(const DebuggerItem &i1, const DebuggerItem &i2)
|
||||||
{ return !i1.equals(i2); }
|
{ return !i1.looksLike(i2); }
|
||||||
|
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include "debuggeractions.h"
|
#include "debuggeractions.h"
|
||||||
#include "debuggerinternalconstants.h"
|
#include "debuggerinternalconstants.h"
|
||||||
#include "debuggercore.h"
|
#include "debuggercore.h"
|
||||||
|
#include "debuggerkitconfigwidget.h"
|
||||||
#include "debuggerdialogs.h"
|
#include "debuggerdialogs.h"
|
||||||
#include "debuggerengine.h"
|
#include "debuggerengine.h"
|
||||||
#include "debuggermainwindow.h"
|
#include "debuggermainwindow.h"
|
||||||
@@ -1626,7 +1627,7 @@ void DebuggerPluginPrivate::attachCore()
|
|||||||
DebuggerStartParameters sp;
|
DebuggerStartParameters sp;
|
||||||
QString display = dlg.useLocalCoreFile() ? 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);
|
||||||
DebuggerKitInformation::DebuggerItem info = DebuggerKitInformation::debuggerItem(dlg.kit());
|
DebuggerItem info = DebuggerKitInformation::debuggerItem(dlg.kit());
|
||||||
sp.masterEngineType = info.engineType;
|
sp.masterEngineType = info.engineType;
|
||||||
sp.executable = dlg.localExecutableFile();
|
sp.executable = dlg.localExecutableFile();
|
||||||
sp.coreFile = dlg.localCoreFile();
|
sp.coreFile = dlg.localCoreFile();
|
||||||
@@ -3182,6 +3183,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
|
|||||||
foreach (IOptionsPage *op, engineOptionPages)
|
foreach (IOptionsPage *op, engineOptionPages)
|
||||||
m_plugin->addAutoReleasedObject(op);
|
m_plugin->addAutoReleasedObject(op);
|
||||||
m_plugin->addAutoReleasedObject(new LocalsAndExpressionsOptionsPage);
|
m_plugin->addAutoReleasedObject(new LocalsAndExpressionsOptionsPage);
|
||||||
|
m_plugin->addAutoReleasedObject(new DebuggerOptionsPage);
|
||||||
|
|
||||||
connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
|
connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
|
||||||
SLOT(onModeChanged(Core::IMode*)));
|
SLOT(onModeChanged(Core::IMode*)));
|
||||||
@@ -3436,6 +3438,8 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
|
|||||||
mstart->addSeparator(globalcontext, Constants::G_GENERAL);
|
mstart->addSeparator(globalcontext, Constants::G_GENERAL);
|
||||||
mstart->addSeparator(globalcontext, Constants::G_SPECIAL);
|
mstart->addSeparator(globalcontext, Constants::G_SPECIAL);
|
||||||
|
|
||||||
|
DebuggerItemManager::restoreDebuggers();
|
||||||
|
|
||||||
KitManager::registerKitInformation(new DebuggerKitInformation);
|
KitManager::registerKitInformation(new DebuggerKitInformation);
|
||||||
|
|
||||||
return theDebuggerCore->initialize(arguments, errorMessage);
|
return theDebuggerCore->initialize(arguments, errorMessage);
|
||||||
|
@@ -179,6 +179,7 @@ const char PROJECTEXPLORER_SETTINGS_TR_CATEGORY[] = QT_TRANSLATE_NOOP("ProjectEx
|
|||||||
const char PROJECTEXPLORER_SETTINGS_CATEGORY_ICON[] = ":/core/images/category_buildrun.png";
|
const char PROJECTEXPLORER_SETTINGS_CATEGORY_ICON[] = ":/core/images/category_buildrun.png";
|
||||||
const char PROJECTEXPLORER_SETTINGS_ID[] = "A.ProjectExplorer.ProjectExplorer";
|
const char PROJECTEXPLORER_SETTINGS_ID[] = "A.ProjectExplorer.ProjectExplorer";
|
||||||
const char TOOLCHAIN_SETTINGS_PAGE_ID[] = "M.ProjectExplorer.ToolChainOptions";
|
const char TOOLCHAIN_SETTINGS_PAGE_ID[] = "M.ProjectExplorer.ToolChainOptions";
|
||||||
|
const char DEBUGGER_SETTINGS_PAGE_ID[] = "N.ProjectExplorer.DebuggerOptions";
|
||||||
const char KITS_SETTINGS_PAGE_ID[] = "D.ProjectExplorer.KitsOptions";
|
const char KITS_SETTINGS_PAGE_ID[] = "D.ProjectExplorer.KitsOptions";
|
||||||
|
|
||||||
// Device settings page
|
// Device settings page
|
||||||
|
Reference in New Issue
Block a user