forked from qt-creator/qt-creator
Debugger: Expose DebuggerKitInformation::ConfigurationErrors
... to allow more fine-grained decision making for kit choosers. Change-Id: I9a4e97f7b4f4b074e1c764f6b134c15e2896dc79 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -107,7 +107,7 @@ DebuggerKitChooser::DebuggerKitChooser(Mode mode, QWidget *parent)
|
|||||||
{
|
{
|
||||||
setKitMatcher([this](const Kit *k) {
|
setKitMatcher([this](const Kit *k) {
|
||||||
// Match valid debuggers and restrict local debugging to compatible toolchains.
|
// Match valid debuggers and restrict local debugging to compatible toolchains.
|
||||||
if (!DebuggerKitInformation::isValidDebugger(k))
|
if (DebuggerKitInformation::configurationErrors(k))
|
||||||
return false;
|
return false;
|
||||||
if (m_mode == LocalDebugging)
|
if (m_mode == LocalDebugging)
|
||||||
return ToolChainKitInformation::targetAbi(k).os() == m_hostAbi.os();
|
return ToolChainKitInformation::targetAbi(k).os() == m_hostAbi.os();
|
||||||
@@ -223,7 +223,7 @@ StartApplicationDialog::StartApplicationDialog(QWidget *parent)
|
|||||||
|
|
||||||
d->kitChooser = new KitChooser(this);
|
d->kitChooser = new KitChooser(this);
|
||||||
d->kitChooser->setKitMatcher([this](const Kit *k) {
|
d->kitChooser->setKitMatcher([this](const Kit *k) {
|
||||||
return DebuggerKitInformation::isValidDebugger(k);
|
return !DebuggerKitInformation::configurationErrors(k);
|
||||||
});
|
});
|
||||||
d->kitChooser->populate();
|
d->kitChooser->populate();
|
||||||
|
|
||||||
|
@@ -191,15 +191,7 @@ void DebuggerKitInformation::fix(Kit *k)
|
|||||||
// Check the configuration errors and return a flag mask. Provide a quick check and
|
// Check the configuration errors and return a flag mask. Provide a quick check and
|
||||||
// a verbose one with a list of errors.
|
// a verbose one with a list of errors.
|
||||||
|
|
||||||
enum DebuggerConfigurationErrors {
|
DebuggerKitInformation::ConfigurationErrors DebuggerKitInformation::configurationErrors(const Kit *k)
|
||||||
NoDebugger = 0x1,
|
|
||||||
DebuggerNotFound = 0x2,
|
|
||||||
DebuggerNotExecutable = 0x4,
|
|
||||||
DebuggerNeedsAbsolutePath = 0x8,
|
|
||||||
DebuggerDoesNotMatch = 0x10
|
|
||||||
};
|
|
||||||
|
|
||||||
static unsigned debuggerConfigurationErrors(const Kit *k)
|
|
||||||
{
|
{
|
||||||
QTC_ASSERT(k, return NoDebugger);
|
QTC_ASSERT(k, return NoDebugger);
|
||||||
|
|
||||||
@@ -210,7 +202,7 @@ static unsigned debuggerConfigurationErrors(const Kit *k)
|
|||||||
if (item->command().isEmpty())
|
if (item->command().isEmpty())
|
||||||
return NoDebugger;
|
return NoDebugger;
|
||||||
|
|
||||||
unsigned result = 0;
|
ConfigurationErrors result = NoConfigurationError;
|
||||||
const QFileInfo fi = item->command().toFileInfo();
|
const QFileInfo fi = item->command().toFileInfo();
|
||||||
if (!fi.exists() || fi.isDir())
|
if (!fi.exists() || fi.isDir())
|
||||||
result |= DebuggerNotFound;
|
result |= DebuggerNotFound;
|
||||||
@@ -257,17 +249,12 @@ StandardRunnable DebuggerKitInformation::runnable(const Kit *kit)
|
|||||||
return runnable;
|
return runnable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DebuggerKitInformation::isValidDebugger(const Kit *k)
|
|
||||||
{
|
|
||||||
return debuggerConfigurationErrors(k) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Task> DebuggerKitInformation::validateDebugger(const Kit *k)
|
QList<Task> DebuggerKitInformation::validateDebugger(const Kit *k)
|
||||||
{
|
{
|
||||||
QList<Task> result;
|
QList<Task> result;
|
||||||
|
|
||||||
const unsigned errors = debuggerConfigurationErrors(k);
|
const ConfigurationErrors errors = configurationErrors(k);
|
||||||
if (!errors)
|
if (errors == NoConfigurationError)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
QString path;
|
QString path;
|
||||||
|
@@ -52,8 +52,19 @@ public:
|
|||||||
static const DebuggerItem *debugger(const ProjectExplorer::Kit *kit);
|
static const DebuggerItem *debugger(const ProjectExplorer::Kit *kit);
|
||||||
static ProjectExplorer::StandardRunnable runnable(const ProjectExplorer::Kit *kit);
|
static ProjectExplorer::StandardRunnable runnable(const ProjectExplorer::Kit *kit);
|
||||||
|
|
||||||
|
enum ConfigurationError
|
||||||
|
{
|
||||||
|
NoConfigurationError = 0x0,
|
||||||
|
NoDebugger = 0x1,
|
||||||
|
DebuggerNotFound = 0x2,
|
||||||
|
DebuggerNotExecutable = 0x4,
|
||||||
|
DebuggerNeedsAbsolutePath = 0x8,
|
||||||
|
DebuggerDoesNotMatch = 0x10
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS(ConfigurationErrors, ConfigurationError)
|
||||||
|
|
||||||
static QList<ProjectExplorer::Task> validateDebugger(const ProjectExplorer::Kit *k);
|
static QList<ProjectExplorer::Task> validateDebugger(const ProjectExplorer::Kit *k);
|
||||||
static bool isValidDebugger(const ProjectExplorer::Kit *k);
|
static ConfigurationErrors configurationErrors(const ProjectExplorer::Kit *k);
|
||||||
|
|
||||||
ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const override;
|
ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const override;
|
||||||
void addToMacroExpander(ProjectExplorer::Kit *kit, Utils::MacroExpander *expander) const override;
|
void addToMacroExpander(ProjectExplorer::Kit *kit, Utils::MacroExpander *expander) const override;
|
||||||
|
@@ -583,7 +583,7 @@ static std::function<bool(const Kit *)> cdbMatcher(char wordWidth = 0)
|
|||||||
{
|
{
|
||||||
return [wordWidth](const Kit *k) -> bool {
|
return [wordWidth](const Kit *k) -> bool {
|
||||||
if (DebuggerKitInformation::engineType(k) != CdbEngineType
|
if (DebuggerKitInformation::engineType(k) != CdbEngineType
|
||||||
|| !DebuggerKitInformation::isValidDebugger(k)) {
|
|| DebuggerKitInformation::configurationErrors(k)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (wordWidth)
|
if (wordWidth)
|
||||||
@@ -1125,13 +1125,13 @@ static Kit *guessKitFromParameters(const DebuggerRunParameters &rp)
|
|||||||
// Try exact abis.
|
// Try exact abis.
|
||||||
kit = KitManager::find(KitMatcher([abis](const Kit *k) -> bool {
|
kit = KitManager::find(KitMatcher([abis](const Kit *k) -> bool {
|
||||||
const Abi tcAbi = ToolChainKitInformation::targetAbi(k);
|
const Abi tcAbi = ToolChainKitInformation::targetAbi(k);
|
||||||
return abis.contains(tcAbi) && DebuggerKitInformation::isValidDebugger(k);
|
return abis.contains(tcAbi) && !DebuggerKitInformation::configurationErrors(k);
|
||||||
}));
|
}));
|
||||||
if (!kit) {
|
if (!kit) {
|
||||||
// Or something compatible.
|
// Or something compatible.
|
||||||
kit = KitManager::find(KitMatcher([abis](const Kit *k) -> bool {
|
kit = KitManager::find(KitMatcher([abis](const Kit *k) -> bool {
|
||||||
const Abi tcAbi = ToolChainKitInformation::targetAbi(k);
|
const Abi tcAbi = ToolChainKitInformation::targetAbi(k);
|
||||||
return DebuggerKitInformation::isValidDebugger(k)
|
return !DebuggerKitInformation::configurationErrors(k)
|
||||||
&& Utils::contains(abis, [tcAbi](const Abi &a) { return a.isCompatibleWith(tcAbi); });
|
&& Utils::contains(abis, [tcAbi](const Abi &a) { return a.isCompatibleWith(tcAbi); });
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user