[Lldb-commits] [lldb] Add 'FindFirstSymbolWithNameAndType()' to ModuleList. (PR #117777)
Miro Bucko via lldb-commits
lldb-commits at lists.llvm.org
Wed Nov 27 08:35:13 PST 2024
https://github.com/mbucko updated https://github.com/llvm/llvm-project/pull/117777
>From 4ba15cd7e64f8f4a2a5d804a1f986aafff9f6d17 Mon Sep 17 00:00:00 2001
From: Miro Bucko <mbucko at meta.com>
Date: Tue, 26 Nov 2024 12:07:57 -0800
Subject: [PATCH] Add 'FindFirstSymbolWithNameAndType()' to ModuleList.
---
lldb/include/lldb/Core/ModuleList.h | 9 +++++++++
lldb/source/Core/ModuleList.cpp | 12 ++++++++++++
2 files changed, 21 insertions(+)
diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h
index 43d931a8447406..b122b1ce1d84ff 100644
--- a/lldb/include/lldb/Core/ModuleList.h
+++ b/lldb/include/lldb/Core/ModuleList.h
@@ -353,6 +353,15 @@ class ModuleList {
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const;
+ /// Find the first symbol that matches \a name and \a symbol_type.
+ /// \param[in] name
+ /// The name of the symbol we are looking for.
+ /// \param[in] symbol_type
+ /// The type of symbol we are looking for.
+ const Symbol *
+ FindFirstSymbolWithNameAndType(ConstString name,
+ lldb::SymbolType symbol_type) const;
+
void FindSymbolsWithNameAndType(ConstString name,
lldb::SymbolType symbol_type,
SymbolContextList &sc_list) const;
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index 2b8ccab2406c6b..572e4d640fa2b1 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -524,6 +524,18 @@ void ModuleList::FindGlobalVariables(const RegularExpression ®ex,
module_sp->FindGlobalVariables(regex, max_matches, variable_list);
}
+const Symbol *
+ModuleList::FindFirstSymbolWithNameAndType(ConstString name,
+ lldb::SymbolType symbol_type) const {
+ std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
+ for (const ModuleSP &module_sp : m_modules) {
+ if (const Symbol *symbol =
+ module_sp->FindFirstSymbolWithNameAndType(name, symbol_type))
+ return symbol;
+ }
+ return nullptr;
+}
+
void ModuleList::FindSymbolsWithNameAndType(ConstString name,
SymbolType symbol_type,
SymbolContextList &sc_list) const {
More information about the lldb-commits
mailing list