OSDN Git Service

Copyright updates for 2007.
[pf3gnuchains/pf3gnuchains3x.git] / gdb / testsuite / gdb.base / return.exp
1 # Copyright (C) 1992, 1997, 2001, 2007 Free Software Foundation, Inc.
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 2 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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20 # This file was written by Jeff Law. (law@cs.utah.edu)
21
22 if $tracelevel then {
23         strace $tracelevel
24 }
25
26 set prms_id 0
27 set bug_id 0
28
29 set testfile "return"
30 set srcfile ${testfile}.c
31 set binfile ${objdir}/${subdir}/${testfile}
32 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
33      untested return.exp
34      return -1
35 }
36
37 proc return_tests { } {
38     global gdb_prompt
39
40
41     if { ! [ runto func1 ] } then { return 0 }
42     send_gdb "return\n"
43     gdb_expect {
44         -re "Make .* return now.*y or n. $" {
45             send_gdb "y\n"
46             exp_continue
47         }
48         -re "func1 ..;.*$gdb_prompt $" {
49             send_gdb "step\n"
50             exp_continue
51         }
52     -re ".*in main after func1.*$gdb_prompt $" { pass "simple return" }
53     -re "$gdb_prompt $" { fail "simple return" }
54     timeout { fail "(timeout) simple return" }
55     }
56
57     # Set breakpoints in other interesting functions.
58     gdb_test "break func2" "" "break func2"
59     gdb_test "break func3" "" "break func3"
60
61     gdb_test "continue" "return -5;" "continue to return of -5"
62     send_gdb "return 5\n"
63     gdb_expect {
64         -re "Make .* return now.*y or n. $" {
65             send_gdb "y\n"
66             exp_continue
67         }
68     -re ".*tmp2 = func2.*$gdb_prompt $" { }
69     -re "$gdb_prompt $" { fail "did not return (integer test)" }
70     timeout { fail "(timeout) did not return (integer test)" }
71     }
72     gdb_test "next" "tmp3 = func3.*" "next over call to func2"
73
74     gdb_test "p tmp2" ".* = 5" "correct value returned (integer test)"
75
76     gdb_test "continue" "return -5.0;" "continue to return of -5.0"
77
78     # Return of a double does not work for 68hc11 (need struct return
79     # in memory).
80     setup_xfail "m6811-*-*"
81     send_gdb "return 5.0\n"
82     gdb_expect {
83         -re "Make .* return now.*y or n. $" {
84             send_gdb "y\n"
85             exp_continue
86         }
87         -re ".*tmp3 = func3.*$gdb_prompt $" { }
88         -re "$gdb_prompt $" { fail "did not return (double test)" }
89         timeout { fail "(timeout) did not return (double test)" }
90     }
91
92     setup_xfail "m6811-*-*"
93     gdb_test "next" "printf.*" "next over call to func3"
94
95     # This test also fails for sparc Solaris 2.3 & 2.4, but passes under 2.5
96     # At the time the `next' is issued, the floating point unit for the
97     # process is not yet initialized, and the storing of the floating
98     # point value to the floating point return register is ignored.
99     # Xfail it for current versions that are known to fail.  Presumably
100     # if some future version does initialize the floating point unit at
101     # process start, making this test pass, it will be for a version that
102     # is not xfailed.
103
104     setup_xfail "sparc-*-solaris2.3*" "sparc-*-solaris2.4*" "m6811-*-*"
105     gdb_test "p tmp3" ".* = 5.*" "correct value returned double test (known problem with sparc solaris)"
106 }
107
108
109 # Start with a fresh gdb.
110
111 gdb_exit
112 gdb_start
113 gdb_reinitialize_dir $srcdir/$subdir
114 gdb_load ${binfile}
115
116 set timeout 30
117 return_tests