From 7f34b5008b31b8a85acfef952ef019909eef285e Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 29 Mar 2011 12:55:36 +0200 Subject: [PATCH] febugger: prepare for saner handling of changed breakpoints --- src/plugins/debugger/breakhandler.cpp | 12 +++---- src/plugins/debugger/breakhandler.h | 3 +- src/plugins/debugger/breakpoint.cpp | 47 +++++++++++++++++++-------- src/plugins/debugger/breakpoint.h | 30 +++++++++++++++++ src/plugins/debugger/breakwindow.cpp | 16 +++++---- 5 files changed, 82 insertions(+), 26 deletions(-) diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index f4a3200d0f5..b1db0f5d872 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -1092,21 +1092,21 @@ void BreakHandler::setResponse(BreakpointId id, updateMarker(id); } -void BreakHandler::setBreakpointData(BreakpointId id, - const BreakpointParameters &data) +void BreakHandler::changeBreakpointData(BreakpointId id, + const BreakpointParameters &data, BreakpointParts parts) { Iterator it = m_storage.find(id); QTC_ASSERT(it != m_storage.end(), return); if (data == it->data) return; it->data = data; - if (it->needsChange() && it->engine && it->state != BreakpointNew) { - setState(id, BreakpointChangeRequested); - scheduleSynchronization(); - } else { + if (parts == NoParts) { it->destroyMarker(); updateMarker(id); layoutChanged(); + } else if (it->needsChange() && it->engine && it->state != BreakpointNew) { + setState(id, BreakpointChangeRequested); + scheduleSynchronization(); } } diff --git a/src/plugins/debugger/breakhandler.h b/src/plugins/debugger/breakhandler.h index ce3cbfdbb8a..7a85367653b 100644 --- a/src/plugins/debugger/breakhandler.h +++ b/src/plugins/debugger/breakhandler.h @@ -121,7 +121,8 @@ public: quint64 address(BreakpointId id) const; void setAddress(BreakpointId id, const quint64 &address); int lineNumber(BreakpointId id) const; - void setBreakpointData(BreakpointId id, const BreakpointParameters &data); + void changeBreakpointData(BreakpointId id, const BreakpointParameters &data, + BreakpointParts parts); const BreakpointParameters &breakpointData(BreakpointId id) const; BreakpointState state(BreakpointId id) const; bool isEnabled(BreakpointId id) const; diff --git a/src/plugins/debugger/breakpoint.cpp b/src/plugins/debugger/breakpoint.cpp index 8a6c69b5ddc..c11963dc929 100644 --- a/src/plugins/debugger/breakpoint.cpp +++ b/src/plugins/debugger/breakpoint.cpp @@ -58,21 +58,42 @@ BreakpointParameters::BreakpointParameters(BreakpointType t) tracepoint(false) {} +BreakpointParts BreakpointParameters::differencesTo + (const BreakpointParameters &rhs) const +{ + BreakpointParts parts = BreakpointParts(); + if (type != rhs.type) + parts |= TypePart; + if (enabled != rhs.enabled) + parts |= EnabledPart; + if (pathUsage != rhs.pathUsage) + parts |= PathUsagePart; + if (fileName != rhs.fileName) + parts |= FileAndLinePart; + if (conditionsMatch(rhs.condition)) + parts |= ConditionPart; + if (ignoreCount != rhs.ignoreCount) + parts |= IgnoreCountPart; + if (lineNumber != rhs.lineNumber) + parts |= FileAndLinePart; + if (address != rhs.address) + parts |= AddressPart; + if (threadSpec != rhs.threadSpec) + parts |= ThreadSpecPart; + if (functionName != rhs.functionName) + parts |= FunctionPart; + if (tracepoint != rhs.tracepoint) + parts |= TracePointPart; + if (module != rhs.module) + parts |= ModulePart; + if (command != rhs.command) + parts |= CommandPart; + return parts; +} + bool BreakpointParameters::equals(const BreakpointParameters &rhs) const { - return type == rhs.type - && enabled == rhs.enabled - && pathUsage == rhs.pathUsage - && fileName == rhs.fileName - && conditionsMatch(rhs.condition) - && ignoreCount == rhs.ignoreCount - && lineNumber == rhs.lineNumber - && address == rhs.address - && threadSpec == rhs.threadSpec - && functionName == rhs.functionName - && tracepoint == rhs.tracepoint - && module == rhs.module - && command == rhs.command; + return !differencesTo(rhs); } bool BreakpointParameters::conditionsMatch(const QByteArray &other) const diff --git a/src/plugins/debugger/breakpoint.h b/src/plugins/debugger/breakpoint.h index 6c85561cfa4..85ad101bd5b 100644 --- a/src/plugins/debugger/breakpoint.h +++ b/src/plugins/debugger/breakpoint.h @@ -88,10 +88,40 @@ enum BreakpointPathUsage BreakpointUseShortPath //!< Use filename only, in case source files are relocated. }; +enum BreakpointParts +{ + NoParts = 0, + FileAndLinePart = 0x1, + FunctionPart = 0x2, + AddressPart = 0x4, + ConditionPart = 0x8, + IgnoreCountPart = 0x10, + ThreadSpecPart = 0x20, + AllConditionParts = ConditionPart|IgnoreCountPart|ThreadSpecPart, + ModulePart = 0x40, + TracePointPart = 0x80, + + EnabledPart = 0x100, + TypePart = 0x200, + PathUsagePart = 0x400, + CommandPart = 0x400, + + AllParts = FileAndLinePart|FunctionPart|AddressPart|ConditionPart + |IgnoreCountPart|ThreadSpecPart|ModulePart|TracePointPart + |EnabledPart|TypePart|PathUsagePart|CommandPart +}; + +inline void operator|=(BreakpointParts &p, BreakpointParts r) +{ + p = BreakpointParts(int(p) | int(r)); +} + + class BreakpointParameters { public: explicit BreakpointParameters(BreakpointType = UnknownType); + BreakpointParts differencesTo(const BreakpointParameters &rhs) const; bool equals(const BreakpointParameters &rhs) const; bool conditionsMatch(const QByteArray &other) const; bool isWatchpoint() const { return type == Watchpoint; } diff --git a/src/plugins/debugger/breakwindow.cpp b/src/plugins/debugger/breakwindow.cpp index 1ce02e0893e..86740ea49df 100644 --- a/src/plugins/debugger/breakwindow.cpp +++ b/src/plugins/debugger/breakwindow.cpp @@ -71,7 +71,7 @@ class BreakpointDialog : public QDialog Q_OBJECT public: explicit BreakpointDialog(unsigned engineCapabilities, QWidget *parent = 0); - bool showDialog(BreakpointParameters *data); + bool showDialog(BreakpointParameters *data, BreakpointParts *parts); void setParameters(const BreakpointParameters &data); BreakpointParameters parameters() const; @@ -385,7 +385,8 @@ void BreakpointDialog::typeChanged(int) } } -bool BreakpointDialog::showDialog(BreakpointParameters *data) +bool BreakpointDialog::showDialog(BreakpointParameters *data, + BreakpointParts *parts) { setParameters(*data); if (exec() != QDialog::Accepted) @@ -393,7 +394,8 @@ bool BreakpointDialog::showDialog(BreakpointParameters *data) // Check if changed. const BreakpointParameters newParameters = parameters(); - if (data->equals(newParameters)) + *parts = data->differencesTo(newParameters); + if (!*parts) return false; *data = newParameters; @@ -651,17 +653,19 @@ void BreakWindow::editBreakpoint(BreakpointId id, QWidget *parent) unsigned engineCapabilities = AllDebuggerCapabilities; if (const DebuggerEngine *engine = breakHandler()->engine(id)) engineCapabilities = engine->debuggerCapabilities(); + BreakpointParts parts = NoParts; BreakpointDialog dialog(engineCapabilities, parent); - if (dialog.showDialog(&data)) - breakHandler()->setBreakpointData(id, data); + if (dialog.showDialog(&data, &parts)) + breakHandler()->changeBreakpointData(id, data, parts); } void BreakWindow::addBreakpoint() { BreakpointParameters data(BreakpointByFileAndLine); + BreakpointParts parts = NoParts; BreakpointDialog dialog(AllDebuggerCapabilities, this); dialog.setWindowTitle(tr("Add Breakpoint")); - if (dialog.showDialog(&data)) + if (dialog.showDialog(&data, &parts)) breakHandler()->appendBreakpoint(data); }