Skip to content

Commit

Permalink
fix: [debugger] Error in displaying QList member variables
Browse files Browse the repository at this point in the history
Log: as title
  • Loading branch information
LiHua000 authored and deepin-mozart committed Jan 6, 2025
1 parent cebb43f commit 542dc99
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/scripts/prettyprinters/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def __init__(self, nodetype, d):

self.externalStorage = isLarge or isStatic #see QList::Node::t()


def __iter__(self):
return self

Expand Down
16 changes: 14 additions & 2 deletions src/tools/debugadapter/debugger/gdbmi/gdbdebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ void GDBDebugger::addVariablesWatched(const QList<gdbmi::Variable *> &variableLi
}
}

void GDBDebugger::parseChildVariable(const QString &evaluateName, const gdbmi::Variable *parentVariable)
void GDBDebugger::parseChildVariable(const QString &evaluateName, gdbmi::Variable *parentVariable)
{
d->runningCommand++;
DebugManager::instance()->commandAndResponse(QString { "-var-list-children --all-values %1" }.arg(evaluateName), [=](const QVariant &r) {
Expand All @@ -781,10 +781,22 @@ void GDBDebugger::parseChildVariable(const QString &evaluateName, const gdbmi::V
parseChildVariable(childMap.value("name").toString(), parentVariable);
} else {
auto var = gdbmi::Variable::parseMap(childMap);
if (var->dynamic)
parseChildVariable(var->name, var);

var->name = childMap.value("exp").toString();
var->hasMore = (var->dynamic && var->hasMore) || var->numChild;
if(var->hasMore)
if (var->hasMore)
var->childRefrence = ++d->reference;
else if (var->value == "{...}") // var has no children and it`s value is {...}. ignore it
var->value = "";

if (!parentVariable->hasMore) {
parentVariable->childRefrence = ++d->reference;
parentVariable->hasMore = true;
if (parentVariable->value.isEmpty())
parentVariable->value = "{...}";
}
d->variableListByReference.insert(parentVariable->childRefrence, var);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/debugadapter/debugger/gdbmi/gdbdebugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public slots:
void sendLibraryUnloadedNotify(const gdbmi::Library &library, bool print);
void parseDisassembleData(const gdbmi::Record &record);
void addVariablesWatched(const QList<gdbmi::Variable *> &variableList, int reference);
void parseChildVariable(const QString &evaluateName , const gdbmi::Variable *parentVariable);
void parseChildVariable(const QString &evaluateName , gdbmi::Variable *parentVariable);
void evaluateValue(gdbmi::Variable *variable);
void resetVariables();
void checkVariablesLocker();
Expand Down
2 changes: 1 addition & 1 deletion src/tools/debugadapter/debugger/gdbmi/gdbmi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ gdbmi::Variable *gdbmi::Variable::parseMap(const QVariantMap &data)
v->value = data.value("value").toString();
v->type = data.value("type").toString();
v->threadId = data.value("thread-id").toString();
v->hasMore = data.value("has_more", true).toBool();
v->hasMore = data.value("has_more", false).toBool();
v->dynamic = data.value("dynamic", false).toBool();
v->displayhint = data.value("displayhint").toString();
return v;
Expand Down

0 comments on commit 542dc99

Please sign in to comment.