diff options
author | Tom de Vries <tdevries@suse.de> | 2023-08-04 15:05:57 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2023-08-04 15:05:57 +0200 |
commit | 1f83e2cd3f512f68751b76d1cb5dd1e38a5a2fbf (patch) | |
tree | d113f1ce36fe605d02c620d548dc9e31c3bb5da5 | |
parent | 0961970dea995ce9f8750bd615a534bbbd23cefd (diff) | |
download | binutils-1f83e2cd3f512f68751b76d1cb5dd1e38a5a2fbf.zip binutils-1f83e2cd3f512f68751b76d1cb5dd1e38a5a2fbf.tar.gz binutils-1f83e2cd3f512f68751b76d1cb5dd1e38a5a2fbf.tar.bz2 |
[gdb/testsuite] Move "maint wait-for-index-cache" ALAP in gdb.base/index-cache.exp
In test-case gdb.base/index-cache.exp proc run_test_with_flags contains:
...
clean_restart ${testfile}
# The tests generally want to check the cache, so make sure it
# has completed its work.
gdb_test_no_output "maintenance wait-for-index-cache"
...
This however hides data races between:
- index-cache writing (due to file $exec), and
- symbol lookups (due to subsequent ptype commands).
Fix this by:
- moving the "maintenance wait-for-index-cache" to proc check_cache_stats, and
- moving all calls to proc check_cache_stats ALAP.
Tested on x86_64-linux.
-rw-r--r-- | gdb/testsuite/gdb.base/index-cache.exp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/gdb/testsuite/gdb.base/index-cache.exp b/gdb/testsuite/gdb.base/index-cache.exp index c26c4f9..1379a04 100644 --- a/gdb/testsuite/gdb.base/index-cache.exp +++ b/gdb/testsuite/gdb.base/index-cache.exp @@ -65,6 +65,10 @@ proc ls_host { dir } { # values. proc check_cache_stats { expected_hits expected_misses } { + # This test wants to check the cache, so make sure it has completed + # its work. + gdb_test_no_output "maintenance wait-for-index-cache" + set re [multi_line \ " Cache hits .this session.: $expected_hits" \ "Cache misses .this session.: $expected_misses" \ @@ -84,10 +88,6 @@ proc run_test_with_flags { cache_dir cache_enabled code } { clean_restart ${testfile} - # The tests generally want to check the cache, so make sure it - # has completed its work. - gdb_test_no_output "maintenance wait-for-index-cache" - uplevel 1 $code } } @@ -146,13 +146,13 @@ proc_with_prefix test_cache_disabled { cache_dir test_prefix } { set nfiles_created [expr [llength $files_after] - [llength $files_before]] gdb_assert "$nfiles_created == 0" "no files were created" - check_cache_stats 0 0 - # Trigger expansion of symtab containing main, if not already done. gdb_test "ptype main" "^type = int \\(void\\)" # Trigger expansion of symtab not containing main. gdb_test "ptype foo" "^type = int \\(void\\)" + + check_cache_stats 0 0 } } } @@ -193,17 +193,17 @@ proc_with_prefix test_cache_enabled_miss { cache_dir } { remote_exec host rm "-f $cache_dir/$expected_created_file" - if { $expecting_index_cache_use } { - check_cache_stats 0 1 - } else { - check_cache_stats 0 0 - } - # Trigger expansion of symtab containing main, if not already done. gdb_test "ptype main" "^type = int \\(void\\)" # Trigger expansion of symtab not containing main. gdb_test "ptype foo" "^type = int \\(void\\)" + + if { $expecting_index_cache_use } { + check_cache_stats 0 1 + } else { + check_cache_stats 0 0 + } } } @@ -228,17 +228,17 @@ proc_with_prefix test_cache_enabled_hit { cache_dir } { set nfiles_created [expr [llength $files_after] - [llength $files_before]] gdb_assert "$nfiles_created == 0" "no files were created" - if { $expecting_index_cache_use } { - check_cache_stats 1 0 - } else { - check_cache_stats 0 0 - } - # Trigger expansion of symtab containing main, if not already done. gdb_test "ptype main" "^type = int \\(void\\)" # Trigger expansion of symtab not containing main. gdb_test "ptype foo" "^type = int \\(void\\)" + + if { $expecting_index_cache_use } { + check_cache_stats 1 0 + } else { + check_cache_stats 0 0 + } } } |