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