Home | History | Annotate | Line # | Download | only in gdb.rocm
      1 # Copyright 2021-2024 Free Software Foundation, Inc.
      2 
      3 # This file is part of GDB.
      4 
      5 # This program is free software; you can redistribute it and/or modify
      6 # it under the terms of the GNU General Public License as published by
      7 # the Free Software Foundation; either version 3 of the License, or
      8 # (at your option) any later version.
      9 
     10 # This program is distributed in the hope that it will be useful,
     11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 # GNU General Public License for more details.
     14 
     15 # You should have received a copy of the GNU General Public License
     16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17 
     18 # Test that the "set amdgpu precise-memory" setting is per-inferior, and
     19 # inherited by an inferior created using the clone-inferior command.
     20 
     21 load_lib rocm.exp
     22 
     23 require allow_hipcc_tests
     24 
     25 clean_restart
     26 
     27 set test_python [allow_python_tests]
     28 
     29 proc test_per_inferior { } {
     30     gdb_test "show amdgpu precise-memory" \
     31 	"AMDGPU precise memory access reporting is off \\(currently disabled\\)." \
     32 	"show initial value, inferior 1"
     33     if $::test_python {
     34 	gdb_test "python print(gdb.parameter(\"amdgpu precise-memory\"))" \
     35 	    "False" \
     36 	    "show initial value using Python, inferior 1"
     37     }
     38     gdb_test_no_output "set amdgpu precise-memory" \
     39 	"set on inferior 1"
     40     gdb_test "show amdgpu precise-memory" \
     41 	"AMDGPU precise memory access reporting is on \\(currently disabled\\)." \
     42 	"show new value, inferior 1"
     43     if $::test_python {
     44 	gdb_test "python print(gdb.parameter(\"amdgpu precise-memory\"))" \
     45 	    "True" \
     46 	    "show new value using Python, inferior 1"
     47     }
     48 
     49     gdb_test "add-inferior" "Added inferior 2"
     50     gdb_test "inferior 2" "Switching to inferior 2 .*"
     51 
     52     gdb_test "show amdgpu precise-memory" \
     53 	"AMDGPU precise memory access reporting is off \\(currently disabled\\)." \
     54 	"show initial value, inferior 2"
     55     if $::test_python {
     56 	gdb_test "python print(gdb.parameter(\"amdgpu precise-memory\"))" \
     57 	    "False" \
     58 	    "show initial value using Python, inferior 2"
     59     }
     60 }
     61 
     62 proc test_copy_precise_memory_on_clone {precise_memory} {
     63     set value $precise_memory
     64     if {$precise_memory == "unspecified"} {
     65 	set value off
     66     }
     67 
     68     clean_restart
     69     gdb_test "show amdgpu precise-memory" "is off.*" \
     70 	"show default amdgpu precise-memory"
     71     if {$precise_memory != "unspecified"} {
     72 	gdb_test_no_output "set amdgpu precise-memory $value"
     73 	gdb_test "show amdgpu precise-memory" "is $value.*" \
     74 		 "show amdgpu precise-memory on original inferior"
     75     }
     76 
     77     gdb_test "clone-inferior" "Added inferior 2.*"
     78     gdb_test "inferior 2"
     79     gdb_test "show amdgpu precise-memory" "is $value.*" \
     80 	"show amdgpu precise-memory on cloned inferior"
     81 }
     82 
     83 test_per_inferior
     84 
     85 foreach_with_prefix precise_memory { unspecified on off } {
     86     test_copy_precise_memory_on_clone $precise_memory
     87 }
     88