aprantl updated this revision to Diff 224161.

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

https://reviews.llvm.org/D68678

Files:
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/Makefile
  
lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/TestCPPAccelerator.py
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/a.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/b.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/c.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -110,6 +110,18 @@
   const bool has_qualified_name_hash =
       m_apple_types_up->GetHeader().header_data.ContainsAtom(
           DWARFMappedHash::eAtomTypeQualNameHash);
+
+  // When searching for "std::vector<int>::const_iterator", reject any
+  // files without "vector<int>" early, since there will be many other
+  // "const_iterators".
+  if (context.GetSize() > 1 && (context[1].tag == DW_TAG_class_type ||
+                                context[1].tag == DW_TAG_structure_type)) {
+    DIEArray class_matches;
+    m_apple_types_up->FindByName(context[1].name, class_matches);
+    if (class_matches.empty())
+      return;
+  }
+
   const ConstString type_name(context[0].name);
   const dw_tag_t tag = context[0].tag;
   if (has_tag && has_qualified_name_hash) {
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
===================================================================
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
@@ -0,0 +1,12 @@
+#define CLASS(NAME)                             \
+  class NAME {                                  \
+    public:                                     \
+    class Inner {                               \
+      int j = #NAME[0];                         \
+    };                                          \
+    Inner *i = nullptr;                         \
+  };                                            \
+                                                \
+  static NAME::Inner inner;                     \
+  static NAME obj;                              \
+  NAME::Inner &getInner##NAME() { return inner; }
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
===================================================================
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
@@ -0,0 +1,28 @@
+#define CLASS(NAME)                             \
+  class NAME {                                  \
+  public:                                       \
+    struct Inner;                               \
+    Inner *i = nullptr;                         \
+  };                                            \
+NAME::Inner &getInner##NAME();
+
+CLASS(A)
+CLASS(B)
+CLASS(C)
+CLASS(D)
+CLASS(E)
+CLASS(F)
+CLASS(G)
+
+int main()
+{
+  A::Inner &inner_a = getInnerA();
+  B::Inner &inner_b = getInnerB();
+  C::Inner &inner_c = getInnerC();
+  D::Inner &inner_d = getInnerD();
+  E::Inner &inner_e = getInnerE();
+  F::Inner &inner_f = getInnerF();
+  G::Inner &inner_g = getInnerG();
+
+  return 0; // break here
+}
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp
===================================================================
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(G)
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp
===================================================================
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(F)
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp
===================================================================
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(E)
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp
===================================================================
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(D)
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/c.cpp
===================================================================
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/c.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(C)
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/b.cpp
===================================================================
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/b.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(B)
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/a.cpp
===================================================================
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/a.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(A)
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/TestCPPAccelerator.py
===================================================================
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/TestCPPAccelerator.py
@@ -0,0 +1,31 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class CPPAcceleratorTableTestCase(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    @skipUnlessDarwin
+    @skipIf(debug_info=no_match(["dwarf"]))
+    def test(self):
+        """Test that type lookups fail early (performance)"""
+        self.build()
+        logfile = self.getBuildArtifact('dwarf.log')
+        self.expect('log enable dwarf lookups -f' + logfile)
+        target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+            self, 'break here', lldb.SBFileSpec('main.cpp'))
+        # Pick one from the middle of the list to have a high chance
+        # of it not being in the first file looked at.
+        self.expect('frame variable inner_d')
+
+        log = open(logfile, 'r')
+        n = 0
+        for line in log:
+            if re.findall(r'[abcdefg]\.o: FindByNameAndTag\(\)', line):
+                self.assertTrue("d.o" in line)
+                n += 1
+
+        self.assertEqual(n, 1, log)
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/Makefile
===================================================================
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/Makefile
@@ -0,0 +1,7 @@
+# There is no guaranteed order in which the linker will order these
+# files, so we just have a lot of them to make it unlikely that we hit
+# the right one first by pure luck.
+
+CXX_SOURCES := main.cpp a.cpp b.cpp c.cpp d.cpp e.cpp f.cpp g.cpp
+
+include Makefile.rules
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to