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

Subversion Repositories openrisc

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

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

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

powered by: WebSVN 2.1.0

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