Commit | Line | Data |
---|---|---|
0fb0cc75 | 1 | # Copyright 2008, 2009 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 | ||
19 | set testfile "fullname" | |
20 | set srcfile ${testfile}.c | |
21 | set binfile ${objdir}/${subdir}/${testfile} | |
22 | ||
23 | # We rely on being able to copy things around. | |
24 | ||
25 | if { [is_remote host] } { | |
26 | untested "setting breakpoints by full path" | |
27 | return -1 | |
28 | } | |
29 | ||
30 | # Create a temporary file in the build directory. Use a different | |
31 | # filename in case ${srcdir} == ${objdir}. | |
32 | if { [catch {file copy -force ${srcdir}/${subdir}/${srcfile} \ | |
33 | ${objdir}/${subdir}/tmp-${srcfile}}] != 0 } { | |
34 | error "Could not create temporary file" | |
35 | return -1 | |
36 | } | |
37 | ||
38 | # Build the test executable using an absolute path. | |
39 | if { [gdb_compile "${objdir}/${subdir}/tmp-${srcfile}" "${binfile}" executable {debug}] != "" } { | |
40 | return -1 | |
41 | } | |
42 | ||
43 | # Unlike most GDB tests, we do not use gdb_reinitialize_dir in this script. | |
44 | # We're testing GDB's ability to find files in other ways. | |
45 | ||
46 | # Get the line number. | |
47 | ||
48 | set line [gdb_get_line_number "set breakpoint 1 here"] | |
49 | ||
50 | # Initialize GDB after getting the line number, to make sure | |
51 | # symbols aren't loaded. | |
52 | ||
53 | gdb_exit | |
54 | gdb_start | |
55 | gdb_load ${binfile} | |
56 | ||
57 | set msg "set breakpoint by full path before loading symbols - built absolute" | |
58 | if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } { | |
59 | pass $msg | |
60 | } else { | |
61 | fail $msg | |
62 | } | |
63 | ||
64 | gdb_test "break main" \ | |
65 | "Breakpoint.*at.*line.*" "set breakpoint at main - built absolute" | |
66 | ||
67 | set msg "set breakpoint by full path after loading symbols - built absolute" | |
68 | if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } { | |
69 | pass $msg | |
70 | } else { | |
71 | fail $msg | |
72 | } | |
73 | ||
74 | # Build the test executable using a relative path. | |
75 | if { [gdb_compile "${subdir}/tmp-${srcfile}" "${binfile}" executable {debug}] != "" } { | |
76 | return -1 | |
77 | } | |
78 | ||
79 | gdb_exit | |
80 | gdb_start | |
81 | gdb_load ${binfile} | |
82 | ||
83 | set msg "set breakpoint by full path before loading symbols - built relative" | |
84 | if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } { | |
85 | pass $msg | |
86 | } else { | |
87 | fail $msg | |
88 | } | |
89 | ||
90 | gdb_test "break main" \ | |
91 | "Breakpoint.*at.*line.*" "set breakpoint at main - built relative" | |
92 | ||
93 | set msg "set breakpoint by full path after loading symbols - built relative" | |
94 | if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } { | |
95 | pass $msg | |
96 | } else { | |
97 | fail $msg | |
98 | } | |
99 | ||
100 | # Build the test executable using relative paths not relative to the directory | |
101 | # we'll run GDB from. | |
102 | ||
103 | set save_pwd [pwd] | |
104 | cd ${subdir} | |
105 | if { [gdb_compile "tmp-${srcfile}" "${testfile}" executable {debug}] != "" } { | |
a4a9b1c4 | 106 | cd $save_pwd |
55cd6f92 DJ |
107 | return -1 |
108 | } | |
109 | cd $save_pwd | |
110 | ||
111 | gdb_exit | |
112 | gdb_start | |
113 | gdb_load ${binfile} | |
114 | ||
115 | set msg "set breakpoint by full path before loading symbols - built other" | |
116 | if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } { | |
117 | pass $msg | |
118 | } else { | |
119 | fail $msg | |
120 | } | |
121 | ||
122 | gdb_test "break main" \ | |
123 | "Breakpoint.*at.*line.*" "set breakpoint at main - built other" | |
124 | ||
125 | set msg "set breakpoint by full path after loading symbols - built other" | |
126 | if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } { | |
127 | pass $msg | |
128 | } else { | |
129 | fail $msg | |
130 | } |