Skip to content

Commit ca3b9af

Browse files
authored
Add logs for SymbolFileDWARF::FindTypes (#106030)
`SymbolFileDWARF::FindTypes` was logged prior to [this commit](dd95877#diff-edef3a65d5d569bbb75a4158d35b827aa5d42ee03ccd3b0c1d4f354afa12210c). This is a helpful log message for checking for redundant type searches
1 parent fbef4c2 commit ca3b9af

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2737,10 +2737,19 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, TypeResults &results) {
27372737
if (results.AlreadySearched(this))
27382738
return;
27392739

2740+
auto type_basename = query.GetTypeBasename();
2741+
2742+
Log *log = GetLog(DWARFLog::Lookups);
2743+
if (log) {
2744+
GetObjectFile()->GetModule()->LogMessage(
2745+
log, "SymbolFileDWARF::FindTypes(type_basename=\"{0}\")",
2746+
type_basename);
2747+
}
2748+
27402749
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
27412750

27422751
bool have_index_match = false;
2743-
m_index->GetTypes(query.GetTypeBasename(), [&](DWARFDIE die) {
2752+
m_index->GetTypes(type_basename, [&](DWARFDIE die) {
27442753
// Check the language, but only if we have a language filter.
27452754
if (query.HasLanguage()) {
27462755
if (!query.LanguageMatches(GetLanguageFamily(*die.GetCU())))
@@ -2779,8 +2788,14 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, TypeResults &results) {
27792788
return !results.Done(query); // Keep iterating if we aren't done.
27802789
});
27812790

2782-
if (results.Done(query))
2791+
if (results.Done(query)) {
2792+
if (log) {
2793+
GetObjectFile()->GetModule()->LogMessage(
2794+
log, "SymbolFileDWARF::FindTypes(type_basename=\"{0}\") => {1}",
2795+
type_basename, results.GetTypeMap().GetSize());
2796+
}
27832797
return;
2798+
}
27842799

27852800
// With -gsimple-template-names, a templated type's DW_AT_name will not
27862801
// contain the template parameters. Try again stripping '<' and anything
@@ -2795,10 +2810,10 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, TypeResults &results) {
27952810
// it trims any context items down by removing template parameter names.
27962811
TypeQuery query_simple(query);
27972812
if (UpdateCompilerContextForSimpleTemplateNames(query_simple)) {
2798-
2813+
auto type_basename_simple = query_simple.GetTypeBasename();
27992814
// Copy our match's context and update the basename we are looking for
28002815
// so we can use this only to compare the context correctly.
2801-
m_index->GetTypes(query_simple.GetTypeBasename(), [&](DWARFDIE die) {
2816+
m_index->GetTypes(type_basename_simple, [&](DWARFDIE die) {
28022817
// Check the language, but only if we have a language filter.
28032818
if (query.HasLanguage()) {
28042819
if (!query.LanguageMatches(GetLanguageFamily(*die.GetCU())))
@@ -2834,8 +2849,17 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, TypeResults &results) {
28342849
}
28352850
return !results.Done(query); // Keep iterating if we aren't done.
28362851
});
2837-
if (results.Done(query))
2852+
if (results.Done(query)) {
2853+
if (log) {
2854+
GetObjectFile()->GetModule()->LogMessage(
2855+
log,
2856+
"SymbolFileDWARF::FindTypes(type_basename=\"{0}\") => {1} "
2857+
"(simplified as \"{2}\")",
2858+
type_basename, results.GetTypeMap().GetSize(),
2859+
type_basename_simple);
2860+
}
28382861
return;
2862+
}
28392863
}
28402864
}
28412865

@@ -2847,8 +2871,11 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, TypeResults &results) {
28472871
for (const auto &pair : m_external_type_modules) {
28482872
if (ModuleSP external_module_sp = pair.second) {
28492873
external_module_sp->FindTypes(query, results);
2850-
if (results.Done(query))
2874+
if (results.Done(query)) {
2875+
// We don't log the results here as they are already logged in the
2876+
// nested FindTypes call
28512877
return;
2878+
}
28522879
}
28532880
}
28542881
}

0 commit comments

Comments
 (0)