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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1181 sfurman
# Copyright (C) 1996, 1997, 2002 Free Software Foundation, Inc.
2
 
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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 Daniel Jacobowitz 
21
# (parts based on pthreads.exp by Fred Fish (fnf@cygnus.com).
22
#
23
# It tests miscellaneous actions with multiple threads, including
24
# handling for thread exit.
25
 
26
if $tracelevel then {
27
        strace $tracelevel
28
}
29
 
30
set prms_id 0
31
set bug_id 0
32
 
33
set testfile "print-threads"
34
set srcfile ${testfile}.c
35
set binfile ${objdir}/${subdir}/${testfile}
36
 
37
# regexp for "horizontal" text (i.e. doesn't include newline or
38
# carriage return)
39
set horiz "\[^\n\r\]*"
40
 
41
set built_binfile 0
42
 
43
# Default to the usual (only?) -lpthread on GNU/Linux to quiet noise
44
if [istarget "*-*-linux*"] then {
45
    set possible_libs "-lpthread -lpthreads -lthread"
46
} else {
47
    set possible_libs "-lpthreads -lpthread -lthread"
48
}
49
 
50
set why_msg "unrecognized error"
51
foreach lib $possible_libs {
52
    set options "debug"
53
    lappend options "incdir=${objdir}/${subdir}"
54
    lappend options "libs=$lib"
55
    set ccout [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $options]
56
    switch -regexp -- $ccout {
57
        ".*no posix threads support.*" {
58
            set why_msg "missing threads include file"
59
            break
60
        }
61
        ".*cannot open -lpthread.*" {
62
            set why_msg "missing runtime threads library"
63
        }
64
        ".*Can't find library for -lpthread.*" {
65
            set why_msg "missing runtime threads library"
66
        }
67
        {^$} {
68
            pass "successfully compiled posix threads test case"
69
            set built_binfile 1
70
            break
71
        }
72
    }
73
}
74
if {$built_binfile == "0"} {
75
    unsupported "Couldn't compile ${srcfile}, ${why_msg}"
76
    return -1
77
}
78
 
79
# Now we can proceed with the real testing.
80
 
81
# Start with a fresh gdb.
82
 
83
gdb_exit
84
gdb_start
85
gdb_reinitialize_dir $srcdir/$subdir
86
gdb_load ${binfile}
87
 
88
gdb_test "set print sevenbit-strings" ""
89
#gdb_test "set print address off" ""
90
gdb_test "set width 0" ""
91
 
92
# We'll need this when we send_gdb a ^C to GDB.  Need to do it before we
93
# run the program and gdb starts saving and restoring tty states.
94
# On Ultrix, we don't need it and it is really slow (because shell_escape
95
# doesn't use vfork).
96
if ![istarget "*-*-ultrix*"] then {
97
    gdb_test "shell stty intr '^C'" ""
98
}
99
 
100
proc test_all_threads { name kill } {
101
    global gdb_prompt
102
 
103
    set i 0
104
    set j 0
105
    send_gdb "continue\n"
106
    gdb_expect {
107
        -re "Breakpoint \[0-9\]+, thread_function \\(arg=.*\\) at .*print-threads.c:\[0-9\]+.*$gdb_prompt" {
108
            set i [expr $i + 1]
109
            pass "Hit thread_function breakpoint, $i ($name)"
110
            send_gdb "continue\n"
111
            exp_continue
112
        }
113
        -re "Breakpoint \[0-9\]+, .* kill \\(.*\\) .*$gdb_prompt" {
114
            set j [expr $j + 1]
115
            if { $kill == 1 } {
116
                pass "Hit kill breakpoint, $j ($name)"
117
            } else {
118
                fail "Hit kill breakpoint, $j ($name) (unexpected)"
119
            }
120
            send_gdb "continue\n"
121
            exp_continue
122
        }
123
        -re "Program exited normally\\.\[\r\n\]+$gdb_prompt" {
124
            pass "program exited normally"
125
            if {$i == 5} {
126
                pass "all threads ran once ($name)"
127
            } else {
128
                fail "all threads ran once ($name) (total $i threads ran)"
129
            }
130
        }
131
        -re "$gdb_prompt" {
132
            fail "Running threads ($name) (unknown output)"
133
        }
134
        timeout {
135
            fail "Running threads ($name) (timeout)"
136
        }
137
    }
138
}
139
 
140
runto_main
141
gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\."
142
gdb_test "set var slow = 0" ""
143
test_all_threads "fast" 0
144
 
145
runto_main
146
gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." "break thread_function (2)"
147
gdb_test "set var slow = 1" ""
148
test_all_threads "slow" 0
149
 
150
runto_main
151
gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." "break thread_function (3)"
152
gdb_test "set var slow = 1" "" "set var slow = 1 (2)"
153
gdb_test "break kill" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+"
154
test_all_threads "slow with kill breakpoint" 1
155
 
156
return 0

powered by: WebSVN 2.1.0

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