Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 2014-2022 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 | ||
20 | load_lib dwarf.exp | |
21 | ||
22 | # This test can only be run on targets which support DWARF-2 and use | |
23 | # gas. | |
24 | if {![dwarf2_support]} { | |
25 | return 0 | |
26 | } | |
27 | ||
d1c8a76d | 28 | standard_testfile .c .S |
40e3ad0e PA |
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 | ||
34 | proc 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 } { | |
40e3ad0e PA |
45 | compile_unit { |
46 | {name file1.txt} | |
47 | {language @$cu_lang} | |
90c3ec2d | 48 | {MACRO_AT_range {func}} |
40e3ad0e PA |
49 | } { |
50 | subprogram { | |
51 | {external 1 flag} | |
90c3ec2d | 52 | {MACRO_AT_func {func}} |
40e3ad0e PA |
53 | } { |
54 | } | |
55 | } | |
56 | } | |
57 | } | |
58 | ||
59 | if { [prepare_for_testing "failed to prepare" ${testfile} \ | |
60 | [list $srcfile $asm_file] {nodebug}] } { | |
61 | return -1 | |
62 | } | |
63 | ||
64 | if ![runto func] { | |
65 | return -1 | |
66 | } | |
67 | ||
68 | gdb_test "show language" "\"auto; currently $gdb_lang\".*" | |
69 | } | |
70 | ||
111b33f0 TV |
71 | proc do_test_with_prefix {cu_lang gdb_lang} { |
72 | with_test_prefix $gdb_lang { | |
73 | do_test $cu_lang $gdb_lang | |
74 | } | |
75 | } | |
76 | ||
40e3ad0e PA |
77 | # Some paths in the debugger fall back to C. Check C++ as well to |
78 | # make sure the test doesn't happen to work because of such a | |
79 | # fallback. | |
111b33f0 TV |
80 | do_test_with_prefix DW_LANG_C "c" |
81 | do_test_with_prefix DW_LANG_C_plus_plus "c\\+\\+" |