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