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

Ted Woodward via lldb-dev lldb-dev at lists.llvm.org
Thu Feb 18 16:16:28 PST 2016


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

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20160218/2b136e9f/attachment.html>


More information about the lldb-dev mailing list