[Lldb-commits] [PATCH] D79384: RFC: Add an API that allows iterating over a debug map's OSO's Modules
Adrian Prantl via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon May 4 18:50:42 PDT 2020
aprantl created this revision.
aprantl added reviewers: jingham, jasonmolenda, teemperor, friss.
Herald added a reviewer: jdoerfert.
For Swift LLDB (but potentially also for module support in Clang-land) I need a way to accumulate the path remappings produced by `Module::RegisterXcodeSDK()`. Unfortunately there is no way to go from an executable's Module to the auxiliary modules that represent the individual OSO object files of a SymbolFileDWARFDebugMap.
Here is a proposed API that would allow me to do this. Does this look reasonable?
https://reviews.llvm.org/D79384
Files:
lldb/include/lldb/Symbol/SymbolFile.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -67,6 +67,8 @@
bool ForEachExternalModule(
lldb_private::CompileUnit &, llvm::DenseSet<lldb_private::SymbolFile *> &,
llvm::function_ref<bool(lldb_private::Module &)>) override;
+ bool ForEachAuxiliaryModule(
+ llvm::function_ref<bool(lldb_private::Module &)>) override;
bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit,
lldb_private::FileSpecList &support_files) override;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -663,6 +663,19 @@
return false;
}
+bool SymbolFileDWARFDebugMap::ForEachAuxiliaryModule(
+ llvm::function_ref<bool(Module &)> f) {
+ std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
+ ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+ if (oso_dwarf)
+ if (auto *obj = oso_dwarf->GetObjectFile())
+ if (ModuleSP module_sp = obj->GetModule())
+ return f(*module_sp);
+ return false;
+ });
+ return false;
+}
+
bool SymbolFileDWARFDebugMap::ParseSupportFiles(CompileUnit &comp_unit,
FileSpecList &support_files) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
Index: lldb/include/lldb/Symbol/SymbolFile.h
===================================================================
--- lldb/include/lldb/Symbol/SymbolFile.h
+++ lldb/include/lldb/Symbol/SymbolFile.h
@@ -164,6 +164,25 @@
llvm::function_ref<bool(Module &)> lambda) {
return false;
}
+
+ /// Apply a lambda to each auxiliary lldb::Module referenced by this
+ /// \p comp_unit.
+ ///
+ /// This function can be used to traverse all OSO modules in a
+ /// SymbolFileDWARFDebugMap.
+ ///
+ /// \param[in] lambda
+ /// The lambda that should be applied to every function. The lambda can
+ /// return true if the iteration should be aborted earlier.
+ ///
+ /// \return
+ /// If the lambda early-exited, this function returns true to
+ /// propagate the early exit.
+ virtual bool
+ ForEachAuxiliaryModule(llvm::function_ref<bool(Module &)> lambda) {
+ return false;
+ }
+
virtual bool ParseSupportFiles(CompileUnit &comp_unit,
FileSpecList &support_files) = 0;
virtual size_t ParseTypes(CompileUnit &comp_unit) = 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79384.261983.patch
Type: text/x-patch
Size: 2784 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200505/e302b5b6/attachment-0001.bin>
More information about the lldb-commits
mailing list