Debugger: make BreakpointParameters::fileName a Utils::FilePath

Task-number: QTCREATORBUG-23339
Change-Id: Ifc497c14589cd6df10d8219533e100f1919213b3
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
David Schulz
2020-01-02 11:31:14 +01:00
parent 1291755288
commit a7dd0e50a2
14 changed files with 105 additions and 112 deletions

View File

@@ -110,9 +110,9 @@ public:
{ {
TextMark::updateFileName(fileName); TextMark::updateFileName(fileName);
QTC_ASSERT(m_bp, return); QTC_ASSERT(m_bp, return);
m_bp->setFileName(fileName.toString()); m_bp->setFileName(fileName);
if (GlobalBreakpoint gbp = m_bp->globalBreakpoint()) if (GlobalBreakpoint gbp = m_bp->globalBreakpoint())
gbp->m_params.fileName = fileName.toString(); gbp->m_params.fileName = fileName;
} }
bool isDraggable() const final { return true; } bool isDraggable() const final { return true; }
@@ -666,7 +666,7 @@ void BreakpointDialog::getParts(unsigned partsMask, BreakpointParameters *data)
if (partsMask & FileAndLinePart) { if (partsMask & FileAndLinePart) {
data->lineNumber = m_lineEditLineNumber->text().toInt(); data->lineNumber = m_lineEditLineNumber->text().toInt();
data->pathUsage = static_cast<BreakpointPathUsage>(m_comboBoxPathUsage->currentIndex()); data->pathUsage = static_cast<BreakpointPathUsage>(m_comboBoxPathUsage->currentIndex());
data->fileName = m_pathChooserFileName->path(); data->fileName = FilePath::fromUserInput(m_pathChooserFileName->path());
} }
if (partsMask & FunctionPart) if (partsMask & FunctionPart)
data->functionName = m_lineEditFunction->text(); data->functionName = m_lineEditFunction->text();
@@ -703,7 +703,7 @@ void BreakpointDialog::setParts(unsigned mask, const BreakpointParameters &data)
m_lineEditMessage->setText(data.message); m_lineEditMessage->setText(data.message);
if (mask & FileAndLinePart) { if (mask & FileAndLinePart) {
m_pathChooserFileName->setPath(data.fileName); m_pathChooserFileName->setFileName(data.fileName);
m_lineEditLineNumber->setText(QString::number(data.lineNumber)); m_lineEditLineNumber->setText(QString::number(data.lineNumber));
} }
@@ -911,17 +911,9 @@ BreakHandler::BreakHandler(DebuggerEngine *engine)
tr("Condition"), tr("Ignore"), tr("Threads")}); tr("Condition"), tr("Ignore"), tr("Threads")});
} }
static inline bool fileNameMatch(const QString &f1, const QString &f2) bool BreakpointParameters::isLocatedAt(const FilePath &file, int line, const FilePath &markerFile) const
{ {
if (HostOsInfo::fileNameCaseSensitivity() == Qt::CaseInsensitive) return lineNumber == line && (fileName == file || fileName == markerFile);
return f1.compare(f2, Qt::CaseInsensitive) == 0;
return f1 == f2;
}
bool BreakpointParameters::isLocatedAt(const QString &file, int line, const QString &markerFile) const
{
return lineNumber == line
&& (fileNameMatch(fileName, file) || fileNameMatch(fileName, markerFile));
} }
static bool isSimilarTo(const BreakpointParameters &params, const BreakpointParameters &needle) static bool isSimilarTo(const BreakpointParameters &params, const BreakpointParameters &needle)
@@ -942,7 +934,7 @@ static bool isSimilarTo(const BreakpointParameters &params, const BreakpointPara
// At least at a position we were looking for. // At least at a position we were looking for.
// FIXME: breaks multiple breakpoints at the same location // FIXME: breaks multiple breakpoints at the same location
if (!params.fileName.isEmpty() if (!params.fileName.isEmpty()
&& fileNameMatch(params.fileName, needle.fileName) && params.fileName == needle.fileName
&& params.lineNumber == needle.lineNumber) && params.lineNumber == needle.lineNumber)
return true; return true;
@@ -1085,12 +1077,8 @@ QVariant BreakpointItem::data(int column, int role) const
} }
break; break;
case BreakpointFileColumn: case BreakpointFileColumn:
if (role == Qt::DisplayRole) { if (role == Qt::DisplayRole)
const QString str = markerFileName(); return markerFileName().toUserOutput();
if (!str.isEmpty())
return QDir::toNativeSeparators(str);
return empty;
}
break; break;
case BreakpointLineColumn: case BreakpointLineColumn:
if (role == Qt::DisplayRole) { if (role == Qt::DisplayRole) {
@@ -1223,7 +1211,7 @@ void BreakHandler::requestSubBreakpointEnabling(const SubBreakpoint &sbp, bool e
} }
} }
void BreakpointItem::setMarkerFileAndLine(const QString &fileName, int lineNumber) void BreakpointItem::setMarkerFileAndLine(const FilePath &fileName, int lineNumber)
{ {
if (m_parameters.fileName == fileName && m_parameters.lineNumber == lineNumber) if (m_parameters.fileName == fileName && m_parameters.lineNumber == lineNumber)
return; return;
@@ -1471,8 +1459,7 @@ void BreakHandler::gotoLocation(const Breakpoint &bp) const
// Don't use gotoLocation unconditionally as this ends up in // Don't use gotoLocation unconditionally as this ends up in
// disassembly if OperateByInstruction is on. But fallback // disassembly if OperateByInstruction is on. But fallback
// to disassembly if we can't open the file. // to disassembly if we can't open the file.
const QString file = QDir::cleanPath(bp->markerFileName()); if (IEditor *editor = EditorManager::openEditor(bp->markerFileName().toString()))
if (IEditor *editor = EditorManager::openEditor(file))
editor->gotoLine(bp->markerLineNumber(), 0); editor->gotoLine(bp->markerLineNumber(), 0);
else else
m_engine->openDisassemblerView(Location(bp->m_parameters.address)); m_engine->openDisassemblerView(Location(bp->m_parameters.address));
@@ -1805,20 +1792,21 @@ void BreakpointItem::destroyMarker()
} }
} }
QString BreakpointItem::markerFileName() const FilePath BreakpointItem::markerFileName() const
{ {
// Some heuristics to find a "good" file name. // Some heuristics to find a "good" file name.
if (!m_parameters.fileName.isEmpty()) { if (!m_parameters.fileName.exists())
QFileInfo fi(m_parameters.fileName); return FilePath::fromString(m_parameters.fileName.toFileInfo().absolutePath());
if (fi.exists())
return fi.absoluteFilePath(); const FilePath origFileName = requestedParameters().fileName;
} if (m_parameters.fileName.endsWith(origFileName.fileName()))
const QString origFileName = requestedParameters().fileName;
if (m_parameters.fileName.endsWith(origFileName))
return m_parameters.fileName; return m_parameters.fileName;
if (origFileName.endsWith(m_parameters.fileName)) if (origFileName.endsWith(m_parameters.fileName.fileName()))
return origFileName; return origFileName;
return m_parameters.fileName.size() > origFileName ? m_parameters.fileName : origFileName;
return m_parameters.fileName.toString().size() > origFileName.toString().size()
? m_parameters.fileName
: origFileName;
} }
int BreakpointItem::markerLineNumber() const int BreakpointItem::markerLineNumber() const
@@ -1876,7 +1864,7 @@ void BreakpointItem::updateMarkerIcon()
void BreakpointItem::updateMarker() void BreakpointItem::updateMarker()
{ {
FilePath file = FilePath::fromString(markerFileName()); const FilePath &file = markerFileName();
int line = markerLineNumber(); int line = markerLineNumber();
if (m_marker && (file != m_marker->fileName() || line != m_marker->lineNumber())) if (m_marker && (file != m_marker->fileName() || line != m_marker->lineNumber()))
destroyMarker(); destroyMarker();
@@ -1922,7 +1910,7 @@ QString BreakpointItem::toolTip() const
str << "<tr><td>" << tr("Breakpoint Type:") str << "<tr><td>" << tr("Breakpoint Type:")
<< "</td><td>" << typeToString(requested.type) << "</td></tr>" << "</td><td>" << typeToString(requested.type) << "</td></tr>"
<< "<tr><td>" << tr("Marker File:") << "<tr><td>" << tr("Marker File:")
<< "</td><td>" << QDir::toNativeSeparators(markerFileName()) << "</td></tr>" << "</td><td>" << markerFileName().toUserOutput() << "</td></tr>"
<< "<tr><td>" << tr("Marker Line:") << "<tr><td>" << tr("Marker Line:")
<< "</td><td>" << markerLineNumber() << "</td></tr>" << "</td><td>" << markerLineNumber() << "</td></tr>"
<< "<tr><td>" << tr("Hit Count:") << "<tr><td>" << tr("Hit Count:")
@@ -1943,8 +1931,8 @@ QString BreakpointItem::toolTip() const
} }
if (m_parameters.type == BreakpointByFileAndLine) { if (m_parameters.type == BreakpointByFileAndLine) {
str << "<tr><td>" << tr("File Name:") str << "<tr><td>" << tr("File Name:")
<< "</td><td>" << QDir::toNativeSeparators(requested.fileName) << "</td><td>" << requested.fileName.toUserOutput()
<< "</td><td>" << QDir::toNativeSeparators(m_parameters.fileName) << "</td><td>" << m_parameters.fileName.toUserOutput()
<< "</td></tr>" << "</td></tr>"
<< "<tr><td>" << tr("Line Number:") << "<tr><td>" << tr("Line Number:")
<< "</td><td>" << requested.lineNumber << "</td><td>" << requested.lineNumber
@@ -2153,12 +2141,8 @@ QVariant GlobalBreakpointItem::data(int column, int role) const
} }
break; break;
case BreakpointFileColumn: case BreakpointFileColumn:
if (role == Qt::DisplayRole) { if (role == Qt::DisplayRole)
QString str = m_params.fileName; return m_params.fileName.toUserOutput();
if (!str.isEmpty())
return QDir::toNativeSeparators(str);
return empty;
}
break; break;
case BreakpointLineColumn: case BreakpointLineColumn:
if (role == Qt::DisplayRole) { if (role == Qt::DisplayRole) {
@@ -2277,21 +2261,17 @@ void GlobalBreakpointItem::updateLineNumber(int lineNumber)
void GlobalBreakpointItem::updateFileName(const FilePath &fileName) void GlobalBreakpointItem::updateFileName(const FilePath &fileName)
{ {
const QString &file = fileName.toString(); if (m_params.fileName == fileName)
if (m_params.fileName == file)
return; return;
m_params.fileName = file; m_params.fileName = fileName;
update(); update();
} }
QString GlobalBreakpointItem::markerFileName() const FilePath GlobalBreakpointItem::markerFileName() const
{ {
// Some heuristics to find a "good" file name. // Some heuristics to find a "good" file name.
if (!m_params.fileName.isEmpty()) { if (!m_params.fileName.exists())
QFileInfo fi(m_params.fileName); return FilePath::fromString(m_params.fileName.toFileInfo().absoluteFilePath());
if (fi.exists())
return fi.absoluteFilePath();
}
return m_params.fileName; return m_params.fileName;
} }
@@ -2317,15 +2297,14 @@ void GlobalBreakpointItem::updateMarker()
return; return;
} }
const FilePath file = FilePath::fromString(m_params.fileName);
const int line = m_params.lineNumber; const int line = m_params.lineNumber;
if (m_marker) { if (m_marker) {
if (file != m_marker->fileName()) if (m_params.fileName != m_marker->fileName())
m_marker->updateFileName(file); m_marker->updateFileName(m_params.fileName);
if (line != m_marker->lineNumber()) if (line != m_marker->lineNumber())
m_marker->move(line); m_marker->move(line);
} else if (!file.isEmpty() && line > 0) { } else if (!m_params.fileName.isEmpty() && line > 0) {
m_marker = new GlobalBreakpointMarker(this, file, line); m_marker = new GlobalBreakpointMarker(this, m_params.fileName, line);
} }
if (m_marker) if (m_marker)
@@ -2375,7 +2354,7 @@ QString GlobalBreakpointItem::toolTip() const
} }
if (m_params.type == BreakpointByFileAndLine) { if (m_params.type == BreakpointByFileAndLine) {
str << "<tr><td>" << BreakpointItem::tr("File Name:") str << "<tr><td>" << BreakpointItem::tr("File Name:")
<< "</td><td>" << QDir::toNativeSeparators(m_params.fileName) << "</td><td>" << m_params.fileName.toUserOutput()
<< "</td></tr>" << "</td></tr>"
<< "<tr><td>" << BreakpointItem::tr("Line Number:") << "<tr><td>" << BreakpointItem::tr("Line Number:")
<< "</td><td>" << m_params.lineNumber; << "</td><td>" << m_params.lineNumber;
@@ -2509,7 +2488,7 @@ GlobalBreakpoint BreakpointManager::findBreakpointFromContext(const ContextData
GlobalBreakpoint bestMatch; GlobalBreakpoint bestMatch;
theBreakpointManager->forItemsAtLevel<1>([&](const GlobalBreakpoint &gbp) { theBreakpointManager->forItemsAtLevel<1>([&](const GlobalBreakpoint &gbp) {
if (location.type == LocationByFile) { if (location.type == LocationByFile) {
if (gbp->m_params.isLocatedAt(location.fileName, location.lineNumber, QString())) { if (gbp->m_params.isLocatedAt(location.fileName, location.lineNumber, FilePath())) {
matchLevel = 2; matchLevel = 2;
bestMatch = gbp; bestMatch = gbp;
} else if (matchLevel < 2) { } else if (matchLevel < 2) {
@@ -2517,7 +2496,7 @@ GlobalBreakpoint BreakpointManager::findBreakpointFromContext(const ContextData
BreakHandler *handler = engine->breakHandler(); BreakHandler *handler = engine->breakHandler();
for (Breakpoint bp : handler->breakpoints()) { for (Breakpoint bp : handler->breakpoints()) {
if (bp->globalBreakpoint() == gbp) { if (bp->globalBreakpoint() == gbp) {
if (fileNameMatch(bp->fileName(), location.fileName) if (bp->fileName() == location.fileName
&& bp->lineNumber() == location.lineNumber) { && bp->lineNumber() == location.lineNumber) {
matchLevel = 1; matchLevel = 1;
bestMatch = gbp; bestMatch = gbp;
@@ -2649,15 +2628,16 @@ bool BreakpointManager::contextMenuEvent(const ItemViewEvent &ev)
// Delete by file: Find indices of breakpoints of the same file. // Delete by file: Find indices of breakpoints of the same file.
GlobalBreakpoints breakpointsInFile; GlobalBreakpoints breakpointsInFile;
QString file; FilePath file;
if (GlobalBreakpoint gbp = itemForIndexAtLevel<1>(ev.sourceModelIndex())) { if (GlobalBreakpoint gbp = itemForIndexAtLevel<1>(ev.sourceModelIndex())) {
file = gbp->markerFileName();
if (!file.isEmpty()) { if (!file.isEmpty()) {
for (int i = 0; i != rowCount(); ++i) for (int i = 0; i != rowCount(); ++i)
if (gbp->markerFileName() == file) if (gbp->markerFileName() == file)
breakpointsInFile.append(gbp); breakpointsInFile.append(gbp);
} }
} }
addAction(menu, tr("Delete Breakpoints of \"%1\"").arg(file), addAction(menu, tr("Delete Breakpoints of \"%1\"").arg(file.toUserOutput()),
tr("Delete Breakpoints of File"), tr("Delete Breakpoints of File"),
breakpointsInFile.size() > 1, breakpointsInFile.size() > 1,
[breakpointsInFile] { [breakpointsInFile] {
@@ -2679,8 +2659,7 @@ bool BreakpointManager::contextMenuEvent(const ItemViewEvent &ev)
void BreakpointManager::gotoLocation(const GlobalBreakpoint &gbp) const void BreakpointManager::gotoLocation(const GlobalBreakpoint &gbp) const
{ {
QTC_ASSERT(gbp, return); QTC_ASSERT(gbp, return);
const QString file = QDir::cleanPath(gbp->markerFileName()); if (IEditor *editor = EditorManager::openEditor(gbp->markerFileName().toString()))
if (IEditor *editor = EditorManager::openEditor(file))
editor->gotoLine(gbp->markerLineNumber(), 0); editor->gotoLine(gbp->markerLineNumber(), 0);
} }
@@ -2762,7 +2741,7 @@ void BreakpointManager::saveSessionData()
if (params.type != BreakpointByFileAndLine) if (params.type != BreakpointByFileAndLine)
map.insert("type", params.type); map.insert("type", params.type);
if (!params.fileName.isEmpty()) if (!params.fileName.isEmpty())
map.insert("filename", params.fileName); map.insert("filename", params.fileName.toVariant());
if (params.lineNumber) if (params.lineNumber)
map.insert("linenumber", params.lineNumber); map.insert("linenumber", params.lineNumber);
if (!params.functionName.isEmpty()) if (!params.functionName.isEmpty())
@@ -2807,7 +2786,7 @@ void BreakpointManager::loadSessionData()
BreakpointParameters params(BreakpointByFileAndLine); BreakpointParameters params(BreakpointByFileAndLine);
QVariant v = map.value("filename"); QVariant v = map.value("filename");
if (v.isValid()) if (v.isValid())
params.fileName = v.toString(); params.fileName = FilePath::fromVariant(v);
v = map.value("linenumber"); v = map.value("linenumber");
if (v.isValid()) if (v.isValid())
params.lineNumber = v.toString().toInt(); params.lineNumber = v.toString().toInt();

View File

@@ -79,7 +79,7 @@ public:
void updateFileName(const Utils::FilePath &fileName); void updateFileName(const Utils::FilePath &fileName);
QString displayName() const; QString displayName() const;
QString markerFileName() const; Utils::FilePath markerFileName() const;
QString toolTip() const; QString toolTip() const;
int markerLineNumber() const; int markerLineNumber() const;
int modelId() const; int modelId() const;
@@ -122,11 +122,11 @@ public:
QIcon icon() const; QIcon icon() const;
void setMarkerFileAndLine(const QString &fileName, int lineNumber); void setMarkerFileAndLine(const Utils::FilePath &fileName, int lineNumber);
bool needsChange() const; bool needsChange() const;
SubBreakpoint findOrCreateSubBreakpoint(const QString &responseId); SubBreakpoint findOrCreateSubBreakpoint(const QString &responseId);
QString markerFileName() const; Utils::FilePath markerFileName() const;
int markerLineNumber() const; int markerLineNumber() const;
const BreakpointParameters &requestedParameters() const; const BreakpointParameters &requestedParameters() const;
@@ -146,7 +146,7 @@ public:
QString condition() const { return m_parameters.condition; } QString condition() const { return m_parameters.condition; }
int ignoreCount() const { return m_parameters.ignoreCount; } int ignoreCount() const { return m_parameters.ignoreCount; }
int threadSpec() const { return m_parameters.threadSpec; } int threadSpec() const { return m_parameters.threadSpec; }
QString fileName() const { return m_parameters.fileName; } Utils::FilePath fileName() const { return m_parameters.fileName; }
QString functionName() const { return m_parameters.functionName; } QString functionName() const { return m_parameters.functionName; }
QString expression() const { return m_parameters.expression; } QString expression() const { return m_parameters.expression; }
QString message() const { return m_parameters.message; } QString message() const { return m_parameters.message; }
@@ -160,7 +160,7 @@ public:
bool isPending() const { return m_parameters.pending; } bool isPending() const { return m_parameters.pending; }
void setLineNumber(int lineNumber) { m_parameters.lineNumber = lineNumber; } void setLineNumber(int lineNumber) { m_parameters.lineNumber = lineNumber; }
void setFileName(const QString &fileName) { m_parameters.fileName = fileName; } void setFileName(const Utils::FilePath &fileName) { m_parameters.fileName = fileName; }
void setFunctionName(const QString &functionName) { m_parameters.functionName = functionName; } void setFunctionName(const QString &functionName) { m_parameters.functionName = functionName; }
void setPending(bool pending); void setPending(bool pending);
void setResponseId(const QString &str) { m_responseId = str; } void setResponseId(const QString &str) { m_responseId = str; }

View File

@@ -142,7 +142,7 @@ void BreakpointParameters::updateLocation(const QString &location)
file = file.mid(1, file.size() - 2); file = file.mid(1, file.size() - 2);
QFileInfo fi(file); QFileInfo fi(file);
if (fi.isReadable()) if (fi.isReadable())
fileName = fi.absoluteFilePath(); fileName = Utils::FilePath::fromFileInfo(fi);
} }
} }
@@ -156,8 +156,9 @@ bool BreakpointParameters::isQmlFileAndLineBreakpoint() const
qmlExtensionString = ".qml;.js"; qmlExtensionString = ".qml;.js";
const auto qmlFileExtensions = qmlExtensionString.splitRef(';', QString::SkipEmptyParts); const auto qmlFileExtensions = qmlExtensionString.splitRef(';', QString::SkipEmptyParts);
const QString file = fileName.toString();
for (const QStringRef &extension : qmlFileExtensions) { for (const QStringRef &extension : qmlFileExtensions) {
if (fileName.endsWith(extension, Qt::CaseInsensitive)) if (file.endsWith(extension, Qt::CaseInsensitive))
return true; return true;
} }
return false; return false;
@@ -377,7 +378,6 @@ void BreakpointParameters::updateFromGdbOutput(const GdbMi &bkpt)
QString name; QString name;
if (!fullName.isEmpty()) { if (!fullName.isEmpty()) {
name = cleanupFullName(fullName); name = cleanupFullName(fullName);
fileName = name;
//if (data->markerFileName().isEmpty()) //if (data->markerFileName().isEmpty())
// data->setMarkerFileName(name); // data->setMarkerFileName(name);
} else { } else {
@@ -386,7 +386,7 @@ void BreakpointParameters::updateFromGdbOutput(const GdbMi &bkpt)
// gdb's own. No point in assigning markerFileName for now. // gdb's own. No point in assigning markerFileName for now.
} }
if (!name.isEmpty()) if (!name.isEmpty())
fileName = name; fileName = Utils::FilePath::fromString(name);
if (fileName.isEmpty()) if (fileName.isEmpty())
updateLocation(originalLocation); updateLocation(originalLocation);

View File

@@ -28,6 +28,8 @@
#include <QMetaType> #include <QMetaType>
#include <QString> #include <QString>
#include <utils/fileutils.h>
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
@@ -140,7 +142,7 @@ public:
bool conditionsMatch(const QString &other) const; bool conditionsMatch(const QString &other) const;
bool isWatchpoint() const bool isWatchpoint() const
{ return type == WatchpointAtAddress || type == WatchpointAtExpression; } { return type == WatchpointAtAddress || type == WatchpointAtExpression; }
bool isLocatedAt(const QString &fileName, int lineNumber, const QString &markerFileName) const; bool isLocatedAt(const Utils::FilePath &file, int line, const Utils::FilePath &markerFile) const;
// Enough for now. // Enough for now.
bool isBreakpoint() const { return !isWatchpoint() && !isTracepoint(); } bool isBreakpoint() const { return !isWatchpoint() && !isTracepoint(); }
bool isTracepoint() const { return tracepoint; } bool isTracepoint() const { return tracepoint; }
@@ -156,7 +158,7 @@ public:
BreakpointType type; //!< Type of breakpoint. BreakpointType type; //!< Type of breakpoint.
bool enabled; //!< Should we talk to the debugger engine? bool enabled; //!< Should we talk to the debugger engine?
BreakpointPathUsage pathUsage; //!< Should we use the full path when setting the bp? BreakpointPathUsage pathUsage; //!< Should we use the full path when setting the bp?
QString fileName; //!< Short name of source file. Utils::FilePath fileName;//!< Short name of source file.
QString condition; //!< Condition associated with breakpoint. QString condition; //!< Condition associated with breakpoint.
int ignoreCount; //!< Ignore count associated with breakpoint. int ignoreCount; //!< Ignore count associated with breakpoint.
int lineNumber; //!< Line in source file. int lineNumber; //!< Line in source file.

View File

@@ -879,7 +879,7 @@ void CdbEngine::executeJumpToLine(const ContextData &data)
// Jump to source line: Resolve source line address and go to that location // Jump to source line: Resolve source line address and go to that location
QString cmd; QString cmd;
StringInputStream str(cmd); StringInputStream str(cmd);
str << "? `" << QDir::toNativeSeparators(data.fileName) << ':' << data.lineNumber << '`'; str << "? `" << data.fileName.toUserOutput() << ':' << data.lineNumber << '`';
runCommand({cmd, BuiltinCommand, [this, data](const DebuggerResponse &r) { runCommand({cmd, BuiltinCommand, [this, data](const DebuggerResponse &r) {
handleJumpToLineAddressResolution(r, data); }}); handleJumpToLineAddressResolution(r, data); }});
} }
@@ -916,7 +916,7 @@ void CdbEngine::handleJumpToLineAddressResolution(const DebuggerResponse &respon
const quint64 address = answer.toULongLong(&ok, 16); const quint64 address = answer.toULongLong(&ok, 16);
if (ok && address) { if (ok && address) {
jumpToAddress(address); jumpToAddress(address);
gotoLocation(Location(context.fileName, context.lineNumber)); gotoLocation(Location(context.fileName.toString(), context.lineNumber));
} }
} }
@@ -2449,8 +2449,8 @@ void CdbEngine::insertBreakpoint(const Breakpoint &bp)
if (!m_autoBreakPointCorrection if (!m_autoBreakPointCorrection
&& parameters.type == BreakpointByFileAndLine && parameters.type == BreakpointByFileAndLine
&& boolSetting(CdbBreakPointCorrection)) { && boolSetting(CdbBreakPointCorrection)) {
response.lineNumber = int(lineCorrection->fixLineNumber( response.lineNumber = int(lineCorrection->fixLineNumber(parameters.fileName.toString(),
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});
} else { } else {

View File

@@ -82,10 +82,10 @@ static inline QString cdbBreakPointFileName(const BreakpointParameters &params,
const QList<QPair<QString, QString> > &sourcePathMapping) const QList<QPair<QString, QString> > &sourcePathMapping)
{ {
if (params.fileName.isEmpty()) if (params.fileName.isEmpty())
return params.fileName; return {};
if (params.pathUsage == BreakpointUseShortPath) if (params.pathUsage == BreakpointUseShortPath)
return Utils::FilePath::fromString(params.fileName).fileName(); return params.fileName.fileName();
return cdbSourcePathMapping(QDir::toNativeSeparators(params.fileName), sourcePathMapping, SourceToDebugger); return cdbSourcePathMapping(params.fileName.toUserOutput(), sourcePathMapping, SourceToDebugger);
} }
static BreakpointParameters fixWinMSVCBreakpoint(const BreakpointParameters &p) static BreakpointParameters fixWinMSVCBreakpoint(const BreakpointParameters &p)
@@ -250,7 +250,8 @@ void parseBreakPoint(const GdbMi &gdbmi, BreakpointParameters *r,
r->module = moduleG.data(); r->module = moduleG.data();
const GdbMi sourceFileName = gdbmi["srcfile"]; const GdbMi sourceFileName = gdbmi["srcfile"];
if (sourceFileName.isValid()) { if (sourceFileName.isValid()) {
r->fileName = Utils::FileUtils::normalizePathName(sourceFileName.data()); r->fileName = Utils::FilePath::fromUserInput(
Utils::FileUtils::normalizePathName(sourceFileName.data()));
const GdbMi lineNumber = gdbmi["srcline"]; const GdbMi lineNumber = gdbmi["srcline"];
if (lineNumber.isValid()) if (lineNumber.isValid())
r->lineNumber = lineNumber.data().toULongLong(nullptr, 0); r->lineNumber = lineNumber.data().toULongLong(nullptr, 0);

View File

@@ -672,9 +672,9 @@ public:
message = tr("0x%1 hit").arg(data.address, 0, 16); message = tr("0x%1 hit").arg(data.address, 0, 16);
} else { } else {
//: Message tracepoint: %1 file, %2 line %3 function hit. //: Message tracepoint: %1 file, %2 line %3 function hit.
message = tr("%1:%2 %3() hit").arg(FilePath::fromString(data.fileName).fileName()). message = tr("%1:%2 %3() hit").arg(data.fileName.fileName()).
arg(data.lineNumber). arg(data.lineNumber).
arg(cppFunctionAt(data.fileName, data.lineNumber)); arg(cppFunctionAt(data.fileName.toString(), data.lineNumber));
} }
QInputDialog dialog; // Create wide input dialog. QInputDialog dialog; // Create wide input dialog.
dialog.setWindowFlags(dialog.windowFlags() dialog.setWindowFlags(dialog.windowFlags()
@@ -1927,7 +1927,7 @@ void DebuggerPluginPrivate::requestContextMenu(TextEditorWidget *widget,
// Disassemble current function in stopped state. // Disassemble current function in stopped state.
if (engine->hasCapability(DisassemblerCapability)) { if (engine->hasCapability(DisassemblerCapability)) {
StackFrame frame; StackFrame frame;
frame.function = cppFunctionAt(args.fileName, lineNumber, 1); frame.function = cppFunctionAt(args.fileName.toString(), lineNumber, 1);
frame.line = 42; // trick gdb into mixed mode. frame.line = 42; // trick gdb into mixed mode.
if (!frame.function.isEmpty()) { if (!frame.function.isEmpty()) {
const QString text = tr("Disassemble Function \"%1\"") const QString text = tr("Disassemble Function \"%1\"")

View File

@@ -811,6 +811,11 @@ void DebuggerCommand::arg(const char *name, const QJsonValue &value)
args = addToJsonObject(args, name, value); args = addToJsonObject(args, name, value);
} }
void DebuggerCommand::arg(const char *name, const Utils::FilePath &filePath)
{
args = addToJsonObject(args, name, filePath.toString());
}
static QJsonValue translateJsonToPython(const QJsonValue &value) static QJsonValue translateJsonToPython(const QJsonValue &value)
{ {
// TODO: Verify that this covers all incompatibilities between python and json, // TODO: Verify that this covers all incompatibilities between python and json,

View File

@@ -33,6 +33,7 @@
#include <QVector> #include <QVector>
#include <functional> #include <functional>
#include <utils/fileutils.h>
namespace Utils { class ProcessHandle; } namespace Utils { class ProcessHandle; }
@@ -64,6 +65,7 @@ public:
void arg(const char *name, const QList<int> &list); void arg(const char *name, const QList<int> &list);
void arg(const char *name, const QStringList &list); // Note: Hex-encodes. void arg(const char *name, const QStringList &list); // Note: Hex-encodes.
void arg(const char *name, const QJsonValue &value); void arg(const char *name, const QJsonValue &value);
void arg(const char *name, const Utils::FilePath &filePath);
QString argsToPython() const; QString argsToPython() const;
QString argsToString() const; QString argsToString() const;
@@ -313,7 +315,7 @@ public:
public: public:
LocationType type = UnknownLocation; LocationType type = UnknownLocation;
QString fileName; Utils::FilePath fileName;
int lineNumber = 0; int lineNumber = 0;
quint64 address = 0; quint64 address = 0;
}; };

View File

@@ -1213,9 +1213,9 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
if (!nr.isEmpty() && frame.isValid()) { if (!nr.isEmpty() && frame.isValid()) {
// Use opportunity to update the breakpoint marker position. // Use opportunity to update the breakpoint marker position.
if (Breakpoint bp = breakHandler()->findBreakpointByResponseId(nr)) { if (Breakpoint bp = breakHandler()->findBreakpointByResponseId(nr)) {
QString fileName = bp->fileName(); FilePath fileName = bp->fileName();
if (fileName.isEmpty()) if (fileName.isEmpty())
fileName = fullName; fileName = FilePath::fromString(fullName);
if (!fileName.isEmpty()) if (!fileName.isEmpty())
bp->setMarkerFileAndLine(fileName, lineNumber); bp->setMarkerFileAndLine(fileName, lineNumber);
} }
@@ -1980,7 +1980,7 @@ void GdbEngine::executeRunToLine(const ContextData &data)
if (data.address) if (data.address)
loc = addressSpec(data.address); loc = addressSpec(data.address);
else else
loc = '"' + breakLocation(data.fileName) + '"' + ':' + QString::number(data.lineNumber); loc = '"' + breakLocation(data.fileName.toString()) + '"' + ':' + QString::number(data.lineNumber);
runCommand({"tbreak " + loc}); runCommand({"tbreak " + loc});
runCommand({"continue", NativeCommand|RunRequest, CB(handleExecuteRunToLine)}); runCommand({"continue", NativeCommand|RunRequest, CB(handleExecuteRunToLine)});
@@ -2008,7 +2008,7 @@ void GdbEngine::executeJumpToLine(const ContextData &data)
if (data.address) if (data.address)
loc = addressSpec(data.address); loc = addressSpec(data.address);
else else
loc = '"' + breakLocation(data.fileName) + '"' + ':' + QString::number(data.lineNumber); loc = '"' + breakLocation(data.fileName.toString()) + '"' + ':' + QString::number(data.lineNumber);
runCommand({"tbreak " + loc}); runCommand({"tbreak " + loc});
notifyInferiorRunRequested(); notifyInferiorRunRequested();
@@ -2110,7 +2110,7 @@ QString GdbEngine::breakpointLocation(const BreakpointParameters &data)
usage = BreakpointUseShortPath; usage = BreakpointUseShortPath;
const QString fileName = usage == BreakpointUseFullPath const QString fileName = usage == BreakpointUseFullPath
? data.fileName : breakLocation(data.fileName); ? data.fileName.toString() : breakLocation(data.fileName.toString());
// The argument is simply a C-quoted version of the argument to the // The argument is simply a C-quoted version of the argument to the
// non-MI "break" command, including the "original" quoting it wants. // non-MI "break" command, including the "original" quoting it wants.
return "\"\\\"" + GdbMi::escapeCString(fileName) + "\\\":" return "\"\\\"" + GdbMi::escapeCString(fileName) + "\\\":"
@@ -2124,7 +2124,7 @@ QString GdbEngine::breakpointLocation2(const BreakpointParameters &data)
usage = BreakpointUseShortPath; usage = BreakpointUseShortPath;
const QString fileName = usage == BreakpointUseFullPath const QString fileName = usage == BreakpointUseFullPath
? data.fileName : breakLocation(data.fileName); ? data.fileName.toString() : breakLocation(data.fileName.toString());
return GdbMi::escapeCString(fileName) + ':' + QString::number(data.lineNumber); return GdbMi::escapeCString(fileName) + ':' + QString::number(data.lineNumber);
} }
@@ -2252,7 +2252,7 @@ void GdbEngine::handleBreakInsert1(const DebuggerResponse &response, const Break
} else if (response.data["msg"].data().contains("Unknown option")) { } else if (response.data["msg"].data().contains("Unknown option")) {
// Older version of gdb don't know the -a option to set tracepoints // Older version of gdb don't know the -a option to set tracepoints
// ^error,msg="mi_cmd_break_insert: Unknown option ``a''" // ^error,msg="mi_cmd_break_insert: Unknown option ``a''"
const QString fileName = bp->fileName(); const QString fileName = bp->fileName().toString();
const int lineNumber = bp->lineNumber(); const int lineNumber = bp->lineNumber();
DebuggerCommand cmd("trace \"" + GdbMi::escapeCString(fileName) + "\":" DebuggerCommand cmd("trace \"" + GdbMi::escapeCString(fileName) + "\":"
+ QString::number(lineNumber), + QString::number(lineNumber),
@@ -2539,7 +2539,8 @@ void GdbEngine::removeBreakpoint(const Breakpoint &bp)
if (!bp->responseId().isEmpty()) { if (!bp->responseId().isEmpty()) {
// We already have a fully inserted breakpoint. // We already have a fully inserted breakpoint.
notifyBreakpointRemoveProceeding(bp); notifyBreakpointRemoveProceeding(bp);
showMessage(QString("DELETING BP %1 IN %2").arg(bp->responseId()).arg(bp->fileName())); showMessage(
QString("DELETING BP %1 IN %2").arg(bp->responseId()).arg(bp->fileName().toString()));
DebuggerCommand cmd("-break-delete " + bp->responseId(), NeedsTemporaryStop); DebuggerCommand cmd("-break-delete " + bp->responseId(), NeedsTemporaryStop);
runCommand(cmd); runCommand(cmd);

View File

@@ -564,7 +564,7 @@ void LldbEngine::updateBreakpointData(const Breakpoint &bp, const GdbMi &bkpt, b
bp->setIgnoreCount(bkpt["ignorecount"].toInt()); bp->setIgnoreCount(bkpt["ignorecount"].toInt());
bp->setCondition(fromHex(bkpt["condition"].data())); bp->setCondition(fromHex(bkpt["condition"].data()));
bp->setHitCount(bkpt["hitcount"].toInt()); bp->setHitCount(bkpt["hitcount"].toInt());
bp->setFileName(bkpt["file"].data()); bp->setFileName(FilePath::fromUserInput(bkpt["file"].data()));
bp->setLineNumber(bkpt["line"].toInt()); bp->setLineNumber(bkpt["line"].toInt());
GdbMi locations = bkpt["locations"]; GdbMi locations = bkpt["locations"];
@@ -577,7 +577,7 @@ void LldbEngine::updateBreakpointData(const Breakpoint &bp, const GdbMi &bkpt, b
loc->params.type = bp->type(); loc->params.type = bp->type();
loc->params.address = location["addr"].toAddress(); loc->params.address = location["addr"].toAddress();
loc->params.functionName = location["function"].data(); loc->params.functionName = location["function"].data();
loc->params.fileName = location["file"].data(); loc->params.fileName = FilePath::fromUserInput(location["file"].data());
loc->params.lineNumber = location["line"].toInt(); loc->params.lineNumber = location["line"].toInt();
loc->displayName = QString("%1.%2").arg(bp->responseId()).arg(locid); loc->displayName = QString("%1.%2").arg(bp->responseId()).arg(locid);
} }

View File

@@ -233,8 +233,7 @@ void PdbEngine::selectThread(const Thread &thread)
bool PdbEngine::acceptsBreakpoint(const BreakpointParameters &bp) const bool PdbEngine::acceptsBreakpoint(const BreakpointParameters &bp) const
{ {
const QString fileName = bp.fileName; return bp.fileName.endsWith(".py");
return fileName.endsWith(".py");
} }
void PdbEngine::insertBreakpoint(const Breakpoint &bp) void PdbEngine::insertBreakpoint(const Breakpoint &bp)
@@ -248,7 +247,7 @@ void PdbEngine::insertBreakpoint(const Breakpoint &bp)
if (params.type == BreakpointByFunction) if (params.type == BreakpointByFunction)
loc = params.functionName; loc = params.functionName;
else else
loc = params.fileName + ':' + QString::number(params.lineNumber); loc = params.fileName.toString() + ':' + QString::number(params.lineNumber);
postDirectCommand("break " + loc); postDirectCommand("break " + loc);
} }
@@ -285,7 +284,7 @@ void PdbEngine::removeBreakpoint(const Breakpoint &bp)
return; return;
} }
showMessage(QString("DELETING BP %1 IN %2") showMessage(QString("DELETING BP %1 IN %2")
.arg(bp->responseId()).arg(bp->fileName())); .arg(bp->responseId()).arg(bp->fileName().toUserOutput()));
postDirectCommand("clear " + bp->responseId()); postDirectCommand("clear " + bp->responseId());
// Pretend it succeeds without waiting for response. // Pretend it succeeds without waiting for response.
notifyBreakpointRemoveOk(bp); notifyBreakpointRemoveOk(bp);
@@ -498,7 +497,8 @@ void PdbEngine::handleOutput2(const QString &data)
const QString bpnr = line.mid(11, pos1 - 11); const QString bpnr = line.mid(11, pos1 - 11);
const int pos2 = line.lastIndexOf(':'); const int pos2 = line.lastIndexOf(':');
QTC_ASSERT(pos2 != -1, continue); QTC_ASSERT(pos2 != -1, continue);
const QString fileName = line.mid(pos1 + 4, pos2 - pos1 - 4); const Utils::FilePath fileName = Utils::FilePath::fromString(
line.mid(pos1 + 4, pos2 - pos1 - 4));
const int lineNumber = line.midRef(pos2 + 1).toInt(); const int lineNumber = line.midRef(pos2 + 1).toInt();
const Breakpoint bp = Utils::findOrDefault(breakHandler()->breakpoints(), [&](const Breakpoint &bp) { const Breakpoint bp = Utils::findOrDefault(breakHandler()->breakpoints(), [&](const Breakpoint &bp) {
return bp->parameters().isLocatedAt(fileName, lineNumber, bp->markerFileName()) return bp->parameters().isLocatedAt(fileName, lineNumber, bp->markerFileName())

View File

@@ -625,8 +625,11 @@ void QmlEngine::executeStepOver(bool)
void QmlEngine::executeRunToLine(const ContextData &data) void QmlEngine::executeRunToLine(const ContextData &data)
{ {
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
showStatusMessage(tr("Run to line %1 (%2) requested...").arg(data.lineNumber).arg(data.fileName), 5000); showStatusMessage(tr("Run to line %1 (%2) requested...")
d->setBreakpoint(SCRIPTREGEXP, data.fileName, true, data.lineNumber); .arg(data.lineNumber)
.arg(data.fileName.toString()),
5000);
d->setBreakpoint(SCRIPTREGEXP, data.fileName.toString(), true, data.lineNumber);
clearExceptionSelection(); clearExceptionSelection();
d->continueDebugging(Continue); d->continueDebugging(Continue);
@@ -677,7 +680,7 @@ void QmlEngine::insertBreakpoint(const Breakpoint &bp)
d->setExceptionBreak(AllExceptions, requested.enabled); d->setExceptionBreak(AllExceptions, requested.enabled);
} else if (requested.type == BreakpointByFileAndLine) { } else if (requested.type == BreakpointByFileAndLine) {
d->setBreakpoint(SCRIPTREGEXP, requested.fileName, d->setBreakpoint(SCRIPTREGEXP, requested.fileName.toString(),
requested.enabled, requested.lineNumber, 0, requested.enabled, requested.lineNumber, 0,
requested.condition, requested.ignoreCount); requested.condition, requested.ignoreCount);
@@ -735,7 +738,7 @@ void QmlEngine::updateBreakpoint(const Breakpoint &bp)
d->changeBreakpoint(bp, requested.enabled); d->changeBreakpoint(bp, requested.enabled);
} else { } else {
d->clearBreakpoint(bp); d->clearBreakpoint(bp);
d->setBreakpoint(SCRIPTREGEXP, requested.fileName, d->setBreakpoint(SCRIPTREGEXP, requested.fileName.toString(),
requested.enabled, requested.lineNumber, 0, requested.enabled, requested.lineNumber, 0,
requested.condition, requested.ignoreCount); requested.condition, requested.ignoreCount);
d->breakpointsSync.insert(d->sequence, bp); d->breakpointsSync.insert(d->sequence, bp);
@@ -1855,7 +1858,7 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data)
clearBreakpoint(bp); clearBreakpoint(bp);
setBreakpoint(SCRIPTREGEXP, setBreakpoint(SCRIPTREGEXP,
params.fileName, params.fileName.toString(),
params.enabled, params.enabled,
params.lineNumber, params.lineNumber,
newColumn, newColumn,

View File

@@ -328,14 +328,14 @@ ContextData getLocationContext(TextDocument *document, int lineNumber)
int ln = line.leftRef(pos - 1).toInt(); int ln = line.leftRef(pos - 1).toInt();
if (ln > 0) { if (ln > 0) {
data.type = LocationByFile; data.type = LocationByFile;
data.fileName = fileName; data.fileName = Utils::FilePath::fromString(fileName);
data.lineNumber = ln; data.lineNumber = ln;
} }
} }
} }
} else { } else {
data.type = LocationByFile; data.type = LocationByFile;
data.fileName = document->filePath().toString(); data.fileName = document->filePath();
data.lineNumber = lineNumber; data.lineNumber = lineNumber;
} }
return data; return data;