Skip to content

Commit 9a041c0

Browse files
committed
Add logs for SymbolFileDWARF::FindTypes (llvm#106030)
`SymbolFileDWARF::FindTypes` was logged prior to [this commit](llvm@dd95877#diff-edef3a65d5d569bbb75a4158d35b827aa5d42ee03ccd3b0c1d4f354afa12210c). This is a helpful log message for checking for redundant type searches
1 parent 0657c77 commit 9a041c0

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
@@ -2756,10 +2756,19 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, TypeResults &results) {
27562756
if (results.AlreadySearched(this))
27572757
return;
27582758

2759+
auto type_basename = query.GetTypeBasename();
2760+
2761+
Log *log = GetLog(DWARFLog::Lookups);
2762+
if (log) {
2763+
GetObjectFile()->GetModule()->LogMessage(
2764+
log, "SymbolFileDWARF::FindTypes(type_basename=\"{0}\")",
2765+
type_basename);
2766+
}
2767+
27592768
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
27602769

27612770
bool have_index_match = false;
2762-
m_index->GetTypes(query.GetTypeBasename(), [&](DWARFDIE die) {
2771+
m_index->GetTypes(type_basename, [&](DWARFDIE die) {
27632772
// Check the language, but only if we have a language filter.
27642773
if (query.HasLanguage()) {
27652774
if (!query.LanguageMatches(GetLanguageFamily(*die.GetCU())))
@@ -2798,8 +2807,14 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, TypeResults &results) {
27982807
return !results.Done(query); // Keep iterating if we aren't done.
27992808
});
28002809

2801-
if (results.Done(query))
2810+
if (results.Done(query)) {
2811+
if (log) {
2812+
GetObjectFile()->GetModule()->LogMessage(
2813+
log, "SymbolFileDWARF::FindTypes(type_basename=\"{0}\") => {1}",
2814+
type_basename, results.GetTypeMap().GetSize());
2815+
}
28022816
return;
2817+
}
28032818

28042819
// With -gsimple-template-names, a templated type's DW_AT_name will not
28052820
// contain the template parameters. Try again stripping '<' and anything
@@ -2814,10 +2829,10 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, TypeResults &results) {
28142829
// it trims any context items down by removing template parameter names.
28152830
TypeQuery query_simple(query);
28162831
if (UpdateCompilerContextForSimpleTemplateNames(query_simple)) {
2817-
2832+
auto type_basename_simple = query_simple.GetTypeBasename();
28182833
// Copy our match's context and update the basename we are looking for
28192834
// so we can use this only to compare the context correctly.
2820-
m_index->GetTypes(query_simple.GetTypeBasename(), [&](DWARFDIE die) {
2835+
m_index->GetTypes(type_basename_simple, [&](DWARFDIE die) {
28212836
// Check the language, but only if we have a language filter.
28222837
if (query.HasLanguage()) {
28232838
if (!query.LanguageMatches(GetLanguageFamily(*die.GetCU())))
@@ -2853,8 +2868,17 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, TypeResults &results) {
28532868
}
28542869
return !results.Done(query); // Keep iterating if we aren't done.
28552870
});
2856-
if (results.Done(query))
2871+
if (results.Done(query)) {
2872+
if (log) {
2873+
GetObjectFile()->GetModule()->LogMessage(
2874+
log,
2875+
"SymbolFileDWARF::FindTypes(type_basename=\"{0}\") => {1} "
2876+
"(simplified as \"{2}\")",
2877+
type_basename, results.GetTypeMap().GetSize(),
2878+
type_basename_simple);
2879+
}
28572880
return;
2881+
}
28582882
}
28592883
}
28602884

@@ -2866,8 +2890,11 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, TypeResults &results) {
28662890
for (const auto &pair : m_external_type_modules) {
28672891
if (ModuleSP external_module_sp = pair.second) {
28682892
external_module_sp->FindTypes(query, results);
2869-
if (results.Done(query))
2893+
if (results.Done(query)) {
2894+
// We don't log the results here as they are already logged in the
2895+
// nested FindTypes call
28702896
return;
2897+
}
28712898
}
28722899
}
28732900
}

0 commit comments

Comments
 (0)