1 # Copyright 2022-2024 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file is part of the GDB testsuite. It tests the functionality of
17 # the maintenance print record-instruction command, but does not check the
18 # syntax, only if the command finds or fails to find recorded history.
19 # This is done by putting the inferior in mulpitle states with and without
20 # history to be printed, then checking if GDB is able to print an
22 # To identify if GDB has printed an instruction, we can see if some
23 # change is printed, since any instruction must have at least a change
26 if ![supports_reverse] {
32 if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
36 proc test_print { has_history level test_name } {
37 gdb_test_multiple "maint print record-instruction $level" $test_name {
38 -re -wrap ".*Not enough recorded history.*" {
39 gdb_assert !$has_history $test_name
42 -re -wrap ".*changed.*" {
43 gdb_assert $has_history $test_name
48 if { ![runto_main] } {
52 #confirm that GDB doesn't go crazy if recording isn't enabled
53 test_print false "" "print before starting to record"
55 if ![supports_process_record] {
56 # No point in testing the rest if we can't record anything
60 gdb_test_no_output "record" "turn on process record"
62 test_print false "" "print before any instruction"
64 gdb_test "stepi 3" ".*" "collecting history"
65 test_print true "" "print current after executing a bit"
66 test_print true "-1" "print previous after executing a bit"
67 test_print false "1" "print following after executing a bit"
69 gdb_test "reverse-stepi" ".*" "moving back"
70 test_print true "" "print current after reversing"
71 test_print true "-1" "print previous after reversing"
72 test_print true "1" "print following after reversing"
74 test_print false "-10" "trying to print too far back"
75 test_print false "10" "trying to print too far forward"