From 76c226dfdbf1449844c457ce8b49035555f7871e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@nokia.com> Date: Wed, 19 Aug 2009 14:41:51 +0200 Subject: [PATCH] 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 --- share/qtcreator/translations/qtcreator_de.ts | 309 +++---------------- src/plugins/debugger/cdb/cdbdebugengine.cpp | 17 + src/plugins/debugger/cdb/cdbdebugengine.h | 1 + src/plugins/debugger/debuggeragents.cpp | 4 +- src/plugins/debugger/debuggeragents.h | 6 +- src/plugins/debugger/debuggerdialogs.cpp | 57 ++++ src/plugins/debugger/debuggerdialogs.h | 22 ++ src/plugins/debugger/watchwindow.cpp | 37 +-- 8 files changed, 151 insertions(+), 302 deletions(-) diff --git a/share/qtcreator/translations/qtcreator_de.ts b/share/qtcreator/translations/qtcreator_de.ts index 684a98a8d6c..f7e854c8c7d 100644 --- a/share/qtcreator/translations/qtcreator_de.ts +++ b/share/qtcreator/translations/qtcreator_de.ts @@ -490,10 +490,6 @@ <source>Qt Creator has detected an <b>in-source-build in %1</b> which prevents shadow builds. Qt Creator will not allow you to change the build directory. If you want a shadow build, clean your source directory and re-open the project.</source> <translation>Es wurde ein <b>Build im Quellverzeichnis</b> festgestellt, der Shadow-Builds verhindert. Das Build-Verzeichnis kann nicht in Qt Creator geändert werden. Wenn Sie einen Shadow-Build wünschen, bereinigen Sie bitte das Quellverzeichnis und öffnen Sie das Projekt noch einmal.</translation> </message> - <message> - <source>Qt Creator has detected an in-source-build which prevents shadow builds. Qt Creator will not allow you to change the build directory. If you want a shadow build, clean your source directory and re-open the project.</source> - <translation type="obsolete">Es wurde ein Build im Quellverzeichnis festgestellt, der Shadow-Builds verhindert. Das Build-Verzeichnis kann nicht in Qt Creator geändert werden. Wenn Sie einen Shadow-Build wünschen, bereinigen Sie bitte das Quellverzeichnis und öffnen Sie das Projekt noch einmal.</translation> - </message> </context> <context> <name>CMakeProjectManager::Internal::MakeStepConfigWidget</name> @@ -544,17 +540,6 @@ <translation><keine Symbole></translation> </message> </context> -<context> - <name>CVS::Internal::CVSOutputWindow</name> - <message> - <source>CVS Output</source> - <translation type="obsolete">CVS-Ausgabe</translation> - </message> - <message> - <source>CVS</source> - <translation type="obsolete">CVS</translation> - </message> -</context> <context> <name>CVS::Internal::CVSPlugin</name> <message> @@ -769,23 +754,6 @@ <source>Executing in %1: %2 %2 </source> <translation>Kommando [%1]: %2 %3 -</translation> - </message> - <message> - <source>Executing: %2 %3 -</source> - <translation type="obsolete">Kommando: %2 %3 -</translation> - </message> - <message> - <source>%1 Executing: %2 %3 -</source> - <translation type="obsolete">%1 Kommando: %2 %3</translation> - </message> - <message> - <source>%1 Executing in %2: %3 %4 -</source> - <translation type="obsolete">%1 Kommando [%2]: %3 %4 </translation> </message> <message> @@ -2670,10 +2638,6 @@ Sollen sie überschrieben werden?</translation> <source>Sort alphabetically</source> <translation>Alphabetisch sortieren</translation> </message> - <message> - <source>Rename '%1'</source> - <translation type="obsolete">'%1' Umbenennen</translation> - </message> </context> <context> <name>CppEditor::Internal::ClassNamePage</name> @@ -2982,10 +2946,23 @@ Sollen sie überschrieben werden?</translation> <translation><Encoding-Fehler></translation> </message> </context> +<context> + <name>Debugger::Internal::AddressDialog</name> + <message> + <location filename="../../../src/plugins/debugger/debuggerdialogs.cpp" line="+545"/> + <source>Select start address</source> + <translation>Startadresse</translation> + </message> + <message> + <location line="+3"/> + <source>Enter an address: </source> + <translation>Adresse:</translation> + </message> +</context> <context> <name>Debugger::Internal::AttachCoreDialog</name> <message> - <location filename="../../../src/plugins/debugger/debuggerdialogs.cpp" line="+134"/> + <location line="-414"/> <source>Select Executable</source> <translation>Ausführbare Datei auswählen</translation> </message> @@ -3276,7 +3253,12 @@ Sollen sie überschrieben werden?</translation> <translation>Der Wert '%1' konnte nicht an '%2' zugewiesen werden: %3</translation> </message> <message> - <location line="+249"/> + <location line="+234"/> + <source>Unable to retrieve %1 bytes of memory at 0x%2: %3</source> + <translation>Die Abfrage des Speichers (%1 bytes ab 0x%2) schlug fehl: %3</translation> + </message> + <message> + <location line="+32"/> <source>Cannot retrieve symbols while the debuggee is running.</source> <translation>Die Symbole können nicht bestimmt werden, solange die zu debuggende Anwendung läuft.</translation> </message> @@ -3429,14 +3411,6 @@ Sollen sie überschrieben werden?</translation> <source>Step Into</source> <translation>Einzelschritt herein</translation> </message> - <message> - <source>Step Over Instruction</source> - <translation type="obsolete">Einzelschritt über Anweisung</translation> - </message> - <message> - <source>Step One Instruction</source> - <translation type="obsolete">Einzelschritt eine Anweisung</translation> - </message> <message> <location line="+5"/> <source>Step Out</source> @@ -3786,30 +3760,6 @@ Sollen sie überschrieben werden?</translation> <source>Synchronize breakpoints</source> <translation>Haltepunkte synchronisieren</translation> </message> - <message> - <source>Hexadecimal</source> - <translation type="obsolete">Hexadezimal</translation> - </message> - <message> - <source>Decimal</source> - <translation type="obsolete">Dezimal</translation> - </message> - <message> - <source>Octal</source> - <translation type="obsolete">Oktal</translation> - </message> - <message> - <source>Binary</source> - <translation type="obsolete">Binär</translation> - </message> - <message> - <source>Raw</source> - <translation type="obsolete">Rohformat</translation> - </message> - <message> - <source>Natural</source> - <translation type="obsolete">Natürliches Format</translation> - </message> <message> <location line="+23"/> <source>Automatically quit debugger</source> @@ -3864,44 +3814,6 @@ Sollen sie überschrieben werden?</translation> <translation></translation> </message> </context> -<context> - <name>Debugger::Internal::DisassemblerHandler</name> - <message> - <source>Address</source> - <translation type="obsolete">Adresse</translation> - </message> - <message> - <source>Symbol</source> - <translation type="obsolete">Symbol</translation> - </message> - <message> - <source>Mnemonic</source> - <translation type="obsolete">Kürzel</translation> - </message> -</context> -<context> - <name>Debugger::Internal::DisassemblerWindow</name> - <message> - <source>Disassembler</source> - <translation type="obsolete">Disassembler</translation> - </message> - <message> - <source>Adjust column widths to contents</source> - <translation type="obsolete">Spaltenbreite an Inhalt anpassen</translation> - </message> - <message> - <source>Always adjust column widths to contents</source> - <translation type="obsolete">Spaltenbreite immer an Inhalt anpassen</translation> - </message> - <message> - <source>Reload disassembler listing</source> - <translation type="obsolete">Dissambler neu laden</translation> - </message> - <message> - <source>Always reload disassembler listing</source> - <translation type="obsolete">Dissambler immer neu laden</translation> - </message> -</context> <context> <name>Debugger::Internal::GdbEngine</name> <message> @@ -4189,10 +4101,6 @@ Es wird empfohlen, gdb 6.7 oder später zu benutzen.</translation> <source>Debugger exited.</source> <translation>Debugger beendet.</translation> </message> - <message> - <source><could not retreive module information></source> - <translation type="obsolete"><Modulinformation nicht verfügbar></translation> - </message> <message> <location line="+570"/> <source>Unable to run '%1': %2</source> @@ -4328,6 +4236,14 @@ Es wird empfohlen, gdb 6.7 oder später zu benutzen.</translation> <translation>Pfad zu Startup-Skript</translation> </message> </context> +<context> + <name>Debugger::Internal::MemoryViewAgent</name> + <message> + <location filename="../../../src/plugins/debugger/debuggeragents.cpp" line="+90"/> + <source>Memory $</source> + <translation>Speicher $</translation> + </message> +</context> <context> <name>Debugger::Internal::ModulesModel</name> <message> @@ -4464,10 +4380,6 @@ Es wird empfohlen, gdb 6.7 oder später zu benutzen.</translation> <source>Value (base %1)</source> <translation>Wert (Basis %1)</translation> </message> - <message> - <source>Value</source> - <translation type="obsolete">Wert</translation> - </message> </context> <context> <name>Debugger::Internal::RegisterWindow</name> @@ -4910,7 +4822,12 @@ Es wird empfohlen, gdb 6.7 oder später zu benutzen.</translation> <translation>Format für den Ausdruck ändern</translation> </message> <message> - <location line="+37"/> + <location line="+14"/> + <source>Open memory editor...</source> + <translation>Speicher-Editor öffnen...</translation> + </message> + <message> + <location line="+21"/> <source>Adjust column widths to contents</source> <translation>Spaltenbreite an Inhalt anpassen</translation> </message> @@ -4920,17 +4837,7 @@ Es wird empfohlen, gdb 6.7 oder später zu benutzen.</translation> <translation>Spaltenbreite immer an Inhalt anpassen</translation> </message> <message> - <location line="+19"/> - <source>Enter an address: </source> - <translation>Adresse:</translation> - </message> - <message> - <location line="+6"/> - <source>Select start address</source> - <translation>Startadresse</translation> - </message> - <message> - <location line="-55"/> + <location line="-28"/> <source>Insert new watch item</source> <translation>Neuen Überwachten Ausdruck einfügen</translation> </message> @@ -4941,11 +4848,6 @@ Es wird empfohlen, gdb 6.7 oder später zu benutzen.</translation> </message> <message> <location line="+6"/> - <source>Open memory editor</source> - <translation>Speicher-Editor öffnen</translation> - </message> - <message> - <location line="+3"/> <source>Open memory editor at %1</source> <translation>Speicher-Editor bei %1 öffnen</translation> </message> @@ -5085,17 +4987,6 @@ Es wird empfohlen, gdb 6.7 oder später zu benutzen.</translation> <translation>Qt-Modulnamen in #include-Direktive verwenden</translation> </message> </context> -<context> - <name>Designer::Internal::EditorWidget</name> - <message> - <source>Action editor</source> - <translation type="obsolete">Aktionseditor</translation> - </message> - <message> - <source>Signals and slots editor</source> - <translation type="obsolete">Signale und Slots</translation> - </message> -</context> <context> <name>Designer::Internal::FormClassWizardDialog</name> <message> @@ -5157,26 +5048,6 @@ Es wird empfohlen, gdb 6.7 oder später zu benutzen.</translation> </context> <context> <name>Designer::Internal::FormEditorW</name> - <message> - <source>Designer widgetbox</source> - <translation type="obsolete">Widgetbox</translation> - </message> - <message> - <source>Object inspector</source> - <translation type="obsolete">Objektanzeige</translation> - </message> - <message> - <source>Property editor</source> - <translation type="obsolete">Eigenschaften</translation> - </message> - <message> - <source>Signals and slots editor</source> - <translation type="obsolete">Signale und Slots</translation> - </message> - <message> - <source>Action editor</source> - <translation type="obsolete">Aktionseditor</translation> - </message> <message> <location filename="../../../src/plugins/designer/formeditorw.cpp" line="+334"/> <location line="+170"/> @@ -6359,10 +6230,6 @@ Grund: %3</translation> <source>Tool Chain:</source> <translation>Toolchain:</translation> </message> - <message> - <source>Toolchain:</source> - <translation type="obsolete">Werkzeugkette:</translation> - </message> <message> <location line="+8"/> <source>Generic Manager</source> @@ -6577,12 +6444,6 @@ Grund: %3</translation> <source>Unable to parse the file output.</source> <translation>Die Ausgabe der Datei konnte nicht ausgewertet werden.</translation> </message> - <message> - <source>%1 Executing: %2 %3 -</source> - <extracomment><timestamp> Executing: <executable> <arguments></extracomment> - <translation type="obsolete">%1 Kommando: %2 %3</translation> - </message> <message> <location line="+7"/> <source>Executing: %1 %2 @@ -6721,17 +6582,6 @@ Grund: %3</translation> <translation>Es gibt keine geänderten Dateien.</translation> </message> </context> -<context> - <name>Git::Internal::GitOutputWindow</name> - <message> - <source>Git Output</source> - <translation type="obsolete">Git-Ausgabe</translation> - </message> - <message> - <source>Git</source> - <translation type="obsolete">Git</translation> - </message> -</context> <context> <name>Git::Internal::GitPlugin</name> <message> @@ -6974,10 +6824,6 @@ Grund: %3</translation> <source>Another submit is currently being executed.</source> <translation>Another submit is currently being executed.</translation> </message> - <message> - <source>Another submit is currently beeing executed.</source> - <translation type="obsolete">Es läuft bereits ein Commit.</translation> - </message> <message> <location line="+30"/> <source>Cannot create temporary file: %1</source> @@ -8241,17 +8087,6 @@ p, li { white-space: pre-wrap; } <translation>Change %1: %2</translation> </message> </context> -<context> - <name>Perforce::Internal::PerforceOutputWindow</name> - <message> - <source>Perforce Output</source> - <translation type="obsolete">Perforce-Ausgabe</translation> - </message> - <message> - <source>Perforce</source> - <translation type="obsolete">Perforce</translation> - </message> -</context> <context> <name>Perforce::Internal::PerforcePlugin</name> <message> @@ -8517,12 +8352,6 @@ p, li { white-space: pre-wrap; } <source>Executing: %1 </source> <translation>Kommando: %1 -</translation> - </message> - <message> - <source>%1 Executing: %2 -</source> - <translation type="obsolete">%1 Kommando: %2 </translation> </message> <message> @@ -9059,14 +8888,6 @@ Fehler: %2</translation> </context> <context> <name>ProjectExplorer::EnvironmentWidget</name> - <message> - <source>Show Details</source> - <translation type="obsolete">Details anzeigen</translation> - </message> - <message> - <source>Hide Details</source> - <translation type="obsolete">Details ausblenden</translation> - </message> <message> <location line="+142"/> <source>Details</source> @@ -9417,10 +9238,6 @@ Fehler: %2</translation> <source>%1 depends on: %2.</source> <translation>%1 hängt von %2 ab.</translation> </message> - <message> - <source>, </source> - <translation type="obsolete">, </translation> - </message> </context> <context> <name>ProjectExplorer::Internal::DetailedModel</name> @@ -9553,10 +9370,6 @@ Fehler: %2</translation> </context> <context> <name>ProjectExplorer::Internal::ProcessStepWidget</name> - <message> - <source>Enable custom process step</source> - <translation type="obsolete">Benutzerdefinierten Verarbeitungsschritt aktivieren</translation> - </message> <message> <location filename="../../../src/plugins/projectexplorer/processstep.ui"/> <source>Name:</source> @@ -9764,25 +9577,6 @@ Fehler: %2</translation> <translation>Zu erzeugende Dateien:</translation> </message> </context> -<context> - <name>ProjectExplorer::Internal::ProjetExplorerSettingsPageUi</name> - <message> - <source>Save all files before Build</source> - <translation type="obsolete">Alle Dateien vor Erstellen speichern</translation> - </message> - <message> - <source>Always build Project before Running</source> - <translation type="obsolete">Projekt vor Ausführung stets erstellen</translation> - </message> - <message> - <source>Build and Run</source> - <translation type="obsolete">Erstellung und Ausführung</translation> - </message> - <message> - <source>Show Compiler Output on building</source> - <translation type="obsolete">Compiler-Ausgabe beim Erstellen anzeigen</translation> - </message> -</context> <context> <name>ProjectExplorer::Internal::RemoveFileDialog</name> <message> @@ -10551,10 +10345,6 @@ unter Versionsverwaltung (%2) gestellt werden?</translation> </context> <context> <name>QrcEditor</name> - <message> - <source>Form</source> - <translation type="obsolete">Formular</translation> - </message> <message> <location filename="../../../src/shared/qrceditor/qrceditor.ui"/> <source>Add</source> @@ -11439,10 +11229,6 @@ unter Versionsverwaltung (%2) gestellt werden?</translation> <source>using Qt version: <b>%1</b><br>with tool chain <b>%2</b><br>building in <b>%3</b></source> <translation>verwende Qt-Version: <b>%1</b><br>mit Toolchain <b>%2</b><br>Erstellung in <b>%3</b></translation> </message> - <message> - <source>using Qt Version: <b>%1</b><br>with tool chain <b>%2</b><br>building in <b>%3</b></source> - <translation type="obsolete">benutze</translation> - </message> <message> <location line="+17"/> <source>General</source> @@ -11805,19 +11591,11 @@ p, li { white-space: pre-wrap; } <source>Device on Serial Port:</source> <translation>Gerät auf serieller Schnittstelle:</translation> </message> - <message> - <source>Self-sign</source> - <translation type="obsolete">Selbstsigniertes Zertifikat</translation> - </message> <message> <location line="+19"/> <source>Choose certificate file (.cer)</source> <translation>Geben Sie eine Datei mit einem Zertifikat (.cer) an</translation> </message> - <message> - <source>Custom signature:</source> - <translation type="obsolete">Signatur:</translation> - </message> <message> <location line="+4"/> <source>Choose key file (.key / .pem)</source> @@ -13231,17 +13009,6 @@ Um es abzurufen, tippen Sie das Kürzel im Locator, gefolgt von einem Leerzeich <translation>Subversion-Kommando</translation> </message> </context> -<context> - <name>Subversion::Internal::SubversionOutputWindow</name> - <message> - <source>Subversion Output</source> - <translation type="obsolete">Subversion-Ausgabe</translation> - </message> - <message> - <source>Subversion</source> - <translation type="obsolete">Subversion</translation> - </message> -</context> <context> <name>Subversion::Internal::SubversionPlugin</name> <message> @@ -13443,12 +13210,6 @@ Um es abzurufen, tippen Sie das Kürzel im Locator, gefolgt von einem Leerzeich <translation>Es wurde keine ausführbaren Subversion-Datei angegeben! </translation> </message> - <message> - <source>%1 Executing: %2 %3 -</source> - <extracomment><timestamp> Executing: <executable> <arguments></extracomment> - <translation type="obsolete">%1 Kommando: %2 %3</translation> - </message> <message> <location line="+37"/> <source>The process terminated with exit code %1.</source> diff --git a/src/plugins/debugger/cdb/cdbdebugengine.cpp b/src/plugins/debugger/cdb/cdbdebugengine.cpp index fb2f0d7676e..d6660fa0938 100644 --- a/src/plugins/debugger/cdb/cdbdebugengine.cpp +++ b/src/plugins/debugger/cdb/cdbdebugengine.cpp @@ -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() { } diff --git a/src/plugins/debugger/cdb/cdbdebugengine.h b/src/plugins/debugger/cdb/cdbdebugengine.h index 995347e7a95..521b7b17201 100644 --- a/src/plugins/debugger/cdb/cdbdebugengine.h +++ b/src/plugins/debugger/cdb/cdbdebugengine.h @@ -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); diff --git a/src/plugins/debugger/debuggeragents.cpp b/src/plugins/debugger/debuggeragents.cpp index 8234ee65415..ad1b6d67710 100644 --- a/src/plugins/debugger/debuggeragents.cpp +++ b/src/plugins/debugger/debuggeragents.cpp @@ -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); diff --git a/src/plugins/debugger/debuggeragents.h b/src/plugins/debugger/debuggeragents.h index c6d4b768c74..2ee788ccedc 100644 --- a/src/plugins/debugger/debuggeragents.h +++ b/src/plugins/debugger/debuggeragents.h @@ -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); diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp index 1990b161f7f..36128020850 100644 --- a/src/plugins/debugger/debuggerdialogs.cpp +++ b/src/plugins/debugger/debuggerdialogs.cpp @@ -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 diff --git a/src/plugins/debugger/debuggerdialogs.h b/src/plugins/debugger/debuggerdialogs.h index b277b6aabfd..2b63fa3e9e8 100644 --- a/src/plugins/debugger/debuggerdialogs.h +++ b/src/plugins/debugger/debuggerdialogs.h @@ -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 diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index 18f02472d0f..b8a687c82db 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -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; -- GitLab