22
22
#include " lldb/Interpreter/OptionValueFileSpecList.h"
23
23
#include " lldb/Interpreter/OptionValueProperties.h"
24
24
#include " lldb/Interpreter/Property.h"
25
+ #include " lldb/Symbol/LocateSymbolFile.h"
25
26
#include " lldb/Symbol/ObjectFile.h"
26
27
#include " lldb/Target/Platform.h"
27
28
#include " lldb/Target/Process.h"
@@ -791,9 +792,10 @@ Status PlatformDarwinKernel::GetSharedModuleKernel(
791
792
const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
792
793
const FileSpecList *module_search_paths_ptr,
793
794
llvm::SmallVectorImpl<ModuleSP> *old_modules, bool *did_create_ptr) {
794
- Status error;
795
- module_sp.reset ();
795
+ assert (module_sp.get () == nullptr );
796
796
UpdateKextandKernelsLocalScan ();
797
+ if (did_create_ptr)
798
+ *did_create_ptr = false ;
797
799
798
800
// First try all kernel binaries that have a dSYM next to them
799
801
for (auto possible_kernel : m_kernel_binaries_with_dsyms) {
@@ -803,22 +805,19 @@ Status PlatformDarwinKernel::GetSharedModuleKernel(
803
805
module_sp.reset (new Module (kern_spec));
804
806
if (module_sp && module_sp->GetObjectFile () &&
805
807
module_sp->MatchesModuleSpec (kern_spec)) {
806
- // module_sp is an actual kernel binary we want to add.
807
- if (process) {
808
- const bool notify = false ;
809
- process->GetTarget ().GetImages ().AppendIfNeeded (module_sp, notify);
810
- error.Clear ();
811
- return error;
812
- } else {
813
- error = ModuleList::GetSharedModule (kern_spec, module_sp, nullptr ,
814
- nullptr , nullptr );
815
- if (module_sp && module_sp->GetObjectFile () &&
816
- module_sp->GetObjectFile ()->GetType () !=
817
- ObjectFile::Type::eTypeCoreFile) {
818
- return error;
819
- }
820
- module_sp.reset ();
821
- }
808
+ // The dSYM is next to the binary (that's the only
809
+ // way it ends up in the index), but it might be a
810
+ // .dSYM.yaa that needs to be expanded, don't just
811
+ // append ".dSYM" to the filename for the SymbolFile.
812
+ FileSpecList search_paths =
813
+ process->GetTarget ().GetDebugFileSearchPaths ();
814
+ FileSpec dsym_fspec =
815
+ Symbols::LocateExecutableSymbolFile (kern_spec, search_paths);
816
+ if (FileSystem::Instance ().Exists (dsym_fspec))
817
+ module_sp->SetSymbolFileFileSpec (dsym_fspec);
818
+ if (did_create_ptr)
819
+ *did_create_ptr = true ;
820
+ return {};
822
821
}
823
822
}
824
823
}
@@ -836,36 +835,18 @@ Status PlatformDarwinKernel::GetSharedModuleKernel(
836
835
module_sp.reset (new Module (kern_spec));
837
836
if (module_sp && module_sp->GetObjectFile () &&
838
837
module_sp->MatchesModuleSpec (kern_spec)) {
839
- // module_sp is an actual kernel binary we want to add.
840
- if (process) {
841
- const bool notify = false ;
842
- process->GetTarget ().GetImages ().AppendIfNeeded (module_sp, notify);
843
- error.Clear ();
844
- return error;
845
- } else {
846
- error = ModuleList::GetSharedModule (kern_spec, module_sp, nullptr ,
847
- nullptr , nullptr );
848
- if (module_sp && module_sp->GetObjectFile () &&
849
- module_sp->GetObjectFile ()->GetType () !=
850
- ObjectFile::Type::eTypeCoreFile) {
851
- return error;
852
- }
853
- module_sp.reset ();
854
- }
838
+ if (did_create_ptr)
839
+ *did_create_ptr = true ;
840
+ return {};
855
841
}
856
842
}
857
843
}
858
844
859
- // Give the generic methods, including possibly calling into DebugSymbols
845
+ // Give the generic methods, including possibly calling into DebugSymbols
860
846
// framework on macOS systems, a chance.
861
- error = PlatformDarwin::GetSharedModule (module_spec, process, module_sp,
862
- module_search_paths_ptr, old_modules,
863
- did_create_ptr);
864
- if (error.Success () && module_sp.get ()) {
865
- return error;
866
- }
867
-
868
- return error;
847
+ return PlatformDarwin::GetSharedModule (module_spec, process, module_sp,
848
+ module_search_paths_ptr, old_modules,
849
+ did_create_ptr);
869
850
}
870
851
871
852
std::vector<lldb_private::FileSpec>
0 commit comments