]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.dwarf2/comp-unit-lang.exp
update copyright year range in GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / comp-unit-lang.exp
CommitLineData
61baf725 1# Copyright 2014-2017 Free Software Foundation, Inc.
40e3ad0e
PA
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# Test that GDB determines the frame's language based on the comp
17# unit's language, even if the file has an unknown file extension,
18# such as ".txt".
19
20load_lib dwarf.exp
21
22# This test can only be run on targets which support DWARF-2 and use
23# gas.
24if {![dwarf2_support]} {
25 return 0
26}
27
28standard_testfile .c comp-unit-lang.S
29
30# Assemble the DWARF using CU_LANG as compilation unit's language.
31# Run to a function in that compilation unit and check that GDB
32# figures out that the language is GDB_LANG.
33
34proc do_test {cu_lang gdb_lang} {
35 global testfile srcfile srcfile2
36
37 # Make some DWARF for the test.
38 set asm_file [standard_output_file $srcfile2]
39 Dwarf::assemble $asm_file {
40 upvar cu_lang cu_lang
41
42 # Creating a CU with 4-byte addresses lets this test link on
43 # both 32- and 64-bit machines.
44 cu { addr_size 4 } {
45 extern func_start func_end
46
47 compile_unit {
48 {name file1.txt}
49 {language @$cu_lang}
50 {low_pc func_start addr}
51 {high_pc func_end addr}
52 } {
53 subprogram {
54 {external 1 flag}
55 {name func}
56 {low_pc func_start addr}
57 {high_pc func_end addr}
58 } {
59 }
60 }
61 }
62 }
63
64 if { [prepare_for_testing "failed to prepare" ${testfile} \
65 [list $srcfile $asm_file] {nodebug}] } {
66 return -1
67 }
68
69 if ![runto func] {
70 return -1
71 }
72
73 gdb_test "show language" "\"auto; currently $gdb_lang\".*"
74}
75
76# Some paths in the debugger fall back to C. Check C++ as well to
77# make sure the test doesn't happen to work because of such a
78# fallback.
79do_test DW_LANG_C "c"
80do_test DW_LANG_C_plus_plus "c\\+\\+"