forked from qt-creator/qt-creator
debugger: move marker filename and linenumber to BreakpointItem
This commit is contained in:
@@ -162,7 +162,7 @@ BreakpointId BreakHandler::findBreakpointByFileAndLine(const QString &fileName,
|
||||
{
|
||||
ConstIterator it = m_storage.constBegin(), et = m_storage.constEnd();
|
||||
for ( ; it != et; ++it)
|
||||
if (it->data.isLocatedAt(fileName, lineNumber, useMarkerPosition))
|
||||
if (it->isLocatedAt(fileName, lineNumber, useMarkerPosition))
|
||||
return it.key();
|
||||
return BreakpointId(-1);
|
||||
}
|
||||
@@ -305,15 +305,14 @@ void BreakHandler::updateMarker(BreakpointId id)
|
||||
{
|
||||
Iterator it = m_storage.find(id);
|
||||
QTC_ASSERT(it != m_storage.end(), return);
|
||||
const BreakpointData &data = it->data;
|
||||
BreakpointMarker *marker = it->marker;
|
||||
|
||||
if (marker && (data.m_markerFileName != marker->fileName()
|
||||
|| data.m_markerLineNumber != marker->lineNumber()))
|
||||
if (marker && (it->markerFileName != marker->fileName()
|
||||
|| it->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);
|
||||
if (!marker && !it->markerFileName.isEmpty() && it->markerLineNumber > 0) {
|
||||
marker = new BreakpointMarker(id, it->markerFileName, it->markerLineNumber);
|
||||
it->marker = marker;
|
||||
}
|
||||
}
|
||||
@@ -491,10 +490,8 @@ void BreakHandler::setter(BreakpointId id, const type &value) \
|
||||
|
||||
|
||||
PROPERTY(bool, useFullPath, setUseFullPath)
|
||||
PROPERTY(QString, markerFileName, setMarkerFileName)
|
||||
PROPERTY(QString, fileName, setFileName)
|
||||
PROPERTY(QString, functionName, setFunctionName)
|
||||
PROPERTY(int, markerLineNumber, setMarkerLineNumber)
|
||||
PROPERTY(BreakpointType, type, setType)
|
||||
PROPERTY(QByteArray, threadSpec, setThreadSpec)
|
||||
PROPERTY(QByteArray, condition, setCondition)
|
||||
@@ -522,6 +519,16 @@ void BreakHandler::setEnabled(BreakpointId id, bool on)
|
||||
}
|
||||
}
|
||||
|
||||
void BreakHandler::setMarkerFileAndLine(BreakpointId id,
|
||||
const QString &fileName, int lineNumber)
|
||||
{
|
||||
Iterator it = m_storage.find(id);
|
||||
QTC_ASSERT(it != m_storage.end(), return);
|
||||
it->markerFileName = fileName;
|
||||
it->markerLineNumber = lineNumber;
|
||||
updateMarker(id);
|
||||
}
|
||||
|
||||
BreakpointState BreakHandler::state(BreakpointId id) const
|
||||
{
|
||||
ConstIterator it = m_storage.find(id);
|
||||
@@ -728,8 +735,8 @@ void BreakHandler::updateLineNumberFromMarker(BreakpointId id, int lineNumber)
|
||||
QTC_ASSERT(it != m_storage.end(), return);
|
||||
//if (data.markerLineNumber == lineNumber)
|
||||
// return;
|
||||
if (it->data.markerLineNumber() != lineNumber) {
|
||||
it->data.setMarkerLineNumber(lineNumber);
|
||||
if (it->markerLineNumber != lineNumber) {
|
||||
it->markerLineNumber = lineNumber;
|
||||
// FIXME: Should we tell gdb about the change?
|
||||
// Ignore it for now, as we would require re-compilation
|
||||
// and debugger re-start anyway.
|
||||
@@ -849,6 +856,17 @@ void BreakHandler::setResponse(BreakpointId id, const BreakpointResponse &data)
|
||||
updateMarker(id);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Storage
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
BreakHandler::BreakpointItem::BreakpointItem()
|
||||
: state(BreakpointNew), engine(0), marker(0), markerLineNumber(0)
|
||||
{}
|
||||
|
||||
void BreakHandler::BreakpointItem::destroyMarker()
|
||||
{
|
||||
BreakpointMarker *m = marker;
|
||||
@@ -883,6 +901,13 @@ static QString stateToString(BreakpointState state)
|
||||
}
|
||||
};
|
||||
|
||||
bool BreakHandler::BreakpointItem::isLocatedAt
|
||||
(const QString &fileName, int lineNumber, bool useMarkerPosition) const
|
||||
{
|
||||
int line = useMarkerPosition ? markerLineNumber : data.lineNumber();
|
||||
return lineNumber == line && fileNameMatch(fileName, markerFileName);
|
||||
}
|
||||
|
||||
QString BreakHandler::BreakpointItem::toToolTip() const
|
||||
{
|
||||
QString t;
|
||||
@@ -923,9 +948,9 @@ QString BreakHandler::BreakpointItem::toToolTip() const
|
||||
<< "<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>"
|
||||
<< "</td><td>" << QDir::toNativeSeparators(markerFileName) << "</td></tr>"
|
||||
<< "<tr><td>" << tr("Marker Line:")
|
||||
<< "</td><td>" << data.m_markerLineNumber << "</td></tr>"
|
||||
<< "</td><td>" << markerLineNumber << "</td></tr>"
|
||||
<< "<tr><td>" << tr("Breakpoint Number:")
|
||||
<< "</td><td>" << response.number << "</td></tr>"
|
||||
<< "<tr><td>" << tr("Breakpoint Type:")
|
||||
|
@@ -44,6 +44,9 @@
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace Debugger {
|
||||
|
||||
class DebuggerEngine;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class BreakpointMarker;
|
||||
@@ -105,8 +108,8 @@ public:
|
||||
void setter(BreakpointId id, const type &value);
|
||||
|
||||
PROPERTY(bool, useFullPath, setUseFullPath)
|
||||
PROPERTY(QString, markerFileName, setMarkerFileName)
|
||||
PROPERTY(int, markerLineNumber, setMarkerLineNumber)
|
||||
//PROPERTY(QString, markerFileName, setMarkerFileName)
|
||||
//PROPERTY(int, markerLineNumber, setMarkerLineNumber)
|
||||
PROPERTY(QByteArray, condition, setCondition)
|
||||
PROPERTY(int, ignoreCount, setIgnoreCount)
|
||||
PROPERTY(QByteArray, threadSpec, setThreadSpec)
|
||||
@@ -120,6 +123,8 @@ public:
|
||||
bool isEnabled(BreakpointId id) const;
|
||||
void setEnabled(BreakpointId id, bool on);
|
||||
void updateLineNumberFromMarker(BreakpointId id, int lineNumber);
|
||||
void setMarkerFileAndLine(BreakpointId id,
|
||||
const QString &fileName, int lineNumber);
|
||||
|
||||
DebuggerEngine *engine(BreakpointId id) const;
|
||||
void setEngine(BreakpointId id, DebuggerEngine *engine);
|
||||
@@ -168,10 +173,13 @@ private:
|
||||
|
||||
struct BreakpointItem
|
||||
{
|
||||
BreakpointItem() : state(BreakpointNew), engine(0), marker(0) {}
|
||||
BreakpointItem();
|
||||
|
||||
void destroyMarker();
|
||||
bool isPending() const { return state == BreakpointPending
|
||||
|| state == BreakpointNew; }
|
||||
bool isLocatedAt(const QString &fileName, int lineNumber,
|
||||
bool useMarkerPosition) const;
|
||||
QString toToolTip() const;
|
||||
|
||||
BreakpointData data;
|
||||
@@ -179,6 +187,8 @@ private:
|
||||
DebuggerEngine *engine; // Engine currently handling the breakpoint.
|
||||
BreakpointResponse response;
|
||||
BreakpointMarker *marker;
|
||||
QString markerFileName; // Used to locate the marker.
|
||||
int markerLineNumber;
|
||||
};
|
||||
typedef QHash<BreakpointId, BreakpointItem> BreakpointStorage;
|
||||
typedef BreakpointStorage::ConstIterator ConstIterator;
|
||||
|
@@ -57,74 +57,68 @@ bool BreakpointParameters::equals(const BreakpointParameters &rhs) const
|
||||
&& functionName == rhs.functionName;
|
||||
}
|
||||
|
||||
BreakpointData::BreakpointData(BreakpointType type) :
|
||||
m_parameters(type), m_markerLineNumber(0)
|
||||
{
|
||||
}
|
||||
BreakpointData::BreakpointData(BreakpointType type)
|
||||
: m_parameters(type)
|
||||
{}
|
||||
|
||||
BreakpointResponse::BreakpointResponse() :
|
||||
number(0), multiple(false)
|
||||
{
|
||||
}
|
||||
BreakpointResponse::BreakpointResponse()
|
||||
: number(0), multiple(false)
|
||||
{}
|
||||
|
||||
#define SETIT(var, value) return (var != value) && (var = value, true)
|
||||
|
||||
bool BreakpointData::setUseFullPath(bool on)
|
||||
{ SETIT(m_parameters.useFullPath, on); }
|
||||
|
||||
bool BreakpointData::setMarkerFileName(const QString &file)
|
||||
{ SETIT(m_markerFileName, file); }
|
||||
|
||||
bool BreakpointData::setMarkerLineNumber(int line)
|
||||
{ SETIT(m_markerLineNumber, line); }
|
||||
{
|
||||
SETIT(m_parameters.useFullPath, on);
|
||||
}
|
||||
|
||||
bool BreakpointData::setFileName(const QString &file)
|
||||
{ SETIT(m_parameters.fileName, file); }
|
||||
{
|
||||
SETIT(m_parameters.fileName, file);
|
||||
}
|
||||
|
||||
bool BreakpointData::setEnabled(bool on)
|
||||
{ SETIT(m_parameters.enabled, on); }
|
||||
{
|
||||
SETIT(m_parameters.enabled, on);
|
||||
}
|
||||
|
||||
bool BreakpointData::setIgnoreCount(int count)
|
||||
{ SETIT(m_parameters.ignoreCount, count); }
|
||||
{
|
||||
SETIT(m_parameters.ignoreCount, count);
|
||||
}
|
||||
|
||||
bool BreakpointData::setFunctionName(const QString &name)
|
||||
{ SETIT(m_parameters.functionName, name); }
|
||||
{
|
||||
SETIT(m_parameters.functionName, name);
|
||||
}
|
||||
|
||||
bool BreakpointData::setLineNumber(int line)
|
||||
{ SETIT(m_parameters.lineNumber, line); }
|
||||
{
|
||||
SETIT(m_parameters.lineNumber, line);
|
||||
}
|
||||
|
||||
bool BreakpointData::setAddress(quint64 address)
|
||||
{ SETIT(m_parameters.address, address); }
|
||||
{
|
||||
SETIT(m_parameters.address, address);
|
||||
}
|
||||
|
||||
bool BreakpointData::setThreadSpec(const QByteArray &spec)
|
||||
{ SETIT(m_parameters.threadSpec, spec); }
|
||||
{
|
||||
SETIT(m_parameters.threadSpec, spec);
|
||||
}
|
||||
|
||||
bool BreakpointData::setType(BreakpointType type)
|
||||
{ SETIT(m_parameters.type, type); }
|
||||
{
|
||||
SETIT(m_parameters.type, type);
|
||||
}
|
||||
|
||||
bool BreakpointData::setCondition(const QByteArray &cond)
|
||||
{ SETIT(m_parameters.condition, cond); }
|
||||
{
|
||||
SETIT(m_parameters.condition, cond);
|
||||
}
|
||||
|
||||
#undef SETIT
|
||||
|
||||
|
||||
// Compare file names case insensitively on Windows.
|
||||
static inline bool fileNameMatch(const QString &f1, const QString &f2)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
return f1.compare(f2, Qt::CaseInsensitive) == 0;
|
||||
#else
|
||||
return f1 == f2;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool BreakpointData::isLocatedAt(const QString &fileName, int lineNumber,
|
||||
bool useMarkerPosition) const
|
||||
{
|
||||
int line = useMarkerPosition ? m_markerLineNumber : m_parameters.lineNumber;
|
||||
return lineNumber == line && fileNameMatch(fileName, m_markerFileName);
|
||||
}
|
||||
|
||||
bool BreakpointData::conditionsMatch(const QByteArray &other) const
|
||||
{
|
||||
// Some versions of gdb "beautify" the passed condition.
|
||||
|
@@ -37,8 +37,6 @@
|
||||
|
||||
namespace Debugger {
|
||||
|
||||
class DebuggerEngine;
|
||||
|
||||
typedef quint64 BreakpointId; // FIXME: make Internal.
|
||||
|
||||
namespace Internal {
|
||||
@@ -82,7 +80,8 @@ enum BreakpointState
|
||||
BreakpointDead,
|
||||
};
|
||||
|
||||
class BreakpointParameters {
|
||||
class BreakpointParameters
|
||||
{
|
||||
public:
|
||||
explicit BreakpointParameters(BreakpointType = UnknownType);
|
||||
bool equals(const BreakpointParameters &rhs) const;
|
||||
@@ -113,20 +112,16 @@ private:
|
||||
friend QDataStream &operator>>(QDataStream& stream, BreakpointData &data);
|
||||
|
||||
public:
|
||||
explicit BreakpointData(BreakpointType = UnknownType);
|
||||
explicit BreakpointData(BreakpointType type = UnknownType);
|
||||
|
||||
BreakpointType type() const { return m_parameters.type; }
|
||||
quint64 address() const { return m_parameters.address; }
|
||||
bool useFullPath() const { return m_parameters.useFullPath; }
|
||||
QString toString() const;
|
||||
|
||||
bool isLocatedAt(const QString &fileName, int lineNumber,
|
||||
bool useMarkerPosition) const;
|
||||
bool conditionsMatch(const QByteArray &other) const;
|
||||
QString functionName() const { return m_parameters.functionName; }
|
||||
QString markerFileName() const { return m_markerFileName; }
|
||||
QString fileName() const { return m_parameters.fileName; }
|
||||
int markerLineNumber() const { return m_markerLineNumber; }
|
||||
int lineNumber() const { return m_parameters.lineNumber; }
|
||||
int ignoreCount() const { return m_parameters.ignoreCount; }
|
||||
bool isEnabled() const { return m_parameters.enabled; }
|
||||
@@ -155,8 +150,6 @@ private:
|
||||
private:
|
||||
// This "user requested information" will get stored in the session.
|
||||
BreakpointParameters m_parameters;
|
||||
QString m_markerFileName; // Used to locate the marker.
|
||||
int m_markerLineNumber;
|
||||
|
||||
public:
|
||||
Q_DECLARE_TR_FUNCTIONS(BreakHandler)
|
||||
|
@@ -2686,7 +2686,7 @@ void GdbEngine::removeBreakpoint(BreakpointId id)
|
||||
handler->setState(id, BreakpointRemoveProceeding);
|
||||
BreakpointResponse br = handler->response(id);
|
||||
showMessage(_("DELETING BP %1 IN ").arg(br.number)
|
||||
+ handler->markerFileName(id));
|
||||
+ handler->fileName(id));
|
||||
postCommand("-break-delete " + QByteArray::number(br.number),
|
||||
NeedsStop | RebuildBreakpointModel);
|
||||
// Pretend it succeeds without waiting for response. Feels better.
|
||||
|
Reference in New Issue
Block a user