]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/fullname.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / fullname.exp
CommitLineData
1d506c26 1# Copyright 2008-2024 Free Software Foundation, Inc.
55cd6f92
DJ
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# This file tests setting breakpoints according to the full path of a
17# source file.
18
289f9037 19standard_testfile
55cd6f92 20
52c0551e
TT
21# We rely on being able to copy things around and being able to set
22# breakpoints by full path.
23require {!is_remote host}
55cd6f92
DJ
24
25# Create a temporary file in the build directory. Use a different
26# filename in case ${srcdir} == ${objdir}.
27if { [catch {file copy -force ${srcdir}/${subdir}/${srcfile} \
289f9037 28 [standard_output_file tmp-${srcfile}]}] != 0 } {
55cd6f92
DJ
29 error "Could not create temporary file"
30 return -1
31}
32
33# Build the test executable using an absolute path.
289f9037 34if { [gdb_compile [standard_output_file tmp-${srcfile}] "${binfile}" executable {debug}] != "" } {
55cd6f92
DJ
35 return -1
36}
37
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.
40
41# Get the line number.
42
43set line [gdb_get_line_number "set breakpoint 1 here"]
44
45# Initialize GDB after getting the line number, to make sure
46# symbols aren't loaded.
47
c95d486d 48clean_restart $binfile
55cd6f92
DJ
49
50set msg "set breakpoint by full path before loading symbols - built absolute"
289f9037 51if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
55cd6f92
DJ
52 pass $msg
53} else {
54 fail $msg
55}
56
e777225b 57gdb_test "break -q main" \
55cd6f92
DJ
58 "Breakpoint.*at.*line.*" "set breakpoint at main - built absolute"
59
60set msg "set breakpoint by full path after loading symbols - built absolute"
289f9037 61if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
55cd6f92
DJ
62 pass $msg
63} else {
64 fail $msg
65}
66
67# Build the test executable using a relative path.
1e537771
TT
68if { [gdb_compile [relative_filename [pwd] [standard_output_file tmp-${srcfile}]] \
69 "${binfile}" executable {debug}] != "" } {
55cd6f92
DJ
70 return -1
71}
72
c95d486d 73clean_restart $binfile
55cd6f92
DJ
74
75set msg "set breakpoint by full path before loading symbols - built relative"
289f9037 76if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
55cd6f92
DJ
77 pass $msg
78} else {
79 fail $msg
80}
81
e777225b 82gdb_test "break -q main" \
55cd6f92
DJ
83 "Breakpoint.*at.*line.*" "set breakpoint at main - built relative"
84
85set msg "set breakpoint by full path after loading symbols - built relative"
289f9037 86if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
55cd6f92
DJ
87 pass $msg
88} else {
89 fail $msg
90}
91
92# Build the test executable using relative paths not relative to the directory
93# we'll run GDB from.
94
019a5c62
SM
95with_cwd [standard_output_file {}] {
96 if { [gdb_compile [standard_output_file tmp-${srcfile}] "${testfile}" \
97 executable {debug}] != "" } {
98 return -1
99 }
55cd6f92 100}
55cd6f92 101
c95d486d 102clean_restart $binfile
55cd6f92
DJ
103
104set msg "set breakpoint by full path before loading symbols - built other"
289f9037 105if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
55cd6f92
DJ
106 pass $msg
107} else {
108 fail $msg
109}
110
e777225b 111gdb_test "break -q main" \
55cd6f92
DJ
112 "Breakpoint.*at.*line.*" "set breakpoint at main - built other"
113
114set msg "set breakpoint by full path after loading symbols - built other"
289f9037 115if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
55cd6f92
DJ
116 pass $msg
117} else {
118 fail $msg
119}