Debugger[CDB]: Add memory editing.

Add infrastructure for custom special stops with data.
This commit is contained in:
Friedemann Kleint
2011-02-28 14:33:35 +01:00
parent 6061f4bb48
commit e8d12ae464
4 changed files with 65 additions and 2 deletions

View File

@@ -173,10 +173,20 @@ struct MemoryViewCookie
quint64 length;
};
struct MemoryChangeCookie
{
explicit MemoryChangeCookie(quint64 addr = 0, const QByteArray &d = QByteArray()) :
address(addr), data(d) {}
quint64 address;
QByteArray data;
};
} // namespace Internal
} // namespace Debugger
Q_DECLARE_METATYPE(Debugger::Internal::MemoryViewCookie)
Q_DECLARE_METATYPE(Debugger::Internal::MemoryChangeCookie)
namespace Debugger {
namespace Internal {
@@ -451,6 +461,7 @@ void CdbEngine::init()
m_extensionCommandQueue.clear();
m_extensionMessageBuffer.clear();
m_pendingBreakpointMap.clear();
m_customSpecialStopData.clear();
QTC_ASSERT(m_process.state() != QProcess::Running, Utils::SynchronousProcess::stopProcess(m_process); )
}
@@ -1087,6 +1098,13 @@ void CdbEngine::interruptInferior()
}
}
void CdbEngine::doInterruptInferiorCustomSpecialStop(const QVariant &v)
{
if (m_specialStopMode == NoSpecialStop)
doInterruptInferior(CustomSpecialStop);
m_customSpecialStopData.push_back(v);
}
void CdbEngine::doInterruptInferior(SpecialStopMode sm)
{
#ifdef Q_OS_WIN
@@ -1446,6 +1464,17 @@ void CdbEngine::fetchMemory(MemoryAgent *agent, QObject *editor, quint64 addr, q
postExtensionCommand("memory", args, 0, &CdbEngine::handleMemory, 0, cookie);
}
void CdbEngine::changeMemory(Internal::MemoryAgent *, QObject *, quint64 addr, const QByteArray &data)
{
QTC_ASSERT(!data.isEmpty(), return; )
if (!m_accessible) {
const MemoryChangeCookie cookie(addr, data);
doInterruptInferiorCustomSpecialStop(qVariantFromValue(cookie));
} else {
postCommand(cdbWriteMemoryCommand(addr, data), 0);
}
}
void CdbEngine::handleMemory(const CdbExtensionCommandPtr &command)
{
QTC_ASSERT(qVariantCanConvert<MemoryViewCookie>(command->cookie), return;)
@@ -1782,6 +1811,12 @@ void CdbEngine::handleSessionIdle(const QByteArray &messageBA)
case SpecialStopGetWidgetAt:
postWidgetAtCommand();
return;
case CustomSpecialStop:
foreach (const QVariant &data, m_customSpecialStopData)
handleCustomSpecialStop(data);
m_customSpecialStopData.clear();
doContinueInferior();
return;
case NoSpecialStop:
break;
}
@@ -2560,5 +2595,14 @@ void CdbEngine::postWidgetAtCommand()
postExtensionCommand("widgetat", arguments, 0, &CdbEngine::handleWidgetAt, 0);
}
void CdbEngine::handleCustomSpecialStop(const QVariant &v)
{
if (qVariantCanConvert<MemoryChangeCookie>(v)) {
const MemoryChangeCookie changeData = qVariantValue<MemoryChangeCookie>(v);
postCommand(cdbWriteMemoryCommand(changeData.address, changeData.data), 0);
return;
}
}
} // namespace Internal
} // namespace Debugger