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

Sergio Durigan Junior
2017-11-30T17:43:19Z

On Thursday, November 30 2017, Pedro Alves wrote:

> On 11/30/2017 05:26 PM, Sergio Durigan Junior wrote:
>
>>> (Another thing that I noticed but I'm kind of ignoring is the fact
>>> that gdb_test treats the question as optional gdb output, so
>>> pedantically gdb could stop outputting the question and answer
>>> "n" automatically and the testcase wouldn't notice.)
>>
>> Would you prefer if I made the tests answer "y" instead? Or maybe I'm
>> misunderstanding your concern.
>>
>
> Take a look at how gdb_test implements the question/response. The
> question argument is a question that GDB _may_ ask, not one that
> GDB _must_ ask.
>
> So pedantically if add-symbol-file's query ever becomes broken in a way
> that makes GDB simply automatically assume "n" without GDB printing
> the question in the first place, like:
>
> (gdb) add-symbol-file -s .text 0x200 $binfile 0x100
> Not confirmed.
> (gdb)
>
> then this:
>
> gdb_test "add-symbol-file -s .text 0x200 $binfile 0x100" \
> "Not confirmed\." \
> "add-symbol-file different -s .text, before file" \
> "add symbol table from file \"${binfile}\" at\r\n\t\.text_addr = x100\r\n\t\.text_addr = 0x200\r\n\\(y or n\\) " \
> "n"
>
> won't notice it, it'll still PASS.
>
> The usual way to test must-ask questions is to use
> one gdb_test_multiple up to the question, and another gdb_test for
> answering the question. Something like (untested):
>
> set test "add-symbol-file different -s .text, before file"
> gdb_test_multiple "add-symbol-file -s .text 0x200 $binfile 0x100" $test {
> -re "add symbol table from file \"${binfile}\" at\r\n\t\.text_addr = x100\r\n\t\.text_addr = 0x200\r\n\\(y or n\\) " {
> gdb_test "n" "Not confirmed\." $test
> }
> }

OK, I see what you mean. You obviously know that I copied the same
pattern present at gdb.base/relocate.exp (and many other tests, which
makes me frown a bit when I read "The usual way to test must-ask...").

I'll rewrite my tests to use the suggested way, then.

Thanks,

--
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible