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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.threads/] [step2.exp] - Blame information for rev 842

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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