]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.mi/mi-simplerun.exp
This commit was manufactured by cvs2svn to create branch
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-simplerun.exp
CommitLineData
9b254dd1
DJ
1# Copyright 1999, 2000, 2001, 2002, 2004, 2007, 2008
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
28load_lib mi-support.exp
b30bf9ee 29set MIFLAGS "-i=mi"
fb40c209
AC
30
31gdb_exit
32if [mi_gdb_start] {
33 continue
34}
35
36set testfile "basics"
37set srcfile ${testfile}.c
38set binfile ${objdir}/${subdir}/${testfile}
39if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
b60f0898
JB
40 untested mi-simplerun.exp
41 return -1
fb40c209
AC
42}
43
44mi_delete_breakpoints
45mi_gdb_reinitialize_dir $srcdir/$subdir
46mi_gdb_reinitialize_dir $srcdir/$subdir
47mi_gdb_load ${binfile}
48
49proc test_breakpoints_creation_and_listing {} {
50 global mi_gdb_prompt
51 global srcfile
52 global hex
53
45f07fef 54 set line_callee4_head [gdb_get_line_number "callee4 ("]
b40e7bf3 55 set line_callee4_body [expr $line_callee4_head + 2]
45f07fef 56 set line_callee3_head [gdb_get_line_number "callee3 ("]
b40e7bf3 57 set line_callee3_body [expr $line_callee3_head + 2]
45f07fef
MC
58 set line_callee2_head [gdb_get_line_number "callee2 ("]
59 set line_callee2_body [expr $line_callee2_head + 2]
60 set line_main_head [gdb_get_line_number "main ("]
61 set line_main_body [expr $line_main_head + 2]
62
fb40c209
AC
63 # Insert some breakpoints and list them
64 # Also, disable some so they do not interfere with other tests
65 # Tests:
66 # -break-insert
67 # -break-list
68 # -break-disable
69 # -break-info
70
d24317b4 71 mi_create_breakpoint "main" 1 keep main ".*basics.c" $line_main_body $hex \
fb40c209
AC
72 "break-insert operation"
73
d24317b4 74 mi_create_breakpoint "basics.c:callee2" 2 keep callee2 ".*basics.c" $line_callee2_body $hex \
fb40c209
AC
75 "insert breakpoint at basics.c:callee2"
76
d24317b4 77 mi_create_breakpoint "basics.c:$line_callee3_head" 3 keep callee3 ".*basics.c" $line_callee3_body $hex \
45f07fef 78 "insert breakpoint at basics.c:\$line_callee3_head"
fb40c209 79
d24317b4 80 mi_create_breakpoint "\"\\\"${srcfile}\\\":$line_callee4_head\"" 4 keep callee4 ".*basics.c" $line_callee4_body $hex \
45f07fef 81 "insert breakpoint at \"<fullfilename>\":\$line_callee4_head"
fb40c209
AC
82
83 mi_gdb_test "204-break-list" \
d24317b4 84 "204\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"$line_main_body\",times=\"0\",original-location=\".*\"\},.*\}\\\]\}" \
fb40c209
AC
85 "list of breakpoints"
86
87 mi_gdb_test "205-break-disable 2 3 4" \
88 "205\\^done.*" \
89 "disabling of breakpoints"
90
91 mi_gdb_test "206-break-info 2" \
cff22675 92 "206\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"2\",.*,enabled=\"n\",.*\}\\\]\}" \
fb40c209
AC
93 "list of breakpoints, 16 disabled"
94}
95
96proc test_running_the_program {} {
97 global mi_gdb_prompt
98 global hex
99
45f07fef
MC
100 set line_main_head [gdb_get_line_number "main ("]
101 set line_main_body [expr $line_main_head + 2]
102
fb40c209
AC
103 # Run the program without args, then specify srgs and rerun the program
104 # Tests:
105 # -exec-run
106 # -gdb-set
107
108 # mi_gdb_test cannot be used for asynchronous commands because there are
109 # two prompts involved and this can lead to a race condition.
110 # The following is equivalent to a send_gdb "000-exec-run\n"
111 mi_run_cmd
18ac113b
AR
112 mi_expect_stop "breakpoint-hit" "main" "" ".*basics.c" "$line_main_body" \
113 { "" "disp=\"keep\"" } "run to main"
fb40c209
AC
114}
115
116proc test_controlled_execution {} {
117 global mi_gdb_prompt
118 global hex
119
45f07fef
MC
120 set line_callee4_head [gdb_get_line_number "callee4 ("]
121 set line_callee4_body [expr $line_callee4_head + 2]
122 set line_callee3_head [gdb_get_line_number "callee3 ("]
471ba8c9 123 set line_callee3_call [expr $line_callee3_head + 2]
45f07fef
MC
124 set line_callee3_close_brace [expr $line_callee3_head + 3]
125 set line_callee1_head [gdb_get_line_number "callee1 ("]
126 set line_callee1_body [expr $line_callee1_head + 2]
127 set line_main_head [gdb_get_line_number "main ("]
128 set line_main_body [expr $line_main_head + 2]
129
fb40c209
AC
130 # Continue execution until a breakpoint is reached, step into calls, verifying
131 # if the arguments are correctly shown, continue to the end of a called
132 # function, step over a call (next).
133 # Tests:
134 # -exec-continue
135 # -exec-next
136 # -exec-step
137 # -exec-finish
138
45f07fef 139 mi_next_to "main" "" "basics.c" [expr $line_main_body + 1] "next at main"
fb40c209
AC
140
141 # FIXME: A string argument is not printed right; should be fixed and
142 # we should look for the right thing here.
143 # NOTE: The ``\\\\\"'' is for \".
dcf95b47
DJ
144 mi_step_to "callee1" \
145 "\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\},\{name=\"fltarg\",value=\"3.5\"\}" \
45f07fef 146 "basics.c" "$line_callee1_body" "step at main"
fb40c209
AC
147
148 # FIXME: A string argument is not printed right; should be fixed and
149 # we should look for the right thing here.
fc5cfef4 150 mi_execute_to "exec-step 3" "end-stepping-range" "callee4" "" \
45f07fef 151 "basics.c" $line_callee4_body "" "step to callee4"
fb40c209
AC
152
153 # FIXME: A string argument is not printed right; should be fixed and
154 # we should look for the right thing here.
155 # NOTE: The ``.'' is part of ``gdb-result-var="$1"''
471ba8c9
DJ
156 mi_finish_to "callee3" ".*" "basics.c" \
157 "($line_callee3_call|$line_callee3_close_brace)" ".1" "0" "exec-finish"
fb40c209
AC
158}
159
160proc test_controlling_breakpoints {} {
161 global mi_gdb_prompt
162
163 # Enable, delete, set ignore counts in breakpoints
164 # (disable was already tested above)
165 # Tests:
166 # -break-delete
167 # -break-enable
168 # -break-after
169 # -break-condition
170
171}
172
173proc test_program_termination {} {
174 global mi_gdb_prompt
175
176 # Run to completion: normal and forced
177 # Tests:
178 # -exec-abort
179 # (normal termination of inferior)
180
bb378428 181 mi_execute_to "exec-continue" "exited-normally" "" "" "" "" "" "continue to end"
fb40c209
AC
182}
183
184test_breakpoints_creation_and_listing
185test_running_the_program
186test_controlled_execution
187test_controlling_breakpoints
188test_program_termination
189
190mi_gdb_exit
191return 0