diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 2fc6dbb546f79..a8915c9b9386c 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -871,8 +871,19 @@ Status ProcessGDBRemote::DoLaunch(lldb_private::Module *exe_module, // Since we can't send argv0 separate from the executable path, we need to // make sure to use the actual executable path found in the launch_info... Args args = launch_info.GetArguments(); - if (FileSpec exe_file = launch_info.GetExecutableFile()) - args.ReplaceArgumentAtIndex(0, exe_file.GetPath(/*denormalize=*/true)); + if (FileSpec exe_file = launch_info.GetExecutableFile()) { + const llvm::Triple &remote_triple = + GetTarget().GetArchitecture().GetTriple(); + if (remote_triple.getOS() != llvm::Triple::UnknownOS) { + FileSpec remote_exe_file(exe_file.GetPath(/*denormalize=*/false), + remote_triple); + args.ReplaceArgumentAtIndex( + 0, remote_exe_file.GetPath(/*denormalize=*/true)); + } else { + args.ReplaceArgumentAtIndex(0, + exe_file.GetPath(/*denormalize=*/true)); + } + } if (llvm::Error err = m_gdb_comm.LaunchProcess(args)) { error = Status::FromErrorStringWithFormatv( "Cannot launch '{0}': {1}", args.GetArgumentAtIndex(0),