================
@@ -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:

> What do other debuggers do? (like Visual Studio itself)
> 
> & not sure that `GetNumChildren` should cause indefinite recursive expansion 
> - could limit this feature to just going one level deep, for instance. But 
> certainly worth comparing to other debuggers to see what sort of 
> heuristics/rules/guidelines are good in terms of the amount of data expanded 
> by default V unexpanded.
>
> (& yeah, if everything's expanded all the way down, that's probably not good)

It will cause the type to be completed, so if the type has instances of objects 
or it inherits from one or more classes, those need to be completed. We use 
clang AST types to answer these questions by counting fields and base classes 
that have ivars to show etc, so yes the type needs to be completed. We only 
need to know the layout of a type, so if we have ivars that are pointers or 
references, then we don't need the complete type. So it can and must complete 
the type.






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