[all-commits] [llvm/llvm-project] 91d5bf: Add "indexedVariables" to variables with lots of c...

Greg Clayton via All-commits all-commits at lists.llvm.org
Wed May 11 16:18:13 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 91d5bfdb7996b353097c886128fc984e310f7122
      https://github.com/llvm/llvm-project/commit/91d5bfdb7996b353097c886128fc984e310f7122
  Author: Greg Clayton <gclayton at fb.com>
  Date:   2022-05-11 (Wed, 11 May 2022)

  Changed paths:
    M lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
    M lldb/test/API/tools/lldb-vscode/variables/main.cpp
    M lldb/tools/lldb-vscode/JSONUtils.cpp

  Log Message:
  -----------
  Add "indexedVariables" to variables with lots of children.

Prior to this fix if we have a really large array or collection class, we would end up always creating all of the child variables for an array or collection class. If the number of children was very high this can cause delays when expanding variables. By adding the "indexedVariables" to variables with lots of children, we can keep good performance in the variables view at all times. This patch will add the "indexedVariables" key/value pair to any "Variable" JSON dictionairies when we have an array of synthetic child provider that will create more than 100 children.

We have to be careful to not call "uint32_t SBValue::GetNumChildren()" on any lldb::SBValue that we use because it can cause a class, struct or union to complete the type in order to be able to properly tell us how many children it has and this can be expensive if you have a lot of variables. By default LLDB won't need to complete a type if we have variables that are classes, structs or unions unless the user expands the variable in the variable view. So we try to only get the GetNumChildren() when we have an array, as this is a cheap operation, or a synthetic child provider, most of which are for showing collections that typically fall into this category. We add a variable reference, which indicates that something can be expanded, when the function "bool SBValue::MightHaveChildren()" is true as this call doesn't need to complete the type in order to return true. This way if no one ever expands class variables, we don't need to complete the type.

Differential Revision: https://reviews.llvm.org/D125347




More information about the All-commits mailing list