gdb/testsuite: update a pattern in gdb_file_cmd

Message ID OS3P286MB21529F9399D6081C4069F313F01A9@OS3P286MB2152.JPNP286.PROD.OUTLOOK.COM
State Committed
Commit c968f038619c319775d41b228c037e4c05ef97a3
Headers
Series gdb/testsuite: update a pattern in gdb_file_cmd |

Commit Message

Enze Li Dec. 7, 2022, 1:06 p.m. UTC
  When building GDB with the following CFLAGS and CXXFLAGS as part of
configure line:

    CFLAGS=-std=gnu11 CXXFLAGS=-std=gnu++11

Then run the selftest.exp, I see:

======
Running /home/lee/dev/binutils-gdb/gdb/testsuite/gdb.gdb/selftest.exp
...
FAIL: gdb.gdb/selftest.exp: run until breakpoint at captured_main
WARNING: Couldn't test self

                === gdb Summary ===

 # of unexpected failures        1
/home/lee/dev/binutils-gdb/gdb/gdb version  13.0.50.20221206-git -nw -nx
-iex "set height 0" -iex "set width 0" -data-directory
/home/lee/dev/binutils-gdb/gdb/testsuite/../data-directory
======

It is the fact that when I use the previously mentioned CFLAGS and
CXXFLAGS as part of the configuration line, the default value (-O2 -g)
is overridden, then GDB has no debug information.  When there's no debug
information, GDB should not run the testcase in selftest.exp.

The root cause of this FAIL is that the $gdb_file_cmd_debug_info didn't
get the right value ("nodebug") during the gdb_file_cmd procedure.

That's because in this commit,

  commit 3453e7e409f44a79ac6695589836edb8a49bfb08
  Date:   Sat May 19 11:25:20 2018 -0600

    Clean up "Reading symbols" output

It changed "no debugging..." to "No debugging..." which causes the above
problem.  This patch only updates the corresponding pattern to fix this
issue.

With this patch applied, I see:

======
Running /home/lee/dev/binutils-gdb/gdb/testsuite/gdb.gdb/selftest.exp
...

                === gdb Summary ===

 # of untested testcases         1
/home/lee/dev/binutils-gdb/gdb/gdb version  13.0.50.20221206-git -nw -nx
-iex "set height 0" -iex "set width 0" -data-directory
/home/lee/dev/binutils-gdb/gdb/testsuite/../data-directory
======

Tested on x86_64-linux.
---
 gdb/testsuite/lib/gdb.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


base-commit: 83f18e5ebe627163f744215d3760a8eaacee6ec1
  

Comments

Simon Marchi Dec. 7, 2022, 3:01 p.m. UTC | #1
On 12/7/22 08:06, Enze Li via Gdb-patches wrote:
> When building GDB with the following CFLAGS and CXXFLAGS as part of
> configure line:
> 
>     CFLAGS=-std=gnu11 CXXFLAGS=-std=gnu++11
> 
> Then run the selftest.exp, I see:
> 
> ======
> Running /home/lee/dev/binutils-gdb/gdb/testsuite/gdb.gdb/selftest.exp
> ...
> FAIL: gdb.gdb/selftest.exp: run until breakpoint at captured_main
> WARNING: Couldn't test self
> 
>                 === gdb Summary ===
> 
>  # of unexpected failures        1
> /home/lee/dev/binutils-gdb/gdb/gdb version  13.0.50.20221206-git -nw -nx
> -iex "set height 0" -iex "set width 0" -data-directory
> /home/lee/dev/binutils-gdb/gdb/testsuite/../data-directory
> ======
> 
> It is the fact that when I use the previously mentioned CFLAGS and
> CXXFLAGS as part of the configuration line, the default value (-O2 -g)
> is overridden, then GDB has no debug information.  When there's no debug
> information, GDB should not run the testcase in selftest.exp.
> 
> The root cause of this FAIL is that the $gdb_file_cmd_debug_info didn't
> get the right value ("nodebug") during the gdb_file_cmd procedure.
> 
> That's because in this commit,
> 
>   commit 3453e7e409f44a79ac6695589836edb8a49bfb08
>   Date:   Sat May 19 11:25:20 2018 -0600
> 
>     Clean up "Reading symbols" output
> 
> It changed "no debugging..." to "No debugging..." which causes the above
> problem.  This patch only updates the corresponding pattern to fix this
> issue.
> 
> With this patch applied, I see:
> 
> ======
> Running /home/lee/dev/binutils-gdb/gdb/testsuite/gdb.gdb/selftest.exp
> ...
> 
>                 === gdb Summary ===
> 
>  # of untested testcases         1
> /home/lee/dev/binutils-gdb/gdb/gdb version  13.0.50.20221206-git -nw -nx
> -iex "set height 0" -iex "set width 0" -data-directory
> /home/lee/dev/binutils-gdb/gdb/testsuite/../data-directory
> ======
> 
> Tested on x86_64-linux.
> ---
>  gdb/testsuite/lib/gdb.exp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index e4ce3c30c2ff..008f59b9f30b 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -2139,7 +2139,7 @@ proc gdb_file_cmd { arg } {
>  	    set gdb_file_cmd_debug_info "lzma"
>  	    return 0
>  	}
> -	-re "(Reading symbols from.*no debugging symbols found.*$gdb_prompt $)" {
> +	-re "(Reading symbols from.*No debugging symbols found.*$gdb_prompt $)" {
>  	    verbose "\t\tLoaded $arg into $GDB with no debugging symbols"
>  	    set gdb_file_cmd_msg $expect_out(1,string)
>  	    set gdb_file_cmd_debug_info "nodebug"
> 
> base-commit: 83f18e5ebe627163f744215d3760a8eaacee6ec1

Thanks for the good explanation, I didn't know about all these things.
LGTM:

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon
  
Tom de Vries Dec. 8, 2022, 2:36 p.m. UTC | #2
On 12/7/22 16:01, Simon Marchi via Gdb-patches wrote:
> On 12/7/22 08:06, Enze Li via Gdb-patches wrote:
>> When building GDB with the following CFLAGS and CXXFLAGS as part of
>> configure line:
>>
>>      CFLAGS=-std=gnu11 CXXFLAGS=-std=gnu++11
>>
>> Then run the selftest.exp, I see:
>>
>> ======
>> Running /home/lee/dev/binutils-gdb/gdb/testsuite/gdb.gdb/selftest.exp
>> ...
>> FAIL: gdb.gdb/selftest.exp: run until breakpoint at captured_main
>> WARNING: Couldn't test self
>>
>>                  === gdb Summary ===
>>
>>   # of unexpected failures        1
>> /home/lee/dev/binutils-gdb/gdb/gdb version  13.0.50.20221206-git -nw -nx
>> -iex "set height 0" -iex "set width 0" -data-directory
>> /home/lee/dev/binutils-gdb/gdb/testsuite/../data-directory
>> ======
>>
>> It is the fact that when I use the previously mentioned CFLAGS and
>> CXXFLAGS as part of the configuration line, the default value (-O2 -g)
>> is overridden, then GDB has no debug information.  When there's no debug
>> information, GDB should not run the testcase in selftest.exp.
>>
>> The root cause of this FAIL is that the $gdb_file_cmd_debug_info didn't
>> get the right value ("nodebug") during the gdb_file_cmd procedure.
>>
>> That's because in this commit,
>>
>>    commit 3453e7e409f44a79ac6695589836edb8a49bfb08
>>    Date:   Sat May 19 11:25:20 2018 -0600
>>
>>      Clean up "Reading symbols" output
>>
>> It changed "no debugging..." to "No debugging..." which causes the above
>> problem.  This patch only updates the corresponding pattern to fix this
>> issue.
>>
>> With this patch applied, I see:
>>
>> ======
>> Running /home/lee/dev/binutils-gdb/gdb/testsuite/gdb.gdb/selftest.exp
>> ...
>>
>>                  === gdb Summary ===
>>
>>   # of untested testcases         1
>> /home/lee/dev/binutils-gdb/gdb/gdb version  13.0.50.20221206-git -nw -nx
>> -iex "set height 0" -iex "set width 0" -data-directory
>> /home/lee/dev/binutils-gdb/gdb/testsuite/../data-directory
>> ======
>>
>> Tested on x86_64-linux.
>> ---
>>   gdb/testsuite/lib/gdb.exp | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
>> index e4ce3c30c2ff..008f59b9f30b 100644
>> --- a/gdb/testsuite/lib/gdb.exp
>> +++ b/gdb/testsuite/lib/gdb.exp
>> @@ -2139,7 +2139,7 @@ proc gdb_file_cmd { arg } {
>>   	    set gdb_file_cmd_debug_info "lzma"
>>   	    return 0
>>   	}
>> -	-re "(Reading symbols from.*no debugging symbols found.*$gdb_prompt $)" {
>> +	-re "(Reading symbols from.*No debugging symbols found.*$gdb_prompt $)" {
>>   	    verbose "\t\tLoaded $arg into $GDB with no debugging symbols"
>>   	    set gdb_file_cmd_msg $expect_out(1,string)
>>   	    set gdb_file_cmd_debug_info "nodebug"
>>
>> base-commit: 83f18e5ebe627163f744215d3760a8eaacee6ec1
> 
> Thanks for the good explanation, I didn't know about all these things.
> LGTM:
> 
> Approved-By: Simon Marchi <simon.marchi@efficios.com>

Hi,

I ended up needing this patch in trunk for another patch, so I've 
applied it (after adding the approved-by tag).

Thanks again,
- Tom
  
Tom Tromey Dec. 9, 2022, 5:45 p.m. UTC | #3
Enze> Then run the selftest.exp, I see:

Thanks for doing this.

Not your problem really, but these self-tests have been difficult for a
long time.  In the long run I hope we can get rid of them entirely and
replace them with unit tests where possible.

Tom
  
Enze Li Dec. 13, 2022, 2:28 p.m. UTC | #4
On Fri, Dec 09 2022 at 10:45:54 AM -0700, Tom Tromey wrote:

> Enze> Then run the selftest.exp, I see:
>
> Thanks for doing this.
>
> Not your problem really, but these self-tests have been difficult for a
> long time.  In the long run I hope we can get rid of them entirely and
> replace them with unit tests where possible.
>
> Tom

Hi Tom,

How about we document this idea in the TODO list? This will make it
easier for others to know about the requirement.

--- a/gdb/testsuite/TODO
+++ b/gdb/testsuite/TODO
@@ -195,6 +195,8 @@ prologues will need to look different.  For sparc, the immediate field
 is 13 bits (signed), so I believe the threshold would be 4K bytes in a
 frame).

+Whenever possible, replace self-tests with unit tests.
+
 ^L
 (this is for editing this file with GNU emacs)
 Local Variables:

I dunno if this file still makes sense, and since it exists, I guess it
would be appropriate to document it here.

WDYT?

Best Regards,
Enze
  
Tom Tromey Dec. 13, 2022, 4:23 p.m. UTC | #5
>>>>> "Enze" == Enze Li via Gdb-patches <gdb-patches@sourceware.org> writes:

Enze> I dunno if this file still makes sense, and since it exists, I guess it
Enze> would be appropriate to document it here.

Enze> WDYT?

It's fine by me but I don't think the to-do list is really maintained,
and probably would make more sense to just delete.

Also maybe the remaining self-tests can't be replaced, I'm not sure.
One of them at least is for testing gdb's own pretty-printers, so that
seems pretty difficult.

Really the main problem with these is that they are fragile and, at
least for me, seem to time out a lot (I guess depending on whether I've
done a -g -O0 build or not).  So maybe it's better to just try to remove
the flaws.

Tom
  

Patch

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index e4ce3c30c2ff..008f59b9f30b 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2139,7 +2139,7 @@  proc gdb_file_cmd { arg } {
 	    set gdb_file_cmd_debug_info "lzma"
 	    return 0
 	}
-	-re "(Reading symbols from.*no debugging symbols found.*$gdb_prompt $)" {
+	-re "(Reading symbols from.*No debugging symbols found.*$gdb_prompt $)" {
 	    verbose "\t\tLoaded $arg into $GDB with no debugging symbols"
 	    set gdb_file_cmd_msg $expect_out(1,string)
 	    set gdb_file_cmd_debug_info "nodebug"