[Lldb-commits] [PATCH] D56230: [gdb-remote] Use lldb's portable Host::GetEnvironment() instead of getenv
Hui Huang via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Jan 15 10:16:32 PST 2019
Hui added a comment.
In D56230#1355248 <https://reviews.llvm.org/D56230#1355248>, @labath wrote:
> In D56230#1355247 <https://reviews.llvm.org/D56230#1355247>, @labath wrote:
>
> > For example, for a `Args` vector like `lldb-server`, `gdb-remote`, `--log-channels=foo\\\ \\\""" '''`, `whatever`, `QuoteForCreateProcess` would return
> > `lldb-server gdb-remote "--log-channels=foo\\\ \\\\\\\"\"\" '''" whatever` (there are other ways to quote this too). Passing this string to CreateProcess will result in the original vector being available to the `main` function of lldb-server, which is what this code (and all other code that works with the `Args` class) expects.
>
>
> Btw, there is already code for doing this in llvm (`llvm::sys::flattenWindowsCommandLine`), so we can just steal the implementation from there.
What do you think of the following codes to be added in Args?
bool Args::GetFlattenQuotedCommandString(std::string &command) const {
std::vector<llvm::StringRef> args_ref;
std::vector<std::string> owner;
for (size_t i = 0; i < m_entries.size(); ++i) {
if (m_entries[i].quote) {
std::string arg;
arg += m_entries[i].quote;
arg += m_entries[i].ref;
arg += m_entries[i].quote;
owner.push_back(arg);
args_ref.push_back(owner.back());
} else {
args_ref.push_back(m_entries[i].ref);
}
}
command = llvm::sys::flattenWindowsCommandLine(args_ref);
return !m_entries.empty();
}
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56230/new/
https://reviews.llvm.org/D56230
More information about the lldb-commits
mailing list