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