Skip to content

Commit

Permalink
[lldb] Resolve executables more aggressively on the host
Browse files Browse the repository at this point in the history
When unifying the ResolveExecutable implementations in llvm#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.
  • Loading branch information
JDevlieghere authored and AlexisPerry committed Jun 27, 2024
1 parent 8e7271d commit 416295c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lldb/include/lldb/Target/RemoteAwarePlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
23 changes: 23 additions & 0 deletions lldb/source/Target/RemoteAwarePlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 416295c

Please sign in to comment.