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