[Lldb-commits] [lldb] Improve type and namespace lookup using parent chain (PR #108907)

via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 19 14:11:37 PDT 2024


================
@@ -402,6 +420,36 @@ bool DebugNamesDWARFIndex::SameParentChain(
   return true;
 }
 
+bool DebugNamesDWARFIndex::WithinParentChain(
+    llvm::ArrayRef<llvm::StringRef> query_parent_names,
+    llvm::ArrayRef<DebugNames::Entry> parent_chain) const {
+  if (parent_chain.size() < query_parent_names.size())
+    return false;
+
+  size_t query_idx = 0, chain_idx = 0;
+  while (query_idx < query_parent_names.size() &&
+         chain_idx < parent_chain.size()) {
+    if (SameAsEntryATName(query_parent_names[query_idx],
+                          parent_chain[chain_idx])) {
+      ++query_idx;
+      ++chain_idx;
+    } else {
+      // Name does not match, try next parent_chain entry if the current entry
+      // is namespace because the current one can be an inline namespace.
----------------
jeffreytan81 wrote:

Yeah, I would love to but I do not think .debug_names tag has information to filter it out. It simply encodes `DW_TAG_namespace` tag:
```
   Name 1748 {
      Hash: 0xB3EF34A4
      String: 0x0000ae01 "inline_ns"
      Entry @ 0xb2d9 {
        Abbrev: 0x5
        Tag: DW_TAG_namespace
        DW_IDX_die_offset: 0x00015df7
        DW_IDX_parent: Entry @ 0xbab8
      }
    }
```
I guess we could try to PeekDieName() to parse this DIE from dwo files to check if it is an inline vs non-inline namespace but that is the expensive code path this PR wants to avoid.

https://github.com/llvm/llvm-project/pull/108907


More information about the lldb-commits mailing list