2012-04-02 Siva Chandra Reddy <sivachandra@google.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / py-explore-cc.exp
1 # Copyright (C) 2012 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 # This file is part of the GDB testsuite. It tests the mechanism
17 # exposing values to Python.
18
19 if { [skip_cplus_tests] } { continue }
20
21 set testfile "py-explore"
22 set srcfile ${testfile}.cc
23 set binfile ${objdir}/${subdir}/${testfile}
24
25 if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
26 return -1
27 }
28
29 # Skip all tests if Python scripting is not enabled.
30 if { [skip_python_tests] } { continue }
31
32 set int_ptr_ref_desc "The value of 'int_ptr_ref' is of type 'int_ptr' which is a typedef of type 'int \\*'.*\'int_ptr_ref' is a pointer to a value of type 'int'.*"
33
34 set b_desc "The value of 'b' is a struct/class of type 'B' with the following fields:.*\
35 A = <Enter 0 to explore this base class of type 'A'>.*\
36 i = 10 \\.\\. \\(Value of type 'int'\\).*\
37 c = 97 'a' \\.\\. \\(Value of type 'char'\\).*"
38
39 set B_desc "'B' is a struct/class with the following fields:.*\
40 A = <Enter 0 to explore this base class of type 'A'>.*\
41 i = <Enter 1 to explore this field of type 'int'>.*\
42 c = <Enter 2 to explore this field of type 'char'>.*"
43
44 if ![runto_main] {
45 return -1
46 }
47
48 gdb_breakpoint [gdb_get_line_number "Break here."]
49 gdb_continue_to_breakpoint "Break here" ".*Break here.*"
50
51 gdb_test "explore A" "'A' is a struct/class with no fields\."
52 gdb_test "explore a" "The value of 'a' is a struct/class of type 'const A' with no fields\."
53 gdb_test "explore int_ref" "'int_ref' is a scalar value of type 'int'.*int_ref = 10"
54
55 gdb_test_multiple "explore int_ptr_ref" "" {
56 -re "$int_ptr_ref_desc.*Continue exploring it as a pointer to a single value \\\[y/n\\\]:.*" {
57 pass "explore int_ptr_ref"
58 gdb_test_multiple "y" "explore_int_ptr_ref_as_single_value_pointer" {
59 -re "'\[*\]int_ptr_ref' is a scalar value of type 'int'.*\[*\]int_ptr_ref = 10.*$gdb_prompt" {
60 pass "explore_int_ptr_ref_as_single_value_pointer"
61 }
62 }
63 }
64 }
65
66 gdb_test_multiple "explore b" "" {
67 -re "$b_desc.*Enter the field number of choice:.*" {
68 pass "explore b"
69 gdb_test_multiple "0" "explore_base_class_A" {
70 -re "The value of 'b\.A' is a struct/class of type 'A' with no fields\." {
71 pass "explore_base_class_A"
72 gdb_test_multiple "\0" "return_to_b_from_A" {
73 -re ".*$b_desc.*Enter the field number of choice:.*" {
74 pass "return_to_b_from_A"
75 gdb_test_multiple "1" "explore_field_i_of_b" {
76 -re "'b\.i' is a scalar value of type 'int'.*b\.i = 10.*" {
77 pass "explore_field_i_of_b"
78 gdb_test_multiple "\0" "return_to_b_from_i" {
79 -re "$b_desc.*Enter the field number of choice:.*" {
80 pass "return_to_b_from_i"
81 }
82 }
83 }
84 }
85 gdb_test_multiple "2" "explore_field_c_of_b" {
86 -re "'b\.c' is a scalar value of type 'char'.*b\.c = .*'a'.*" {
87 pass "explore_field_c_of_b"
88 gdb_test_multiple "\0" "return_to_b_from_c" {
89 -re "$b_desc.*Enter the field number of choice:.*" {
90 pass "return_to_b_from_i"
91 }
92 }
93 }
94 }
95 gdb_test_multiple "\0" "return_to_gdb_prompt" {
96 -re "$gdb_prompt" {
97 pass "return_to_gdb_prompt_from_b"
98 }
99 }
100 }
101 }
102 }
103 }
104 }
105 }
106
107 gdb_test_multiple "explore B" "" {
108 -re "$B_desc.*Enter the field number of choice:.*" {
109 pass "explore B"
110 gdb_test_multiple "0" "explore_base_class_A" {
111 -re "base class 'A' of 'B' is a struct/class of type 'A' with no fields\." {
112 pass "explore_base_class_A"
113 gdb_test_multiple "\0" "return_to_B" {
114 -re "$B_desc.*Enter the field number of choice:.*" {
115 pass "return_to_B"
116 gdb_test_multiple "1" "explore_field_i_of_B" {
117 -re "field 'i' of 'B' is of a scalar type 'int'.*" {
118 pass "explore_field_i_of_B"
119 gdb_test_multiple "\0" "return_to_B_from_i" {
120 -re "$B_desc.*Enter the field number of choice:.*" {
121 pass "return_to_B_from_i"
122 }
123 }
124 }
125 }
126 gdb_test_multiple "2" "explore_field_c_of_B" {
127 -re "field 'c' of 'B' is of a scalar type 'char'.*" {
128 pass "explore_field_c_of_B"
129 gdb_test_multiple "\0" "return_to_B_from_c" {
130 -re "$B_desc.*Enter the field number of choice:.*" {
131 pass "return_to_B_from_c"
132 }
133 }
134 }
135 }
136 gdb_test_multiple "\0" "return_to_gdb_prompt" {
137 -re "$gdb_prompt" {
138 pass "return_to_gdb_prompt_from_B"
139 }
140 }
141 }
142 }
143 }
144 }
145 }
146 }
This page took 0.033253 seconds and 5 git commands to generate.