1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
# Copyright 2008-2023 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This file tests setting breakpoints according to the full path of a
# source file.
standard_testfile
# We rely on being able to copy things around.
if { [is_remote host] } {
untested "setting breakpoints by full path"
return -1
}
# Create a temporary file in the build directory. Use a different
# filename in case ${srcdir} == ${objdir}.
if { [catch {file copy -force ${srcdir}/${subdir}/${srcfile} \
[standard_output_file tmp-${srcfile}]}] != 0 } {
error "Could not create temporary file"
return -1
}
# Build the test executable using an absolute path.
if { [gdb_compile [standard_output_file tmp-${srcfile}] "${binfile}" executable {debug}] != "" } {
return -1
}
# Unlike most GDB tests, we do not use gdb_reinitialize_dir in this script.
# We're testing GDB's ability to find files in other ways.
# Get the line number.
set line [gdb_get_line_number "set breakpoint 1 here"]
# Initialize GDB after getting the line number, to make sure
# symbols aren't loaded.
gdb_exit
gdb_start
gdb_load ${binfile}
set msg "set breakpoint by full path before loading symbols - built absolute"
if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
pass $msg
} else {
fail $msg
}
gdb_test "break -q main" \
"Breakpoint.*at.*line.*" "set breakpoint at main - built absolute"
set msg "set breakpoint by full path after loading symbols - built absolute"
if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
pass $msg
} else {
fail $msg
}
# Build the test executable using a relative path.
if { [gdb_compile [relative_filename [pwd] [standard_output_file tmp-${srcfile}]] \
"${binfile}" executable {debug}] != "" } {
return -1
}
gdb_exit
gdb_start
gdb_load ${binfile}
set msg "set breakpoint by full path before loading symbols - built relative"
if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
pass $msg
} else {
fail $msg
}
gdb_test "break -q main" \
"Breakpoint.*at.*line.*" "set breakpoint at main - built relative"
set msg "set breakpoint by full path after loading symbols - built relative"
if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
pass $msg
} else {
fail $msg
}
# Build the test executable using relative paths not relative to the directory
# we'll run GDB from.
with_cwd [standard_output_file {}] {
if { [gdb_compile [standard_output_file tmp-${srcfile}] "${testfile}" \
executable {debug}] != "" } {
return -1
}
}
gdb_exit
gdb_start
gdb_load ${binfile}
set msg "set breakpoint by full path before loading symbols - built other"
if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
pass $msg
} else {
fail $msg
}
gdb_test "break -q main" \
"Breakpoint.*at.*line.*" "set breakpoint at main - built other"
set msg "set breakpoint by full path after loading symbols - built other"
if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
pass $msg
} else {
fail $msg
}
|