Commit 24912c3f authored by Christiaan Janssen's avatar Christiaan Janssen
Browse files

QmlObserver: breakpoint list is shared between engines

Reviewed by:  Kai Koehne, Andre Poenitz
parent 9dfc5b14
...@@ -65,6 +65,8 @@ BreakHandler::BreakHandler(Debugger::DebuggerEngine *engine) ...@@ -65,6 +65,8 @@ BreakHandler::BreakHandler(Debugger::DebuggerEngine *engine)
//m_emptyIcon(_(":/debugger/images/debugger_empty_14.png")), //m_emptyIcon(_(":/debugger/images/debugger_empty_14.png")),
m_watchpointIcon(_(":/debugger/images/watchpoint.png")), m_watchpointIcon(_(":/debugger/images/watchpoint.png")),
m_engine(engine), m_engine(engine),
m_bp(0),
m_masterList(false),
m_lastFound(0), m_lastFound(0),
m_lastFoundQueried(false) m_lastFoundQueried(false)
{ {
...@@ -73,6 +75,11 @@ BreakHandler::BreakHandler(Debugger::DebuggerEngine *engine) ...@@ -73,6 +75,11 @@ BreakHandler::BreakHandler(Debugger::DebuggerEngine *engine)
BreakHandler::~BreakHandler() BreakHandler::~BreakHandler()
{ {
if (m_bp && m_masterList) {
qDeleteAll(*m_bp);
m_bp->clear();
delete m_bp;
}
clear(); clear();
} }
...@@ -97,20 +104,20 @@ bool BreakHandler::hasPendingBreakpoints() const ...@@ -97,20 +104,20 @@ bool BreakHandler::hasPendingBreakpoints() const
BreakpointData *BreakHandler::at(int index) const BreakpointData *BreakHandler::at(int index) const
{ {
QTC_ASSERT(index < size(), return 0); QTC_ASSERT(index < size(), return 0);
return m_bp.at(index); QTC_ASSERT(m_bp,/**/);
return m_bp->at(index);
} }
void BreakHandler::removeAt(int index) void BreakHandler::removeAt(int index)
{ {
QTC_ASSERT(m_bp,/**/);
BreakpointData *data = at(index); BreakpointData *data = at(index);
m_bp.removeAt(index); m_bp->removeAt(index);
delete data; delete data;
} }
void BreakHandler::clear() void BreakHandler::clear()
{ {
qDeleteAll(m_bp);
m_bp.clear();
m_enabled.clear(); m_enabled.clear();
m_disabled.clear(); m_disabled.clear();
m_removed.clear(); m_removed.clear();
...@@ -119,9 +126,10 @@ void BreakHandler::clear() ...@@ -119,9 +126,10 @@ void BreakHandler::clear()
BreakpointData *BreakHandler::findSimilarBreakpoint(const BreakpointData *needle) const BreakpointData *BreakHandler::findSimilarBreakpoint(const BreakpointData *needle) const
{ {
QTC_ASSERT(m_bp, /**/);
// Search a breakpoint we might refer to. // Search a breakpoint we might refer to.
for (int index = 0; index != size(); ++index) { for (int index = 0; index != size(); ++index) {
BreakpointData *data = m_bp[index]; BreakpointData *data = (*m_bp)[index];
if (data->isSimilarTo(needle)) if (data->isSimilarTo(needle))
return data; return data;
} }
...@@ -516,8 +524,9 @@ void BreakHandler::reinsertBreakpoint(BreakpointData *data) ...@@ -516,8 +524,9 @@ void BreakHandler::reinsertBreakpoint(BreakpointData *data)
void BreakHandler::append(BreakpointData *data) void BreakHandler::append(BreakpointData *data)
{ {
QTC_ASSERT(m_bp,/**/);
data->m_handler = this; data->m_handler = this;
m_bp.append(data); m_bp->append(data);
m_inserted.append(data); m_inserted.append(data);
} }
...@@ -554,8 +563,9 @@ Breakpoints BreakHandler::takeDisabledBreakpoints() ...@@ -554,8 +563,9 @@ Breakpoints BreakHandler::takeDisabledBreakpoints()
void BreakHandler::removeBreakpointHelper(int index) void BreakHandler::removeBreakpointHelper(int index)
{ {
BreakpointData *data = m_bp.at(index); QTC_ASSERT(m_bp,/**/);
m_bp.removeAt(index); BreakpointData *data = m_bp->at(index);
m_bp->removeAt(index);
data->removeMarker(); data->removeMarker();
m_removed.append(data); m_removed.append(data);
} }
...@@ -570,7 +580,8 @@ void BreakHandler::removeBreakpoint(int index) ...@@ -570,7 +580,8 @@ void BreakHandler::removeBreakpoint(int index)
void BreakHandler::removeBreakpoint(BreakpointData *data) void BreakHandler::removeBreakpoint(BreakpointData *data)
{ {
removeBreakpointHelper(m_bp.indexOf(data)); QTC_ASSERT(m_bp,/**/);
removeBreakpointHelper(m_bp->indexOf(data));
emit layoutChanged(); emit layoutChanged();
} }
...@@ -614,7 +625,8 @@ void BreakHandler::removeAllBreakpoints() ...@@ -614,7 +625,8 @@ void BreakHandler::removeAllBreakpoints()
BreakpointData *BreakHandler::findBreakpoint(quint64 address) const BreakpointData *BreakHandler::findBreakpoint(quint64 address) const
{ {
foreach (BreakpointData *data, m_bp) QTC_ASSERT(m_bp,/**/);
foreach (BreakpointData *data, *m_bp)
if (data->address == address) if (data->address == address)
return data; return data;
return 0; return 0;
...@@ -623,7 +635,8 @@ BreakpointData *BreakHandler::findBreakpoint(quint64 address) const ...@@ -623,7 +635,8 @@ BreakpointData *BreakHandler::findBreakpoint(quint64 address) const
BreakpointData *BreakHandler::findBreakpoint(const QString &fileName, BreakpointData *BreakHandler::findBreakpoint(const QString &fileName,
int lineNumber, bool useMarkerPosition) int lineNumber, bool useMarkerPosition)
{ {
foreach (BreakpointData *data, m_bp) QTC_ASSERT(m_bp,/**/);
foreach (BreakpointData *data, *m_bp)
if (data->isLocatedAt(fileName, lineNumber, useMarkerPosition)) if (data->isLocatedAt(fileName, lineNumber, useMarkerPosition))
return data; return data;
return 0; return 0;
...@@ -633,15 +646,14 @@ void BreakHandler::toggleBreakpoint(const QString &fileName, int lineNumber, ...@@ -633,15 +646,14 @@ void BreakHandler::toggleBreakpoint(const QString &fileName, int lineNumber,
quint64 address /* = 0 */) quint64 address /* = 0 */)
{ {
BreakpointData *data = 0; BreakpointData *data = 0;
do {
if (address) { if (address) {
data = findBreakpoint(address); data = findBreakpoint(address);
break; } else {
}
data = findBreakpoint(fileName, lineNumber, true); data = findBreakpoint(fileName, lineNumber, true);
if (!data) if (!data)
data = findBreakpoint(fileName, lineNumber, false); data = findBreakpoint(fileName, lineNumber, false);
} while (false); }
if (data) { if (data) {
removeBreakpoint(data); removeBreakpoint(data);
...@@ -667,9 +679,19 @@ void BreakHandler::saveSessionData() ...@@ -667,9 +679,19 @@ void BreakHandler::saveSessionData()
saveBreakpoints(); saveBreakpoints();
} }
void BreakHandler::initMasterList()
{
if (m_bp) {
delete m_bp;
}
m_masterList = true;
m_bp = new Breakpoints;
}
void BreakHandler::loadSessionData() void BreakHandler::loadSessionData()
{ {
QTC_ASSERT(m_engine->isSessionEngine(), return); QTC_ASSERT(m_engine->isSessionEngine(), return);
initMasterList();
loadBreakpoints(); loadBreakpoints();
updateMarkers(); updateMarkers();
} }
...@@ -697,23 +719,33 @@ bool BreakHandler::isActive() const ...@@ -697,23 +719,33 @@ bool BreakHandler::isActive() const
return m_engine->isActive(); return m_engine->isActive();
} }
bool BreakHandler::isMasterList() const
{
return m_masterList;
}
void BreakHandler::initializeFromTemplate(BreakHandler *other) void BreakHandler::initializeFromTemplate(BreakHandler *other)
{ {
QTC_ASSERT(m_bp.isEmpty(), /**/); QTC_ASSERT(other->isMasterList(), /**/);
foreach (BreakpointData *data, other->m_bp) { QTC_ASSERT(!isMasterList(), /**/);
append(data->clone()); QTC_ASSERT(other->m_bp,/**/);
data->removeMarker();
m_bp = other->m_bp;
foreach(BreakpointData *data, *m_bp) {
if (m_engine->acceptsBreakpoint(data))
data->m_handler = this;
} }
updateMarkers();
} }
void BreakHandler::storeToTemplate(BreakHandler *other) void BreakHandler::storeToTemplate(BreakHandler *other)
{ {
other->removeAllBreakpoints(); QTC_ASSERT(m_bp,/**/);
foreach (const BreakpointData *data, m_bp) foreach (BreakpointData *data, *m_bp) {
other->append(data->clone()); data->m_handler = other;
removeAllBreakpoints(); }
other->updateMarkers(); m_bp = 0;
other->saveSessionData(); other->saveSessionData();
} }
......
...@@ -64,11 +64,11 @@ public: ...@@ -64,11 +64,11 @@ public:
QAbstractItemModel *model() { return this; } QAbstractItemModel *model() { return this; }
BreakpointData *at(int index) const; BreakpointData *at(int index) const;
int size() const { return m_bp.size(); } int size() const { return m_bp?m_bp->size():0; }
bool hasPendingBreakpoints() const; bool hasPendingBreakpoints() const;
void removeAt(int index); // This also deletes the marker. void removeAt(int index); // This also deletes the marker.
void clear(); // This also deletes all the marker. void clear(); // This also deletes all the marker.
int indexOf(BreakpointData *data) { return m_bp.indexOf(data); } int indexOf(BreakpointData *data) { return m_bp?m_bp->indexOf(data):-1; }
// Find a breakpoint matching approximately the data in needle. // Find a breakpoint matching approximately the data in needle.
BreakpointData *findSimilarBreakpoint(const BreakpointData *needle) const; BreakpointData *findSimilarBreakpoint(const BreakpointData *needle) const;
BreakpointData *findBreakpointByNumber(int bpNumber) const; BreakpointData *findBreakpointByNumber(int bpNumber) const;
...@@ -76,6 +76,7 @@ public: ...@@ -76,6 +76,7 @@ public:
bool watchPointAt(quint64 address) const; bool watchPointAt(quint64 address) const;
void updateMarkers(); void updateMarkers();
bool isActive() const; bool isActive() const;
bool isMasterList() const;
Breakpoints insertedBreakpoints() const; Breakpoints insertedBreakpoints() const;
void takeInsertedBreakPoint(BreakpointData *); void takeInsertedBreakPoint(BreakpointData *);
...@@ -121,6 +122,8 @@ private: ...@@ -121,6 +122,8 @@ private:
void removeBreakpointHelper(int index); void removeBreakpointHelper(int index);
void append(BreakpointData *data); void append(BreakpointData *data);
void initMasterList();
const QIcon m_breakpointIcon; const QIcon m_breakpointIcon;
const QIcon m_disabledBreakpointIcon; const QIcon m_disabledBreakpointIcon;
const QIcon m_pendingBreakPointIcon; const QIcon m_pendingBreakPointIcon;
...@@ -128,12 +131,14 @@ private: ...@@ -128,12 +131,14 @@ private:
const QIcon m_watchpointIcon; const QIcon m_watchpointIcon;
Debugger::DebuggerEngine *m_engine; // Not owned. Debugger::DebuggerEngine *m_engine; // Not owned.
Breakpoints m_bp; Breakpoints *m_bp;
Breakpoints m_inserted; // Lately inserted breakpoints. Breakpoints m_inserted; // Lately inserted breakpoints.
Breakpoints m_removed; // Lately removed breakpoints. Breakpoints m_removed; // Lately removed breakpoints.
Breakpoints m_enabled; // Lately enabled breakpoints. Breakpoints m_enabled; // Lately enabled breakpoints.
Breakpoints m_disabled; // Lately disabled breakpoints. Breakpoints m_disabled; // Lately disabled breakpoints.
bool m_masterList;
// Hack for BreakWindow::findSimilarBreakpoint // Hack for BreakWindow::findSimilarBreakpoint
mutable BreakpointData *m_lastFound; mutable BreakpointData *m_lastFound;
mutable bool m_lastFoundQueried; mutable bool m_lastFoundQueried;
......
...@@ -1667,6 +1667,11 @@ void DebuggerEngine::attemptBreakpointSynchronization() ...@@ -1667,6 +1667,11 @@ void DebuggerEngine::attemptBreakpointSynchronization()
{ {
} }
bool DebuggerEngine::acceptsBreakpoint(const BreakpointData *)
{
return true;
}
void DebuggerEngine::selectThread(int) void DebuggerEngine::selectThread(int)
{ {
} }
......
...@@ -129,6 +129,7 @@ class StackFrame; ...@@ -129,6 +129,7 @@ class StackFrame;
class SourceFilesHandler; class SourceFilesHandler;
class ThreadsHandler; class ThreadsHandler;
class WatchHandler; class WatchHandler;
class BreakpointData;
struct WatchUpdateFlags struct WatchUpdateFlags
{ {
...@@ -182,6 +183,7 @@ public: ...@@ -182,6 +183,7 @@ public:
virtual void updateAll(); virtual void updateAll();
virtual void attemptBreakpointSynchronization(); virtual void attemptBreakpointSynchronization();
virtual bool acceptsBreakpoint(const Internal::BreakpointData *);
virtual void selectThread(int index); virtual void selectThread(int index);
virtual void assignValueInDebugger(const Internal::WatchData *w, const QString &expr, const QVariant &value); virtual void assignValueInDebugger(const Internal::WatchData *w, const QString &expr, const QVariant &value);
......
...@@ -2580,6 +2580,11 @@ void GdbEngine::attemptBreakpointSynchronization() ...@@ -2580,6 +2580,11 @@ void GdbEngine::attemptBreakpointSynchronization()
handler->updateMarkers(); handler->updateMarkers();
} }
bool GdbEngine::acceptsBreakpoint(const Internal::BreakpointData *br)
{
return !( br->fileName.endsWith(QLatin1String("js")) || br->fileName.endsWith(QLatin1String("qml")) );
}
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
......
...@@ -309,6 +309,7 @@ private: ////////// Inferior Management ////////// ...@@ -309,6 +309,7 @@ private: ////////// Inferior Management //////////
// This should be always the last call in a function. // This should be always the last call in a function.
Q_SLOT virtual void attemptBreakpointSynchronization(); Q_SLOT virtual void attemptBreakpointSynchronization();
bool acceptsBreakpoint(const Internal::BreakpointData *br);
virtual void executeStep(); virtual void executeStep();
virtual void executeStepOut(); virtual void executeStepOut();
......
...@@ -222,6 +222,11 @@ void QmlCppEngine::attemptBreakpointSynchronization() ...@@ -222,6 +222,11 @@ void QmlCppEngine::attemptBreakpointSynchronization()
static_cast<DebuggerEngine*>(d->m_qmlEngine)->attemptBreakpointSynchronization(); static_cast<DebuggerEngine*>(d->m_qmlEngine)->attemptBreakpointSynchronization();
} }
bool QmlCppEngine::acceptsBreakpoint(const Internal::BreakpointData *br)
{
return d->m_cppEngine->acceptsBreakpoint(br) || d->m_qmlEngine->acceptsBreakpoint(br);
}
void QmlCppEngine::selectThread(int index) void QmlCppEngine::selectThread(int index)
{ {
d->m_cppEngine->selectThread(index); d->m_cppEngine->selectThread(index);
......
...@@ -52,6 +52,7 @@ public: ...@@ -52,6 +52,7 @@ public:
virtual void updateAll(); virtual void updateAll();
virtual void attemptBreakpointSynchronization(); virtual void attemptBreakpointSynchronization();
virtual bool acceptsBreakpoint(const Internal::BreakpointData *br);
virtual void selectThread(int index); virtual void selectThread(int index);
virtual void assignValueInDebugger(const Internal::WatchData *w, const QString &expr, const QVariant &value); virtual void assignValueInDebugger(const Internal::WatchData *w, const QString &expr, const QVariant &value);
......
...@@ -460,6 +460,11 @@ void QmlEngine::attemptBreakpointSynchronization() ...@@ -460,6 +460,11 @@ void QmlEngine::attemptBreakpointSynchronization()
} }
} }
bool QmlEngine::acceptsBreakpoint(const Internal::BreakpointData *br)
{
return (br->fileName.endsWith(QLatin1String("qml")) || br->fileName.endsWith(QLatin1String("js")));
}
void QmlEngine::loadSymbols(const QString &moduleName) void QmlEngine::loadSymbols(const QString &moduleName)
{ {
Q_UNUSED(moduleName) Q_UNUSED(moduleName)
......
...@@ -93,6 +93,7 @@ private: ...@@ -93,6 +93,7 @@ private:
void selectThread(int index); void selectThread(int index);
void attemptBreakpointSynchronization(); void attemptBreakpointSynchronization();
bool acceptsBreakpoint(const Internal::BreakpointData *br);
void assignValueInDebugger(const Internal::WatchData *w, const QString &expr, const QVariant &value); void assignValueInDebugger(const Internal::WatchData *w, const QString &expr, const QVariant &value);
void loadSymbols(const QString &moduleName); void loadSymbols(const QString &moduleName);
......
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