Commit | Line | Data |
---|---|---|
6aba47ca | 1 | # Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2007 |
76ff342d | 2 | # Free Software Foundation, Inc. |
fb40c209 AC |
3 | |
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
e22f8b7c | 6 | # the Free Software Foundation; either version 3 of the License, or |
fb40c209 | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
fb40c209 AC |
9 | # This program is distributed in the hope that it will be useful, |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
e22f8b7c | 13 | # |
fb40c209 | 14 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
fb40c209 | 16 | |
fb40c209 AC |
17 | # |
18 | # Test essential Machine interface (MI) operations | |
19 | # | |
20 | # Verify that, using the MI, we can run a simple program and perform basic | |
21 | # debugging activities like: insert breakpoints, run the program, | |
22 | # step, next, continue until it ends and, last but not least, quit. | |
23 | # | |
24 | # The goal is not to test gdb functionality, which is done by other tests, | |
25 | # but to verify the correct output response to MI operations. | |
26 | # | |
27 | ||
28 | load_lib mi-support.exp | |
b30bf9ee | 29 | set MIFLAGS "-i=mi" |
fb40c209 AC |
30 | |
31 | gdb_exit | |
32 | if [mi_gdb_start] { | |
33 | continue | |
34 | } | |
35 | ||
36 | set testfile "basics" | |
37 | set srcfile ${testfile}.c | |
38 | set binfile ${objdir}/${subdir}/${testfile} | |
39 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { | |
b60f0898 JB |
40 | untested mi-watch.exp |
41 | return -1 | |
fb40c209 AC |
42 | } |
43 | ||
44 | mi_delete_breakpoints | |
45 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
46 | mi_gdb_load ${binfile} | |
47 | ||
48 | proc test_watchpoint_creation_and_listing {} { | |
49 | global mi_gdb_prompt | |
50 | global srcfile | |
51 | global hex | |
52 | ||
45f07fef MC |
53 | set line_callee4_head [gdb_get_line_number "callee4 ("] |
54 | set line_callee4_body [expr $line_callee4_head + 2] | |
55 | ||
fb40c209 AC |
56 | # Insert a watchpoint and list |
57 | # Tests: | |
58 | # -break-watch C | |
59 | # -break-list | |
60 | ||
61 | mi_gdb_test "111-break-watch C" \ | |
62 | "111\\^done,wpt=\{number=\"2\",exp=\"C\"\}" \ | |
63 | "break-watch operation" | |
64 | ||
65 | mi_gdb_test "222-break-list" \ | |
038224f6 | 66 | "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\",addr=\"\",what=\"C\",times=\"0\"\}\\\]\}" \ |
fb40c209 AC |
67 | "list of watchpoints" |
68 | ||
69 | } | |
70 | ||
71 | # UNUSED at the time | |
72 | proc test_awatch_creation_and_listing {} { | |
73 | global mi_gdb_prompt | |
74 | global srcfile | |
75 | global hex | |
76 | ||
45f07fef MC |
77 | set line_main_head [gdb_get_line_number "main ("] |
78 | set line_main_body [expr $line_main_head + 2] | |
79 | ||
fb40c209 AC |
80 | # Insert an access watchpoint and list it |
81 | # Tests: | |
82 | # -break-watch -a A | |
83 | # -break-list | |
84 | ||
85 | mi_gdb_test "333-break-watch -a A" \ | |
45f07fef | 86 | "333\\^done,bkpt=\{number=\"1\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_main_body\"\}" \ |
fb40c209 AC |
87 | "break-watch -a operation" |
88 | ||
89 | mi_gdb_test "444-break-list" \ | |
45f07fef | 90 | "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 |
91 | "list of watchpoints awatch" |
92 | ||
93 | mi_gdb_test "777-break-delete 3" \ | |
94 | "777\\^done" \ | |
95 | "delete access watchpoint" | |
96 | } | |
97 | ||
98 | # UNUSED at the time | |
99 | proc test_rwatch_creation_and_listing {} { | |
100 | global mi_gdb_prompt | |
101 | global srcfile | |
102 | global hex | |
103 | ||
45f07fef MC |
104 | set line_main_head [gdb_get_line_number "main ("] |
105 | set line_main_body [expr $line_main_head + 2] | |
106 | ||
fb40c209 AC |
107 | # Insert a read watchpoint and list it. |
108 | # Tests: | |
109 | # -break-insert -r B | |
110 | # -break-list | |
111 | ||
112 | mi_gdb_test "200-break-watch -r C" \ | |
45f07fef | 113 | "200\\^done,bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"$line_main_body\",times=\"0\"\}" \ |
fb40c209 AC |
114 | "break-insert -r operation" |
115 | ||
116 | mi_gdb_test "300-break-list" \ | |
45f07fef | 117 | "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 |
118 | "list of breakpoints" |
119 | ||
120 | mi_gdb_test "177-break-delete 4" \ | |
121 | "177\\^done" \ | |
122 | "delete read watchpoint" | |
123 | } | |
124 | ||
fb40c209 AC |
125 | proc test_watchpoint_triggering {} { |
126 | global mi_gdb_prompt | |
76ff342d | 127 | global hex fullname_syntax srcfile |
fb40c209 | 128 | |
45f07fef MC |
129 | set line_callee4_return_0 [gdb_get_line_number "return 0;"] |
130 | set line_callee3_head [gdb_get_line_number "callee3 ("] | |
131 | set line_callee3_close_brace [expr $line_callee3_head + 3] | |
132 | ||
fb40c209 AC |
133 | # Continue execution until the watchpoint is reached, continue again, |
134 | # to see the watchpoint go out of scope. | |
135 | # Does: | |
136 | # -exec-continue (Here wp triggers) | |
137 | # -exec-continue (Here wp goes out of scope) | |
138 | ||
139 | send_gdb "222-exec-continue\n" | |
140 | gdb_expect { | |
141 | -re "222\\^running\r\n$mi_gdb_prompt" { | |
142 | gdb_expect { | |
76ff342d | 143 | -re "222\\*stopped,reason=\"watchpoint-trigger\",wpt=\{number=\"2\",exp=\"C\"\},value=\{old=\".*\",new=\"3\"\},thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"callee4\",args=\\\[\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_return_0\"\}\r\n$mi_gdb_prompt$" { |
fb40c209 AC |
144 | pass "watchpoint trigger" |
145 | } | |
146 | -re ".*$mi_gdb_prompt$" {fail "watchpoint trigger (2)"} | |
147 | timeout {fail "watchpoint trigger (timeout 2)"} | |
148 | } | |
149 | } | |
150 | -re ".*$mi_gdb_prompt$" {fail "watchpoint trigger (1)"} | |
151 | timeout {fail "watchpoint trigger (timeout 1)"} | |
152 | } | |
153 | ||
154 | send_gdb "223-exec-continue\n" | |
155 | gdb_expect { | |
156 | -re "223\\^running\r\n$mi_gdb_prompt" { | |
157 | gdb_expect { | |
76ff342d | 158 | -re "\[\r\n\]*223\\*stopped,reason=\"watchpoint-scope\",wpnum=\"2\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"callee3\",args=\\\[.*\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee3_close_brace\"\}\r\n$mi_gdb_prompt$" { |
fb40c209 AC |
159 | pass "wp out of scope" |
160 | } | |
161 | -re ".*$mi_gdb_prompt$" {fail "wp out of scope (2)"} | |
162 | timeout {fail "wp out of scope (timeout 2)"} | |
163 | } | |
164 | } | |
165 | -re ".*$mi_gdb_prompt$" {fail "wp out of scope (1)"} | |
166 | timeout {fail "wp out of scope (timeout 1)"} | |
167 | } | |
168 | } | |
169 | ||
3e347599 DJ |
170 | # Disable hardware watchpoints if necessary. |
171 | if [target_info exists gdb,no_hardware_watchpoints] { | |
172 | mi_gdb_test "-gdb-set can-use-hw-watchpoints 0" "\\^done" "" | |
173 | } | |
174 | ||
6afa27b0 | 175 | mi_runto callee4 |
fb40c209 AC |
176 | test_watchpoint_creation_and_listing |
177 | #test_rwatch_creation_and_listing | |
178 | #test_awatch_creation_and_listing | |
179 | test_watchpoint_triggering | |
180 | ||
181 | mi_gdb_exit | |
182 | return 0 |