[Lldb-commits] [PATCH] D37154: lldb-mi: -var-update can hang when traversing complex types with pointers

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 30 14:55:32 PDT 2017


clayborg requested changes to this revision.
clayborg added inline comments.
This revision now requires changes to proceed.


================
Comment at: tools/lldb-mi/MICmdCmdVar.cpp:518-522
+    // skip pointers and references to avoid infinite loop
+    if (member.GetType().GetTypeFlags() &
+        (lldb::eTypeIsPointer | lldb::eTypeIsReference))
+      continue;
+
----------------
This code needs to go before the children loop, but after the "if (vrwValue.GetValueDidChange()) {...}". We want to know if a pointer or reference has changed, just not their children.

```
bool CMICmdCmdVarUpdate::ExamineSBValueForChange(lldb::SBValue &vrwValue,
                                                 bool &vrwbChanged) {
  if (vrwValue.GetValueDidChange()) {
    vrwbChanged = true;
    return MIstatus::success;
  }
  vrwbChanged = false;

  // Skip children of pointers and references to avoid infinite loop
  if (vrwValue.GetType().GetTypeFlags() & 
      (lldb::eTypeIsPointer | lldb::eTypeIsReference)) {
    return MIstatus::success;
  }

  const MIuint nChildren = vrwValue.GetNumChildren();
  for (MIuint i = 0; i < nChildren; ++i) {
    auto member = vrwValue.GetChildAtIndex(i);
    if (ExamineSBValueForChange(member, vrwbChanged) && vrwbChanged)
      break;
  }
  return MIstatus::success;
}
    


https://reviews.llvm.org/D37154





More information about the lldb-commits mailing list