forked from qt-creator/qt-creator
Debugger: Use more FilePath in source file handling
Needed for the double-remote case. With this we have proper breakpoint markers in the text editor for a remotely running gdb on a remotely loaded project. Change-Id: If80e4a4108a4a0bcdd7612a59e2bd695213f5ea5 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -1126,9 +1126,9 @@ void BreakpointItem::addToCommand(DebuggerCommand *cmd) const
|
||||
cmd->arg("expression", requested.expression);
|
||||
}
|
||||
|
||||
void BreakpointItem::updateFromGdbOutput(const GdbMi &bkpt)
|
||||
void BreakpointItem::updateFromGdbOutput(const GdbMi &bkpt, const FilePath &fileRoot)
|
||||
{
|
||||
m_parameters.updateFromGdbOutput(bkpt);
|
||||
m_parameters.updateFromGdbOutput(bkpt, fileRoot);
|
||||
adjustMarker();
|
||||
}
|
||||
|
||||
|
@@ -107,7 +107,7 @@ public:
|
||||
|
||||
const BreakpointParameters &requestedParameters() const;
|
||||
void addToCommand(DebuggerCommand *cmd) const;
|
||||
void updateFromGdbOutput(const GdbMi &bkpt);
|
||||
void updateFromGdbOutput(const GdbMi &bkpt, const Utils::FilePath &fileRoot);
|
||||
|
||||
int modelId() const;
|
||||
QString responseId() const { return m_responseId; }
|
||||
|
@@ -265,7 +265,8 @@ static QString cleanupFullName(const QString &fileName)
|
||||
|
||||
return cleanFilePath;
|
||||
}
|
||||
void BreakpointParameters::updateFromGdbOutput(const GdbMi &bkpt)
|
||||
|
||||
void BreakpointParameters::updateFromGdbOutput(const GdbMi &bkpt, const Utils::FilePath &fileRoot)
|
||||
{
|
||||
QTC_ASSERT(bkpt.isValid(), return);
|
||||
|
||||
@@ -358,7 +359,7 @@ void BreakpointParameters::updateFromGdbOutput(const GdbMi &bkpt)
|
||||
QString name;
|
||||
if (!fullName.isEmpty()) {
|
||||
name = cleanupFullName(fullName);
|
||||
fileName = Utils::FilePath::fromString(name);
|
||||
fileName = fileRoot.withNewPath(name);
|
||||
//if (data->markerFileName().isEmpty())
|
||||
// data->setMarkerFileName(name);
|
||||
} else {
|
||||
@@ -367,7 +368,7 @@ void BreakpointParameters::updateFromGdbOutput(const GdbMi &bkpt)
|
||||
// gdb's own. No point in assigning markerFileName for now.
|
||||
}
|
||||
if (!name.isEmpty())
|
||||
fileName = Utils::FilePath::fromString(name);
|
||||
fileName = fileRoot.withNewPath(name);
|
||||
|
||||
if (fileName.isEmpty())
|
||||
updateLocation(originalLocation);
|
||||
|
@@ -128,7 +128,7 @@ public:
|
||||
bool isQmlFileAndLineBreakpoint() const;
|
||||
QString toString() const;
|
||||
void updateLocation(const QString &location); // file.cpp:42
|
||||
void updateFromGdbOutput(const GdbMi &bkpt);
|
||||
void updateFromGdbOutput(const GdbMi &bkpt, const Utils::FilePath &fileRoot);
|
||||
|
||||
bool operator==(const BreakpointParameters &p) const { return equals(p); }
|
||||
bool operator!=(const BreakpointParameters &p) const { return !equals(p); }
|
||||
|
@@ -901,6 +901,9 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, AllowTerminal allowTerm
|
||||
if (Project *project = runControl->project()) {
|
||||
m_runParameters.projectSourceDirectory = project->projectDirectory();
|
||||
m_runParameters.projectSourceFiles = project->files(Project::SourceFiles);
|
||||
} else {
|
||||
m_runParameters.projectSourceDirectory = m_runParameters.debugger.command.executable().parentDir();
|
||||
m_runParameters.projectSourceFiles.clear();
|
||||
}
|
||||
|
||||
m_runParameters.toolChainAbi = ToolChainKitAspect::targetAbi(kit);
|
||||
|
@@ -539,6 +539,7 @@ void GdbEngine::handleAsyncOutput(const QStringView asyncClass, const GdbMi &res
|
||||
ba.remove(pos1, pos3 - pos1 + 1);
|
||||
GdbMi res;
|
||||
res.fromString(ba);
|
||||
const FilePath &fileRoot = runParameters().projectSourceDirectory;
|
||||
BreakHandler *handler = breakHandler();
|
||||
Breakpoint bp;
|
||||
for (const GdbMi &bkpt : res) {
|
||||
@@ -547,13 +548,13 @@ void GdbEngine::handleAsyncOutput(const QStringView asyncClass, const GdbMi &res
|
||||
// A sub-breakpoint.
|
||||
QTC_ASSERT(bp, continue);
|
||||
SubBreakpoint loc = bp->findOrCreateSubBreakpoint(nr);
|
||||
loc->params.updateFromGdbOutput(bkpt);
|
||||
loc->params.updateFromGdbOutput(bkpt, fileRoot);
|
||||
loc->params.type = bp->type();
|
||||
} else {
|
||||
// A primary breakpoint.
|
||||
bp = handler->findBreakpointByResponseId(nr);
|
||||
if (bp)
|
||||
bp->updateFromGdbOutput(bkpt);
|
||||
bp->updateFromGdbOutput(bkpt, fileRoot);
|
||||
}
|
||||
}
|
||||
if (bp)
|
||||
@@ -569,7 +570,7 @@ void GdbEngine::handleAsyncOutput(const QStringView asyncClass, const GdbMi &res
|
||||
const QString nr = bkpt["number"].data();
|
||||
BreakpointParameters br;
|
||||
br.type = BreakpointByFileAndLine;
|
||||
br.updateFromGdbOutput(bkpt);
|
||||
br.updateFromGdbOutput(bkpt, runParameters().projectSourceDirectory);
|
||||
handler->handleAlienBreakpoint(nr, br);
|
||||
}
|
||||
} else if (asyncClass == u"breakpoint-deleted") {
|
||||
@@ -1028,7 +1029,7 @@ void GdbEngine::handleQuerySources(const DebuggerResponse &response)
|
||||
{
|
||||
m_sourcesListUpdating = false;
|
||||
if (response.resultClass == ResultDone) {
|
||||
QMap<QString, QString> oldShortToFull = m_shortToFullName;
|
||||
QMap<QString, FilePath> oldShortToFull = m_shortToFullName;
|
||||
m_shortToFullName.clear();
|
||||
m_fullToShortName.clear();
|
||||
// "^done,files=[{file="../../../../bin/dumper/dumper.cpp",
|
||||
@@ -1039,7 +1040,7 @@ void GdbEngine::handleQuerySources(const DebuggerResponse &response)
|
||||
continue;
|
||||
GdbMi fullName = item["fullname"];
|
||||
QString file = fileName.data();
|
||||
QString full;
|
||||
FilePath full;
|
||||
if (fullName.isValid()) {
|
||||
full = cleanupFullName(fullName.data());
|
||||
m_fullToShortName[full] = file;
|
||||
@@ -1183,7 +1184,7 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
|
||||
|
||||
const QString nr = data["bkptno"].data();
|
||||
int lineNumber = 0;
|
||||
QString fullName;
|
||||
FilePath fullName;
|
||||
QString function;
|
||||
QString language;
|
||||
if (frame.isValid()) {
|
||||
@@ -1196,15 +1197,13 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
|
||||
lineNumber = lineNumberG.toInt();
|
||||
fullName = cleanupFullName(frame["fullname"].data());
|
||||
if (fullName.isEmpty())
|
||||
fullName = frame["file"].data();
|
||||
fullName = runParameters().projectSourceDirectory.withNewPath(frame["file"].data());
|
||||
} // found line number
|
||||
} else {
|
||||
showMessage("INVALID STOPPED REASON", LogWarning);
|
||||
}
|
||||
|
||||
const FilePath onDevicePath = FilePath::fromString(fullName).onDevice(
|
||||
runParameters().debugger.command.executable());
|
||||
const FilePath fileName = onDevicePath.localSource().value_or(onDevicePath);
|
||||
const FilePath fileName = fullName.localSource().value_or(fullName);
|
||||
|
||||
if (!nr.isEmpty() && frame.isValid()) {
|
||||
// Use opportunity to update the breakpoint marker position.
|
||||
@@ -1560,50 +1559,47 @@ void GdbEngine::handleExecuteContinue(const DebuggerResponse &response)
|
||||
}
|
||||
}
|
||||
|
||||
QString GdbEngine::fullName(const QString &fileName)
|
||||
FilePath GdbEngine::fullName(const QString &fileName)
|
||||
{
|
||||
if (fileName.isEmpty())
|
||||
return QString();
|
||||
QTC_ASSERT(!m_sourcesListUpdating, /* */);
|
||||
return m_shortToFullName.value(fileName, QString());
|
||||
return {};
|
||||
QTC_CHECK(!m_sourcesListUpdating);
|
||||
return m_shortToFullName.value(fileName, {});
|
||||
}
|
||||
|
||||
QString GdbEngine::cleanupFullName(const QString &fileName)
|
||||
FilePath GdbEngine::cleanupFullName(const QString &fileName)
|
||||
{
|
||||
QString cleanFilePath = fileName;
|
||||
FilePath cleanFilePath =
|
||||
runParameters().projectSourceDirectory.withNewPath(fileName).cleanPath();
|
||||
|
||||
// Gdb running on windows often delivers "fullnames" which
|
||||
// (a) have no drive letter and (b) are not normalized.
|
||||
if (Abi::hostAbi().os() == Abi::WindowsOS) {
|
||||
if (fileName.isEmpty())
|
||||
return QString();
|
||||
QFileInfo fi(fileName);
|
||||
if (fi.isReadable())
|
||||
cleanFilePath = QDir::cleanPath(fi.absoluteFilePath());
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!debuggerSettings()->autoEnrichParameters.value())
|
||||
return cleanFilePath;
|
||||
|
||||
const QString sysroot = runParameters().sysRoot.toString();
|
||||
if (QFileInfo(cleanFilePath).isReadable())
|
||||
if (cleanFilePath.isReadableFile())
|
||||
return cleanFilePath;
|
||||
|
||||
const FilePath sysroot = runParameters().sysRoot;
|
||||
if (!sysroot.isEmpty() && fileName.startsWith('/')) {
|
||||
cleanFilePath = sysroot + fileName;
|
||||
if (QFileInfo(cleanFilePath).isReadable())
|
||||
cleanFilePath = sysroot.pathAppended(fileName.mid(1));
|
||||
if (cleanFilePath.isReadableFile())
|
||||
return cleanFilePath;
|
||||
}
|
||||
if (m_baseNameToFullName.isEmpty()) {
|
||||
FilePath filePath = FilePath::fromString(sysroot + "/usr/src/debug");
|
||||
FilePath filePath = sysroot.pathAppended("/usr/src/debug");
|
||||
|
||||
if (filePath.isDir()) {
|
||||
filePath.iterateDirectory(
|
||||
[this](const FilePath &filePath) {
|
||||
QString name = filePath.fileName();
|
||||
if (!name.startsWith('.')) {
|
||||
QString path = filePath.path();
|
||||
m_baseNameToFullName.insert(name, path);
|
||||
}
|
||||
if (!name.startsWith('.'))
|
||||
m_baseNameToFullName.insert(name, filePath);
|
||||
return IterationPolicy::Continue;
|
||||
},
|
||||
{{"*"}, QDir::NoFilter, QDirIterator::Subdirectories});
|
||||
@@ -1613,7 +1609,7 @@ QString GdbEngine::cleanupFullName(const QString &fileName)
|
||||
cleanFilePath.clear();
|
||||
const QString base = FilePath::fromUserInput(fileName).fileName();
|
||||
|
||||
QMultiMap<QString, QString>::const_iterator jt = m_baseNameToFullName.constFind(base);
|
||||
auto jt = m_baseNameToFullName.constFind(base);
|
||||
while (jt != m_baseNameToFullName.constEnd() && jt.key() == base) {
|
||||
// FIXME: Use some heuristics to find the "best" match.
|
||||
return jt.value();
|
||||
@@ -1950,7 +1946,7 @@ void GdbEngine::executeRunToLine(const ContextData &data)
|
||||
if (data.address)
|
||||
loc = addressSpec(data.address);
|
||||
else
|
||||
loc = '"' + breakLocation(data.fileName.toString()) + '"' + ':' + QString::number(data.lineNumber);
|
||||
loc = '"' + breakLocation(data.fileName) + '"' + ':' + QString::number(data.lineNumber);
|
||||
runCommand({"tbreak " + loc});
|
||||
|
||||
runCommand({"continue", NativeCommand|RunRequest, CB(handleExecuteRunToLine)});
|
||||
@@ -1978,7 +1974,7 @@ void GdbEngine::executeJumpToLine(const ContextData &data)
|
||||
if (data.address)
|
||||
loc = addressSpec(data.address);
|
||||
else
|
||||
loc = '"' + breakLocation(data.fileName.toString()) + '"' + ':' + QString::number(data.lineNumber);
|
||||
loc = '"' + breakLocation(data.fileName) + '"' + ':' + QString::number(data.lineNumber);
|
||||
runCommand({"tbreak " + loc});
|
||||
notifyInferiorRunRequested();
|
||||
|
||||
@@ -2052,11 +2048,11 @@ void GdbEngine::setTokenBarrier()
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
QString GdbEngine::breakLocation(const QString &file) const
|
||||
QString GdbEngine::breakLocation(const FilePath &file) const
|
||||
{
|
||||
QString where = m_fullToShortName.value(file);
|
||||
if (where.isEmpty())
|
||||
return FilePath::fromString(file).fileName();
|
||||
return file.fileName();
|
||||
return where;
|
||||
}
|
||||
|
||||
@@ -2080,7 +2076,7 @@ QString GdbEngine::breakpointLocation(const BreakpointParameters &data)
|
||||
usage = BreakpointUseShortPath;
|
||||
|
||||
const QString fileName = usage == BreakpointUseFullPath
|
||||
? data.fileName.toString() : breakLocation(data.fileName.toString());
|
||||
? data.fileName.path() : breakLocation(data.fileName);
|
||||
// The argument is simply a C-quoted version of the argument to the
|
||||
// non-MI "break" command, including the "original" quoting it wants.
|
||||
return "\"\\\"" + GdbMi::escapeCString(fileName) + "\\\":"
|
||||
@@ -2094,7 +2090,7 @@ QString GdbEngine::breakpointLocation2(const BreakpointParameters &data)
|
||||
usage = BreakpointUseShortPath;
|
||||
|
||||
const QString fileName = usage == BreakpointUseFullPath
|
||||
? data.fileName.toString() : breakLocation(data.fileName.toString());
|
||||
? data.fileName.path() : breakLocation(data.fileName);
|
||||
return GdbMi::escapeCString(fileName) + ':' + QString::number(data.lineNumber);
|
||||
}
|
||||
|
||||
@@ -2107,7 +2103,7 @@ void GdbEngine::handleInsertInterpreterBreakpoint(const DebuggerResponse &respon
|
||||
notifyBreakpointInsertOk(bp);
|
||||
} else {
|
||||
bp->setResponseId(response.data["number"].data());
|
||||
bp->updateFromGdbOutput(response.data);
|
||||
bp->updateFromGdbOutput(response.data, runParameters().projectSourceDirectory);
|
||||
notifyBreakpointInsertOk(bp);
|
||||
}
|
||||
}
|
||||
@@ -2117,7 +2113,7 @@ void GdbEngine::handleInterpreterBreakpointModified(const GdbMi &data)
|
||||
int modelId = data["modelid"].toInt();
|
||||
Breakpoint bp = breakHandler()->findBreakpointByModelId(modelId);
|
||||
QTC_ASSERT(bp, return);
|
||||
bp->updateFromGdbOutput(data);
|
||||
bp->updateFromGdbOutput(data, runParameters().projectSourceDirectory);
|
||||
}
|
||||
|
||||
void GdbEngine::handleWatchInsert(const DebuggerResponse &response, const Breakpoint &bp)
|
||||
@@ -2167,7 +2163,7 @@ void GdbEngine::handleBkpt(const GdbMi &bkpt, const Breakpoint &bp)
|
||||
// A sub-breakpoint.
|
||||
SubBreakpoint sub = bp->findOrCreateSubBreakpoint(nr);
|
||||
QTC_ASSERT(sub, return);
|
||||
sub->params.updateFromGdbOutput(bkpt);
|
||||
sub->params.updateFromGdbOutput(bkpt, runParameters().projectSourceDirectory);
|
||||
sub->params.type = bp->type();
|
||||
if (usePseudoTracepoints && bp->isTracepoint()) {
|
||||
sub->params.tracepoint = true;
|
||||
@@ -2185,7 +2181,7 @@ void GdbEngine::handleBkpt(const GdbMi &bkpt, const Breakpoint &bp)
|
||||
const QString subnr = location["number"].data();
|
||||
SubBreakpoint sub = bp->findOrCreateSubBreakpoint(subnr);
|
||||
QTC_ASSERT(sub, return);
|
||||
sub->params.updateFromGdbOutput(location);
|
||||
sub->params.updateFromGdbOutput(location, runParameters().projectSourceDirectory);
|
||||
sub->params.type = bp->type();
|
||||
if (usePseudoTracepoints && bp->isTracepoint()) {
|
||||
sub->params.tracepoint = true;
|
||||
@@ -2196,7 +2192,7 @@ void GdbEngine::handleBkpt(const GdbMi &bkpt, const Breakpoint &bp)
|
||||
|
||||
// A (the?) primary breakpoint.
|
||||
bp->setResponseId(nr);
|
||||
bp->updateFromGdbOutput(bkpt);
|
||||
bp->updateFromGdbOutput(bkpt, runParameters().projectSourceDirectory);
|
||||
if (usePseudoTracepoints && bp->isTracepoint())
|
||||
bp->setMessage(bp->requestedParameters().message);
|
||||
}
|
||||
@@ -2503,7 +2499,7 @@ void GdbEngine::handleTracepointModified(const GdbMi &data)
|
||||
// A sub-breakpoint.
|
||||
QTC_ASSERT(bp, continue);
|
||||
SubBreakpoint loc = bp->findOrCreateSubBreakpoint(nr);
|
||||
loc->params.updateFromGdbOutput(bkpt);
|
||||
loc->params.updateFromGdbOutput(bkpt, runParameters().projectSourceDirectory);
|
||||
loc->params.type = bp->type();
|
||||
if (bp->isTracepoint()) {
|
||||
loc->params.tracepoint = true;
|
||||
@@ -2513,7 +2509,7 @@ void GdbEngine::handleTracepointModified(const GdbMi &data)
|
||||
// A primary breakpoint.
|
||||
bp = handler->findBreakpointByResponseId(nr);
|
||||
if (bp)
|
||||
bp->updateFromGdbOutput(bkpt);
|
||||
bp->updateFromGdbOutput(bkpt, runParameters().projectSourceDirectory);
|
||||
}
|
||||
}
|
||||
QTC_ASSERT(bp, return);
|
||||
@@ -3036,7 +3032,7 @@ void GdbEngine::reloadSourceFiles()
|
||||
cmd.callback = [this](const DebuggerResponse &response) {
|
||||
m_sourcesListUpdating = false;
|
||||
if (response.resultClass == ResultDone) {
|
||||
QMap<QString, QString> oldShortToFull = m_shortToFullName;
|
||||
QMap<QString, FilePath> oldShortToFull = m_shortToFullName;
|
||||
m_shortToFullName.clear();
|
||||
m_fullToShortName.clear();
|
||||
// "^done,files=[{file="../../../../bin/dumper/dumper.cpp",
|
||||
@@ -3047,7 +3043,7 @@ void GdbEngine::reloadSourceFiles()
|
||||
continue;
|
||||
GdbMi fullName = item["fullname"];
|
||||
QString file = fileName.data();
|
||||
QString full;
|
||||
FilePath full;
|
||||
if (fullName.isValid()) {
|
||||
full = cleanupFullName(fullName.data());
|
||||
m_fullToShortName[full] = file;
|
||||
|
@@ -210,7 +210,7 @@ private: ////////// General Interface //////////
|
||||
void handleBkpt(const GdbMi &bkpt, const Breakpoint &bp);
|
||||
QString breakpointLocation(const BreakpointParameters &data); // For gdb/MI.
|
||||
QString breakpointLocation2(const BreakpointParameters &data); // For gdb/CLI fallback.
|
||||
QString breakLocation(const QString &file) const;
|
||||
QString breakLocation(const Utils::FilePath &file) const;
|
||||
void updateTracepointCaptures(const Breakpoint &bp);
|
||||
|
||||
//
|
||||
@@ -265,13 +265,13 @@ private: ////////// General Interface //////////
|
||||
void reloadSourceFilesInternal();
|
||||
void handleQuerySources(const DebuggerResponse &response);
|
||||
|
||||
QString fullName(const QString &fileName);
|
||||
QString cleanupFullName(const QString &fileName);
|
||||
Utils::FilePath fullName(const QString &fileName);
|
||||
Utils::FilePath cleanupFullName(const QString &fileName);
|
||||
|
||||
// awful hack to keep track of used files
|
||||
QMap<QString, QString> m_shortToFullName;
|
||||
QMap<QString, QString> m_fullToShortName;
|
||||
QMultiMap<QString, QString> m_baseNameToFullName;
|
||||
QMap<QString, Utils::FilePath> m_shortToFullName;
|
||||
QMap<Utils::FilePath, QString> m_fullToShortName;
|
||||
QMultiMap<QString, Utils::FilePath> m_baseNameToFullName;
|
||||
|
||||
bool m_sourcesListUpdating = false;
|
||||
|
||||
|
@@ -1802,10 +1802,10 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data)
|
||||
updateScriptSource(name, lineOffset, columnOffset, source);
|
||||
}
|
||||
|
||||
QMap<QString,QString> files;
|
||||
QMap<QString, FilePath> files;
|
||||
for (const QString &file : std::as_const(sourceFiles)) {
|
||||
QString shortName = file;
|
||||
QString fullName = engine->toFileInProject(file);
|
||||
FilePath fullName = engine->toFileInProject(file);
|
||||
files.insert(shortName, fullName);
|
||||
}
|
||||
|
||||
@@ -1915,7 +1915,7 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data)
|
||||
|
||||
const QVariantMap script = body.value("script").toMap();
|
||||
QUrl fileUrl(script.value(NAME).toString());
|
||||
QString filePath = engine->toFileInProject(fileUrl);
|
||||
FilePath filePath = engine->toFileInProject(fileUrl);
|
||||
|
||||
const QVariantMap exception = body.value("exception").toMap();
|
||||
QString errorMessage = exception.value("text").toString();
|
||||
@@ -2045,8 +2045,7 @@ StackFrame QmlEnginePrivate::extractStackFrame(const QVariant &bodyVal)
|
||||
stackFrame.function = extractString(body.value("func"));
|
||||
if (stackFrame.function.isEmpty())
|
||||
stackFrame.function = Tr::tr("Anonymous Function");
|
||||
stackFrame.file = FilePath::fromString(
|
||||
engine->toFileInProject(extractString(body.value("script"))));
|
||||
stackFrame.file = engine->toFileInProject(extractString(body.value("script")));
|
||||
stackFrame.usable = stackFrame.file.isReadableFile();
|
||||
stackFrame.receiver = extractString(body.value("receiver"));
|
||||
stackFrame.line = body.value("line").toInt() + 1;
|
||||
@@ -2444,7 +2443,7 @@ void QmlEnginePrivate::flushSendBuffer()
|
||||
sendBuffer.clear();
|
||||
}
|
||||
|
||||
QString QmlEngine::toFileInProject(const QUrl &fileUrl)
|
||||
FilePath QmlEngine::toFileInProject(const QUrl &fileUrl)
|
||||
{
|
||||
// make sure file finder is properly initialized
|
||||
const DebuggerRunParameters &rp = runParameters();
|
||||
@@ -2453,7 +2452,7 @@ QString QmlEngine::toFileInProject(const QUrl &fileUrl)
|
||||
d->fileFinder.setAdditionalSearchDirectories(rp.additionalSearchDirectories);
|
||||
d->fileFinder.setSysroot(rp.sysRoot);
|
||||
|
||||
return d->fileFinder.findFile(fileUrl).constFirst().toString();
|
||||
return d->fileFinder.findFile(fileUrl).constFirst();
|
||||
}
|
||||
|
||||
DebuggerEngine *createQmlEngine()
|
||||
|
@@ -25,7 +25,7 @@ public:
|
||||
void logServiceActivity(const QString &service, const QString &logMessage);
|
||||
|
||||
void expressionEvaluated(quint32 queryId, const QVariant &result);
|
||||
QString toFileInProject(const QUrl &fileUrl);
|
||||
Utils::FilePath toFileInProject(const QUrl &fileUrl);
|
||||
|
||||
private:
|
||||
void disconnected();
|
||||
|
@@ -20,6 +20,7 @@ using namespace QmlDebug;
|
||||
using namespace QmlJS;
|
||||
using namespace QmlJS::AST;
|
||||
using namespace TextEditor;
|
||||
using namespace Utils;
|
||||
|
||||
namespace Debugger::Internal {
|
||||
|
||||
@@ -218,11 +219,10 @@ void clearExceptionSelection()
|
||||
}
|
||||
}
|
||||
|
||||
QStringList highlightExceptionCode(int lineNumber, const QString &filePath, const QString &errorMessage)
|
||||
QStringList highlightExceptionCode(int lineNumber, const FilePath &filePath, const QString &errorMessage)
|
||||
{
|
||||
QStringList messages;
|
||||
const QList<IEditor *> editors = DocumentModel::editorsForFilePath(
|
||||
Utils::FilePath::fromString(filePath));
|
||||
const QList<IEditor *> editors = DocumentModel::editorsForFilePath(filePath);
|
||||
|
||||
const TextEditor::FontSettings &fontSettings = TextEditor::TextEditorSettings::fontSettings();
|
||||
QTextCharFormat errorFormat = fontSettings.toTextCharFormat(TextEditor::C_ERROR);
|
||||
@@ -251,7 +251,7 @@ QStringList highlightExceptionCode(int lineNumber, const QString &filePath, cons
|
||||
selections.append(sel);
|
||||
ed->setExtraSelections(TextEditorWidget::DebuggerExceptionSelection, selections);
|
||||
|
||||
messages.append(QString::fromLatin1("%1: %2: %3").arg(filePath).arg(lineNumber).arg(errorMessage));
|
||||
messages.append(QString::fromLatin1("%1: %2: %3").arg(filePath.toUserOutput()).arg(lineNumber).arg(errorMessage));
|
||||
}
|
||||
return messages;
|
||||
}
|
||||
|
@@ -6,11 +6,13 @@
|
||||
#include <qmldebug/qdebugmessageclient.h>
|
||||
#include <qmldebug/qmloutputparser.h>
|
||||
|
||||
namespace Utils { class FilePath; }
|
||||
|
||||
namespace Debugger::Internal {
|
||||
|
||||
void appendDebugOutput(QtMsgType type, const QString &message, const QmlDebug::QDebugContextInfo &info);
|
||||
|
||||
void clearExceptionSelection();
|
||||
QStringList highlightExceptionCode(int lineNumber, const QString &filePath, const QString &errorMessage);
|
||||
QStringList highlightExceptionCode(int lineNumber, const Utils::FilePath &filePath, const QString &errorMessage);
|
||||
|
||||
} // Debugger::Internal
|
||||
|
@@ -32,6 +32,7 @@
|
||||
|
||||
using namespace QmlDebug;
|
||||
using namespace QmlDebug::Constants;
|
||||
using namespace Utils;
|
||||
|
||||
namespace Debugger::Internal {
|
||||
|
||||
@@ -541,8 +542,8 @@ void QmlInspectorAgent::buildDebugIdHashRecursive(const ObjectReference &ref)
|
||||
lineNum += match.captured(3).toInt() - 1;
|
||||
}
|
||||
|
||||
const QString filePath = m_qmlEngine->toFileInProject(fileUrl);
|
||||
m_debugIdLocations.insert(ref.debugId(), FileReference(filePath, lineNum, colNum));
|
||||
const FilePath filePath = m_qmlEngine->toFileInProject(fileUrl);
|
||||
m_debugIdLocations.insert(ref.debugId(), FileReference(filePath.toFSPathString(), lineNum, colNum));
|
||||
|
||||
const auto children = ref.children();
|
||||
for (const ObjectReference &it : children)
|
||||
@@ -735,7 +736,7 @@ void QmlInspectorAgent::onShowAppOnTopChanged(bool checked)
|
||||
|
||||
void QmlInspectorAgent::jumpToObjectDefinitionInEditor(const FileReference &objSource)
|
||||
{
|
||||
const auto filePath = Utils::FilePath::fromString(m_qmlEngine->toFileInProject(objSource.url()));
|
||||
const FilePath filePath = m_qmlEngine->toFileInProject(objSource.url());
|
||||
Core::EditorManager::openEditorAt({filePath, objSource.lineNumber()});
|
||||
}
|
||||
|
||||
|
@@ -55,8 +55,8 @@ Qt::ItemFlags SourceFilesHandler::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (index.row() >= m_fullNames.size())
|
||||
return {};
|
||||
QFileInfo fi(m_fullNames.at(index.row()));
|
||||
return fi.isReadable() ? QAbstractItemModel::flags(index) : Qt::ItemFlags({});
|
||||
FilePath filePath = m_fullNames.at(index.row());
|
||||
return filePath.isReadableFile() ? QAbstractItemModel::flags(index) : Qt::ItemFlags({});
|
||||
}
|
||||
|
||||
QVariant SourceFilesHandler::data(const QModelIndex &index, int role) const
|
||||
@@ -75,7 +75,7 @@ QVariant SourceFilesHandler::data(const QModelIndex &index, int role) const
|
||||
break;
|
||||
case 1:
|
||||
if (role == Qt::DisplayRole)
|
||||
return m_fullNames.at(row);
|
||||
return m_fullNames.at(row).toUserOutput();
|
||||
//if (role == Qt::DecorationRole)
|
||||
// return module.symbolsRead ? icon2 : icon;
|
||||
break;
|
||||
@@ -123,13 +123,13 @@ bool SourceFilesHandler::setData(const QModelIndex &idx, const QVariant &data, i
|
||||
return false;
|
||||
}
|
||||
|
||||
void SourceFilesHandler::setSourceFiles(const QMap<QString, QString> &sourceFiles)
|
||||
void SourceFilesHandler::setSourceFiles(const QMap<QString, FilePath> &sourceFiles)
|
||||
{
|
||||
beginResetModel();
|
||||
m_shortNames.clear();
|
||||
m_fullNames.clear();
|
||||
QMap<QString, QString>::ConstIterator it = sourceFiles.begin();
|
||||
QMap<QString, QString>::ConstIterator et = sourceFiles.end();
|
||||
auto it = sourceFiles.begin();
|
||||
const auto et = sourceFiles.end();
|
||||
for (; it != et; ++it) {
|
||||
m_shortNames.append(it.key());
|
||||
m_fullNames.append(it.value());
|
||||
@@ -139,7 +139,7 @@ void SourceFilesHandler::setSourceFiles(const QMap<QString, QString> &sourceFile
|
||||
|
||||
void SourceFilesHandler::removeAll()
|
||||
{
|
||||
setSourceFiles(QMap<QString, QString>());
|
||||
setSourceFiles({});
|
||||
//header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
||||
}
|
||||
|
||||
|
@@ -3,6 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utils/filepath.h>
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QStringList>
|
||||
|
||||
@@ -29,7 +31,7 @@ public:
|
||||
|
||||
void clearModel();
|
||||
|
||||
void setSourceFiles(const QMap<QString, QString> &sourceFiles);
|
||||
void setSourceFiles(const QMap<QString, Utils::FilePath> &sourceFiles);
|
||||
void removeAll();
|
||||
|
||||
QAbstractItemModel *model() { return m_proxyModel; }
|
||||
@@ -37,7 +39,7 @@ public:
|
||||
private:
|
||||
DebuggerEngine *m_engine;
|
||||
QStringList m_shortNames;
|
||||
QStringList m_fullNames;
|
||||
Utils::FilePaths m_fullNames;
|
||||
QAbstractItemModel *m_proxyModel;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user