Debugger: more QString > FilePath replacements

Change-Id: I7242546574d7692f97419a9df876330c800719ab
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
David Schulz
2021-05-27 12:07:25 +02:00
parent 588af658ee
commit 447a719fe2

View File

@@ -2437,45 +2437,45 @@ public:
const CppTools::WorkingCopy &workingCopy) : const CppTools::WorkingCopy &workingCopy) :
m_snapshot(s), m_workingCopy(workingCopy) {} m_snapshot(s), m_workingCopy(workingCopy) {}
unsigned fixLineNumber(const QString &fileName, unsigned lineNumber) const; unsigned fixLineNumber(const Utils::FilePath &filePath, unsigned lineNumber) const;
private: private:
const CPlusPlus::Snapshot m_snapshot; const CPlusPlus::Snapshot m_snapshot;
CppTools::WorkingCopy m_workingCopy; CppTools::WorkingCopy m_workingCopy;
}; };
static CPlusPlus::Document::Ptr getParsedDocument(const QString &fileName, static CPlusPlus::Document::Ptr getParsedDocument(const Utils::FilePath &filePath,
const CppTools::WorkingCopy &workingCopy, const CppTools::WorkingCopy &workingCopy,
const CPlusPlus::Snapshot &snapshot) const CPlusPlus::Snapshot &snapshot)
{ {
QByteArray src; QByteArray src;
if (workingCopy.contains(fileName)) { if (workingCopy.contains(filePath))
src = workingCopy.source(fileName); src = workingCopy.source(filePath);
} else { else
FileReader reader; src = QString::fromLocal8Bit(filePath.fileContents()).toUtf8();
if (reader.fetch(Utils::FilePath::fromString(fileName))) // ### FIXME error reporting
src = QString::fromLocal8Bit(reader.data()).toUtf8();
}
CPlusPlus::Document::Ptr doc = snapshot.preprocessedDocument(src, fileName); CPlusPlus::Document::Ptr doc = snapshot.preprocessedDocument(src, filePath.toString());
doc->parse(); doc->parse();
return doc; return doc;
} }
unsigned BreakpointCorrectionContext::fixLineNumber(const QString &fileName, unsigned BreakpointCorrectionContext::fixLineNumber(const Utils::FilePath &filePath,
unsigned lineNumber) const unsigned lineNumber) const
{ {
const CPlusPlus::Document::Ptr doc = getParsedDocument(fileName, m_workingCopy, m_snapshot); const CPlusPlus::Document::Ptr doc = getParsedDocument(filePath,
m_workingCopy,
m_snapshot);
CPlusPlus::FindCdbBreakpoint findVisitor(doc->translationUnit()); CPlusPlus::FindCdbBreakpoint findVisitor(doc->translationUnit());
const unsigned correctedLine = findVisitor(lineNumber); const unsigned correctedLine = findVisitor(lineNumber);
if (!correctedLine) { if (!correctedLine) {
qWarning("Unable to find breakpoint location for %s:%d", qWarning("Unable to find breakpoint location for %s:%d",
qPrintable(QDir::toNativeSeparators(fileName)), lineNumber); qPrintable(filePath.toUserOutput()),
lineNumber);
return lineNumber; return lineNumber;
} }
if (debug) if (debug)
qDebug("Code model: Breakpoint line %u -> %u in %s", qDebug("Code model: Breakpoint line %u -> %u in %s",
lineNumber, correctedLine, qPrintable(fileName)); lineNumber, correctedLine, qPrintable(filePath.toString()));
return correctedLine; return correctedLine;
} }
@@ -2490,7 +2490,7 @@ void CdbEngine::insertBreakpoint(const Breakpoint &bp)
if (!m_autoBreakPointCorrection if (!m_autoBreakPointCorrection
&& parameters.type == BreakpointByFileAndLine && parameters.type == BreakpointByFileAndLine
&& debuggerSettings()->cdbBreakPointCorrection.value()) { && debuggerSettings()->cdbBreakPointCorrection.value()) {
response.lineNumber = int(lineCorrection->fixLineNumber(parameters.fileName.toString(), response.lineNumber = int(lineCorrection->fixLineNumber(parameters.fileName,
unsigned(parameters.lineNumber))); unsigned(parameters.lineNumber)));
QString cmd = cdbAddBreakpointCommand(response, m_sourcePathMappings, responseId); QString cmd = cdbAddBreakpointCommand(response, m_sourcePathMappings, responseId);
runCommand({cmd, BuiltinCommand, handleBreakInsertCB}); runCommand({cmd, BuiltinCommand, handleBreakInsertCB});