]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/frame-view.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / frame-view.exp
CommitLineData
1d506c26 1# Copyright 2022-2024 Free Software Foundation, Inc.
bc2cbe81
SM
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16# Test the "frame view" family of commands.
17
18standard_testfile
19
20if { [build_executable "failed to prepare" \
bc0c6793 21 ${testfile} ${srcfile} {debug pthreads}] } {
bc2cbe81
SM
22 return
23}
24
836a8d37
SM
25# If WITH_PRETTY_PRINTER is true, load pretty printers for the function
26# parameter types, in which we do an inferior call. This is meant to test
27# that the frame_info_ptr correctly reinflates frames created using
28# "select-frame view".
29
30proc test_select_frame_view { with_pretty_printer } {
bc2cbe81
SM
31 clean_restart $::binfile
32
836a8d37
SM
33 if { $with_pretty_printer } {
34 require allow_python_tests
35 }
36
bc2cbe81
SM
37 if { ![runto_main] } {
38 return
39 }
40
836a8d37
SM
41 if { $with_pretty_printer } {
42 set remote_python_file \
43 [gdb_remote_download host "${::srcdir}/${::subdir}/${::testfile}.py"]
44 gdb_test_no_output "source ${remote_python_file}" "load python file"
45 }
46
bc2cbe81
SM
47 # Stop thread 2 at a baz.
48 gdb_test "break baz"
49 gdb_test "continue" "Thread 2.*hit Breakpoint $::decimal, baz .*"
50
51 # Grab the stack pointer and pc of thread 2's frame.
52 set frame_sp ""
53 set frame_pc ""
54
55 gdb_test_multiple "info frame" "" {
56 -re -wrap ".*frame at ($::hex):.*" {
57 set frame_sp $expect_out(1,string)
58 pass $gdb_test_name
59 }
60 }
61
62 gdb_test_multiple "print/x \$pc" "" {
63 -re -wrap " = ($::hex)" {
64 set frame_pc $expect_out(1,string)
65 pass $gdb_test_name
66 }
67 }
68
69 if { $frame_sp == "" || $frame_pc == "" } {
70 # Something must have failed and logged a failure above.
71 return
72 }
73
74 # Select thread 2's frame in thread 1.
75 gdb_test "thread 1" "Switching to thread 1 .*"
9f462dde
AB
76 gdb_test_no_output "select-frame view $frame_sp $frame_pc" \
77 "select thread 2 frame from thread 1"
bc2cbe81 78
836a8d37
SM
79 if { $with_pretty_printer } {
80 # When the pretty printer does its infcall, it is done on the currently
81 # selected thread, thread 1 here. However, other threads are resumed
82 # at the same time. This causes thread 2 to exit during that infcall,
83 # leading to this weirdness:
84 #
85 # frame^M
86 # #0 baz (z=[Thread 0x7ffff7cc26c0 (LWP 417519) exited]^M
87 # hohoho) at /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/frame-view.c:35^M
88 # 35 return z.n + 2;^M
89 #
90 # Avoid that by setting scheduler-locking on.
91 gdb_test_no_output "set scheduler-locking on"
92
93 set z1_pattern "hahaha"
94 set z2_pattern "hohoho"
95 } else {
96 set z1_pattern "\\.\\.\\."
97 set z2_pattern "\\.\\.\\."
98 }
99
bc2cbe81
SM
100 # Verify that the "frame" command does not change the selected frame.
101 # There used to be a bug where the "frame" command would lose the
102 # selection of user-created frames.
836a8d37
SM
103 gdb_test "frame" "#0 baz \\(z1=$z1_pattern, z2=$z2_pattern\\).*" "frame"
104 gdb_test "frame" "#0 baz \\(z1=$z1_pattern, z2=$z2_pattern\\).*" "frame again"
bc2cbe81
SM
105}
106
836a8d37
SM
107foreach_with_prefix with_pretty_printer {false true} {
108 test_select_frame_view $with_pretty_printer
109}