Commit 80b2a4f1 authored by hjk's avatar hjk

Debugger: Expose DebuggerKitInformation::ConfigurationErrors

... to allow more fine-grained decision making for kit choosers.

Change-Id: I9a4e97f7b4f4b074e1c764f6b134c15e2896dc79
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
parent 5b058ebb
......@@ -107,7 +107,7 @@ DebuggerKitChooser::DebuggerKitChooser(Mode mode, QWidget *parent)
{
setKitMatcher([this](const Kit *k) {
// Match valid debuggers and restrict local debugging to compatible toolchains.
if (!DebuggerKitInformation::isValidDebugger(k))
if (DebuggerKitInformation::configurationErrors(k))
return false;
if (m_mode == LocalDebugging)
return ToolChainKitInformation::targetAbi(k).os() == m_hostAbi.os();
......@@ -223,7 +223,7 @@ StartApplicationDialog::StartApplicationDialog(QWidget *parent)
d->kitChooser = new KitChooser(this);
d->kitChooser->setKitMatcher([this](const Kit *k) {
return DebuggerKitInformation::isValidDebugger(k);
return !DebuggerKitInformation::configurationErrors(k);
});
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
// a verbose one with a list of errors.
enum DebuggerConfigurationErrors {
NoDebugger = 0x1,
DebuggerNotFound = 0x2,
DebuggerNotExecutable = 0x4,
DebuggerNeedsAbsolutePath = 0x8,
DebuggerDoesNotMatch = 0x10
};
static unsigned debuggerConfigurationErrors(const Kit *k)
DebuggerKitInformation::ConfigurationErrors DebuggerKitInformation::configurationErrors(const Kit *k)
{
QTC_ASSERT(k, return NoDebugger);
......@@ -210,7 +202,7 @@ static unsigned debuggerConfigurationErrors(const Kit *k)
if (item->command().isEmpty())
return NoDebugger;
unsigned result = 0;
ConfigurationErrors result = NoConfigurationError;
const QFileInfo fi = item->command().toFileInfo();
if (!fi.exists() || fi.isDir())
result |= DebuggerNotFound;
......@@ -257,17 +249,12 @@ StandardRunnable DebuggerKitInformation::runnable(const Kit *kit)
return runnable;
}
bool DebuggerKitInformation::isValidDebugger(const Kit *k)
{
return debuggerConfigurationErrors(k) == 0;
}
QList<Task> DebuggerKitInformation::validateDebugger(const Kit *k)
{
QList<Task> result;
const unsigned errors = debuggerConfigurationErrors(k);
if (!errors)
const ConfigurationErrors errors = configurationErrors(k);
if (errors == NoConfigurationError)
return result;
QString path;
......
......@@ -52,8 +52,19 @@ public:
static const DebuggerItem *debugger(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 bool isValidDebugger(const ProjectExplorer::Kit *k);
static ConfigurationErrors configurationErrors(const ProjectExplorer::Kit *k);
ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) 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 {
if (DebuggerKitInformation::engineType(k) != CdbEngineType
|| !DebuggerKitInformation::isValidDebugger(k)) {
|| DebuggerKitInformation::configurationErrors(k)) {
return false;
}
if (wordWidth)
......@@ -1125,13 +1125,13 @@ static Kit *guessKitFromParameters(const DebuggerRunParameters &rp)
// Try exact abis.
kit = KitManager::find(KitMatcher([abis](const Kit *k) -> bool {
const Abi tcAbi = ToolChainKitInformation::targetAbi(k);
return abis.contains(tcAbi) && DebuggerKitInformation::isValidDebugger(k);
return abis.contains(tcAbi) && !DebuggerKitInformation::configurationErrors(k);
}));
if (!kit) {
// Or something compatible.
kit = KitManager::find(KitMatcher([abis](const Kit *k) -> bool {
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); });
}));
}
......
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