Commit 0af2934e authored by hjk's avatar hjk
Browse files

debugger: add watchpoint option to memoryview context menu



Change-Id: I9511e15afcfe4664ae5077dd568e5a3637888e30
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 48fcfe0b
......@@ -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(&copyAsciiAction);
contextMenu.addAction(&copyHexAction);
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 == &copyHexAction)
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,
......
......@@ -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);
......
......@@ -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<Core::IEditor> &e, m_editors)
......
......@@ -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);
......
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