diff --git a/src/plugins/bineditor/bineditor.cpp b/src/plugins/bineditor/bineditor.cpp index e8edf796bf7..1b48537ac90 100644 --- a/src/plugins/bineditor/bineditor.cpp +++ b/src/plugins/bineditor/bineditor.cpp @@ -1416,7 +1416,6 @@ void BinEditor::highlightSearchResults(const QByteArray &pattern, QTextDocument: viewport()->update(); } - void BinEditor::changeData(int position, uchar character, bool highNibble) { if (!requestDataAt(position)) @@ -1493,38 +1492,46 @@ void BinEditor::contextMenuEvent(QContextMenuEvent *event) { const int selStart = selectionStart(); const int byteCount = selectionEnd() - selStart; - if (byteCount == 0) - return; QMenu contextMenu; QAction copyAsciiAction(tr("Copy Selection as ASCII Characters"), this); QAction copyHexAction(tr("Copy Selection as Hex Values"), this); - QAction jumpToBeAddressHere(this); - QAction jumpToBeAddressNewWindow(this); - QAction jumpToLeAddressHere(this); - QAction jumpToLeAddressNewWindow(this); + QAction jumpToBeAddressHereAction(this); + QAction jumpToBeAddressNewWindowAction(this); + QAction jumpToLeAddressHereAction(this); + QAction jumpToLeAddressNewWindowAction(this); + QAction addWatchpointAction(tr("Set Data Breakpoint on Selection"), this); contextMenu.addAction(©AsciiAction); contextMenu.addAction(©HexAction); + contextMenu.addAction(&addWatchpointAction); + + copyAsciiAction.setEnabled(byteCount > 0); + copyHexAction.setEnabled(byteCount > 0);; + jumpToBeAddressHereAction.setEnabled(byteCount > 0); + jumpToBeAddressNewWindowAction.setEnabled(byteCount > 0); + jumpToLeAddressHereAction.setEnabled(byteCount > 0); + jumpToLeAddressNewWindowAction.setEnabled(byteCount > 0); + addWatchpointAction.setEnabled(byteCount > 0 && byteCount <= 32); quint64 beAddress = 0; quint64 leAddress = 0; if (byteCount <= 8) { asIntegers(selStart, byteCount, beAddress, leAddress); - setupJumpToMenuAction(&contextMenu, &jumpToBeAddressHere, - &jumpToBeAddressNewWindow, beAddress); + setupJumpToMenuAction(&contextMenu, &jumpToBeAddressHereAction, + &jumpToBeAddressNewWindowAction, beAddress); // If the menu entries would be identical, show only one of them. if (beAddress != leAddress) { - setupJumpToMenuAction(&contextMenu, &jumpToLeAddressHere, - &jumpToLeAddressNewWindow, leAddress); + setupJumpToMenuAction(&contextMenu, &jumpToLeAddressHereAction, + &jumpToLeAddressNewWindowAction, leAddress); } } else { - jumpToBeAddressHere.setText(tr("Jump to Address in This Window")); - jumpToBeAddressNewWindow.setText(tr("Jump to Address in New Window")); - jumpToBeAddressHere.setEnabled(false); - jumpToBeAddressNewWindow.setEnabled(false); - contextMenu.addAction(&jumpToBeAddressHere); - contextMenu.addAction(&jumpToBeAddressNewWindow); + jumpToBeAddressHereAction.setText(tr("Jump to Address in This Window")); + jumpToBeAddressNewWindowAction.setText(tr("Jump to Address in New Window")); + jumpToBeAddressHereAction.setEnabled(false); + jumpToBeAddressNewWindowAction.setEnabled(false); + contextMenu.addAction(&jumpToBeAddressHereAction); + contextMenu.addAction(&jumpToBeAddressNewWindowAction); } QAction *action = contextMenu.exec(event->globalPos()); @@ -1532,14 +1539,16 @@ void BinEditor::contextMenuEvent(QContextMenuEvent *event) copy(true); else if (action == ©HexAction) copy(false); - else if (action == &jumpToBeAddressHere) + else if (action == &jumpToBeAddressHereAction) jumpToAddress(beAddress); - else if (action == &jumpToLeAddressHere) + else if (action == &jumpToLeAddressHereAction) jumpToAddress(leAddress); - else if (action == &jumpToBeAddressNewWindow) + else if (action == &jumpToBeAddressNewWindowAction) emit newWindowRequested(beAddress); - else if (action == &jumpToLeAddressNewWindow) + else if (action == &jumpToLeAddressNewWindowAction) emit newWindowRequested(leAddress); + else if (action == &addWatchpointAction) + emit addWatchpointRequested(m_baseAddr + selStart, byteCount); } void BinEditor::setupJumpToMenuAction(QMenu *menu, QAction *actionHere, diff --git a/src/plugins/bineditor/bineditor.h b/src/plugins/bineditor/bineditor.h index f0ce8a9271e..0482dce47e3 100644 --- a/src/plugins/bineditor/bineditor.h +++ b/src/plugins/bineditor/bineditor.h @@ -145,6 +145,7 @@ Q_SIGNALS: void dataRequested(Core::IEditor *editor, quint64 block); void newWindowRequested(quint64 address); void newRangeRequested(Core::IEditor *, quint64 address); + void addWatchpointRequested(quint64 address, uint size); void startOfFileRequested(Core::IEditor *); void endOfFileRequested(Core::IEditor *); void dataChanged(Core::IEditor *, quint64 address, const QByteArray &data); diff --git a/src/plugins/debugger/memoryagent.cpp b/src/plugins/debugger/memoryagent.cpp index 480bfbdb7ea..279cf02c434 100644 --- a/src/plugins/debugger/memoryagent.cpp +++ b/src/plugins/debugger/memoryagent.cpp @@ -33,6 +33,7 @@ #include "memoryagent.h" #include "memoryview.h" +#include "breakhandler.h" #include "debuggerengine.h" #include "debuggerstartparameters.h" #include "debuggercore.h" @@ -152,6 +153,12 @@ void MemoryAgent::connectBinEditorWidget(QWidget *w) connect(w, SIGNAL(dataChanged(Core::IEditor*,quint64,QByteArray)), SLOT(handleDataChanged(Core::IEditor*,quint64,QByteArray))); + connect(w, + SIGNAL(dataChanged(Core::IEditor*,quint64,QByteArray)), + SLOT(handleDataChanged(Core::IEditor*,quint64,QByteArray))); + connect(w, + SIGNAL(addWatchpointRequested(quint64, uint)), + SLOT(handleWatchpointRequest(quint64, uint))); } bool MemoryAgent::doCreateBinEditor(quint64 addr, unsigned flags, @@ -270,6 +277,11 @@ void MemoryAgent::handleDataChanged(IEditor *, m_engine->changeMemory(this, sender(), addr, data); } +void MemoryAgent::handleWatchpointRequest(quint64 address, uint size) +{ + m_engine->breakHandler()->setWatchpointAtAddress(address, size); +} + void MemoryAgent::updateContents() { foreach (const QPointer &e, m_editors) diff --git a/src/plugins/debugger/memoryagent.h b/src/plugins/debugger/memoryagent.h index 236061a7ab6..60a7d59eb0c 100644 --- a/src/plugins/debugger/memoryagent.h +++ b/src/plugins/debugger/memoryagent.h @@ -106,6 +106,7 @@ private slots: void handleEndOfFileRequested(Core::IEditor *editor); void handleDataChanged(Core::IEditor *editor, quint64 address, const QByteArray &data); + void handleWatchpointRequest(quint64 address, uint size); void updateMemoryView(quint64 address, quint64 length); void engineStateChanged(Debugger::DebuggerState s);