1 # Copyright 2020-2021 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/>.
17 # The function foo is encapsulated by two functions from CU
18 # $srcfile (main and bar), but the debug info does not describe foo, so
19 # foo should not be seen as part of CU $srcfile.
20 # Run to foo, and check that the current language is the default auto/C.
21 # If foo is considered part of CU $srcfile, the language will be auto/C++
24 # This test can only be run on targets which support DWARF-2 and use gas.
25 if {![dwarf2_support]} {
26 verbose "Skipping $gdb_test_file_name."
30 # The .c files use __attribute__.
31 if [get_compiler_info] {
35 verbose "Skipping $gdb_test_file_name."
39 standard_testfile .c -dw.S
41 set asm_file [standard_output_file $srcfile2]
42 Dwarf::assemble $asm_file {
43 global srcdir subdir srcfile srcfile2
44 declare_labels ranges_label
46 # Find start address and length for our functions.
48 [function_range main [list ${srcdir}/${subdir}/$srcfile]]
50 [function_range foo [list ${srcdir}/${subdir}/$srcfile]]
52 [function_range bar [list ${srcdir}/${subdir}/$srcfile]]
56 {language @DW_LANG_C_plus_plus}
58 {ranges ${ranges_label} DW_FORM_sec_offset}
67 ranges {is_64 [is_64_target]} {
68 ranges_label: sequence {
69 base [lindex $main_func 0]
70 range 0 [lindex $main_func 1]
71 base [lindex $bar_func 0]
72 range 0 [lindex $bar_func 1]
77 if { [prepare_for_testing "failed to prepare" ${testfile} \
78 [list $srcfile $asm_file] {nodebug}] } {
86 gdb_test "show language" \
87 "The current source language is \"auto; currently c\"\."