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