diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2018-05-18 17:45:16 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2018-05-24 18:01:31 +0100 |
commit | 45f25d6c83c31a48a01ef8293bb3978f5e58e653 (patch) | |
tree | 3eddbff0a9ff77faa031e6180f985b60774583a7 /gdb/testsuite/gdb.base/bt-selected-frame.exp | |
parent | d9f6d7f8b636a2b32004273143d72a77d82b40de (diff) | |
download | gdb-45f25d6c83c31a48a01ef8293bb3978f5e58e653.zip gdb-45f25d6c83c31a48a01ef8293bb3978f5e58e653.tar.gz gdb-45f25d6c83c31a48a01ef8293bb3978f5e58e653.tar.bz2 |
gdb: Restore selected frame in print_frame_local_vars
PR gdb/23203 reports 'bt full' causing the currently selected frame to
change, this issue is fixed in this commit.
Add a new class scoped_restore_selected_frame that saves and restores
the selected frame. Make use of this in print_frame_local_vars to
restore the selected frame on exit.
gdb/ChangeLog:
PR gdb/23203
* frame.c
(scoped_restore_selected_frame::scoped_restore_selected_frame):
Define.
(scoped_restore_selected_frame::~scoped_restore_selected_frame):
Define.
* frame.h (class scoped_restore_selected_frame): New class.
* stack.c (print_frame_local_vars): Remove catching and rethrowing
of any exception, use scoped_restore_selected_frame to restore the
frame instead.
gdb/testsuite/ChangeLog:
PR gdb/23203
* gdb.base/bt-selected-frame.c: New file.
* gdb.base/bt-selected-frame.exp: New file.
* lib/gdb.exp (get_current_frame_number): New function.
Diffstat (limited to 'gdb/testsuite/gdb.base/bt-selected-frame.exp')
-rw-r--r-- | gdb/testsuite/gdb.base/bt-selected-frame.exp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.base/bt-selected-frame.exp b/gdb/testsuite/gdb.base/bt-selected-frame.exp new file mode 100644 index 0000000..a60962f --- /dev/null +++ b/gdb/testsuite/gdb.base/bt-selected-frame.exp @@ -0,0 +1,72 @@ +# Copyright 2018 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 <http://www.gnu.org/licenses/>. + +# 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\."] |