debugger: move breakpoit tooltip from BreakpointData to BreakpointHandler

It also shows the response data.
This commit is contained in:
hjk
2010-11-15 14:27:06 +01:00
parent 956b54289e
commit 482db08b00
4 changed files with 111 additions and 122 deletions

View File

@@ -32,6 +32,7 @@
#include "debuggeractions.h" #include "debuggeractions.h"
#include "debuggercore.h" #include "debuggercore.h"
#include "debuggerengine.h"
#include "debuggerstringutils.h" #include "debuggerstringutils.h"
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -312,10 +313,8 @@ void BreakHandler::updateMarker(BreakpointId id)
BreakpointMarker *marker = it->marker; BreakpointMarker *marker = it->marker;
if (marker && (data.m_markerFileName != marker->fileName() if (marker && (data.m_markerFileName != marker->fileName()
|| data.m_markerLineNumber != marker->lineNumber())) { || data.m_markerLineNumber != marker->lineNumber()))
removeMarker(id); it->destroyMarker();
marker = 0;
}
if (!marker && !data.m_markerFileName.isEmpty() && data.m_markerLineNumber > 0) { if (!marker && !data.m_markerFileName.isEmpty() && data.m_markerLineNumber > 0) {
marker = new BreakpointMarker(id, data.m_markerFileName, data.m_markerLineNumber); 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, QVariant BreakHandler::headerData(int section,
Qt::Orientation orientation, int role) const Qt::Orientation orientation, int role) const
{ {
@@ -462,7 +453,7 @@ QVariant BreakHandler::data(const QModelIndex &mi, int role) const
} }
if (role == Qt::ToolTipRole) if (role == Qt::ToolTipRole)
return debuggerCore()->boolSetting(UseToolTipsInBreakpointsView) return debuggerCore()->boolSetting(UseToolTipsInBreakpointsView)
? data.toToolTip() : QVariant(); ? QVariant(it->toToolTip()) : QVariant();
return QVariant(); return QVariant();
} }
@@ -799,7 +790,7 @@ void BreakHandler::cleanupBreakpoint(BreakpointId id)
{ {
QTC_ASSERT(state(id) == BreakpointDead, /**/); QTC_ASSERT(state(id) == BreakpointDead, /**/);
BreakpointItem item = m_storage.take(id); BreakpointItem item = m_storage.take(id);
item.destroy(); item.destroyMarker();
} }
BreakpointResponse BreakHandler::response(BreakpointId id) const BreakpointResponse BreakHandler::response(BreakpointId id) const
@@ -836,10 +827,110 @@ void BreakHandler::notifyBreakpointAdjusted(BreakpointId id)
} }
#endif #endif
void BreakHandler::BreakpointItem::destroy() void BreakHandler::BreakpointItem::destroyMarker()
{ {
delete marker; BreakpointMarker *m = marker;
marker = 0; 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>&mdash;</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 } // namespace Internal

View File

@@ -79,7 +79,6 @@ public:
void setWatchpointByAddress(quint64 address); void setWatchpointByAddress(quint64 address);
bool hasWatchpointAt(quint64 address) const; bool hasWatchpointAt(quint64 address) const;
void updateMarkers(); void updateMarkers();
void removeMarker(BreakpointId id);
QIcon breakpointIcon() const { return m_breakpointIcon; } QIcon breakpointIcon() const { return m_breakpointIcon; }
QIcon disabledBreakpointIcon() const { return m_disabledBreakpointIcon; } QIcon disabledBreakpointIcon() const { return m_disabledBreakpointIcon; }
@@ -139,6 +138,7 @@ public:
void notifyBreakpointRemoveFailed(BreakpointId id); void notifyBreakpointRemoveFailed(BreakpointId id);
void notifyBreakpointReleased(BreakpointId id); void notifyBreakpointReleased(BreakpointId id);
public: public:
// FIXME: Make private. // FIXME: Make private.
void setState(BreakpointId id, BreakpointState state); void setState(BreakpointId id, BreakpointState state);
@@ -171,9 +171,10 @@ private:
struct BreakpointItem struct BreakpointItem
{ {
BreakpointItem() : state(BreakpointNew), engine(0), marker(0) {} BreakpointItem() : state(BreakpointNew), engine(0), marker(0) {}
void destroy(); void destroyMarker();
bool isPending() const { return state == BreakpointPending bool isPending() const { return state == BreakpointPending
|| state == BreakpointNew; } || state == BreakpointNew; }
QString toToolTip() const;
BreakpointData data; BreakpointData data;
BreakpointState state; // Current state of breakpoint. BreakpointState state; // Current state of breakpoint.

View File

@@ -28,15 +28,9 @@
**************************************************************************/ **************************************************************************/
#include "breakpoint.h" #include "breakpoint.h"
#include "stackframe.h"
#include <utils/qtcassert.h>
#include <QtCore/QByteArray> #include <QtCore/QByteArray>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QTextStream>
#include <QtCore/QFileInfo>
#include <QtCore/QDir>
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
@@ -113,102 +107,6 @@ bool BreakpointData::setCondition(const QByteArray &cond)
#undef SETIT #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>&mdash;</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. // Compare file names case insensitively on Windows.
static inline bool fileNameMatch(const QString &f1, const QString &f2) static inline bool fileNameMatch(const QString &f1, const QString &f2)
{ {

View File

@@ -95,7 +95,6 @@ public:
BreakpointType type() const { return m_type; } BreakpointType type() const { return m_type; }
quint64 address() const { return m_address; } quint64 address() const { return m_address; }
bool useFullPath() const { return m_useFullPath; } bool useFullPath() const { return m_useFullPath; }
QString toToolTip() const;
QString toString() const; QString toString() const;
bool isLocatedAt(const QString &fileName, int lineNumber, bool isLocatedAt(const QString &fileName, int lineNumber,