Commit 482db08b authored by hjk's avatar hjk
Browse files

debugger: move breakpoit tooltip from BreakpointData to BreakpointHandler

It also shows the response data.
parent 956b5428
......@@ -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>&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
......
......@@ -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.
......
......@@ -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>&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.
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;
......
......@@ -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,
......
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