]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.ada/info_auto_lang.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.ada / info_auto_lang.exp
1 # Copyright 2018-2023 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 load_lib "ada.exp"
17
18 if { [skip_ada_tests] } { return -1 }
19
20 # This test verifies that the commands
21 # info [functions|variables|types]
22 # respect the 'set language auto|ada|c' setting, whatever the language
23 # of the current frame.
24 # Similarly, checks that rbreak reports its results respecting
25 # the language mode.
26
27 standard_ada_testfile proc_in_ada
28 set cfile "some_c"
29 # gnat normalizes proc_in_ada source file when compiling.
30 # As the 'info' commands results are sorted by absolute path names, also normalize
31 # the some_c source file to ensure that the 'info' results are always
32 # giving Ada results first.
33 set csrcfile [file normalize ${srcdir}/${subdir}/${testdir}/${cfile}.c]
34 set cobject [standard_output_file ${cfile}.o]
35
36 if { [gdb_compile "${csrcfile}" "${cobject}" object [list debug]] != "" } {
37 untested "failed to compile"
38 return -1
39 }
40 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } {
41 untested "failed to compile"
42 return -1
43 }
44
45 clean_restart ${testfile}
46
47 set bp_location [gdb_get_line_number "STOP" ${testdir}/some_c.c]
48 if {![runto "some_c.c:$bp_location"]} {
49 return
50 }
51
52 set func_in_c(c_syntax) "${decimal}: void proc_in_c\\\(void\\\);"
53 set func_in_c(ada_syntax) "${decimal}: procedure proc_in_c;"
54 set func_in_ada(c_syntax) "${decimal}: void proc_in_ada\\\(void\\\);"
55 set func_in_ada(ada_syntax) "${decimal}: procedure proc_in_ada;"
56
57 set type_in_c(c_syntax) "${decimal}: typedef struct {\\.\\.\\.} some_type_in_c;"
58 set type_in_c(ada_syntax) [multi_line \
59 "${decimal}: record" \
60 " some_component_in_c: int;" \
61 "end record" ]
62 set type_in_ada(c_syntax) "${decimal}: struct global_pack__some_type_in_ada;"
63 set type_in_ada(ada_syntax) "${decimal}: global_pack.some_type_in_ada;"
64
65 set var_in_c(c_syntax) "${decimal}: some_type_in_c some_struct_in_c;"
66 set var_in_c(ada_syntax) "${decimal}: some_struct_in_c: some_type_in_c;"
67 set var_in_ada(c_syntax) "${decimal}: struct global_pack__some_type_in_ada global_pack.some_struct_in_ada;"
68 set var_in_ada(ada_syntax) "${decimal}: global_pack.some_struct_in_ada: global_pack.some_type_in_ada;"
69
70 set rbreak_func_in_c(c_syntax) "void proc_in_c\\\(void\\\);"
71 set rbreak_func_in_c(ada_syntax) "procedure proc_in_c;"
72 set rbreak_func_in_ada(c_syntax) "void proc_in_ada\\\(void\\\);"
73 set rbreak_func_in_ada(ada_syntax) "procedure proc_in_ada;"
74
75
76 foreach_with_prefix language_choice { "auto" "ada" "c" } {
77
78 # Check that switching to the desired language_choice when the selected
79 # frame has the same language (or the desired language is auto) gives no
80 # warning. Also set the expected matches for the various commands
81 # tested afterwards.
82 if {$language_choice == "auto"} {
83 gdb_test "frame 0" "#0 .*" "select frame with lang c"
84 set c_match c_syntax
85 set ada_match ada_syntax
86 } elseif {$language_choice == "ada"} {
87 gdb_test "frame 1" "#1 .*" "select frame with lang ada"
88 set c_match ada_syntax
89 set ada_match ada_syntax
90 } elseif {$language_choice == "c"} {
91 gdb_test "frame 0" "#0 .*" "select frame with lang c"
92 set c_match c_syntax
93 set ada_match c_syntax
94 } else {
95 error "unexpected language choice"
96 }
97 gdb_test_no_output "set language $language_choice" "set language language_choice"
98
99 foreach frame {
100 "0"
101 "1" } {
102 if { $frame == 0 } {
103 set frame_lang "c"
104 } else {
105 set frame_lang "ada"
106 }
107
108 with_test_prefix "frame=$frame, frame_lang=$frame_lang" {
109
110 gdb_test "frame $frame" "#$frame .*" "select frame"
111
112 gdb_test "info functions proc_in_" \
113 [multi_line \
114 "All functions matching regular expression \"proc_in_\":" \
115 "" \
116 "File .*proc_in_ada.adb:" \
117 $func_in_ada($ada_match) \
118 "" \
119 "File .*some_c.c:" \
120 $func_in_c($c_match)
121 ]
122
123 gdb_test "info types some_type" \
124 [multi_line \
125 "All types matching regular expression \"some_type\":" \
126 "" \
127 "File .*global_pack.ads:" \
128 $type_in_ada($ada_match)\
129 "" \
130 "File .*some_c.c:" \
131 $type_in_c($c_match)
132 ]
133
134 gdb_test "info variables some_struct" \
135 [multi_line \
136 "All variables matching regular expression \"some_struct\":" \
137 "" \
138 "File .*global_pack.ads:" \
139 $var_in_ada($ada_match) \
140 "" \
141 "File .*some_c.c:" \
142 $var_in_c($c_match)
143 ]
144
145 gdb_test "rbreak proc_in_" \
146 [multi_line \
147 "Breakpoint.*file .*proc_in_ada.adb,.*" \
148 $rbreak_func_in_ada($ada_match) \
149 "Breakpoint.*file .*some_c.c,.*" \
150 $rbreak_func_in_c($c_match)
151 ]
152 delete_breakpoints
153 }
154 }
155 }
156