[lldb-dev] problem with quoted strings in setting target.run-args

Pavel Labath via lldb-dev lldb-dev at lists.llvm.org
Fri Feb 19 05:39:08 PST 2016


Hi Ted,

I did some improvements in this area a year ago, which (I hope) made
things better, but they are still not perfect (hint: try running:
settings set target.run-args '"') [that's
<single-quote><double-quote><single-quote>]. I tried to finish the
job, but it ended up being too complicated, for the reasons you
mention above...

I think the current method of "quoting" in
OptionValueString::SetValueFromString is wrong and I would welcome
anything that changes that. Also, if you can decrease the number of
times we need to quote and unquote stuff while passing the arguments
internally around, I would be super happy. :)

(I'm not sure if this helps you. I don't really have a good suggestion
on how to do what you want, but I wanted to encourage the idea.)

pl

On 19 February 2016 at 00:16, Ted Woodward via lldb-dev
<lldb-dev at lists.llvm.org> wrote:
> Quoted strings in target.run-args aren’t handled correctly.
>
>
>
> (lldb) settings set target.run-args "foo bar"
>
> (lldb) settings show target.run-args
>
> target.run-args (array of strings) =
>
>   [0]: "foo bar"
>
>
>
> This looks correct, but the Args in the ProcessLaunchInfo passed to the
> Platform doesn’t have m_args_quote_char set, so if the Args is later pulled
> out with GetQuotedCommandString() it won’t get “foo bar”, but will instead
> get foo and bar unquoted. This is masked when talking to debugserver or
> lldb_server because run-args are sent to the server using an RSP packet, but
> on systems like Windows or the Hexagon Simulator, where run-args are on the
> command line, you get 2 args, foo and bar, instead of 1 arg “foo bar”.
>
>
>
> The first problem is in OptionValueArray::SetArgs(), in the
> eVarSetOperationAppend case. It calls Args::GetArgumentAtIndex(), which
> doesn’t return a quoted argument. I added a function
> GetQuotedArgumentAtIndex() and called that, which revealed the second
> problem. The string is passed into
> OptionValue::CreateValueFromCStringForTypeMask(), which calls
> OptionValueString::SetValueFromString(). In that function it explicitly
> strips quotes. Changing it to not strip quotes leads to the third problem –
> when TargetProperties::RunArgsValueChangedCallback() pulls the data from the
> OptionValueArray to make a new Args, it calls OptionValueArray::GetArgs(),
> which doesn’t handle quoting like the Args ctor does.
>
>
>
> I think changing the OptionValue classes to handle quoting could lead to
> problems with other use cases. So that leaves me with the option of going
> through the Args before launch and adding quotes around anything with
> spaces, which seems hackish. Any thoughts on how to solve this issue?
>
>
>
> --
>
> Qualcomm Innovation Center, Inc.
>
> The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
> Linux Foundation Collaborative Project
>
>
>
>
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
>


More information about the lldb-dev mailing list