Skip to content

[🍒 stable/20240723] Add logs for SymbolFileDWARF::FindTypes #9443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 33 additions & 6 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2756,10 +2756,19 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, TypeResults &results) {
if (results.AlreadySearched(this))
return;

auto type_basename = query.GetTypeBasename();

Log *log = GetLog(DWARFLog::Lookups);
if (log) {
GetObjectFile()->GetModule()->LogMessage(
log, "SymbolFileDWARF::FindTypes(type_basename=\"{0}\")",
type_basename);
}

std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());

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

if (results.Done(query))
if (results.Done(query)) {
if (log) {
GetObjectFile()->GetModule()->LogMessage(
log, "SymbolFileDWARF::FindTypes(type_basename=\"{0}\") => {1}",
type_basename, results.GetTypeMap().GetSize());
}
return;
}

// With -gsimple-template-names, a templated type's DW_AT_name will not
// contain the template parameters. Try again stripping '<' and anything
Expand All @@ -2814,10 +2829,10 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, TypeResults &results) {
// it trims any context items down by removing template parameter names.
TypeQuery query_simple(query);
if (UpdateCompilerContextForSimpleTemplateNames(query_simple)) {

auto type_basename_simple = query_simple.GetTypeBasename();
// Copy our match's context and update the basename we are looking for
// so we can use this only to compare the context correctly.
m_index->GetTypes(query_simple.GetTypeBasename(), [&](DWARFDIE die) {
m_index->GetTypes(type_basename_simple, [&](DWARFDIE die) {
// Check the language, but only if we have a language filter.
if (query.HasLanguage()) {
if (!query.LanguageMatches(GetLanguageFamily(*die.GetCU())))
Expand Down Expand Up @@ -2853,8 +2868,17 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, TypeResults &results) {
}
return !results.Done(query); // Keep iterating if we aren't done.
});
if (results.Done(query))
if (results.Done(query)) {
if (log) {
GetObjectFile()->GetModule()->LogMessage(
log,
"SymbolFileDWARF::FindTypes(type_basename=\"{0}\") => {1} "
"(simplified as \"{2}\")",
type_basename, results.GetTypeMap().GetSize(),
type_basename_simple);
}
return;
}
}
}

Expand All @@ -2866,8 +2890,11 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, TypeResults &results) {
for (const auto &pair : m_external_type_modules) {
if (ModuleSP external_module_sp = pair.second) {
external_module_sp->FindTypes(query, results);
if (results.Done(query))
if (results.Done(query)) {
// We don't log the results here as they are already logged in the
// nested FindTypes call
return;
}
}
}
}
Expand Down