Skip to content

Commit 2340ff2

Browse files
authored
Remove the traversal of the SBValue's children values (#118)
This change comes from the [clayborg ](https://github.com/clayborg)'s comment in #115 (comment) and should help solve the memory leak issues mentioned in #115. --------- Co-authored-by: Greg Clayton <[email protected]>
1 parent a6c8c66 commit 2340ff2

File tree

1 file changed

+5
-38
lines changed

1 file changed

+5
-38
lines changed

src/MICmdCmdVar.cpp

+5-38
Original file line numberDiff line numberDiff line change
@@ -300,18 +300,8 @@ CMICmdBase *CMICmdCmdVarCreate::CreateSelf() {
300300
void CMICmdCmdVarCreate::CompleteSBValue(lldb::SBValue &vrwValue) {
301301
// Force a value to update
302302
vrwValue.GetValueDidChange();
303-
304-
// And update its children
305-
lldb::SBType valueType = vrwValue.GetType();
306-
if (!valueType.IsPointerType() && !valueType.IsReferenceType()) {
307-
const auto temp = vrwValue.GetNumChildren();
308-
const MIuint nChildren = temp > 64 ? 64 : temp;
309-
for (MIuint i = 0; i < nChildren; ++i) {
310-
lldb::SBValue member = vrwValue.GetChildAtIndex(i);
311-
if (member.IsValid())
312-
CompleteSBValue(member);
313-
}
314-
}
303+
// Do not traverse the Children values. For reference, see
304+
// https://github.com/lldb-tools/lldb-mi/pull/115#discussion_r1706360623.
315305
}
316306

317307
//++
@@ -588,33 +578,10 @@ void CMICmdCmdVarUpdate::MIFormResponse(const CMIUtilString &vrStrVarName,
588578
//--
589579
bool CMICmdCmdVarUpdate::ExamineSBValueForChange(lldb::SBValue &vrwValue,
590580
bool &vrwbChanged) {
591-
// Note SBValue::GetValueDidChange() returns false if value changes from
592-
// invalid (for example if it represents a field of a structure, and
593-
// structure is pointed at with a NULL pointer) to a valid value, which is not
594-
// a desired result for -var-update changelist - it will miss case of
595-
// invalid-to-valid change.
596-
if (vrwValue.GetValueDidChange()) {
597-
vrwbChanged = true;
598-
return MIstatus::success;
599-
}
581+
vrwbChanged = vrwValue.GetValueDidChange();
582+
// Do not traverse the Children values. For reference, see
583+
// https://github.com/lldb-tools/lldb-mi/pull/115#discussion_r1706367538.
600584

601-
const auto temp = vrwValue.GetNumChildren();
602-
const MIuint nChildren = temp > 64 ? 64 : temp;
603-
for (MIuint i = 0; i < nChildren; ++i) {
604-
lldb::SBValue member = vrwValue.GetChildAtIndex(i);
605-
if (!member.IsValid())
606-
continue;
607-
608-
// skip pointers and references to avoid infinite loop
609-
if (member.GetType().GetTypeFlags() &
610-
(lldb::eTypeIsPointer | lldb::eTypeIsReference))
611-
continue;
612-
613-
// Handle composite types (i.e. struct or arrays)
614-
if (ExamineSBValueForChange(member, vrwbChanged) && vrwbChanged)
615-
return MIstatus::success;
616-
}
617-
vrwbChanged = false;
618585
return MIstatus::success;
619586
}
620587

0 commit comments

Comments
 (0)