--- /dev/null
+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)
--- /dev/null
+#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
+}
const bool has_qualified_name_hash =
m_apple_types_up->GetHeader().header_data.ContainsAtom(
DWARFMappedHash::eAtomTypeQualNameHash);
+
const ConstString type_name(context[0].name);
const dw_tag_t tag = context[0].tag;
if (has_tag && has_qualified_name_hash) {
m_module.LogMessage(log, "FindByNameAndTagAndQualifiedNameHash()");
m_apple_types_up->FindByNameAndTagAndQualifiedNameHash(
type_name.GetStringRef(), tag, qualified_name_hash, offsets);
- } else if (has_tag) {
+ return;
+ }
+
+ if (has_tag) {
+ // When searching for a scoped type (for example,
+ // "std::vector<int>::const_iterator") searching for the innermost
+ // name alone ("const_iterator") could yield many false
+ // positives. By searching for the parent type ("vector<int>")
+ // first we can avoid extracting type DIEs from object files that
+ // would fail the filter anyway.
+ if (!has_qualified_name_hash && (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;
+ }
+
if (log)
m_module.LogMessage(log, "FindByNameAndTag()");
m_apple_types_up->FindByNameAndTag(type_name.GetStringRef(), tag, offsets);
- } else
- m_apple_types_up->FindByName(type_name.GetStringRef(), offsets);
+ return;
+ }
+
+ m_apple_types_up->FindByName(type_name.GetStringRef(), offsets);
}
void AppleDWARFIndex::GetNamespaces(ConstString name, DIEArray &offsets) {