[Lldb-commits] [PATCH] D125347: Add "indexedVariables" to variables with lots of children.

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed May 11 15:29:10 PDT 2022


clayborg added inline comments.


================
Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:1055
+      const char *first_child_name = v.GetChildAtIndex(0).GetName();
+      if (first_child_name && strcmp(first_child_name, "[0]") == 0)
+        object.try_emplace("indexedVariables", num_children);
----------------
All of the collection classes emit very similar stuff with indexed names. 

```
std::unordered_map<std::string, std::string> u = {
        {"RED","#FF0000"},
        {"GREEN","#00FF00"},
        {"BLUE","#0000FF"}
    };
```
Then when we debug:
```
(std::unordered_map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >) u = size=3 {
  [0] = {
    __cc = (first = "BLUE", second = "#0000FF")
  }
  [1] = {
    __cc = (first = "GREEN", second = "#00FF00")
  }
  [2] = {
    __cc = (first = "RED", second = "#FF0000")
  }
}
```
So it will work for unordered_map.


================
Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:1035
+  // or if we have a synthetic child provider. We don't want to call
+  // "v.GetNumChildren()" on all objects as class, struct and union types don't
+  // need to be completed if they are never expanded. So we want to avoid
----------------
yinghuitan wrote:
> It sucks that `indexedVariables` has be to be filled at container variable creation time to determine the children number. 
> A better DAP design would be VSCode asking for children count at container expansion time. Then we can always call `GetNumChildren()` since all children will be enumerated anyway.
Agreed, but not much we can do there.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125347/new/

https://reviews.llvm.org/D125347



More information about the lldb-commits mailing list