Skip to content

Commit 72c1804

Browse files
committed
[lldb] Move LocateExecutableSymbolFile to SymbolLocator plugin (llvm#71266)
This builds on top of the work started in c3a302d to convert LocateSymbolFile to a SymbolLocator plugin. This commit moves LocateExecutableSymbolFile. (cherry picked from commit 19df9aa)
1 parent af0e861 commit 72c1804

File tree

19 files changed

+631
-370
lines changed

19 files changed

+631
-370
lines changed

lldb/include/lldb/Core/PluginManager.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ class PluginManager {
351351
SymbolLocatorCreateInstance create_callback,
352352
SymbolLocatorLocateExecutableObjectFile locate_executable_object_file =
353353
nullptr,
354+
SymbolLocatorLocateExecutableSymbolFile locate_executable_symbol_file =
355+
nullptr,
354356
SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle = nullptr);
355357

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

361363
static ModuleSpec LocateExecutableObjectFile(const ModuleSpec &module_spec);
362364

365+
static FileSpec
366+
LocateExecutableSymbolFile(const ModuleSpec &module_spec,
367+
const FileSpecList &default_search_paths);
368+
363369
static FileSpec FindSymbolFileInBundle(const FileSpec &dsym_bundle_fspec,
364370
const UUID *uuid,
365371
const ArchSpec *arch);

lldb/include/lldb/Symbol/LocateSymbolFile.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@ class UUID;
2424

2525
class Symbols {
2626
public:
27-
// Locate the symbol file given a module specification.
28-
//
29-
// Locating the file should happen only on the local computer or using the
30-
// current computers global settings.
31-
static FileSpec
32-
LocateExecutableSymbolFile(const ModuleSpec &module_spec,
33-
const FileSpecList &default_search_paths);
34-
3527
// Locate the object and symbol file given a module specification.
3628
//
3729
// Locating the file can try to download the file from a corporate build

lldb/include/lldb/lldb-private-interfaces.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ typedef std::optional<ModuleSpec> (*SymbolLocatorLocateExecutableObjectFile)(
9696
const ModuleSpec &module_spec);
9797
typedef std::optional<FileSpec> (*SymbolLocatorFindSymbolFileInBundle)(
9898
const FileSpec &dsym_bundle_fspec, const UUID *uuid, const ArchSpec *arch);
99+
typedef std::optional<FileSpec> (*SymbolLocatorLocateExecutableSymbolFile)(
100+
const ModuleSpec &module_spec, const FileSpecList &default_search_paths);
99101
typedef bool (*BreakpointHitCallback)(void *baton,
100102
StoppointCallbackContext *context,
101103
lldb::user_id_t break_id,

lldb/source/Core/DynamicLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ ModuleSP DynamicLoader::LoadBinaryWithUUIDAndAddress(
219219
if (!module_sp) {
220220
FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
221221
module_spec.GetSymbolFileSpec() =
222-
Symbols::LocateExecutableSymbolFile(module_spec, search_paths);
222+
PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
223223
ModuleSpec objfile_module_spec =
224224
PluginManager::LocateExecutableObjectFile(module_spec);
225225
module_spec.GetFileSpec() = objfile_module_spec.GetFileSpec();

lldb/source/Core/PluginManager.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,13 +1089,16 @@ struct SymbolLocatorInstance
10891089
llvm::StringRef name, llvm::StringRef description,
10901090
CallbackType create_callback,
10911091
SymbolLocatorLocateExecutableObjectFile locate_executable_object_file,
1092+
SymbolLocatorLocateExecutableSymbolFile locate_executable_symbol_file,
10921093
SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle)
10931094
: PluginInstance<SymbolLocatorCreateInstance>(name, description,
10941095
create_callback),
10951096
locate_executable_object_file(locate_executable_object_file),
1097+
locate_executable_symbol_file(locate_executable_symbol_file),
10961098
find_symbol_file_in_bundle(find_symbol_file_in_bundle) {}
10971099

10981100
SymbolLocatorLocateExecutableObjectFile locate_executable_object_file;
1101+
SymbolLocatorLocateExecutableSymbolFile locate_executable_symbol_file;
10991102
SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle;
11001103
};
11011104
typedef PluginInstances<SymbolLocatorInstance> SymbolLocatorInstances;
@@ -1109,10 +1112,11 @@ bool PluginManager::RegisterPlugin(
11091112
llvm::StringRef name, llvm::StringRef description,
11101113
SymbolLocatorCreateInstance create_callback,
11111114
SymbolLocatorLocateExecutableObjectFile locate_executable_object_file,
1115+
SymbolLocatorLocateExecutableSymbolFile locate_executable_symbol_file,
11121116
SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle) {
11131117
return GetSymbolLocatorInstances().RegisterPlugin(
11141118
name, description, create_callback, locate_executable_object_file,
1115-
find_symbol_file_in_bundle);
1119+
locate_executable_symbol_file, find_symbol_file_in_bundle);
11161120
}
11171121

11181122
bool PluginManager::UnregisterPlugin(
@@ -1139,6 +1143,20 @@ PluginManager::LocateExecutableObjectFile(const ModuleSpec &module_spec) {
11391143
return {};
11401144
}
11411145

1146+
FileSpec PluginManager::LocateExecutableSymbolFile(
1147+
const ModuleSpec &module_spec, const FileSpecList &default_search_paths) {
1148+
auto &instances = GetSymbolLocatorInstances().GetInstances();
1149+
for (auto &instance : instances) {
1150+
if (instance.locate_executable_symbol_file) {
1151+
std::optional<FileSpec> result = instance.locate_executable_symbol_file(
1152+
module_spec, default_search_paths);
1153+
if (result)
1154+
return *result;
1155+
}
1156+
}
1157+
return {};
1158+
}
1159+
11421160
FileSpec PluginManager::FindSymbolFileInBundle(const FileSpec &symfile_bundle,
11431161
const UUID *uuid,
11441162
const ArchSpec *arch) {

lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ Status PlatformDarwinKernel::GetSharedModuleKernel(
812812
FileSpecList search_paths =
813813
process->GetTarget().GetDebugFileSearchPaths();
814814
FileSpec dsym_fspec =
815-
Symbols::LocateExecutableSymbolFile(kern_spec, search_paths);
815+
PluginManager::LocateExecutableSymbolFile(kern_spec, search_paths);
816816
if (FileSystem::Instance().Exists(dsym_fspec))
817817
module_sp->SetSymbolFileFileSpec(dsym_fspec);
818818
if (did_create_ptr)

lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ Status ProcessKDP::DoConnectRemote(llvm::StringRef remote_url) {
279279
FileSpecList search_paths =
280280
Target::GetDefaultDebugFileSearchPaths();
281281
module_spec.GetSymbolFileSpec() =
282-
Symbols::LocateExecutableSymbolFile(module_spec,
283-
search_paths);
282+
PluginManager::LocateExecutableSymbolFile(module_spec,
283+
search_paths);
284284
if (module_spec.GetSymbolFileSpec()) {
285285
ModuleSpec executable_module_spec =
286286
PluginManager::LocateExecutableObjectFile(module_spec);

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4257,7 +4257,7 @@ const std::shared_ptr<SymbolFileDWARFDwo> &SymbolFileDWARF::GetDwpSymbolFile() {
42574257

42584258
FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
42594259
FileSpec dwp_filespec =
4260-
Symbols::LocateExecutableSymbolFile(module_spec, search_paths);
4260+
PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
42614261
if (FileSystem::Instance().Exists(dwp_filespec)) {
42624262
DataBufferSP dwp_file_data_sp;
42634263
lldb::offset_t dwp_file_data_offset = 0;

0 commit comments

Comments
 (0)