forked from qt-creator/qt-creator
Debugger: modernize cdb detection
Change-Id: Icc01ee47311fdd6d34df7555afd93bb323fdd05c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/asconst.h>
|
||||||
#include <utils/detailswidget.h>
|
#include <utils/detailswidget.h>
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
@@ -629,18 +630,19 @@ void DebuggerItemManagerPrivate::autoDetectCdbDebuggers()
|
|||||||
{
|
{
|
||||||
FileNameList cdbs;
|
FileNameList cdbs;
|
||||||
|
|
||||||
QStringList programDirs;
|
const QStringList programDirs = {
|
||||||
programDirs.append(QString::fromLocal8Bit(qgetenv("ProgramFiles")));
|
QString::fromLocal8Bit(qgetenv("ProgramFiles")),
|
||||||
programDirs.append(QString::fromLocal8Bit(qgetenv("ProgramFiles(x86)")));
|
QString::fromLocal8Bit(qgetenv("ProgramFiles(x86)")),
|
||||||
programDirs.append(QString::fromLocal8Bit(qgetenv("ProgramW6432")));
|
QString::fromLocal8Bit(qgetenv("ProgramW6432"))
|
||||||
|
};
|
||||||
|
|
||||||
foreach (const QString &dirName, programDirs) {
|
for (const QString &dirName: programDirs) {
|
||||||
if (dirName.isEmpty())
|
if (dirName.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
QDir dir(dirName);
|
const QDir dir(dirName);
|
||||||
// Windows SDK's starting from version 8 live in
|
// Windows SDK's starting from version 8 live in
|
||||||
// "ProgramDir\Windows Kits\<version>"
|
// "ProgramDir\Windows Kits\<version>"
|
||||||
const QString windowsKitsFolderName = QLatin1String("Windows Kits");
|
const QString windowsKitsFolderName = "Windows Kits";
|
||||||
if (dir.exists(windowsKitsFolderName)) {
|
if (dir.exists(windowsKitsFolderName)) {
|
||||||
QDir windowKitsFolder = dir;
|
QDir windowKitsFolder = dir;
|
||||||
if (windowKitsFolder.cd(windowsKitsFolderName)) {
|
if (windowKitsFolder.cd(windowsKitsFolderName)) {
|
||||||
@@ -648,12 +650,12 @@ void DebuggerItemManagerPrivate::autoDetectCdbDebuggers()
|
|||||||
const QFileInfoList kitFolders =
|
const QFileInfoList kitFolders =
|
||||||
windowKitsFolder.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot,
|
windowKitsFolder.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot,
|
||||||
QDir::Time | QDir::Reversed);
|
QDir::Time | QDir::Reversed);
|
||||||
foreach (const QFileInfo &kitFolderFi, kitFolders) {
|
for (const QFileInfo &kitFolderFi : kitFolders) {
|
||||||
const QString path = kitFolderFi.absoluteFilePath();
|
const QString path = kitFolderFi.absoluteFilePath();
|
||||||
const QFileInfo cdb32(path + QLatin1String("/Debuggers/x86/cdb.exe"));
|
const QFileInfo cdb32(path + "/Debuggers/x86/cdb.exe");
|
||||||
if (cdb32.isExecutable())
|
if (cdb32.isExecutable())
|
||||||
cdbs.append(FileName::fromString(cdb32.absoluteFilePath()));
|
cdbs.append(FileName::fromString(cdb32.absoluteFilePath()));
|
||||||
const QFileInfo cdb64(path + QLatin1String("/Debuggers/x64/cdb.exe"));
|
const QFileInfo cdb64(path + "/Debuggers/x64/cdb.exe");
|
||||||
if (cdb64.isExecutable())
|
if (cdb64.isExecutable())
|
||||||
cdbs.append(FileName::fromString(cdb64.absoluteFilePath()));
|
cdbs.append(FileName::fromString(cdb64.absoluteFilePath()));
|
||||||
}
|
}
|
||||||
@@ -661,16 +663,16 @@ void DebuggerItemManagerPrivate::autoDetectCdbDebuggers()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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*")),
|
for (const QFileInfo &fi : dir.entryInfoList({"Debugging Tools for Windows*"},
|
||||||
QDir::Dirs | QDir::NoDotAndDotDot)) {
|
QDir::Dirs | QDir::NoDotAndDotDot)) {
|
||||||
FileName filePath(fi);
|
FileName filePath(fi);
|
||||||
filePath.appendPath(QLatin1String("cdb.exe"));
|
filePath.appendPath("cdb.exe");
|
||||||
if (!cdbs.contains(filePath))
|
if (!cdbs.contains(filePath))
|
||||||
cdbs.append(filePath);
|
cdbs.append(filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const FileName &cdb, cdbs) {
|
for (const FileName &cdb : Utils::asConst(cdbs)) {
|
||||||
if (DebuggerItemManager::findByCommand(cdb))
|
if (DebuggerItemManager::findByCommand(cdb))
|
||||||
continue;
|
continue;
|
||||||
DebuggerItem item;
|
DebuggerItem item;
|
||||||
|
Reference in New Issue
Block a user