forked from qt-creator/qt-creator
debugger: better synchronize icon selection for editor and view marker
This commit is contained in:
@@ -52,19 +52,38 @@ namespace Debugger {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
BreakHandler::BreakHandler()
|
BreakHandler::BreakHandler()
|
||||||
: m_breakpointIcon(_(":/debugger/images/breakpoint_16.png")),
|
: m_syncTimerId(-1)
|
||||||
m_disabledBreakpointIcon(_(":/debugger/images/breakpoint_disabled_16.png")),
|
|
||||||
m_pendingBreakPointIcon(_(":/debugger/images/breakpoint_pending_16.png")),
|
|
||||||
//m_emptyIcon(_(":/debugger/images/watchpoint.png")),
|
|
||||||
m_emptyIcon(_(":/debugger/images/breakpoint_pending_16.png")),
|
|
||||||
//m_emptyIcon(_(":/debugger/images/debugger_empty_14.png")),
|
|
||||||
m_watchpointIcon(_(":/debugger/images/watchpoint.png")),
|
|
||||||
m_syncTimerId(-1)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
BreakHandler::~BreakHandler()
|
BreakHandler::~BreakHandler()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
QIcon BreakHandler::breakpointIcon()
|
||||||
|
{
|
||||||
|
static QIcon icon(_(":/debugger/images/breakpoint_16.png"));
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon BreakHandler::disabledBreakpointIcon()
|
||||||
|
{
|
||||||
|
static QIcon icon(_(":/debugger/images/breakpoint_disabled_16.png"));
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon BreakHandler::pendingBreakPointIcon()
|
||||||
|
{
|
||||||
|
static QIcon icon(_(":/debugger/images/breakpoint_pending_16.png"));
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon BreakHandler::emptyIcon()
|
||||||
|
{
|
||||||
|
static QIcon icon(_(":/debugger/images/breakpoint_pending_16.png"));
|
||||||
|
//static QIcon icon(_(":/debugger/images/watchpoint.png"));
|
||||||
|
//static QIcon icon(_(":/debugger/images/debugger_empty_14.png"));
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
int BreakHandler::columnCount(const QModelIndex &parent) const
|
int BreakHandler::columnCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
return parent.isValid() ? 0 : 8;
|
return parent.isValid() ? 0 : 8;
|
||||||
@@ -358,6 +377,7 @@ QVariant BreakHandler::data(const QModelIndex &mi, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
BreakpointId id = findBreakpointByIndex(mi);
|
BreakpointId id = findBreakpointByIndex(mi);
|
||||||
|
//qDebug() << "DATA: " << id << role << mi.column();
|
||||||
ConstIterator it = m_storage.find(id);
|
ConstIterator it = m_storage.find(id);
|
||||||
QTC_ASSERT(it != m_storage.end(), return QVariant());
|
QTC_ASSERT(it != m_storage.end(), return QVariant());
|
||||||
const BreakpointParameters &data = it->data;
|
const BreakpointParameters &data = it->data;
|
||||||
@@ -369,43 +389,45 @@ QVariant BreakHandler::data(const QModelIndex &mi, int role) const
|
|||||||
return QString::number(id);
|
return QString::number(id);
|
||||||
//return QString("%1 - %2").arg(id).arg(response.number);
|
//return QString("%1 - %2").arg(id).arg(response.number);
|
||||||
}
|
}
|
||||||
if (role == Qt::DecorationRole) {
|
if (role == Qt::DecorationRole)
|
||||||
if (data.isWatchpoint())
|
return it->icon();
|
||||||
return m_watchpointIcon;
|
|
||||||
if (!data.enabled)
|
|
||||||
return m_disabledBreakpointIcon;
|
|
||||||
return it->isPending() ? m_pendingBreakPointIcon : m_breakpointIcon;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
const QString str = it->isPending()
|
if (!response.functionName.isEmpty())
|
||||||
? data.functionName : response.functionName;
|
return response.functionName;
|
||||||
return str.isEmpty() ? empty : str;
|
if (!data.functionName.isEmpty())
|
||||||
|
return data.functionName;
|
||||||
|
return empty;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
QString str = it->isPending()
|
QString str;
|
||||||
? data.fileName : response.fileName;
|
if (!response.fileName.isEmpty())
|
||||||
str = QFileInfo(str).fileName();
|
str = response.fileName;
|
||||||
|
if (str.isEmpty() && !data.fileName.isEmpty())
|
||||||
|
str = response.fileName;
|
||||||
|
if (str.isEmpty()) {
|
||||||
|
QString s = QFileInfo(str).fileName();
|
||||||
|
if (!s.isEmpty())
|
||||||
|
str = s;
|
||||||
|
}
|
||||||
// FIXME: better?
|
// FIXME: better?
|
||||||
//if (data.multiple && str.isEmpty() && !response.fileName.isEmpty())
|
//if (data.multiple && str.isEmpty() && !response.fileName.isEmpty())
|
||||||
// str = response.fileName;
|
// str = response.fileName;
|
||||||
str = str.isEmpty() ? empty : str;
|
if (!str.isEmpty())
|
||||||
if (data.useFullPath)
|
|
||||||
str = QDir::toNativeSeparators(QLatin1String("/.../") + str);
|
|
||||||
return str;
|
return str;
|
||||||
|
return empty;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
// FIXME: better?
|
if (response.lineNumber > 0)
|
||||||
//if (data.multiple && str.isEmpty() && !reponse.fileName.isEmpty())
|
return response.lineNumber;
|
||||||
// str = response.lineNumber;
|
if (data.lineNumber > 0)
|
||||||
const int nr = it->isPending()
|
return data.lineNumber;
|
||||||
? data.lineNumber : response.lineNumber;
|
return empty;
|
||||||
return nr ? QString::number(nr) : empty;
|
|
||||||
}
|
}
|
||||||
if (role == Qt::UserRole + 1)
|
if (role == Qt::UserRole + 1)
|
||||||
return data.lineNumber;
|
return data.lineNumber;
|
||||||
@@ -532,8 +554,9 @@ void BreakHandler::setMarkerFileAndLine(BreakpointId id,
|
|||||||
return;
|
return;
|
||||||
it->response.fileName = fileName;
|
it->response.fileName = fileName;
|
||||||
it->response.lineNumber = lineNumber;
|
it->response.lineNumber = lineNumber;
|
||||||
|
it->destroyMarker();
|
||||||
updateMarker(id);
|
updateMarker(id);
|
||||||
scheduleSynchronization();
|
emit layoutChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
BreakpointState BreakHandler::state(BreakpointId id) const
|
BreakpointState BreakHandler::state(BreakpointId id) const
|
||||||
@@ -558,6 +581,7 @@ void BreakHandler::setEngine(BreakpointId id, DebuggerEngine *value)
|
|||||||
QTC_ASSERT(!it->engine, return);
|
QTC_ASSERT(!it->engine, return);
|
||||||
it->engine = value;
|
it->engine = value;
|
||||||
it->state = BreakpointInsertRequested;
|
it->state = BreakpointInsertRequested;
|
||||||
|
it->response = BreakpointResponse();
|
||||||
updateMarker(id);
|
updateMarker(id);
|
||||||
scheduleSynchronization();
|
scheduleSynchronization();
|
||||||
}
|
}
|
||||||
@@ -721,6 +745,7 @@ void BreakHandler::removeBreakpoint(BreakpointId id)
|
|||||||
QTC_ASSERT(it != m_storage.end(), return);
|
QTC_ASSERT(it != m_storage.end(), return);
|
||||||
if (it->state == BreakpointInserted) {
|
if (it->state == BreakpointInserted) {
|
||||||
setState(id, BreakpointRemoveRequested);
|
setState(id, BreakpointRemoveRequested);
|
||||||
|
scheduleSynchronization();
|
||||||
} else if (it->state == BreakpointNew) {
|
} else if (it->state == BreakpointNew) {
|
||||||
it->state = BreakpointDead;
|
it->state = BreakpointDead;
|
||||||
cleanupBreakpoint(id);
|
cleanupBreakpoint(id);
|
||||||
@@ -809,11 +834,7 @@ QIcon BreakHandler::icon(BreakpointId id) const
|
|||||||
{
|
{
|
||||||
ConstIterator it = m_storage.find(id);
|
ConstIterator it = m_storage.find(id);
|
||||||
QTC_ASSERT(it != m_storage.end(), return pendingBreakPointIcon());
|
QTC_ASSERT(it != m_storage.end(), return pendingBreakPointIcon());
|
||||||
if (!it->data.enabled)
|
return it->icon();
|
||||||
return m_disabledBreakpointIcon;
|
|
||||||
if (it->state == BreakpointInserted)
|
|
||||||
return breakpointIcon();
|
|
||||||
return pendingBreakPointIcon();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BreakHandler::scheduleSynchronization()
|
void BreakHandler::scheduleSynchronization()
|
||||||
@@ -845,6 +866,7 @@ void BreakHandler::gotoLocation(BreakpointId id) const
|
|||||||
void BreakHandler::updateLineNumberFromMarker(BreakpointId id, int lineNumber)
|
void BreakHandler::updateLineNumberFromMarker(BreakpointId id, int lineNumber)
|
||||||
{
|
{
|
||||||
Iterator it = m_storage.find(id);
|
Iterator it = m_storage.find(id);
|
||||||
|
it->response.pending = false;
|
||||||
QTC_ASSERT(it != m_storage.end(), return);
|
QTC_ASSERT(it != m_storage.end(), return);
|
||||||
//if (data.markerLineNumber == lineNumber)
|
//if (data.markerLineNumber == lineNumber)
|
||||||
// return;
|
// return;
|
||||||
@@ -867,6 +889,7 @@ void BreakHandler::updateLineNumberFromMarker(BreakpointId id, int lineNumber)
|
|||||||
it->data.lineNumber = lineNumber;
|
it->data.lineNumber = lineNumber;
|
||||||
}
|
}
|
||||||
updateMarker(id);
|
updateMarker(id);
|
||||||
|
emit layoutChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
BreakpointIds BreakHandler::allBreakpointIds() const
|
BreakpointIds BreakHandler::allBreakpointIds() const
|
||||||
@@ -914,7 +937,6 @@ void BreakHandler::setResponse(BreakpointId id, const BreakpointResponse &data)
|
|||||||
Iterator it = m_storage.find(id);
|
Iterator it = m_storage.find(id);
|
||||||
QTC_ASSERT(it != m_storage.end(), return);
|
QTC_ASSERT(it != m_storage.end(), return);
|
||||||
it->response = data;
|
it->response = data;
|
||||||
updateMarker(id);
|
|
||||||
//qDebug() << "SET RESPONSE: " << id << it->state << it->needsChange();
|
//qDebug() << "SET RESPONSE: " << id << it->state << it->needsChange();
|
||||||
if (it->state == BreakpointChangeProceeding
|
if (it->state == BreakpointChangeProceeding
|
||||||
|| it->state == BreakpointInsertProceeding) {
|
|| it->state == BreakpointInsertProceeding) {
|
||||||
@@ -923,6 +945,8 @@ void BreakHandler::setResponse(BreakpointId id, const BreakpointResponse &data)
|
|||||||
else
|
else
|
||||||
setState(id, BreakpointInserted);
|
setState(id, BreakpointInserted);
|
||||||
}
|
}
|
||||||
|
it->destroyMarker();
|
||||||
|
updateMarker(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BreakHandler::setBreakpointData(BreakpointId id, const BreakpointParameters &data)
|
void BreakHandler::setBreakpointData(BreakpointId id, const BreakpointParameters &data)
|
||||||
@@ -932,6 +956,7 @@ void BreakHandler::setBreakpointData(BreakpointId id, const BreakpointParameters
|
|||||||
if (data == it->data)
|
if (data == it->data)
|
||||||
return;
|
return;
|
||||||
it->data = data;
|
it->data = data;
|
||||||
|
it->destroyMarker();
|
||||||
updateMarker(id);
|
updateMarker(id);
|
||||||
layoutChanged();
|
layoutChanged();
|
||||||
}
|
}
|
||||||
@@ -977,15 +1002,15 @@ static void formatAddress(QTextStream &str, quint64 address)
|
|||||||
static QString stateToString(BreakpointState state)
|
static QString stateToString(BreakpointState state)
|
||||||
{
|
{
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case BreakpointNew: return "new";
|
case BreakpointNew: return "New";
|
||||||
case BreakpointInsertRequested: return "insertion requested";
|
case BreakpointInsertRequested: return "Insertion requested";
|
||||||
case BreakpointInsertProceeding: return "insertion proceeding";
|
case BreakpointInsertProceeding: return "Insertion proceeding";
|
||||||
case BreakpointChangeRequested: return "change requested";
|
case BreakpointChangeRequested: return "Change requested";
|
||||||
case BreakpointChangeProceeding: return "change proceeding";
|
case BreakpointChangeProceeding: return "Change proceeding";
|
||||||
case BreakpointInserted: return "breakpoint inserted";
|
case BreakpointInserted: return "Breakpoint inserted";
|
||||||
case BreakpointRemoveRequested: return "removal requested";
|
case BreakpointRemoveRequested: return "Removal requested";
|
||||||
case BreakpointRemoveProceeding: return "removal is proceeding";
|
case BreakpointRemoveProceeding: return "Removal proceeding";
|
||||||
case BreakpointDead: return "dead";
|
case BreakpointDead: return "Dead";
|
||||||
default: return "<invalid state>";
|
default: return "<invalid state>";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1008,6 +1033,17 @@ bool BreakHandler::BreakpointItem::isLocatedAt
|
|||||||
return lineNumber == line && fileNameMatch(fileName, response.fileName);
|
return lineNumber == line && fileNameMatch(fileName, response.fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon BreakHandler::BreakpointItem::icon() const
|
||||||
|
{
|
||||||
|
// FIXME: This seems to be called on each cursor blink as soon as the
|
||||||
|
// cursor is near a line with a breakpoint marker (+/- 2 lines or so).
|
||||||
|
if (!data.enabled)
|
||||||
|
return BreakHandler::disabledBreakpointIcon();
|
||||||
|
if (state == BreakpointInserted)
|
||||||
|
return BreakHandler::breakpointIcon();
|
||||||
|
return BreakHandler::pendingBreakPointIcon();
|
||||||
|
}
|
||||||
|
|
||||||
QString BreakHandler::BreakpointItem::toToolTip() const
|
QString BreakHandler::BreakpointItem::toToolTip() const
|
||||||
{
|
{
|
||||||
QString t;
|
QString t;
|
||||||
@@ -1053,6 +1089,8 @@ QString BreakHandler::BreakpointItem::toToolTip() const
|
|||||||
<< "</td><td>" << t << "</td></tr>"
|
<< "</td><td>" << t << "</td></tr>"
|
||||||
<< "<tr><td>" << tr("Extra Information:")
|
<< "<tr><td>" << tr("Extra Information:")
|
||||||
<< "</td><td>" << response.extra << "</td></tr>"
|
<< "</td><td>" << response.extra << "</td></tr>"
|
||||||
|
<< "<tr><td>" << tr("Pending:")
|
||||||
|
<< "</td><td>" << (response.pending ? "True" : "False") << "</td></tr>"
|
||||||
<< "</table><br><hr><table>"
|
<< "</table><br><hr><table>"
|
||||||
<< "<tr><th>" << tr("Property")
|
<< "<tr><th>" << tr("Property")
|
||||||
<< "</th><th>" << tr("Requested")
|
<< "</th><th>" << tr("Requested")
|
||||||
|
|||||||
@@ -83,10 +83,10 @@ public:
|
|||||||
bool hasWatchpointAt(quint64 address) const;
|
bool hasWatchpointAt(quint64 address) const;
|
||||||
void updateMarkers();
|
void updateMarkers();
|
||||||
|
|
||||||
QIcon breakpointIcon() const { return m_breakpointIcon; }
|
static QIcon breakpointIcon();
|
||||||
QIcon disabledBreakpointIcon() const { return m_disabledBreakpointIcon; }
|
static QIcon disabledBreakpointIcon();
|
||||||
QIcon pendingBreakPointIcon() const { return m_pendingBreakPointIcon; }
|
static QIcon pendingBreakPointIcon();
|
||||||
QIcon emptyIcon() const { return m_emptyIcon; }
|
static QIcon emptyIcon();
|
||||||
|
|
||||||
void toggleBreakpoint(const QString &fileName, int lineNumber, quint64 address = 0);
|
void toggleBreakpoint(const QString &fileName, int lineNumber, quint64 address = 0);
|
||||||
BreakpointId findBreakpointByFileAndLine(const QString &fileName,
|
BreakpointId findBreakpointByFileAndLine(const QString &fileName,
|
||||||
@@ -167,12 +167,6 @@ private:
|
|||||||
void updateMarker(BreakpointId id);
|
void updateMarker(BreakpointId id);
|
||||||
void cleanupBreakpoint(BreakpointId id);
|
void cleanupBreakpoint(BreakpointId id);
|
||||||
|
|
||||||
const QIcon m_breakpointIcon;
|
|
||||||
const QIcon m_disabledBreakpointIcon;
|
|
||||||
const QIcon m_pendingBreakPointIcon;
|
|
||||||
const QIcon m_emptyIcon;
|
|
||||||
const QIcon m_watchpointIcon;
|
|
||||||
|
|
||||||
struct BreakpointItem
|
struct BreakpointItem
|
||||||
{
|
{
|
||||||
BreakpointItem();
|
BreakpointItem();
|
||||||
@@ -185,6 +179,7 @@ private:
|
|||||||
QString toToolTip() const;
|
QString toToolTip() const;
|
||||||
QString markerFileName() const;
|
QString markerFileName() const;
|
||||||
int markerLineNumber() const;
|
int markerLineNumber() const;
|
||||||
|
QIcon icon() const;
|
||||||
|
|
||||||
BreakpointParameters data;
|
BreakpointParameters data;
|
||||||
BreakpointState state; // Current state of breakpoint.
|
BreakpointState state; // Current state of breakpoint.
|
||||||
|
|||||||
@@ -2036,6 +2036,7 @@ void GdbEngine::updateBreakpointDataFromOutput(BreakpointId id, const GdbMi &bkp
|
|||||||
|
|
||||||
response.multiple = false;
|
response.multiple = false;
|
||||||
response.enabled = true;
|
response.enabled = true;
|
||||||
|
response.pending = false;
|
||||||
response.condition.clear();
|
response.condition.clear();
|
||||||
QByteArray file, fullName;
|
QByteArray file, fullName;
|
||||||
foreach (const GdbMi &child, bkpt.children()) {
|
foreach (const GdbMi &child, bkpt.children()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user