[gdb/testsuite] Fix info-types.exp for debug info from more than one file
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / info-types.exp
1 # Copyright 2019 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 # Check that 'info types' produces the expected output for an inferior
17 # containing a number of different types.
18
19 # Only test C++ if we are able. Always use C.
20 if { [skip_cplus_tests] || [get_compiler_info "c++"] } {
21 set lang {c}
22 } else {
23 set lang {c c++}
24 }
25
26 foreach l $lang {
27 set dir "$l"
28 remote_exec host "rm -rf [standard_output_file ${dir}]"
29 remote_exec host "mkdir -p [standard_output_file ${dir}]"
30 }
31
32 # Run 'info types' test, compiling the test file for language LANG,
33 # which should be either 'c' or 'c++'.
34 proc run_test { lang } {
35 global testfile
36 global srcfile
37 global binfile
38 global subdir
39 global srcdir
40 global compile_flags
41
42 standard_testfile .c
43
44 if {[prepare_for_testing "failed to prepare" \
45 "${lang}/${testfile}" $srcfile "debug $lang"]} {
46 return -1
47 }
48
49 if ![runto_main] then {
50 fail "can't run to main"
51 return 0
52 }
53
54 if { $lang == "c++" } {
55 set output_re \
56 [multi_line \
57 "All defined types:" \
58 "" \
59 "File .*:" \
60 "98:\[\t \]+CL;" \
61 "42:\[\t \]+anon_struct_t;" \
62 "65:\[\t \]+anon_union_t;" \
63 "21:\[\t \]+baz_t;" \
64 "33:\[\t \]+enum_t;" \
65 "56:\[\t \]+union_t;" \
66 "52:\[\t \]+typedef enum {\\.\\.\\.} anon_enum_t;" \
67 "45:\[\t \]+typedef anon_struct_t anon_struct_t;" \
68 "68:\[\t \]+typedef anon_union_t anon_union_t;" \
69 "28:\[\t \]+typedef baz_t baz;" \
70 "31:\[\t \]+typedef baz_t \\* baz_ptr;" \
71 "27:\[\t \]+typedef baz_t baz_t;" \
72 "\[\t \]+double" \
73 "\[\t \]+float" \
74 "\[\t \]+int" \
75 "103:\[\t \]+typedef CL my_cl;" \
76 "38:\[\t \]+typedef enum_t my_enum_t;" \
77 "17:\[\t \]+typedef float my_float_t;" \
78 "16:\[\t \]+typedef int my_int_t;" \
79 "104:\[\t \]+typedef CL \\* my_ptr;" \
80 "54:\[\t \]+typedef enum {\\.\\.\\.} nested_anon_enum_t;" \
81 "47:\[\t \]+typedef anon_struct_t nested_anon_struct_t;" \
82 "70:\[\t \]+typedef anon_union_t nested_anon_union_t;" \
83 "30:\[\t \]+typedef baz_t nested_baz;" \
84 "29:\[\t \]+typedef baz_t nested_baz_t;" \
85 "39:\[\t \]+typedef enum_t nested_enum_t;" \
86 "19:\[\t \]+typedef float nested_float_t;" \
87 "18:\[\t \]+typedef int nested_int_t;" \
88 "62:\[\t \]+typedef union_t nested_union_t;" \
89 "\[\t \]+unsigned int(" \
90 "" \
91 "File .*:.*)?" ]
92 } else {
93 set output_re \
94 [multi_line \
95 "All defined types:" \
96 "" \
97 "File .*:" \
98 "52:\[\t \]+typedef enum {\\.\\.\\.} anon_enum_t;" \
99 "45:\[\t \]+typedef struct {\\.\\.\\.} anon_struct_t;" \
100 "68:\[\t \]+typedef union {\\.\\.\\.} anon_union_t;" \
101 "28:\[\t \]+typedef struct baz_t baz;" \
102 "31:\[\t \]+typedef struct baz_t \\* baz_ptr;" \
103 "21:\[\t \]+struct baz_t;" \
104 "\[\t \]+double" \
105 "33:\[\t \]+enum enum_t;" \
106 "\[\t \]+float" \
107 "\[\t \]+int" \
108 "38:\[\t \]+typedef enum enum_t my_enum_t;" \
109 "17:\[\t \]+typedef float my_float_t;" \
110 "16:\[\t \]+typedef int my_int_t;" \
111 "54:\[\t \]+typedef enum {\\.\\.\\.} nested_anon_enum_t;" \
112 "47:\[\t \]+typedef struct {\\.\\.\\.} nested_anon_struct_t;" \
113 "70:\[\t \]+typedef union {\\.\\.\\.} nested_anon_union_t;" \
114 "30:\[\t \]+typedef struct baz_t nested_baz;" \
115 "29:\[\t \]+typedef struct baz_t nested_baz_t;" \
116 "39:\[\t \]+typedef enum enum_t nested_enum_t;" \
117 "19:\[\t \]+typedef float nested_float_t;" \
118 "18:\[\t \]+typedef int nested_int_t;" \
119 "62:\[\t \]+typedef union union_t nested_union_t;" \
120 "56:\[\t \]+union union_t;" \
121 "\[\t \]+unsigned int(" \
122 "" \
123 "File .*:.*)?" ]
124 }
125
126 gdb_test "info types" $output_re
127 }
128
129 foreach_with_prefix l $lang {
130 run_test $l
131 }
This page took 0.033264 seconds and 4 git commands to generate.