Home | History | Annotate | Line # | Download | only in gdb.reverse
      1 # Copyright 2022-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 # This file is part of the gdb testsuite.
     17 
     18 #
     19 # This test tests getrandom syscall for reverse execution.
     20 #
     21 
     22 require supports_reverse
     23 require {have_system_header sys/random.h}
     24 
     25 standard_testfile
     26 
     27 if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
     28     return -1
     29 }
     30 
     31 runto_main
     32 
     33 if [supports_process_record] {
     34     # Activate process record/replay
     35     gdb_test_no_output "record" "turn on process record"
     36 }
     37 
     38 gdb_test "break marker2" \
     39     "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
     40     "set breakpoint at marker2"
     41 
     42 gdb_continue_to_breakpoint "marker2" ".*$srcfile:.*"
     43 
     44 gdb_test "break marker1" \
     45     "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
     46     "set breakpoint at marker1"
     47 
     48 gdb_test "reverse-continue" ".*$srcfile:$decimal.*" "reverse to marker1"
     49 
     50 gdb_test "print (unsigned)buf\[0\]" ".* = 255" "check buf\[0\]"
     51 gdb_test "print (unsigned)buf\[1\]" ".* = 0" "check buf\[1\]"
     52 gdb_test "print (unsigned)buf\[2\]" ".* = 0" "check buf\[2\]"
     53 gdb_test "print (unsigned)buf\[3\]" ".* = 0" "check buf\[3\]"
     54 gdb_test "print (unsigned)buf\[4\]" ".* = 0" "check buf\[4\]"
     55 gdb_test "print (unsigned)buf\[5\]" ".* = 255" "check buf\[5\]"
     56