]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.mi/mi-var-invalidate.exp
3a61624ba82c262e7c1129e783cb2a9d20f2966d
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-var-invalidate.exp
1 # Copyright 2007-2013 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 3 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, see <http://www.gnu.org/licenses/>.
15 #
16 # Test essential Machine interface (MI) operations
17 #
18 # Verify that once binary file has changed, GDB correctly handles
19 # previously defined MI variables.
20 #
21
22
23 load_lib mi-support.exp
24 set MIFLAGS "-i=mi"
25
26 gdb_exit
27 if [mi_gdb_start] {
28 continue
29 }
30
31 standard_testfile var-cmd.c
32
33 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
34 untested mi-var-invalidate.exp
35 return -1
36 }
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
41 return -1
42 }
43
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
49 return -1
50 }
51
52 mi_delete_breakpoints
53 mi_gdb_reinitialize_dir $srcdir/$subdir
54 mi_gdb_load ${binfile}
55
56 # Desc: Create global variable.
57 mi_create_varobj global_simple global_simple "create global variable"
58
59 mi_runto do_locals_tests
60
61 # Desc: create local variables
62 mi_create_varobj linteger linteger "create local variable linteger"
63
64 # Desc: create floating variable
65 mi_create_floating_varobj float_simple array "create floating variable"
66
67 #
68 # Reload the same binary.
69 # Global variable should remain, local should be invalidated.
70 #
71 mi_delete_breakpoints
72 mi_gdb_load ${binfile_bis}
73 mi_runto main
74
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"
80
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"
85
86 mi_gdb_test "-var-info-type linteger" \
87 "\\^done,type=\"\"" \
88 "no type for invalid variable linteger (1)"
89
90 # Check global variable is still correct.
91 mi_gdb_test "-var-update global_simple" \
92 "\\^done,changelist=\\\[\]" \
93 "global_simple still alive"
94
95 mi_gdb_test "-var-info-type global_simple" \
96 "\\^done,type=\"simpleton\"" \
97 "type simpleton for valid variable global_simple"
98
99
100 #
101 # Load an other binary.
102 # All variables must be invalidated.
103 #
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"
110
111 mi_gdb_test "-var-info-type linteger" \
112 "\\^done,type=\"\"" \
113 "no type for invalid variable linteger (2)"
114
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"
119
120 mi_gdb_test "-var-info-type global_simple" \
121 "\\^done,type=\"\"" \
122 "no type for invalid variable global_simple"
123
124 mi_gdb_exit
125 return 0