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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1181 sfurman
# Copyright 1998, 1999, 2000 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
# Test GDB's ability to restore saved registers from stack frames
21
# when using the `return' command.
22
#
23
# This file was written by Jim Blandy , with
24
# fragments borrowed from return.exp.
25
 
26
if $tracelevel then {
27
        strace $tracelevel
28
}
29
 
30
set prms_id 0
31
set bug_id 0
32
 
33
set testfile "restore"
34
set srcfile ${testfile}.c
35
set binfile ${objdir}/${subdir}/${testfile}
36
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
37
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
38
}
39
 
40
proc restore_tests { } {
41
    global gdb_prompt
42
 
43
    if { ! [ runto driver ] } then { return 0 }
44
 
45
    set limit 5
46
 
47
    # For each caller function,
48
    #   call each of the callee functions,
49
    #   force a return from the callee, and
50
    #   make sure that the local variables still have the right values.
51
    for {set c 1} {$c <= $limit} {incr c} {
52
 
53
        # Set a breakpoint at the next caller function.
54
        gdb_test "tbreak caller$c" "Breakpoint.*\[0-9\]*\\." "tbreak caller$c"
55
 
56
        # Continue to the next caller function.
57
        gdb_test "continue" ".*/\\* caller$c \\*/" "run to caller$c"
58
 
59
        # Do each callee function.
60
        for {set e 1} {$e <= $limit} {incr e} {
61
 
62
            gdb_test "tbreak callee$e" "Breakpoint.*\[0-9\]*\\." \
63
                    "tbreak callee$e"
64
 
65
            gdb_test "continue" ".*/\\* callee$e \\*/" "run to callee$e"
66
 
67
            # Do a forced return from the callee.
68
            send_gdb "return 0\n"
69
            gdb_expect {
70
                -re "Make .* return now.*y or n. $" {
71
                    send_gdb "y\n"
72
                    exp_continue
73
                }
74
                -re "$gdb_prompt $" { }
75
            }
76
 
77
            # Check that the values of the local variables are what
78
            # they should be.
79
            for {set var 1} {$var <= $c} {incr var} {
80
                set expected [expr 0x7eeb + $var]
81
                gdb_test "print l$var" " = $expected" \
82
                         "caller$c called callee$e; variable l$var restored to $expected"
83
            }
84
        }
85
    }
86
 
87
    if ![gdb_skip_stdio_test "run to completion"] {
88
        send_gdb "continue\n"
89
 
90
        gdb_expect {
91
            -re "exiting" {
92
                pass "run to completion"
93
            }
94
            timeout {
95
                fail "(timeout) run to completion"
96
            }
97
        }
98
    } else {
99
        gdb_test "continue" "" ""
100
    }
101
}
102
 
103
 
104
 
105
# Start with a fresh gdb.
106
 
107
gdb_exit
108
gdb_start
109
gdb_reinitialize_dir $srcdir/$subdir
110
gdb_load ${binfile}
111
 
112
set timeout 30
113
restore_tests

powered by: WebSVN 2.1.0

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