Fix: Null pointer dereference in ldlex.l
[binutils-gdb.git] / gdb / testsuite / gdb.base / list-missing-source.exp
blob63fd137273e184c8752280c34c43e2542ce89ff1
1 # Copyright 2019-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 # This test checks how GDB handles missing source files around the
17 # 'list' and 'info source' commands.
19 standard_testfile
21 # Create a source file in the output directory.
22 set srcfile [standard_output_file list-missing-source.c]
23 set fd [open "$srcfile" w]
24 puts $fd {
25 int
26 main ()
28 return 0;
31 close $fd
32 set srcfile [remote_download host $srcfile]
34 # Compile the source file.
35 set options "debug"
36 if { [gdb_compile "${srcfile}" "${binfile}" \
37 executable $options] != "" } {
38 untested "failed to compile"
39 return -1
42 # Now delete the source file.
43 remote_file host delete $srcfile
45 # Now start GDB, run to main and try to list the source.
46 clean_restart ${binfile}
48 if {![runto_main]} {
49 return 0
52 gdb_test "list" "1\[ \t\]+in\[ \t\]+$srcfile"
54 gdb_test "info source" \
55 [multi_line \
56 "info source" \
57 "Current source file is $srcfile\(" \
58 "Compilation directory is \[^\n\r\]+)?" \
59 "Source language is c." \
60 "Producer is \[^\n\r\]+" \
61 "Compiled with DWARF $decimal debugging format." \
62 "Does not include preprocessor macro info." ]