]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.mi/mi-var-invalidate.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-var-invalidate.exp
CommitLineData
8acc9f48 1# Copyright 2007-2013 Free Software Foundation, Inc.
fada3feb
DP
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
fada3feb
DP
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
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
fada3feb
DP
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
23load_lib mi-support.exp
24set MIFLAGS "-i=mi"
25
26gdb_exit
27if [mi_gdb_start] {
28 continue
29}
30
298a9cf0
TT
31standard_testfile var-cmd.c
32
9357e021 33if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
fada3feb
DP
34 untested mi-var-invalidate.exp
35 return -1
36}
37# Just change the output binary.
298a9cf0 38set binfile_bis [standard_output_file mi-var-invalidate_bis]
9357e021 39if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile_bis}" executable {debug}] != "" } {
fada3feb
DP
40 untested mi-var-invalidate.exp
41 return -1
42}
43
44set testfile2 "basics"
45set srcfile2 ${testfile2}.c
298a9cf0 46set binfile2 [standard_output_file ${testfile2}]
9357e021 47if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug}] != "" } {
fada3feb
DP
48 untested mi-var-invalidate.exp
49 return -1
50}
51
52mi_delete_breakpoints
53mi_gdb_reinitialize_dir $srcdir/$subdir
54mi_gdb_load ${binfile}
55
56# Desc: Create global variable.
9e8e3afe 57mi_create_varobj global_simple global_simple "create global variable"
fada3feb
DP
58
59mi_runto do_locals_tests
60
61# Desc: create local variables
9e8e3afe 62mi_create_varobj linteger linteger "create local variable linteger"
fada3feb 63
4e969b4f
AB
64# Desc: create floating variable
65mi_create_floating_varobj float_simple array "create floating variable"
66
fada3feb
DP
67#
68# Reload the same binary.
69# Global variable should remain, local should be invalidated.
70#
71mi_delete_breakpoints
72mi_gdb_load ${binfile_bis}
73mi_runto main
74
4e969b4f
AB
75# Change format of floating variable immediately after reload reveals a
76# bug where gdb still uses a free'd pointer.
77mi_gdb_test "-var-set-format float_simple hexadecimal" \
78 "\\^done,format=\"hexadecimal\",value=\"\\\[-1\\\]\"" \
79 "set format variable float_simple"
80
fada3feb
DP
81# Check local variable is "invalid".
82mi_gdb_test "-var-update linteger" \
0cc7d26f 83 "\\^done,changelist=\\\[\{name=\"linteger\",in_scope=\"invalid\",has_more=\"0\"\}\\\]" \
fada3feb
DP
84 "linteger not anymore in scope due to binary changes"
85
86mi_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.
91mi_gdb_test "-var-update global_simple" \
92 "\\^done,changelist=\\\[\]" \
93 "global_simple still alive"
94
95mi_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#
104mi_delete_breakpoints
105mi_gdb_load ${binfile2}
106# Check local variable are "invalid"
107mi_gdb_test "-var-update linteger" \
0cc7d26f 108 "\\^done,changelist=\\\[\{name=\"linteger\",in_scope=\"invalid\",has_more=\"0\"\}\\\]" \
fada3feb
DP
109 "linteger not valid anymore due to binary changes"
110
111mi_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.
116mi_gdb_test "-var-update global_simple" \
0cc7d26f 117 "\\^done,changelist=\\\[\{name=\"global_simple\",in_scope=\"invalid\",has_more=\"0\"\}\\\]" \
fada3feb
DP
118 "global_simple not anymore in scope due to binary changes"
119
120mi_gdb_test "-var-info-type global_simple" \
121 "\\^done,type=\"\"" \
122 "no type for invalid variable global_simple"
123
124mi_gdb_exit
125return 0