Re: [PATCH 3/4] [PR gdbserver/25893]: Use construct_inferior_arguments which handles special chars

Simon Marchi
2020-05-13T01:59:12Z

On 2020-05-12 1:37 p.m., Simon Marchi wrote:
> On 2020-05-12 12:07 p.m., Michael Weghorn via Gdb-patches wrote:
>>> If you are game, you could make another preparatory patch (anywhere in the series
>>> before this one) that would make construct_inferior_arguments take a
>>> gdb::array_view<char *> parameter. That would allow you to call it more simply
>>> here:
>>>
>>> construct_inferior_arguments (program_args);
>>
>>
>> I tried this, but as far as I understand (but I might have missed
>> something), this does not work here, since the gdb::array_view
>> constructor does not accept a const container (or reference to one) as a
>> parameter, so e.g.
>>
>> const std::vector<char *> vec;
>> gdb::array_view<char *> view(vec);
>>
>> does not work/compile, and program_args is a const reference here.
>> (Using a non-const vector does, but I'd personally rather not remove the
>> const qualifier for the 'program_args' parameter of the
>> 'create_inferior' method.)
>>
>> Michael
>
> Hmm yeah not sure about that. We can deal with this after.
>
> Simon
>

I gave this a try, it works to declare the parameter as

gdb::array_view<char * const> argv

Simon