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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.threads/] [step.exp] - Blame information for rev 318

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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