]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/step-over-exit.exp
Fix test names starting with uppercase output by basic functions
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / step-over-exit.exp
CommitLineData
f50bf8e5
YQ
1# Copyright 2016 Free Software Foundation, Inc.
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
16standard_testfile
17
18# Test a thread is doing step-over a syscall instruction which is exit,
19# and GDBserver should cleanup its state of step-over properly.
20
21set syscall_insn ""
22
23# Define the syscall instruction for each target.
24
25if { [istarget "i\[34567\]86-*-linux*"] || [istarget "x86_64-*-linux*"] } {
26 set syscall_insn "\[ \t\](int|syscall|sysenter)\[ \t\]"
27} elseif { [istarget "aarch64*-*-linux*"] || [istarget "arm*-*-linux*"] } {
28 set syscall_insn "\[ \t\](swi|svc)\[ \t\]"
29} else {
30 unsupported "unknown syscall instruction"
31 return -1
32}
33
34if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
35 untested $testfile.exp
36 return -1
37}
38
39# Start with a fresh gdb.
40clean_restart ${testfile}
41if ![runto_main] {
bc6c7af4 42 fail "can't run to main"
f50bf8e5
YQ
43 return -1
44}
45
46gdb_test "set follow-fork-mode child"
47gdb_test "set detach-on-fork off"
48
49# Step 1, find the syscall instruction address.
50
51gdb_test "break _exit" "Breakpoint $decimal at .*"
52
53# Hit the breakpoint on _exit. The address of syscall insn is recorded.
54
55gdb_test "continue" \
56 "Continuing\\..*Breakpoint $decimal.*_exit \\(.*\\).*" \
57 "continue to exit"
58
59gdb_test "display/i \$pc" ".*"
60
61# Single step until we see a syscall insn or we reach the
62# upper bound of loop iterations.
63set msg "find syscall insn in exit"
64set steps 0
65set max_steps 1000
66gdb_test_multiple "stepi" $msg {
67 -re ".*$syscall_insn.*$gdb_prompt $" {
68 pass $msg
69 }
70 -re "x/i .*=>.*\r\n$gdb_prompt $" {
71 incr steps
72 if {$steps == $max_steps} {
73 fail $msg
74 } else {
75 send_gdb "stepi\n"
76 exp_continue
77 }
78 }
79}
80
81if {$steps == $max_steps} {
82 return
83}
84
85# Remove the display
86gdb_test_no_output "delete display 1"
87
88set syscall_insn_addr [get_hexadecimal_valueof "\$pc" "0"]
89
90gdb_test "continue" "exited normally.*" "continue to end, first time"
91gdb_test "inferior 1" ".*Switching to inferior 1.*" \
92 "switch back to inferior 1, first time"
93
94delete_breakpoints
95
96gdb_test "break marker"
97
98gdb_test "continue" "Continuing\\..*Breakpoint $decimal, .*" \
99 "continue to marker, first time"
100
101# Step 2, create a breakpoint which evaluates false, and force it
102# evaluated on the target side.
103
104set test "set breakpoint condition-evaluation target"
105gdb_test_multiple $test $test {
106 -re "warning: Target does not support breakpoint condition evaluation.\r\nUsing host evaluation mode instead.\r\n$gdb_prompt $" {
107 # Target doesn't support breakpoint condition evaluation
108 # on its side, but it is no harm to run the test.
109 }
110 -re "^$test\r\n$gdb_prompt $" {
111 }
112}
113
114gdb_test "break \*$syscall_insn_addr if main == 0" \
115 "Breakpoint \[0-9\]* at .*"
116
117# Resume the child process, and the step-over is being done.
118
119gdb_test "continue" "exited normally.*" "continue to end, second time"
120gdb_test "inferior 1" ".*Switching to inferior 1.*" \
121 "switch back to inferior 1, second time"
122
123# Switch back to the parent process, continue to the marker to
124# test GDBserver's state is still correct.
125
126gdb_test "continue" "Continuing\\..*Breakpoint $decimal, .*" \
127 "continue to marker, second time"