Re: [PATCH v4] Make '{add-,}symbol-file' not care about the position of command line arguments

Pedro Alves
2017-12-01T12:11:38Z

On 11/30/2017 07:59 PM, Sergio Durigan Junior wrote:
> Changes from v3:
>
> - 'add-symbol-file -s' now accepts sections whose names start with a
> dash.
>
> - Use a better way to test must-ask questions on the testsuite.
>
>
> This is a bug that's been detected while doing the readnever work.
>
> If you use 'symbol-file' or 'add-symbol-file', the position of each
> argument passed to the command matters. This means that if you do:
>
> (gdb) symbol-file -readnow /foo/bar
>
> The symbol file specified will (correctly) have all of its symbols
> read by GDB (because of the -readnow flag). However, if you do:
>
> (gdb) symbol-file /foo/bar -readnow
>
> GDB will silently ignore the -readnow flag, because it was specified
> after the filename. This is not a good thing to do and may confuse
> the user.
>
> To address that, I've modified the argument parsing mechanisms of
> symbol_file_command and add_symbol_file_command to be
> "position-independent". I have also added one error call at the end
> of add_symbol_file_command's argument parsing logic, which now clearly
> complains if no filename has been specified. Both commands now
> support the "--" option to stop argument processing.
>
> This patch provides a testcase for both commands, in order to make
> sure that the argument order does not matter. It has been
> regression-tested on BuildBot.
>
> gdb/ChangeLog:
>
> 2017-11-30 Sergio Durigan Junior <sergiodj@redhat.com>
>
> * symfile.c (symbol_file_command): Call
> 'symbol_file_add_main_1' only after processing all command
> line options.
> (add_symbol_file_command): Modify logic to make arguments
> position-independent.
>
> gdb/testsuite/ChangeLog:
>
> 2017-11-30 Sergio Durigan Junior <sergiodj@redhat.com>
>
> * gdb.base/relocate.exp: Add tests to guarantee that arguments
> to 'symbol-file' and 'add-symbol-file' can be
> position-independent.

OK.

Thanks,
Pedro Alves