1 # Copyright 2023-2024 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 require allow_ada_tests 19 20 # GCC with commit ff9baa5f1c5 ("DWARF: make it possible to emit debug info for 21 # declarations only") is required. The commit makes sure that file-scope 22 # function and variable declarations are emitted in dwarf. This allows the 23 # description of imported entries, making them available to the debugger. 24 require {expr [gcc_major_version] >= 8} 25 26 standard_ada_testfile prog 27 28 set cfile "inc" 29 set csrcfile ${srcdir}/${subdir}/${testdir}/${cfile}.c 30 set cobject [standard_output_file ${cfile}.o] 31 32 if {[gdb_compile "${csrcfile}" "${cobject}" object debug] != ""} { 33 untested "could not compile C file" 34 return 35 } 36 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable \ 37 [list debug additional_flags=-largs \ 38 additional_flags=${cobject} additional_flags=-margs]] != ""} { 39 return -1 40 } 41 42 clean_restart ${testfile} 43 44 set bp_location [gdb_get_line_number "BREAK" ${testdir}/prog.adb] 45 runto "prog.adb:$bp_location" 46 47 gdb_test "print ordinary_var" " = 78" 48 49 gdb_test "print imported_var" " = 42" 50 gdb_test "print imported_var_ada" " = 42" 51 gdb_test "print local_imported_var" " = 42" 52 gdb_test "print pkg.imported_var_ada" " = 42" 53 54 gdb_test "print pkg.exported_var_ada" " = 99" 55 gdb_test "print exported_var_ada" " = 99" 56 57 # This passes with gcc 10 but fails with gcc 9. With gcc 9, we have: 58 # <1><1659>: Abbrev Number: 4 (DW_TAG_subprogram) 59 # <165a> DW_AT_external : 1 60 # <165a> DW_AT_name : pkg__imported_func_ada 61 # <165e> DW_AT_decl_file : 2 62 # <165f> DW_AT_decl_line : 22 63 # <1660> DW_AT_decl_column : 13 64 # <1661> DW_AT_linkage_name: imported_func 65 # <1665> DW_AT_type : <0x1669> 66 # and with gcc 10 instead: 67 # <1><1670>: Abbrev Number: 4 (DW_TAG_subprogram) 68 # <1671> DW_AT_external : 1 69 # <1671> DW_AT_name : pkg__imported_func_ada 70 # <1675> DW_AT_decl_file : 2 71 # <1676> DW_AT_decl_line : 22 72 # <1677> DW_AT_decl_column : 13 73 # <1678> DW_AT_linkage_name: imported_func 74 # <167c> DW_AT_type : <0x1680> 75 # <1680> DW_AT_declaration : 1 76 # The fact that things start to work when adding the DW_AT_declaration is 77 # consistent with what is described in commit ff9baa5f1c5, so xfail this 78 # (without pinpointing it to a specific gcc PR or commit). 79 if { [gcc_major_version] < 10 } { 80 setup_xfail *-*-* 81 } 82 gdb_breakpoint "pkg.imported_func_ada" message 83 gdb_breakpoint "imported_func" message 84 if { [gcc_major_version] < 10 } { 85 setup_xfail *-*-* 86 } 87 gdb_breakpoint "imported_func_ada" message 88 89 gdb_breakpoint "local_imported_func" message 90 gdb_breakpoint "pkg.exported_func_ada" message 91 gdb_breakpoint "exported_func_ada" message 92 gdb_breakpoint "exported_func" message 93 94 gdb_test "print copy" " = 42" 95