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

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 25 11:10:07 PDT 2018


clayborg added a comment.

The current SymbolFile::FindTypes(...) in was designed with type base name only due to how DWARF stores it variables. It has a "const CompilerDeclContext *parent_decl_ctx" which can be specified in order to limit what we find. So we might be able to think of this as a type lookup by basename. It might be handy to add another type lookup that does lookups by fully qualified name only. and leave the current infrastructure alone? A default implementation can be added that returns false for all symbol file unless they support name lookup. Also the current implementation allows you to under specify a type. For code like:

  struct Pt { char x; char y; };
  namespace a {
    struct Pt { short x; short y; };
    namespace b {
      struct Pt { int x; int y; };
    }
  }

We can find all of them using:

  (lldb) type lookup Pt
  struct Pt {
      short x;
      short y;
  }
  struct Pt {
      int x;
      int y;
  }
  struct Pt {
      char x;
      char y;
  }
  
  Or each one individually using:
  
  (lldb) type lookup a::b::Pt
  struct Pt {
      int x;
      int y;
  }
  (lldb) type lookup a::Pt
  struct Pt {
      short x;
      short y;
  }
  (lldb) type lookup ::Pt
  struct Pt {
      char x;
      char y;
  }

Or under specify the namespace:

  (lldb) type lookup b::Pt
  struct Pt {
      int x;
      int y;
  }

That is the current behavior. Not saying it is right. Note we also don't display the decl context for a type when dumping it which would be nice to fix. So we probably need to make sure there are tests for all of the cases above once we hone in on the approach we want all symbol plug-ins to use.



================
Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2443
+
+  // FIXME: When exact_match is true, we should do an optimized O(1) lookup.
+  llvm::StringRef scope;
----------------
There is no O(1) lookup for types in DWARF. Accelerator tables do not have fully qualified type names, only the identifier for the type basename only.


https://reviews.llvm.org/D53662





More information about the lldb-commits mailing list