[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
Fri Jan 11 14:01:15 PST 2019
Hui added a comment.
I think the key problem here is to make sure the argument will be treated as a single argument to the process launcher.
To be specific to this case only, could we just provide a quote char to argument log file path and log channels on Windows?
The downside is one more #if is introduced.
#ifdef _WIN32
char quote_char= '"';
#else
char quote_char='\0';
#endif
std::string env_debugserver_log_channels =
host_env.lookup("LLDB_SERVER_LOG_CHANNELS");
if (!env_debugserver_log_channels.empty()) {
debugserver_args.AppendArgument(
llvm::formatv("--log-channels={0}", env_debugserver_log_channels)
.str(), quote_char);
}
In D56230#1350986 <https://reviews.llvm.org/D56230#1350986>, @labath wrote:
> > It is not that applicable for the windows process launcher to determine which entry in the args needs to be quoted unless given very specific flag or option.
>
> Why not? Given the argv parsing rules described here https://docs.microsoft.com/en-us/cpp/cpp/parsing-cpp-command-line-arguments?view=vs-2017, it sounds like it should be possible to create an algorithm doing the reverse mapping.
> Something like this ought to do the trick:
>
> for(string: Args) {
> if (string.contains_either_of(" \t\"") {
> double_the_amount_of_backslashes_in_front_of_every_quote_char(string);
> string = '"' + string '"';
> }
> cmdline += " " + string;
> }
>
Repository:
rLLDB LLDB
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56230/new/
https://reviews.llvm.org/D56230
More information about the lldb-commits
mailing list