Fix: Null pointer dereference in ldlex.l
[binutils-gdb.git] / gdb / testsuite / gdb.base / fullname.exp
blob3e25f8de58bebf0db62fefc242e6af36a7672612
1 # Copyright 2008-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 file tests setting breakpoints according to the full path of a
17 # source file.
19 standard_testfile
21 # We rely on being able to copy things around and being able to set
22 # breakpoints by full path.
23 require {!is_remote host}
25 # Create a temporary file in the build directory. Use a different
26 # filename in case ${srcdir} == ${objdir}.
27 if { [catch {file copy -force ${srcdir}/${subdir}/${srcfile} \
28 [standard_output_file tmp-${srcfile}]}] != 0 } {
29 error "Could not create temporary file"
30 return -1
33 # Build the test executable using an absolute path.
34 if { [gdb_compile [standard_output_file tmp-${srcfile}] "${binfile}" executable {debug}] != "" } {
35 return -1
38 # Unlike most GDB tests, we do not use gdb_reinitialize_dir in this script.
39 # We're testing GDB's ability to find files in other ways.
41 # Get the line number.
43 set line [gdb_get_line_number "set breakpoint 1 here"]
45 # Initialize GDB after getting the line number, to make sure
46 # symbols aren't loaded.
48 clean_restart $binfile
50 set msg "set breakpoint by full path before loading symbols - built absolute"
51 if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
52 pass $msg
53 } else {
54 fail $msg
57 gdb_test "break -q main" \
58 "Breakpoint.*at.*line.*" "set breakpoint at main - built absolute"
60 set msg "set breakpoint by full path after loading symbols - built absolute"
61 if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
62 pass $msg
63 } else {
64 fail $msg
67 # Build the test executable using a relative path.
68 if { [gdb_compile [relative_filename [pwd] [standard_output_file tmp-${srcfile}]] \
69 "${binfile}" executable {debug}] != "" } {
70 return -1
73 clean_restart $binfile
75 set msg "set breakpoint by full path before loading symbols - built relative"
76 if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
77 pass $msg
78 } else {
79 fail $msg
82 gdb_test "break -q main" \
83 "Breakpoint.*at.*line.*" "set breakpoint at main - built relative"
85 set msg "set breakpoint by full path after loading symbols - built relative"
86 if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
87 pass $msg
88 } else {
89 fail $msg
92 # Build the test executable using relative paths not relative to the directory
93 # we'll run GDB from.
95 with_cwd [standard_output_file {}] {
96 if { [gdb_compile [standard_output_file tmp-${srcfile}] "${testfile}" \
97 executable {debug}] != "" } {
98 return -1
102 clean_restart $binfile
104 set msg "set breakpoint by full path before loading symbols - built other"
105 if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
106 pass $msg
107 } else {
108 fail $msg
111 gdb_test "break -q main" \
112 "Breakpoint.*at.*line.*" "set breakpoint at main - built other"
114 set msg "set breakpoint by full path after loading symbols - built other"
115 if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
116 pass $msg
117 } else {
118 fail $msg