1 # Copyright 2021-2023 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/>.
16 # C test-case that mimics gdb.ada/dgopt.exp.
18 standard_testfile .c main.c
20 if { [build_executable "failed to prepare" $testfile $srcfile {debug}] } {
26 # Set language explicitly, to avoid expanding the include-main.c CU for the
27 # language lookup (this is currently not required, but may be after
28 # integration of the no-more-psym branch).
29 # This to make sure that the source file lookup we do later triggers the
31 gdb_test_no_output "set language c"
36 # Verify that no CU was expanded.
37 gdb_test_no_output "maint info symtab"
40 # List a line in include-main.c. The tricky bit is that there's no code in
41 # include-main.c, so the file should not occur in the .debug_line info.
42 # GDB needs to find the file based on the CU's DW_AT_name/DW_AT_comp_dir.
43 set line [gdb_get_line_number "include" $srcfile]
44 gdb_test "list $srcfile:$line" "$line\[ \t\]*#include \"main.c\""
46 # For completeness, also try to list a line in the file that does contain
48 set line [gdb_get_line_number "main" $srcfile2]
49 gdb_test "list $srcfile2:$line" "$line\[ \t\]*main \\(void\\)\r\n.*"