Commit b30ef621 authored by hjk's avatar hjk
Browse files

debugger: register related refactoring (common code)

parent 5074001b
......@@ -1274,15 +1274,10 @@ void CdbEngine::reloadRegisters()
qDebug() << Q_FUNC_INFO << intBase;
QString errorMessage;
const Registers oldRegisters = registerHandler()->registers();
Registers registers = getRegisters(m_d->interfaces().debugControl,
const Registers registers = getRegisters(m_d->interfaces().debugControl,
m_d->interfaces().debugRegisters, &errorMessage, intBase);
if (registers.isEmpty() && !errorMessage.isEmpty())
warning(msgFunctionFailed("reloadRegisters" , errorMessage));
for (int i = qMin(registers.size(), oldRegisters.size()); --i >= 0; ) {
Register &reg = registers[i];
reg.changed = (reg.value != oldRegisters.at(i).value);
}
registerHandler()->setRegisters(registers);
}
......
......@@ -3110,13 +3110,10 @@ void GdbEngine::handleRegisterListValues(const GdbResponse &response)
handled = true;
}
}
const QString value = _(handled ? ba : val.data());
reg.changed = (value != reg.value);
if (reg.changed)
reg.value = value;
reg.value = _(handled ? ba : val.data());
}
}
registerHandler()->setRegisters(registers);
registerHandler()->setAndMarkRegisters(registers);
}
......
......@@ -482,19 +482,12 @@ void Snapshot::syncRegisters(uint threadId, RegisterHandler *handler) const
QTC_ASSERT(debuggerRegisters.size() >= RegisterPSGdb,
qDebug() << "HAVE: " << debuggerRegisters.size(); return);
bool changed = false;
for (int i = 0; i < RegisterCount; ++i) {
const int gdbIndex = i == RegisterPSTrk ? int(RegisterPSGdb) : i;
Register &reg = debuggerRegisters[gdbIndex];
const QString value = trk::hexxNumber(thread.registers[i]);
reg.changed = (value != reg.value);
if (reg.changed) {
reg.value = value;
changed = true;
reg.value = trk::hexxNumber(thread.registers[i]);
}
}
if (changed)
handler->setRegisters(debuggerRegisters);
handler->setAndMarkRegisters(debuggerRegisters);
}
void Snapshot::parseGdbStepRange(const QByteArray &cmd, bool so)
......
......@@ -187,6 +187,15 @@ void RegisterHandler::setRegisters(const Registers &registers)
reset();
}
void RegisterHandler::setAndMarkRegisters(const Registers &registers)
{
const Registers old = m_registers;
m_registers = registers;
for (int i = qMin(m_registers.size(), old.size()); --i >= 0; )
m_registers[i].changed = m_registers[i].value != old[i].value;
reset();
}
Registers RegisterHandler::registers() const
{
return m_registers;
......
......@@ -63,6 +63,7 @@ public:
bool isEmpty() const; // nothing known so far?
void setRegisters(const Registers &registers);
void setAndMarkRegisters(const Registers &registers);
Registers registers() const;
void removeAll();
Q_SLOT void setNumberBase(int base);
......
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