Re: [PATCH 4/4] [PR gdbserver/25893]: Add gdbserver test for argument with space in it

Michael Weghorn
2020-05-11T14:33:43Z

On 10/05/2020 18.09, Simon Marchi wrote:
> On 2020-05-07 6:15 p.m., Simon Marchi wrote:
>> It would be nice to write a test in such a way that it can cover this use case
>> when using GDB (without GDBserver) too.
>>
>> It's possible to run the same test using plain GDB with:
>>
>> make check TESTS="gdb.base/foo.exp"
>>
>> or
>>
>> make check TESTS="gdb.base/foo.exp" RUNTESTFLAGS="--target_board=unix"
>>
>> unix is the default DejaGNU (runtest) board, so these two are equivalent.
>>
>> It's also possible to run a test using gdbserver as a target:
>>
>> make check TESTS="gdb.base/foo.exp" RUNTESTFLAGS="--target_board=native-gdbserver"
>> make check TESTS="gdb.base/foo.exp" RUNTESTFLAGS="--target_board=native-extended-gdbserver"
>>
>> So it should be possible to write a test that runs a process with arguments
>> containing spaces. However, it's not currently possible with the testsuite
>> to pass arguments to a test program using the native-gdbserver board. These
>> arguments would have to be forwarded all the way to gdbserver's command line,
>> exactly like when you start gdbserver by hand. This will require a bit of
>> testsuite refactoring, I'll try to look into it.
>>
>> With native-extended-gdbserver, the args could be passed to the `run` command,
>> just like the native debugging case. It's by playing with this that I noticed
>> gdbserver crashing with this patchset applied when trying to remotely run a
>> process with arguments.
>>
>> Simon
>
> Hi Michael,
>

Hi Simon,

> Can you please check the patches I proposed for such a test?
>
> https://sourceware.org/pipermail/gdb-patches/2020-May/168262.html
> https://sourceware.org/pipermail/gdb-patches/2020-May/168263.html
>
> Your fix should make this work:
>
> make check TESTS="gdb.base/inferior-args.exp" RUNTESTFLAGS="--target_board=native-gdbserver"

Indeed, this works fine. Thanks a lot for extending the test suite.

>
> But these two should work as well:
>
> make check TESTS="gdb.base/inferior-args.exp" RUNTESTFLAGS="--target_board=unix"
> make check TESTS="gdb.base/inferior-args.exp" RUNTESTFLAGS="--target_board=native-extended-gdbserver"

These don't work yet with the last patch series. I'll recheck once I
have finished updating the patch series and in particular fixed the
segfault you mentioned earlier.

I hope to be able to send an updated patch series tomorrow.

Do I understand correctly that I can just drop my patch adding the test,
since this is now already covered in a better way by the test case added
in your second patch?

Michael