# Copyright 2018-2021 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # Check that the selected stack frame doesn't change after a backtrace. standard_testfile if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } { return -1 } proc check_selected_frame_after_bt { bt_cmd stack_pattern } { global binfile clean_restart $binfile with_test_prefix $bt_cmd { if ![runto_main] then { fail "can't run to main" return 0 } gdb_breakpoint "breakpt" gdb_continue_to_breakpoint "breakpt" # Visit each frame in the stack and ensure that the selected # frame doesn't change after executing the backtrace command # in BT_CMD. foreach_with_prefix frame {0 1 2} { if { $frame == 0 } { gdb_assert {[get_current_frame_number] == $frame} \ "check frame" } else { gdb_test "frame $frame" "#$frame .*" "select frame" } gdb_test "$bt_cmd" $stack_pattern \ "perform backtrace command" gdb_assert {[get_current_frame_number] == $frame} \ "check frame is still selected" } } } check_selected_frame_after_bt "bt" \ [multi_line \ "#0 \[^\n\r\]+" \ "#1 \[^\n\r\]+" \ "#2 \[^\n\r\]+"] check_selected_frame_after_bt "bt full" \ [multi_line \ "#0 \[^\n\r\]+" \ "No locals\." \ "#1 \[^\n\r\]+" \ "No locals\." \ "#2 \[^\n\r\]+" \ "No locals\."]