-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[lldb][DWARFIndex] Adapt DebugNamesDWARFIndex::ProcessEntry to IterationAction #152025
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
Michael137
merged 1 commit into
llvm:main
from
Michael137:lldb/dwarf-index-iteration-action-debug-names
Aug 4, 2025
Merged
[lldb][DWARFIndex] Adapt DebugNamesDWARFIndex::ProcessEntry to IterationAction #152025
Michael137
merged 1 commit into
llvm:main
from
Michael137:lldb/dwarf-index-iteration-action-debug-names
Aug 4, 2025
+38
−40
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) ChangesContinuation of #151489 Full diff: https://github.com/llvm/llvm-project/pull/152025.diff 2 Files Affected:
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 9fe03dc5ba1a7..fa5baf1a0eeb1 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -152,17 +152,17 @@ DWARFDIE DebugNamesDWARFIndex::GetDIE(const DebugNames::Entry &entry) const {
return DWARFDIE();
}
-bool DebugNamesDWARFIndex::ProcessEntry(
+IterationAction DebugNamesDWARFIndex::ProcessEntry(
const DebugNames::Entry &entry,
- llvm::function_ref<bool(DWARFDIE die)> callback) {
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
DWARFDIE die = GetDIE(entry);
if (!die)
- return true;
+ return IterationAction::Continue;
// Clang used to erroneously emit index entries for declaration DIEs in case
// when the definition is in a type unit (llvm.org/pr77696).
if (die.IsStructUnionOrClass() &&
die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0))
- return true;
+ return IterationAction::Continue;
return callback(die);
}
@@ -185,7 +185,7 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
if (entry.tag() != DW_TAG_variable)
continue;
- if (!ProcessEntry(entry, IterationActionAdaptor(callback)))
+ if (ProcessEntry(entry, callback) == IterationAction::Stop)
return;
}
@@ -207,7 +207,7 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
if (entry_or->tag() != DW_TAG_variable)
continue;
- if (!ProcessEntry(*entry_or, IterationActionAdaptor(callback)))
+ if (ProcessEntry(*entry_or, callback) == IterationAction::Stop)
return;
}
MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
@@ -243,7 +243,7 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
continue;
found_entry_for_cu = true;
- if (!ProcessEntry(*entry_or, IterationActionAdaptor(callback)))
+ if (ProcessEntry(*entry_or, callback) == IterationAction::Stop)
return;
}
MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
@@ -358,16 +358,15 @@ void DebugNamesDWARFIndex::GetFullyQualifiedType(
if (!parent_chain) {
// Fallback: use the base class implementation.
- if (!ProcessEntry(entry, IterationActionAdaptor([&](DWARFDIE die) {
- return GetFullyQualifiedTypeImpl(context, die,
- callback);
- })))
+ if (ProcessEntry(entry, [&](DWARFDIE die) {
+ return GetFullyQualifiedTypeImpl(context, die, callback);
+ }) == IterationAction::Stop)
return;
continue;
}
if (SameParentChain(parent_names, *parent_chain)) {
- if (!ProcessEntry(entry, IterationActionAdaptor(callback)))
+ if (ProcessEntry(entry, callback) == IterationAction::Stop)
return;
}
}
@@ -462,7 +461,7 @@ void DebugNamesDWARFIndex::GetTypes(
for (const DebugNames::Entry &entry :
m_debug_names_up->equal_range(name.GetStringRef())) {
if (isType(entry.tag())) {
- if (!ProcessEntry(entry, IterationActionAdaptor(callback)))
+ if (ProcessEntry(entry, callback) == IterationAction::Stop)
return;
}
}
@@ -476,7 +475,7 @@ void DebugNamesDWARFIndex::GetTypes(
auto name = context[0].name;
for (const DebugNames::Entry &entry : m_debug_names_up->equal_range(name)) {
if (entry.tag() == context[0].tag) {
- if (!ProcessEntry(entry, IterationActionAdaptor(callback)))
+ if (ProcessEntry(entry, callback) == IterationAction::Stop)
return;
}
}
@@ -492,7 +491,7 @@ void DebugNamesDWARFIndex::GetNamespaces(
llvm::dwarf::Tag entry_tag = entry.tag();
if (entry_tag == DW_TAG_namespace ||
entry_tag == DW_TAG_imported_declaration) {
- if (!ProcessEntry(entry, IterationActionAdaptor(callback)))
+ if (ProcessEntry(entry, callback) == IterationAction::Stop)
return;
}
}
@@ -549,21 +548,20 @@ void DebugNamesDWARFIndex::GetTypesWithQuery(
getParentChain(entry);
if (!parent_chain) {
// Fallback: use the base class implementation.
- if (!ProcessEntry(entry, IterationActionAdaptor([&](DWARFDIE die) {
- return ProcessTypeDIEMatchQuery(query, die, callback);
- })))
+ if (ProcessEntry(entry, [&](DWARFDIE die) {
+ return ProcessTypeDIEMatchQuery(query, die, callback);
+ }) == IterationAction::Stop)
return;
continue;
}
if (WithinParentChain(parent_contexts, *parent_chain)) {
- if (!ProcessEntry(entry, IterationActionAdaptor([&](DWARFDIE die) {
- // After .debug_names filtering still sending to base
- // class for further filtering before calling the
- // callback.
- return ProcessTypeDIEMatchQuery(query, die, callback);
- })))
- // If the callback returns false, we're done.
+ if (ProcessEntry(entry, [&](DWARFDIE die) {
+ // After .debug_names filtering still sending to base
+ // class for further filtering before calling the
+ // callback.
+ return ProcessTypeDIEMatchQuery(query, die, callback);
+ }) == IterationAction::Stop)
return;
}
}
@@ -588,23 +586,22 @@ void DebugNamesDWARFIndex::GetNamespacesWithParents(
getParentChain(entry);
if (!parent_chain) {
// Fallback: use the base class implementation.
- if (!ProcessEntry(entry, IterationActionAdaptor([&](DWARFDIE die) {
- return ProcessNamespaceDieMatchParents(
- parent_decl_ctx, die, callback);
- })))
+ if (ProcessEntry(entry, [&](DWARFDIE die) {
+ return ProcessNamespaceDieMatchParents(parent_decl_ctx, die,
+ callback);
+ }) == IterationAction::Stop)
return;
continue;
}
if (WithinParentChain(parent_named_contexts, *parent_chain)) {
- if (!ProcessEntry(entry, IterationActionAdaptor([&](DWARFDIE die) {
- // After .debug_names filtering still sending to
- // base class for further filtering before calling
- // the callback.
- return ProcessNamespaceDieMatchParents(
- parent_decl_ctx, die, callback);
- })))
- // If the callback returns false, we're done.
+ if (ProcessEntry(entry, [&](DWARFDIE die) {
+ // After .debug_names filtering still sending to
+ // base class for further filtering before calling
+ // the callback.
+ return ProcessNamespaceDieMatchParents(parent_decl_ctx, die,
+ callback);
+ }) == IterationAction::Stop)
return;
}
}
@@ -653,7 +650,7 @@ void DebugNamesDWARFIndex::GetFunctions(
if (tag != DW_TAG_subprogram && tag != DW_TAG_inlined_subroutine)
continue;
- if (!ProcessEntry(*entry_or, IterationActionAdaptor(callback)))
+ if (ProcessEntry(*entry_or, callback) == IterationAction::Stop)
return;
}
MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
index 0587f0401f718..5ebd4f6deb5d4 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
@@ -122,8 +122,9 @@ class DebugNamesDWARFIndex : public DWARFIndex {
std::optional<DWARFTypeUnit *>
GetForeignTypeUnit(const DebugNames::Entry &entry) const;
- bool ProcessEntry(const DebugNames::Entry &entry,
- llvm::function_ref<bool(DWARFDIE die)> callback);
+ IterationAction
+ ProcessEntry(const DebugNames::Entry &entry,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback);
/// Returns true if `parent_entries` have identical names to `parent_names`.
bool SameParentChain(llvm::ArrayRef<llvm::StringRef> parent_names,
|
adrian-prantl
approved these changes
Aug 4, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Continuation of #151489