debugger: reduce line noise

By using ProjectExplorer, using Utils.

Change-Id: I723c8ffb21bd26153ff2c0c73bf9f6ef7760d8de
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
hjk
2012-08-13 12:39:11 +02:00
parent 26c4329f74
commit beb3236b75

View File

@@ -41,6 +41,9 @@
#include <QDir> #include <QDir>
#include <QPair> #include <QPair>
using namespace ProjectExplorer;
using namespace Utils;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Helpers: // Helpers:
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@@ -48,7 +51,7 @@
static QPair<QString, QString> autoDetectCdbDebugger() static QPair<QString, QString> autoDetectCdbDebugger()
{ {
QPair<QString, QString> result; QPair<QString, QString> result;
QList<Utils::FileName> cdbs; QList<FileName> cdbs;
QStringList programDirs; QStringList programDirs;
programDirs.append(QString::fromLocal8Bit(qgetenv("ProgramFiles"))); programDirs.append(QString::fromLocal8Bit(qgetenv("ProgramFiles")));
@@ -73,10 +76,10 @@ static QPair<QString, QString> autoDetectCdbDebugger()
const QString path = kitFolderFi.absoluteFilePath(); const QString path = kitFolderFi.absoluteFilePath();
const QFileInfo cdb32(path + QLatin1String("/Debuggers/x86/cdb.exe")); const QFileInfo cdb32(path + QLatin1String("/Debuggers/x86/cdb.exe"));
if (cdb32.isExecutable()) if (cdb32.isExecutable())
cdbs.push_back(Utils::FileName::fromString(cdb32.absoluteFilePath())); cdbs.push_back(FileName::fromString(cdb32.absoluteFilePath()));
const QFileInfo cdb64(path + QLatin1String("/Debuggers/x64/cdb.exe")); const QFileInfo cdb64(path + QLatin1String("/Debuggers/x64/cdb.exe"));
if (cdb64.isExecutable()) if (cdb64.isExecutable())
cdbs.push_back(Utils::FileName::fromString(cdb64.absoluteFilePath())); cdbs.push_back(FileName::fromString(cdb64.absoluteFilePath()));
} // for Kits } // for Kits
} // can cd to "Windows Kits" } // can cd to "Windows Kits"
} // "Windows Kits" exists } // "Windows Kits" exists
@@ -84,15 +87,15 @@ static QPair<QString, QString> autoDetectCdbDebugger()
// Pre Windows SDK 8: Check 'Debugging Tools for Windows' // Pre Windows SDK 8: Check 'Debugging Tools for Windows'
foreach (const QFileInfo &fi, dir.entryInfoList(QStringList(QLatin1String("Debugging Tools for Windows*")), foreach (const QFileInfo &fi, dir.entryInfoList(QStringList(QLatin1String("Debugging Tools for Windows*")),
QDir::Dirs | QDir::NoDotAndDotDot)) { QDir::Dirs | QDir::NoDotAndDotDot)) {
Utils::FileName filePath(fi); FileName filePath(fi);
filePath.appendPath(QLatin1String("cdb.exe")); filePath.appendPath(QLatin1String("cdb.exe"));
if (!cdbs.contains(filePath)) if (!cdbs.contains(filePath))
cdbs.append(filePath); cdbs.append(filePath);
} }
} }
foreach (const Utils::FileName &cdb, cdbs) { foreach (const FileName &cdb, cdbs) {
QList<ProjectExplorer::Abi> abis = ProjectExplorer::Abi::abisOfBinary(cdb); QList<Abi> abis = Abi::abisOfBinary(cdb);
if (abis.isEmpty()) if (abis.isEmpty())
continue; continue;
if (abis.first().wordWidth() == 32) if (abis.first().wordWidth() == 32)
@@ -132,16 +135,15 @@ unsigned int DebuggerProfileInformation::priority() const
return 28000; return 28000;
} }
QVariant DebuggerProfileInformation::defaultValue(ProjectExplorer::Profile *p) const QVariant DebuggerProfileInformation::defaultValue(Profile *p) const
{ {
ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainProfileInformation::toolChain(p); ToolChain *tc = ToolChainProfileInformation::toolChain(p);
ProjectExplorer::Abi abi = ProjectExplorer::Abi::hostAbi(); Abi abi = Abi::hostAbi();
if (tc) if (tc)
abi = tc->targetAbi(); abi = tc->targetAbi();
// CDB for windows: // CDB for windows:
if (abi.os() == ProjectExplorer::Abi::WindowsOS if (abi.os() == Abi::WindowsOS && abi.osFlavor() != Abi::WindowsMSysFlavor) {
&& abi.osFlavor() != ProjectExplorer::Abi::WindowsMSysFlavor) {
QPair<QString, QString> cdbs = autoDetectCdbDebugger(); QPair<QString, QString> cdbs = autoDetectCdbDebugger();
return (abi.wordWidth() == 32) ? cdbs.first : cdbs.second; return (abi.wordWidth() == 32) ? cdbs.first : cdbs.second;
} }
@@ -159,51 +161,47 @@ QVariant DebuggerProfileInformation::defaultValue(ProjectExplorer::Profile *p) c
} }
} }
Utils::Environment env = Utils::Environment::systemEnvironment(); Environment env = Environment::systemEnvironment();
return env.searchInPath(debugger); return env.searchInPath(debugger);
} }
QList<ProjectExplorer::Task> DebuggerProfileInformation::validate(ProjectExplorer::Profile *p) const QList<Task> DebuggerProfileInformation::validate(Profile *p) const
{ {
QList<ProjectExplorer::Task> result; QList<Task> result;
Utils::FileName dbg = debuggerCommand(p); FileName dbg = debuggerCommand(p);
if (dbg.isEmpty()) { if (dbg.isEmpty()) {
result << ProjectExplorer::Task(ProjectExplorer::Task::Warning, result << Task(Task::Warning, tr("No debugger set up."), FileName(), -1,
tr("No debugger set up."), Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM));
Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
return result; return result;
} }
QFileInfo fi = dbg.toFileInfo(); QFileInfo fi = dbg.toFileInfo();
if (!fi.exists() || fi.isDir()) if (!fi.exists() || fi.isDir())
result << ProjectExplorer::Task(ProjectExplorer::Task::Error, result << Task(Task::Error, tr("Debugger not found."), FileName(), -1,
tr("Debugger not found."), Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM));
Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
else if (!fi.isExecutable()) else if (!fi.isExecutable())
result << ProjectExplorer::Task(ProjectExplorer::Task::Error, result << Task(Task::Error, tr("Debugger not exectutable."), FileName(), -1,
tr("Debugger not exectutable."), Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM));
Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
return result; return result;
} }
ProjectExplorer::ProfileConfigWidget * ProfileConfigWidget *DebuggerProfileInformation::createConfigWidget(Profile *p) const
DebuggerProfileInformation::createConfigWidget(ProjectExplorer::Profile *p) const
{ {
return new Internal::DebuggerProfileConfigWidget(p, this); return new Internal::DebuggerProfileConfigWidget(p, this);
} }
ProjectExplorer::ProfileInformation::ItemList DebuggerProfileInformation::toUserOutput(ProjectExplorer::Profile *p) const ProfileInformation::ItemList DebuggerProfileInformation::toUserOutput(Profile *p) const
{ {
return ItemList() << qMakePair(tr("Debugger"), debuggerCommand(p).toUserOutput()); return ItemList() << qMakePair(tr("Debugger"), debuggerCommand(p).toUserOutput());
} }
Utils::FileName DebuggerProfileInformation::debuggerCommand(const ProjectExplorer::Profile *p) FileName DebuggerProfileInformation::debuggerCommand(const Profile *p)
{ {
return Utils::FileName::fromString(p->value(Core::Id(DEBUGGER_INFORMATION)).toString()); return FileName::fromString(p->value(Core::Id(DEBUGGER_INFORMATION)).toString());
} }
void DebuggerProfileInformation::setDebuggerCommand(ProjectExplorer::Profile *p, const Utils::FileName &command) void DebuggerProfileInformation::setDebuggerCommand(Profile *p, const FileName &command)
{ {
p->setValue(Core::Id(DEBUGGER_INFORMATION), command.toString()); p->setValue(Core::Id(DEBUGGER_INFORMATION), command.toString());
} }