Cdbext: Fix fetching partial variable

Avoid calling PyValue::childCount as it expands the values in front of the
partial variable recursively. This outdates scopeEnd as it is fetched
before the items are expanded, which again results in a too early return
from that function.

Fixes: QTCREATORBUG-24108
Change-Id: I0848cde88c6ff8019a4ab22ac1153598c20e563d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2020-07-10 11:37:12 +02:00
parent 2ad3a02150
commit cda204aa34
3 changed files with 11 additions and 9 deletions

View File

@@ -220,17 +220,13 @@ static PyObject *cdbext_listOfLocals(PyObject *, PyObject *args) // -> [ Value ]
++currentPartialIname; // skip "local" part
ULONG symbolGroupIndex = 0;
ULONG childEndIndex = 0;
for (;symbolGroupIndex < scopeEnd; ++symbolGroupIndex) {
PyValue value(symbolGroupIndex, symbolGroup);
if (childEndIndex <= symbolGroupIndex) { // do not return a child value
if (value.name() == *currentPartialIname) {
PyList_Append(locals, createPythonObject(value));
return locals;
}
++childEndIndex;
if (value.name() == *currentPartialIname) {
PyList_Append(locals, createPythonObject(value));
return locals;
}
childEndIndex += ULONG(value.childCount());
symbolGroupIndex += value.currentNumberOfDescendants();
}
}

View File

@@ -278,13 +278,18 @@ PyValue PyValue::childFromIndex(int index)
int offset = index + 1;
for (ULONG childIndex = m_index + 1; childIndex < m_index + offset; ) {
const ULONG childDescendantCount = currentNumberOfDescendants(childIndex, m_symbolGroup);
const ULONG childDescendantCount = ::currentNumberOfDescendants(childIndex, m_symbolGroup);
childIndex += childDescendantCount + 1;
offset += childDescendantCount;
}
return PyValue(m_index + offset, m_symbolGroup);
}
ULONG PyValue::currentNumberOfDescendants()
{
return ::currentNumberOfDescendants(m_index, m_symbolGroup);
}
PyValue PyValue::createValue(ULONG64 address, const PyType &type)
{
if (debuggingValueEnabled()) {

View File

@@ -55,6 +55,7 @@ public:
PyValue childFromName(const std::string &name);
PyValue childFromField(const PyField &field);
PyValue childFromIndex(int index);
ULONG currentNumberOfDescendants();
static PyValue createValue(ULONG64 address, const PyType &type);
static int tag(const std::string &typeName);