1# This testcase is part of GDB, the GNU debugger. 2# 3# Copyright 2013-2023 Free Software Foundation, Inc. 4# 5# Contributed by Intel Corp. <christian.himpel@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 20if { [skip_btrace_tests] } { 21 unsupported "target does not support record-btrace" 22 return -1 23} 24 25# start fresh - without an executable 26gdb_exit 27gdb_start 28 29# record cannot be stopped, if it was never active 30gdb_test "record stop" "No recording is currently active\\..*" "record stop without target" 31 32# btrace cannot be enabled without a running inferior 33gdb_test "record btrace" "The program is not being run\\." "record btrace without running program" 34 35# no function and no instruction history without btrace enabled 36gdb_test "record function-call-history" "No recording is currently active\\..*" "record function-call-history without target" 37gdb_test "record instruction-history" "No recording is currently active\\..*" "record instruction-history without target" 38gdb_test "info record" "No recording is currently active\\." "info record without target" 39 40standard_testfile 41if [prepare_for_testing "failed to prepare" $testfile {} {debug}] { 42 return -1 43} 44 45if ![runto_main] { 46 return -1 47} 48 49# enable btrace 50gdb_test_no_output "record btrace" "record btrace" 51gdb_test "record function-call-history" "No trace\\." "record function-call-history without trace" 52gdb_test "record instruction-history" "No trace\\." "record instruction-history without trace" 53 54# btrace cannot be enabled twice 55gdb_test "record btrace" "The process is already being recorded\\. Use \"record stop\" to stop recording first\\." "record btrace the second time" 56 57# full record cannot be activated as long as btrace is active 58gdb_test "record full" "The process is already being recorded\\. Use \"record stop\" to stop recording first\\." "record full cannot be enabled" 59 60# no trace recorded yet 61gdb_test "info record" "Active record target: record-btrace\r 62.*\r 63Recorded 0 instructions in 0 functions \\\(0 gaps\\\) for thread 1.*\\." "info record without trace" 64 65# stop btrace record 66gdb_test "record stop" "Process record is stopped and all execution logs are deleted\\." 67gdb_test "record stop" "No recording is currently active\\..*" "record stop the second time" 68 69# enable btrace again 70gdb_test_no_output "record btrace" "record btrace re-enable" 71gdb_test "record btrace" "The process is already being recorded\\. Use \"record stop\" to stop recording first\\." "record btrace re-enable twice" 72 73# continue to the end and make sure we don't die 74gdb_test "continue" ".*Inferior.*exited.*" "continue to end" 75 76# skip_gdbserver_tests requires GDB not running. 77gdb_exit 78 79# skip the rerun test when using gdbserver 80# otherwise rerun twice, target should be automatically disabled 81load_lib gdbserver-support.exp 82if [skip_gdbserver_tests] { 83 unsupported "target does not support gdbserver" 84 return 0 85} 86clean_restart $testfile 87if ![runto_main] { 88 return -1 89} 90if ![runto_main] { 91 return -1 92} 93 94# make sure record-btrace can be enabled after re-run 95clean_restart $testfile 96if ![runto_main] { 97 return -1 98} 99gdb_test_no_output "record btrace" "enable after restart" 100if ![runto_main] { 101 return -1 102} 103gdb_test_no_output "record btrace" "enable after re-run" 104