972ab762a27e7b57872031cb9065e90f4e41f3cc
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / dw2-ranges-overlap.exp
1 # Copyright 2020-2021 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 load_lib dwarf.exp
16
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++
22 # instead.
23
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."
27 return 0
28 }
29
30 # The .c files use __attribute__.
31 if [get_compiler_info] {
32 return -1
33 }
34 if !$gcc_compiled {
35 verbose "Skipping $gdb_test_file_name."
36 return 0
37 }
38
39 standard_testfile .c -dw.S
40
41 set asm_file [standard_output_file $srcfile2]
42 Dwarf::assemble $asm_file {
43 global srcdir subdir srcfile srcfile2
44 declare_labels ranges_label
45
46 # Find start address and length for our functions.
47 set main_func \
48 [function_range main [list ${srcdir}/${subdir}/$srcfile]]
49 set foo_func \
50 [function_range foo [list ${srcdir}/${subdir}/$srcfile]]
51 set bar_func \
52 [function_range bar [list ${srcdir}/${subdir}/$srcfile]]
53
54 cu {} {
55 compile_unit {
56 {language @DW_LANG_C_plus_plus}
57 {name $srcfile}
58 {ranges ${ranges_label} DW_FORM_sec_offset}
59 } {
60 subprogram {
61 {external 1 flag}
62 {name main}
63 }
64 }
65 }
66
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]
73 }
74 }
75 }
76
77 if { [prepare_for_testing "failed to prepare" ${testfile} \
78 [list $srcfile $asm_file] {nodebug}] } {
79 return -1
80 }
81
82 if ![runto foo] {
83 return -1
84 }
85
86 gdb_test "show language" \
87 "The current source language is \"auto; currently c\"\."
This page took 0.031172 seconds and 3 git commands to generate.