]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright (C) 2012-2024 Free Software Foundation, Inc. |
06fc020f SCR |
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 | ||
d82e5429 | 19 | require allow_cplus_tests allow_python_tests |
06fc020f | 20 | |
b4a58790 | 21 | standard_testfile py-explore.cc |
06fc020f | 22 | |
5b362f04 | 23 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} { |
06fc020f SCR |
24 | return -1 |
25 | } | |
26 | ||
06fc020f SCR |
27 | 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'.*" |
28 | ||
29 | set b_desc "The value of 'b' is a struct/class of type 'B' with the following fields:.*\ | |
30 | A = <Enter 0 to explore this base class of type 'A'>.*\ | |
31 | i = 10 \\.\\. \\(Value of type 'int'\\).*\ | |
32 | c = 97 'a' \\.\\. \\(Value of type 'char'\\).*" | |
33 | ||
34 | set B_desc "'B' is a struct/class with the following fields:.*\ | |
35 | A = <Enter 0 to explore this base class of type 'A'>.*\ | |
36 | i = <Enter 1 to explore this field of type 'int'>.*\ | |
37 | c = <Enter 2 to explore this field of type 'char'>.*" | |
38 | ||
39 | if ![runto_main] { | |
40 | return -1 | |
41 | } | |
42 | ||
43 | gdb_breakpoint [gdb_get_line_number "Break here."] | |
44 | gdb_continue_to_breakpoint "Break here" ".*Break here.*" | |
45 | ||
46 | gdb_test "explore A" "'A' is a struct/class with no fields\." | |
47 | gdb_test "explore a" "The value of 'a' is a struct/class of type 'const A' with no fields\." | |
48 | gdb_test "explore int_ref" "'int_ref' is a scalar value of type 'int'.*int_ref = 10" | |
49 | ||
50 | gdb_test_multiple "explore int_ptr_ref" "" { | |
51 | -re "$int_ptr_ref_desc.*Continue exploring it as a pointer to a single value \\\[y/n\\\]:.*" { | |
52 | pass "explore int_ptr_ref" | |
53 | gdb_test_multiple "y" "explore_int_ptr_ref_as_single_value_pointer" { | |
54 | -re "'\[*\]int_ptr_ref' is a scalar value of type 'int'.*\[*\]int_ptr_ref = 10.*$gdb_prompt" { | |
55 | pass "explore_int_ptr_ref_as_single_value_pointer" | |
56 | } | |
57 | } | |
58 | } | |
59 | } | |
60 | ||
61 | gdb_test_multiple "explore b" "" { | |
62 | -re "$b_desc.*Enter the field number of choice:.*" { | |
63 | pass "explore b" | |
64 | gdb_test_multiple "0" "explore_base_class_A" { | |
65 | -re "The value of 'b\.A' is a struct/class of type 'A' with no fields\." { | |
66bb1dd9 | 66 | pass "explore_base_class_A, exploring b" |
06fc020f SCR |
67 | gdb_test_multiple "\0" "return_to_b_from_A" { |
68 | -re ".*$b_desc.*Enter the field number of choice:.*" { | |
69 | pass "return_to_b_from_A" | |
70 | gdb_test_multiple "1" "explore_field_i_of_b" { | |
71 | -re "'b\.i' is a scalar value of type 'int'.*b\.i = 10.*" { | |
72 | pass "explore_field_i_of_b" | |
73 | gdb_test_multiple "\0" "return_to_b_from_i" { | |
74 | -re "$b_desc.*Enter the field number of choice:.*" { | |
75 | pass "return_to_b_from_i" | |
76 | } | |
77 | } | |
78 | } | |
79 | } | |
80 | gdb_test_multiple "2" "explore_field_c_of_b" { | |
81 | -re "'b\.c' is a scalar value of type 'char'.*b\.c = .*'a'.*" { | |
82 | pass "explore_field_c_of_b" | |
83 | gdb_test_multiple "\0" "return_to_b_from_c" { | |
84 | -re "$b_desc.*Enter the field number of choice:.*" { | |
66bb1dd9 | 85 | pass "return_to_b_from_c" |
06fc020f SCR |
86 | } |
87 | } | |
88 | } | |
89 | } | |
90 | gdb_test_multiple "\0" "return_to_gdb_prompt" { | |
91 | -re "$gdb_prompt" { | |
92 | pass "return_to_gdb_prompt_from_b" | |
93 | } | |
94 | } | |
95 | } | |
96 | } | |
97 | } | |
98 | } | |
99 | } | |
100 | } | |
101 | ||
102 | gdb_test_multiple "explore B" "" { | |
103 | -re "$B_desc.*Enter the field number of choice:.*" { | |
104 | pass "explore B" | |
105 | gdb_test_multiple "0" "explore_base_class_A" { | |
106 | -re "base class 'A' of 'B' is a struct/class of type 'A' with no fields\." { | |
66bb1dd9 | 107 | pass "explore_base_class_A, exploring B" |
06fc020f SCR |
108 | gdb_test_multiple "\0" "return_to_B" { |
109 | -re "$B_desc.*Enter the field number of choice:.*" { | |
110 | pass "return_to_B" | |
111 | gdb_test_multiple "1" "explore_field_i_of_B" { | |
112 | -re "field 'i' of 'B' is of a scalar type 'int'.*" { | |
113 | pass "explore_field_i_of_B" | |
114 | gdb_test_multiple "\0" "return_to_B_from_i" { | |
115 | -re "$B_desc.*Enter the field number of choice:.*" { | |
66bb1dd9 | 116 | pass "return_to_B_from_i, exploring B" |
06fc020f SCR |
117 | } |
118 | } | |
119 | } | |
120 | } | |
121 | gdb_test_multiple "2" "explore_field_c_of_B" { | |
122 | -re "field 'c' of 'B' is of a scalar type 'char'.*" { | |
123 | pass "explore_field_c_of_B" | |
124 | gdb_test_multiple "\0" "return_to_B_from_c" { | |
125 | -re "$B_desc.*Enter the field number of choice:.*" { | |
126 | pass "return_to_B_from_c" | |
127 | } | |
128 | } | |
129 | } | |
130 | } | |
131 | gdb_test_multiple "\0" "return_to_gdb_prompt" { | |
132 | -re "$gdb_prompt" { | |
133 | pass "return_to_gdb_prompt_from_B" | |
134 | } | |
135 | } | |
136 | } | |
137 | } | |
138 | } | |
139 | } | |
140 | } | |
141 | } |