1 # Copyright 2018-2019 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/>.
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
25 standard_ada_testfile proc_in_ada
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]
34 if { [gdb_compile "${csrcfile}" "${cobject}" object [list debug]] != "" } {
35 untested "failed to compile"
38 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } {
39 untested "failed to compile"
43 clean_restart ${testfile}
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"
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;"
56 set type_in_c(c_syntax) "${decimal}: typedef struct {\\.\\.\\.} some_type_in_c;"
57 set type_in_c(ada_syntax) [multi_line \
58 "${decimal}: record" \
59 " some_component_in_c: int;" \
61 set type_in_ada(c_syntax) "${decimal}: struct global_pack__some_type_in_ada;"
62 set type_in_ada(ada_syntax) "${decimal}: global_pack.some_type_in_ada;"
64 set var_in_c(c_syntax) "${decimal}: some_type_in_c some_struct_in_c;"
65 set var_in_c(ada_syntax) "${decimal}: some_struct_in_c: some_type_in_c;"
66 set var_in_ada(c_syntax) "${decimal}: struct global_pack__some_type_in_ada global_pack.some_struct_in_ada;"
67 set var_in_ada(ada_syntax) "${decimal}: global_pack.some_struct_in_ada: global_pack.some_type_in_ada;"
69 set rbreak_func_in_c(c_syntax) "void proc_in_c\\\(void\\\);"
70 set rbreak_func_in_c(ada_syntax) "procedure proc_in_c;"
71 set rbreak_func_in_ada(c_syntax) "void proc_in_ada\\\(void\\\);"
72 set rbreak_func_in_ada(ada_syntax) "procedure proc_in_ada;"
75 foreach_with_prefix language_choice { "auto" "ada" "c" } {
77 # Check that switching to the desired language_choice when the selected
78 # frame has the same language (or the desired language is auto) gives no
79 # warning. Also set the expected matches for the various commands
81 if {$language_choice == "auto"} {
82 gdb_test "frame 0" "#0 .*" "select frame with lang c"
84 set ada_match ada_syntax
85 } elseif {$language_choice == "ada"} {
86 gdb_test "frame 1" "#1 .*" "select frame with lang ada"
87 set c_match ada_syntax
88 set ada_match ada_syntax
89 } elseif {$language_choice == "c"} {
90 gdb_test "frame 0" "#0 .*" "select frame with lang c"
92 set ada_match c_syntax
94 error "unexpected language choice"
96 gdb_test_no_output "set language $language_choice" "set language language_choice"
107 with_test_prefix "frame=$frame, frame_lang=$frame_lang" {
109 gdb_test "frame $frame" "#$frame .*" "select frame"
111 gdb_test "info functions proc_in_" \
113 "All functions matching regular expression \"proc_in_\":" \
115 "File .*proc_in_ada.adb:" \
116 $func_in_ada($ada_match) \
122 gdb_test "info types some_type" \
124 "All types matching regular expression \"some_type\":" \
126 "File .*global_pack.ads:" \
127 $type_in_ada($ada_match)\
133 gdb_test "info variables some_struct" \
135 "All variables matching regular expression \"some_struct\":" \
137 "File .*global_pack.ads:" \
138 $var_in_ada($ada_match) \
144 gdb_test "rbreak proc_in_" \
146 "Breakpoint.*file .*proc_in_ada.adb,.*" \
147 $rbreak_func_in_ada($ada_match) \
148 "Breakpoint.*file .*some_c.c,.*" \
149 $rbreak_func_in_c($c_match)