]>
Commit | Line | Data |
---|---|---|
8acc9f48 | 1 | # Copyright 1999-2013 Free Software Foundation, Inc. |
fb40c209 AC |
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 |
fb40c209 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
fb40c209 AC |
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 | # |
fb40c209 | 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/>. |
fb40c209 | 15 | |
fb40c209 AC |
16 | # |
17 | # Test essential Machine interface (MI) operations | |
18 | # | |
19 | # Verify that, using the MI, we can run a simple program and perform basic | |
20 | # debugging activities like: insert breakpoints, run the program, | |
21 | # step, next, continue until it ends and, last but not least, quit. | |
22 | # | |
23 | # The goal is not to test gdb functionality, which is done by other tests, | |
24 | # but to verify the correct output response to MI operations. | |
25 | # | |
26 | ||
27 | load_lib mi-support.exp | |
b30bf9ee | 28 | set MIFLAGS "-i=mi" |
fb40c209 AC |
29 | |
30 | gdb_exit | |
31 | if [mi_gdb_start] { | |
32 | continue | |
33 | } | |
34 | ||
298a9cf0 TT |
35 | standard_testfile basics.c |
36 | ||
9357e021 | 37 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { |
b60f0898 JB |
38 | untested mi-watch.exp |
39 | return -1 | |
fb40c209 AC |
40 | } |
41 | ||
4a543daf | 42 | proc test_watchpoint_creation_and_listing {type} { |
fb40c209 AC |
43 | global mi_gdb_prompt |
44 | global srcfile | |
45 | global hex | |
46 | ||
45f07fef MC |
47 | set line_callee4_head [gdb_get_line_number "callee4 ("] |
48 | set line_callee4_body [expr $line_callee4_head + 2] | |
49 | ||
fb40c209 AC |
50 | # Insert a watchpoint and list |
51 | # Tests: | |
52 | # -break-watch C | |
53 | # -break-list | |
54 | ||
55 | mi_gdb_test "111-break-watch C" \ | |
56 | "111\\^done,wpt=\{number=\"2\",exp=\"C\"\}" \ | |
57 | "break-watch operation" | |
58 | ||
59 | mi_gdb_test "222-break-list" \ | |
8d3788bd | 60 | "222\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[bkpt=\{number=\"2\",type=\".*watchpoint\",disp=\"keep\",enabled=\"y\",what=\"C\",times=\"0\",original-location=\"C\"\}\\\]\}" \ |
fb40c209 AC |
61 | "list of watchpoints" |
62 | ||
63 | } | |
64 | ||
65 | # UNUSED at the time | |
4a543daf | 66 | proc test_awatch_creation_and_listing {type} { |
fb40c209 AC |
67 | global mi_gdb_prompt |
68 | global srcfile | |
69 | global hex | |
70 | ||
45f07fef MC |
71 | set line_main_head [gdb_get_line_number "main ("] |
72 | set line_main_body [expr $line_main_head + 2] | |
73 | ||
fb40c209 AC |
74 | # Insert an access watchpoint and list it |
75 | # Tests: | |
76 | # -break-watch -a A | |
77 | # -break-list | |
78 | ||
79 | mi_gdb_test "333-break-watch -a A" \ | |
45f07fef | 80 | "333\\^done,bkpt=\{number=\"1\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_main_body\"\}" \ |
fb40c209 AC |
81 | "break-watch -a operation" |
82 | ||
83 | mi_gdb_test "444-break-list" \ | |
45f07fef | 84 | "444\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"3\",type=\"watchpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"$line_main_body\",times=\"0\"\},.*\}\\\]\}" \ |
fb40c209 AC |
85 | "list of watchpoints awatch" |
86 | ||
87 | mi_gdb_test "777-break-delete 3" \ | |
88 | "777\\^done" \ | |
89 | "delete access watchpoint" | |
90 | } | |
91 | ||
92 | # UNUSED at the time | |
4a543daf | 93 | proc test_rwatch_creation_and_listing {type} { |
fb40c209 AC |
94 | global mi_gdb_prompt |
95 | global srcfile | |
96 | global hex | |
97 | ||
45f07fef MC |
98 | set line_main_head [gdb_get_line_number "main ("] |
99 | set line_main_body [expr $line_main_head + 2] | |
100 | ||
fb40c209 AC |
101 | # Insert a read watchpoint and list it. |
102 | # Tests: | |
e714f336 | 103 | # -break-watch -r B |
fb40c209 AC |
104 | # -break-list |
105 | ||
106 | mi_gdb_test "200-break-watch -r C" \ | |
45f07fef | 107 | "200\\^done,bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"$line_main_body\",times=\"0\"\}" \ |
e714f336 | 108 | "break-watch -r operation" |
fb40c209 AC |
109 | |
110 | mi_gdb_test "300-break-list" \ | |
45f07fef | 111 | "300\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"$line_main_body\",times=\"0\"\},.*\}\\\}\}" \ |
fb40c209 AC |
112 | "list of breakpoints" |
113 | ||
114 | mi_gdb_test "177-break-delete 4" \ | |
115 | "177\\^done" \ | |
116 | "delete read watchpoint" | |
117 | } | |
118 | ||
4a543daf | 119 | proc test_watchpoint_triggering {type} { |
fb40c209 | 120 | global mi_gdb_prompt |
76ff342d | 121 | global hex fullname_syntax srcfile |
fb40c209 | 122 | |
45f07fef MC |
123 | set line_callee4_return_0 [gdb_get_line_number "return 0;"] |
124 | set line_callee3_head [gdb_get_line_number "callee3 ("] | |
125 | set line_callee3_close_brace [expr $line_callee3_head + 3] | |
126 | ||
fb40c209 AC |
127 | # Continue execution until the watchpoint is reached, continue again, |
128 | # to see the watchpoint go out of scope. | |
129 | # Does: | |
130 | # -exec-continue (Here wp triggers) | |
131 | # -exec-continue (Here wp goes out of scope) | |
132 | ||
bb378428 VP |
133 | mi_execute_to "exec-continue" "watchpoint-trigger" "callee4" "" \ |
134 | ".*basics.c" $line_callee4_return_0 \ | |
135 | {"" "wpt=\{number=\"2\",exp=\"C\"\},value=\{old=\".*\",new=\"3\"\}"} \ | |
136 | "watchpoint trigger" | |
fb40c209 | 137 | |
4a543daf MR |
138 | if { $type == "sw" } { |
139 | setup_xfail *-*-* | |
140 | } | |
bb378428 VP |
141 | mi_execute_to "exec-continue" "watchpoint-scope" "callee3" ".*" \ |
142 | ".*basics.c" $line_callee3_close_brace \ | |
143 | {"" "wpnum=\"2\""} \ | |
144 | "watchpoint trigger" | |
4a543daf | 145 | clear_xfail *-*-* |
fb40c209 AC |
146 | } |
147 | ||
0f4d39d5 | 148 | proc test_watchpoint_all {type} { with_test_prefix "$type" { |
5509918f MR |
149 | upvar srcdir srcdir |
150 | upvar subdir subdir | |
151 | upvar binfile binfile | |
152 | ||
5509918f MR |
153 | mi_delete_breakpoints |
154 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
155 | mi_gdb_load ${binfile} | |
156 | ||
157 | mi_runto callee4 | |
4a543daf MR |
158 | test_watchpoint_creation_and_listing $type |
159 | #test_rwatch_creation_and_listing $type | |
160 | #test_awatch_creation_and_listing $type | |
161 | test_watchpoint_triggering $type | |
6a5870ce | 162 | }} |
5509918f MR |
163 | |
164 | # Run the tests twice, once using software watchpoints... | |
165 | mi_gdb_test "567-gdb-set can-use-hw-watchpoints 0" \ | |
166 | "567\\^done" \ | |
167 | "hw watchpoints toggle (1)" | |
168 | test_watchpoint_all sw | |
169 | ||
170 | mi_gdb_exit | |
171 | ||
172 | # ... and unless requested otherwise... | |
3e347599 | 173 | if [target_info exists gdb,no_hardware_watchpoints] { |
5509918f | 174 | return 0 |
3e347599 DJ |
175 | } |
176 | ||
5509918f MR |
177 | mi_gdb_start |
178 | ||
179 | # ... once using hardware watchpoints (if available). | |
180 | mi_gdb_test "890-gdb-set can-use-hw-watchpoints 1" \ | |
181 | "890\\^done" \ | |
182 | "hw watchpoints toggle (2)" | |
183 | test_watchpoint_all hw | |
fb40c209 AC |
184 | |
185 | mi_gdb_exit | |
186 | return 0 |