Commit | Line | Data |
---|---|---|
2fcf52f0 AC |
1 | # Copyright (C) 1999, 2000, 2002 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 | # Test essential Machine interface (MI) operations | |
21 | # | |
22 | # Verify that, using the MI, we can create, update, delete variables. | |
23 | # | |
24 | ||
25 | ||
26 | load_lib mi-support.exp | |
27 | set MIFLAGS "-i=mi2" | |
28 | ||
29 | gdb_exit | |
30 | if [mi_gdb_start] { | |
31 | continue | |
32 | } | |
33 | ||
34 | set testfile "var-cmd" | |
35 | set srcfile ${testfile}.c | |
36 | set binfile ${objdir}/${subdir}/${testfile} | |
37 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { | |
38 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
39 | } | |
40 | ||
41 | mi_delete_breakpoints | |
42 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
43 | mi_gdb_load ${binfile} | |
44 | ||
45 | mi_runto do_block_tests | |
46 | ||
47 | # Test: c_variable-3.2 | |
48 | # Desc: create cb and foo | |
49 | mi_gdb_test "-var-create cb * cb" \ | |
50 | "\\^done,name=\"cb\",numchild=\"0\",type=\"int\"" \ | |
51 | "create local variable cb" | |
52 | ||
53 | mi_gdb_test "-var-create foo * foo" \ | |
54 | "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \ | |
55 | "create local variable foo" | |
56 | ||
57 | # step to "foo = 123;" | |
58 | mi_step_to "do_block_tests" "" "var-cmd.c" "158" "step at do_block_test" | |
59 | ||
60 | ||
61 | # Be paranoid and assume 3.2 created foo | |
62 | mi_gdb_test "-var-delete foo" \ | |
63 | "&\"Variable object not found\\\\n\".*\\^error,msg=\"Variable object not found\"" \ | |
64 | "delete var foo" | |
65 | ||
66 | ||
67 | # Test: c_variable-3.3 | |
68 | # Desc: create foo | |
69 | mi_gdb_test "-var-create foo * foo" \ | |
70 | "\\^done,name=\"foo\",numchild=\"0\",type=\"int\"" \ | |
71 | "create local variable foo" | |
72 | ||
73 | # step to "foo2 = 123;" | |
74 | mi_step_to "do_block_tests" "" "var-cmd.c" "161" "step at do_block_test" | |
75 | ||
76 | # Test: c_variable-3.4 | |
77 | # Desc: check foo, cb changed | |
78 | mi_gdb_test "-var-update *" \ | |
79 | "\\^done,changelist=\\\[\{name=\"foo\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"cb\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ | |
80 | "update all vars: cb foo changed" | |
81 | ||
82 | # step to "foo = 321;" | |
83 | mi_step_to "do_block_tests" "" "var-cmd.c" "164" "step at do_block_test" | |
84 | ||
85 | # Test: c_variable-3.5 | |
86 | # Desc: create inner block foo | |
87 | mi_gdb_test "-var-create inner_foo * foo" \ | |
88 | "\\^done,name=\"inner_foo\",numchild=\"0\",type=\"int\"" \ | |
89 | "create local variable inner_foo" | |
90 | ||
91 | # step to "foo2 = 0;" | |
92 | mi_step_to "do_block_tests" "" "var-cmd.c" "166" "step at do_block_test" | |
93 | ||
94 | # Test: c_variable-3.6 | |
95 | # Desc: create foo2 | |
96 | mi_gdb_test "-var-create foo2 * foo2" \ | |
97 | "\\^done,name=\"foo2\",numchild=\"0\",type=\"int\"" \ | |
98 | "create local variable foo2" | |
99 | ||
100 | # Test: c_variable-3.7 | |
101 | # Desc: check that outer foo in scope and inner foo out of scope | |
102 | # Note: also a known gdb problem | |
103 | setup_xfail *-*-* | |
104 | mi_gdb_test "-var-update inner_foo" \ | |
105 | "\\^done,changelist=\{FIXME\}" \ | |
106 | "update inner_foo: should be out of scope: KNOWN PROBLEM" | |
107 | clear_xfail *-*-* | |
108 | ||
109 | setup_xfail *-*-* | |
110 | mi_gdb_test "-var-evaluate-expression inner_foo" \ | |
111 | "\\^done,value=\{FIXME\}" \ | |
112 | "evaluate inner_foo: should be out of scope: KNOWN PROBLEM" | |
113 | clear_xfail *-*-* | |
114 | ||
115 | mi_gdb_test "-var-update foo" \ | |
116 | "\\^done,changelist=\\\[\\\]" \ | |
117 | "update foo: did not change" | |
118 | ||
119 | mi_gdb_test "-var-delete inner_foo" \ | |
120 | "\\^done,ndeleted=\"1\"" \ | |
121 | "delete var inner_foo" | |
122 | ||
123 | # step to "foo = 0;" | |
124 | mi_step_to "do_block_tests" "" "var-cmd.c" "168" "step at do_block_test" | |
125 | ||
126 | # Test: c_variable-3.8 | |
127 | # Desc: check that foo2 out of scope (known gdb problem) | |
128 | setup_xfail *-*-* | |
129 | mi_gdb_test "-var-update foo2" \ | |
130 | "\\^done,changelist=\{FIXME\}" \ | |
131 | "update foo2: should be out of scope: KNOWN PROBLEM" | |
132 | clear_xfail *-*-* | |
133 | ||
134 | # step to "cb = 21;" | |
135 | mi_step_to "do_block_tests" "" "var-cmd.c" "171" "step at do_block_test" | |
136 | ||
137 | # Test: c_variable-3.9 | |
138 | # Desc: check that only cb is in scope (known gdb problem) | |
139 | setup_xfail *-*-* | |
140 | mi_gdb_test "-var-update foo2" \ | |
141 | "\\^done,changelist=\\\[FIXME\\\]" \ | |
142 | "update foo2 should be out of scope: KNOWN PROBLEM" | |
143 | clear_xfail *-*-* | |
144 | setup_xfail *-*-* | |
145 | mi_gdb_test "-var-update foo" \ | |
146 | "\\^done,changelist=\{FIXME\}" \ | |
147 | "update foo should be out of scope: KNOWN PROBLEM" | |
148 | clear_xfail *-*-* | |
149 | mi_gdb_test "-var-update cb" \ | |
150 | "\\^done,changelist=\\\[\\\]" \ | |
151 | "update cb" | |
152 | ||
153 | # Test: c_variable-3.10 | |
154 | # Desc: names of editable variables | |
155 | #gdbtk_test c_variable-3.10 {names of editable variables} { | |
156 | # editable_variables | |
157 | #} {{foo cb foo2} {}} | |
158 | ||
159 | # Done with block tests | |
160 | mi_gdb_test "-var-delete foo" \ | |
161 | "\\^done,ndeleted=\"1\"" \ | |
162 | "delete var foo" | |
163 | ||
164 | mi_gdb_test "-var-delete foo2" \ | |
165 | "\\^done,ndeleted=\"1\"" \ | |
166 | "delete var foo2" | |
167 | ||
168 | mi_gdb_test "-var-delete cb" \ | |
169 | "\\^done,ndeleted=\"1\"" \ | |
170 | "delete var cb" | |
171 | ||
172 | mi_gdb_exit | |
173 | return 0 |