Clean up testsuite compiler_info support.
authorDoug Evans <dje@google.com>
Fri, 24 Jul 2015 22:32:45 +0000 (15:32 -0700)
committerDoug Evans <dje@google.com>
Fri, 24 Jul 2015 22:32:45 +0000 (15:32 -0700)
gdb/testsuite/ChangeLog:

* gdb.base/watchpoint.exp (test_complex_watchpoint): Remove
compiler_info references.
* gdb.cp/temargs.exp: Ditto.
* lib/gdb.exp: Unset compiler_info instead of setting to "unknown".
(get_compiler_info): Early exit if already computed.  Set compiler_info
to "unknown" if there was a problem.
(test_compiler_info): Add function comment.  Call get_compiler_info.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/watchpoint.exp
gdb/testsuite/gdb.cp/temargs.exp
gdb/testsuite/lib/gdb.exp

index 7f4386e97376fb2b87061f4c941cc2c086c6df71..992d74a72f3652f95298728dbbbdc20fd4679593 100644 (file)
@@ -1,3 +1,13 @@
+2015-07-24  Doug Evans  <dje@google.com>
+
+       * gdb.base/watchpoint.exp (test_complex_watchpoint): Remove
+       compiler_info references.
+       * gdb.cp/temargs.exp: Ditto.
+       * lib/gdb.exp: Unset compiler_info instead of setting to "unknown".
+       (get_compiler_info): Early exit if already computed.  Set compiler_info
+       to "unknown" if there was a problem.
+       (test_compiler_info): Add function comment.  Call get_compiler_info.
+
 2015-07-24  Doug Evans  <dje@google.com>
 
        * Makefile.in (check/%.exp): Pass directory for GDB_PARALLEL.
index b2924d75198e0f7254cb075617420c67a5495520..fcc9a8dd4aad9cce678cff2309ae11681cdb79ad 100644 (file)
@@ -464,12 +464,11 @@ proc test_complex_watchpoint {} {
                pass $test
            }
            -re "can't compute CFA for this frame.*\r\n$gdb_prompt $" {
-               global compiler_info no_hw
+               global no_hw
 
                # GCC < 4.5.0 does not get LOCATIONS_VALID set by dwarf2read.c.
                # Therefore epilogue unwinder gets applied which is
                # incompatible with dwarf2_frame_cfa.
-               verbose -log "compiler_info: $compiler_info"
                if {$no_hw && ([test_compiler_info {gcc-[0-3]-*}]
                               || [test_compiler_info {gcc-4-[0-4]-*}])} {
                    xfail "$test (old GCC has broken watchpoints in epilogues)"
index e5aff51b0af2ed8bb2539aaf35feeb2748a13d72..f086a63935f74decdf7a0aa80bdea7170aff77ae 100644 (file)
@@ -34,7 +34,6 @@ if {![runto_main]} {
 # NOTE: prepare_for_testing calls get_compiler_info, which we need
 # for the test_compiler_info calls.
 # gcc 4.4 and earlier don't emit enough info for some of our template tests.
-verbose -log "compiler_info: $compiler_info"
 set have_older_template_gcc 0
 set have_pr_41736_fixed 1
 set have_pr_45024_fixed 1
index fa0ab096217df75109f12a71e0954e1323252b45..f32d04a3f21b0f3d1081ceed6c31e5db8b0e269f 100644 (file)
@@ -2788,12 +2788,20 @@ gdb_caching_proc target_is_gdbserver {
     return $is_gdbserver
 }
 
-set compiler_info              "unknown"
+# N.B. compiler_info is intended to be local to this file.
+# Call test_compiler_info with no arguments to fetch its value.
+# Yes, this is counterintuitive when there's get_compiler_info,
+# but that's the current API.
+if [info exists compiler_info] {
+    unset compiler_info
+}
+
 set gcc_compiled               0
 set hp_cc_compiler             0
 set hp_aCC_compiler            0
 
 # Figure out what compiler I am using.
+# The result is cached so only the first invocation runs the compiler.
 #
 # ARG can be empty or "C++".  If empty, "C" is assumed.
 #
@@ -2860,6 +2868,11 @@ proc get_compiler_info {{arg ""}} {
     global hp_cc_compiler
     global hp_aCC_compiler
 
+    if [info exists compiler_info] {
+       # Already computed.
+       return 0
+    }
+
     # Choose which file to preprocess.
     set ifile "${srcdir}/lib/compiler.c"
     if { $arg == "c++" } {
@@ -2901,8 +2914,14 @@ proc get_compiler_info {{arg ""}} {
        }
     }
 
-    # Reset to unknown compiler if any diagnostics happened.
+    # Set to unknown if for some reason compiler_info didn't get defined.
+    if ![info exists compiler_info] {
+       verbose -log "get_compiler_info: compiler_info not provided"
+       set compiler_info "unknown"
+    }
+    # Also set to unknown compiler if any diagnostics happened.
     if { $unknown } {
+       verbose -log "get_compiler_info: got unexpected diagnostics"
        set compiler_info "unknown"
     }
 
@@ -2936,18 +2955,18 @@ proc get_compiler_info {{arg ""}} {
     return 0
 }
 
+# Return the compiler_info string if no arg is provided.
+# Otherwise the argument is a glob-style expression to match against
+# compiler_info.
+
 proc test_compiler_info { {compiler ""} } {
     global compiler_info
+    get_compiler_info
 
-     # if no arg, return the compiler_info string
-
-     if [string match "" $compiler] {
-         if [info exists compiler_info] {
-             return $compiler_info
-         } else {
-             perror "No compiler info found."
-         }
-     }
+    # If no arg, return the compiler_info string.
+    if [string match "" $compiler] {
+       return $compiler_info
+    }
 
     return [string match $compiler $compiler_info]
 }