diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp --- a/lldb/source/Host/linux/Host.cpp +++ b/lldb/source/Host/linux/Host.cpp @@ -156,6 +156,8 @@ while (!Rest.empty()) { llvm::StringRef Arg; std::tie(Arg, Rest) = Rest.split('\0'); + if (Arg.empty()) + continue; process_info.GetArguments().AppendArgument(Arg); } } diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -1199,10 +1199,9 @@ if (!value.getAsInteger(0, pointer_byte_size)) ++num_keys_decoded; } else if (name.equals("os_version") || - name.equals( - "version")) // Older debugserver binaries used the - // "version" key instead of - // "os_version"... + name.equals("version")) // Older debugserver binaries used + // the "version" key instead of + // "os_version"... { if (!m_os_version.tryParse(value)) ++num_keys_decoded; @@ -1927,6 +1926,28 @@ std::string name; extractor.GetHexByteString(name); process_info.GetExecutableFile().SetFile(name, FileSpec::Style::native); + } else if (name.equals("args")) { + StringExtractor extractor(value); + std::stringstream stream(value); + + auto extractOneArg = [&](std::string &arg) { + std::string hex_arg; + if (!getline(stream, hex_arg, '-')) + return false; + extractor = StringExtractor(hex_arg); + extractor.GetHexByteString(arg); + return true; + }; + + std::string arg; + if (!extractOneArg(arg)) + continue; + process_info.SetArg0(arg); + process_info.GetArguments().AppendArgument(arg); + + while (extractOneArg(arg)) { + process_info.GetArguments().AppendArgument(arg); + } } else if (name.equals("cputype")) { value.getAsInteger(0, cpu); } else if (name.equals("cpusubtype")) { @@ -2067,7 +2088,7 @@ !vendor_name.empty()) { llvm::Triple triple(llvm::Twine("-") + vendor_name + "-" + os_name); if (!environment.empty()) - triple.setEnvironmentName(environment); + triple.setEnvironmentName(environment); assert(triple.getObjectFormat() != llvm::Triple::UnknownObjectFormat); assert(triple.getObjectFormat() != llvm::Triple::Wasm); @@ -2580,7 +2601,7 @@ * The reply from '?' packet could be as simple as 'S05'. There is no packet * which can * give us pid and/or tid. Assume pid=tid=1 in such cases. - */ + */ if (response.IsUnsupportedResponse() && IsConnected()) { m_curr_tid = 1; return true; @@ -2753,7 +2774,7 @@ * be as simple as 'S05'. There is no packet which can give us pid and/or * tid. * Assume pid=tid=1 in such cases. - */ + */ if ((response.IsUnsupportedResponse() || response.IsNormalResponse()) && thread_ids.size() == 0 && IsConnected()) { thread_ids.push_back(1); diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -1176,6 +1176,18 @@ response.PutCString("name:"); response.PutStringAsRawHex8(proc_info.GetExecutableFile().GetCString()); response.PutChar(';'); + response.PutCString("args:"); + response.PutStringAsRawHex8(proc_info.GetArg0()); + // for (auto it = proc_info.GetArguments().begin(); it != + // proc_info.GetArguments().end(); ++it) { + // response.PutChar('-'); + // response.PutStringAsRawHex8(it->c_str()); + // + for (auto &arg : proc_info.GetArguments()) { + response.PutChar('-'); + response.PutStringAsRawHex8(arg.c_str()); + } + response.PutChar(';'); const ArchSpec &proc_arch = proc_info.GetArchitecture(); if (proc_arch.IsValid()) { const llvm::Triple &proc_triple = proc_arch.GetTriple(); diff --git a/lldb/source/Utility/ProcessInfo.cpp b/lldb/source/Utility/ProcessInfo.cpp --- a/lldb/source/Utility/ProcessInfo.cpp +++ b/lldb/source/Utility/ProcessInfo.cpp @@ -39,6 +39,8 @@ } const char *ProcessInfo::GetName() const { + if (m_executable.GetFilename().IsEmpty()) + return GetArguments().GetArgumentAtIndex(0); return m_executable.GetFilename().GetCString(); }