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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [testsuite/] [gdb.threads/] [step.exp] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
# step.exp -- Expect script to test gdb with step.c
2
# Copyright (C) 1992, 1997 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 Hiro Sugawara. (hiro@lynx.com)
22
#
23
# This test really needs some major surgery to be acceptable, but
24
# I'm just about burnt out on lynx work, so I'm not doing it now.
25
#
26
#       * The test has an indeterminate number of pass/fails
27
#       for each run (it runs a small group of tests until
28
#       it's timer kicks off).  This is very bad for nightly
29
#       automated regression testing.
30
#
31
#       * It tries to "step" from withint he prologue of a
32
#       function.  This isn't support in gdb (it's going
33
#       to act like a continue).
34
#
35
#       * This test rarely check that it stopped in sensible
36
#       places.  (see previous bullet -- this test doesn't
37
#       catch the fact it continued rather than stepped)
38
 
39
 
40
if $tracelevel then {
41
        strace $tracelevel
42
}
43
 
44
set program_exited 0
45
 
46
proc set_bp { where } {
47
    global gdb_prompt
48
 
49
    send_gdb "break $where\n"
50
    # The first regexp is what we get with -g, the second without -g.
51
    gdb_expect {
52
        -re "Break.* at .*: file .*, line \[0-9\]*.*$gdb_prompt $" {}
53
        -re "Breakpoint \[0-9\]* at 0x\[0-9a-f\]*.*$gdb_prompt $" {}
54
        -re "$gdb_prompt $" { fail "setting breakpoint at $where" ; return 0 }
55
        timeout { fail "setting breakpoint at $where (timeout)" ; return 0 }
56
    }
57
    pass "set_bp"
58
}
59
 
60
proc step_it { cmd } {
61
    global gdb_prompt
62
    global program_exited
63
 
64
    send_gdb "$cmd\n"
65
    gdb_expect {
66
        -re "0x\[0-9A-Fa-f\]* *in.*\r\n$gdb_prompt $" { pass "step_it"; return 0 }
67
        -re "0x\[0-9A-Fa-f\]* *\[0-9\]*.*\r\n$gdb_prompt $" { pass "step_it"; return 1 }
68
        -re "Program exited .*\n$gdb_prompt $" {
69
                set program_exited 1
70
                return -1
71
            }
72
        -re "$gdb_prompt $"     { fail "single-stepping ($cmd).\n" ; return -1 }
73
        timeout { fail "single-stepping ($cmd) timout.\n" ; return -1 }
74
    }
75
}
76
 
77
proc step_inst {} {
78
    step_it "stepi"
79
}
80
 
81
proc step_source {} {
82
    step_it "step"
83
}
84
 
85
proc continue_all {} {
86
    global gdb_prompt
87
 
88
    send_gdb "continue\n"
89
    gdb_expect {
90
        -re "Breakpoint \[0-9\]*, thread\[0-9\]* .*$gdb_prompt $" {
91
            pass "continue_all"
92
            return 0
93
        }
94
        -re "Program exited .*\n$gdb_prompt $" {
95
            set program_exited 1
96
            return 1;
97
        }
98
        -re "$gdb_prompt $" { fail "continue" ; return -1 }
99
        timeout { fail "continue (timeout)" ; return -1 }
100
    }
101
}
102
 
103
proc check_threads { num_threads } {
104
    global gdb_prompt
105
 
106
    set curr_thread 0
107
    send_gdb "info threads\n"
108
    while { $num_threads > 0 } {
109
        gdb_expect {
110
            -re "\\* *\[0-9\]* process \[0-9\]* thread \[0-9\]* .*\n" {
111
                incr curr_thread
112
                set num_threads [expr $num_threads - 1]
113
            }
114
            -re " *\[0-9\]* process \[0-9\]* thread \[0-9\]* .*\n" {
115
                set num_threads [expr $num_threads - 1]
116
            }
117
            -re "$gdb_prompt $" {
118
                if { $num_threads < 0 } {
119
                    fail "check_threads (too many)" ; return -1
120
                }
121
                break
122
            }
123
            timeout { fail "check_threads (timeout)" ; return -1 }
124
        }
125
    }
126
 
127
    if { $curr_thread == 0 } {
128
        fail "check_threads (no current thread)\n"
129
        return -1
130
    }
131
    if { $curr_thread > 1 } {
132
        fail "check_threads (more than one current thread)\n"
133
        return -1
134
    }
135
    return 0
136
}
137
 
138
proc test_cond_wait {} {
139
    global program_exited
140
 
141
    set_bp      135
142
    runto       179
143
    while { 1 } {
144
        set stepi_counter 0
145
        while { [step_inst] } {
146
                if { $program_exited } { break }
147
                incr stepi_counter
148
                if { $stepi_counter > 30 } {
149
                        fail "too many stepi's per line\n"
150
                        return -1
151
                }
152
        }
153
        if { $program_exited } { break }
154
        step_source
155
        if { $program_exited } { break }
156
        continue_all
157
        if { $program_exited } { break }
158
        check_threads 3
159
    }
160
}
161
 
162
proc do_tests {} {
163
    global prms_id
164
    global bug_id
165
    global subdir
166
    global objdir
167
    global srcdir
168
    global binfile
169
    global gdb_prompt
170
 
171
    set prms_id 0
172
    set bug_id 0
173
 
174
    # Start with a fresh gdb.
175
 
176
    gdb_exit
177
    gdb_start
178
    gdb_reinitialize_dir $srcdir/$subdir
179
    gdb_load $objdir/$subdir/$binfile
180
 
181
    send_gdb "set width 0\n"
182
    gdb_expect -re "$gdb_prompt $"
183
 
184
    test_cond_wait
185
}
186
 
187
# Check to see if we have an executable to test.  If not, then either we
188
# haven't tried to compile one, or the compilation failed for some reason.
189
# In either case, just notify the user and skip the tests in this file.
190
 
191
set binfile "step"
192
set srcfile "step.c"
193
 
194
if ![file exists $objdir/$subdir/$binfile] then {
195
    if $all_flag then {
196
        warning "$binfile does not exist; tests suppressed."
197
    }
198
} else {
199
    do_tests
200
}

powered by: WebSVN 2.1.0

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