alvinhochun created this revision. alvinhochun added reviewers: JDevlieghere, labath, mstorsjo. Herald added subscribers: jsji, pengfei. Herald added a project: All. alvinhochun requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
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 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D127436 Files: lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Target/TargetList.cpp Index: lldb/source/Target/TargetList.cpp =================================================================== --- lldb/source/Target/TargetList.cpp +++ lldb/source/Target/TargetList.cpp @@ -121,6 +121,14 @@ if (!user_exe_path.empty()) { ModuleSpec module_spec(FileSpec(user_exe_path, FileSpec::Style::native)); FileSystem::Instance().Resolve(module_spec.GetFileSpec()); + + // Try to resolve the exe based on PATH and/or platform-specific suffixes, + // but only if using the host platform. + if (platform_sp->IsHost() && + !FileSystem::Instance().Exists(module_spec.GetFileSpec())) + FileSystem::Instance().ResolveExecutableLocation( + module_spec.GetFileSpec()); + // Resolve the executable in case we are given a path to a application // bundle like a .app bundle on MacOSX. Host::ResolveExecutableInBundle(module_spec.GetFileSpec()); Index: lldb/source/Commands/CommandObjectTarget.cpp =================================================================== --- lldb/source/Commands/CommandObjectTarget.cpp +++ lldb/source/Commands/CommandObjectTarget.cpp @@ -299,12 +299,6 @@ 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 @@ 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
Index: lldb/source/Target/TargetList.cpp =================================================================== --- lldb/source/Target/TargetList.cpp +++ lldb/source/Target/TargetList.cpp @@ -121,6 +121,14 @@ if (!user_exe_path.empty()) { ModuleSpec module_spec(FileSpec(user_exe_path, FileSpec::Style::native)); FileSystem::Instance().Resolve(module_spec.GetFileSpec()); + + // Try to resolve the exe based on PATH and/or platform-specific suffixes, + // but only if using the host platform. + if (platform_sp->IsHost() && + !FileSystem::Instance().Exists(module_spec.GetFileSpec())) + FileSystem::Instance().ResolveExecutableLocation( + module_spec.GetFileSpec()); + // Resolve the executable in case we are given a path to a application // bundle like a .app bundle on MacOSX. Host::ResolveExecutableInBundle(module_spec.GetFileSpec()); Index: lldb/source/Commands/CommandObjectTarget.cpp =================================================================== --- lldb/source/Commands/CommandObjectTarget.cpp +++ lldb/source/Commands/CommandObjectTarget.cpp @@ -299,12 +299,6 @@ 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 @@ 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
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits