1# Copyright 2018-2020 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 16load_lib "ada.exp" 17 18if { [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 27standard_ada_testfile proc_in_ada 28set 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. 33set csrcfile [file normalize ${srcdir}/${subdir}/${testdir}/${cfile}.c] 34set cobject [standard_output_file ${cfile}.o] 35 36if { [gdb_compile "${csrcfile}" "${cobject}" object [list debug]] != "" } { 37 untested "failed to compile" 38 return -1 39} 40if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } { 41 untested "failed to compile" 42 return -1 43} 44 45clean_restart ${testfile} 46 47set bp_location [gdb_get_line_number "STOP" ${testdir}/some_c.c] 48if ![runto "some_c.c:$bp_location"] then { 49 fail "can't run to some_c.c STOP location" 50 return 51} 52 53set func_in_c(c_syntax) "${decimal}: void proc_in_c\\\(void\\\);" 54set func_in_c(ada_syntax) "${decimal}: procedure proc_in_c;" 55set func_in_ada(c_syntax) "${decimal}: void proc_in_ada\\\(void\\\);" 56set func_in_ada(ada_syntax) "${decimal}: procedure proc_in_ada;" 57 58set type_in_c(c_syntax) "${decimal}: typedef struct {\\.\\.\\.} some_type_in_c;" 59set type_in_c(ada_syntax) [multi_line \ 60 "${decimal}: record" \ 61 " some_component_in_c: int;" \ 62 "end record" ] 63set type_in_ada(c_syntax) "${decimal}: struct global_pack__some_type_in_ada;" 64set type_in_ada(ada_syntax) "${decimal}: global_pack.some_type_in_ada;" 65 66set var_in_c(c_syntax) "${decimal}: some_type_in_c some_struct_in_c;" 67set var_in_c(ada_syntax) "${decimal}: some_struct_in_c: some_type_in_c;" 68set var_in_ada(c_syntax) "${decimal}: struct global_pack__some_type_in_ada global_pack.some_struct_in_ada;" 69set var_in_ada(ada_syntax) "${decimal}: global_pack.some_struct_in_ada: global_pack.some_type_in_ada;" 70 71set rbreak_func_in_c(c_syntax) "void proc_in_c\\\(void\\\);" 72set rbreak_func_in_c(ada_syntax) "procedure proc_in_c;" 73set rbreak_func_in_ada(c_syntax) "void proc_in_ada\\\(void\\\);" 74set rbreak_func_in_ada(ada_syntax) "procedure proc_in_ada;" 75 76 77foreach_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 "" \ 117 "File .*proc_in_ada.adb:" \ 118 $func_in_ada($ada_match) \ 119 "" \ 120 "File .*some_c.c:" \ 121 $func_in_c($c_match) 122 ] 123 124 gdb_test "info types some_type" \ 125 [multi_line \ 126 "All types matching regular expression \"some_type\":" \ 127 "" \ 128 "File .*global_pack.ads:" \ 129 $type_in_ada($ada_match)\ 130 "" \ 131 "File .*some_c.c:" \ 132 $type_in_c($c_match) 133 ] 134 135 gdb_test "info variables some_struct" \ 136 [multi_line \ 137 "All variables matching regular expression \"some_struct\":" \ 138 "" \ 139 "File .*global_pack.ads:" \ 140 $var_in_ada($ada_match) \ 141 "" \ 142 "File .*some_c.c:" \ 143 $var_in_c($c_match) 144 ] 145 146 gdb_test "rbreak proc_in_" \ 147 [multi_line \ 148 "Breakpoint.*file .*proc_in_ada.adb,.*" \ 149 $rbreak_func_in_ada($ada_match) \ 150 "Breakpoint.*file .*some_c.c,.*" \ 151 $rbreak_func_in_c($c_match) 152 ] 153 delete_breakpoints 154 } 155 } 156} 157 158