Commit 2cf04cb2 authored by Ryan May's avatar Ryan May Committed by hjk
Browse files

Fix register view with GDB.



Because missing registers are discarded, the register number returned by
GDB (when values are obtained) are not the same as the indices into the
internal list of registers. Explicitly store this mapping now.

Task-number: QTCREATORBUG-7468
Change-Id: Ica6fc6e6bd0a240cbd59923e4cabc7127e1aad8b
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 3518934e
......@@ -3770,9 +3770,23 @@ void GdbEngine::handleRegisterListNames(const GdbResponse &response)
}
Registers registers;
foreach (const GdbMi &item, response.data.findChild("register-names").children())
if (!item.data().isEmpty())
int gdbRegisterNumber = 0, internalIndex = 0;
// This both handles explicitly having space for all the registers and
// initializes all indices to 0, giving missing registers a sane default
// in the event of something wacky.
GdbMi names = response.data.findChild("register-names");
m_registerNumbers.resize(names.childCount());
foreach (const GdbMi &item, names.children()) {
// Since we throw away missing registers to eliminate empty rows
// we need to maintain a mapping of GDB register numbers to their
// respective indices in the register list.
if (!item.data().isEmpty()) {
m_registerNumbers[gdbRegisterNumber] = internalIndex++;
registers.append(Register(item.data()));
}
gdbRegisterNumber++;
}
registerHandler()->setRegisters(registers);
}
......@@ -3784,14 +3798,15 @@ void GdbEngine::handleRegisterListValues(const GdbResponse &response)
Registers registers = registerHandler()->registers();
const int registerCount = registers.size();
const int gdbRegisterCount = m_registerNumbers.size();
// 24^done,register-values=[{number="0",value="0xf423f"},...]
const GdbMi values = response.data.findChild("register-values");
QTC_ASSERT(registerCount == values.children().size(), return);
foreach (const GdbMi &item, values.children()) {
const int number = item.findChild("number").data().toInt();
if (number >= 0 && number < registerCount)
registers[number].value = item.findChild("value").data();
if (number >= 0 && number < gdbRegisterCount)
registers[m_registerNumbers[number]].value = item.findChild("value").data();
}
registerHandler()->setAndMarkRegisters(registers);
}
......
......@@ -495,6 +495,7 @@ private: ////////// View & Data Stuff //////////
void setRegisterValue(int nr, const QString &value);
void handleRegisterListNames(const GdbResponse &response);
void handleRegisterListValues(const GdbResponse &response);
QVector<int> m_registerNumbers; // Map GDB register numbers to indices
//
// Disassembler specific stuff
......
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