--- /dev/null
+# Copyright 2012, 2013 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+# The in-memory cache.
+array set gdb_data_cache {}
+
+# A helper for gdb_caching_proc that handles the caching.
+
+proc gdb_do_cache {name} {
+ global gdb_data_cache objdir
+
+ # See if some other process wrote the cache file. Cache value per
+ # "board" to handle runs with multiple options
+ # (e.g. unix/{-m32,-64}) correctly. We use "file join" here
+ # because we later use this in a real filename.
+ set cache_name [file join [target_info name] $name]
+
+ if {[info exists gdb_data_cache($cache_name)]} {
+ verbose "$name: returning '$gdb_data_cache($cache_name)' from cache" 2
+ return $gdb_data_cache($cache_name)
+ }
+
+ set real_name gdb_real__$name
+ set gdb_data_cache($cache_name) [uplevel 1 $real_name]
+
+ return $gdb_data_cache($cache_name)
+}
+
+# Define a new proc named NAME that takes no arguments. BODY is the
+# body of the proc. The proc will evaluate BODY and cache the
+# results, both in memory and, if GDB_PARALLEL is defined, in the
+# filesystem for use across invocations of dejagnu.
+
+proc gdb_caching_proc {name body} {
+ # Define the underlying proc that we'll call.
+ set real_name gdb_real__$name
+ proc $real_name {} $body
+
+ # Define the advertised proc.
+ proc $name {} [list gdb_do_cache $name]
+}
}
load_lib libgloss.exp
+load_lib cache.exp
global GDB
# Return 1 if _Complex types are supported, otherwise, return 0.
-proc support_complex_tests {} {
- global support_complex_tests_saved
-
- # Use the cached value, if it exists.
- if [info exists support_complex_tests_saved] {
- verbose "returning saved $support_complex_tests_saved" 2
- return $support_complex_tests_saved
- }
-
+gdb_caching_proc support_complex_tests {
# Set up, compile, and execute a test program containing _Complex types.
# Include the current process ID in the file names to prevent conflicts
# with invocations for multiple testsuites.
if ![string match "" $lines] then {
verbose "testfile compilation failed, returning 0" 2
- set support_complex_tests_saved 0
+ set result 0
} else {
- set support_complex_tests_saved 1
+ set result 1
}
- return $support_complex_tests_saved
+ return $result
}
# Return 1 if target hardware or OS supports single stepping to signal
# Return 1 if target is ILP32.
# This cannot be decided simply from looking at the target string,
# as it might depend on externally passed compiler options like -m64.
-proc is_ilp32_target {} {
- global is_ilp32_target_saved
-
- # Use the cached value, if it exists. Cache value per "board" to handle
- # runs with multiple options (e.g. unix/{-m32,-64}) correctly.
+gdb_caching_proc is_ilp32_target {
set me "is_ilp32_target"
- set board [target_info name]
- if [info exists is_ilp32_target_saved($board)] {
- verbose "$me: returning saved $is_ilp32_target_saved($board)" 2
- return $is_ilp32_target_saved($board)
- }
-
set src [standard_temp_file ilp32[pid].c]
set obj [standard_temp_file ilp32[pid].o]
if ![string match "" $lines] then {
verbose "$me: testfile compilation failed, returning 0" 2
- return [set is_ilp32_target_saved($board) 0]
+ return 0
}
verbose "$me: returning 1" 2
- return [set is_ilp32_target_saved($board) 1]
+ return 1
}
# Return 1 if target is LP64.
# This cannot be decided simply from looking at the target string,
# as it might depend on externally passed compiler options like -m64.
-proc is_lp64_target {} {
- global is_lp64_target_saved
-
- # Use the cached value, if it exists. Cache value per "board" to handle
- # runs with multiple options (e.g. unix/{-m32,-64}) correctly.
+gdb_caching_proc is_lp64_target {
set me "is_lp64_target"
- set board [target_info name]
- if [info exists is_lp64_target_saved($board)] {
- verbose "$me: returning saved $is_lp64_target_saved($board)" 2
- return $is_lp64_target_saved($board)
- }
set src [standard_temp_file lp64[pid].c]
set obj [standard_temp_file lp64[pid].o]
if ![string match "" $lines] then {
verbose "$me: testfile compilation failed, returning 0" 2
- return [set is_lp64_target_saved($board) 0]
+ return 0
}
verbose "$me: returning 1" 2
- return [set is_lp64_target_saved($board) 1]
+ return 1
}
# Return 1 if target has x86_64 registers - either amd64 or x32.
# x32 target identifies as x86_64-*-linux*, therefore it cannot be determined
# just from the target string.
-proc is_amd64_regs_target {} {
- global is_amd64_regs_target_saved
-
+gdb_caching_proc is_amd64_regs_target {
if {![istarget "x86_64-*-*"] && ![istarget "i?86-*"]} {
return 0
}
- # Use the cached value, if it exists. Cache value per "board" to handle
- # runs with multiple options (e.g. unix/{-m32,-64}) correctly.
set me "is_amd64_regs_target"
- set board [target_info name]
- if [info exists is_amd64_regs_target_saved($board)] {
- verbose "$me: returning saved $is_amd64_regs_target_saved($board)" 2
- return $is_amd64_regs_target_saved($board)
- }
set src [standard_temp_file reg64[pid].s]
set obj [standard_temp_file reg64[pid].o]
if ![string match "" $lines] then {
verbose "$me: testfile compilation failed, returning 0" 2
- return [set is_amd64_regs_target_saved($board) 0]
+ return 0
}
verbose "$me: returning 1" 2
- return [set is_amd64_regs_target_saved($board) 1]
+ return 1
}
# Return 1 if this target is an x86 or x86-64 with -m32.
# Run a test on the target to see if it supports vmx hardware. Return 0 if so,
# 1 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.
-proc skip_altivec_tests {} {
- global skip_vmx_tests_saved
+gdb_caching_proc skip_altivec_tests {
global srcdir subdir gdb_prompt inferior_exited_re
- # Use the cached value, if it exists.
set me "skip_altivec_tests"
- if [info exists skip_vmx_tests_saved] {
- verbose "$me: returning saved $skip_vmx_tests_saved" 2
- return $skip_vmx_tests_saved
- }
# Some simulators are known to not support VMX instructions.
if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
verbose "$me: target known to not support VMX, returning 1" 2
- return [set skip_vmx_tests_saved 1]
+ return 1
}
# Make sure we have a compiler that understands altivec.
if ![string match "" $lines] then {
verbose "$me: testfile compilation failed, returning 1" 2
- return [set skip_vmx_tests_saved 1]
+ return 1
}
# No error message, compilation succeeded so now run it via gdb.
gdb_expect {
-re ".*Illegal instruction.*${gdb_prompt} $" {
verbose -log "\n$me altivec hardware not detected"
- set skip_vmx_tests_saved 1
+ set skip_vmx_tests 1
}
-re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
verbose -log "\n$me: altivec hardware detected"
- set skip_vmx_tests_saved 0
+ set skip_vmx_tests 0
}
default {
warning "\n$me: default case taken"
- set skip_vmx_tests_saved 1
+ set skip_vmx_tests 1
}
}
gdb_exit
remote_file build delete $exe
- verbose "$me: returning $skip_vmx_tests_saved" 2
- return $skip_vmx_tests_saved
+ verbose "$me: returning $skip_vmx_tests" 2
+ return $skip_vmx_tests
}
# Run a test on the target to see if it supports vmx hardware. Return 0 if so,
# 1 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.
-proc skip_vsx_tests {} {
- global skip_vsx_tests_saved
+gdb_caching_proc skip_vsx_tests {
global srcdir subdir gdb_prompt inferior_exited_re
- # Use the cached value, if it exists.
set me "skip_vsx_tests"
- if [info exists skip_vsx_tests_saved] {
- verbose "$me: returning saved $skip_vsx_tests_saved" 2
- return $skip_vsx_tests_saved
- }
# Some simulators are known to not support Altivec instructions, so
# they won't support VSX instructions as well.
if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
verbose "$me: target known to not support VSX, returning 1" 2
- return [set skip_vsx_tests_saved 1]
+ return 1
}
# Make sure we have a compiler that understands altivec.
if ![string match "" $lines] then {
verbose "$me: testfile compilation failed, returning 1" 2
- return [set skip_vsx_tests_saved 1]
+ return 1
}
# No error message, compilation succeeded so now run it via gdb.
gdb_expect {
-re ".*Illegal instruction.*${gdb_prompt} $" {
verbose -log "\n$me VSX hardware not detected"
- set skip_vsx_tests_saved 1
+ set skip_vsx_tests 1
}
-re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
verbose -log "\n$me: VSX hardware detected"
- set skip_vsx_tests_saved 0
+ set skip_vsx_tests 0
}
default {
warning "\n$me: default case taken"
- set skip_vsx_tests_saved 1
+ set skip_vsx_tests 1
}
}
gdb_exit
remote_file build delete $exe
- verbose "$me: returning $skip_vsx_tests_saved" 2
- return $skip_vsx_tests_saved
+ verbose "$me: returning $skip_vsx_tests" 2
+ return $skip_vsx_tests
}
# Run a test on the target to see if it supports btrace hardware. Return 0 if so,
# in the host GDB.
# NOTE: This must be called while gdb is *not* running.
-proc gdb_skip_xml_test { } {
+gdb_caching_proc gdb_skip_xml_test {
global gdb_prompt
global srcdir
- global xml_missing_cached
-
- if {[info exists xml_missing_cached]} {
- return $xml_missing_cached
- }
gdb_start
- set xml_missing_cached 0
+ set xml_missing 0
gdb_test_multiple "set tdesc filename ${srcdir}/gdb.xml/trivial.xml" "" {
-re ".*XML support was disabled at compile time.*$gdb_prompt $" {
- set xml_missing_cached 1
+ set xml_missing 1
}
-re ".*$gdb_prompt $" { }
}
gdb_exit
- return $xml_missing_cached
+ return $xml_missing
}
# Note: the procedure gdb_gnu_strip_debug will produce an executable called
# Run a test on the target to check if it supports OpenCL. Return 0 if so, 1 if
# it does not.
-proc skip_opencl_tests {} {
- global skip_opencl_tests_saved srcdir objdir subdir gdb_prompt
+gdb_caching_proc skip_opencl_tests {
+ global srcdir objdir subdir gdb_prompt
global inferior_exited_re
- # Use the cached value, if it exists. Cache value per "board" to handle
- # runs with multiple options (e.g. unix/{-m32,-64}) correctly.
set me "skip_opencl_tests"
- set board [target_info name]
- if [info exists skip_opencl_tests_saved($board)] {
- verbose "$me: returning saved $skip_opencl_tests_saved($board)" 2
- return $skip_opencl_tests_saved($board)
- }
# Set up, compile, and execute an OpenCL program. Include the current
# process ID in the file name of the executable to prevent conflicts with
set compile_flags {debug nowarnings quiet}
if { [gdb_compile_opencl_hostapp "${clprogram}" "${executable}" "${compile_flags}" ] != "" } {
+ remote_file target delete ${clprogram}
verbose "$me: compiling OpenCL binary failed, returning 1" 2
- return [set skip_opencl_tests_saved($board) 1]
+ return 1
}
# Compilation succeeded so now run it via gdb.
gdb_expect 30 {
-re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
verbose -log "\n$me: OpenCL support detected"
- set skip_opencl_tests_saved($board) 0
+ set result 0
}
-re ".*$inferior_exited_re code.*${gdb_prompt} $" {
verbose -log "\n$me: OpenCL support not detected"
- set skip_opencl_tests_saved($board) 1
+ set result 1
}
default {
verbose -log "\n$me OpenCL support not detected (default case)"
- set skip_opencl_tests_saved($board) 1
+ set result 1
}
}
gdb_exit
# Delete the OpenCL program source file.
remote_file target delete ${clprogram}
- verbose "$me: returning $skip_opencl_tests_saved($board)" 2
- return $skip_opencl_tests_saved($board)
+ verbose "$me: returning $result" 2
+ return $result
}