[Lldb-commits] [PATCH] D53662: Give the SymbolFile plugin enough information to efficiently do exact match lookups

Zachary Turner via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 29 16:19:05 PDT 2018


zturner added a comment.

So I started looking into this, and things get tricky.  If we're doing a lookup by fully qualified name, I would expect there to never be more than one match, but LLDB doesn't seem to hold this same assumption.  For example, in `ItaniumABILanguageRuntime::GetTypeInfoFromVTableAddress` there is code that tries to get an exact match from a single module, and if it doesn't find one, then searches the entire module list for multiple matches on exact name, then specifically handles the case where more than one match was found.  Most of this code is all just for the purposes of logging, but if we cut through all the logging and just get down to the code, it basically amounts to this:

    type_info.SetName(class_name);
    TypeList class_types;
  
    uint32_t num_matches = 0;
    // First look in the module that the vtable symbol came from and
    // look for a single exact match.
    llvm::DenseSet<SymbolFile *> searched_symbol_files;
    if (sc.module_sp) {
      num_modules = sc.module_sp->FindTypes(sc, ConstString(lookup_name),
        exact_match, 1, searched_symbol_files, class_types);
    }
  
    // If we didn't find a symbol, then move on to the entire module
    // list in the target and get as many unique matches as possible
    if (num_matches == 0) {
      num_matches = target.GetImages().FindTypes(
          sc, ConstString(lookup_name), exact_match, UINT32_MAX,
          searched_symbol_files, class_types);
    }
  
    lldb::TypeSP type_sp;
    if (num_matches == 0)
      return TypeAndOrName();
    if (num_matches == 1) {
      type_sp = class_types.GetTypeAtIndex(0);
      if (type_sp) {
        if (ClangASTContext::IsCXXClassType(
                type_sp->GetForwardCompilerType())) {
          type_info.SetTypeSP(type_sp);
      }
    } else if (num_matches > 1) {
      size_t i;
  
      for (i = 0; i < num_matches; i++) {
        type_sp = class_types.GetTypeAtIndex(i);
        if (type_sp) {
          if (ClangASTContext::IsCXXClassType(
                  type_sp->GetForwardCompilerType())) {
            type_info.SetTypeSP(type_sp);
          }
        }
      }
  
    }
    if (type_info)
      SetDynamicTypeInfo(vtable_addr, type_info);
    return type_info;
  }

Why would we ever get more than one type on a fully qualifed exact match name lookup?  And even if we did, why would we care which one we chose?


https://reviews.llvm.org/D53662





More information about the lldb-commits mailing list