]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.mi/mi-var-invalidate.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-var-invalidate.exp
1 # Copyright 2007-2024 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 standard_testfile var-cmd.c
27
28 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
29 untested "failed to compile"
30 return -1
31 }
32 # Just change the output binary.
33 set binfile_bis [standard_output_file mi-var-invalidate_bis]
34 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile_bis}" executable {debug}] != "" } {
35 untested "failed to compile"
36 return -1
37 }
38
39 set testfile2 "basics"
40 set srcfile2 ${testfile2}.c
41 set binfile2 [standard_output_file ${testfile2}]
42 if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug}] != "" } {
43 untested "failed to compile"
44 return -1
45 }
46
47 if {[mi_clean_restart $binfile]} {
48 return
49 }
50
51 # Desc: Create global variable.
52 mi_create_varobj global_simple global_simple "create global variable"
53
54 mi_runto do_locals_tests
55
56 # Desc: create local variables
57 mi_create_varobj linteger linteger "create local variable linteger"
58
59 # Desc: create floating variable
60 mi_create_floating_varobj float_simple array "create floating variable"
61
62 #
63 # Reload the same binary.
64 # Global variable should remain, local should be invalidated.
65 #
66 mi_delete_breakpoints
67 mi_gdb_load ${binfile_bis}
68 mi_runto_main
69
70 # Change format of floating variable immediately after reload reveals a
71 # bug where gdb still uses a free'd pointer.
72 mi_gdb_test "-var-set-format float_simple hexadecimal" \
73 "\\^done,format=\"hexadecimal\",value=\"\\\[3\\\]\"" \
74 "set format variable float_simple"
75
76 # Check local variable is "invalid".
77 mi_gdb_test "-var-update linteger" \
78 "\\^done,changelist=\\\[\{name=\"linteger\",in_scope=\"invalid\",has_more=\"0\"\}\\\]" \
79 "linteger not anymore in scope due to binary changes"
80
81 mi_gdb_test "-var-info-type linteger" \
82 "\\^done,type=\"\"" \
83 "no type for invalid variable linteger (1)"
84
85 # Check global variable is still correct.
86 mi_gdb_test "-var-update global_simple" \
87 "\\^done,changelist=\\\[\]" \
88 "global_simple still alive"
89
90 mi_gdb_test "-var-info-type global_simple" \
91 "\\^done,type=\"simpleton\"" \
92 "type simpleton for valid variable global_simple"
93
94
95 #
96 # Load an other binary.
97 # All variables must be invalidated.
98 #
99 mi_delete_breakpoints
100 mi_gdb_load ${binfile2}
101 # Check local variable are "invalid"
102 mi_gdb_test "-var-update linteger" \
103 "\\^done,changelist=\\\[\{name=\"linteger\",in_scope=\"invalid\",has_more=\"0\"\}\\\]" \
104 "linteger not valid anymore due to binary changes"
105
106 mi_gdb_test "-var-info-type linteger" \
107 "\\^done,type=\"\"" \
108 "no type for invalid variable linteger (2)"
109
110 # Check global variable are still correct.
111 mi_gdb_test "-var-update global_simple" \
112 "\\^done,changelist=\\\[\{name=\"global_simple\",in_scope=\"invalid\",has_more=\"0\"\}\\\]" \
113 "global_simple not anymore in scope due to binary changes"
114
115 mi_gdb_test "-var-info-type global_simple" \
116 "\\^done,type=\"\"" \
117 "no type for invalid variable global_simple"
118
119 mi_gdb_exit