@@ -732,6 +732,7 @@ Status
732
732
Platform::ResolveExecutable (const ModuleSpec &module_spec,
733
733
lldb::ModuleSP &exe_module_sp,
734
734
const FileSpecList *module_search_paths_ptr) {
735
+ Status error;
735
736
736
737
// We may connect to a process and use the provided executable (Don't use
737
738
// local $PATH).
@@ -740,57 +741,55 @@ Platform::ResolveExecutable(const ModuleSpec &module_spec,
740
741
// Resolve any executable within a bundle on MacOSX
741
742
Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec ());
742
743
743
- if (!FileSystem::Instance ().Exists (resolved_module_spec.GetFileSpec ()) &&
744
- !module_spec.GetUUID ().IsValid ())
745
- return Status::createWithFormat (" '{0}' does not exist" ,
746
- resolved_module_spec.GetFileSpec ());
747
-
748
- if (resolved_module_spec.GetArchitecture ().IsValid () ||
749
- resolved_module_spec.GetUUID ().IsValid ()) {
750
- Status error =
751
- ModuleList::GetSharedModule (resolved_module_spec, exe_module_sp,
752
- module_search_paths_ptr, nullptr , nullptr );
744
+ if (FileSystem::Instance ().Exists (resolved_module_spec.GetFileSpec ()) ||
745
+ module_spec.GetUUID ().IsValid ()) {
746
+ if (resolved_module_spec.GetArchitecture ().IsValid () ||
747
+ resolved_module_spec.GetUUID ().IsValid ()) {
748
+ error = ModuleList::GetSharedModule (resolved_module_spec, exe_module_sp,
749
+ module_search_paths_ptr, nullptr ,
750
+ nullptr );
753
751
754
- if (exe_module_sp && exe_module_sp->GetObjectFile ())
755
- return error;
756
- exe_module_sp.reset ();
757
- }
758
- // No valid architecture was specified or the exact arch wasn't found.
759
- // Ask the platform for the architectures that we should be using (in the
760
- // correct order) and see if we can find a match that way.
761
- StreamString arch_names;
762
- llvm::ListSeparator LS;
763
- ArchSpec process_host_arch;
764
- Status error;
765
- for (const ArchSpec &arch : GetSupportedArchitectures (process_host_arch)) {
766
- resolved_module_spec.GetArchitecture () = arch;
767
- error =
768
- ModuleList::GetSharedModule (resolved_module_spec, exe_module_sp,
769
- module_search_paths_ptr, nullptr , nullptr );
770
- if (error.Success ()) {
771
752
if (exe_module_sp && exe_module_sp->GetObjectFile ())
772
- break ;
773
- error. SetErrorToGenericError ();
753
+ return error ;
754
+ exe_module_sp. reset ();
774
755
}
756
+ // No valid architecture was specified or the exact arch wasn't found.
757
+ // Ask the platform for the architectures that we should be using (in the
758
+ // correct order) and see if we can find a match that way.
759
+ StreamString arch_names;
760
+ llvm::ListSeparator LS;
761
+ ArchSpec process_host_arch;
762
+ for (const ArchSpec &arch : GetSupportedArchitectures (process_host_arch)) {
763
+ resolved_module_spec.GetArchitecture () = arch;
764
+ error = ModuleList::GetSharedModule (resolved_module_spec, exe_module_sp,
765
+ module_search_paths_ptr, nullptr ,
766
+ nullptr );
767
+ if (error.Success ()) {
768
+ if (exe_module_sp && exe_module_sp->GetObjectFile ())
769
+ break ;
770
+ error.SetErrorToGenericError ();
771
+ }
775
772
776
- arch_names << LS << arch.GetArchitectureName ();
777
- }
778
-
779
- if (exe_module_sp && error.Success ())
780
- return {};
781
-
782
- if (!FileSystem::Instance ().Readable (resolved_module_spec.GetFileSpec ()))
783
- return Status::createWithFormat (" '{0}' is not readable" ,
784
- resolved_module_spec.GetFileSpec ());
773
+ arch_names << LS << arch.GetArchitectureName ();
774
+ }
785
775
786
- if (!ObjectFile::IsObjectFile (resolved_module_spec.GetFileSpec ()))
787
- return Status::createWithFormat (" '{0}' is not a valid executable" ,
776
+ if (error.Fail () || !exe_module_sp) {
777
+ if (FileSystem::Instance ().Readable (resolved_module_spec.GetFileSpec ())) {
778
+ error.SetErrorStringWithFormatv (
779
+ " '{0}' doesn't contain any '{1}' platform architectures: {2}" ,
780
+ resolved_module_spec.GetFileSpec (), GetPluginName (),
781
+ arch_names.GetData ());
782
+ } else {
783
+ error.SetErrorStringWithFormatv (" '{0}' is not readable" ,
784
+ resolved_module_spec.GetFileSpec ());
785
+ }
786
+ }
787
+ } else {
788
+ error.SetErrorStringWithFormatv (" '{0}' does not exist" ,
788
789
resolved_module_spec.GetFileSpec ());
790
+ }
789
791
790
- return Status::createWithFormat (
791
- " '{0}' doesn't contain any '{1}' platform architectures: {2}" ,
792
- resolved_module_spec.GetFileSpec (), GetPluginName (),
793
- arch_names.GetData ());
792
+ return error;
794
793
}
795
794
796
795
Status Platform::ResolveSymbolFile (Target &target, const ModuleSpec &sym_spec,
0 commit comments