1 # This testcase is part of GDB, the GNU debugger. 2 # 3 # Copyright 2016-2024 Free Software Foundation, Inc. 4 # 5 # Contributed by Intel Corp. <tim.wiederhake (at) intel.com> 6 # 7 # This program is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 3 of the License, or 10 # (at your option) any later version. 11 # 12 # This program is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 19 20 load_lib gdbserver-support.exp 21 22 require allow_btrace_tests 23 require allow_gdbserver_tests 24 25 standard_testfile 26 if [prepare_for_testing "failed to prepare" $testfile $srcfile] { 27 return -1 28 } 29 30 set target_binfile [gdb_remote_download target $binfile] 31 32 # Make sure we're disconnected and no recording is active, in case 33 # we're testing with an extended-remote board, therefore already 34 # connected. 35 with_test_prefix "preparation" { 36 gdb_test "record stop" ".*" 37 gdb_test "disconnect" ".*" 38 } 39 40 # Start fresh gdbserver. 41 set gdbserver_reconnect_p 1 42 set res [gdbserver_start "" $target_binfile] 43 set gdbserver_protocol [lindex $res 0] 44 set gdbserver_gdbport [lindex $res 1] 45 gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport 46 47 # Create a record, check, reconnect 48 with_test_prefix "first" { 49 gdb_test_no_output "record btrace" "record btrace enable" 50 gdb_test "stepi 19" ".*" 51 52 gdb_test "info record" [multi_line \ 53 "Active record target: .*" \ 54 "Recorded 19 instructions in .+ functions \\(. gaps\\) for thread 1 \\(Thread .*\\)." 55 ] 56 57 gdb_test "disconnect" "Ending remote debugging." 58 gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport 59 } 60 61 # Test if we can access the recorded data from first connect. 62 # Note: BTS loses the first function call entry with its associated 63 # instructions for technical reasons. This is why we test for 64 # "a number between 10 and 19", so we catch at least the case where 65 # there are 0 instructions in the record. 66 with_test_prefix "second" { 67 gdb_test "info record" [multi_line \ 68 "Active record target: .*" \ 69 "Recorded 1. instructions in .+ functions \\(. gaps\\) for thread 1 \\(Thread .*\\)." 70 ] 71 72 gdb_test "record stop" "Process record is stopped and all execution logs are deleted." 73 74 gdb_test "disconnect" "Ending remote debugging." 75 gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport 76 } 77 78 # Test that recording is now off. 79 with_test_prefix "third" { 80 gdb_test "info record" "No recording is currently active." 81 } 82