aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectTarget.cpp
diff options
context:
space:
mode:
authorAlvin Wong <alvin@alvinhc.com>2022-06-22 16:13:57 +0300
committerMartin Storsjö <martin@martin.st>2022-06-22 17:16:05 +0300
commit2bae9560575362ffd756f193efa1de2d5c2f4cfd (patch)
tree75e3602a24ec94a38ced975981edbbe870a8f00c /lldb/source/Commands/CommandObjectTarget.cpp
parent8a64dd5b06146f073a4a326f0e24fa18e571b281 (diff)
downloadllvm-2bae9560575362ffd756f193efa1de2d5c2f4cfd.zip
llvm-2bae9560575362ffd756f193efa1de2d5c2f4cfd.tar.gz
llvm-2bae9560575362ffd756f193efa1de2d5c2f4cfd.tar.bz2
[lldb] Resolve exe location for `target create`
This fixes an issue that, when you start lldb or use `target create` with a program name which is on $PATH, or not specify the .exe suffix of a program in the working directory on Windows, you get a confusing error, for example: (lldb) target create notepad error: 'C:\WINDOWS\SYSTEM32\notepad.exe' doesn't contain any 'host' platform architectures: i686, x86_64, i386, i386 Fixes https://github.com/mstorsjo/llvm-mingw/issues/265 Reviewed By: DavidSpickett Differential Revision: https://reviews.llvm.org/D127436
Diffstat (limited to 'lldb/source/Commands/CommandObjectTarget.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 7789698..23ebbdb 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -299,12 +299,6 @@ protected:
const char *file_path = command.GetArgumentAtIndex(0);
LLDB_SCOPED_TIMERF("(lldb) target create '%s'", file_path);
- FileSpec file_spec;
-
- if (file_path) {
- file_spec.SetFile(file_path, FileSpec::Style::native);
- FileSystem::Instance().Resolve(file_spec);
- }
bool must_set_platform_path = false;
@@ -333,6 +327,18 @@ protected:
PlatformSP platform_sp = target_sp->GetPlatform();
+ FileSpec file_spec;
+ if (file_path) {
+ file_spec.SetFile(file_path, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(file_spec);
+
+ // Try to resolve the exe based on PATH and/or platform-specific
+ // suffixes, but only if using the host platform.
+ if (platform_sp && platform_sp->IsHost() &&
+ !FileSystem::Instance().Exists(file_spec))
+ FileSystem::Instance().ResolveExecutableLocation(file_spec);
+ }
+
if (remote_file) {
if (platform_sp) {
// I have a remote file.. two possible cases