Commit fc78ae27 authored by hjk's avatar hjk
Browse files

debugger: use short paths by default for setting breakpoints

parent 643d4b94
......@@ -154,6 +154,13 @@ BreakpointData::BreakpointData(BreakHandler *handler)
marker = 0;
markerLineNumber = 0;
bpMultiple = false;
//#if defined(Q_OS_MAC)
// // full names do not work on Mac/MI
useFullPath = false;
//#else
// //where = m_manager->shortName(data->fileName);
// useFullPath = true;
//#endif
}
BreakpointData::~BreakpointData()
......@@ -326,6 +333,8 @@ void BreakHandler::saveBreakpoints()
map["ignorecount"] = data->ignoreCount;
if (!data->enabled)
map["disabled"] = "1";
if (data->useFullPath)
map["usefullpath"] = "1";
list.append(map);
}
setSessionValueRequested("Breakpoints", list);
......@@ -347,6 +356,7 @@ void BreakHandler::loadBreakpoints()
data->ignoreCount = map["ignorecount"].toString();
data->funcName = map["funcname"].toString();
data->enabled = !map["disabled"].toInt();
data->useFullPath = bool(map["usefullpath"].toInt());
data->markerFileName = data->fileName;
data->markerLineNumber = data->lineNumber.toInt();
append(data);
......@@ -427,8 +437,13 @@ QVariant BreakHandler::data(const QModelIndex &mi, int role) const
str = QFileInfo(str).fileName();
//if (data->bpMultiple && str.isEmpty() && !data->markerFileName.isEmpty())
// str = data->markerFileName;
return str.isEmpty() ? empty : str;
str = str.isEmpty() ? empty : str;
if (data->useFullPath)
str = "/.../" + str;
return str;
}
if (role == Qt::UserRole)
return data->useFullPath;
break;
case 3:
if (role == Qt::DisplayRole) {
......@@ -480,6 +495,13 @@ bool BreakHandler::setData(const QModelIndex &mi, const QVariant &value, int rol
}
return true;
}
case 2: {
if (data->useFullPath != value.toBool()) {
data->useFullPath = value.toBool();
dataChanged(mi, mi);
}
return true;
}
case 4: {
QString val = value.toString();
if (val != data->condition) {
......
......@@ -78,6 +78,7 @@ public:
QString ignoreCount; // ignore count associated with breakpoint
QString lineNumber; // line in source file
QString funcName; // name of containing function
bool useFullPath; // should we use the full path when setting the bp?
// this is what gdb produced in response
QString bpNumber; // breakpoint number assigned by the debugger engine
......
......@@ -82,6 +82,7 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev)
const QModelIndex index = indexAt(ev->pos());
const bool indexIsValid = index.isValid();
const QModelIndex index0 = index.sibling(index.row(), 0);
const QModelIndex index2 = index.sibling(index.row(), 2);
QAction *act0 = new QAction(tr("Delete breakpoint"), &menu);
act0->setEnabled(indexIsValid);
QAction *act1 = new QAction(tr("Adjust column widths to contents"), &menu);
......@@ -94,10 +95,14 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev)
bool enabled = indexIsValid && model()->data(index0, Qt::UserRole).toBool();
QString str = enabled ? tr("Disable breakpoint") : tr("Enable breakpoint");
QAction *act5 = new QAction(str, &menu);
bool fullpath = indexIsValid && model()->data(index2, Qt::UserRole).toBool();
QString str1 = fullpath ? tr("Use short path") : tr("Use full path");
QAction *act6 = new QAction(str1, &menu);
menu.addAction(act0);
menu.addAction(act3);
menu.addAction(act5);
menu.addAction(act6);
menu.addSeparator();
menu.addAction(act1);
menu.addAction(act2);
......@@ -120,6 +125,9 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev)
else if (act == act5) {
model()->setData(index0, !enabled);
emit breakpointSynchronizationRequested();
} else if (act == act6) {
model()->setData(index2, !fullpath);
emit breakpointSynchronizationRequested();
}
}
......
......@@ -1821,23 +1821,12 @@ void GdbEngine::sendInsertBreakpoint(int index)
const BreakpointData *data = qq->breakHandler()->at(index);
QString where;
if (data->funcName.isEmpty()) {
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
where = data->fileName;
#endif
#if defined(Q_OS_MAC)
// full names do not work on Mac/MI
QFileInfo fi(data->fileName);
where = fi.fileName();
//where = fi.absoluteFilePath();
#endif
#if defined(Q_OS_WIN)
// full names do not work on Mac/MI
QFileInfo fi(data->fileName);
where = fi.fileName();
//where = m_manager->shortName(data->fileName);
//if (where.isEmpty())
// where = data->fileName;
#endif
if (data->useFullPath) {
where = data->fileName;
} else {
QFileInfo fi(data->fileName);
where = fi.fileName();
}
// The argument is simply a C-quoted version of the argument to the
// non-MI "break" command, including the "original" quoting it wants.
where = _("\"\\\"") + GdbMi::escapeCString(where) + _("\\\":") + data->lineNumber + _c('"');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment