Commit cfd2dbb3 authored by hjk's avatar hjk
Browse files

debugger: split debuggeragents.{h,cpp} int {memory,disassembler}agent.{h,cpp}

parent d7ca39da
...@@ -40,9 +40,10 @@ ...@@ -40,9 +40,10 @@
#include "cdboptions.h" #include "cdboptions.h"
#include "cdbexceptionutils.h" #include "cdbexceptionutils.h"
#include "cdbsymbolpathlisteditor.h" #include "cdbsymbolpathlisteditor.h"
#include "debuggeragents.h"
#include "debuggercore.h"
#include "dbgwinutils.h" #include "dbgwinutils.h"
#include "debuggercore.h"
#include "disassemblerviewagent.h"
#include "memoryviewagent.h"
#include "debuggeractions.h" #include "debuggeractions.h"
#include "breakhandler.h" #include "breakhandler.h"
......
...@@ -40,7 +40,8 @@ ...@@ -40,7 +40,8 @@
#include "debuggeractions.h" #include "debuggeractions.h"
#include "debuggercore.h" #include "debuggercore.h"
#include "registerhandler.h" #include "registerhandler.h"
#include "debuggeragents.h" #include "disassembleragent.h"
#include "memoryagent.h"
#include "debuggertooltip.h" #include "debuggertooltip.h"
#include "cdbparsehelpers.h" #include "cdbparsehelpers.h"
#include "watchutils.h" #include "watchutils.h"
......
...@@ -23,7 +23,6 @@ HEADERS += breakhandler.h \ ...@@ -23,7 +23,6 @@ HEADERS += breakhandler.h \
consolewindow.h \ consolewindow.h \
debugger_global.h \ debugger_global.h \
debuggeractions.h \ debuggeractions.h \
debuggeragents.h \
debuggercore.h \ debuggercore.h \
debuggerconstants.h \ debuggerconstants.h \
debuggerdialogs.h \ debuggerdialogs.h \
...@@ -34,8 +33,10 @@ HEADERS += breakhandler.h \ ...@@ -34,8 +33,10 @@ HEADERS += breakhandler.h \
debuggerstreamops.h \ debuggerstreamops.h \
debuggerstringutils.h \ debuggerstringutils.h \
debuggertooltip.h \ debuggertooltip.h \
disassembleragent.h \
disassemblerlines.h \ disassemblerlines.h \
logwindow.h \ logwindow.h \
memoryagent.h \
moduleshandler.h \ moduleshandler.h \
moduleswindow.h \ moduleswindow.h \
name_demangler.h \ name_demangler.h \
...@@ -65,7 +66,6 @@ SOURCES += breakhandler.cpp \ ...@@ -65,7 +66,6 @@ SOURCES += breakhandler.cpp \
breakwindow.cpp \ breakwindow.cpp \
consolewindow.cpp \ consolewindow.cpp \
debuggeractions.cpp \ debuggeractions.cpp \
debuggeragents.cpp \
debuggerdialogs.cpp \ debuggerdialogs.cpp \
debuggerengine.cpp \ debuggerengine.cpp \
debuggermainwindow.cpp \ debuggermainwindow.cpp \
...@@ -73,8 +73,10 @@ SOURCES += breakhandler.cpp \ ...@@ -73,8 +73,10 @@ SOURCES += breakhandler.cpp \
debuggerrunner.cpp \ debuggerrunner.cpp \
debuggerstreamops.cpp \ debuggerstreamops.cpp \
debuggertooltip.cpp \ debuggertooltip.cpp \
disassembleragent.cpp \
disassemblerlines.cpp \ disassemblerlines.cpp \
logwindow.cpp \ logwindow.cpp \
memoryagent.cpp \
moduleshandler.cpp \ moduleshandler.cpp \
moduleswindow.cpp \ moduleswindow.cpp \
name_demangler.cpp \ name_demangler.cpp \
......
...@@ -30,13 +30,14 @@ ...@@ -30,13 +30,14 @@
#include "debuggerengine.h" #include "debuggerengine.h"
#include "debuggeractions.h" #include "debuggeractions.h"
#include "debuggeragents.h"
#include "debuggercore.h" #include "debuggercore.h"
#include "debuggerplugin.h" #include "debuggerplugin.h"
#include "debuggerrunner.h" #include "debuggerrunner.h"
#include "debuggerstringutils.h" #include "debuggerstringutils.h"
#include "debuggertooltip.h" #include "debuggertooltip.h"
#include "memoryagent.h"
#include "disassembleragent.h"
#include "breakhandler.h" #include "breakhandler.h"
#include "moduleshandler.h" #include "moduleshandler.h"
#include "registerhandler.h" #include "registerhandler.h"
...@@ -1418,6 +1419,17 @@ bool DebuggerEngine::isCppBreakpoint(const BreakpointParameters &p) ...@@ -1418,6 +1419,17 @@ bool DebuggerEngine::isCppBreakpoint(const BreakpointParameters &p)
&& !p.fileName.endsWith(QLatin1String(".js"), Qt::CaseInsensitive); && !p.fileName.endsWith(QLatin1String(".js"), Qt::CaseInsensitive);
} }
void DebuggerEngine::openMemoryView(quint64 address)
{
(void) new MemoryViewAgent(this, address);
}
void DebuggerEngine::openDisassemblerView(const StackFrame &frame)
{
DisassemblerViewAgent *agent = new DisassemblerViewAgent(this);
agent->setFrame(frame, true, false);
}
} // namespace Debugger } // namespace Debugger
#include "debuggerengine.moc" #include "debuggerengine.moc"
...@@ -160,8 +160,10 @@ public: ...@@ -160,8 +160,10 @@ public:
void startDebugger(DebuggerRunControl *runControl); void startDebugger(DebuggerRunControl *runControl);
virtual void watchPoint(const QPoint &); virtual void watchPoint(const QPoint &);
virtual void openMemoryView(quint64 addr);
virtual void fetchMemory(Internal::MemoryViewAgent *, QObject *, virtual void fetchMemory(Internal::MemoryViewAgent *, QObject *,
quint64 addr, quint64 length); quint64 addr, quint64 length);
virtual void openDisassemblerView(const Internal::StackFrame &frame);
virtual void fetchDisassembler(Internal::DisassemblerViewAgent *); virtual void fetchDisassembler(Internal::DisassemblerViewAgent *);
virtual void activateFrame(int index); virtual void activateFrame(int index);
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "debuggerplugin.h" #include "debuggerplugin.h"
#include "debuggeractions.h" #include "debuggeractions.h"
#include "debuggeragents.h"
#include "debuggerconstants.h" #include "debuggerconstants.h"
#include "debuggercore.h" #include "debuggercore.h"
#include "debuggerdialogs.h" #include "debuggerdialogs.h"
...@@ -44,6 +43,7 @@ ...@@ -44,6 +43,7 @@
#include "breakhandler.h" #include "breakhandler.h"
#include "breakwindow.h" #include "breakwindow.h"
#include "consolewindow.h" #include "consolewindow.h"
#include "disassembleragent.h"
#include "logwindow.h" #include "logwindow.h"
#include "moduleswindow.h" #include "moduleswindow.h"
#include "registerwindow.h" #include "registerwindow.h"
...@@ -2430,7 +2430,7 @@ void DebuggerPluginPrivate::openMemoryEditor() ...@@ -2430,7 +2430,7 @@ void DebuggerPluginPrivate::openMemoryEditor()
{ {
AddressDialog dialog; AddressDialog dialog;
if (dialog.exec() == QDialog::Accepted) if (dialog.exec() == QDialog::Accepted)
(void) new MemoryViewAgent(currentEngine(), dialog.address()); currentEngine()->openMemoryView(dialog.address());
} }
void DebuggerPluginPrivate::coreShutdown() void DebuggerPluginPrivate::coreShutdown()
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
** **
**************************************************************************/ **************************************************************************/
#include "debuggeragents.h" #include "disassembleragent.h"
#include "breakhandler.h" #include "breakhandler.h"
#include "debuggerengine.h" #include "debuggerengine.h"
...@@ -36,10 +36,9 @@ ...@@ -36,10 +36,9 @@
#include "stackframe.h" #include "stackframe.h"
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h> #include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <texteditor/basetextdocument.h> #include <texteditor/basetextdocument.h>
#include <texteditor/basetexteditor.h> #include <texteditor/basetexteditor.h>
...@@ -49,143 +48,15 @@ ...@@ -49,143 +48,15 @@
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QMetaObject>
#include <QtCore/QTimer>
#include <QtGui/QMessageBox>
#include <QtGui/QPlainTextEdit>
#include <QtGui/QTextBlock> #include <QtGui/QTextBlock>
#include <QtGui/QTextCursor>
#include <QtGui/QIcon> #include <QtGui/QIcon>
#include <limits.h>
using namespace Core; using namespace Core;
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
///////////////////////////////////////////////////////////////////////
//
// MemoryViewAgent
//
///////////////////////////////////////////////////////////////////////
/*!
\class MemoryViewAgent
Objects form this class are created in response to user actions in
the Gui for showing raw memory from the inferior. After creation
it handles communication between the engine and the bineditor.
*/
namespace { const int DataRange = 1024 * 1024; }
MemoryViewAgent::MemoryViewAgent(Debugger::DebuggerEngine *engine, quint64 addr)
: QObject(engine), m_engine(engine)
{
QTC_ASSERT(engine, /**/);
createBinEditor(addr);
}
MemoryViewAgent::MemoryViewAgent(Debugger::DebuggerEngine *engine, const QString &addr)
: QObject(engine), m_engine(engine)
{
QTC_ASSERT(engine, /**/);
bool ok = true;
createBinEditor(addr.toULongLong(&ok, 0));
//qDebug() << " ADDRESS: " << addr << addr.toUInt(&ok, 0);
}
MemoryViewAgent::~MemoryViewAgent()
{
EditorManager *editorManager = EditorManager::instance();
QList<IEditor *> editors;
foreach (QPointer<IEditor> editor, m_editors)
if (editor)
editors.append(editor.data());
editorManager->closeEditors(editors);
}
void MemoryViewAgent::createBinEditor(quint64 addr)
{
EditorManager *editorManager = EditorManager::instance();
QString titlePattern = tr("Memory $");
IEditor *editor = editorManager->openEditorWithContents(
Core::Constants::K_DEFAULT_BINARY_EDITOR_ID,
&titlePattern);
if (editor) {
connect(editor->widget(),
SIGNAL(lazyDataRequested(Core::IEditor *, quint64,bool)),
SLOT(fetchLazyData(Core::IEditor *, quint64,bool)));
connect(editor->widget(),
SIGNAL(newWindowRequested(quint64)),
SLOT(createBinEditor(quint64)));
connect(editor->widget(),
SIGNAL(newRangeRequested(Core::IEditor *, quint64)),
SLOT(provideNewRange(Core::IEditor*,quint64)));
connect(editor->widget(),
SIGNAL(startOfFileRequested(Core::IEditor *)),
SLOT(handleStartOfFileRequested(Core::IEditor*)));
connect(editor->widget(),
SIGNAL(endOfFileRequested(Core::IEditor *)),
SLOT(handleEndOfFileRequested(Core::IEditor*)));
m_editors << editor;
editorManager->activateEditor(editor);
QMetaObject::invokeMethod(editor->widget(), "setNewWindowRequestAllowed");
QMetaObject::invokeMethod(editor->widget(), "setLazyData",
Q_ARG(quint64, addr), Q_ARG(int, DataRange), Q_ARG(int, BinBlockSize));
} else {
showMessageBox(QMessageBox::Warning,
tr("No memory viewer available"),
tr("The memory contents cannot be shown as no viewer plugin "
"for binary data has been loaded."));
deleteLater();
}
}
void MemoryViewAgent::fetchLazyData(IEditor *editor, quint64 block, bool sync)
{
Q_UNUSED(sync); // FIXME: needed support for incremental searching
m_engine->fetchMemory(this, editor, BinBlockSize * block, BinBlockSize);
}
void MemoryViewAgent::addLazyData(QObject *editorToken, quint64 addr,
const QByteArray &ba)
{
IEditor *editor = qobject_cast<IEditor *>(editorToken);
if (editor && editor->widget()) {
Core::EditorManager::instance()->activateEditor(editor);
QMetaObject::invokeMethod(editor->widget(), "addLazyData",
Q_ARG(quint64, addr / BinBlockSize), Q_ARG(QByteArray, ba));
}
}
void MemoryViewAgent::provideNewRange(IEditor *editor, quint64 address)
{
QMetaObject::invokeMethod(editor->widget(), "setLazyData",
Q_ARG(quint64, address), Q_ARG(int, DataRange),
Q_ARG(int, BinBlockSize));
}
// Since we are not dealing with files, we take these signals to mean
// "move to start/end of range". This seems to make more sense than
// jumping to the start or end of the address space, respectively.
void MemoryViewAgent::handleStartOfFileRequested(IEditor *editor)
{
QMetaObject::invokeMethod(editor->widget(),
"setCursorPosition", Q_ARG(int, 0));
}
void MemoryViewAgent::handleEndOfFileRequested(IEditor *editor)
{
QMetaObject::invokeMethod(editor->widget(),
"setCursorPosition", Q_ARG(int, DataRange - 1));
}
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
// //
// DisassemblerViewAgent // DisassemblerViewAgent
......
...@@ -27,15 +27,13 @@ ...@@ -27,15 +27,13 @@
** **
**************************************************************************/ **************************************************************************/
#ifndef DEBUGGER_AGENTS_H #ifndef DEBUGGER_DISASSEMBLERAGENT_H
#define DEBUGGER_AGENTS_H #define DEBUGGER_DISASSEMBLERAGENT_H
#include "disassemblerlines.h"
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QHash>
#include <QtCore/QPointer> #include <QtCore/QPointer>
#include <QtCore/QVector>
#include "disassemblerlines.h"
namespace Core { namespace Core {
class IEditor; class IEditor;
...@@ -51,40 +49,13 @@ class StackFrame; ...@@ -51,40 +49,13 @@ class StackFrame;
class DisassemblerViewAgent; class DisassemblerViewAgent;
class DisassemblerViewAgentPrivate; class DisassemblerViewAgentPrivate;
class MemoryViewAgent : public QObject
{
Q_OBJECT
public:
// Called from Gui
explicit MemoryViewAgent(Debugger::DebuggerEngine *engine, quint64 startaddr);
explicit MemoryViewAgent(Debugger::DebuggerEngine *engine, const QString &startaddr);
~MemoryViewAgent();
enum { BinBlockSize = 1024 };
public slots:
// Called from Engine
void addLazyData(QObject *editorToken, quint64 addr, const QByteArray &data);
private:
Q_SLOT void createBinEditor(quint64 startAddr);
Q_SLOT void fetchLazyData(Core::IEditor *, quint64 block, bool sync);
Q_SLOT void provideNewRange(Core::IEditor *editor, quint64 address);
Q_SLOT void handleStartOfFileRequested(Core::IEditor *editor);
Q_SLOT void handleEndOfFileRequested(Core::IEditor *editor);
QList<QPointer<Core::IEditor> > m_editors;
QPointer<Debugger::DebuggerEngine> m_engine;
};
class DisassemblerViewAgent : public QObject class DisassemblerViewAgent : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString mimeType READ mimeType WRITE setMimeType) Q_PROPERTY(QString mimeType READ mimeType WRITE setMimeType)
public: public:
// Called from Gui // Called from Gui
explicit DisassemblerViewAgent(Debugger::DebuggerEngine *engine); explicit DisassemblerViewAgent(DebuggerEngine *engine);
~DisassemblerViewAgent(); ~DisassemblerViewAgent();
void setFrame(const StackFrame &frame, bool tryMixed, bool setMarker); void setFrame(const StackFrame &frame, bool tryMixed, bool setMarker);
...@@ -105,6 +76,7 @@ public: ...@@ -105,6 +76,7 @@ public:
// Return address of an assembly line "0x0dfd bla" // Return address of an assembly line "0x0dfd bla"
static quint64 addressFromDisassemblyLine(const QString &data); static quint64 addressFromDisassemblyLine(const QString &data);
private: private:
DisassemblerViewAgentPrivate *d; DisassemblerViewAgentPrivate *d;
}; };
...@@ -113,4 +85,4 @@ private: ...@@ -113,4 +85,4 @@ private:
} // namespace Internal } // namespace Internal
} // namespace Debugger } // namespace Debugger
#endif // DEBUGGER_WATCHWINDOW_H #endif // DEBUGGER_DISASSEMBLERAGENT_H
...@@ -31,11 +31,6 @@ ...@@ -31,11 +31,6 @@
#include "gdbengine.h" #include "gdbengine.h"
#include "gdboptionspage.h"
#include "debuggercore.h"
#include "debuggerplugin.h"
#include "debuggerrunner.h"
#include "attachgdbadapter.h" #include "attachgdbadapter.h"
#include "coregdbadapter.h" #include "coregdbadapter.h"
#include "localplaingdbadapter.h" #include "localplaingdbadapter.h"
...@@ -45,13 +40,18 @@ ...@@ -45,13 +40,18 @@
#include "trkgdbadapter.h" #include "trkgdbadapter.h"
#include "tcftrkgdbadapter.h" #include "tcftrkgdbadapter.h"
#include "watchutils.h"
#include "debuggeractions.h" #include "debuggeractions.h"
#include "debuggeragents.h"
#include "debuggerconstants.h" #include "debuggerconstants.h"
#include "debuggertooltip.h" #include "debuggercore.h"
#include "debuggerplugin.h"
#include "debuggerrunner.h"
#include "debuggerstringutils.h" #include "debuggerstringutils.h"
#include "debuggertooltip.h"
#include "disassembleragent.h"
#include "gdbmi.h" #include "gdbmi.h"
#include "gdboptionspage.h"
#include "memoryagent.h"
#include "watchutils.h"
#include "breakhandler.h" #include "breakhandler.h"
#include "moduleshandler.h" #include "moduleshandler.h"
...@@ -62,16 +62,12 @@ ...@@ -62,16 +62,12 @@
#include "threadshandler.h" #include "threadshandler.h"
#include "watchhandler.h" #include "watchhandler.h"
#include "sourcefileswindow.h"
#include "debuggerdialogs.h"
#include "logwindow.h" #include "logwindow.h"
#include <utils/qtcassert.h>
#include <utils/fancymainwindow.h>
#include <texteditor/itexteditor.h>
#include <projectexplorer/toolchain.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <projectexplorer/toolchain.h>
#include <texteditor/itexteditor.h>
#include <utils/qtcassert.h>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QtCore/QDebug> #include <QtCore/QDebug>
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
**************************************************************************/ **************************************************************************/
#include "ipcenginehost.h" #include "ipcenginehost.h"
#include "ipcengineguest.h" #include "ipcengineguest.h"
#include "breakhandler.h" #include "breakhandler.h"
#include "breakpoint.h" #include "breakpoint.h"
...@@ -38,15 +39,17 @@ ...@@ -38,15 +39,17 @@
#include "watchhandler.h" #include "watchhandler.h"
#include "watchutils.h" #include "watchutils.h"
#include "threadshandler.h" #include "threadshandler.h"
#include "debuggeragents.h" #include "disassembleragent.h"
#include "memoryagent.h"
#include "debuggerstreamops.h" #include "debuggerstreamops.h"
#include "debuggercore.h" #include "debuggercore.h"
#include <utils/qtcassert.h>
#include <QSysInfo> #include <QSysInfo>
#include <QDebug> #include <QDebug>
#include <QFileInfo> #include <QFileInfo>
#include <QTimer> #include <QTimer>
#include <utils/qtcassert.h>
#include <QLocalSocket> #include <QLocalSocket>
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include "debuggerdialogs.h" #include "debuggerdialogs.h"
#include "debuggerplugin.h" #include "debuggerplugin.h"
#include "debuggerstringutils.h" #include "debuggerstringutils.h"
#include "coreplugin/icore.h"
#include "breakhandler.h" #include "breakhandler.h"
#include "breakpoint.h" #include "breakpoint.h"
...@@ -46,9 +45,12 @@ ...@@ -46,9 +45,12 @@