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.mi/] [mi-nsmoribund.exp] - Blame information for rev 227

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
load_lib mi-support.exp
17
set MIFLAGS "-i=mi"
18
 
19
gdb_exit
20
if {[mi_gdb_start]} {
21
    continue
22
}
23
 
24
#
25
# Start here
26
#
27
set testfile "nsmoribund"
28
set srcfile "$testfile.c"
29
set binfile "$objdir/$subdir/mi-$testfile"
30
 
31
set options [list debug incdir=$objdir]
32
if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
33
    return -1
34
}
35
 
36
mi_gdb_reinitialize_dir $srcdir/$subdir
37
mi_gdb_load $binfile
38
 
39
set supported 0
40
send_gdb "-gdb-show non-stop\n"
41
gdb_expect {
42
    -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$" {
43
        if { $expect_out(1,string) == "1" } {
44
            set supported 1
45
        }
46
    }
47
    -re ".$mi_gdb_prompt$" {
48
    }
49
}
50
 
51
mi_gdb_test "-gdb-set non-stop 1" ".*"
52
mi_gdb_test "-gdb-set target-async 1" ".*"
53
detect_async
54
 
55
if { [mi_run_to_main] < 0 } {
56
    perror "mi-nsmoribund.exp tests suppressed"
57
    continue
58
}
59
 
60
# Keep this in sync with THREADS in the the $srcfile.
61
set nthreads 10
62
 
63
# Set a breakpoint and let all threads hit it (except the main
64
# thread).
65
 
66
set bkpt_line [gdb_get_line_number "set breakpoint here"]
67
 
68
mi_create_breakpoint "$srcfile:$bkpt_line" 2 keep thread_function .* .* .* \
69
    "breakpoint at thread_function"
70
 
71
mi_send_resuming_command "exec-continue --all" "resume all"
72
for {set i 0} {$i < $nthreads} {incr i} {
73
    mi_expect_stop "breakpoint-hit" "thread_function" "\[^\n\]*" "$srcfile" \
74
        "\[0-9\]*" {"" "disp=\"keep\""} "stop $i"
75
}
76
 
77
# All but the main thread should have hit it.
78
 
79
mi_check_thread_states \
80
    {"running" "stopped" "stopped" "stopped" "stopped" "stopped" "stopped" "stopped" "stopped" "stopped" "stopped"} \
81
    "thread state: all stopped except the main thread"
82
 
83
# Select a stopped thread to make sure we're able to delete
84
# breakpoints
85
mi_gdb_test "-thread-select 5" "\\^done.*" "select thread 5"
86
 
87
# Now that we know about all the threads, we can get rid of
88
# breakpoint.
89
mi_delete_breakpoints
90
 
91
# Recreate the same breakpoint, but this time, specific to thread 5.
92
mi_create_breakpoint "-p 5 $srcfile:$bkpt_line" 3 keep thread_function .* .* .* \
93
    "thread specific breakpoint at thread_function"
94
 
95
# Resume all threads.  Only thread 5 should report a stop.
96
 
97
set running_re ""
98
for {set i $nthreads} {$i > 0} {incr i -1} {
99
    set running_re "$running_re\\*running,thread-id=\"$decimal\"\r\n"
100
}
101
 
102
send_gdb "-exec-continue --all\n"
103
gdb_expect {
104
    -re ".*$running_re$mi_gdb_prompt" {
105
        pass "resume all, thread specific breakpoint"
106
    }
107
    timeout {
108
        fail "resume all, thread specific breakpoint (timeout)"
109
    }
110
}
111
 
112
mi_expect_stop "breakpoint-hit" "thread_function" "\[^\n\]*" "$srcfile" \
113
    "\[0-9\]*" {"" "disp=\"keep\""} "hit thread specific breakpoint"
114
 
115
# All threads except both thread 5 (and the main thread) should now be
116
# repeatedly hitting the thread specific breakpoint and stepping over
117
# it transparently.  These are internal events, so the frontend should
118
# see those threads as running.
119
 
120
mi_check_thread_states \
121
    {"running" "running" "running" "running" "stopped" "running" "running" "running" "running"} \
122
    "thread state: all running except the breakpoint thread"
123
 
124
# Get rid of the breakpoint while the other threads are stepping over
125
# it, and tell all threads to exit.  The program should exit
126
# gracefully shortly.  Send all commands in a row, since if something
127
# goes wrong with moribund locations support or displaced stepping (or
128
# a target bug if it can step over breakpoints itself), a spurious
129
# SIGTRAP/SIGSEGV can come at any time after deleting the breakpoint.
130
 
131
send_gdb "102-break-delete\n"
132
send_gdb "print done = 1\n"
133
send_gdb "103-exec-continue --all\n"
134
 
135
gdb_expect {
136
    -re "\\*stopped,reason=\"exited-normally\"" {
137
        pass "resume all, program exited normally"
138
    }
139
    -re "\\*stopped" {
140
        fail "unexpected stop"
141
    }
142
    timeout {
143
        fail "resume all, waiting for program exit (timeout)"
144
    }
145
}
146
 
147
mi_gdb_exit

powered by: WebSVN 2.1.0

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