Commit 76c226df authored by Friedemann Kleint's avatar Friedemann Kleint

Debugger: Fix memory display

- Watchwindow: Do not open Address dialog if menu is canceled (act = 0
  matching the unitialized unknown memory action)
- Actually pass the address of the dialog to the agent
- Make the "Open Memory editor..." action always visible to be able to
  look at const char *x pointing at y
- Improve the address dialog with checking and dialog button box
- Explicitly pass the quint64 around
- Translate & purge
parent 2bc577df
......@@ -1337,6 +1337,23 @@ void CdbDebugEngine::fetchDisassembler(DisassemblerViewAgent *agent,
}
}
void CdbDebugEngine::fetchMemory(MemoryViewAgent *agent, quint64 addr, quint64 length)
{
if (!m_d->m_hDebuggeeProcess && !length)
return;
ULONG received;
QByteArray data(length, '\0');
const HRESULT hr = m_d->m_cif.debugDataSpaces->ReadVirtual(addr, data.data(), length, &received);
if (FAILED(hr)) {
warning(tr("Unable to retrieve %1 bytes of memory at 0x%2: %3").
arg(length).arg(addr, 0, 16).arg(msgComFailed("ReadVirtual", hr)));
return;
}
if (received < length)
data.truncate(received);
agent->addLazyData(addr, data);
}
void CdbDebugEngine::reloadModules()
{
}
......
......@@ -89,6 +89,7 @@ public:
virtual void fetchDisassembler(DisassemblerViewAgent *agent,
const StackFrame &frame);
virtual void fetchMemory(MemoryViewAgent *, quint64 addr, quint64 length);
virtual void reloadModules();
virtual void loadSymbols(const QString &moduleName);
......
......@@ -75,7 +75,7 @@ MemoryViewAgent::MemoryViewAgent(DebuggerManager *manager, const QString &addr)
: QObject(manager), m_engine(manager->currentEngine())
{
bool ok = true;
init(addr.toUInt(&ok, 0));
init(addr.toULongLong(&ok, 0));
//qDebug() << " ADDRESS: " << addr << addr.toUInt(&ok, 0);
}
......@@ -87,7 +87,7 @@ MemoryViewAgent::~MemoryViewAgent()
void MemoryViewAgent::init(quint64 addr)
{
Core::EditorManager *editorManager = Core::EditorManager::instance();
QString titlePattern = "Memory $";
QString titlePattern = tr("Memory $");
m_editor = editorManager->openEditorWithContents(
Core::Constants::K_DEFAULT_BINARY_EDITOR,
&titlePattern);
......
......@@ -53,8 +53,8 @@ class MemoryViewAgent : public QObject
public:
// Called from Gui
MemoryViewAgent(DebuggerManager *manager, quint64 startaddr);
MemoryViewAgent(DebuggerManager *manager, const QString &startaddr);
explicit MemoryViewAgent(DebuggerManager *manager, quint64 startaddr);
explicit MemoryViewAgent(DebuggerManager *manager, const QString &startaddr);
~MemoryViewAgent();
enum { BinBlockSize = 1024 };
......@@ -79,7 +79,7 @@ class DisassemblerViewAgent : public QObject
public:
// Called from Gui
DisassemblerViewAgent(DebuggerManager *manager);
explicit DisassemblerViewAgent(DebuggerManager *manager);
~DisassemblerViewAgent();
void setFrame(const StackFrame &frame);
......
......@@ -537,5 +537,62 @@ void StartRemoteDialog::updateState()
m_ui->serverStartScript->setEnabled(enabled);
}
AddressDialog::AddressDialog(QWidget *parent) :
QDialog(parent),
m_lineEdit(new QLineEdit),
m_box(new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel))
{
setWindowTitle(tr("Select start address"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
QHBoxLayout *hLayout = new QHBoxLayout;
hLayout->addWidget(new QLabel(tr("Enter an address: ")));
hLayout->addWidget(m_lineEdit);
QVBoxLayout *vLayout = new QVBoxLayout;
vLayout->addLayout(hLayout);
vLayout->addWidget(m_box);
setLayout(vLayout);
connect(m_box, SIGNAL(accepted()), this, SLOT(accept()));
connect(m_box, SIGNAL(rejected()), this, SLOT(reject()));
connect(m_lineEdit, SIGNAL(returnPressed()), this, SLOT(accept()));
connect(m_lineEdit, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
setOkButtonEnabled(false);
}
void AddressDialog::setOkButtonEnabled(bool v)
{
m_box->button(QDialogButtonBox::Ok)->setEnabled(v);
}
bool AddressDialog::isOkButtonEnabled() const
{
return m_box->button(QDialogButtonBox::Ok)->isEnabled();
}
quint64 AddressDialog::address() const
{
return m_lineEdit->text().toULongLong(0, 16);
}
void AddressDialog::accept()
{
if (isOkButtonEnabled())
QDialog::accept();
}
void AddressDialog::textChanged()
{
setOkButtonEnabled(isValid());
}
bool AddressDialog::isValid() const
{
const QString text = m_lineEdit->text();
bool ok = false;
text.toULongLong(&ok, 16);
return ok;
}
} // namespace Internal
} // namespace Debugger
......@@ -36,6 +36,8 @@ QT_BEGIN_NAMESPACE
class QModelIndex;
class QPushButton;
class QLineEdit;
class QDialogButtonBox;
namespace Ui {
class AttachCoreDialog;
......@@ -171,6 +173,26 @@ private:
Ui::StartRemoteDialog *m_ui;
};
class AddressDialog : public QDialog {
Q_OBJECT
public:
explicit AddressDialog(QWidget *parent = 0);
quint64 address() const;
virtual void accept();
private slots:
void textChanged();
private:
void setOkButtonEnabled(bool v);
bool isOkButtonEnabled() const;
bool isValid() const;
QLineEdit *m_lineEdit;
QDialogButtonBox *m_box;
};
} // namespace Debugger
} // namespace Internal
......
......@@ -32,6 +32,7 @@
#include "debuggeractions.h"
#include "debuggeragents.h"
#include "debuggerdialogs.h"
#include <utils/qtcassert.h>
......@@ -51,7 +52,6 @@
using namespace Debugger::Internal;
/////////////////////////////////////////////////////////////////////
//
// WatchDelegate
......@@ -249,14 +249,11 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
QAction *actInsertNewWatchItem = menu.addAction(tr("Insert new watch item"));
QAction *actSelectWidgetToWatch = menu.addAction(tr("Select widget to watch"));
QString address = model()->data(mi0, AddressRole).toString();
const QString address = model()->data(mi0, AddressRole).toString();
QAction *actWatchKnownMemory = 0;
QAction *actWatchUnknownMemory = 0;
if (address.isEmpty())
actWatchUnknownMemory = new QAction(tr("Open memory editor"), &menu);
else
actWatchKnownMemory =
new QAction(tr("Open memory editor at %1").arg(address), &menu);
QAction *actWatchUnknownMemory = new QAction(tr("Open memory editor..."), &menu);;
if (!address.isEmpty())
actWatchKnownMemory = new QAction(tr("Open memory editor at %1").arg(address), &menu);
menu.addSeparator();
int atype = (m_type == LocalsType) ? WatchExpression : RemoveWatchExpression;
......@@ -266,8 +263,9 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
menu.addAction(actSelectWidgetToWatch);
menu.addMenu(&typeFormatMenu);
menu.addMenu(&individualFormatMenu);
menu.addAction(actWatchKnownMemory ? actWatchKnownMemory : actWatchUnknownMemory);
if (actWatchKnownMemory)
menu.addAction(actWatchKnownMemory);
menu.addAction(actWatchUnknownMemory);
menu.addSeparator();
menu.addAction(theDebuggerAction(RecheckDebuggingHelpers));
menu.addAction(theDebuggerAction(UseDebuggingHelpers));
......@@ -292,20 +290,13 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
} else if (act == actInsertNewWatchItem) {
theDebuggerAction(WatchExpression)
->trigger(WatchHandler::watcherEditPlaceHolder());
} else if (act == actWatchKnownMemory) {
} else if (actWatchKnownMemory != 0 && act == actWatchKnownMemory) {
(void) new MemoryViewAgent(m_manager, address);
} else if (act == actWatchUnknownMemory) {
QLabel *label = new QLabel(tr("Enter an address: "));
QLineEdit *lineEdit = new QLineEdit;
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(label);
layout->addWidget(lineEdit);
QDialog dialog(this);
dialog.setWindowTitle(tr("Select start address"));
dialog.setLayout(layout);
connect(lineEdit, SIGNAL(returnPressed()), &dialog, SLOT(accept()));
if (dialog.exec() == QDialog::Accepted)
(void) new MemoryViewAgent(m_manager, address);
} else if (actWatchUnknownMemory != 0 && act == actWatchUnknownMemory) {
AddressDialog dialog;
if (dialog.exec() == QDialog::Accepted) {
(void) new MemoryViewAgent(m_manager, dialog.address());
}
} 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