[pushed,1/3,gdb/testsuite] Fix gdb.cp/*.exp for remote host

Message ID 20230322083819.14320-2-tdevries@suse.de
State Committed
Headers
Series Fix gdb.cp/*.exp for remote host/target |

Commit Message

Tom de Vries March 22, 2023, 8:38 a.m. UTC
  Fix a few test-cases in gdb.cp/*.exp for remote host using new proc
include_file.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.cp/breakpoint-locs.exp |  2 ++
 gdb/testsuite/gdb.cp/filename.exp        |  2 ++
 gdb/testsuite/gdb.cp/gdb2384.exp         |  2 ++
 gdb/testsuite/gdb.cp/hang.exp            |  2 ++
 gdb/testsuite/gdb.cp/m-static.exp        |  8 +++++++-
 gdb/testsuite/gdb.cp/mb-inline.exp       |  1 +
 gdb/testsuite/gdb.cp/minsym-fallback.exp |  3 +++
 gdb/testsuite/gdb.cp/ovsrch.exp          |  2 ++
 gdb/testsuite/gdb.cp/pr10728.exp         |  2 ++
 gdb/testsuite/gdb.cp/rtti.exp            |  2 ++
 gdb/testsuite/gdb.cp/stub-array-size.exp |  2 ++
 gdb/testsuite/gdb.cp/subtypes.exp        |  2 ++
 gdb/testsuite/lib/gdb.exp                | 12 ++++++++++++
 13 files changed, 41 insertions(+), 1 deletion(-)
  

Comments

Simon Marchi March 22, 2023, 3:05 p.m. UTC | #1
On 3/22/23 04:38, Tom de Vries via Gdb-patches wrote:
> Fix a few test-cases in gdb.cp/*.exp for remote host using new proc
> include_file.

Starting with this patch, I see:

    info variable everywhere^M
    All variables matching regular expression "everywhere":^M
    ^M
    File /home/simark/src/binutils-gdb/gdb/testsuite/gdb.cp/m-static.h:^M
    8:      const int gnu_obj_4::everywhere;^M
    (gdb) FAIL: gdb.cp/m-static.exp: info variable everywhere

Simon
  
Tom de Vries March 23, 2023, 12:18 a.m. UTC | #2
On 3/22/23 16:05, Simon Marchi wrote:
> 
> 
> On 3/22/23 04:38, Tom de Vries via Gdb-patches wrote:
>> Fix a few test-cases in gdb.cp/*.exp for remote host using new proc
>> include_file.
> 
> Starting with this patch, I see:
> 
>      info variable everywhere^M
>      All variables matching regular expression "everywhere":^M
>      ^M
>      File /home/simark/src/binutils-gdb/gdb/testsuite/gdb.cp/m-static.h:^M
>      8:      const int gnu_obj_4::everywhere;^M
>      (gdb) FAIL: gdb.cp/m-static.exp: info variable everywhere
> 

Hi Simon,

thanks for reporting this.

I don't see this on openSUSE Leap 15.4 and Tumbleweed, but I managed to 
reproduce on Ubuntu 20.04 (though with the readnow board, it disappears 
again).

Anyway, the problem is that I changed the matching to be more strict, 
and that's what we're seeing the effect of.  I'll propose a patch that 
reverts things to the way things were before, with less strict matching.

As for what I'm seeing:
...
(gdb) info variable everywhere^M
All variables matching regular expression "everywhere":^M
^M
File /data/vries/gdb/src/gdb/testsuite/gdb.cp/m-static.h:^M
8:      const int gnu_obj_4::everywhere;^M
^M
File /data/vries/gdb/src/gdb/testsuite/gdb.cp/m-static1.cc:^M
8:      const int gnu_obj_4::everywhere;^M
(gdb) PASS: gdb.cp/m-static.exp: info variable everywhere
...
the combination of line 8 with m-static1.cc doesn't seem to make sense.

I don't know this as a known issue, so I'll file a PR about it.

Thanks,
- Tom
  
Tom de Vries March 23, 2023, 1:49 p.m. UTC | #3
On 3/23/23 01:18, Tom de Vries wrote:
> On 3/22/23 16:05, Simon Marchi wrote:
>>
>>
>> On 3/22/23 04:38, Tom de Vries via Gdb-patches wrote:
>>> Fix a few test-cases in gdb.cp/*.exp for remote host using new proc
>>> include_file.
>>
>> Starting with this patch, I see:
>>
>>      info variable everywhere^M
>>      All variables matching regular expression "everywhere":^M
>>      ^M
>>      File 
>> /home/simark/src/binutils-gdb/gdb/testsuite/gdb.cp/m-static.h:^M
>>      8:      const int gnu_obj_4::everywhere;^M
>>      (gdb) FAIL: gdb.cp/m-static.exp: info variable everywhere
>>
> 
> Hi Simon,
> 
> thanks for reporting this.
> 
> I don't see this on openSUSE Leap 15.4 and Tumbleweed, but I managed to 
> reproduce on Ubuntu 20.04 (though with the readnow board, it disappears 
> again).
> 
> Anyway, the problem is that I changed the matching to be more strict, 
> and that's what we're seeing the effect of.  I'll propose a patch that 
> reverts things to the way things were before, with less strict matching.
> 

Proposed patch is here ( 
https://sourceware.org/pipermail/gdb-patches/2023-March/198240.html ).

> As for what I'm seeing:
> ...
> (gdb) info variable everywhere^M
> All variables matching regular expression "everywhere":^M
> ^M
> File /data/vries/gdb/src/gdb/testsuite/gdb.cp/m-static.h:^M
> 8:      const int gnu_obj_4::everywhere;^M
> ^M
> File /data/vries/gdb/src/gdb/testsuite/gdb.cp/m-static1.cc:^M
> 8:      const int gnu_obj_4::everywhere;^M
> (gdb) PASS: gdb.cp/m-static.exp: info variable everywhere
> ...
> the combination of line 8 with m-static1.cc doesn't seem to make sense.
> 
> I don't know this as a known issue, so I'll file a PR about it.
> 

Filed this PR ( https://sourceware.org/bugzilla/show_bug.cgi?id=30265 ).

Thanks,
- Tom
  

Patch

diff --git a/gdb/testsuite/gdb.cp/breakpoint-locs.exp b/gdb/testsuite/gdb.cp/breakpoint-locs.exp
index 0d1ad68f9f5..11192654a35 100644
--- a/gdb/testsuite/gdb.cp/breakpoint-locs.exp
+++ b/gdb/testsuite/gdb.cp/breakpoint-locs.exp
@@ -19,6 +19,8 @@  require allow_cplus_tests
 
 standard_testfile .cc breakpoint-locs-2.cc
 
+include_file breakpoint-locs.h
+
 if { [prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2"\
 	  {debug c++}] } {
     return -1
diff --git a/gdb/testsuite/gdb.cp/filename.exp b/gdb/testsuite/gdb.cp/filename.exp
index 9b1d2b8a606..2eddb9b7982 100644
--- a/gdb/testsuite/gdb.cp/filename.exp
+++ b/gdb/testsuite/gdb.cp/filename.exp
@@ -17,6 +17,8 @@  require allow_cplus_tests
 
 standard_testfile .cc
 
+include_file includefile
+
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
     return -1
 }
diff --git a/gdb/testsuite/gdb.cp/gdb2384.exp b/gdb/testsuite/gdb.cp/gdb2384.exp
index 46d93d27e7b..7c6b27fd8db 100644
--- a/gdb/testsuite/gdb.cp/gdb2384.exp
+++ b/gdb/testsuite/gdb.cp/gdb2384.exp
@@ -25,6 +25,8 @@  require allow_cplus_tests allow_shlib_tests
 
 standard_testfile .cc gdb2384-base.cc
 
+include_file gdb2384-base.h
+
 set sofile [standard_output_file gdb2384-base.so]
 
 if { [gdb_compile_shlib $srcdir/$subdir/$srcfile2 $sofile {debug c++}] != ""
diff --git a/gdb/testsuite/gdb.cp/hang.exp b/gdb/testsuite/gdb.cp/hang.exp
index 7d8588520ec..71ab5c7a63b 100644
--- a/gdb/testsuite/gdb.cp/hang.exp
+++ b/gdb/testsuite/gdb.cp/hang.exp
@@ -18,6 +18,8 @@  require allow_cplus_tests
 
 standard_testfile hang1.cc hang2.cc hang3.cc
 
+include_file hang.H
+
 if {[prepare_for_testing "failed to prepare" $testfile \
 	 [list $srcfile $srcfile2 $srcfile3] {debug c++}]} {
     return -1
diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp
index 56c4cdad95e..419d772e28e 100644
--- a/gdb/testsuite/gdb.cp/m-static.exp
+++ b/gdb/testsuite/gdb.cp/m-static.exp
@@ -27,6 +27,8 @@  require allow_cplus_tests
 
 standard_testfile .cc m-static1.cc
 
+include_file m-static.h
+
 set flags [list debug c++]
 if { [test_compiler_info gcc-*] && [gcc_major_version] >= 10 } {
     # Work around PR gcc/101452.
@@ -181,7 +183,11 @@  gdb_test "print test4.somewhere" "\\$\[0-9\].* = 3.14\[0-9\]*" "static const flo
 
 # Also make sure static const members can be found via "info var".
 if { $non_dwarf } { setup_xfail *-*-* }
-gdb_test "info variable everywhere" "File .*/m-static\[.\]h.*const int gnu_obj_4::everywhere;"
+gdb_test "info variable everywhere" \
+    [multi_line \
+	 "File (.*/)?m-static\[.\]h:" \
+	 "$decimal:\tconst int gnu_obj_4::everywhere;" \
+	 ".*"]
 
 # Perhaps at some point test4 should also include a test for a static
 # const int that was initialized in the header file.  But I'm not sure
diff --git a/gdb/testsuite/gdb.cp/mb-inline.exp b/gdb/testsuite/gdb.cp/mb-inline.exp
index 555827806f7..9793b14c073 100644
--- a/gdb/testsuite/gdb.cp/mb-inline.exp
+++ b/gdb/testsuite/gdb.cp/mb-inline.exp
@@ -22,6 +22,7 @@  require allow_cplus_tests
 
 standard_testfile mb-inline1.cc mb-inline2.cc
 set hdrfile "${testfile}.h"
+include_file $hdrfile
 
 if {[prepare_for_testing "failed to prepare" $testfile \
 	 [list $srcfile $srcfile2] {debug c++}]} {
diff --git a/gdb/testsuite/gdb.cp/minsym-fallback.exp b/gdb/testsuite/gdb.cp/minsym-fallback.exp
index 56a56a3da6b..a3bfe56bec6 100644
--- a/gdb/testsuite/gdb.cp/minsym-fallback.exp
+++ b/gdb/testsuite/gdb.cp/minsym-fallback.exp
@@ -18,6 +18,9 @@ 
 # a different file providing only ELF symbols.
 
 standard_testfile .cc minsym-fallback-main.cc
+
+include_file minsym-fallback.h
+
 set executable $testfile
 set objfile [standard_output_file ${testfile}.o]
 set objmainfile [standard_output_file ${testfile}-main.o]
diff --git a/gdb/testsuite/gdb.cp/ovsrch.exp b/gdb/testsuite/gdb.cp/ovsrch.exp
index 31a8abf7793..39e022c6676 100644
--- a/gdb/testsuite/gdb.cp/ovsrch.exp
+++ b/gdb/testsuite/gdb.cp/ovsrch.exp
@@ -57,6 +57,8 @@  require allow_cplus_tests
 # Test for c++/11734
 standard_testfile ovsrch1.cc ovsrch2.cc ovsrch3.cc ovsrch4.cc
 
+include_file ovsrch.h
+
 if {[prepare_for_testing "failed to prepare" $testfile \
 	 [list $srcfile $srcfile2 $srcfile3 $srcfile4] {c++ debug}]} {
     return -1
diff --git a/gdb/testsuite/gdb.cp/pr10728.exp b/gdb/testsuite/gdb.cp/pr10728.exp
index b860fb7c3ae..ea9c1242725 100644
--- a/gdb/testsuite/gdb.cp/pr10728.exp
+++ b/gdb/testsuite/gdb.cp/pr10728.exp
@@ -22,6 +22,8 @@  require allow_cplus_tests
 load_lib "cp-support.exp"
 
 standard_testfile pr10728-x.cc pr10728-y.cc
+include_file pr10728-x.h
+
 set tfx [standard_output_file pr10728-x.o]
 set tfy [standard_output_file pr10728-y.o]
 
diff --git a/gdb/testsuite/gdb.cp/rtti.exp b/gdb/testsuite/gdb.cp/rtti.exp
index 8ad7683ee40..18dfaf0c2bd 100644
--- a/gdb/testsuite/gdb.cp/rtti.exp
+++ b/gdb/testsuite/gdb.cp/rtti.exp
@@ -34,6 +34,8 @@  require allow_cplus_tests
 
 standard_testfile rtti1.cc rtti2.cc
 
+include_file rtti.h
+
 if {[prepare_for_testing "failed to prepare" $testfile \
 	 [list $srcfile $srcfile2] {debug c++}]} {
     return -1
diff --git a/gdb/testsuite/gdb.cp/stub-array-size.exp b/gdb/testsuite/gdb.cp/stub-array-size.exp
index 0afe232d583..7757db20af9 100644
--- a/gdb/testsuite/gdb.cp/stub-array-size.exp
+++ b/gdb/testsuite/gdb.cp/stub-array-size.exp
@@ -22,6 +22,8 @@  require allow_cplus_tests
 
 standard_testfile .cc stub-array-size2.cc
 
+include_file stub-array-size.h
+
 if {[prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" \
 	{c++ debug}]} {
     return -1
diff --git a/gdb/testsuite/gdb.cp/subtypes.exp b/gdb/testsuite/gdb.cp/subtypes.exp
index f5cf349cc26..afad478cba3 100644
--- a/gdb/testsuite/gdb.cp/subtypes.exp
+++ b/gdb/testsuite/gdb.cp/subtypes.exp
@@ -22,6 +22,8 @@  load_lib "cp-support.exp"
 
 standard_testfile .cc subtypes-2.cc
 
+include_file subtypes.h
+
 if {[prepare_for_testing "failed to prepare" $testfile \
 	 [list $srcfile $srcfile2] \
 	 {debug c++ additional_flags=-std=c++11}]} {
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 0a0ae697d1e..24fcb8f1746 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -9554,6 +9554,18 @@  gdb_caching_proc have_compile_flag { flag } {
 		additional_flags=$flag]
 }
 
+# Handle include file $srcdir/$subdir/FILE.
+
+proc include_file { file } {
+    set file [file join $::srcdir $::subdir $file]
+    if { [is_remote host] } {
+	set res [remote_download host $file]
+    } else {
+	set res $file
+    }
+
+    return $res
+}
 
 # Handle include file FILE, and if necessary update compiler flags variable
 # FLAGS.