Commit | Line | Data |
---|---|---|
3666a048 | 1 | # Copyright 2018-2021 Free Software Foundation, Inc. |
fb5e1ed9 PW |
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 | ||
7a82e903 PA |
18 | if { [skip_ada_tests] } { return -1 } |
19 | ||
fb5e1ed9 PW |
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" | |
161d081c PW |
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] | |
fb5e1ed9 PW |
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"] then { | |
49 | fail "can't run to some_c.c STOP location" | |
50 | return | |
51 | } | |
52 | ||
53 | set func_in_c(c_syntax) "${decimal}: void proc_in_c\\\(void\\\);" | |
54 | set func_in_c(ada_syntax) "${decimal}: procedure proc_in_c;" | |
55 | set func_in_ada(c_syntax) "${decimal}: void proc_in_ada\\\(void\\\);" | |
56 | set func_in_ada(ada_syntax) "${decimal}: procedure proc_in_ada;" | |
57 | ||
a8e9d247 | 58 | set type_in_c(c_syntax) "${decimal}: typedef struct {\\.\\.\\.} some_type_in_c;" |
fb5e1ed9 PW |
59 | set type_in_c(ada_syntax) [multi_line \ |
60 | "${decimal}: record" \ | |
61 | " some_component_in_c: int;" \ | |
62 | "end record" ] | |
63 | set type_in_ada(c_syntax) "${decimal}: struct global_pack__some_type_in_ada;" | |
64 | set type_in_ada(ada_syntax) "${decimal}: global_pack.some_type_in_ada;" | |
65 | ||
66 | set var_in_c(c_syntax) "${decimal}: some_type_in_c some_struct_in_c;" | |
67 | set var_in_c(ada_syntax) "${decimal}: some_struct_in_c: some_type_in_c;" | |
68 | set var_in_ada(c_syntax) "${decimal}: struct global_pack__some_type_in_ada global_pack.some_struct_in_ada;" | |
69 | set var_in_ada(ada_syntax) "${decimal}: global_pack.some_struct_in_ada: global_pack.some_type_in_ada;" | |
70 | ||
71 | set rbreak_func_in_c(c_syntax) "void proc_in_c\\\(void\\\);" | |
72 | set rbreak_func_in_c(ada_syntax) "procedure proc_in_c;" | |
73 | set rbreak_func_in_ada(c_syntax) "void proc_in_ada\\\(void\\\);" | |
74 | set rbreak_func_in_ada(ada_syntax) "procedure proc_in_ada;" | |
75 | ||
76 | ||
77 | foreach_with_prefix language_choice { "auto" "ada" "c" } { | |
78 | ||
79 | # Check that switching to the desired language_choice when the selected | |
80 | # frame has the same language (or the desired language is auto) gives no | |
81 | # warning. Also set the expected matches for the various commands | |
82 | # tested afterwards. | |
83 | if {$language_choice == "auto"} { | |
84 | gdb_test "frame 0" "#0 .*" "select frame with lang c" | |
85 | set c_match c_syntax | |
86 | set ada_match ada_syntax | |
87 | } elseif {$language_choice == "ada"} { | |
88 | gdb_test "frame 1" "#1 .*" "select frame with lang ada" | |
89 | set c_match ada_syntax | |
90 | set ada_match ada_syntax | |
91 | } elseif {$language_choice == "c"} { | |
92 | gdb_test "frame 0" "#0 .*" "select frame with lang c" | |
93 | set c_match c_syntax | |
94 | set ada_match c_syntax | |
95 | } else { | |
96 | error "unexpected language choice" | |
97 | } | |
98 | gdb_test_no_output "set language $language_choice" "set language language_choice" | |
99 | ||
100 | foreach frame { | |
101 | "0" | |
102 | "1" } { | |
103 | if { $frame == 0 } { | |
104 | set frame_lang "c" | |
105 | } else { | |
106 | set frame_lang "ada" | |
107 | } | |
108 | ||
109 | with_test_prefix "frame=$frame, frame_lang=$frame_lang" { | |
110 | ||
111 | gdb_test "frame $frame" "#$frame .*" "select frame" | |
112 | ||
113 | gdb_test "info functions proc_in_" \ | |
114 | [multi_line \ | |
115 | "All functions matching regular expression \"proc_in_\":" \ | |
116 | "" \ | |
fb5e1ed9 | 117 | "File .*proc_in_ada.adb:" \ |
161d081c PW |
118 | $func_in_ada($ada_match) \ |
119 | "" \ | |
120 | "File .*some_c.c:" \ | |
121 | $func_in_c($c_match) | |
fb5e1ed9 PW |
122 | ] |
123 | ||
124 | gdb_test "info types some_type" \ | |
125 | [multi_line \ | |
161d081c | 126 | "All types matching regular expression \"some_type\":" \ |
fb5e1ed9 PW |
127 | "" \ |
128 | "File .*global_pack.ads:" \ | |
161d081c PW |
129 | $type_in_ada($ada_match)\ |
130 | "" \ | |
131 | "File .*some_c.c:" \ | |
132 | $type_in_c($c_match) | |
fb5e1ed9 PW |
133 | ] |
134 | ||
135 | gdb_test "info variables some_struct" \ | |
136 | [multi_line \ | |
137 | "All variables matching regular expression \"some_struct\":" \ | |
138 | "" \ | |
fb5e1ed9 | 139 | "File .*global_pack.ads:" \ |
161d081c PW |
140 | $var_in_ada($ada_match) \ |
141 | "" \ | |
142 | "File .*some_c.c:" \ | |
143 | $var_in_c($c_match) | |
fb5e1ed9 PW |
144 | ] |
145 | ||
146 | gdb_test "rbreak proc_in_" \ | |
147 | [multi_line \ | |
fb5e1ed9 | 148 | "Breakpoint.*file .*proc_in_ada.adb,.*" \ |
161d081c PW |
149 | $rbreak_func_in_ada($ada_match) \ |
150 | "Breakpoint.*file .*some_c.c,.*" \ | |
151 | $rbreak_func_in_c($c_match) | |
fb5e1ed9 PW |
152 | ] |
153 | delete_breakpoints | |
154 | } | |
155 | } | |
156 | } | |
157 |