@@ -732,7 +732,6 @@ Status
732732Platform::ResolveExecutable (const ModuleSpec &module_spec,
733733 lldb::ModuleSP &exe_module_sp,
734734 const FileSpecList *module_search_paths_ptr) {
735- Status error;
736735
737736 // We may connect to a process and use the provided executable (Don't use
738737 // local $PATH).
@@ -741,55 +740,57 @@ Platform::ResolveExecutable(const ModuleSpec &module_spec,
741740 // Resolve any executable within a bundle on MacOSX
742741 Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec ());
743742
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 );
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 );
751753
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 ()) {
752771 if (exe_module_sp && exe_module_sp->GetObjectFile ())
753- return error ;
754- exe_module_sp. reset ();
772+ break ;
773+ error. SetErrorToGenericError ();
755774 }
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- }
772775
773- arch_names << LS << arch.GetArchitectureName ();
774- }
776+ arch_names << LS << arch.GetArchitectureName ();
777+ }
775778
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" ,
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" ,
789784 resolved_module_spec.GetFileSpec ());
790- }
791785
792- return error;
786+ if (!ObjectFile::IsObjectFile (resolved_module_spec.GetFileSpec ()))
787+ return Status::createWithFormat (" '{0}' is not a valid executable" ,
788+ resolved_module_spec.GetFileSpec ());
789+
790+ return Status::createWithFormat (
791+ " '{0}' doesn't contain any '{1}' platform architectures: {2}" ,
792+ resolved_module_spec.GetFileSpec (), GetPluginName (),
793+ arch_names.GetData ());
793794}
794795
795796Status Platform::ResolveSymbolFile (Target &target, const ModuleSpec &sym_spec,
0 commit comments