• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/gdb/gdb/testsuite/gdb.base/
1# Copyright 2000, 2001, 2004, 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 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# Please email any bugs, comments, and/or additions to this file to:
17# bug-gdb@prep.ai.mit.edu
18
19# This file was written by Michael Snyder (msnyder@redhat.com)
20
21if $tracelevel then {
22	strace $tracelevel
23}
24
25set prms_id 0
26set bug_id 0
27
28set testfile "return2"
29set srcfile ${testfile}.c
30set binfile ${objdir}/${subdir}/${testfile}
31if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
32     untested return2.exp
33     return -1
34}
35
36proc return_1 { type } {
37    global gdb_prompt
38
39    gdb_test "break ${type}_func" "Breakpoint \[0123456789\].*" \
40	    "set break on ${type}_func"
41    gdb_test "continue" "Breakpoint.* ${type}_func.*" \
42	    "continue to ${type}_func"
43    send_gdb "return testval.${type}_testval\n"
44    gdb_expect {
45	-re "Make ${type}_func return now.*y or n. $" {
46	    send_gdb "y\n"
47	    exp_continue
48	}
49	-re ".*${type}_resultval *= ${type}_func.*$gdb_prompt $" {
50	    send_gdb "step\n"
51	    exp_continue
52	}
53	-re ".*${type}_checkpoint.*$gdb_prompt $" {
54	    pass "return from ${type}_func"
55	}
56	-re ".*$gdb_prompt $" {
57	    fail "return from ${type}_func"
58	}
59	timeout {
60	    fail "return from ${type}_func (timeout)"
61	}
62    }
63    gdb_test "print ${type}_resultval == testval.${type}_testval" ".* = 1" \
64	    "${type} value returned successfully"
65    gdb_test "print ${type}_resultval != ${type}_returnval" ".* = 1" \
66	    "validate result value not equal to program return value"
67}
68
69proc return_void { } {
70    global gdb_prompt
71
72    gdb_test "break void_func" "Breakpoint \[0123456789\].*" \
73	    "set break on void_func"
74    gdb_test "continue" "Breakpoint.* void_func.*" \
75	    "continue to void_func"
76    send_gdb "return \n"
77    gdb_expect {
78	-re "Make void_func return now.*y or n. $" {
79	    send_gdb "y\n"
80	    exp_continue
81	}
82	-re ".*void_func.*call to void_func.*$gdb_prompt $" {
83	    send_gdb "step\n"
84	    exp_continue
85	}
86	-re ".*void_checkpoint.*$gdb_prompt $" {
87	    pass "return from void_func"
88	}
89	-re ".*$gdb_prompt $" {
90	    fail "return from void_func"
91	}
92	timeout {
93	    fail "return from void_func (timeout)"
94	}
95    }
96    gdb_test "print void_test == 0" ".* = 1" \
97	    "void function returned successfully"
98}
99
100proc return2_tests { } {
101    global gdb_prompt
102
103    if { ! [ runto_main ] } then {
104	untested return2.exp
105	return -1
106    }
107
108    return_void
109    return_1 "char"
110    return_1 "short"
111    return_1 "int"
112    return_1 "long"
113    if { ! [istarget "m6811-*-*"] && ![istarget "h8300*-*"] } then {
114        return_1 "long_long"
115    }
116    return_1 "float"
117    if { ! [istarget "m6811-*-*"] } then {
118        return_1 "double"
119    }
120}
121
122# Start with a fresh gdb.
123
124gdb_exit
125gdb_start
126gdb_reinitialize_dir $srcdir/$subdir
127gdb_load ${binfile}
128
129set timeout 30
130return2_tests
131