Commit | Line | Data |
---|---|---|
835c559f PA |
1 | # Copyright (C) 2014 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 | # Test that GDB doesn't get confused in the following scenario | |
17 | # (PR breakpoints/17000). Say, we have this program: | |
18 | # | |
19 | # => 0xff000001 INSN1 | |
20 | # 0xff000002 INSN2 | |
21 | # | |
22 | # The PC currently points at INSN1. | |
23 | # | |
24 | # 1 - User sets a breakpoint at 0xff000002 (INSN2). | |
25 | # | |
26 | # 2 - User steps. On software single-step archs, this sets a software | |
27 | # single-step breakpoint at 0xff000002 (INSN2) too. | |
28 | # | |
29 | # 3 - User deletes breakpoint (INSN2) before the single-step finishes. | |
30 | # | |
31 | # 4 - The single-step finishes, and GDB removes the single-step | |
32 | # breakpoint. | |
33 | ||
34 | standard_testfile | |
35 | ||
36 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { | |
37 | return -1 | |
38 | } | |
39 | ||
40 | if ![runto_main] { | |
41 | fail "Can't run to main" | |
42 | return 0 | |
43 | } | |
44 | ||
45 | set line_re "\[^\r\n\]*" | |
46 | ||
47 | gdb_test "b test:label" "Breakpoint .*" | |
48 | gdb_continue_to_breakpoint "run past setup" | |
49 | delete_breakpoints | |
50 | ||
51 | # So we can precisely control breakpoint insertion order. | |
52 | gdb_test_no_output "set breakpoint always-inserted on" | |
53 | ||
54 | # Capture disassembly output. PREFIX is used as test prefix. The | |
55 | # current instruction indicator (=>) is stripped away. | |
56 | proc disassemble { prefix } { | |
57 | with_test_prefix "$prefix" { | |
58 | set output [capture_command_output "disassemble test" ""] | |
59 | return [string map {"=>" " "} $output] | |
60 | } | |
61 | } | |
62 | ||
63 | # Issue a stepi and immediately delete the user breakpoint that is set | |
64 | # at the same address as the software single-step breakpoint. Do this | |
65 | # in a user defined command, so that the stepi's trap doesn't have a | |
66 | # chance to be handled before further input is processed. We then | |
67 | # compare before/after disassembly. GDB should be able to handle | |
68 | # deleting the user breakpoint before deleting the single-step | |
69 | # breakpoint. E.g., we shouldn't see breakpoint instructions in the | |
70 | # disassembly. | |
71 | ||
72 | set disasm_before [disassemble "before"] | |
73 | ||
74 | gdb_test "b test:label2" ".*" "set breakpoint where si will land" | |
75 | ||
76 | set test "define stepi_del_break" | |
77 | gdb_test_multiple $test $test { | |
78 | -re "Type commands for definition of \"stepi_del_break\".\r\nEnd with a line saying just \"end\".\r\n>$" { | |
79 | gdb_test "si&\ndel \$bpnum\nend" "" $test | |
80 | } | |
81 | } | |
82 | ||
83 | set command "stepi_del_break" | |
84 | set test $command | |
85 | setup_kfail "breakpoints/17000" "*-*-*" | |
86 | gdb_test_multiple $command $test { | |
87 | -re "^$command\r\n$gdb_prompt " { | |
88 | # Note no end anchor, because "si&" finishes and prints the | |
89 | # current frame/line after the prompt is printed. | |
90 | pass $test | |
91 | } | |
92 | } | |
93 | ||
94 | # Now consume the output of the finished "si&". | |
95 | set test "si& finished" | |
96 | gdb_test_multiple "" $test { | |
97 | -re "must be a single line \\\*/\r\n" { | |
98 | pass $test | |
99 | } | |
100 | } | |
101 | ||
102 | set disasm_after [disassemble "after"] | |
103 | ||
104 | set test "before/after disassembly matches" | |
105 | if ![string compare $disasm_before $disasm_after] { | |
106 | pass $test | |
107 | } else { | |
108 | fail $test | |
109 | } |