OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [gdb/] [testsuite/] [gdb.gdb/] [xfullpath.exp] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1181 sfurman
#   Copyright 2002
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 2 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, write to the Free Software
16
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
 
18
# Please email any bugs, comments, and/or additions to this file to:
19
# bug-gdb@prep.ai.mit.edu
20
 
21
# This file was written by Joel Brobecker. (brobecker@gnat.com), derived
22
# from selftest.exp, written by Rob Savoye.
23
 
24
if $tracelevel then {
25
    strace $tracelevel
26
}
27
 
28
set prms_id 0
29
set bug_id 0
30
 
31
# are we on a target board
32
if [is_remote target] {
33
    return
34
}
35
 
36
if [istarget "m68k*-*-hpux*"] then {
37
    # The top-level makefile passes CFLAGS= (no -g) for hp300.  This probably
38
    # should be fixed (it is only needed for gcc bootstrapping, not gdb),
39
    # but until then.....
40
    setup_xfail "*-*-*"
41
    fail "cannot test self if compiled without debug info"
42
    return -1
43
}
44
 
45
proc setup_test { executable } {
46
    global gdb_prompt
47
    global timeout
48
 
49
    # load yourself into the debugger
50
    # This can take a relatively long time, particularly for testing where
51
    # the executable is being accessed over a network, or where gdb does not
52
    # support partial symbols for a particular target and has to load the
53
    # entire symbol table.  Set the timeout to 10 minutes, which should be
54
    # adequate for most environments (it *has* timed out with 5 min on a
55
    # SPARCstation SLC under moderate load, so this isn't unreasonable).
56
    # After gdb is started, set the timeout to 30 seconds for the duration
57
    # of this test, and then back to the original value.
58
 
59
    set oldtimeout $timeout
60
    set timeout 600
61
    verbose "Timeout is now $timeout seconds" 2
62
    if {[gdb_load $executable] <0} then {
63
        set timeout $oldtimeout
64
        verbose "Timeout is now $timeout seconds" 2
65
        return -1
66
    }
67
    set timeout $oldtimeout
68
    verbose "Timeout is now $timeout seconds" 2
69
 
70
    # Set a breakpoint at main
71
    gdb_test "break captured_main" \
72
            "Breakpoint.*at.* file.*, line.*" \
73
            "breakpoint in captured_main"
74
 
75
    # run yourself
76
    # It may take a very long time for the inferior gdb to start (lynx),
77
    # so we bump it back up for the duration of this command.
78
    set timeout 600
79
 
80
    set description "run until breakpoint at captured_main"
81
    send_gdb "run -nw\n"
82
    gdb_expect {
83
        -re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.* at .*main.c:.*$gdb_prompt $" {
84
            pass "$description"
85
        }
86
        -re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.*$gdb_prompt $" {
87
            xfail "$description (line numbers scrambled?)"
88
        }
89
        -re "vfork: No more processes.*$gdb_prompt $" {
90
            fail "$description (out of virtual memory)"
91
            set timeout $oldtimeout
92
            verbose "Timeout is now $timeout seconds" 2
93
            return -1
94
        }
95
        -re ".*$gdb_prompt $" {
96
            fail "$description"
97
            set timeout $oldtimeout
98
            verbose "Timeout is now $timeout seconds" 2
99
            return -1
100
        }
101
        timeout {
102
            fail "$description (timeout)"
103
        }
104
    }
105
 
106
    set timeout $oldtimeout
107
    verbose "Timeout is now $timeout seconds" 2
108
 
109
    return 0
110
}
111
 
112
proc test_with_self { executable } {
113
 
114
    set setup_result [setup_test $executable]
115
    if {$setup_result <0} then {
116
        return -1
117
    }
118
 
119
    # A file which contains a directory prefix
120
    gdb_test "print xfullpath (\"./xfullpath.exp\")" \
121
             ".\[0-9\]+ =.*\".*/xfullpath.exp\"" \
122
             "A filename with ./ as the directory prefix"
123
 
124
    # A file which contains a directory prefix
125
    gdb_test "print xfullpath (\"../../defs.h\")" \
126
             ".\[0-9\]+ =.*\".*/defs.h\"" \
127
             "A filename with ../ in the directory prefix"
128
 
129
    # A one-character filename
130
    gdb_test "print xfullpath (\"./a\")" \
131
             ".\[0-9\]+ =.*\".*/a\"" \
132
             "A one-char filename in the current directory"
133
 
134
    # A file in the root directory
135
    gdb_test "print xfullpath (\"/root_file_which_should_exist\")" \
136
             ".\[0-9\]+ =.*\"/root_file_which_should_exist\"" \
137
             "A filename in the root directory"
138
 
139
    # A file which does not have a directory prefix
140
    gdb_test "print xfullpath (\"xfullpath.exp\")" \
141
             ".\[0-9\]+ =.*\"xfullpath.exp\"" \
142
             "A filename without any directory prefix"
143
 
144
    # A one-char filename without any directory prefix
145
    gdb_test "print xfullpath (\"a\")" \
146
             ".\[0-9\]+ =.*\"a\"" \
147
             "A one-char filename without any directory prefix"
148
 
149
    # An empty filename
150
    gdb_test "print xfullpath (\"\")" \
151
             ".\[0-9\]+ =.*\"\"" \
152
             "An empty filename"
153
 
154
    return 0
155
}
156
 
157
# Find a pathname to a file that we would execute if the shell was asked
158
# to run $arg using the current PATH.
159
 
160
proc find_gdb { arg } {
161
 
162
    # If the arg directly specifies an existing executable file, then
163
    # simply use it.
164
 
165
    if [file executable $arg] then {
166
        return $arg
167
    }
168
 
169
    set result [which $arg]
170
    if [string match "/" [ string range $result 0 0 ]] then {
171
        return $result
172
    }
173
 
174
    # If everything fails, just return the unqualified pathname as default
175
    # and hope for best.
176
 
177
    return $arg
178
}
179
 
180
# Run the test with self.
181
# Copy the file executable file in case this OS doesn't like to edit its own
182
# text space.
183
 
184
set GDB_FULLPATH [find_gdb $GDB]
185
 
186
# Remove any old copy lying around.
187
remote_file host delete x$tool
188
 
189
gdb_start
190
set file [remote_download host $GDB_FULLPATH x$tool]
191
set result [test_with_self $file];
192
gdb_exit;
193
catch "remote_file host delete $file";
194
 
195
if {$result <0} then {
196
    warning "Couldn't test self"
197
    return -1
198
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.