Home | History | Annotate | Line # | Download | only in gdb.base
      1 # Copyright 2020-2024 Free Software Foundation, Inc.
      2 
      3 # This program is free software; you can redistribute it and/or modify
      4 # it under the terms of the GNU General Public License as published by
      5 # the Free Software Foundation; either version 3 of the License, or
      6 # (at your option) any later version.
      7 #
      8 # This program is distributed in the hope that it will be useful,
      9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11 # GNU General Public License for more details.
     12 #
     13 # You should have received a copy of the GNU General Public License
     14 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15 
     16 # Test that the dcache can be flushed.
     17 
     18 standard_testfile
     19 
     20 if { [prepare_for_testing "failed to prepare" ${testfile}] } {
     21     return -1
     22 }
     23 
     24 if ![runto func] {
     25     return -1
     26 }
     27 
     28 gdb_test "up" ".* main .*"
     29 gdb_test "p var1" " = 4"
     30 gdb_test "p var2" " = 3"
     31 
     32 # By reading var1 and var2 we should have at least one line in the
     33 # dcache.
     34 gdb_test "info dcache" \
     35     [multi_line \
     36 	 "Dcache $decimal lines of $decimal bytes each." \
     37 	 "Contains data for (process $decimal|Thread \[^\r\n\]*)" \
     38 	 "Line 0: address $hex \[$decimal hits\].*" \
     39 	 "Cache state: $decimal active lines, $decimal hits" ] \
     40     "check dcache before flushing"
     41 
     42 # Flush the dcache.
     43 gdb_test "maint flush dcache" "The dcache was flushed\."
     44 
     45 # Check the dcache is now empty.
     46 gdb_test "info dcache" \
     47     [multi_line  "Dcache $decimal lines of $decimal bytes each." \
     48 	 "No data cache available." ] \
     49     "check dcache after flushing"
     50 
     51 # Read the stack variables again, refilling the dcache.
     52 with_test_prefix "refilling" {
     53     gdb_test "p var1" " = 4"
     54     gdb_test "p var2" " = 3"
     55 }
     56 
     57 # And check we have some content back in the dcache.
     58 gdb_test "info dcache" \
     59     [multi_line \
     60 	 "Dcache $decimal lines of $decimal bytes each." \
     61 	 "Contains data for (process $decimal|Thread \[^\r\n\]*)" \
     62 	 "Line 0: address $hex \[$decimal hits\].*" \
     63 	 "Cache state: $decimal active lines, $decimal hits" ] \
     64     "check dcache before refilling"
     65