global gdb_data_cache objdir
global GDB_PARALLEL
+ # Normally, if we have a cached value, we skip computation and return
+ # the cached value. If set to 1, instead don't skip computation and
+ # verify against the cached value.
+ set cache_verify 0
+
+ # Alternatively, set this to do cache_verify only for one proc.
+ set cache_verify_proc ""
+ if { $name == $cache_verify_proc } {
+ set cache_verify 1
+ }
+
# 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]
+ set is_cached 0
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 cached $gdb_data_cache($cache_name)
+ verbose "$name: returning '$cached' from cache" 2
+ if { $cache_verify == 0 } {
+ return $cached
+ }
+ set is_cached 1
}
- if {[info exists GDB_PARALLEL]} {
+ if { $is_cached == 0 && [info exists GDB_PARALLEL] } {
set cache_filename [make_gdb_parallel_path cache $cache_name]
if {[file exists $cache_filename]} {
set fd [open $cache_filename]
set gdb_data_cache($cache_name) [read -nonewline $fd]
close $fd
- verbose "$name: returning '$gdb_data_cache($cache_name)' from file cache" 2
- return $gdb_data_cache($cache_name)
+ set cached $gdb_data_cache($cache_name)
+ verbose "$name: returning '$cached' from file cache" 2
+ if { $cache_verify == 0 } {
+ return $cached
+ }
+ set is_cached 1
}
}
set real_name gdb_real__$name
set gdb_data_cache($cache_name) [gdb_do_cache_wrap $real_name]
+ if { $cache_verify == 1 && $is_cached == 1 } {
+ set computed $gdb_data_cache($cache_name)
+ if { $cached != $computed } {
+ error [join [list "Inconsistent results for $cache_name:"
+ "cached: $cached vs. computed: $computed"]]
+ }
+ }
if {[info exists GDB_PARALLEL]} {
verbose "$name: returning '$gdb_data_cache($cache_name)' and writing file" 2