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