1 # Copyright 2019-2021 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 # Check that 'info types' produces the expected output for an inferior
17 # containing a number of different types.
19 # Match LINE against regexp OUTPUT_LINES[IDX].
20 proc match_line
{ line output_lines idx_name
} {
24 if { $idx == [llength $output_lines] } {
25 # Ran out of regexps, bail out.
29 set re
[lindex $output_lines $idx]
30 if { $re == "--optional" } {
31 # Optional, get actual regexp.
34 set re
[lindex $output_lines $idx]
40 if { [regexp $re $line] } {
43 if { $idx == [llength $output_lines] } {
44 # Last match, we're done.
47 # Match found, keep looking for next match.
52 # First match not found, just keep looking for first match.
55 # Try next regexp on same line.
70 # Run 'info types' test, compiling the test file for language LANG,
71 # which should be either 'c' or 'c++'.
72 proc run_test
{ lang
} {
80 standard_testfile info-types.c
82 if {[prepare_for_testing
"failed to prepare" \
83 "${testfile}" $srcfile "debug $lang"]} {
87 if ![runto_main
] then
{
88 fail
"can't run to main"
92 set file_re
"File .*[string_to_regexp $srcfile]:"
94 if { $lang == "c++" } {
99 "42:\[\t \]+anon_struct_t;" \
100 "65:\[\t \]+anon_union_t;" \
101 "21:\[\t \]+baz_t;" \
102 "33:\[\t \]+enum_t;" \
103 "56:\[\t \]+union_t;" \
104 "52:\[\t \]+typedef enum {\\.\\.\\.} anon_enum_t;" \
105 "45:\[\t \]+typedef anon_struct_t anon_struct_t;" \
106 "68:\[\t \]+typedef anon_union_t anon_union_t;" \
107 "28:\[\t \]+typedef baz_t baz;" \
108 "31:\[\t \]+typedef baz_t \\* baz_ptr;" \
109 "27:\[\t \]+typedef baz_t baz_t;" \
113 "103:\[\t \]+typedef CL my_cl;" \
114 "38:\[\t \]+typedef enum_t my_enum_t;" \
115 "17:\[\t \]+typedef float my_float_t;" \
116 "16:\[\t \]+typedef int my_int_t;" \
117 "104:\[\t \]+typedef CL \\* my_ptr;" \
118 "54:\[\t \]+typedef enum {\\.\\.\\.} nested_anon_enum_t;" \
119 "47:\[\t \]+typedef anon_struct_t nested_anon_struct_t;" \
120 "70:\[\t \]+typedef anon_union_t nested_anon_union_t;" \
121 "30:\[\t \]+typedef baz_t nested_baz;" \
122 "29:\[\t \]+typedef baz_t nested_baz_t;" \
123 "39:\[\t \]+typedef enum_t nested_enum_t;" \
124 "19:\[\t \]+typedef float nested_float_t;" \
125 "18:\[\t \]+typedef int nested_int_t;" \
126 "62:\[\t \]+typedef union_t nested_union_t;" \
127 "--optional" "\[\t \]+unsigned int" \
133 "52:\[\t \]+typedef enum {\\.\\.\\.} anon_enum_t;" \
134 "45:\[\t \]+typedef struct {\\.\\.\\.} anon_struct_t;" \
135 "68:\[\t \]+typedef union {\\.\\.\\.} anon_union_t;" \
136 "28:\[\t \]+typedef struct baz_t baz;" \
137 "31:\[\t \]+typedef struct baz_t \\* baz_ptr;" \
138 "21:\[\t \]+struct baz_t;" \
140 "33:\[\t \]+enum enum_t;" \
143 "38:\[\t \]+typedef enum enum_t my_enum_t;" \
144 "17:\[\t \]+typedef float my_float_t;" \
145 "16:\[\t \]+typedef int my_int_t;" \
146 "54:\[\t \]+typedef enum {\\.\\.\\.} nested_anon_enum_t;" \
147 "47:\[\t \]+typedef struct {\\.\\.\\.} nested_anon_struct_t;" \
148 "70:\[\t \]+typedef union {\\.\\.\\.} nested_anon_union_t;" \
149 "30:\[\t \]+typedef struct baz_t nested_baz;" \
150 "29:\[\t \]+typedef struct baz_t nested_baz_t;" \
151 "39:\[\t \]+typedef enum enum_t nested_enum_t;" \
152 "19:\[\t \]+typedef float nested_float_t;" \
153 "18:\[\t \]+typedef int nested_int_t;" \
154 "62:\[\t \]+typedef union union_t nested_union_t;" \
155 "56:\[\t \]+union union_t;" \
156 "--optional" "\[\t \]+unsigned int" \
162 gdb_test_multiple
"info types" "" {
163 -re "\r\nAll defined types:" {
164 if { $state == 0 } { set state
1 } else { set state
-1 }
167 -re "^\r\n(\[^\r\n\]*)(?=\r\n)" {
169 set line
$expect_out(1,string)
170 set res
[match_line
$line $output_lines idx
]
173 } elseif
{ $res == -1 } {
183 fail
"$gdb_test_name (state == $state)"