1 # Copyright (C) 2012 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file is part of the GDB testsuite. It tests the mechanism
17 # exposing values to Python.
19 if { [skip_cplus_tests] } { continue }
21 set testfile "py-explore"
22 set srcfile ${testfile}.cc
23 set binfile ${objdir}/${subdir}/${testfile}
25 if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
29 # Skip all tests if Python scripting is not enabled.
30 if { [skip_python_tests] } { continue }
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'.*"
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'\\).*"
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'>.*"
48 gdb_breakpoint [gdb_get_line_number "Break here."]
49 gdb_continue_to_breakpoint "Break here" ".*Break here.*"
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"
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"
66 gdb_test_multiple "explore b" "" {
67 -re "$b_desc.*Enter the field number of choice:.*" {
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"
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"
95 gdb_test_multiple "\0" "return_to_gdb_prompt" {
97 pass "return_to_gdb_prompt_from_b"
107 gdb_test_multiple "explore B" "" {
108 -re "$B_desc.*Enter the field number of choice:.*" {
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:.*" {
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"
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"
136 gdb_test_multiple "\0" "return_to_gdb_prompt" {
138 pass "return_to_gdb_prompt_from_B"