Skip to content

Commit c3fe1c4

Browse files
committed
[lldb] Resolve executables more aggressively on the host
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.
1 parent 34d44eb commit c3fe1c4

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lldb/include/lldb/Target/RemoteAwarePlatform.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ class RemoteAwarePlatform : public Platform {
2020
public:
2121
using Platform::Platform;
2222

23+
virtual Status
24+
ResolveExecutable(const ModuleSpec &module_spec,
25+
lldb::ModuleSP &exe_module_sp,
26+
const FileSpecList *module_search_paths_ptr) override;
27+
2328
bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch,
2429
ModuleSpec &module_spec) override;
2530

lldb/source/Target/RemoteAwarePlatform.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,29 @@ bool RemoteAwarePlatform::GetModuleSpec(const FileSpec &module_file_spec,
2929
return false;
3030
}
3131

32+
Status RemoteAwarePlatform::ResolveExecutable(
33+
const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp,
34+
const FileSpecList *module_search_paths_ptr) {
35+
ModuleSpec resolved_module_spec(module_spec);
36+
37+
// The host platform can resolve the path more aggressively.
38+
if (IsHost()) {
39+
FileSpec &resolved_file_spec = resolved_module_spec.GetFileSpec();
40+
41+
if (!FileSystem::Instance().Exists(resolved_file_spec)) {
42+
resolved_module_spec.GetFileSpec().SetFile(resolved_file_spec.GetPath(),
43+
FileSpec::Style::native);
44+
FileSystem::Instance().Resolve(resolved_file_spec);
45+
}
46+
47+
if (!FileSystem::Instance().Exists(resolved_file_spec))
48+
FileSystem::Instance().ResolveExecutableLocation(resolved_file_spec);
49+
}
50+
51+
return Platform::ResolveExecutable(resolved_module_spec, exe_module_sp,
52+
module_search_paths_ptr);
53+
}
54+
3255
Status RemoteAwarePlatform::RunShellCommand(
3356
llvm::StringRef command, const FileSpec &working_dir, int *status_ptr,
3457
int *signo_ptr, std::string *command_output,

0 commit comments

Comments
 (0)