1 # Copyright 2007-2012 Free Software Foundation, Inc.
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 3 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # Test essential Machine interface (MI) operations
18 # Verify that once binary file has changed, GDB correctly handles
19 # previously defined MI variables.
23 load_lib mi-support.exp
31 standard_testfile var-cmd.c
33 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
34 untested mi-var-invalidate.exp
37 # Just change the output binary.
38 set binfile_bis [standard_output_file mi-var-invalidate_bis]
39 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile_bis}" executable {debug}] != "" } {
40 untested mi-var-invalidate.exp
44 set testfile2 "basics"
45 set srcfile2 ${testfile2}.c
46 set binfile2 [standard_output_file ${testfile2}]
47 if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug}] != "" } {
48 untested mi-var-invalidate.exp
53 mi_gdb_reinitialize_dir $srcdir/$subdir
54 mi_gdb_load ${binfile}
56 # Desc: Create global variable.
57 mi_create_varobj global_simple global_simple "create global variable"
59 mi_runto do_locals_tests
61 # Desc: create local variables
62 mi_create_varobj linteger linteger "create local variable linteger"
64 # Desc: create floating variable
65 mi_create_floating_varobj float_simple array "create floating variable"
68 # Reload the same binary.
69 # Global variable should remain, local should be invalidated.
72 mi_gdb_load ${binfile_bis}
75 # Change format of floating variable immediately after reload reveals a
76 # bug where gdb still uses a free'd pointer.
77 mi_gdb_test "-var-set-format float_simple hexadecimal" \
78 "\\^done,format=\"hexadecimal\",value=\"\\\[-1\\\]\"" \
79 "set format variable float_simple"
81 # Check local variable is "invalid".
82 mi_gdb_test "-var-update linteger" \
83 "\\^done,changelist=\\\[\{name=\"linteger\",in_scope=\"invalid\",has_more=\"0\"\}\\\]" \
84 "linteger not anymore in scope due to binary changes"
86 mi_gdb_test "-var-info-type linteger" \
88 "no type for invalid variable linteger (1)"
90 # Check global variable is still correct.
91 mi_gdb_test "-var-update global_simple" \
92 "\\^done,changelist=\\\[\]" \
93 "global_simple still alive"
95 mi_gdb_test "-var-info-type global_simple" \
96 "\\^done,type=\"simpleton\"" \
97 "type simpleton for valid variable global_simple"
101 # Load an other binary.
102 # All variables must be invalidated.
104 mi_delete_breakpoints
105 mi_gdb_load ${binfile2}
106 # Check local variable are "invalid"
107 mi_gdb_test "-var-update linteger" \
108 "\\^done,changelist=\\\[\{name=\"linteger\",in_scope=\"invalid\",has_more=\"0\"\}\\\]" \
109 "linteger not valid anymore due to binary changes"
111 mi_gdb_test "-var-info-type linteger" \
112 "\\^done,type=\"\"" \
113 "no type for invalid variable linteger (2)"
115 # Check global variable are still correct.
116 mi_gdb_test "-var-update global_simple" \
117 "\\^done,changelist=\\\[\{name=\"global_simple\",in_scope=\"invalid\",has_more=\"0\"\}\\\]" \
118 "global_simple not anymore in scope due to binary changes"
120 mi_gdb_test "-var-info-type global_simple" \
121 "\\^done,type=\"\"" \
122 "no type for invalid variable global_simple"