forked from qt-creator/qt-creator
Debugger[CDB]: Use file normalization function from utils.
Remove complicated/expensive function in dbgwinutils in favour of the utils one (improved to upper case the drive letter) as it is sufficient now with the improved checking in editor manager/location mark.
This commit is contained in:
@@ -173,6 +173,9 @@ QTCREATOR_UTILS_EXPORT QString normalizePathName(const QString &name)
|
||||
canonicalName = getLongPathName(canonicalName);
|
||||
if (canonicalName.isEmpty())
|
||||
return name;
|
||||
// Upper case drive letter
|
||||
if (canonicalName.size() > 2 && canonicalName.at(1) == QLatin1Char(':'))
|
||||
canonicalName[0] = canonicalName.at(0).toUpper();
|
||||
return canonicalName;
|
||||
}
|
||||
|
||||
|
||||
@@ -2477,7 +2477,7 @@ CdbEngine::NormalizedSourceFileName CdbEngine::sourceMapNormalizeFileNameFromDeb
|
||||
DebuggerToSource);
|
||||
// Up/lower case normalization according to Windows.
|
||||
#ifdef Q_OS_WIN
|
||||
QString normalized = winNormalizeFileName(fileName);
|
||||
QString normalized = Utils::normalizePathName(fileName);
|
||||
#else
|
||||
QString normalized = fileName;
|
||||
#endif
|
||||
|
||||
@@ -200,53 +200,6 @@ static bool mapDeviceToDriveLetter(QString *s)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Determine normalized case of a Windows file name (camelcase.cpp -> CamelCase.cpp)
|
||||
// Restriction: File needs to exists and be non-empty and will be to be opened/mapped.
|
||||
// This is the MSDN-recommended way of doing that.
|
||||
|
||||
QString winNormalizeFileName(const QString &f)
|
||||
{
|
||||
HANDLE hFile = CreateFile((const wchar_t*)f.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||
if(hFile == INVALID_HANDLE_VALUE)
|
||||
return f;
|
||||
// Get the file size. We need a non-empty file to map it.
|
||||
DWORD dwFileSizeHi = 0;
|
||||
DWORD dwFileSizeLo = GetFileSize(hFile, &dwFileSizeHi);
|
||||
if (dwFileSizeLo == 0 && dwFileSizeHi == 0) {
|
||||
CloseHandle(hFile);
|
||||
return f;
|
||||
}
|
||||
// Create a file mapping object.
|
||||
HANDLE hFileMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 1, NULL);
|
||||
if (!hFileMap) {
|
||||
CloseHandle(hFile);
|
||||
return f;
|
||||
}
|
||||
|
||||
// Create a file mapping to get the file name.
|
||||
void* pMem = MapViewOfFile(hFileMap, FILE_MAP_READ, 0, 0, 1);
|
||||
if (!pMem) {
|
||||
CloseHandle(hFileMap);
|
||||
CloseHandle(hFile);
|
||||
return f;
|
||||
}
|
||||
|
||||
QString rc;
|
||||
WCHAR pszFilename[MAX_PATH];
|
||||
pszFilename[0] = 0;
|
||||
// Get a file name of the form "/Device/HarddiskVolume1/file.cpp"
|
||||
if (GetMappedFileName (GetCurrentProcess(), pMem, pszFilename, MAX_PATH)) {
|
||||
rc = QString::fromWCharArray(pszFilename);
|
||||
if (!mapDeviceToDriveLetter(&rc))
|
||||
rc.clear();
|
||||
}
|
||||
|
||||
UnmapViewOfFile(pMem);
|
||||
CloseHandle(hFileMap);
|
||||
CloseHandle(hFile);
|
||||
return rc.isEmpty() ? f : rc;
|
||||
}
|
||||
|
||||
bool isWinProcessBeingDebugged(unsigned long pid)
|
||||
{
|
||||
HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
|
||||
|
||||
@@ -53,14 +53,6 @@ bool winDebugBreakProcess(unsigned long pid, QString *errorMessage);
|
||||
|
||||
unsigned long winGetCurrentProcessId();
|
||||
|
||||
/* Helper for (case-)normalizing file names:
|
||||
* Determine normalized case of a Windows file name (camelcase.cpp -> CamelCase.cpp)
|
||||
* as the debugger reports lower case file names.
|
||||
* Restriction: File needs to exist and be non-empty and will be to be opened/mapped.
|
||||
* The result should be cached as the function can be extensive. */
|
||||
|
||||
QString winNormalizeFileName(const QString &f);
|
||||
|
||||
bool isWinProcessBeingDebugged(unsigned long pid);
|
||||
|
||||
// Special exception codes.
|
||||
|
||||
Reference in New Issue
Block a user