Author: Jonas Devlieghere Date: 2024-06-22T08:18:15-07:00 New Revision: c3fe1c4472e72a3832be911e8fa9098fa84762a0
URL: https://github.com/llvm/llvm-project/commit/c3fe1c4472e72a3832be911e8fa9098fa84762a0 DIFF: https://github.com/llvm/llvm-project/commit/c3fe1c4472e72a3832be911e8fa9098fa84762a0.diff LOG: [lldb] Resolve executables more aggressively on the host When unifying the ResolveExecutable implementations in #96256, I missed that RemoteAwarePlatform was able to resolve executables more aggressively. The host platform can rely on the current working directory to make relative paths absolute and resolve things like home directories. This should fix command-target-create-resolve-exe.test. Added: Modified: lldb/include/lldb/Target/RemoteAwarePlatform.h lldb/source/Target/RemoteAwarePlatform.cpp Removed: ################################################################################ diff --git a/lldb/include/lldb/Target/RemoteAwarePlatform.h b/lldb/include/lldb/Target/RemoteAwarePlatform.h index 6fbeec7888a98..fb2eecfaa23a8 100644 --- a/lldb/include/lldb/Target/RemoteAwarePlatform.h +++ b/lldb/include/lldb/Target/RemoteAwarePlatform.h @@ -20,6 +20,11 @@ class RemoteAwarePlatform : public Platform { public: using Platform::Platform; + virtual Status + ResolveExecutable(const ModuleSpec &module_spec, + lldb::ModuleSP &exe_module_sp, + const FileSpecList *module_search_paths_ptr) override; + bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch, ModuleSpec &module_spec) override; diff --git a/lldb/source/Target/RemoteAwarePlatform.cpp b/lldb/source/Target/RemoteAwarePlatform.cpp index 63243d6e71307..5fc2d63876b92 100644 --- a/lldb/source/Target/RemoteAwarePlatform.cpp +++ b/lldb/source/Target/RemoteAwarePlatform.cpp @@ -29,6 +29,29 @@ bool RemoteAwarePlatform::GetModuleSpec(const FileSpec &module_file_spec, return false; } +Status RemoteAwarePlatform::ResolveExecutable( + const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp, + const FileSpecList *module_search_paths_ptr) { + ModuleSpec resolved_module_spec(module_spec); + + // The host platform can resolve the path more aggressively. + if (IsHost()) { + FileSpec &resolved_file_spec = resolved_module_spec.GetFileSpec(); + + if (!FileSystem::Instance().Exists(resolved_file_spec)) { + resolved_module_spec.GetFileSpec().SetFile(resolved_file_spec.GetPath(), + FileSpec::Style::native); + FileSystem::Instance().Resolve(resolved_file_spec); + } + + if (!FileSystem::Instance().Exists(resolved_file_spec)) + FileSystem::Instance().ResolveExecutableLocation(resolved_file_spec); + } + + return Platform::ResolveExecutable(resolved_module_spec, exe_module_sp, + module_search_paths_ptr); +} + Status RemoteAwarePlatform::RunShellCommand( llvm::StringRef command, const FileSpec &working_dir, int *status_ptr, int *signo_ptr, std::string *command_output, _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits