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