aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2024-06-21 15:00:40 -0700
committerJonas Devlieghere <jonas@devlieghere.com>2024-06-22 08:18:15 -0700
commitc3fe1c4472e72a3832be911e8fa9098fa84762a0 (patch)
tree23e7a01a38ebc38ea5b84907638470ea527502d2
parent34d44eb41dfbbbf01712719558b02763334fbeb3 (diff)
downloadllvm-c3fe1c4472e72a3832be911e8fa9098fa84762a0.zip
llvm-c3fe1c4472e72a3832be911e8fa9098fa84762a0.tar.gz
llvm-c3fe1c4472e72a3832be911e8fa9098fa84762a0.tar.bz2
[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.
-rw-r--r--lldb/include/lldb/Target/RemoteAwarePlatform.h5
-rw-r--r--lldb/source/Target/RemoteAwarePlatform.cpp23
2 files changed, 28 insertions, 0 deletions
diff --git a/lldb/include/lldb/Target/RemoteAwarePlatform.h b/lldb/include/lldb/Target/RemoteAwarePlatform.h
index 6fbeec7..fb2eecf 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 63243d6..5fc2d63 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,