================
@@ -132,6 +132,84 @@ std::vector<std::string> GetStrings(const 
llvm::json::Object *obj,
   return strs;
 }
 
+/// Create a short summary for a container that contains the summary of its
+/// first children, so that the user can get a glimpse of its contents at a
+/// glance.
+static std::optional<std::string>
+GetSyntheticSummaryForContainer(lldb::SBValue &v) {
+  if (v.TypeIsPointerType() || !v.MightHaveChildren())
+    return std::nullopt;
+  /// As this operation can be potentially slow, we limit the total time spent
+  /// fetching children to a few ms.
+  const auto max_evaluation_time = std::chrono::milliseconds(10);
+  /// We don't want to generate a extremely long summary string, so we limit 
its
+  /// length.
+  const size_t max_length = 32;
+
+  auto start = std::chrono::steady_clock::now();
+  std::string summary;
+  llvm::raw_string_ostream os(summary);
+  os << "{";
+
+  llvm::StringRef separator = "";
+
+  for (size_t i = 0, e = v.GetNumChildren(); i < e; ++i) {
----------------
clayborg wrote:

The issue with this is say you have a pointer to a very very complex type that 
contains many of members variables and inherits from many classes, if you call 
"v.GetNumChildren()" is causes that type to have to be completed along with all 
contained types which can cause a lot of debug info to be parsed. 

Previous to this change, if you have 10 class pointer variables, we wouldn't 
ever need to complete the types if the user didn't expand those types. Now with 
this change, all of these types have to be fully completed, due to the 
v.GetNumChildren() call as it will cause those types to be completed. So this 
can be huge performance regression.

https://github.com/llvm/llvm-project/pull/65514
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to