OLD | NEW |
1 # This testcase is part of GDB, the GNU debugger. | 1 # This testcase is part of GDB, the GNU debugger. |
2 | 2 |
3 # Copyright 2011-2012 Free Software Foundation, Inc. | 3 # Copyright 2011-2012 Free Software Foundation, Inc. |
4 | 4 |
5 # This program is free software; you can redistribute it and/or modify | 5 # This program is free software; you can redistribute it and/or modify |
6 # it under the terms of the GNU General Public License as published by | 6 # it under the terms of the GNU General Public License as published by |
7 # the Free Software Foundation; either version 3 of the License, or | 7 # the Free Software Foundation; either version 3 of the License, or |
8 # (at your option) any later version. | 8 # (at your option) any later version. |
9 # | 9 # |
10 # This program is distributed in the hope that it will be useful, | 10 # This program is distributed in the hope that it will be useful, |
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 # GNU General Public License for more details. | 13 # GNU General Public License for more details. |
14 # | 14 # |
15 # You should have received a copy of the GNU General Public License | 15 # You should have received a copy of the GNU General Public License |
16 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 |
18 if { ![support_displaced_stepping] } { | 18 if { ![support_displaced_stepping] } { |
19 unsupported "displaced stepping" | 19 unsupported "displaced stepping" |
20 return -1 | 20 return -1 |
21 } | 21 } |
22 | 22 |
23 set syscall_insn "" | 23 set syscall_insn "" |
24 | 24 |
25 # Define the syscall instruction for each target. | 25 # Define the syscall instruction for each target. |
26 | 26 |
27 if { [istarget "i\[34567\]86-*-linux*"] || [istarget "x86_64-*-linux*"] } { | 27 if { [istarget "i\[34567\]86-*-linux*"] || [istarget "x86_64-*-linux*"] } { |
28 set syscall_insn "(int|syscall|sysenter)" | 28 set syscall_insn "\[ \t\](int|syscall|sysenter)\[ \t\]" |
29 } else { | 29 } else { |
30 return -1 | 30 return -1 |
31 } | 31 } |
32 | 32 |
33 proc disp_step_cross_syscall { syscall } { | 33 proc disp_step_cross_syscall { syscall } { with_test_prefix "$syscall" { |
34 global syscall_insn | 34 global syscall_insn |
35 global gdb_prompt | 35 global gdb_prompt |
36 global pf_prefix | |
37 | 36 |
38 set testfile "disp-step-$syscall" | 37 set testfile "disp-step-$syscall" |
39 | 38 |
40 if [prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.c {debug}] { | 39 if [prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.c {debug}] { |
41 untested ${testfile}.exp | 40 untested ${testfile}.exp |
42 return -1 | 41 return -1 |
43 } | 42 } |
44 | 43 |
45 if { ![runto main] } then { | 44 if { ![runto main] } then { |
46 fail "run to main ($syscall)" | 45 fail "run to main ($syscall)" |
47 return | 46 return |
48 } | 47 } |
49 | 48 |
50 set old_pf_prefix $pf_prefix | |
51 lappend pf_prefix "$syscall:" | |
52 | |
53 # Delete the breakpoint on main. | 49 # Delete the breakpoint on main. |
54 gdb_test_no_output "delete break 1" | 50 gdb_test_no_output "delete break 1" |
55 | 51 |
56 gdb_test "break marker" "Breakpoint.*at.* file .*${testfile}.c, line.*" | 52 gdb_test "break marker" "Breakpoint.*at.* file .*${testfile}.c, line.*" |
57 gdb_test_no_output "set displaced-stepping off" | 53 gdb_test_no_output "set displaced-stepping off" |
58 | 54 |
59 set syscall_bp 0 | 55 set syscall_bp 0 |
60 gdb_test_multiple "break $syscall" "break $syscall" { | 56 gdb_test_multiple "break $syscall" "break $syscall" { |
61 -re "Breakpoint (\[0-9\]*) at .*$gdb_prompt $" { | 57 -re "Breakpoint (\[0-9\]*) at .*$gdb_prompt $" { |
62 set syscall_bp $expect_out(1,string) | 58 set syscall_bp $expect_out(1,string) |
(...skipping 24 matching lines...) Expand all Loading... |
87 gdb_expect { | 83 gdb_expect { |
88 -re ".*$syscall_insn.*$gdb_prompt $" { | 84 -re ".*$syscall_insn.*$gdb_prompt $" { |
89 set see_syscall_insn 1 | 85 set see_syscall_insn 1 |
90 } | 86 } |
91 -re ".*$gdb_prompt $" {} | 87 -re ".*$gdb_prompt $" {} |
92 } | 88 } |
93 } | 89 } |
94 | 90 |
95 if {$see_syscall_insn == 0} then { | 91 if {$see_syscall_insn == 0} then { |
96 fail "find syscall insn in $syscall" | 92 fail "find syscall insn in $syscall" |
97 set pf_prefix $old_pf_prefix | |
98 return -1 | 93 return -1 |
99 } | 94 } |
100 | 95 |
101 set syscall_insn_addr [get_hexadecimal_valueof "\$pc" "0"] | 96 set syscall_insn_addr [get_hexadecimal_valueof "\$pc" "0"] |
102 gdb_test "stepi" ".*" "stepi $syscall insn" | 97 gdb_test "stepi" ".*" "stepi $syscall insn" |
103 set syscall_insn_next_addr [get_hexadecimal_valueof "\$pc" "0"] | 98 set syscall_insn_next_addr [get_hexadecimal_valueof "\$pc" "0"] |
104 | 99 |
105 gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in |__libc_|)$s
yscall \\(\\).*" \ | 100 gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in |__libc_|)$s
yscall \\(\\).*" \ |
106 "continue to $syscall (3rd time)" | 101 "continue to $syscall (3rd time)" |
107 | 102 |
108 # Hit the breakpoint on $syscall for the third time. In this time, we'll se
t | 103 # Hit the breakpoint on $syscall for the third time. In this time, we'll se
t |
109 # breakpoint on the syscall insn we recorded previously, and single step ove
r it. | 104 # breakpoint on the syscall insn we recorded previously, and single step ove
r it. |
110 | 105 |
111 set syscall_insn_bp 0 | 106 set syscall_insn_bp 0 |
112 gdb_test_multiple "break \*$syscall_insn_addr" "break on syscall insn" { | 107 gdb_test_multiple "break \*$syscall_insn_addr" "break on syscall insn" { |
113 -re "Breakpoint (\[0-9\]*) at .*$gdb_prompt $" { | 108 -re "Breakpoint (\[0-9\]*) at .*$gdb_prompt $" { |
114 set syscall_insn_bp $expect_out(1,string) | 109 set syscall_insn_bp $expect_out(1,string) |
115 pass "break on syscall insns" | 110 pass "break on syscall insns" |
116 } | 111 } |
117 } | 112 } |
118 gdb_test_no_output "delete $syscall_bp" "delete break $syscall" | 113 gdb_test_no_output "delete $syscall_bp" "delete break $syscall" |
119 | 114 |
120 gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, .*" \ | 115 gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, .*" \ |
121 "continue to syscall insn $syscall" | 116 "continue to syscall insn $syscall" |
122 | 117 |
123 gdb_test_no_output "set displaced-stepping on" | 118 gdb_test_no_output "set displaced-stepping on" |
124 | 119 |
125 # Check the address of next instruction of syscall. | 120 # Check the address of next instruction of syscall. |
126 gdb_test "stepi" ".*$syscall_insn_next_addr.*" "single step over $syscall" | 121 if {$syscall == "vfork" && [is_remote target]} { |
| 122 » setup_kfail server/13796 "*-*-*" |
| 123 } |
| 124 set test "single step over $syscall" |
| 125 gdb_test_multiple "stepi" $test { |
| 126 » -re "Program terminated with signal SIGILL,.*\r\n$gdb_prompt $" { |
| 127 » fail $test |
| 128 » return |
| 129 » } |
| 130 » -re "\\\[Inferior .* exited normally\\\].*\r\n$gdb_prompt $" { |
| 131 » fail $test |
| 132 » return |
| 133 » } |
| 134 » -re "\r\n$gdb_prompt $" { |
| 135 » pass $test |
| 136 » } |
| 137 } |
| 138 |
| 139 set syscall_insn_next_addr_found [get_hexadecimal_valueof "\$pc" "0"] |
| 140 |
| 141 set test "single step over $syscall final pc" |
| 142 if {$syscall_insn_next_addr != 0 |
| 143 » && $syscall_insn_next_addr == $syscall_insn_next_addr_found} { |
| 144 pass $test |
| 145 } else { |
| 146 fail $test |
| 147 } |
127 | 148 |
128 # Delete breakpoint syscall insns to avoid interference to other syscalls. | 149 # Delete breakpoint syscall insns to avoid interference to other syscalls. |
129 gdb_test_no_output "delete $syscall_insn_bp" "delete break $syscall insn" | 150 gdb_test_no_output "delete $syscall_insn_bp" "delete break $syscall insn" |
130 | 151 |
131 gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker \\(\\) at.*"
\ | 152 gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker \\(\\) at.*"
\ |
132 "continue to marker ($syscall)" | 153 "continue to marker ($syscall)" |
133 | 154 }} |
134 set pf_prefix $old_pf_prefix | |
135 } | |
136 | 155 |
137 disp_step_cross_syscall "fork" | 156 disp_step_cross_syscall "fork" |
138 disp_step_cross_syscall "vfork" | 157 disp_step_cross_syscall "vfork" |
OLD | NEW |