gdb/testsuite/
[external/binutils.git] / gdb / testsuite / gdb.mi / mi-inheritance-syntax-error.exp
1 # Copyright 2011
2 # Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 if { [skip_cplus_tests] } { continue }
18
19 load_lib mi-support.exp
20 set MIFLAGS "-i=mi"
21
22 gdb_exit
23 if [mi_gdb_start] {
24     continue
25 }
26
27 set testfile mi-inheritance-syntax-error
28 set srcfile "$testfile.cc"
29 set binfile $objdir/$subdir/$testfile
30
31 if [get_compiler_info ${binfile} "c++"] {
32     return -1;
33 }
34
35 if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable {debug c++}] != ""} {
36   untested mi-inheritance-syntax-error.exp
37   return -1
38 }
39
40 # Test that children of derived classes are given the proper
41 # path by -var-info-path-expression
42
43 mi_gdb_load ${binfile}
44 mi_runto C::testLocation
45
46 mi_create_varobj "var1" "this" "create var for THIS"
47
48 mi_list_varobj_children "var1" {
49     {var1.A A 1 A}
50     {var1.public public 1}
51 } "list children of THIS"
52
53 # We don't care what the result of -var-info-path-expression
54 # as long as it can be used in the -data-evaluate-expression
55 # that follows
56 mi_gdb_test "-var-info-path-expression var1.A" \
57     "\\^done,path_expr=\".*\"" \
58     "-var-info-path-expression var1.A"
59
60 # Extract the result of the -var-info-path-expression command
61 # to use it in -data-evaluate-expression
62 set cmd_output $expect_out(2,string)
63 set path [lindex [split $cmd_output "\""] 1]
64 verbose "var-info-path-expression returned $cmd_output" 2
65 verbose "Using $path for data-evaluate-expression" 2
66
67
68 mi_gdb_test "-data-evaluate-expression \"$path\"" \
69     "\\^done,value=\"\{a = 5\}\"" \
70     "-data-evaluate-expression $path"
71
72 mi_gdb_exit
73 return 0