1 |
1181 |
sfurman |
# Copyright 1999, 2000 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 2 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, write to the Free Software
|
15 |
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16 |
|
|
|
17 |
|
|
# Please email any bugs, comments, and/or additions to this file to:
|
18 |
|
|
# bug-gdb@prep.ai.mit.edu
|
19 |
|
|
|
20 |
|
|
#
|
21 |
|
|
# Test essential Machine interface (MI) operations
|
22 |
|
|
#
|
23 |
|
|
# Verify that, using the MI, we can run a simple program and perform basic
|
24 |
|
|
# debugging activities like: insert breakpoints, run the program,
|
25 |
|
|
# step, next, continue until it ends and, last but not least, quit.
|
26 |
|
|
#
|
27 |
|
|
# The goal is not to test gdb functionality, which is done by other tests,
|
28 |
|
|
# but to verify the correct output response to MI operations.
|
29 |
|
|
#
|
30 |
|
|
|
31 |
|
|
load_lib mi-support.exp
|
32 |
|
|
set MIFLAGS "-i=mi"
|
33 |
|
|
|
34 |
|
|
gdb_exit
|
35 |
|
|
if [mi_gdb_start] {
|
36 |
|
|
continue
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
set testfile "basics"
|
40 |
|
|
set srcfile ${testfile}.c
|
41 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
42 |
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
|
43 |
|
|
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
mi_delete_breakpoints
|
47 |
|
|
mi_gdb_reinitialize_dir $srcdir/$subdir
|
48 |
|
|
mi_gdb_load ${binfile}
|
49 |
|
|
|
50 |
|
|
proc test_watchpoint_creation_and_listing {} {
|
51 |
|
|
global mi_gdb_prompt
|
52 |
|
|
global srcfile
|
53 |
|
|
global hex
|
54 |
|
|
|
55 |
|
|
# Insert a watchpoint and list
|
56 |
|
|
# Tests:
|
57 |
|
|
# -break-watch C
|
58 |
|
|
# -break-list
|
59 |
|
|
|
60 |
|
|
mi_gdb_test "111-break-watch C" \
|
61 |
|
|
"111\\^done,wpt=\{number=\"2\",exp=\"C\"\}" \
|
62 |
|
|
"break-watch operation"
|
63 |
|
|
|
64 |
|
|
mi_gdb_test "222-break-list" \
|
65 |
|
|
"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=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"8\",times=\"1\"\},bkpt=\{number=\"2\",type=\".*watchpoint\",disp=\"keep\",enabled=\"y\",addr=\"\",what=\"C\",times=\"0\"\}\\\]\}" \
|
66 |
|
|
"list of watchpoints"
|
67 |
|
|
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
# UNUSED at the time
|
71 |
|
|
proc test_awatch_creation_and_listing {} {
|
72 |
|
|
global mi_gdb_prompt
|
73 |
|
|
global srcfile
|
74 |
|
|
global hex
|
75 |
|
|
|
76 |
|
|
# Insert an access watchpoint and list it
|
77 |
|
|
# Tests:
|
78 |
|
|
# -break-watch -a A
|
79 |
|
|
# -break-list
|
80 |
|
|
|
81 |
|
|
mi_gdb_test "333-break-watch -a A" \
|
82 |
|
|
"333\\^done,bkpt=\{number=\"1\",addr=\"$hex\",file=\".*basics.c\",line=\"32\"\}" \
|
83 |
|
|
"break-watch -a operation"
|
84 |
|
|
|
85 |
|
|
mi_gdb_test "444-break-list" \
|
86 |
|
|
"444\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"3\",type=\"watchpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\},.*\}\\\]\}" \
|
87 |
|
|
"list of watchpoints awatch"
|
88 |
|
|
|
89 |
|
|
mi_gdb_test "777-break-delete 3" \
|
90 |
|
|
"777\\^done" \
|
91 |
|
|
"delete access watchpoint"
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
# UNUSED at the time
|
95 |
|
|
proc test_rwatch_creation_and_listing {} {
|
96 |
|
|
global mi_gdb_prompt
|
97 |
|
|
global srcfile
|
98 |
|
|
global hex
|
99 |
|
|
|
100 |
|
|
# Insert a read watchpoint and list it.
|
101 |
|
|
# Tests:
|
102 |
|
|
# -break-insert -r B
|
103 |
|
|
# -break-list
|
104 |
|
|
|
105 |
|
|
mi_gdb_test "200-break-watch -r C" \
|
106 |
|
|
"200\\^done,bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"32\",times=\"0\"\}" \
|
107 |
|
|
"break-insert -r operation"
|
108 |
|
|
|
109 |
|
|
mi_gdb_test "300-break-list" \
|
110 |
|
|
"300\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\},.*\}\\\}\}" \
|
111 |
|
|
"list of breakpoints"
|
112 |
|
|
|
113 |
|
|
mi_gdb_test "177-break-delete 4" \
|
114 |
|
|
"177\\^done" \
|
115 |
|
|
"delete read watchpoint"
|
116 |
|
|
}
|
117 |
|
|
|
118 |
|
|
proc test_running_the_program {} {
|
119 |
|
|
global mi_gdb_prompt
|
120 |
|
|
global hex
|
121 |
|
|
|
122 |
|
|
# Run the program without args, then specify srgs and rerun the program
|
123 |
|
|
# Tests:
|
124 |
|
|
# -exec-run
|
125 |
|
|
|
126 |
|
|
mi_gdb_test "300-break-insert callee4" \
|
127 |
|
|
"300\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"8\",times=\"0\"\}" \
|
128 |
|
|
"insert breakpoint at callee4"
|
129 |
|
|
|
130 |
|
|
# mi_gdb_test cannot be used for asynchronous commands because there are
|
131 |
|
|
# two prompts involved and this can lead to a race condition.
|
132 |
|
|
# The following is equivalent to a send_gdb "000-exec-run\n"
|
133 |
|
|
mi_run_cmd
|
134 |
|
|
# The running part has been checked already by mi_run_cmd
|
135 |
|
|
gdb_expect {
|
136 |
|
|
-re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"callee4\",args=\\\[\\\],file=\".*basics.c\",line=\"8\"\}\r\n$mi_gdb_prompt$" \
|
137 |
|
|
{ pass "run to callee4" }
|
138 |
|
|
-re ".*$mi_gdb_prompt$" {fail "run to callee4 (2)"}
|
139 |
|
|
timeout {fail "run to callee4 (timeout 2)"}
|
140 |
|
|
}
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
proc test_watchpoint_triggering {} {
|
144 |
|
|
global mi_gdb_prompt
|
145 |
|
|
global hex
|
146 |
|
|
|
147 |
|
|
# Continue execution until the watchpoint is reached, continue again,
|
148 |
|
|
# to see the watchpoint go out of scope.
|
149 |
|
|
# Does:
|
150 |
|
|
# -exec-continue (Here wp triggers)
|
151 |
|
|
# -exec-continue (Here wp goes out of scope)
|
152 |
|
|
|
153 |
|
|
send_gdb "222-exec-continue\n"
|
154 |
|
|
gdb_expect {
|
155 |
|
|
-re "222\\^running\r\n$mi_gdb_prompt" {
|
156 |
|
|
gdb_expect {
|
157 |
|
|
-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\",line=\"13\"\}\r\n$mi_gdb_prompt$" {
|
158 |
|
|
pass "watchpoint trigger"
|
159 |
|
|
}
|
160 |
|
|
-re ".*$mi_gdb_prompt$" {fail "watchpoint trigger (2)"}
|
161 |
|
|
timeout {fail "watchpoint trigger (timeout 2)"}
|
162 |
|
|
}
|
163 |
|
|
}
|
164 |
|
|
-re ".*$mi_gdb_prompt$" {fail "watchpoint trigger (1)"}
|
165 |
|
|
timeout {fail "watchpoint trigger (timeout 1)"}
|
166 |
|
|
}
|
167 |
|
|
|
168 |
|
|
send_gdb "223-exec-continue\n"
|
169 |
|
|
gdb_expect {
|
170 |
|
|
-re "223\\^running\r\n$mi_gdb_prompt" {
|
171 |
|
|
gdb_expect {
|
172 |
|
|
-re "\[\r\n\]*223\\*stopped,reason=\"watchpoint-scope\",wpnum=\"2\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"callee3\",args=\\\[.*\\\],file=\".*basics.c\",line=\"18\"\}\r\n$mi_gdb_prompt$" {
|
173 |
|
|
pass "wp out of scope"
|
174 |
|
|
}
|
175 |
|
|
-re ".*$mi_gdb_prompt$" {fail "wp out of scope (2)"}
|
176 |
|
|
timeout {fail "wp out of scope (timeout 2)"}
|
177 |
|
|
}
|
178 |
|
|
}
|
179 |
|
|
-re ".*$mi_gdb_prompt$" {fail "wp out of scope (1)"}
|
180 |
|
|
timeout {fail "wp out of scope (timeout 1)"}
|
181 |
|
|
}
|
182 |
|
|
}
|
183 |
|
|
|
184 |
|
|
test_running_the_program
|
185 |
|
|
test_watchpoint_creation_and_listing
|
186 |
|
|
#test_rwatch_creation_and_listing
|
187 |
|
|
#test_awatch_creation_and_listing
|
188 |
|
|
test_watchpoint_triggering
|
189 |
|
|
|
190 |
|
|
mi_gdb_exit
|
191 |
|
|
return 0
|