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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
# step2.exp -- Expect script to test gdb 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 Jeff Law. (law@cygnus.com)
22
#
23
 
24
 
25
if $tracelevel then {
26
        strace $tracelevel
27
}
28
 
29
set program_exited 0
30
 
31
# A simple and crude test to see that we can step two threads independently
32
proc test_multi_threaded_stepping {} {
33
    global gdb_prompt
34
    global hex
35
    global srcfile
36
    global decimal
37
 
38
    # Set breakpoints in code that we know is executed in only
39
    # thread of control.
40
    gdb_test "break thread1" \
41
             "Break.* at $hex: file .*$srcfile, line $decimal\\."
42
    gdb_test "break thread2" \
43
             "Break.* at $hex: file .*$srcfile, line $decimal\\."
44
 
45
    # the order in which things happen is indeterminate.  So we basically
46
    # look for a set of events and note that each one happens and that
47
    # all of the required events have happened when we're done.
48
    #
49
    # Right now we only verify that both threads start and that they
50
    # both call pthread_cond_wait twice.
51
    set thread1started 0
52
    set thread1condwait 0
53
    set thread2started 0
54
    set thread2condwait 0
55
 
56
    send_gdb "run\n"
57
    gdb_expect {
58
        -re "The program .* has been started already.*y or n. $" {
59
            send_gdb "y\n"
60
            exp_continue
61
        }
62
        -re ".*Breakpoint \[0-9\]+,.*thread1.* at .*$srcfile:.*\[\t \].*$gdb_prompt $" {
63
            if { $thread1started != 0 } then {
64
                fail "thread1 started"
65
                return
66
            } else {
67
                set thread1started 1
68
                pass "thread1 started"
69
            }
70
            send_gdb "step\n"
71
            exp_continue
72
        }
73
        -re ".*Breakpoint \[0-9\]+,.*thread2.* at .*$srcfile:.*\[\t \].*$gdb_prompt $" {
74
            if { $thread2started != 0 } then {
75
                fail "thread2 started"
76
                return
77
            } else {
78
                set thread2started 1
79
                pass "thread2 started"
80
            }
81
            send_gdb "step\n"
82
            exp_continue
83
        }
84
        -re ".*pthread_cond_wait.*cv_a.*$gdb_prompt" {
85
            if { $thread1started == 0 } then {
86
                fail "thread1 condwait"
87
                return
88
            }
89
            if { $thread1condwait < 2 } then {
90
                pass "thread1 condwait"
91
                incr thread1condwait
92
            }
93
            if { $thread2condwait == 2 } then {
94
                pass "multi threaded stepping"
95
                return
96
            }
97
            send_gdb "step\n"
98
            exp_continue
99
        }
100
 
101
        -re ".*pthread_cond_wait.*cv_b.*$gdb_prompt" {
102
            if { $thread2started == 0 } then {
103
                fail "thread2 condwait"
104
                return
105
            }
106
            if { $thread2condwait < 2 } then {
107
                pass "thread2 condwait"
108
                incr thread2condwait
109
            }
110
            if { $thread1condwait == 2 } then {
111
                pass "multi threaded stepping"
112
                return
113
            }
114
            send_gdb "step\n"
115
            exp_continue
116
        }
117
 
118
        -re "$gdb_prompt" {
119
            send_gdb "step\n"
120
            exp_continue
121
        }
122
        default { fail "multi threaded stepping" }
123
    }
124
}
125
 
126
# Check to see if we have an executable to test.  If not, then either we
127
# haven't tried to compile one, or the compilation failed for some reason.
128
# In either case, just notify the user and skip the tests in this file.
129
 
130
set binfile "step"
131
set srcfile "step.c"
132
 
133
if ![file exists $objdir/$subdir/$binfile] then {
134
    if $all_flag then {
135
        warning "$binfile does not exist; tests suppressed."
136
    }
137
    return
138
}
139
 
140
set prms_id 0
141
set bug_id 0
142
 
143
# Start with a fresh gdb.
144
 
145
gdb_exit
146
gdb_start
147
gdb_reinitialize_dir $srcdir/$subdir
148
gdb_load $objdir/$subdir/$binfile
149
 
150
test_multi_threaded_stepping

powered by: WebSVN 2.1.0

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