3aecf00a29137ba39f771f853f70cc59299800a5
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / valgrind-disp-step.exp
1 # Copyright 2012-2021 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
16 # Step over breakpoints with displaced stepping on, against Valgrind.
17 # We can't really use displaced stepping with Valgrind, so what this
18 # really tests is that GDB falls back to in-line stepping
19 # automatically instead of getting stuck or crashing.
20
21 load_lib valgrind.exp
22
23 if [is_remote target] {
24 # The test always runs locally.
25 return 0
26 }
27
28 standard_testfile .c
29 if {[build_executable "failed to build" $testfile $srcfile {debug}] == -1} {
30 return -1
31 }
32
33 if { [vgdb_start] == -1 } {
34 return -1
35 }
36
37 gdb_test_no_output "set displaced-stepping off"
38 gdb_breakpoint "main" "breakpoint at main"
39 gdb_test "continue" " stop 0 .*" "continue to main"
40 delete_breakpoints
41
42 set curr_stop 0
43 foreach displaced { "off" "on" } {
44 with_test_prefix "displaced $displaced" {
45
46 gdb_test_no_output "set displaced-stepping $displaced"
47
48 foreach go { "once" "twice" } {
49 with_test_prefix $go {
50 gdb_test "break" "Breakpoint .* at .*" "set breakpoint"
51
52 # Whether we should see a warning.
53 set should_warn [expr {$go == "once" && $displaced == "on"}]
54
55 incr curr_stop
56
57 set msg "step over breakpoint"
58 set pattern " stop $curr_stop .*$gdb_prompt $"
59 gdb_test_multiple "next" $msg {
60 -re "warning: disabling displaced stepping.*$pattern" {
61 gdb_assert $should_warn $msg
62 }
63 -re "$pattern" {
64 gdb_assert !$should_warn $msg
65 }
66 }
67 }
68 }
69 }
70 }
71
72 vgdb_stop
This page took 0.04339 seconds and 3 git commands to generate.