aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2015-07-24 15:32:45 -0700
committerDoug Evans <dje@google.com>2015-07-24 15:32:45 -0700
commita97b16b8fcfc7ac818c43c9f9457966cfc47aed6 (patch)
treeea09d448807ddfa5690e799a26931764f64a6294 /gdb/testsuite/lib
parent35baa57fcfb50f7db24f7850ec9e34f4bc25b45c (diff)
downloadgdb-a97b16b8fcfc7ac818c43c9f9457966cfc47aed6.zip
gdb-a97b16b8fcfc7ac818c43c9f9457966cfc47aed6.tar.gz
gdb-a97b16b8fcfc7ac818c43c9f9457966cfc47aed6.tar.bz2
Clean up testsuite compiler_info support.
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.
Diffstat (limited to 'gdb/testsuite/lib')
-rw-r--r--gdb/testsuite/lib/gdb.exp41
1 files changed, 30 insertions, 11 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index fa0ab09..f32d04a 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -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]
}