public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb/testsuite: remove global gcc_compiled from gdb.exp
@ 2022-06-24 14:07 Andrew Burgess
  0 siblings, 0 replies; only message in thread
From: Andrew Burgess @ 2022-06-24 14:07 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ef7a6b977bf5e8499734a3b8df48ce2ca690cf57

commit ef7a6b977bf5e8499734a3b8df48ce2ca690cf57
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Thu Jun 9 15:21:37 2022 +0100

    gdb/testsuite: remove global gcc_compiled from gdb.exp
    
    After this commit the gcc_compiled global is no longer exported from
    lib/gdb.exp.  In theory we could switch over all uses of gcc_compiled
    to instead call test_compiler_info directly, however, I have instead
    added a new proc to gdb.exp: 'is_c_compiler_gcc'.  I've then updated
    the testsuite to call this proc instead of using the global.
    
    Having a new proc specifically for this task means that we have a
    single consistent pattern for detecting gcc.  By wrapping this logic
    within a proc that calls test_compiler_info, rather than using the
    global, means that test scripts don't need to call get_compiler_info
    before they read the global, simply calling the new proc does
    everything in one go.
    
    As a result I've been able to remove the get_compiler_info calls from
    all the test scripts that I've touched in this commit.
    
    In some of the tests e.g. gdb.dwarf2/*.exp, the $gcc_compiled flag was
    being checked at the top of the script to decide if the whole script
    should be skipped or not.  In these cases I've called the new proc
    directly and removed all uses of gcc_compiled.
    
    In other cases, e.g. most of the gdb.base scripts, there were many
    uses of gcc_compiled.  In these cases I set a new global gcc_compiled
    near the top of the script, and leave the rest of the script
    unchanged.
    
    There should be no changes in what is tested after this commit.

Diff:
---
 gdb/testsuite/gdb.base/ctf-ptype.exp                |  9 +++------
 gdb/testsuite/gdb.base/funcargs.exp                 |  8 ++------
 gdb/testsuite/gdb.base/gdb1555.exp                  |  5 -----
 gdb/testsuite/gdb.base/langs.exp                    |  9 ++-------
 gdb/testsuite/gdb.base/morestack.exp                |  9 +++------
 gdb/testsuite/gdb.base/opaque.exp                   | 10 +++-------
 gdb/testsuite/gdb.base/prelink.exp                  |  7 ++-----
 gdb/testsuite/gdb.base/ptype.exp                    |  7 ++-----
 gdb/testsuite/gdb.base/setvar.exp                   |  8 +-------
 gdb/testsuite/gdb.base/type-opaque.exp              |  5 -----
 gdb/testsuite/gdb.base/until-trailing-insns.exp     |  6 +-----
 gdb/testsuite/gdb.base/whatis.exp                   |  3 +++
 gdb/testsuite/gdb.ctf/funcreturn.exp                |  9 +++------
 .../gdb.dwarf2/dw2-disasm-over-non-stmt.exp         |  5 +----
 gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp    |  5 +----
 gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp    |  5 +----
 gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp    |  5 +----
 gdb/testsuite/gdb.dwarf2/dw2-inline-many-frames.exp |  5 +----
 gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp  |  5 +----
 gdb/testsuite/gdb.dwarf2/dw2-inline-stepping.exp    |  5 +----
 gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp          |  5 +----
 gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp            |  5 +----
 gdb/testsuite/gdb.dwarf2/dw2-line-number-zero.exp   |  5 +----
 .../gdb.dwarf2/dw2-main-no-line-number.exp          |  5 +----
 .../gdb.dwarf2/dw2-out-of-range-end-of-seq.exp      |  5 +----
 gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp        |  5 +----
 gdb/testsuite/gdb.dwarf2/dw2-ranges-func.exp        |  5 +----
 gdb/testsuite/gdb.dwarf2/dw2-ranges-overlap.exp     |  5 +----
 gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp        |  5 +----
 gdb/testsuite/gdb.dwarf2/dw2-ranges.exp             |  5 +----
 .../gdb.dwarf2/dw2-step-out-of-function-no-stmt.exp |  5 +----
 .../gdb.dwarf2/dw2-vendor-extended-opcode.exp       |  5 +----
 gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp.tcl   |  5 +----
 gdb/testsuite/gdb.threads/tls-shared.exp            |  6 ------
 gdb/testsuite/gdb.threads/tls-so_extern.exp         |  6 ------
 gdb/testsuite/lib/compiler.c                        |  3 ---
 gdb/testsuite/lib/gdb.exp                           | 21 +++++++++------------
 37 files changed, 54 insertions(+), 177 deletions(-)

diff --git a/gdb/testsuite/gdb.base/ctf-ptype.exp b/gdb/testsuite/gdb.base/ctf-ptype.exp
index c8d91814f0e..48d39e56c7b 100644
--- a/gdb/testsuite/gdb.base/ctf-ptype.exp
+++ b/gdb/testsuite/gdb.base/ctf-ptype.exp
@@ -20,6 +20,9 @@ if [skip_ctf_tests] {
     return 0
 }
 
+# Some tests require GCC.
+set gcc_compiled [is_c_compiler_gcc]
+
 standard_testfile .c
 
 # Using `-gctf` generates full-fledged CTF debug information.
@@ -30,12 +33,6 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
     return 0
 }
 
-# Create and source the file that provides information about the compiler
-# used to compile the test case.
-if [get_compiler_info] {
-    return -1
-}
-
 # Test ptype of unnamed enumeration members before any action causes
 # the partial symbol table to be expanded to full symbols.  This fails
 # with stabs compilers which fail to use a nameless stab (such as
diff --git a/gdb/testsuite/gdb.base/funcargs.exp b/gdb/testsuite/gdb.base/funcargs.exp
index 96448dc2c9a..483fbd94263 100644
--- a/gdb/testsuite/gdb.base/funcargs.exp
+++ b/gdb/testsuite/gdb.base/funcargs.exp
@@ -18,17 +18,13 @@
 
 standard_testfile
 
+set gcc_compiled [is_c_compiler_gcc]
+
 set compile_flags {debug nowarnings quiet}
 if [support_complex_tests] {
     lappend compile_flags "additional_flags=-DTEST_COMPLEX"
 }
 
-# Create and source the file that provides information about the compiler
-# used to compile the test case.
-if [get_compiler_info] {
-    return -1
-}
-
 set skip_float_test [gdb_skip_float_test]
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile $compile_flags]} {
diff --git a/gdb/testsuite/gdb.base/gdb1555.exp b/gdb/testsuite/gdb.base/gdb1555.exp
index 958cca1a63e..c8c86edbc23 100644
--- a/gdb/testsuite/gdb.base/gdb1555.exp
+++ b/gdb/testsuite/gdb.base/gdb1555.exp
@@ -30,11 +30,6 @@ set execsrc "${srcdir}/${subdir}/${srcfile}"
 
 remote_exec build "rm -f ${binfile}"
 
-# get the value of gcc_compiled
-if [get_compiler_info] {
-    return -1
-}
-
 if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
      || [gdb_compile $execsrc ${binfile} executable \
 	     [list debug shlib=${libobj}]] != "" } {
diff --git a/gdb/testsuite/gdb.base/langs.exp b/gdb/testsuite/gdb.base/langs.exp
index 9c78a8a4397..a21ce5ce3c4 100644
--- a/gdb/testsuite/gdb.base/langs.exp
+++ b/gdb/testsuite/gdb.base/langs.exp
@@ -30,13 +30,8 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
 set oldtimeout $timeout
 set timeout 10
 
-
-
-# Create and source the file that provides information about the compiler
-# used to compile the test case.
-if [get_compiler_info] {
-    return -1
-}
+# Some tests require GCC.
+set gcc_compiled [is_c_compiler_gcc]
 
 gdb_test_multiple "b -qualified langs0" "break on nonexistent function in langs.exp" {
 	-re "Function \"langs0\" not defined\..*Make breakpoint pending on future shared library load.*y or .n.. $" {
diff --git a/gdb/testsuite/gdb.base/morestack.exp b/gdb/testsuite/gdb.base/morestack.exp
index 13c7ed1c1fc..31f7d1a72d0 100644
--- a/gdb/testsuite/gdb.base/morestack.exp
+++ b/gdb/testsuite/gdb.base/morestack.exp
@@ -13,12 +13,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-if [get_compiler_info] {
-    return -1
-}
-
-if {$gcc_compiled == 0} {
-    return -1
+if {![is_c_compiler_gcc]} {
+    unsupported "gcc compiler is required"
+    return
 }
 
 standard_testfile
diff --git a/gdb/testsuite/gdb.base/opaque.exp b/gdb/testsuite/gdb.base/opaque.exp
index c3e760ca368..4d7a3257880 100644
--- a/gdb/testsuite/gdb.base/opaque.exp
+++ b/gdb/testsuite/gdb.base/opaque.exp
@@ -15,15 +15,11 @@
 
 # This file was written by Fred Fish. (fnf@cygnus.com)
 
-
-# Create and source the file that provides information about the compiler
-# used to compile the test case.
-if [get_compiler_info] {
-    return -1
-}
-
 standard_testfile opaque0.c opaque1.c
 
+# Some tests require GCC.
+set gcc_compiled [is_c_compiler_gcc]
+
 if {[prepare_for_testing "failed to prepare" $testfile \
 	 [list $srcfile $srcfile2] debug]} {
     return -1
diff --git a/gdb/testsuite/gdb.base/prelink.exp b/gdb/testsuite/gdb.base/prelink.exp
index e0a090e3b78..8145a5b8a68 100644
--- a/gdb/testsuite/gdb.base/prelink.exp
+++ b/gdb/testsuite/gdb.base/prelink.exp
@@ -23,11 +23,8 @@ if { ![isnative] || [is_remote host] || [skip_shlib_tests]} {
     return
 }
 
-if [get_compiler_info] {
-    return -1
-}
-
-if {$gcc_compiled == 0} {
+if {![is_c_compiler_gcc]} {
+    unsupported "gcc compiler is required"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/ptype.exp b/gdb/testsuite/gdb.base/ptype.exp
index 854acc9c457..0fee624d1db 100644
--- a/gdb/testsuite/gdb.base/ptype.exp
+++ b/gdb/testsuite/gdb.base/ptype.exp
@@ -26,11 +26,8 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
     return -1
 }
 
-# Create and source the file that provides information about the compiler
-# used to compile the test case.
-if [get_compiler_info] {
-    return -1
-}
+# Some tests require GCC.
+set gcc_compiled [is_c_compiler_gcc]
 
 # Test ptype of unnamed enumeration members before any action causes
 # the partial symbol table to be expanded to full symbols.  This fails
diff --git a/gdb/testsuite/gdb.base/setvar.exp b/gdb/testsuite/gdb.base/setvar.exp
index 576df2a066c..3d6c5700a49 100644
--- a/gdb/testsuite/gdb.base/setvar.exp
+++ b/gdb/testsuite/gdb.base/setvar.exp
@@ -26,12 +26,6 @@
 
 standard_testfile
 
-# Create and source the file that provides information about the compiler
-# used to compile the test case.
-if [get_compiler_info] {
-    return -1
-}
-
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
     return -1
 }
@@ -395,7 +389,7 @@ set timeout $prev_timeout
 # Test printing of enumeration bitfields.
 # GNU C supports them, some other compilers don't.
 
-if {$gcc_compiled} then {
+if {[is_c_compiler_gcc]} then {
     gdb_test "print sef.field=sm1" ".*.\[0-9\]* = sm1"
     gdb_test "print sef.field" ".*.\[0-9\]* = sm1" "print sef.field (sm1)"
     gdb_test "print sef.field=s1" ".*.\[0-9\]* = s1"
diff --git a/gdb/testsuite/gdb.base/type-opaque.exp b/gdb/testsuite/gdb.base/type-opaque.exp
index 4608bec1e89..6370c995657 100644
--- a/gdb/testsuite/gdb.base/type-opaque.exp
+++ b/gdb/testsuite/gdb.base/type-opaque.exp
@@ -28,11 +28,6 @@ set execsrc "${srcdir}/${subdir}/${srcfile}"
 
 remote_exec build "rm -f ${binfile}"
 
-# get the value of gcc_compiled
-if [get_compiler_info] {
-    return -1
-}
-
 if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
      || [gdb_compile $execsrc ${binfile} executable \
 	     [list debug shlib=${libobj}]] != "" } {
diff --git a/gdb/testsuite/gdb.base/until-trailing-insns.exp b/gdb/testsuite/gdb.base/until-trailing-insns.exp
index ca5b388c0a6..6396b6650c1 100644
--- a/gdb/testsuite/gdb.base/until-trailing-insns.exp
+++ b/gdb/testsuite/gdb.base/until-trailing-insns.exp
@@ -84,12 +84,8 @@ if {![dwarf2_support]} {
     return 0
 }
 
-if [get_compiler_info] {
-    return -1
-}
-
 # The DWARF assembler requires the gcc compiler.
-if {!$gcc_compiled} {
+if {![is_c_compiler_gcc]} {
     unsupported "gcc is required for this test"
     return 0
 }
diff --git a/gdb/testsuite/gdb.base/whatis.exp b/gdb/testsuite/gdb.base/whatis.exp
index d856e336c21..2bce3f5cdcb 100644
--- a/gdb/testsuite/gdb.base/whatis.exp
+++ b/gdb/testsuite/gdb.base/whatis.exp
@@ -25,6 +25,9 @@ if [target_info exists no_long_long] {
     set exec_opts [list debug]
 }
 
+# Some tests require GCC.
+set gcc_compiled [is_c_compiler_gcc]
+
 standard_testfile .c
 
 # Define a procedure to set up an xfail for all targets that put out a
diff --git a/gdb/testsuite/gdb.ctf/funcreturn.exp b/gdb/testsuite/gdb.ctf/funcreturn.exp
index fe4e045d0ce..ea01e860a84 100644
--- a/gdb/testsuite/gdb.ctf/funcreturn.exp
+++ b/gdb/testsuite/gdb.ctf/funcreturn.exp
@@ -24,6 +24,9 @@ if [target_info exists no_long_long] {
     set exec_opts [list debug]
 }
 
+# Some tests require GCC.
+set gcc_compiled [is_c_compiler_gcc]
+
 standard_testfile whatis.c
 
 # Using `-gctf` generates full-fledged CTF debug information.
@@ -34,12 +37,6 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
     return 0
 }
 
-# Create and source the file that provides information about the compiler
-# used to compile the test case.
-if [get_compiler_info] {
-    return -1
-}
-
 # test print command with functions return type
 set void "(void|)"
 gdb_test "print v_char_func" \
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-disasm-over-non-stmt.exp b/gdb/testsuite/gdb.dwarf2/dw2-disasm-over-non-stmt.exp
index 5311dd61a4c..11cc347570a 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-disasm-over-non-stmt.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-disasm-over-non-stmt.exp
@@ -30,10 +30,7 @@ if {![dwarf2_support]} {
 }
 
 # The .c files use __attribute__.
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     return 0
 }
 
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp
index 19f06adef7b..de33da9d8d4 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp
@@ -58,10 +58,7 @@ if {![dwarf2_support]} {
 }
 
 # The .c files use __attribute__.
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     return 0
 }
 
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp
index 198f3553997..25d77263c0a 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp
@@ -53,10 +53,7 @@ if {![dwarf2_support]} {
 }
 
 # The .c files use __attribute__.
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     return 0
 }
 
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp
index 68261aa78b0..fc4b228d5b6 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp
@@ -42,10 +42,7 @@ if {![dwarf2_support]} {
 }
 
 # The .c files use __attribute__.
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     return 0
 }
 
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-many-frames.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-many-frames.exp
index 9055244979d..e4f6b278aea 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-many-frames.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-many-frames.exp
@@ -31,10 +31,7 @@ if {![dwarf2_support]} {
 }
 
 # The .c files use __attribute__.
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     return 0
 }
 
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp
index 05286ad6d2f..a61f1625499 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp
@@ -32,10 +32,7 @@ if {![dwarf2_support]} {
 }
 
 # The .c files use __attribute__.
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     return 0
 }
 
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-stepping.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-stepping.exp
index bd90715c198..b5e8957f107 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-stepping.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-stepping.exp
@@ -31,10 +31,7 @@ if {![dwarf2_support]} {
 }
 
 # The .c files use __attribute__.
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     return 0
 }
 
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp
index 239f5f1d9e9..5176bd34b20 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp
@@ -31,10 +31,7 @@ if {![dwarf2_support]} {
 }
 
 # The .c files use __attribute__.
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     return 0
 }
 
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp b/gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp
index c449757becb..48dae27fa75 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp
@@ -31,10 +31,7 @@ if {![dwarf2_support]} {
 }
 
 # The .c files use __attribute__.
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     return 0
 }
 
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-line-number-zero.exp b/gdb/testsuite/gdb.dwarf2/dw2-line-number-zero.exp
index 0c5eed9814f..4af702ecc4a 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-line-number-zero.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-line-number-zero.exp
@@ -21,10 +21,7 @@ if {![dwarf2_support]} {
 }
 
 # The .c files use __attribute__.
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     verbose "Skipping $gdb_test_file_name."
     return 0
 }
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-main-no-line-number.exp b/gdb/testsuite/gdb.dwarf2/dw2-main-no-line-number.exp
index c8fd729120e..75d85d2a582 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-main-no-line-number.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-main-no-line-number.exp
@@ -25,10 +25,7 @@ if {![dwarf2_support]} {
 }
 
 # The .c files use __attribute__.
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     verbose "Skipping $gdb_test_file_name."
     return 0
 }
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp b/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp
index f030e1edc1f..170500b6045 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp
@@ -25,10 +25,7 @@ if {![dwarf2_support]} {
 }
 
 # The .c files use __attribute__.
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     verbose "Skipping $gdb_test_file_name."
     return 0
 }
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp b/gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp
index 17530c8cc4b..78962d56290 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp
@@ -24,10 +24,7 @@ if {![dwarf2_support]} {
 }
 
 # The .c files use __attribute__.
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     verbose "Skipping $gdb_test_file_name."
     return 0
 }
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ranges-func.exp b/gdb/testsuite/gdb.dwarf2/dw2-ranges-func.exp
index aa95dae6bfc..11f19f141a1 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-ranges-func.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-ranges-func.exp
@@ -22,10 +22,7 @@ if {![dwarf2_support]} {
     return 0
 }
 
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     unsupported "gcc required for this test"
     return 0
 }
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ranges-overlap.exp b/gdb/testsuite/gdb.dwarf2/dw2-ranges-overlap.exp
index 7ef4f5e5b1e..830258d3154 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-ranges-overlap.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-ranges-overlap.exp
@@ -28,10 +28,7 @@ if {![dwarf2_support]} {
 }
 
 # The .c files use __attribute__.
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     verbose "Skipping $gdb_test_file_name."
     return 0
 }
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp b/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp
index 132f1e9f738..824d7ba8085 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp
@@ -23,10 +23,7 @@ if {![dwarf2_support]} {
     return 0
 }
 
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     unsupported "gcc required for this test"
     return 0
 }
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ranges.exp b/gdb/testsuite/gdb.dwarf2/dw2-ranges.exp
index 4c3ae6bbf0a..e2d6d75044c 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-ranges.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-ranges.exp
@@ -24,10 +24,7 @@ if {![dwarf2_support]} {
 }
 
 # The .c files use __attribute__.
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     verbose "Skipping $gdb_test_file_name."
     return 0  
 }
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-step-out-of-function-no-stmt.exp b/gdb/testsuite/gdb.dwarf2/dw2-step-out-of-function-no-stmt.exp
index 29e6858e04b..b2d5763c539 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-step-out-of-function-no-stmt.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-step-out-of-function-no-stmt.exp
@@ -34,10 +34,7 @@ if {![dwarf2_support]} {
 }
 
 # The .c files use __attribute__.
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     verbose "Skipping $gdb_test_file_name."
     return 0
 }
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-vendor-extended-opcode.exp b/gdb/testsuite/gdb.dwarf2/dw2-vendor-extended-opcode.exp
index de8c82bb40c..24299d45459 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-vendor-extended-opcode.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-vendor-extended-opcode.exp
@@ -21,10 +21,7 @@ if {![dwarf2_support]} {
 }
 
 # The .c files use __attribute__.
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     verbose "Skipping $gdb_test_file_name."
     return 0
 }
diff --git a/gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp.tcl b/gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp.tcl
index fe92c530888..aea04be1d6c 100644
--- a/gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp.tcl
+++ b/gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp.tcl
@@ -23,10 +23,7 @@ if {![dwarf2_support]} {
 }
 
 # The .c files use __attribute__.
-if [get_compiler_info] {
-    return -1
-}
-if !$gcc_compiled {
+if ![is_c_compiler_gcc] {
     return 0
 }
 
diff --git a/gdb/testsuite/gdb.threads/tls-shared.exp b/gdb/testsuite/gdb.threads/tls-shared.exp
index fb34677f874..cff80f86049 100644
--- a/gdb/testsuite/gdb.threads/tls-shared.exp
+++ b/gdb/testsuite/gdb.threads/tls-shared.exp
@@ -23,12 +23,6 @@ set binfile_lib [standard_output_file ${libfile}.so]
 
 remote_exec build "rm -f ${binfile}"
 
-# get the value of gcc_compiled
-if [get_compiler_info] {
-    return -1
-}
-
-
 if { [gdb_compile_shlib_pthreads ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} {debug}] != ""
      || [gdb_compile_pthreads ${srcdir}/${subdir}/${srcfile} ${binfile} executable [list debug shlib=${binfile_lib}]] != ""} {
     return -1
diff --git a/gdb/testsuite/gdb.threads/tls-so_extern.exp b/gdb/testsuite/gdb.threads/tls-so_extern.exp
index be6e03fd88d..e6783175904 100644
--- a/gdb/testsuite/gdb.threads/tls-so_extern.exp
+++ b/gdb/testsuite/gdb.threads/tls-so_extern.exp
@@ -22,12 +22,6 @@ set srcfile_lib ${libfile}.c
 set binfile_lib [standard_output_file ${libfile}.so]
 
 
-# get the value of gcc_compiled
-if [get_compiler_info] {
-    return -1
-}
-
-
 if { [gdb_compile_shlib_pthreads ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} {debug}] != ""
      || [gdb_compile_pthreads ${srcdir}/${subdir}/${srcfile} ${binfile} executable [list debug shlib=${binfile_lib}]] != ""} {
     return -1
diff --git a/gdb/testsuite/lib/compiler.c b/gdb/testsuite/lib/compiler.c
index 86140f8c0e7..25316abb407 100644
--- a/gdb/testsuite/lib/compiler.c
+++ b/gdb/testsuite/lib/compiler.c
@@ -27,9 +27,6 @@
    TODO: make compiler_info a local variable for get_compiler_info and
    test_compiler_info.
 
-   TODO: all clients should use test_compiler_info and should not
-   use gcc_compiled.
-
    */
 
 set compiler_info "unknown"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 975e861b0f6..efbe393f72a 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4043,8 +4043,6 @@ if [info exists compiler_info] {
     unset compiler_info
 }
 
-set gcc_compiled		0
-
 # Figure out what compiler I am using.
 # The result is cached so only the first invocation runs the compiler.
 #
@@ -4178,16 +4176,6 @@ proc get_compiler_info {{language "c"}} {
 
     set compiler_info_cache($language) $compiler_info
 
-    # Set the legacy symbol gcc_compiled.
-    if { $language == "c" } {
-	# Legacy global data symbols.
-	gdb_persistent_global gcc_compiled
-
-	set gcc_compiled 0
-
-	regexp "^gcc-(\[0-9\]+)-" "$compiler_info" matchall gcc_compiled
-    }
-
     # Log what happened.
     verbose -log "get_compiler_info: $compiler_info"
 
@@ -4220,6 +4208,15 @@ proc test_compiler_info { {compiler ""} {language "c"} } {
     return [string match $compiler $compiler_info_cache($language)]
 }
 
+# Return true if the C compiler is GCC, otherwise, return false.
+
+proc is_c_compiler_gcc {} {
+    set compiler_info [test_compiler_info]
+    set gcc_compiled false
+    regexp "^gcc-(\[0-9\]+)-" "$compiler_info" matchall gcc_compiled
+    return $gcc_compiled
+}
+
 # Return the gcc major version, or -1.
 # For gcc 4.8.5, the major version is 4.8.
 # For gcc 7.5.0, the major version 7.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-24 14:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-24 14:07 [binutils-gdb] gdb/testsuite: remove global gcc_compiled from gdb.exp Andrew Burgess

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).