Patchwork [PATCHv2,4/4] gdb: Add new commands to list module variables and functions

login
register
mail settings
Submitter Andrew Burgess
Date Nov. 27, 2019, 9:29 p.m.
Message ID <20191127212923.GC3410@embecosm.com>
Download mbox | patch
Permalink /patch/36327/
State New
Headers show

Comments

Andrew Burgess - Nov. 27, 2019, 9:29 p.m.
* Tom de Vries <tdevries@suse.de> [2019-11-22 13:44:09 +0100]:

> On 03-10-2019 13:29, Andrew Burgess wrote:
> > 	* gdb.fortran/info-modules.exp: Update expected results, and add
> > 	additional tests for 'info module functinos', and 'info module
> > 	variables'.
> > 	* gdb.fortran/info-types.exp: Update expected results.
> > 	* gdb.fortran/info-types.f90: Extend testcase with additional
> > 	module variables and functions.
> 
> Hi,
> 
> This test-case fails to compile for me:
> ...
> $ cd build/gdb; make check RUNTESTFLAGS="gdb.fortran/info-modules.exp"
> gdb compile failed, src/gdb/testsuite/gdb.fortran/info-types.f90:39:6:
> 
>    use mod2
>       1
> Fatal Error: Can't open module file 'mod2.mod' for reading at (1): No
> such file or directory
> compilation terminated.
> 
>                 === gdb Summary ===
> 
> # of untested testcases         1
> ...
> 
> Interestingly, if I first run:
> ...
> $ cd build/gdb; make check RUNTESTFLAGS="gdb.fortran/module.exp"
> Running src/gdb/testsuite/gdb.fortran/module.exp ...
> 
>                 === gdb Summary ===
> 
> # of expected passes            27
> ...
> which produces:
> ...
> $ ls -la build/gdb/testsuite/mod2.mod
> -rw-r--r-- 1 vries users 208 22 nov 13:35 build/gdb/testsuite/mod2.mod
> ...
> then the test-case passes:
> ...
> $ cd build/gdb; make check RUNTESTFLAGS="gdb.fortran/info-modules.exp"
> Running src/gdb/testsuite/gdb.fortran/info-modules.exp ...
> 
>                 === gdb Summary ===
> 
> # of expected passes            12
> ...
> 
> Removing mod2.mod brings the failure back:
> ...
> $ rm -f build/gdb/testsuite/mod2.mod
>              $ cd build/gdb; make check
> RUNTESTFLAGS="gdb.fortran/info-modules.exp"
> gdb compile failed, src/gdb/testsuite/gdb.fortran/info-types.f90:39:6:
> 
>    use mod2
>       1
> Fatal Error: Can't open module file 'mod2.mod' for reading at (1): No
> such file or directory
> compilation terminated.
> 
>                 === gdb Summary ===
> 
> # of untested testcases         1
> ...
> 
> So, I think that in a parallel test run this may succeed, but in a
> sequential testrun this should fail.

Tom,

Thanks for finding this issue.  Sorry that I didn't spot this feedback
until after I'd pushed this patch.

I've committed the fix below to address this issue.

Thanks,
Andrew

---

From 640ab94712483457b99bd1039b52821c510b28a7 Mon Sep 17 00:00:00 2001
From: Andrew Burgess <andrew.burgess@embecosm.com>
Date: Wed, 27 Nov 2019 21:18:38 +0000
Subject: [PATCH] gdb/testsuite: Fix race condition compiling fortran test

The Fortran test gdb.fortran/info-modules compiles the files
info-types.f90 and info-types-2.f90 in that order.  Unfortunately
info-types.f90 makes use of a module defined in info-types-2.f90.

This currently doesn't cause a problem if you run all of the Fortran
tests as the info-types.exp test already compiles info-types-2.f90 and
so the module description file 'mod2.mod' will be created, and can
then be found by info-modules.exp during its compile.

If however you try to run just info-modules.exp in a clean build
directory, the test will fail to compile.

Fix this by compiling the source files in the reverse order so that
the module is compiled first, then the test program that uses the
module.

gdb/testsuite/ChangeLog:

	* gdb.fortran/info-modules.exp: Compile source files in correct
	order.

Change-Id: Ic3a1eded0486f6264ebe3066cf1beafbd2534a91
---
 gdb/testsuite/ChangeLog                    | 5 +++++
 gdb/testsuite/gdb.fortran/info-modules.exp | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)
Tom de Vries - Nov. 28, 2019, 9:20 a.m.
On 27-11-2019 22:29, Andrew Burgess wrote:
>> This test-case fails to compile for me:
>> ...
>> $ cd build/gdb; make check RUNTESTFLAGS="gdb.fortran/info-modules.exp"
>> gdb compile failed, src/gdb/testsuite/gdb.fortran/info-types.f90:39:6:
>>
>>    use mod2
>>       1
>> Fatal Error: Can't open module file 'mod2.mod' for reading at (1): No
>> such file or directory
>> compilation terminated.
>>
>>                 === gdb Summary ===
>>
>> # of untested testcases         1

> 
> I've committed the fix below to address this issue.
> 

> diff --git a/gdb/testsuite/gdb.fortran/info-modules.exp b/gdb/testsuite/gdb.fortran/info-modules.exp
> index 43570066d2f..c57ac3ff569 100644
> --- a/gdb/testsuite/gdb.fortran/info-modules.exp
> +++ b/gdb/testsuite/gdb.fortran/info-modules.exp
> @@ -23,7 +23,7 @@ if { [skip_fortran_tests] } { continue }
>  standard_testfile info-types.f90 info-types-2.f90
>  
>  if { [prepare_for_testing "failed to prepare" $testfile \
> -	  [list $srcfile $srcfile2] {debug f90}] } {
> +	  [list $srcfile2 $srcfile] {debug f90}] } {
>      return -1
>  }
>  
> 

Ah, interesting.  I initially tried:
...
-standard_testfile info-types.f90 info-types-2.f90
+standard_testfile info-types-2.f90 info-types.f90
...
which made the test-case compile but caused a bunch of FAILs, but it
didn't occur to me to switch the order in the preparing_for_testing call.

Thanks,
- Tom
Andrew Burgess - Nov. 28, 2019, 12:18 p.m.
* Tom de Vries <tdevries@suse.de> [2019-11-28 10:20:59 +0100]:

> On 27-11-2019 22:29, Andrew Burgess wrote:
> >> This test-case fails to compile for me:
> >> ...
> >> $ cd build/gdb; make check RUNTESTFLAGS="gdb.fortran/info-modules.exp"
> >> gdb compile failed, src/gdb/testsuite/gdb.fortran/info-types.f90:39:6:
> >>
> >>    use mod2
> >>       1
> >> Fatal Error: Can't open module file 'mod2.mod' for reading at (1): No
> >> such file or directory
> >> compilation terminated.
> >>
> >>                 === gdb Summary ===
> >>
> >> # of untested testcases         1
> 
> > 
> > I've committed the fix below to address this issue.
> > 
> 
> > diff --git a/gdb/testsuite/gdb.fortran/info-modules.exp b/gdb/testsuite/gdb.fortran/info-modules.exp
> > index 43570066d2f..c57ac3ff569 100644
> > --- a/gdb/testsuite/gdb.fortran/info-modules.exp
> > +++ b/gdb/testsuite/gdb.fortran/info-modules.exp
> > @@ -23,7 +23,7 @@ if { [skip_fortran_tests] } { continue }
> >  standard_testfile info-types.f90 info-types-2.f90
> >  
> >  if { [prepare_for_testing "failed to prepare" $testfile \
> > -	  [list $srcfile $srcfile2] {debug f90}] } {
> > +	  [list $srcfile2 $srcfile] {debug f90}] } {
> >      return -1
> >  }
> >  
> > 
> 
> Ah, interesting.  I initially tried:
> ...
> -standard_testfile info-types.f90 info-types-2.f90
> +standard_testfile info-types-2.f90 info-types.f90
> ...
> which made the test-case compile but caused a bunch of FAILs, but it
> didn't occur to me to switch the order in the preparing_for_testing call.

That change will result in $srcfile and $srcfile2 swapping over.  This
test checks that symbols are being reported as from the correct source
file, so the output patterns make use of the srcfile variables.
That's why this didn't work.

Thanks,
Andre

Patch

diff --git a/gdb/testsuite/gdb.fortran/info-modules.exp b/gdb/testsuite/gdb.fortran/info-modules.exp
index 43570066d2f..c57ac3ff569 100644
--- a/gdb/testsuite/gdb.fortran/info-modules.exp
+++ b/gdb/testsuite/gdb.fortran/info-modules.exp
@@ -23,7 +23,7 @@  if { [skip_fortran_tests] } { continue }
 standard_testfile info-types.f90 info-types-2.f90
 
 if { [prepare_for_testing "failed to prepare" $testfile \
-	  [list $srcfile $srcfile2] {debug f90}] } {
+	  [list $srcfile2 $srcfile] {debug f90}] } {
     return -1
 }