OSDN Git Service

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