]>
Commit | Line | Data |
---|---|---|
8acc9f48 | 1 | # Copyright (C) 1998-2013 Free Software Foundation, Inc. |
7be570e7 JM |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
7be570e7 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
7be570e7 JM |
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. | |
e22f8b7c | 12 | # |
7be570e7 | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
7be570e7 | 15 | |
7be570e7 JM |
16 | # |
17 | # test special commands | |
18 | # | |
7be570e7 JM |
19 | |
20 | if { [skip_hp_tests] } then { continue } | |
21 | ||
22 | set testfile "run" | |
23 | set srcfile ${testfile}.c | |
24 | set binfile ${objdir}/${subdir}/${testfile} | |
25 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { | |
b60f0898 JB |
26 | untested watch-cmd.exp |
27 | return -1 | |
7be570e7 JM |
28 | |
29 | } | |
30 | ||
4c93b1db | 31 | if [get_compiler_info] { |
7be570e7 JM |
32 | return -1; |
33 | } | |
34 | if { $gcc_compiled } then { continue } | |
35 | ||
36 | ||
37 | gdb_exit | |
38 | gdb_start | |
39 | delete_breakpoints | |
40 | gdb_reinitialize_dir $srcdir/$subdir | |
41 | gdb_load ${binfile} | |
42 | ||
43 | ||
44 | ||
45 | proc watchpoint_command_test {} { | |
46 | global gdb_prompt | |
47 | ||
48 | if [target_info exists noargs] { | |
49 | verbose "Skipping watchpoint_command_test because of noargs." | |
50 | return | |
51 | } | |
52 | ||
53 | if { ![runto factorial] } then { gdb_suppress_tests } | |
54 | # Don't depend upon argument passing, since most simulators don't currently | |
55 | # support it. Bash value variable to be what we want. | |
56 | gdb_test "p value=6" "" "set value to 6 in watchpoint_command_test" | |
57 | delete_breakpoints | |
58 | ||
59 | # Verify that we can create a watchpoint, and give it a commands | |
60 | # list that continues the inferior. We set the watchpoint on a | |
61 | # local variable, too, so that it self-deletes when the watched | |
62 | # data goes out of scope. | |
63 | # | |
64 | # What should happen is: Each time the watchpoint triggers, it | |
65 | # continues the inferior. Eventually, the watchpoint will self- | |
66 | # delete, when the watched variable is out of scope. But by that | |
67 | # time, the inferior should have exited. GDB shouldn't crash or | |
68 | # anything untoward as a result of this. | |
69 | # | |
70 | send_gdb "watch local_var\n" | |
71 | gdb_expect { | |
72 | -re ".*\[Ww\]atchpoint (\[0-9\]*): local_var.*$gdb_prompt $"\ | |
73 | { pass "watch local_var" | |
74 | set wp_id $expect_out(1,string) | |
75 | send_gdb "commands $wp_id\n" | |
76 | gdb_expect { | |
77 | -re "Type commands for when breakpoint $wp_id is hit, one per line.*>"\ | |
78 | { pass "begin commands on watch"} | |
79 | -re "$gdb_prompt $"\ | |
80 | {fail "begin commands on watch"} | |
81 | timeout {fail "(timeout) begin commands on watch"} | |
82 | } | |
83 | } | |
84 | -re "$gdb_prompt $"\ | |
85 | {fail "watch local_var"} | |
86 | timeout {fail "(timeout) watch local_var"} | |
87 | } | |
88 | # set wp_id $expect_out(1,string) | |
89 | # send_gdb "commands $wp_id\n" | |
90 | # gdb_expect { | |
91 | # -re "Type commands for when breakpoint $wp_id is hit, one per line.*>"\ | |
92 | # {pass "begin commands on watch"} | |
93 | # -re "$gdb_prompt $"\ | |
94 | # {fail "begin commands on watch"} | |
95 | # timeout {fail "(timeout) begin commands on watch"} | |
96 | # } | |
97 | send_gdb "print value\n" | |
98 | gdb_expect { | |
99 | -re ">"\ | |
100 | {pass "add print command to watch"} | |
101 | -re "$gdb_prompt $"\ | |
102 | {fail "add print command to watch"} | |
103 | timeout {fail "(timeout) add print command to watch"} | |
104 | } | |
105 | send_gdb "continue\n" | |
106 | gdb_expect { | |
107 | -re ">"\ | |
108 | {pass "add continue command to watch"} | |
109 | -re "$gdb_prompt $"\ | |
110 | {fail "add continue command to watch"} | |
111 | timeout {fail "(timeout) add continue command to watch"} | |
112 | } | |
113 | send_gdb "end\n" | |
114 | gdb_expect { | |
115 | -re "$gdb_prompt $"\ | |
116 | {pass "begin commands on watch"} | |
117 | timeout {fail "(timeout) begin commands on watch"} | |
118 | } | |
119 | send_gdb "continue\n" | |
120 | gdb_expect { | |
121 | -re "Continuing.*\[Ww\]atchpoint $wp_id deleted because the program has left the block in.*which its expression is valid.*in main.*$gdb_prompt $"\ | |
122 | {pass "continue with watch"} | |
123 | -re "$gdb_prompt $"\ | |
124 | {fail "continue with watch"} | |
125 | timeout {fail "(timeout) continue with watch"} | |
126 | } | |
127 | send_gdb "continue\n" | |
128 | gdb_expect { | |
129 | -re "Continuing.*$gdb_prompt $"\ | |
130 | {pass "continue until exit"} | |
131 | -re "$gdb_prompt $"\ | |
132 | {fail "continue until exit"} | |
133 | timeout {fail "(timeout) continue until exit"} | |
134 | } | |
135 | } | |
136 | ||
137 | watchpoint_command_test | |
138 | ||
139 | ||
140 | ||
141 | ||
142 | ||
143 | ||
144 | ||
145 | ||
146 | ||
147 | ||
148 |