diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index 5ac1b6be1bf954812846a8a98b149e3531d1ea9a..84f322d260dc0b22b5eb458ee6d0e9b723a4ac97 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -32,6 +32,7 @@ #include "debuggeractions.h" #include "debuggercore.h" +#include "debuggerengine.h" #include "debuggerstringutils.h" #include <utils/qtcassert.h> @@ -312,10 +313,8 @@ void BreakHandler::updateMarker(BreakpointId id) BreakpointMarker *marker = it->marker; if (marker && (data.m_markerFileName != marker->fileName() - || data.m_markerLineNumber != marker->lineNumber())) { - removeMarker(id); - marker = 0; - } + || data.m_markerLineNumber != marker->lineNumber())) + it->destroyMarker(); if (!marker && !data.m_markerFileName.isEmpty() && data.m_markerLineNumber > 0) { marker = new BreakpointMarker(id, data.m_markerFileName, data.m_markerLineNumber); @@ -323,14 +322,6 @@ void BreakHandler::updateMarker(BreakpointId id) } } -void BreakHandler::removeMarker(BreakpointId id) -{ - Iterator it = m_storage.find(id); - BreakpointMarker *marker = it->marker; - it->marker = 0; - delete marker; -} - QVariant BreakHandler::headerData(int section, Qt::Orientation orientation, int role) const { @@ -462,7 +453,7 @@ QVariant BreakHandler::data(const QModelIndex &mi, int role) const } if (role == Qt::ToolTipRole) return debuggerCore()->boolSetting(UseToolTipsInBreakpointsView) - ? data.toToolTip() : QVariant(); + ? QVariant(it->toToolTip()) : QVariant(); return QVariant(); } @@ -799,7 +790,7 @@ void BreakHandler::cleanupBreakpoint(BreakpointId id) { QTC_ASSERT(state(id) == BreakpointDead, /**/); BreakpointItem item = m_storage.take(id); - item.destroy(); + item.destroyMarker(); } BreakpointResponse BreakHandler::response(BreakpointId id) const @@ -836,10 +827,110 @@ void BreakHandler::notifyBreakpointAdjusted(BreakpointId id) } #endif -void BreakHandler::BreakpointItem::destroy() +void BreakHandler::BreakpointItem::destroyMarker() { - delete marker; + BreakpointMarker *m = marker; marker = 0; + delete m; +} + +static void formatAddress(QTextStream &str, quint64 address) +{ + if (address) { + str << "0x"; + str.setIntegerBase(16); + str << address; + str.setIntegerBase(10); + } +} + +QString BreakHandler::BreakpointItem::toToolTip() const +{ + QString t; + + switch (data.type()) { + case BreakpointByFileAndLine: + t = tr("Breakpoint by File and Line"); + break; + case BreakpointByFunction: + t = tr("Breakpoint by Function"); + break; + case BreakpointByAddress: + t = tr("Breakpoint by Address"); + break; + case Watchpoint: + t = tr("Watchpoint"); + break; + case UnknownType: + t = tr("Unknown Breakpoint Type"); + } + + QString rc; + QTextStream str(&rc); + str << "<html><body><table>" + //<< "<tr><td>" << tr("Id:") << "</td><td>" << m_id << "</td></tr>" + << "<tr><td>" << tr("State:") + << "</td><td>" << state << "</td></tr>" + << "<tr><td>" << tr("Engine:") + << "</td><td>" << (engine ? engine->objectName() : "0") << "</td></tr>" + << "<tr><td>" << tr("Marker File:") + << "</td><td>" << QDir::toNativeSeparators(data.m_markerFileName) << "</td></tr>" + << "<tr><td>" << tr("Marker Line:") + << "</td><td>" << data.m_markerLineNumber << "</td></tr>" + << "<tr><td>" << tr("Breakpoint Number:") + << "</td><td>" << response.bpNumber << "</td></tr>" + << "<tr><td>" << tr("Breakpoint Type:") + << "</td><td>" << t << "</td></tr>" + << "<tr><td>" << tr("State:") + << "</td><td>" << response.bpState << "</td></tr>" + << "</table><br><hr><table>" + << "<tr><th>" << tr("Property") + << "</th><th>" << tr("Requested") + << "</th><th>" << tr("Obtained") << "</th></tr>" + << "<tr><td>" << tr("Internal Number:") + << "</td><td>—</td><td>" << response.bpNumber << "</td></tr>" + << "<tr><td>" << tr("File Name:") + << "</td><td>" << QDir::toNativeSeparators(data.m_fileName) + << "</td><td>" << QDir::toNativeSeparators(response.bpFileName) + << "</td></tr>" + << "<tr><td>" << tr("Function Name:") + << "</td><td>" << data.m_functionName + << "</td><td>" << response.bpFuncName << "</td></tr>" + << "<tr><td>" << tr("Line Number:") << "</td><td>"; + if (data.m_lineNumber) + str << data.m_lineNumber; + str << "</td><td>"; + if (response.bpLineNumber) + str << response.bpLineNumber; + str << "</td></tr>" + << "<tr><td>" << tr("Breakpoint Address:") + << "</td><td>"; + formatAddress(str, data.m_address); + str << "</td><td>"; + formatAddress(str, response.bpAddress); + //str << "</td></tr>" + // << "<tr><td>" << tr("Corrected Line Number:") + // << "</td><td>-</td><td>"; + //if (response.bpCorrectedLineNumber > 0) + // str << response.bpCorrectedLineNumber; + //else + // str << '-'; + str << "</td></tr>" + << "<tr><td>" << tr("Condition:") + << "</td><td>" << data.m_condition + << "</td><td>" << response.bpCondition << "</td></tr>" + << "<tr><td>" << tr("Ignore Count:") << "</td><td>"; + if (data.m_ignoreCount) + str << data.m_ignoreCount; + str << "</td><td>"; + if (response.bpIgnoreCount) + str << response.bpIgnoreCount; + str << "</td></tr>" + << "<tr><td>" << tr("Thread Specification:") + << "</td><td>" << data.m_threadSpec + << "</td><td>" << response.bpThreadSpec << "</td></tr>" + << "</table></body></html>"; + return rc; } } // namespace Internal diff --git a/src/plugins/debugger/breakhandler.h b/src/plugins/debugger/breakhandler.h index 569055c2ac658f07b3c9345d4caa4c7788c7201f..3da660fdb62eab64e2609ca53bbae1ef91b51b5e 100644 --- a/src/plugins/debugger/breakhandler.h +++ b/src/plugins/debugger/breakhandler.h @@ -79,7 +79,6 @@ public: void setWatchpointByAddress(quint64 address); bool hasWatchpointAt(quint64 address) const; void updateMarkers(); - void removeMarker(BreakpointId id); QIcon breakpointIcon() const { return m_breakpointIcon; } QIcon disabledBreakpointIcon() const { return m_disabledBreakpointIcon; } @@ -139,6 +138,7 @@ public: void notifyBreakpointRemoveFailed(BreakpointId id); void notifyBreakpointReleased(BreakpointId id); + public: // FIXME: Make private. void setState(BreakpointId id, BreakpointState state); @@ -171,9 +171,10 @@ private: struct BreakpointItem { BreakpointItem() : state(BreakpointNew), engine(0), marker(0) {} - void destroy(); + void destroyMarker(); bool isPending() const { return state == BreakpointPending || state == BreakpointNew; } + QString toToolTip() const; BreakpointData data; BreakpointState state; // Current state of breakpoint. diff --git a/src/plugins/debugger/breakpoint.cpp b/src/plugins/debugger/breakpoint.cpp index 097e1bfa262e184348158462005f574fee76c580..3ca98104f3c6a3c9ed49dca67d3da5a95c633096 100644 --- a/src/plugins/debugger/breakpoint.cpp +++ b/src/plugins/debugger/breakpoint.cpp @@ -28,15 +28,9 @@ **************************************************************************/ #include "breakpoint.h" -#include "stackframe.h" - -#include <utils/qtcassert.h> #include <QtCore/QByteArray> #include <QtCore/QDebug> -#include <QtCore/QTextStream> -#include <QtCore/QFileInfo> -#include <QtCore/QDir> namespace Debugger { namespace Internal { @@ -113,102 +107,6 @@ bool BreakpointData::setCondition(const QByteArray &cond) #undef SETIT -static void formatAddress(QTextStream &str, quint64 address) -{ - if (address) { - str << "0x"; - str.setIntegerBase(16); - str << address; - str.setIntegerBase(10); - } -} - -QString BreakpointData::toToolTip() const -{ - QString t; - switch (m_type) { - case BreakpointByFileAndLine: - t = tr("Breakpoint by File and Line"); - break; - case BreakpointByFunction: - t = tr("Breakpoint by Function"); - break; - case BreakpointByAddress: - t = tr("Breakpoint by Address"); - break; - case Watchpoint: - t = tr("Watchpoint"); - break; - case UnknownType: - t = tr("Unknown Breakpoint Type"); - } - - QString rc; - QTextStream str(&rc); - str << "<html><body><table>" - //<< "<tr><td>" << tr("Id:") - //<< "</td><td>" << m_id << "</td></tr>" - //<< "<tr><td>" << tr("State:") - //<< "</td><td>" << m_state << "</td></tr>" - //<< "<tr><td>" << tr("Engine:") - //<< "</td><td>" << m_engine << "</td></tr>" - << "<tr><td>" << tr("Marker File:") - << "</td><td>" << QDir::toNativeSeparators(m_markerFileName) << "</td></tr>" - << "<tr><td>" << tr("Marker Line:") - << "</td><td>" << m_markerLineNumber << "</td></tr>" - //<< "<tr><td>" << tr("Breakpoint Number:") - //<< "</td><td>" << bpNumber << "</td></tr>" - << "<tr><td>" << tr("Breakpoint Type:") - << "</td><td>" << t << "</td></tr>" - << "<tr><td>" << tr("State:") - //<< "</td><td>" << bpState << "</td></tr>" - << "</table><br><hr><table>" - << "<tr><th>" << tr("Property") - << "</th><th>" << tr("Requested") - << "</th><th>" << tr("Obtained") << "</th></tr>" - << "<tr><td>" << tr("Internal Number:") - //<< "</td><td>—</td><td>" << bpNumber << "</td></tr>" - << "<tr><td>" << tr("File Name:") - << "</td><td>" << QDir::toNativeSeparators(m_fileName) - //<< "</td><td>" << QDir::toNativeSeparators(bpFileName) << "</td></tr>" - << "<tr><td>" << tr("Function Name:") - << "</td><td>" << m_functionName // << "</td><td>" << bpFuncName << "</td></tr>" - << "<tr><td>" << tr("Line Number:") << "</td><td>"; - if (m_lineNumber) - str << m_lineNumber; - //str << "</td><td>"; - //if (bpLineNumber) - // str << bpLineNumber; - str << "</td></tr>" - << "<tr><td>" << tr("Breakpoint Address:") - << "</td><td>"; - formatAddress(str, m_address); - str << "</td><td>"; - //formatAddress(str, bpAddress); - //str << "</td></tr>" - // << "<tr><td>" << tr("Corrected Line Number:") - // << "</td><td>-</td><td>"; - //if (bpCorrectedLineNumber > 0) { - // str << bpCorrectedLineNumber; - // } else { - // str << '-'; - // } - str << "</td></tr>" - << "<tr><td>" << tr("Condition:") - // << "</td><td>" << m_condition << "</td><td>" << bpCondition << "</td></tr>" - << "<tr><td>" << tr("Ignore Count:") << "</td><td>"; - if (m_ignoreCount) - str << m_ignoreCount; - str << "</td><td>"; - //if (bpIgnoreCount) - // str << bpIgnoreCount; - str << "</td></tr>" - << "<tr><td>" << tr("Thread Specification:") - // << "</td><td>" << m_threadSpec << "</td><td>" << bpThreadSpec << "</td></tr>" - << "</table></body></html>"; - return rc; -} - // Compare file names case insensitively on Windows. static inline bool fileNameMatch(const QString &f1, const QString &f2) { @@ -219,7 +117,7 @@ static inline bool fileNameMatch(const QString &f1, const QString &f2) #endif } -bool BreakpointData::isLocatedAt(const QString &fileName, int lineNumber, +bool BreakpointData::isLocatedAt(const QString &fileName, int lineNumber, bool useMarkerPosition) const { int line = useMarkerPosition ? m_markerLineNumber : m_lineNumber; diff --git a/src/plugins/debugger/breakpoint.h b/src/plugins/debugger/breakpoint.h index 312cb1e5f91255cbe43989727f363674a58b4931..81e3da214afaee28b2c4572a916944cb5ce8f198 100644 --- a/src/plugins/debugger/breakpoint.h +++ b/src/plugins/debugger/breakpoint.h @@ -95,7 +95,6 @@ public: BreakpointType type() const { return m_type; } quint64 address() const { return m_address; } bool useFullPath() const { return m_useFullPath; } - QString toToolTip() const; QString toString() const; bool isLocatedAt(const QString &fileName, int lineNumber,