1 1.1 christos # Copyright 2022-2024 Free Software Foundation, Inc. 2 1.1 christos 3 1.1 christos # This program is free software; you can redistribute it and/or modify 4 1.1 christos # it under the terms of the GNU General Public License as published by 5 1.1 christos # the Free Software Foundation; either version 3 of the License, or 6 1.1 christos # (at your option) any later version. 7 1.1 christos # 8 1.1 christos # This program is distributed in the hope that it will be useful, 9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 1.1 christos # GNU General Public License for more details. 12 1.1 christos # 13 1.1 christos # You should have received a copy of the GNU General Public License 14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 1.1 christos 16 1.1 christos # This file is part of the GDB testsuite. It tests the functionality of 17 1.1 christos # the maintenance print record-instruction command, but does not check the 18 1.1 christos # syntax, only if the command finds or fails to find recorded history. 19 1.1 christos # This is done by putting the inferior in mulpitle states with and without 20 1.1 christos # history to be printed, then checking if GDB is able to print an 21 1.1 christos # instruction or not. 22 1.1 christos # To identify if GDB has printed an instruction, we can see if some 23 1.1 christos # change is printed, since any instruction must have at least a change 24 1.1 christos # to the PC. 25 1.1 christos 26 1.1 christos if ![supports_reverse] { 27 1.1 christos return 28 1.1 christos } 29 1.1 christos 30 1.1 christos standard_testfile 31 1.1 christos 32 1.1 christos if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { 33 1.1 christos return -1 34 1.1 christos } 35 1.1 christos 36 1.1 christos proc test_print { has_history level test_name } { 37 1.1 christos gdb_test_multiple "maint print record-instruction $level" $test_name { 38 1.1 christos -re -wrap ".*Not enough recorded history.*" { 39 1.1 christos gdb_assert !$has_history $test_name 40 1.1 christos } 41 1.1 christos 42 1.1 christos -re -wrap ".*changed.*" { 43 1.1 christos gdb_assert $has_history $test_name 44 1.1 christos } 45 1.1 christos } 46 1.1 christos } 47 1.1 christos 48 1.1 christos if { ![runto_main] } { 49 1.1 christos return 0 50 1.1 christos } 51 1.1 christos 52 1.1 christos #confirm that GDB doesn't go crazy if recording isn't enabled 53 1.1 christos test_print false "" "print before starting to record" 54 1.1 christos 55 1.1 christos if ![supports_process_record] { 56 1.1 christos # No point in testing the rest if we can't record anything 57 1.1 christos return 58 1.1 christos } 59 1.1 christos 60 1.1 christos gdb_test_no_output "record" "turn on process record" 61 1.1 christos 62 1.1 christos test_print false "" "print before any instruction" 63 1.1 christos 64 1.1 christos gdb_test "stepi 3" ".*" "collecting history" 65 1.1 christos test_print true "" "print current after executing a bit" 66 1.1 christos test_print true "-1" "print previous after executing a bit" 67 1.1 christos test_print false "1" "print following after executing a bit" 68 1.1 christos 69 1.1 christos gdb_test "reverse-stepi" ".*" "moving back" 70 1.1 christos test_print true "" "print current after reversing" 71 1.1 christos test_print true "-1" "print previous after reversing" 72 1.1 christos test_print true "1" "print following after reversing" 73 1.1 christos 74 1.1 christos test_print false "-10" "trying to print too far back" 75 1.1 christos test_print false "10" "trying to print too far forward" 76