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/] [attach-into-signal.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
# Copyright 2008, 2009, 2010 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 3 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, see .
15
 
16
# This test was created by modifying attach-stopped.exp.
17
# This file was created by Jan Kratochvil .
18
 
19
# This test only works on Linux
20
if { ![isnative] || [is_remote host] || ![istarget *-linux*] } {
21
    continue
22
}
23
 
24
set testfile "attach-into-signal"
25
set srcfile  ${testfile}.c
26
set binfile  ${objdir}/${subdir}/${testfile}
27
set escapedbinfile  [string_to_regexp ${objdir}/${subdir}/${testfile}]
28
 
29
remote_exec build "rm -f ${binfile}"
30
# For debugging this test
31
#
32
#log_user 1
33
 
34
proc corefunc { threadtype } {
35
    global srcfile
36
    global binfile
37
    global escapedbinfile
38
    global srcdir
39
    global subdir
40
    global gdb_prompt
41
 
42
    if [get_compiler_info ${binfile}] {
43
        return -1
44
    }
45
 
46
    # Start the program running and then wait for a bit, to be sure
47
    # that it can be attached to.
48
    # Statistically there is a better chance without giving process a nice.
49
 
50
    set testpid [eval exec $binfile &]
51
    exec sleep 2
52
 
53
    # Run 2 passes of the test.
54
    # The C file inferior stops pending its signals if a single one is lost,
55
    # we test successful redelivery of the caught signal by the 2nd pass.
56
 
57
    # linux-2.6.20.4.x86_64 had maximal attempt # 20 in 4 test runs.
58
    set attempts 100
59
    set attempt 1
60
    set passes 1
61
    while { $passes < 3 && $attempt <= $attempts } {
62
        set stoppedtry 0
63
        while { $stoppedtry < 10 } {
64
            if [catch {open /proc/${testpid}/status r} fileid] {
65
                set stoppedtry 10
66
                break
67
            }
68
            gets $fileid line1;
69
            gets $fileid line2;
70
            close $fileid;
71
 
72
            if {![string match "*(stopped)*" $line2]} {
73
                # No PASS message as we may be looping in multiple attempts.
74
                break
75
            }
76
            sleep 1
77
            set stoppedtry [expr $stoppedtry + 1]
78
        }
79
        if { $stoppedtry >= 10 } {
80
            verbose -log $line2
81
            set test "$threadtype: process is still running on the attempt # $attempt of $attempts"
82
            break
83
        }
84
 
85
        # Main test:
86
        set test "$threadtype: attach (pass $passes), pending signal catch"
87
        if {[gdb_test_multiple "attach $testpid" $test {
88
            -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*Received Alarm clock.*$gdb_prompt $" {
89
                # nonthreaded:
90
                pass $test
91
                verbose -log "$test succeeded on the attempt # $attempt of $attempts"
92
                set passes [expr $passes + 1]
93
            }
94
            -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
95
                # nonthreaded:
96
                # We just lack the luck, we should try it again.
97
                set attempt [expr $attempt + 1]
98
            }
99
            -re "Attaching to process $testpid.*Received Alarm clock.*$gdb_prompt $" {
100
                # threaded:
101
                pass $test
102
                verbose -log "$test succeeded on the attempt # $attempt of $attempts"
103
                set passes [expr $passes + 1]
104
            }
105
            -re "Attaching to process $testpid.*$gdb_prompt $" {
106
                # threaded:
107
                # We just lack the luck, we should try it again.
108
                set attempt [expr $attempt - 1]
109
            }
110
        }] != 0 } {
111
            break
112
        }
113
 
114
        gdb_test "detach" "Detaching from.*" ""
115
    }
116
    if {$passes < 3} {
117
        if {$attempt > $attempts} {
118
            unresolved $test
119
        } else {
120
            fail $test
121
        }
122
    }
123
 
124
    # Exit and detach the process.
125
 
126
    gdb_exit
127
 
128
    # Make sure we don't leave a process around to confuse
129
    # the next test run (and prevent the compile by keeping
130
    # the text file busy), in case the "set should_exit" didn't
131
    # work.
132
 
133
    # Continue the program - some Linux kernels need it before -9 if the
134
    # process is stopped.
135
    remote_exec build "kill -s CONT ${testpid}"
136
 
137
    remote_exec build "kill -9 ${testpid}"
138
}
139
 
140
# Start with clean gdb
141
gdb_exit
142
 
143
# build the test case first without threads
144
#
145
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
146
    untested "attach-into-signal.exp (unthreaded)"
147
    return -1
148
}
149
 
150
gdb_start
151
gdb_reinitialize_dir $srcdir/$subdir
152
gdb_load ${binfile}
153
gdb_test "set debug lin-lwp 1" "" ""
154
 
155
corefunc nonthreaded
156
 
157
# build the test case also with threads
158
#
159
if  { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DUSE_THREADS}] != "" } {
160
    untested "attach-into-signal.exp (threaded)"
161
    return -1
162
}
163
 
164
gdb_start
165
gdb_reinitialize_dir $srcdir/$subdir
166
gdb_load ${binfile}
167
gdb_test "set debug lin-lwp 1" "" ""
168
 
169
corefunc threaded

powered by: WebSVN 2.1.0

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