Commit | Line | Data |
---|---|---|
42a4f53d | 1 | # Copyright 2007-2019 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 | ||
23 | load_lib mi-support.exp | |
24 | set MIFLAGS "-i=mi" | |
25 | ||
26 | gdb_exit | |
27 | if [mi_gdb_start] { | |
28 | continue | |
29 | } | |
30 | ||
298a9cf0 TT |
31 | standard_testfile var-cmd.c |
32 | ||
9357e021 | 33 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { |
5b362f04 | 34 | untested "failed to compile" |
fada3feb DP |
35 | return -1 |
36 | } | |
37 | # Just change the output binary. | |
298a9cf0 | 38 | set binfile_bis [standard_output_file mi-var-invalidate_bis] |
9357e021 | 39 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile_bis}" executable {debug}] != "" } { |
5b362f04 | 40 | untested "failed to compile" |
fada3feb DP |
41 | return -1 |
42 | } | |
43 | ||
44 | set testfile2 "basics" | |
45 | set srcfile2 ${testfile2}.c | |
298a9cf0 | 46 | set binfile2 [standard_output_file ${testfile2}] |
9357e021 | 47 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug}] != "" } { |
5b362f04 | 48 | untested "failed to compile" |
fada3feb DP |
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. | |
9e8e3afe | 57 | mi_create_varobj global_simple global_simple "create global variable" |
fada3feb DP |
58 | |
59 | mi_runto do_locals_tests | |
60 | ||
61 | # Desc: create local variables | |
9e8e3afe | 62 | mi_create_varobj linteger linteger "create local variable linteger" |
fada3feb | 63 | |
4e969b4f AB |
64 | # Desc: create floating variable |
65 | mi_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 | # | |
71 | mi_delete_breakpoints | |
72 | mi_gdb_load ${binfile_bis} | |
73 | mi_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. | |
77 | mi_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". |
82 | mi_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 | ||
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" \ | |
0cc7d26f | 108 | "\\^done,changelist=\\\[\{name=\"linteger\",in_scope=\"invalid\",has_more=\"0\"\}\\\]" \ |
fada3feb DP |
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" \ | |
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 | ||
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 |