1# This testcase is part of GDB, the GNU debugger. 2# 3# Copyright 2013-2020 Free Software Foundation, Inc. 4# 5# Contributed by Intel Corp. <markus.t.metzger@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 25standard_testfile exception.cc 26if [prepare_for_testing "failed to prepare" $testfile $srcfile {c++ debug}] { 27 return -1 28} 29 30if ![runto_main] { 31 untested "failed to run to main" 32 return -1 33} 34 35# we want to see the full trace for this test 36gdb_test_no_output "set record function-call-history-size 0" 37 38# set bp 39set bp_1 [gdb_get_line_number "bp.1" $srcfile] 40set bp_2 [gdb_get_line_number "bp.2" $srcfile] 41gdb_breakpoint $bp_1 42gdb_breakpoint $bp_2 43 44# trace the code between the two breakpoints 45gdb_continue_to_breakpoint "cont to bp.1" ".*$srcfile:$bp_1\r\n.*" 46# increase the BTS buffer size - the trace can be quite big 47gdb_test_no_output "set record btrace bts buffer-size 128000" 48gdb_test_no_output "record btrace" 49gdb_continue_to_breakpoint "cont to bp.2" ".*$srcfile:$bp_2\r\n.*" 50 51# show the flat branch trace 52send_gdb "record function-call-history 1\n" 53gdb_expect_list "flat" "\r\n$gdb_prompt $" [list \ 54 [multi_line \ 55 "1\tmain\\(\\)" \ 56 "2\ttest\\(\\)" \ 57 "3\tfoo\\(\\)" \ 58 "4\tbar\\(\\)" \ 59 "5\tbad\\(\\)\r" \ 60 ] \ 61 "" \ 62 "\[0-9\]*\ttest\\(\\)"] 63 64# show the branch trace with calls indented 65send_gdb "record function-call-history /c 1\n" 66gdb_expect_list "indented" "\r\n$gdb_prompt $" [list \ 67 [multi_line \ 68 "1\tmain\\(\\)" \ 69 "2\t test\\(\\)" \ 70 "3\t foo\\(\\)" \ 71 "4\t bar\\(\\)" \ 72 "5\t bad\\(\\)\r" \ 73 ] \ 74 "" \ 75 "\[0-9\]*\t test\\(\\)"] 76