public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/3] clang inspired testsuite fixups.
@ 2024-05-02 18:25 Guinevere Larsen
  2024-05-02 18:25 ` [PATCH 1/3] gdb/testsuite: fix XPASSes when testing with clang Guinevere Larsen
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Guinevere Larsen @ 2024-05-02 18:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Guinevere Larsen

I decided to check out the 95 XPASSes in the clang buildbot and this is
the series that resulted.  The first 2 patches turn 86 XPASSes into
regular passes.

The third patch was going to be merged into the second one, but I
figured testing both DWARF4 and DWARF5 could be useful. So instead, I
made it a standalone clean up to the testsuite.

Guinevere Larsen (3):
  gdb/testsuite: fix XPASSes when testing with clang
  gdb/testsuite: ask for DWARF5 in gdb.cp/pass-by-ref.exp
  gdb/testsuite: introduce dwarf5 option to gdb_compile

 .../amd64-entry-value-param-dwarf5.exp        |  2 +-
 gdb/testsuite/gdb.cp/classes.exp              | 16 +++---
 gdb/testsuite/gdb.cp/pass-by-ref.exp          |  6 ++-
 gdb/testsuite/gdb.cp/ptype-flags.exp          | 11 ++--
 gdb/testsuite/gdb.dwarf2/dw5-rnglist-test.exp |  3 +-
 .../gdb.dwarf2/gdb-index-types-dwarf5.exp     |  2 +-
 gdb/testsuite/gdb.fortran/assumedrank.exp     |  2 +-
 gdb/testsuite/lib/gdb.exp                     | 51 +++++++++++++++++++
 8 files changed, 74 insertions(+), 19 deletions(-)

-- 
2.44.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] gdb/testsuite: fix XPASSes when testing with clang
  2024-05-02 18:25 [PATCH 0/3] clang inspired testsuite fixups Guinevere Larsen
@ 2024-05-02 18:25 ` Guinevere Larsen
  2024-05-02 18:25 ` [PATCH 2/3] gdb/testsuite: ask for DWARF5 in gdb.cp/pass-by-ref.exp Guinevere Larsen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Guinevere Larsen @ 2024-05-02 18:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Guinevere Larsen

Clang used to not add access specifiers for typedefs, and the tests
gdb.cp/ptype-flags.exp and gdb.cp/classes.exp both set XFAILs if clang
is being used to test. This was fixed on the clang 16.0.0 release,
generating many XPASSes. This current commit checks the clang version
used for testing, and only emits XFAIL on when a bad clang version is
used.

The testsuite didn't have a good way to check if a compiler is newer
than a given release, so this commit also adds a naive function that
does that, by assuming that major numbers trump the middle, which
trump the minor number.
---
 gdb/testsuite/gdb.cp/classes.exp     | 16 ++++++-----
 gdb/testsuite/gdb.cp/ptype-flags.exp | 11 ++++---
 gdb/testsuite/lib/gdb.exp            | 43 ++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+), 13 deletions(-)

diff --git a/gdb/testsuite/gdb.cp/classes.exp b/gdb/testsuite/gdb.cp/classes.exp
index 97dca292796..53a8ef1f1d2 100644
--- a/gdb/testsuite/gdb.cp/classes.exp
+++ b/gdb/testsuite/gdb.cp/classes.exp
@@ -25,9 +25,11 @@ load_lib "cp-support.exp"
 standard_testfile .cc
 
 set flags [list debug c++]
-set clang_used false
+set using_broken_clang false
 if { [test_compiler_info "clang-*" "c++"] } {
-    set clang_used true
+    if { [compiler_version_lower_than "16-0-0" "clang" "c++"] } {
+	set using_broken_clang true
+    }
     if { [gcc_major_version "clang-*" "c++"] >= 11} {
 	lappend flags additional_flags=-Wno-non-c-typedef-for-linkage
     }
@@ -330,7 +332,7 @@ proc test_ptype_class_objects {} {
 
     # Clang does not add access information for typedefs in classes.
     # More information on: https://github.com/llvm/llvm-project/issues/57608
-    if {$::clang_used} {
+    if {$::using_broken_clang} {
 	setup_xfail "clang 57608" *-*-*
     }
 
@@ -354,7 +356,7 @@ proc test_ptype_class_objects {} {
 	    { typedef private "typedef int private_int;" }
 	}
 
-    if {$::clang_used} {
+    if {$::using_broken_clang} {
 	setup_xfail "clang 57608" *-*-*
     }
 
@@ -366,7 +368,7 @@ proc test_ptype_class_objects {} {
 	    { typedef public "typedef int INT;" }
 	}
 
-    if {$::clang_used} {
+    if {$::using_broken_clang} {
 	setup_xfail "clang 57608" *-*-*
     }
 
@@ -378,7 +380,7 @@ proc test_ptype_class_objects {} {
 	    { typedef protected "typedef int INT;" }
 	}
 
-    if {$::clang_used} {
+    if {$::using_broken_clang} {
 	setup_xfail "clang 57608" *-*-*
     }
 
@@ -390,7 +392,7 @@ proc test_ptype_class_objects {} {
 	    { typedef protected "typedef int INT;" }
 	}
 
-    if {$::clang_used} {
+    if {$::using_broken_clang} {
 	setup_xfail "clang 57608" *-*-*
     }
 
diff --git a/gdb/testsuite/gdb.cp/ptype-flags.exp b/gdb/testsuite/gdb.cp/ptype-flags.exp
index bb92da6122a..8ac8e371fb2 100644
--- a/gdb/testsuite/gdb.cp/ptype-flags.exp
+++ b/gdb/testsuite/gdb.cp/ptype-flags.exp
@@ -29,10 +29,9 @@ if {![runto_main]} {
     return
 }
 
-if {[test_compiler_info {clang-*-*} c++]} {
-    set using_clang true
-} else {
-    set using_clang false
+set using_broken_clang false
+if {[compiler_version_lower_than "16-0-0" "clang" "c++"]} {
+    set using_broken_clang true
 }
 
 gdb_test_no_output "set language c++" ""
@@ -40,7 +39,7 @@ gdb_test_no_output "set width 0" ""
 
 proc do_check_holder {name {flags ""} {show_typedefs 1} {show_methods 1}
 		      {raw 0}} {
-    global using_clang
+    global using_broken_clang
 
     set contents {
 	{ base "public Base<T>" }
@@ -57,7 +56,7 @@ proc do_check_holder {name {flags ""} {show_typedefs 1} {show_methods 1}
     if {$show_typedefs} {
 	# Clang does not add accessibility information for typedefs:
 	# https://github.com/llvm/llvm-project/issues/57608
-	if {$using_clang} {
+	if {$using_broken_clang} {
 	    setup_xfail "clang 57608" *-*-*
 	}
 	lappend contents { typedef public "typedef Simple<Simple<T> > Z;" }
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index fe3f05c18df..67d5aef9343 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5001,6 +5001,49 @@ proc gcc_major_version { {compiler "gcc-*"} {language "c"} } {
     return $major.$minor
 }
 
+# Calculate if the compiler version is higer than VERSION.
+# If the proc can't tell (for instance, the provided compiler is clang
+# but the testssuite is running with gcc), it returns false.
+# VERSION must be in the form "0-0-0", with all 3 numbers.
+
+proc compiler_version_lower_than { version {compiler "gcc"} \
+				      {language "c"} } {
+    global decimal
+    
+    set res [regexp $compiler-($decimal)-($decimal)-($decimal) \
+		[test_compiler_info "" $language] dummy major mid minor]
+
+    regexp ($decimal)-($decimal)-($decimal) $version dummy \
+	prov_major prov_mid prov_minor
+    
+    # We either can't determine the compiler, or the compiler is
+    # different than provided
+    if { $res != 1} {
+	return false
+    }
+
+    if {$major != $prov_major} {
+	if {$major < $prov_major} {
+	    return true
+	} else {
+	    return false
+	}
+    }
+
+    if {$mid != $prov_mid} {
+	if {$mid < $prov_mid} {
+	    return true
+	} else {
+	    return false
+	}
+    }
+
+    if {$minor < $prov_mid} {
+	return true
+    }
+    return false
+}
+
 proc current_target_name { } {
     global target_info
     if [info exists target_info(target,name)] {
-- 
2.44.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/3] gdb/testsuite: ask for DWARF5 in gdb.cp/pass-by-ref.exp
  2024-05-02 18:25 [PATCH 0/3] clang inspired testsuite fixups Guinevere Larsen
  2024-05-02 18:25 ` [PATCH 1/3] gdb/testsuite: fix XPASSes when testing with clang Guinevere Larsen
@ 2024-05-02 18:25 ` Guinevere Larsen
  2024-05-02 18:25 ` [PATCH 3/3] gdb/testsuite: introduce dwarf5 option to gdb_compile Guinevere Larsen
  2024-05-16 20:10 ` [PING][PATCH 0/3] clang inspired testsuite fixups Guinevere Larsen
  3 siblings, 0 replies; 6+ messages in thread
From: Guinevere Larsen @ 2024-05-02 18:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Guinevere Larsen

The test gdb.cp/pass-by-ref.exp relies on some DWARF attributes that
were only added in version 5. Some compilers (notably clang on fedoras
older than 40) default to using DWARF4, which is why there are many
XFAILs in the output.

However, clang is able to emit dwarf5, and will start doing so as the
default in fedora 40 (which is what the buildbot is using) causing 80
XPASSes to be emitted.

This patch identifies which debug version is being produced by the
compiler, and only sets up the XFAIL if DWARF5 is not used.
---
 gdb/testsuite/gdb.cp/pass-by-ref.exp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.cp/pass-by-ref.exp b/gdb/testsuite/gdb.cp/pass-by-ref.exp
index 7b2a6196c50..69437e9799c 100644
--- a/gdb/testsuite/gdb.cp/pass-by-ref.exp
+++ b/gdb/testsuite/gdb.cp/pass-by-ref.exp
@@ -343,6 +343,9 @@ if {![runto_main]} {
     return -1
 }
 
+get_debug_format
+set using_dwarf5 [test_debug_format "DWARF 5"]
+
 set bp_location [gdb_get_line_number "stop here"]
 gdb_breakpoint $bp_location
 gdb_continue_to_breakpoint "end of main" ".*return .*;"
@@ -412,7 +415,8 @@ proc test_for_class { prefix states cbvfun data_field length} {
 		    "destructor should be called"
 	    }
 	} else {
-	    if {$cctor == "deleted" && ($is_gcc_6_or_older || $is_clang)} {
+	    if {$cctor == "deleted"
+		&& ($is_gcc_6_or_older || !$::using_dwarf5)} {
 		setup_xfail "*-*-*"
 	    }
 	    gdb_test "print ${cbvfun}<$name> (${name}_var)" \
-- 
2.44.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/3] gdb/testsuite: introduce dwarf5 option to gdb_compile
  2024-05-02 18:25 [PATCH 0/3] clang inspired testsuite fixups Guinevere Larsen
  2024-05-02 18:25 ` [PATCH 1/3] gdb/testsuite: fix XPASSes when testing with clang Guinevere Larsen
  2024-05-02 18:25 ` [PATCH 2/3] gdb/testsuite: ask for DWARF5 in gdb.cp/pass-by-ref.exp Guinevere Larsen
@ 2024-05-02 18:25 ` Guinevere Larsen
  2024-05-16 20:10 ` [PING][PATCH 0/3] clang inspired testsuite fixups Guinevere Larsen
  3 siblings, 0 replies; 6+ messages in thread
From: Guinevere Larsen @ 2024-05-02 18:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Guinevere Larsen

A few tests on the testsuite require dwarf5 to work. Up until now, the
way to do this was to explicitly add the command line flag -gdwarf-5.
This isn't very portable, in case a compiler requires a different flag
to emit dwarf5.

This commit adds a new option to gdb_compile that would be able to add
the correct flag (if known) or error out in case we are unable to tell
which flag to use. It also changes the existing tests to use this
general option instead of hard coding -gdwarf-5.
---
 gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.exp | 2 +-
 gdb/testsuite/gdb.dwarf2/dw5-rnglist-test.exp             | 3 +--
 gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.exp       | 2 +-
 gdb/testsuite/gdb.fortran/assumedrank.exp                 | 2 +-
 gdb/testsuite/lib/gdb.exp                                 | 8 ++++++++
 5 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.exp b/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.exp
index 344c4abe456..5078d0c2b9a 100644
--- a/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.exp
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.exp
@@ -19,7 +19,7 @@ set opts {}
 if [info exists COMPILE] {
     # make check RUNTESTFLAGS="gdb.arch/amd64-entry-value-param-dwarf5.exp COMPILE=1"
     standard_testfile .c .c
-    lappend opts optimize=-O2 additional_flags=-gdwarf-5
+    lappend opts optimize=-O2 dwarf5
 } else {
     require is_x86_64_m64_target
 }
diff --git a/gdb/testsuite/gdb.dwarf2/dw5-rnglist-test.exp b/gdb/testsuite/gdb.dwarf2/dw5-rnglist-test.exp
index a6a99e86858..a7ca334869f 100644
--- a/gdb/testsuite/gdb.dwarf2/dw5-rnglist-test.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw5-rnglist-test.exp
@@ -24,8 +24,7 @@ standard_testfile .cc
 # we let that be the test of whether the target supports it.
 
 if { [prepare_for_testing "failed to prepare" "${testfile}" \
-          $srcfile {debug c++ additional_flags=-gdwarf-5 \
-                        additional_flags=-O0}] } {
+          $srcfile {debug c++ dwarf5 additional_flags=-O0}] } {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.exp b/gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.exp
index 540e770a3bf..b97b55468e4 100644
--- a/gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.exp
+++ b/gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.exp
@@ -17,7 +17,7 @@ standard_testfile
 
 set flags {}
 lappend flags {additional_flags=-fdebug-types-section}
-lappend flags {additional_flags=-gdwarf-5}
+lappend flags {dwarf5}
 
 if { [prepare_for_testing "failed to prepare" ${testfile} \
 	  $srcfile $flags] } {
diff --git a/gdb/testsuite/gdb.fortran/assumedrank.exp b/gdb/testsuite/gdb.fortran/assumedrank.exp
index 957dfefc7c7..32fd9d29ca7 100644
--- a/gdb/testsuite/gdb.fortran/assumedrank.exp
+++ b/gdb/testsuite/gdb.fortran/assumedrank.exp
@@ -28,7 +28,7 @@ if { [test_compiler_info {gfortran-*} f90] &&
 }
 
 if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
-	 {debug f90 additional_flags=-gdwarf-5}]} {
+	 {debug f90 dwarf5}]} {
     return -1
 }
 
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 67d5aef9343..b310d125626 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5256,6 +5256,7 @@ proc quote_for_host { args } {
 #   - build-id: Ensure the final binary includes a build-id.
 #   - column-info/no-column-info: Enable/Disable generation of column table
 #     information.
+#   - dwarf5: Force compilation with dwarf-5 debug information.
 #
 # And here are some of the not too obscure options understood by DejaGnu that
 # influence the compilation:
@@ -5497,6 +5498,13 @@ proc gdb_compile {source dest type options} {
 		error "Option gno-column-info not supported by compiler."
 	    }
 
+	} elseif { $opt == "dwarf5" } {
+	    if {[test_compiler_info {gcc-*}] \
+		|| [test_compiler_info {clang-*}]} {
+		lappend new_options "additional_flags=-gdwarf-5"
+	    } else {
+		error "No idea how to force DWARF-5 in this compiler"
+	    }
         } else {
             lappend new_options $opt
         }
-- 
2.44.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PING][PATCH 0/3] clang inspired testsuite fixups.
  2024-05-02 18:25 [PATCH 0/3] clang inspired testsuite fixups Guinevere Larsen
                   ` (2 preceding siblings ...)
  2024-05-02 18:25 ` [PATCH 3/3] gdb/testsuite: introduce dwarf5 option to gdb_compile Guinevere Larsen
@ 2024-05-16 20:10 ` Guinevere Larsen
  2024-05-23 20:27   ` [PING^2][PATCH " Guinevere Larsen
  3 siblings, 1 reply; 6+ messages in thread
From: Guinevere Larsen @ 2024-05-16 20:10 UTC (permalink / raw)
  To: Guinevere Larsen, gdb-patches

Ping :)

On 5/2/24 15:25, Guinevere Larsen wrote:
> I decided to check out the 95 XPASSes in the clang buildbot and this is
> the series that resulted.  The first 2 patches turn 86 XPASSes into
> regular passes.
>
> The third patch was going to be merged into the second one, but I
> figured testing both DWARF4 and DWARF5 could be useful. So instead, I
> made it a standalone clean up to the testsuite.
>
> Guinevere Larsen (3):
>    gdb/testsuite: fix XPASSes when testing with clang
>    gdb/testsuite: ask for DWARF5 in gdb.cp/pass-by-ref.exp
>    gdb/testsuite: introduce dwarf5 option to gdb_compile
>
>   .../amd64-entry-value-param-dwarf5.exp        |  2 +-
>   gdb/testsuite/gdb.cp/classes.exp              | 16 +++---
>   gdb/testsuite/gdb.cp/pass-by-ref.exp          |  6 ++-
>   gdb/testsuite/gdb.cp/ptype-flags.exp          | 11 ++--
>   gdb/testsuite/gdb.dwarf2/dw5-rnglist-test.exp |  3 +-
>   .../gdb.dwarf2/gdb-index-types-dwarf5.exp     |  2 +-
>   gdb/testsuite/gdb.fortran/assumedrank.exp     |  2 +-
>   gdb/testsuite/lib/gdb.exp                     | 51 +++++++++++++++++++
>   8 files changed, 74 insertions(+), 19 deletions(-)
>

-- 
Cheers,
Guinevere Larsen
She/Her/Hers


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PING^2][PATCH 0/3] clang inspired testsuite fixups.
  2024-05-16 20:10 ` [PING][PATCH 0/3] clang inspired testsuite fixups Guinevere Larsen
@ 2024-05-23 20:27   ` Guinevere Larsen
  0 siblings, 0 replies; 6+ messages in thread
From: Guinevere Larsen @ 2024-05-23 20:27 UTC (permalink / raw)
  To: Guinevere Larsen, gdb-patches

Ping

-- 
Cheers,
Guinevere Larsen
She/Her/Hers

On 5/16/24 17:10, Guinevere Larsen wrote:
> Ping :)
>
> On 5/2/24 15:25, Guinevere Larsen wrote:
>> I decided to check out the 95 XPASSes in the clang buildbot and this is
>> the series that resulted.  The first 2 patches turn 86 XPASSes into
>> regular passes.
>>
>> The third patch was going to be merged into the second one, but I
>> figured testing both DWARF4 and DWARF5 could be useful. So instead, I
>> made it a standalone clean up to the testsuite.
>>
>> Guinevere Larsen (3):
>>    gdb/testsuite: fix XPASSes when testing with clang
>>    gdb/testsuite: ask for DWARF5 in gdb.cp/pass-by-ref.exp
>>    gdb/testsuite: introduce dwarf5 option to gdb_compile
>>
>>   .../amd64-entry-value-param-dwarf5.exp        |  2 +-
>>   gdb/testsuite/gdb.cp/classes.exp              | 16 +++---
>>   gdb/testsuite/gdb.cp/pass-by-ref.exp          |  6 ++-
>>   gdb/testsuite/gdb.cp/ptype-flags.exp          | 11 ++--
>>   gdb/testsuite/gdb.dwarf2/dw5-rnglist-test.exp |  3 +-
>>   .../gdb.dwarf2/gdb-index-types-dwarf5.exp     |  2 +-
>>   gdb/testsuite/gdb.fortran/assumedrank.exp     |  2 +-
>>   gdb/testsuite/lib/gdb.exp                     | 51 +++++++++++++++++++
>>   8 files changed, 74 insertions(+), 19 deletions(-)
>>
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-05-23 20:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-02 18:25 [PATCH 0/3] clang inspired testsuite fixups Guinevere Larsen
2024-05-02 18:25 ` [PATCH 1/3] gdb/testsuite: fix XPASSes when testing with clang Guinevere Larsen
2024-05-02 18:25 ` [PATCH 2/3] gdb/testsuite: ask for DWARF5 in gdb.cp/pass-by-ref.exp Guinevere Larsen
2024-05-02 18:25 ` [PATCH 3/3] gdb/testsuite: introduce dwarf5 option to gdb_compile Guinevere Larsen
2024-05-16 20:10 ` [PING][PATCH 0/3] clang inspired testsuite fixups Guinevere Larsen
2024-05-23 20:27   ` [PING^2][PATCH " Guinevere Larsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).