Skip to content

[lldb] Move LocateExecutableSymbolFile to SymbolLocator plugin #71266

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
Nov 4, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions lldb/include/lldb/Core/PluginManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ class PluginManager {
SymbolLocatorCreateInstance create_callback,
SymbolLocatorLocateExecutableObjectFile locate_executable_object_file =
nullptr,
SymbolLocatorLocateExecutableSymbolFile locate_executable_symbol_file =
nullptr,
SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle = nullptr);

static bool UnregisterPlugin(SymbolLocatorCreateInstance create_callback);
Expand All @@ -360,6 +362,10 @@ class PluginManager {

static ModuleSpec LocateExecutableObjectFile(const ModuleSpec &module_spec);

static FileSpec
LocateExecutableSymbolFile(const ModuleSpec &module_spec,
const FileSpecList &default_search_paths);

static FileSpec FindSymbolFileInBundle(const FileSpec &dsym_bundle_fspec,
const UUID *uuid,
const ArchSpec *arch);
Expand Down
8 changes: 0 additions & 8 deletions lldb/include/lldb/Symbol/LocateSymbolFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ class UUID;

class Symbols {
public:
// Locate the symbol file given a module specification.
//
// Locating the file should happen only on the local computer or using the
// current computers global settings.
static FileSpec
LocateExecutableSymbolFile(const ModuleSpec &module_spec,
const FileSpecList &default_search_paths);

// Locate the object and symbol file given a module specification.
//
// Locating the file can try to download the file from a corporate build
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/lldb-private-interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ typedef std::optional<ModuleSpec> (*SymbolLocatorLocateExecutableObjectFile)(
const ModuleSpec &module_spec);
typedef std::optional<FileSpec> (*SymbolLocatorFindSymbolFileInBundle)(
const FileSpec &dsym_bundle_fspec, const UUID *uuid, const ArchSpec *arch);
typedef std::optional<FileSpec> (*SymbolLocatorLocateExecutableSymbolFile)(
const ModuleSpec &module_spec, const FileSpecList &default_search_paths);
typedef bool (*BreakpointHitCallback)(void *baton,
StoppointCallbackContext *context,
lldb::user_id_t break_id,
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Core/DynamicLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ ModuleSP DynamicLoader::LoadBinaryWithUUIDAndAddress(
if (!module_sp) {
FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
module_spec.GetSymbolFileSpec() =
Symbols::LocateExecutableSymbolFile(module_spec, search_paths);
PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
ModuleSpec objfile_module_spec =
PluginManager::LocateExecutableObjectFile(module_spec);
module_spec.GetFileSpec() = objfile_module_spec.GetFileSpec();
Expand Down
20 changes: 19 additions & 1 deletion lldb/source/Core/PluginManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1089,13 +1089,16 @@ struct SymbolLocatorInstance
llvm::StringRef name, llvm::StringRef description,
CallbackType create_callback,
SymbolLocatorLocateExecutableObjectFile locate_executable_object_file,
SymbolLocatorLocateExecutableSymbolFile locate_executable_symbol_file,
SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle)
: PluginInstance<SymbolLocatorCreateInstance>(name, description,
create_callback),
locate_executable_object_file(locate_executable_object_file),
locate_executable_symbol_file(locate_executable_symbol_file),
find_symbol_file_in_bundle(find_symbol_file_in_bundle) {}

SymbolLocatorLocateExecutableObjectFile locate_executable_object_file;
SymbolLocatorLocateExecutableSymbolFile locate_executable_symbol_file;
SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle;
};
typedef PluginInstances<SymbolLocatorInstance> SymbolLocatorInstances;
Expand All @@ -1109,10 +1112,11 @@ bool PluginManager::RegisterPlugin(
llvm::StringRef name, llvm::StringRef description,
SymbolLocatorCreateInstance create_callback,
SymbolLocatorLocateExecutableObjectFile locate_executable_object_file,
SymbolLocatorLocateExecutableSymbolFile locate_executable_symbol_file,
SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle) {
return GetSymbolLocatorInstances().RegisterPlugin(
name, description, create_callback, locate_executable_object_file,
find_symbol_file_in_bundle);
locate_executable_symbol_file, find_symbol_file_in_bundle);
}

bool PluginManager::UnregisterPlugin(
Expand All @@ -1139,6 +1143,20 @@ PluginManager::LocateExecutableObjectFile(const ModuleSpec &module_spec) {
return {};
}

FileSpec PluginManager::LocateExecutableSymbolFile(
const ModuleSpec &module_spec, const FileSpecList &default_search_paths) {
auto &instances = GetSymbolLocatorInstances().GetInstances();
for (auto &instance : instances) {
if (instance.locate_executable_symbol_file) {
std::optional<FileSpec> result = instance.locate_executable_symbol_file(
module_spec, default_search_paths);
if (result)
return *result;
}
}
return {};
}

FileSpec PluginManager::FindSymbolFileInBundle(const FileSpec &symfile_bundle,
const UUID *uuid,
const ArchSpec *arch) {
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ Status ProcessKDP::DoConnectRemote(llvm::StringRef remote_url) {
FileSpecList search_paths =
Target::GetDefaultDebugFileSearchPaths();
module_spec.GetSymbolFileSpec() =
Symbols::LocateExecutableSymbolFile(module_spec,
search_paths);
PluginManager::LocateExecutableSymbolFile(module_spec,
search_paths);
if (module_spec.GetSymbolFileSpec()) {
ModuleSpec executable_module_spec =
PluginManager::LocateExecutableObjectFile(module_spec);
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4329,7 +4329,7 @@ const std::shared_ptr<SymbolFileDWARFDwo> &SymbolFileDWARF::GetDwpSymbolFile() {

FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
FileSpec dwp_filespec =
Symbols::LocateExecutableSymbolFile(module_spec, search_paths);
PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
if (FileSystem::Instance().Exists(dwp_filespec)) {
DataBufferSP dwp_file_data_sp;
lldb::offset_t dwp_file_data_offset = 0;
Expand Down
Loading