diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index 491efd90533..fa40001b897 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -1051,7 +1051,7 @@ QVariant BreakpointItem::data(int column, int role) const if (role == Qt::DisplayRole) return m_displayName.isEmpty() ? m_responseId : m_displayName; if (role == Qt::DecorationRole) - return icon(); + return icon(m_needsLocationMarker); break; case BreakpointFunctionColumn: if (role == Qt::DisplayRole) { @@ -1259,6 +1259,14 @@ void BreakpointItem::gotoState(BreakpointState target, BreakpointState assumedCu setState(target); } +void BreakpointItem::setNeedsLocationMarker(bool needsLocationMarker) +{ + if (m_needsLocationMarker == needsLocationMarker) + return; + m_needsLocationMarker = needsLocationMarker; + update(); +} + void BreakHandler::updateDisassemblerMarker(const Breakpoint &bp) { return m_engine->disassemblerAgent()->updateBreakpointMarker(bp); @@ -1272,6 +1280,30 @@ void BreakHandler::removeDisassemblerMarker(const Breakpoint &bp) gbp->updateMarker(); } +static bool matches(const Location &loc, const BreakpointParameters &bp) +{ + if (loc.fileName() == bp.fileName && loc.lineNumber() == bp.lineNumber && bp.lineNumber > 0) + return true; + if (loc.address() == bp.address && bp.address > 0) + return true; + return false; +} + +void BreakHandler::setLocation(const Location &loc) +{ + forItemsAtLevel<1>([loc](Breakpoint bp) { + bool needsMarker = matches(loc, bp->parameters()); + if (GlobalBreakpoint gpb = bp->globalBreakpoint()) + needsMarker = needsMarker || matches(loc, gpb->requestedParameters()); + bp->setNeedsLocationMarker(needsMarker); + }); +} + +void BreakHandler::resetLocation() +{ + forItemsAtLevel<1>([](Breakpoint bp) { bp->setNeedsLocationMarker(false); }); +} + void BreakpointItem::setState(BreakpointState state) { //qDebug() << "BREAKPOINT STATE TRANSITION, ID: " << m_id @@ -1881,7 +1913,7 @@ void BreakpointItem::updateMarker() m_marker = new BreakpointMarker(this, file, line); } -QIcon BreakpointItem::icon() const +QIcon BreakpointItem::icon(bool withLocationMarker) 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). @@ -1894,7 +1926,8 @@ QIcon BreakpointItem::icon() const if (!m_parameters.enabled) return Icons::BREAKPOINT_DISABLED.icon(); if (m_state == BreakpointInserted && !m_parameters.pending) - return Icons::BREAKPOINT.icon(); + return withLocationMarker ? Icons::BREAKPOINT_WITH_LOCATION.icon() + : Icons::BREAKPOINT.icon(); return Icons::BREAKPOINT_PENDING.icon(); } @@ -2737,6 +2770,7 @@ void BreakpointManager::editBreakpoints(const GlobalBreakpoints &gbps, QWidget * BreakpointManager::createBreakpoint(newParams); } } + void BreakpointManager::saveSessionData() { QList list; diff --git a/src/plugins/debugger/breakhandler.h b/src/plugins/debugger/breakhandler.h index eee210fc896..ad334d10b8a 100644 --- a/src/plugins/debugger/breakhandler.h +++ b/src/plugins/debugger/breakhandler.h @@ -39,13 +39,14 @@ namespace Utils { class ItemViewEvent; } namespace Debugger { namespace Internal { -class BreakpointItem; -class BreakpointMarker; class BreakHandler; +class BreakpointItem; +class BreakpointManager; +class BreakpointMarker; class DebuggerCommand; class DebuggerEngine; -class BreakpointManager; class GlobalBreakpointMarker; +class Location; class SubBreakpointItem : public QObject, public Utils::TypedTreeItem { @@ -122,7 +123,7 @@ public: QVariant data(int column, int role) const final; - QIcon icon() const; + QIcon icon(bool withLocationMarker = false) const; void setMarkerFileAndLine(const Utils::FilePath &fileName, int lineNumber); bool needsChange() const; @@ -197,6 +198,8 @@ public: const GlobalBreakpoint globalBreakpoint() const; void gotoState(BreakpointState target, BreakpointState assumedCurrent); + void setNeedsLocationMarker(bool needsLocationMarker); + private: void destroyMarker(); void updateMarker(); @@ -209,6 +212,7 @@ private: BreakpointMarker *m_marker = nullptr; QString m_responseId; //!< Breakpoint number or id assigned by or used in the debugger backend. QString m_displayName; + bool m_needsLocationMarker = false; }; using Breakpoint = QPointer; @@ -261,6 +265,9 @@ public: void updateDisassemblerMarker(const Breakpoint &bp); void removeDisassemblerMarker(const Breakpoint &bp); + void setLocation(const Location &loc); + void resetLocation(); + private: Breakpoint findBreakpointByIndex(const QModelIndex &index) const; Breakpoints findBreakpointsByIndex(const QList &list) const; diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 783258cb379..437cd0c4520 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -448,6 +448,7 @@ public: m_stackHandler.resetLocation(); m_disassemblerAgent.resetLocation(); m_toolTipManager.resetLocation(); + m_breakHandler.resetLocation(); } public: @@ -1110,6 +1111,8 @@ void DebuggerEngine::gotoLocation(const Location &loc) d->m_locationMark.reset(new LocationMark(this, loc.fileName(), line)); d->m_locationMark->setToolTip(tr("Current debugger location of %1").arg(displayName())); } + + d->m_breakHandler.setLocation(loc); } void DebuggerEngine::gotoCurrentLocation() diff --git a/src/plugins/debugger/debuggericons.cpp b/src/plugins/debugger/debuggericons.cpp index c50f5fdc621..88dfd085a04 100644 --- a/src/plugins/debugger/debuggericons.cpp +++ b/src/plugins/debugger/debuggericons.cpp @@ -37,6 +37,9 @@ const Icon BREAKPOINT_DISABLED({ const Icon BREAKPOINT_PENDING({ {":/utils/images/filledcircle.png", Theme::IconsErrorColor}, {":/debugger/images/breakpoint_pending_overlay.png", Theme::PanelTextColorDark}}, Icon::IconStyleOptions(Icon::Tint | Icon::PunchEdges)); +const Icon BREAKPOINT_WITH_LOCATION({ + {":/utils/images/filledcircle.png", Theme::IconsErrorColor}, + {":/debugger/images/location.png", Theme::IconsWarningToolBarColor}}, Icon::Tint); const Icon BREAKPOINTS( ":/debugger/images/debugger_breakpoints.png"); const Icon WATCHPOINT({ diff --git a/src/plugins/debugger/debuggericons.h b/src/plugins/debugger/debuggericons.h index b7d83f27ddf..4eacbc0020f 100644 --- a/src/plugins/debugger/debuggericons.h +++ b/src/plugins/debugger/debuggericons.h @@ -42,6 +42,7 @@ DEBUGGER_EXPORT extern const Utils::Icon TRACEPOINT_TOOLBAR; extern const Utils::Icon BREAKPOINT; extern const Utils::Icon BREAKPOINT_DISABLED; extern const Utils::Icon BREAKPOINT_PENDING; +extern const Utils::Icon BREAKPOINT_WITH_LOCATION; extern const Utils::Icon BREAKPOINTS; extern const Utils::Icon WATCHPOINT; extern const Utils::Icon CONTINUE;