Commit e2e495a1 authored by Robert Loehning's avatar Robert Loehning
Browse files

Debugger: Enabled removing watchpoints using context menu

parent e40c28cc
......@@ -407,20 +407,20 @@ BreakpointData *BreakHandler::findBreakpointByNumber(int bpNumber) const
return 0;
}
BreakpointData *BreakHandler::findWatchPointByAddress(const QByteArray &a) const
int BreakHandler::findWatchPointIndexByAddress(const QByteArray &a) const
{
for (int index = size() - 1; index >= 0; --index) {
BreakpointData *bd = at(index);
if (bd->type == BreakpointData::WatchpointType && bd->address == a)
return bd;
return index;
}
return 0;
return -1;
}
bool BreakHandler::watchPointAt(quint64 address) const
{
const QByteArray addressBA = QByteArray("0x") + QByteArray::number(address, 16);
return findWatchPointByAddress(addressBA);
return findWatchPointIndexByAddress(addressBA) != -1;
}
void BreakHandler::saveBreakpoints()
......
......@@ -70,7 +70,7 @@ public:
// Find a breakpoint matching approximately the data in needle.bp*,
BreakpointData *findSimilarBreakpoint(const BreakpointData &needle) const;
BreakpointData *findBreakpointByNumber(int bpNumber) const;
BreakpointData *findWatchPointByAddress(const QByteArray &a) const;
int findWatchPointIndexByAddress(const QByteArray &a) const;
bool watchPointAt(quint64 address) const;
void updateMarkers();
......
......@@ -204,15 +204,18 @@ void WatchWindow::dropEvent(QDropEvent *ev)
//QTreeView::dropEvent(ev);
}
static inline void addWatchPoint(DebuggerManager *manager, quint64 address)
static inline void toggleWatchPoint(DebuggerManager *manager, quint64 address)
{
const QByteArray addressBA = QByteArray("0x") + QByteArray::number(address, 16);
if (manager->breakHandler()->findWatchPointByAddress(addressBA))
return;
BreakpointData *data = new BreakpointData;
data->type = BreakpointData::WatchpointType;
data->address = addressBA;
manager->breakHandler()->appendBreakpoint(data);
const int index = manager->breakHandler()->findWatchPointIndexByAddress(addressBA);
if (index == -1) {
BreakpointData *data = new BreakpointData;
data->type = BreakpointData::WatchpointType;
data->address = addressBA;
manager->breakHandler()->appendBreakpoint(data);
} else {
manager->breakHandler()->removeBreakpoint(index);
}
manager->attemptBreakpointSynchronization();
}
......@@ -415,9 +418,9 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
(void) new MemoryViewAgent(m_manager, dialog.address());
}
} else if (act == actSetWatchPointAtVariableAddress) {
addWatchPoint(m_manager, address);
toggleWatchPoint(m_manager, address);
} else if (act == actSetWatchPointAtPointerValue) {
addWatchPoint(m_manager, pointerValue);
toggleWatchPoint(m_manager, pointerValue);
} else if (act == actSelectWidgetToWatch) {
grabMouse(Qt::CrossCursor);
m_grabbing = true;
......
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